diff mbox

[EXPERIMENTAL] ODP DPDK sync with latest ODP (partial)

Message ID 1417442870-6894-1-git-send-email-zoltan.kiss@linaro.org
State New
Headers show

Commit Message

Zoltan Kiss Dec. 1, 2014, 2:07 p.m. UTC
I've started to sync up ODP DPDK with the latest ODP, but I got stucked. These
are the changes I've made so far, they apply the following changes:

https://git.linaro.org/lng/odp.git/commitdiff/0ecee33aefdb002d0014b12ef962abe32cca0a8b
https://git.linaro.org/lng/odp.git/commitdiff/59bdddc183e3ec790bd264950023c1e3059d53b0
https://git.linaro.org/lng/odp.git/commitdiff/7a6c3779f1495166ae10697f7ae7bc26a266583f
https://git.linaro.org/lng/odp.git/commitdiff/4f7a5cbb08297b83b795521d79a4d74115a619f9
https://git.linaro.org/lng/odp.git/commitdiff/6f9938ee

You can use this in the future as a starting point to sync up to the latest ODP.
diff mbox

Patch

diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am
index fcc6619..8edd660 100644
--- a/platform/linux-dpdk/Makefile.am
+++ b/platform/linux-dpdk/Makefile.am
@@ -51,9 +51,7 @@  include_HEADERS = \
 		  $(top_srcdir)/platform/linux-generic/include/api/odp_ticketlock.h \
 		  $(top_srcdir)/platform/linux-generic/include/api/odp_time.h \
 		  $(top_srcdir)/platform/linux-generic/include/api/odp_timer.h \
-		  $(top_srcdir)/platform/linux-generic/include/api/odp_version.h \
-		  $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_socket.h \
-		  $(srcdir)/include/api/odp_pktio_types.h
+		  $(top_srcdir)/platform/linux-generic/include/api/odp_version.h
 
 subdirheadersdir = $(includedir)/helper
 subdirheaders_HEADERS = \
diff --git a/platform/linux-dpdk/include/api/odp_debug.h b/platform/linux-dpdk/include/api/odp_debug.h
index 6b145b5..b8c7f92 100644
--- a/platform/linux-dpdk/include/api/odp_debug.h
+++ b/platform/linux-dpdk/include/api/odp_debug.h
@@ -55,30 +55,76 @@  extern "C" {
 #define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(1, msg)
 
 /**
+ * ODP log level.
+ */
+typedef enum odp_log_level {
+    ODP_LOG_DBG,
+    ODP_LOG_ERR,
+    ODP_LOG_UNIMPLEMENTED,
+    ODP_LOG_ABORT,
+    ODP_LOG_PRINT
+} odp_log_level_e;
+
+/**
+ * ODP default LOG macro.
+ */
+#define ODP_LOG(level, fmt, ...) \
+do { \
+    switch (level) { \
+    case ODP_LOG_ERR: \
+        fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+        __LINE__, __func__, ##__VA_ARGS__); \
+        break; \
+    case ODP_LOG_DBG: \
+        if (ODP_DEBUG_PRINT == 1) \
+            fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+            __LINE__, __func__, ##__VA_ARGS__); \
+        break; \
+    case ODP_LOG_PRINT: \
+        fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
+        __LINE__, __func__, ##__VA_ARGS__); \
+        break; \
+    case ODP_LOG_ABORT: \
+        fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
+        __LINE__, __func__, ##__VA_ARGS__); \
+        abort(); \
+        break; \
+    case ODP_LOG_UNIMPLEMENTED: \
+        fprintf(stderr, \
+            "%s:%d:The function %s() is not implemented\n" \
+            fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
+        break; \
+    default: \
+        fprintf(stderr, "Unknown LOG level"); \
+        break;\
+    } \
+} while (0)
+
+/**
+ * Printing macro, which prints output when the application
+ * calls one of the ODP APIs specifically for dumping internal data.
+ */
+#define ODP_PRINT(fmt, ...) \
+        ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
+
+/**
  * Debug printing macro, which prints output when DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
-		do { if (ODP_DEBUG_PRINT == 1) \
-			printf(fmt, ##__VA_ARGS__); \
-		} while (0)
+        ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
 
 /**
  * Print output to stderr (file, line and function).
  */
 #define ODP_ERR(fmt, ...) \
-do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
-	__LINE__, __func__, ##__VA_ARGS__); \
-} while (0)
+        ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
 
 /**
  * Print output to stderr (file, line and function),
  * then abort.
  */
 #define ODP_ABORT(fmt, ...) \
-do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
-	__LINE__, __func__, ##__VA_ARGS__); \
-	abort(); \
-} while (0)
+        ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
 
 #ifdef __cplusplus
 }
