Skip to contentSkip to conversation

librte_port: modify macros to access packet meta-data

PATCH Applied [email protected] 3 participants 10 messages Sep 11, 2015 – Oct 20, 2015

lore
Share & tools
lore
#0 lore raw

cover librte_port: modify macros to access packet meta-data

From: Fan Zhang <[email protected]>

This patchset links to ABI change announced for librte_port. Macros to access the packet meta-data stored within the packet buffer has been adjusted to cover the packet mbuf structure.

Fan Zhang (4):
librte_port: modify macros to access packet meta-data app/test: modify table and pipeline test app/test_pipeline: modify pipeline test
librte_port: modify release notes and deprecation notice

 app/test-pipeline/main.h              |  2 ++
 app/test-pipeline/pipeline_hash.c     | 34 ++++++++++++++-------------
 app/test-pipeline/pipeline_lpm.c      |  2 +-
 app/test-pipeline/pipeline_lpm_ipv6.c |  2 +-
 app/test/test_table.h                 |  8 +++++--
 app/test/test_table_combined.c        | 28 +++++++++++-----------
 app/test/test_table_pipeline.c        |  3 ++-
 app/test/test_table_tables.c          | 44 ++++++++++++++++++-----------------
 doc/guides/rel_notes/deprecation.rst  |  5 ----
 doc/guides/rel_notes/release_2_2.rst  |  4 +++-
 lib/librte_port/Makefile              |  2 +-
 lib/librte_port/rte_port.h            |  2 +-
 12 files changed, 72 insertions(+), 64 deletions(-)

--
2.1.0

#1 lore raw

PATCH 1/4 librte_port: modify macros to access packet meta-data

From: Fan Zhang <[email protected]>

This patch relates to ABI change proposed for librte_port. Macros to access the packet meta-data stored within the packet buffer has been adjusted to cover the packet mbuf structure.

---
 lib/librte_port/rte_port.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_port/rte_port.h +1 -1
index 396c7e9..00b97a9 100644
@@ -55,7 +55,7 @@ extern "C" {
  * just beyond the end of the mbuf data structure returned by a port
  */
 #define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)          \
-	(&((uint8_t *) &(mbuf)[1])[offset])
+	(&((uint8_t *)(mbuf))[offset])
 #define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset)         \
 	((uint16_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
 #define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset)         \
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/4 app/test: modify table and pipeline test

In reply to [email protected]

From: Fan Zhang <[email protected]>

Test_table has been modified to work on updated macros to access meta-data stored in the mbuf structure.

---
 app/test/test_table.h          |  8 ++++++--
 app/test/test_table_combined.c | 28 +++++++++++++--------------
 app/test/test_table_pipeline.c |  3 ++-
 app/test/test_table_tables.c   | 44 ++++++++++++++++++++++--------------------
 4 files changed, 45 insertions(+), 38 deletions(-)
app/test/test_table.h +6 -2
index accc6f8..2077893 100644
@@ -78,6 +78,8 @@
 #define MP_FLAGS            0
 
 /* Macros */
+#define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
+
 #define RING_ENQUEUE(ring, value) do {					\
 	struct rte_mbuf *m;						\
 	uint32_t *k32, *signature;					\
@@ -86,8 +88,10 @@
 	m = rte_pktmbuf_alloc(pool);					\
 	if (m == NULL)							\
 		return -1;						\
-	signature = RTE_MBUF_METADATA_UINT32_PTR(m, 0);			\
-	key = RTE_MBUF_METADATA_UINT8_PTR(m, 32);			\
+	signature = RTE_MBUF_METADATA_UINT32_PTR(m,			\
+			APP_METADATA_OFFSET(0));		\
+	key = RTE_MBUF_METADATA_UINT8_PTR(m,			\
+			APP_METADATA_OFFSET(32));		\
 	k32 = (uint32_t *) key;						\
 	k32[0] = (value);						\
 	*signature = pipeline_test_hash(key, 0, 0);			\
app/test/test_table_combined.c +14 -14
index dd09da5..5da005b 100644
@@ -295,7 +295,7 @@ test_table_lpm_combined(void)
 	struct rte_table_lpm_params lpm_params = {
 		.n_rules = 1 << 16,
 		.entry_unique_size = 8,
-		.offset = 0,
+		.offset = APP_METADATA_OFFSET(0),
 	};
 
 	struct rte_table_lpm_key lpm_key = {
@@ -355,7 +355,7 @@ test_table_lpm_ipv6_combined(void)
 		.n_rules = 1 << 16,
 		.number_tbl8s = 1 << 13,
 		.entry_unique_size = 8,
-		.offset = 32,
+		.offset = APP_METADATA_OFFSET(32),
 	};
 
 	struct rte_table_lpm_ipv6_key lpm_ipv6_key = {
@@ -417,8 +417,8 @@ test_table_hash8lru(void)
 		.n_entries = 1<<24,
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
-		.signature_offset = 0,
-		.key_offset = 32,
+		.signature_offset = APP_METADATA_OFFSET(0),
+		.key_offset = APP_METADATA_OFFSET(32),
 	};
 
 	uint8_t key8lru[8];
@@ -475,8 +475,8 @@ test_table_hash16lru(void)
 		.n_entries = 1<<16,
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
-		.signature_offset = 0,
-		.key_offset = 32,
+		.signature_offset = APP_METADATA_OFFSET(0),
+		.key_offset = APP_METADATA_OFFSET(32),
 	};
 
 	uint8_t key16lru[16];
@@ -533,8 +533,8 @@ test_table_hash32lru(void)
 		.n_entries = 1<<16,
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
-		.signature_offset = 0,
-		.key_offset = 32,
+		.signature_offset = APP_METADATA_OFFSET(0),
+		.key_offset = APP_METADATA_OFFSET(32),
 	};
 
 	uint8_t key32lru[32];
@@ -592,8 +592,8 @@ test_table_hash8ext(void)
 		.n_entries_ext = 1<<15,
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
-		.signature_offset = 0,
-		.key_offset = 32,
+		.signature_offset = APP_METADATA_OFFSET(0),
+		.key_offset = APP_METADATA_OFFSET(32),
 	};
 
 	uint8_t key8ext[8];
