diff mbox series

[2/4] example: ipsef_offload: port to odpthreads helpers

Message ID 20170221224127.31314-2-dmitry.ereminsolenikov@linaro.org
State New
Headers show
Series [1/4] example: ipsec_offload: enable compilation | expand

Commit Message

Dmitry Eremin-Solenikov Feb. 21, 2017, 10:41 p.m. UTC
Switch from old linux-pthread API to odpthread.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
 example/ipsec_offload/odp_ipsec_offload.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

-- 
2.11.0
diff mbox series

Patch

diff --git a/example/ipsec_offload/odp_ipsec_offload.c b/example/ipsec_offload/odp_ipsec_offload.c
index 4a494d07..001e7038 100644
--- a/example/ipsec_offload/odp_ipsec_offload.c
+++ b/example/ipsec_offload/odp_ipsec_offload.c
@@ -22,7 +22,7 @@ 
 #include <example_debug.h>
 
 #include <odp_api.h>
-#include <odp/helper/linux.h>
+#include <odp/helper/threads.h>
 #include <odp/helper/eth.h>
 #include <odp/helper/ip.h>
 #include <odp/helper/icmp.h>
@@ -30,6 +30,7 @@ 
 #include <odp/helper/ipsec.h>
 
 #include <stdbool.h>
+#include <inttypes.h>
 #include <sys/socket.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
@@ -414,12 +415,12 @@  pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt)
  *  - Input interfaces (i.e. new work)
  *  - Per packet ipsec API completion queue
  *
- * @param arg  Required by "odph_linux_pthread_create", unused
+ * @param arg  Required by "odph_odpthreads_create", unused
  *
- * @return NULL (should never return)
+ * @return 0 (should never return)
  */
 static
-void *pktio_thread(void *arg EXAMPLE_UNUSED)
+int pktio_thread(void *arg EXAMPLE_UNUSED)
 {
 	int thr;
 	odp_packet_t pkt;
@@ -490,7 +491,7 @@  void *pktio_thread(void *arg EXAMPLE_UNUSED)
 			out_port = (odp_out_entry_t *)odp_packet_user_ptr(out_pkt);
 			out_queue = (odp_pktout_queue_t)out_port->pktout;
 
-			eth = (odph_ethhdr_t *)((void *)ip - sizeof(odph_ethhdr_t));
+			eth = (odph_ethhdr_t *)((uint8_t *)ip - sizeof(odph_ethhdr_t));
 			eth->dst = out_port->next_hop_addr;
 			eth->src = out_port->addr;
 			eth->type = odp_cpu_to_be_16(0x800);
@@ -505,7 +506,7 @@  void *pktio_thread(void *arg EXAMPLE_UNUSED)
 	}
 
 	/* unreachable */
-	return NULL;
+	return 0;
 }
 
 /**
@@ -514,7 +515,7 @@  void *pktio_thread(void *arg EXAMPLE_UNUSED)
 int
 main(int argc, char *argv[])
 {
-	odph_linux_pthread_t thread_tbl[MAX_WORKERS];
+	odph_odpthread_t thread_tbl[MAX_WORKERS];
 	int i;
 	odp_shm_t shm;
 	odp_cpumask_t cpumask;
@@ -522,7 +523,7 @@  main(int argc, char *argv[])
 	odp_pool_param_t params;
 	odp_queue_param_t qparam;
 	odp_instance_t instance;
-	odph_linux_thr_params_t thr_params;
+	odph_odpthread_params_t thr_params;
 	odp_ipsec_config_t config;
 	odp_ipsec_capability_t capa;
 
@@ -642,9 +643,9 @@  main(int argc, char *argv[])
 	thr_params.instance = instance;
 
 	/* Create and initialize worker threads */
-	odph_linux_pthread_create(thread_tbl, &cpumask,
+	odph_odpthreads_create(thread_tbl, &cpumask,
 					  &thr_params);
-	odph_linux_pthread_join(thread_tbl, num_workers);
+	odph_odpthreads_join(thread_tbl);
 
 	free(args->appl.if_names);
 	free(args->appl.if_str);