diff --git a/platform/linux-dpdk/include/api/odp_packet.h b/platform/linux-dpdk/include/api/odp_packet.h
index 64a92e8..8cd1c5d 100644
--- a/platform/linux-dpdk/include/api/odp_packet.h
+++ b/platform/linux-dpdk/include/api/odp_packet.h
@@ -60,7 +60,7 @@  odp_packet_t odp_packet_from_buffer(odp_buffer_t buf);
  *
  * @return Buffer handle
  */
-odp_buffer_t odp_buffer_from_packet(odp_packet_t pkt);
+odp_buffer_t odp_packet_to_buffer(odp_packet_t pkt);
 
 /**
  * Set the packet length
@@ -98,53 +98,49 @@  void odp_packet_set_ctx(odp_packet_t buf, const void *ctx);
 void *odp_packet_get_ctx(odp_packet_t buf);
 
 /**
- * Get address to the start of the packet buffer
+ * Packet buffer start address
+ *
+ * Returns a pointer to the start of the packet buffer. The address is not
+ * necessarily the same as packet data address. E.g. on a received Ethernet
+ * frame, the protocol header may start 2 or 6 bytes within the buffer to
+ * ensure 32 or 64-bit alignment of the IP header.
  *
- * The address of the packet buffer is not necessarily the same as the start
- * address of the received frame, e.g. an eth frame may be offset by 2 or 6
- * bytes to ensure 32 or 64-bit alignment of the IP header.
  * Use odp_packet_l2(pkt) to get the start address of a received valid frame
- * or odp_packet_start(pkt) to get the start address even if no valid L2 header
- * could be found.
+ * or odp_packet_data(pkt) to get the current packet data address.
  *
  * @param pkt  Packet handle
  *
  * @return  Pointer to the start of the packet buffer
  *
- * @see odp_packet_l2(), odp_packet_start()
+ * @see odp_packet_l2(), odp_packet_data()
  */
-uint8_t *odp_packet_buf_addr(odp_packet_t pkt);
+uint8_t *odp_packet_addr(odp_packet_t pkt);
 
 /**
- * Get pointer to the start of the received frame
- *
- * The address of the packet buffer is not necessarily the same as the start
- * address of the received frame, e.g. an eth frame may be offset by 2 or 6
- * bytes to ensure 32 or 64-bit alignment of the IP header.
- * Use odp_packet_l2(pkt) to get the start address of a received valid eth frame
+ * Packet data address
  *
- * odp_packet_start() will always return a pointer to the start of the frame,
- * even if the frame is unrecognized and no valid L2 header could be found.
+ * Returns the current packet data address. When a packet is received from
+ * packet input, the data address points to the first byte of the packet.
  *
  * @param pkt  Packet handle
  *
- * @return  Pointer to the start of the received frame
+ * @return  Pointer to the packet data
  *
- * @see odp_packet_l2(), odp_packet_buf_addr()
+ * @see odp_packet_l2(), odp_packet_addr()
  */
-uint8_t *odp_packet_start(odp_packet_t pkt);
+uint8_t *odp_packet_data(odp_packet_t pkt);
 
 /**
  * Get pointer to the start of the L2 frame
  *
  * The L2 frame header address is not necessarily the same as the address of the
- * packet buffer, see odp_packet_buf_addr()
+ * packet buffer, see odp_packet_addr()
  *
  * @param pkt  Packet handle
  *
  * @return  Pointer to L2 header or NULL if not found
  *
- * @see odp_packet_buf_addr(), odp_packet_start()
+ * @see odp_packet_addr(), odp_packet_data()
  */
 uint8_t *odp_packet_l2(odp_packet_t pkt);
 