@@ -658,8 +658,8 @@ test_table_hash16ext(void)
 		.n_entries_ext = 1<<15,
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
-		.signature_offset = 0,
-		.key_offset = 32,
+		.signature_offset = APP_METADATA_OFFSET(0),
+		.key_offset = APP_METADATA_OFFSET(32),
 	};
 
 	uint8_t key16ext[16];
@@ -724,8 +724,8 @@ test_table_hash32ext(void)
 		.n_entries_ext = 1<<15,
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
-		.signature_offset = 0,
-		.key_offset = 32,
+		.signature_offset = APP_METADATA_OFFSET(0),
+		.key_offset = APP_METADATA_OFFSET(32),
 	};
 
 	uint8_t key32ext[32];
app/test/test_table_pipeline.c +2 -1
index a0a9e04..ff07cda 100644
@@ -457,7 +457,8 @@ test_pipeline_single_filter(int test_type, int expected_count)
 				rte_panic("Failed to alloc mbuf from pool\n");
 				return -1;
 			}
-			key = RTE_MBUF_METADATA_UINT8_PTR(m, 32);
+			key = RTE_MBUF_METADATA_UINT8_PTR(m,
+					APP_METADATA_OFFSET(32));
 
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
app/test/test_table_tables.c +23 -21

134 lines not on this page · raw message

Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/4 app/test_pipeline: modify pipeline test

In reply to [email protected]

From: Fan Zhang <[email protected]>

Test_pipeline has been modified to work on updated macros to access meta-data stored in the mbuf structure.

---
 app/test-pipeline/main.h              |  2 ++
 app/test-pipeline/pipeline_hash.c     | 34 ++++++++++++++++++----------------
 app/test-pipeline/pipeline_lpm.c      |  2 +-
 app/test-pipeline/pipeline_lpm_ipv6.c |  2 +-
 4 files changed, 22 insertions(+), 18 deletions(-)
app/test-pipeline/main.h +2 -0
index 0c90fc3..8dcd459 100644
@@ -137,4 +137,6 @@ void app_main_loop_tx(void);
 #define APP_FLUSH 0x3FF
 #endif
 
+#define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
+
 #endif /* _MAIN_H_ */