diff --git a/platform/linux-dpdk/include/api/odp_packet_io.h b/platform/linux-dpdk/include/api/odp_packet_io.h
index bd6868a..cf7f151 100644
--- a/platform/linux-dpdk/include/api/odp_packet_io.h
+++ b/platform/linux-dpdk/include/api/odp_packet_io.h
@@ -23,8 +23,6 @@  extern "C" {
 #include <odp_packet.h>
 #include <odp_queue.h>
 
-#include <odp_pktio_types.h>
-
 /** ODP packet IO handle */
 typedef uint32_t odp_pktio_t;
 
@@ -40,8 +38,7 @@  typedef uint32_t odp_pktio_t;
  *
  * @return ODP packet IO handle or ODP_PKTIO_INVALID on error
  */
-odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool,
-			   odp_pktio_params_t *params);
+odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool);
 
 /**
  * Close an ODP packet IO instance
diff --git a/platform/linux-dpdk/include/api/odp_pktio_types.h b/platform/linux-dpdk/include/api/odp_pktio_types.h
deleted file mode 100644
index b23e6da..0000000
--- a/platform/linux-dpdk/include/api/odp_pktio_types.h
+++ /dev/null
@@ -1,45 +0,0 @@ 
-
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#ifndef ODP_PKTIO_TYPES_H
-#define ODP_PKTIO_TYPES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* We should ensure that future enum values will never overlap, otherwise
- * applications that want netmap suport might get in trouble if the odp lib
- * was not built with netmap support and there are more types define below
- */
-
-typedef enum {
-	ODP_PKTIO_TYPE_SOCKET_BASIC = 0x1,
-	ODP_PKTIO_TYPE_SOCKET_MMSG,
-	ODP_PKTIO_TYPE_SOCKET_MMAP,
-	ODP_PKTIO_TYPE_NETMAP,
-	ODP_PKTIO_TYPE_DPDK,
-} odp_pktio_type_t;
-
-#include <odp_pktio_socket.h>
-#ifdef ODP_HAVE_NETMAP
-#include <odp_pktio_netmap.h>
-#endif
-
-typedef union odp_pktio_params_t {
-	odp_pktio_type_t type;
-	socket_params_t sock_params;
-#ifdef ODP_HAVE_NETMAP
-	netmap_params_t nm_params;
-#endif
-} odp_pktio_params_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h
index 9263349..0071e7d 100644
--- a/platform/linux-dpdk/include/odp_packet_io_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_io_internal.h
@@ -25,12 +25,21 @@  extern "C" {
 #endif
 #include <odp_packet_dpdk.h>
 
+/**
+ * Packet IO types
+ */
+typedef enum {
+	ODP_PKTIO_TYPE_SOCKET_BASIC = 0x1,
+	ODP_PKTIO_TYPE_SOCKET_MMSG,
+	ODP_PKTIO_TYPE_SOCKET_MMAP,
+} odp_pktio_type_t;
+
 struct pktio_entry {
 	odp_spinlock_t lock;		/**< entry spinlock */
 	int taken;			/**< is entry taken(1) or free(0) */
 	odp_queue_t inq_default;	/**< default input queue, if set */
 	odp_queue_t outq_default;	/**< default out queue */
-	odp_pktio_params_t params;	/**< pktio parameters */
+	odp_pktio_type_t type;		/**< pktio type */
 	pkt_dpdk_t pkt_dpdk;		/**< using DPDK API for IO */
 };
 
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
index fa10022..0dd1a65 100644
--- a/platform/linux-dpdk/odp_init.c
+++ b/platform/linux-dpdk/odp_init.c
@@ -45,7 +45,8 @@  int odp_init_dpdk(void)
 	return 0;
 }
 
-int odp_init_global(void)
+int odp_init_global(odp_init_t *params ODP_UNUSED,
+                    odp_platform_init_t *platform_params ODP_UNUSED)
 {
 	odp_thread_init_global();
 
@@ -95,9 +96,9 @@  int odp_init_global(void)
 }
 
 
-int odp_init_local(int thr_id)
+int odp_init_local(void)
 {
-	odp_thread_init_local(thr_id);
+	odp_thread_init_local();
 
 	if (odp_pktio_init_local()) {
 		ODP_ERR("ODP packet io local init failed.\n");
diff --git a/platform/linux-dpdk/odp_linux.c b/platform/linux-dpdk/odp_linux.c
index 96c91a5..72f0723 100644
--- a/platform/linux-dpdk/odp_linux.c
+++ b/platform/linux-dpdk/odp_linux.c
@@ -35,7 +35,7 @@  static void *odp_run_start_routine(void *arg)
 	odp_start_args_t *start_args = arg;
 
 	/* ODP thread local init */
-	odp_init_local(start_args->thr_id);
+	odp_init_local();
 
 	return start_args->start_routine(start_args->arg);
 }
@@ -66,7 +66,6 @@  void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, int num,
 		start_args->start_routine = start_routine;
 		start_args->arg           = arg;
 
-		odp_thread_create(cpu);
 		start_args->thr_id = cpu;
 		/* If not master core */
 		if (cpu != 0) {
diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c
index a1443dc..1f6b70d 100644
--- a/platform/linux-dpdk/odp_packet.c
+++ b/platform/linux-dpdk/odp_packet.c
@@ -41,7 +41,7 @@  odp_packet_t odp_packet_from_buffer(odp_buffer_t buf)
 	return (odp_packet_t)buf;
 }
 
-odp_buffer_t odp_buffer_from_packet(odp_packet_t pkt)
+odp_buffer_t odp_packet_to_buffer(odp_packet_t pkt)
 {
 	return (odp_buffer_t)pkt;
 }
@@ -88,12 +88,12 @@  size_t odp_packet_get_len(odp_packet_t pkt)
 	return mb->pkt_len;
 }
 
-uint8_t *odp_packet_buf_addr(odp_packet_t pkt)
+uint8_t *odp_packet_addr(odp_packet_t pkt)
 {
-	return odp_buffer_addr(odp_buffer_from_packet(pkt));
+	return odp_buffer_addr(odp_packet_to_buffer(pkt));
 }
 
-uint8_t *odp_packet_start(odp_packet_t pkt)
+uint8_t *odp_packet_data(odp_packet_t pkt)
 {
 	struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
 	return ((uint8_t *)(mb->buf_addr) + mb->data_off);
@@ -107,7 +107,7 @@  uint8_t *odp_packet_l2(odp_packet_t pkt)
 	if (odp_unlikely(offset == ODP_PACKET_OFFSET_INVALID))
 		return NULL;
 
-	return odp_packet_start(pkt) + offset;
+	return odp_packet_data(pkt) + offset;
 }
 
 size_t odp_packet_l2_offset(odp_packet_t pkt)
@@ -127,7 +127,7 @@  uint8_t *odp_packet_l3(odp_packet_t pkt)
 	if (odp_unlikely(offset == ODP_PACKET_OFFSET_INVALID))
 		return NULL;
 
-	return odp_packet_start(pkt) + offset;
+	return odp_packet_data(pkt) + offset;
 }
 
 size_t odp_packet_l3_offset(odp_packet_t pkt)
@@ -147,7 +147,7 @@  uint8_t *odp_packet_l4(odp_packet_t pkt)
 	if (odp_unlikely(offset == ODP_PACKET_OFFSET_INVALID))
 		return NULL;
 
-	return odp_packet_start(pkt) + offset;
+	return odp_packet_data(pkt) + offset;
 }
 
 size_t odp_packet_l4_offset(odp_packet_t pkt)
@@ -200,7 +200,7 @@  void odp_packet_parse(odp_packet_t pkt, size_t len, size_t frame_offset)
 	pkt_hdr->input_flags.l2 = 1;
 	pkt_hdr->l2_offset = 0;
 
-	eth = (odph_ethhdr_t *)odp_packet_start(pkt);
+	eth = (odph_ethhdr_t *)odp_packet_data(pkt);
 	ethtype = odp_be_to_cpu_16(eth->type);
 	vlan = (odph_vlanhdr_t *)&eth->type;
 
@@ -367,7 +367,7 @@  void odp_packet_print(odp_packet_t pkt)
 	printf("\n%s\n", str);
 	rte_pktmbuf_dump(stdout, &hdr->buf_hdr.mb, 32);
 