app/test-pipeline/pipeline_hash.c +18 -16
index 548615f..5e4e17f 100644
@@ -163,8 +163,8 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_buckets_ext = 1 << 21,
 			.f_hash = test_hash,
 			.seed = 0,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 		};
 
 		struct rte_pipeline_table_params table_params = {
@@ -214,8 +214,8 @@ app_main_loop_worker_pipeline_hash(void) {
 		struct rte_table_hash_key8_ext_params table_hash_params = {
 			.n_entries = 1 << 24,
 			.n_entries_ext = 1 << 23,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -238,8 +238,8 @@ app_main_loop_worker_pipeline_hash(void) {
 	{
 		struct rte_table_hash_key8_lru_params table_hash_params = {
 			.n_entries = 1 << 24,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -263,8 +263,8 @@ app_main_loop_worker_pipeline_hash(void) {
 		struct rte_table_hash_key16_ext_params table_hash_params = {
 			.n_entries = 1 << 24,
 			.n_entries_ext = 1 << 23,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -287,8 +287,8 @@ app_main_loop_worker_pipeline_hash(void) {
 	{
 		struct rte_table_hash_key16_lru_params table_hash_params = {
 			.n_entries = 1 << 24,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -312,8 +312,8 @@ app_main_loop_worker_pipeline_hash(void) {
 		struct rte_table_hash_key32_ext_params table_hash_params = {
 			.n_entries = 1 << 24,
 			.n_entries_ext = 1 << 23,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -337,8 +337,8 @@ app_main_loop_worker_pipeline_hash(void) {
 	{
 		struct rte_table_hash_key32_lru_params table_hash_params = {
 			.n_entries = 1 << 24,
-			.signature_offset = 0,
-			.key_offset = 32,
+			.signature_offset = APP_METADATA_OFFSET(0),
+			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -456,8 +456,10 @@ app_main_loop_rx_metadata(void) {
 
 			m = app.mbuf_rx.array[j];
 			m_data = rte_pktmbuf_mtod(m, uint8_t *);
-			signature = RTE_MBUF_METADATA_UINT32_PTR(m, 0);
-			key = RTE_MBUF_METADATA_UINT8_PTR(m, 32);
+			signature = RTE_MBUF_METADATA_UINT32_PTR(m,
+					APP_METADATA_OFFSET(0));
+			key = RTE_MBUF_METADATA_UINT8_PTR(m,
+					APP_METADATA_OFFSET(32));
 
 			if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
 				ip_hdr = (struct ipv4_hdr *)
app/test-pipeline/pipeline_lpm.c +1 -1
index b1a2c13..e098f8b 100644
@@ -115,7 +115,7 @@ app_main_loop_worker_pipeline_lpm(void) {
 			.n_rules = 1 << 24,
 			.entry_unique_size =
 				sizeof(struct rte_pipeline_table_entry),
-			.offset = 32,
+			.offset = APP_METADATA_OFFSET(32),
 		};
 
 		struct rte_pipeline_table_params table_params = {
app/test-pipeline/pipeline_lpm_ipv6.c +1 -1
index 3f24a2d..a5cd3a4 100644
@@ -117,7 +117,7 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) {
 			.number_tbl8s = 1 << 21,
 			.entry_unique_size =
 				sizeof(struct rte_pipeline_table_entry),
-			.offset = 32,
+			.offset = APP_METADATA_OFFSET(32),
 		};
 
 		struct rte_pipeline_table_params table_params = {
Signature · 1 line
2.1.0
#4 lore raw

PATCH 4/4 librte_port: modify release notes and deprecation notice

In reply to [email protected]

From: Fan Zhang <[email protected]>

The LIBABIVER number is incremented. The release notes is updated and the deprecation announce is removed.

---
 doc/guides/rel_notes/deprecation.rst | 5 -----
 doc/guides/rel_notes/release_2_2.rst | 4 +++-
 lib/librte_port/Makefile             | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -5
index fffad80..d08ba63 100644
@@ -52,11 +52,6 @@ Deprecation Notices
   the value of macros CFG_NAME_LEN and CFG_NAME_VAL will be increased.
   Most likely, the new values will be 64 and 256, respectively.
 
-* librte_port: Macros to access the packet meta-data stored within the
-  packet buffer will be adjusted to cover the packet mbuf structure as well,
-  as currently they are able to access any packet buffer location except the
-  packet mbuf structure.
-
 * librte_table LPM: A new parameter to hold the table name will be added to
   the LPM table parameter structure.
 
doc/guides/rel_notes/release_2_2.rst +3 -1
index 682f468..4d945db 100644
@@ -47,6 +47,8 @@ ABI Changes
 
 * The LPM structure is changed. The deprecated field mem_location is removed.
 
+* librte_port: Macros to access the packet meta-data stored within the packet
+  buffer has been adjusted to cover the packet mbuf structure.
 
 Shared Library Versions
 -----------------------
@@ -74,7 +76,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pipeline.so.1
      librte_pmd_bond.so.1
    + librte_pmd_ring.so.2
-     librte_port.so.1
+     librte_port.so.2
      librte_power.so.1
      librte_reorder.so.1
      librte_ring.so.1
lib/librte_port/Makefile +1 -1
index ddbb383..410053e 100644
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
 
 EXPORT_MAP := rte_port_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
Signature · 1 line
2.1.0
#5 lore raw

Re: [PATCH 4/4] librte_port: modify release notes and deprecation notice

2015-09-11 14:35, [email protected]:

doc/guides/rel_notes/release_2_2.rst The libraries prepended with a plus sign were incremented in this version. · line 79

Quoted 6 lines
doc/guides/rel_notes/release_2_2.rst +1 -1
@@ -74,7 +76,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pipeline.so.1
      librte_pmd_bond.so.1
    + librte_pmd_ring.so.2
-     librte_port.so.1
+     librte_port.so.2

The updated library must be prepended with a plus sign. Will be fixed before squashing with path 1 and pushing.

Acked-by on the v1 series
#6 lore raw
In reply to [email protected]
Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, September 11, 2015 4:36 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/4]librte_port: modify macros to access packet meta-data

Quoted 6 lines

From: Fan Zhang <[email protected]>

This patchset links to ABI change announced for librte_port. Macros to access the packet meta-data stored within the packet buffer has been adjusted to cover the packet mbuf structure.

#7 lore raw
Quoted 7 lines
Quoted 5 lines

From: Fan Zhang <[email protected]>

This patchset links to ABI change announced for librte_port. Macros to access the packet meta-data stored within the packet buffer has been adjusted to cover the packet mbuf structure.

Applied in 1 commit (such change must be atomic), thanks

#8 lore raw
In reply to [email protected]

2015-09-11 14:35, [email protected]:

Quoted 4 lines
 app/test-pipeline/main.h              |  2 ++
 app/test-pipeline/pipeline_hash.c     | 34 ++++++++++++++-------------
 app/test-pipeline/pipeline_lpm.c      |  2 +-
 app/test-pipeline/pipeline_lpm_ipv6.c |  2 +-
Quoted 8 lines
 app/test/test_table.h                 |  8 +++++--
 app/test/test_table_combined.c        | 28 +++++++++++-----------
 app/test/test_table_pipeline.c        |  3 ++-
 app/test/test_table_tables.c          | 44 ++++++++++++++++++-----------------
 doc/guides/rel_notes/deprecation.rst  |  5 ----
 doc/guides/rel_notes/release_2_2.rst  |  4 +++-
 lib/librte_port/Makefile              |  2 +-
 lib/librte_port/rte_port.h            |  2 +-

examples/ip_pipeline does not need to be updated?

#9 lore raw
Quoted 19 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, October 19, 2015 6:00 PM
To: Zhang, Roy Fan <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH 0/4]librte_port: modify macros to access packet meta-data

2015-09-11 14:35, [email protected]:

Quoted 8 lines
 app/test-pipeline/main.h              |  2 ++
 app/test-pipeline/pipeline_hash.c     | 34 ++++++++++++++-------------
 app/test-pipeline/pipeline_lpm.c      |  2 +-
 app/test-pipeline/pipeline_lpm_ipv6.c |  2 +-
 app/test/test_table.h                 |  8 +++++--
 app/test/test_table_combined.c        | 28 +++++++++++-----------
 app/test/test_table_pipeline.c        |  3 ++-
 app/test/test_table_tables.c          | 44 ++++++++++++++++++---------------
Quoted 7 lines

--

Quoted 4 lines
 doc/guides/rel_notes/deprecation.rst  |  5 ----
 doc/guides/rel_notes/release_2_2.rst  |  4 +++-
 lib/librte_port/Makefile              |  2 +-
 lib/librte_port/rte_port.h            |  2 +-

examples/ip_pipeline does not need to be updated?

No, examples/ip_pipeline does not need to be updated here, so no issues with this patch.

Only apps that define a hardcoded structure for the app metadata need update (app/test, app/test-pipeline), ip_pipeline reads metadata offsets from config file, so it's OK (as current simple config file does not have any offsets).

Thanks,
Cristian