-	p = odp_packet_start(pkt);
+	p = odp_packet_data(pkt);
 	printf("00000000: %02X %02X %02X %02X %02X %02X %02X %02X\n",
 	       p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
 	printf("00000008: %02X %02X %02X %02X %02X %02X %02X %02X\n",
diff --git a/platform/linux-dpdk/odp_packet_io.c b/platform/linux-dpdk/odp_packet_io.c
index 79394bb..7b088ca 100644
--- a/platform/linux-dpdk/odp_packet_io.c
+++ b/platform/linux-dpdk/odp_packet_io.c
@@ -22,7 +22,6 @@ 
 #include <odp_schedule_internal.h>
 #include <odp_debug.h>
 
-#include <odp_pktio_socket.h>
 #ifdef ODP_HAVE_NETMAP
 #include <odp_pktio_netmap.h>
 #endif
@@ -115,16 +114,14 @@  static void unlock_entry(pktio_entry_t *entry)
 	odp_spinlock_unlock(&entry->s.lock);
 }
 
-static void init_pktio_entry(pktio_entry_t *entry, odp_pktio_params_t *params)
+static void init_pktio_entry(pktio_entry_t *entry)
 {
 	set_taken(entry);
 	entry->s.inq_default = ODP_QUEUE_INVALID;
 	memset(&entry->s.pkt_dpdk, 0, sizeof(entry->s.pkt_dpdk));
-	/* Save pktio parameters, type is the most useful */
-	memcpy(&entry->s.params, params, sizeof(*params));
 }
 
-static odp_pktio_t alloc_lock_pktio_entry(odp_pktio_params_t *params)
+static odp_pktio_t alloc_lock_pktio_entry(void)
 {
 	odp_pktio_t id;
 	pktio_entry_t *entry;
@@ -135,7 +132,7 @@  static odp_pktio_t alloc_lock_pktio_entry(odp_pktio_params_t *params)
 		if (is_free(entry)) {
 			lock_entry(entry);
 			if (is_free(entry)) {
-				init_pktio_entry(entry, params);
+				init_pktio_entry(entry);
 				id = i + 1;
 				return id; /* return with entry locked! */
 			}
@@ -158,21 +155,15 @@  static int free_pktio_entry(odp_pktio_t id)
 	return 0;
 }
 
-odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool,
-			   odp_pktio_params_t *params)
+odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool)
 {
 	odp_pktio_t id;
 	pktio_entry_t *pktio_entry;
 	int res;
 
-	if (params == NULL) {
-		ODP_ERR("Invalid pktio params\n");
-		return ODP_PKTIO_INVALID;
-	}
-
 	ODP_DBG("Allocating dpdk pktio\n");
 
-	id = alloc_lock_pktio_entry(params);
+	id = alloc_lock_pktio_entry();
 	if (id == ODP_PKTIO_INVALID) {
 		ODP_ERR("No resources available.\n");
 		return ODP_PKTIO_INVALID;
@@ -377,11 +368,11 @@  odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry)
 
 		if (pkts > 0) {
 			pkt = pkt_tbl[0];
-			buf = odp_buffer_from_packet(pkt);
+			buf = odp_packet_to_buffer(pkt);
 			buf_hdr = odp_buf_to_hdr(buf);
 
 			for (i = 1, j = 0; i < pkts; ++i) {
-				buf = odp_buffer_from_packet(pkt_tbl[i]);
+				buf = odp_packet_to_buffer(pkt_tbl[i]);
 				tmp_hdr_tbl[j++] = odp_buf_to_hdr(buf);
 			}
 			queue_enq_multi(qentry, tmp_hdr_tbl, j);
@@ -413,7 +404,7 @@  int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num)
 				      QUEUE_MULTI_MAX);
 		if (pkts > 0) {
 			for (i = 0; i < pkts; ++i) {
-				buf = odp_buffer_from_packet(pkt_tbl[i]);
+				buf = odp_packet_to_buffer(pkt_tbl[i]);
 				tmp_hdr_tbl[i] = odp_buf_to_hdr(buf);
 			}
 			queue_enq_multi(qentry, tmp_hdr_tbl, pkts);