port: move metadata offset reference at mbuf head

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.

The LIBABIVER number is incremented.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
Fan Zhang 2015-09-11 14:35:45 +01:00 committed by Thomas Monjalon
parent 5aaf45e09a
commit ba92d511dd
12 changed files with 74 additions and 64 deletions

View File

@ -137,4 +137,6 @@ void app_main_loop_tx(void);
#define APP_FLUSH 0x3FF #define APP_FLUSH 0x3FF
#endif #endif
#define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
#endif /* _MAIN_H_ */ #endif /* _MAIN_H_ */

View File

@ -163,8 +163,8 @@ app_main_loop_worker_pipeline_hash(void) {
.n_buckets_ext = 1 << 21, .n_buckets_ext = 1 << 21,
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
struct rte_pipeline_table_params table_params = { 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 = { struct rte_table_hash_key8_ext_params table_hash_params = {
.n_entries = 1 << 24, .n_entries = 1 << 24,
.n_entries_ext = 1 << 23, .n_entries_ext = 1 << 23,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
}; };
@ -238,8 +238,8 @@ app_main_loop_worker_pipeline_hash(void) {
{ {
struct rte_table_hash_key8_lru_params table_hash_params = { struct rte_table_hash_key8_lru_params table_hash_params = {
.n_entries = 1 << 24, .n_entries = 1 << 24,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
}; };
@ -263,8 +263,8 @@ app_main_loop_worker_pipeline_hash(void) {
struct rte_table_hash_key16_ext_params table_hash_params = { struct rte_table_hash_key16_ext_params table_hash_params = {
.n_entries = 1 << 24, .n_entries = 1 << 24,
.n_entries_ext = 1 << 23, .n_entries_ext = 1 << 23,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
}; };
@ -287,8 +287,8 @@ app_main_loop_worker_pipeline_hash(void) {
{ {
struct rte_table_hash_key16_lru_params table_hash_params = { struct rte_table_hash_key16_lru_params table_hash_params = {
.n_entries = 1 << 24, .n_entries = 1 << 24,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
}; };
@ -312,8 +312,8 @@ app_main_loop_worker_pipeline_hash(void) {
struct rte_table_hash_key32_ext_params table_hash_params = { struct rte_table_hash_key32_ext_params table_hash_params = {
.n_entries = 1 << 24, .n_entries = 1 << 24,
.n_entries_ext = 1 << 23, .n_entries_ext = 1 << 23,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
}; };
@ -337,8 +337,8 @@ app_main_loop_worker_pipeline_hash(void) {
{ {
struct rte_table_hash_key32_lru_params table_hash_params = { struct rte_table_hash_key32_lru_params table_hash_params = {
.n_entries = 1 << 24, .n_entries = 1 << 24,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
.f_hash = test_hash, .f_hash = test_hash,
.seed = 0, .seed = 0,
}; };
@ -456,8 +456,10 @@ app_main_loop_rx_metadata(void) {
m = app.mbuf_rx.array[j]; m = app.mbuf_rx.array[j];
m_data = rte_pktmbuf_mtod(m, uint8_t *); m_data = rte_pktmbuf_mtod(m, uint8_t *);
signature = RTE_MBUF_METADATA_UINT32_PTR(m, 0); signature = RTE_MBUF_METADATA_UINT32_PTR(m,
key = RTE_MBUF_METADATA_UINT8_PTR(m, 32); APP_METADATA_OFFSET(0));
key = RTE_MBUF_METADATA_UINT8_PTR(m,
APP_METADATA_OFFSET(32));
if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) { if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
ip_hdr = (struct ipv4_hdr *) ip_hdr = (struct ipv4_hdr *)

View File

@ -116,7 +116,7 @@ app_main_loop_worker_pipeline_lpm(void) {
.n_rules = 1 << 24, .n_rules = 1 << 24,
.entry_unique_size = .entry_unique_size =
sizeof(struct rte_pipeline_table_entry), sizeof(struct rte_pipeline_table_entry),
.offset = 32, .offset = APP_METADATA_OFFSET(32),
}; };
struct rte_pipeline_table_params table_params = { struct rte_pipeline_table_params table_params = {

View File

@ -118,7 +118,7 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) {
.number_tbl8s = 1 << 21, .number_tbl8s = 1 << 21,
.entry_unique_size = .entry_unique_size =
sizeof(struct rte_pipeline_table_entry), sizeof(struct rte_pipeline_table_entry),
.offset = 32, .offset = APP_METADATA_OFFSET(32),
}; };
struct rte_pipeline_table_params table_params = { struct rte_pipeline_table_params table_params = {

View File

@ -78,6 +78,8 @@
#define MP_FLAGS 0 #define MP_FLAGS 0
/* Macros */ /* Macros */
#define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
#define RING_ENQUEUE(ring, value) do { \ #define RING_ENQUEUE(ring, value) do { \
struct rte_mbuf *m; \ struct rte_mbuf *m; \
uint32_t *k32, *signature; \ uint32_t *k32, *signature; \
@ -86,8 +88,10 @@
m = rte_pktmbuf_alloc(pool); \ m = rte_pktmbuf_alloc(pool); \
if (m == NULL) \ if (m == NULL) \
return -1; \ return -1; \
signature = RTE_MBUF_METADATA_UINT32_PTR(m, 0); \ signature = RTE_MBUF_METADATA_UINT32_PTR(m, \
key = RTE_MBUF_METADATA_UINT8_PTR(m, 32); \ APP_METADATA_OFFSET(0)); \
key = RTE_MBUF_METADATA_UINT8_PTR(m, \
APP_METADATA_OFFSET(32)); \
k32 = (uint32_t *) key; \ k32 = (uint32_t *) key; \
k32[0] = (value); \ k32[0] = (value); \
*signature = pipeline_test_hash(key, 0, 0); \ *signature = pipeline_test_hash(key, 0, 0); \

View File

@ -296,7 +296,7 @@ test_table_lpm_combined(void)
.name = "LPM", .name = "LPM",
.n_rules = 1 << 16, .n_rules = 1 << 16,
.entry_unique_size = 8, .entry_unique_size = 8,
.offset = 0, .offset = APP_METADATA_OFFSET(0),
}; };
struct rte_table_lpm_key lpm_key = { struct rte_table_lpm_key lpm_key = {
@ -357,7 +357,7 @@ test_table_lpm_ipv6_combined(void)
.n_rules = 1 << 16, .n_rules = 1 << 16,
.number_tbl8s = 1 << 13, .number_tbl8s = 1 << 13,
.entry_unique_size = 8, .entry_unique_size = 8,
.offset = 32, .offset = APP_METADATA_OFFSET(32),
}; };
struct rte_table_lpm_ipv6_key lpm_ipv6_key = { struct rte_table_lpm_ipv6_key lpm_ipv6_key = {
@ -419,8 +419,8 @@ test_table_hash8lru(void)
.n_entries = 1<<24, .n_entries = 1<<24,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
uint8_t key8lru[8]; uint8_t key8lru[8];
@ -477,8 +477,8 @@ test_table_hash16lru(void)
.n_entries = 1<<16, .n_entries = 1<<16,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
uint8_t key16lru[16]; uint8_t key16lru[16];
@ -535,8 +535,8 @@ test_table_hash32lru(void)
.n_entries = 1<<16, .n_entries = 1<<16,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
uint8_t key32lru[32]; uint8_t key32lru[32];
@ -594,8 +594,8 @@ test_table_hash8ext(void)
.n_entries_ext = 1<<15, .n_entries_ext = 1<<15,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
uint8_t key8ext[8]; uint8_t key8ext[8];
@ -660,8 +660,8 @@ test_table_hash16ext(void)
.n_entries_ext = 1<<15, .n_entries_ext = 1<<15,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
uint8_t key16ext[16]; uint8_t key16ext[16];
@ -726,8 +726,8 @@ test_table_hash32ext(void)
.n_entries_ext = 1<<15, .n_entries_ext = 1<<15,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 0, .signature_offset = APP_METADATA_OFFSET(0),
.key_offset = 32, .key_offset = APP_METADATA_OFFSET(32),
}; };
uint8_t key32ext[32]; uint8_t key32ext[32];

View File

@ -457,7 +457,8 @@ test_pipeline_single_filter(int test_type, int expected_count)
rte_panic("Failed to alloc mbuf from pool\n"); rte_panic("Failed to alloc mbuf from pool\n");
return -1; 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 = (uint32_t *) key;
k32[0] = 0xadadadad >> (j % 2); k32[0] = 0xadadadad >> (j % 2);

View File

@ -52,8 +52,10 @@ table_test table_tests[] = {
uint32_t *k32, *signature; \ uint32_t *k32, *signature; \
uint8_t *key; \ uint8_t *key; \
mbuf = rte_pktmbuf_alloc(pool); \ mbuf = rte_pktmbuf_alloc(pool); \
signature = RTE_MBUF_METADATA_UINT32_PTR(mbuf, 0); \ signature = RTE_MBUF_METADATA_UINT32_PTR(mbuf, \
key = RTE_MBUF_METADATA_UINT8_PTR(mbuf, 32); \ APP_METADATA_OFFSET(0)); \
key = RTE_MBUF_METADATA_UINT8_PTR(mbuf, \
APP_METADATA_OFFSET(32)); \
memset(key, 0, 32); \ memset(key, 0, 32); \
k32 = (uint32_t *) key; \ k32 = (uint32_t *) key; \
k32[0] = (value); \ k32[0] = (value); \
@ -206,7 +208,7 @@ test_table_array(void)
/* Initialize params and create tables */ /* Initialize params and create tables */
struct rte_table_array_params array_params = { struct rte_table_array_params array_params = {
.n_entries = 7, .n_entries = 7,
.offset = 1 .offset = APP_METADATA_OFFSET(1)
}; };
table = rte_table_array_ops.f_create(NULL, 0, 1); table = rte_table_array_ops.f_create(NULL, 0, 1);
@ -226,13 +228,13 @@ test_table_array(void)
return -3; return -3;
array_params.n_entries = 1 << 24; array_params.n_entries = 1 << 24;
array_params.offset = 1; array_params.offset = APP_METADATA_OFFSET(1);
table = rte_table_array_ops.f_create(&array_params, 0, 1); table = rte_table_array_ops.f_create(&array_params, 0, 1);
if (table == NULL) if (table == NULL)
return -4; return -4;
array_params.offset = 32; array_params.offset = APP_METADATA_OFFSET(32);
table = rte_table_array_ops.f_create(&array_params, 0, 1); table = rte_table_array_ops.f_create(&array_params, 0, 1);
if (table == NULL) if (table == NULL)
@ -325,7 +327,7 @@ test_table_lpm(void)
.name = "LPM", .name = "LPM",
.n_rules = 1 << 24, .n_rules = 1 << 24,
.entry_unique_size = entry_size, .entry_unique_size = entry_size,
.offset = 1 .offset = APP_METADATA_OFFSET(1)
}; };
table = rte_table_lpm_ops.f_create(NULL, 0, entry_size); table = rte_table_lpm_ops.f_create(NULL, 0, entry_size);
@ -346,7 +348,7 @@ test_table_lpm(void)
return -3; return -3;
lpm_params.n_rules = 1 << 24; lpm_params.n_rules = 1 << 24;
lpm_params.offset = 32; lpm_params.offset = APP_METADATA_OFFSET(32);
lpm_params.entry_unique_size = 0; lpm_params.entry_unique_size = 0;
table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size); table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
@ -490,7 +492,7 @@ test_table_lpm_ipv6(void)
.n_rules = 1 << 24, .n_rules = 1 << 24,
.number_tbl8s = 1 << 21, .number_tbl8s = 1 << 21,
.entry_unique_size = entry_size, .entry_unique_size = entry_size,
.offset = 32 .offset = APP_METADATA_OFFSET(32)
}; };
table = rte_table_lpm_ipv6_ops.f_create(NULL, 0, entry_size); table = rte_table_lpm_ipv6_ops.f_create(NULL, 0, entry_size);
@ -528,7 +530,7 @@ test_table_lpm_ipv6(void)
return -6; return -6;
lpm_params.entry_unique_size = entry_size; lpm_params.entry_unique_size = entry_size;
lpm_params.offset = 32; lpm_params.offset = APP_METADATA_OFFSET(32);
table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size); table = rte_table_lpm_ipv6_ops.f_create(&lpm_params, 0, entry_size);
if (table == NULL) if (table == NULL)
@ -666,8 +668,8 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)
.n_entries = 1 << 10, .n_entries = 1 << 10,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 1, .signature_offset = APP_METADATA_OFFSET(1),
.key_offset = 32 .key_offset = APP_METADATA_OFFSET(32)
}; };
hash_params.n_entries = 0; hash_params.n_entries = 0;
@ -677,20 +679,20 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)
return -1; return -1;
hash_params.n_entries = 1 << 10; hash_params.n_entries = 1 << 10;
hash_params.signature_offset = 1; hash_params.signature_offset = APP_METADATA_OFFSET(1);
table = ops->f_create(&hash_params, 0, 1); table = ops->f_create(&hash_params, 0, 1);
if (table == NULL) if (table == NULL)
return -2; return -2;
hash_params.signature_offset = 0; hash_params.signature_offset = APP_METADATA_OFFSET(0);
hash_params.key_offset = 1; hash_params.key_offset = APP_METADATA_OFFSET(1);
table = ops->f_create(&hash_params, 0, 1); table = ops->f_create(&hash_params, 0, 1);
if (table == NULL) if (table == NULL)
return -3; return -3;
hash_params.key_offset = 32; hash_params.key_offset = APP_METADATA_OFFSET(32);
hash_params.f_hash = NULL; hash_params.f_hash = NULL;
table = ops->f_create(&hash_params, 0, 1); table = ops->f_create(&hash_params, 0, 1);
@ -781,8 +783,8 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)
.n_entries_ext = 1 << 4, .n_entries_ext = 1 << 4,
.f_hash = pipeline_test_hash, .f_hash = pipeline_test_hash,
.seed = 0, .seed = 0,
.signature_offset = 1, .signature_offset = APP_METADATA_OFFSET(1),
.key_offset = 32 .key_offset = APP_METADATA_OFFSET(32)
}; };
hash_params.n_entries = 0; hash_params.n_entries = 0;
@ -798,19 +800,19 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)
return -2; return -2;
hash_params.n_entries_ext = 1 << 4; hash_params.n_entries_ext = 1 << 4;
hash_params.signature_offset = 1; hash_params.signature_offset = APP_METADATA_OFFSET(1);
table = ops->f_create(&hash_params, 0, 1); table = ops->f_create(&hash_params, 0, 1);
if (table == NULL) if (table == NULL)
return -2; return -2;
hash_params.signature_offset = 0; hash_params.signature_offset = APP_METADATA_OFFSET(0);
hash_params.key_offset = 1; hash_params.key_offset = APP_METADATA_OFFSET(1);
table = ops->f_create(&hash_params, 0, 1); table = ops->f_create(&hash_params, 0, 1);
if (table == NULL) if (table == NULL)
return -3; return -3;
hash_params.key_offset = 32; hash_params.key_offset = APP_METADATA_OFFSET(32);
hash_params.f_hash = NULL; hash_params.f_hash = NULL;
table = ops->f_create(&hash_params, 0, 1); table = ops->f_create(&hash_params, 0, 1);

View File

@ -45,11 +45,6 @@ Deprecation Notices
the value of macros CFG_NAME_LEN and CFG_NAME_VAL will be increased. 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. 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: New functions for table entry bulk add/delete will be added * librte_table: New functions for table entry bulk add/delete will be added
to the table operations structure. to the table operations structure.

View File

@ -101,6 +101,10 @@ ABI Changes
* librte_table LPM: A new parameter to hold the table name will be added to * librte_table LPM: A new parameter to hold the table name will be added to
the LPM table parameter structure. the LPM table parameter structure.
* 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 Shared Library Versions
----------------------- -----------------------
@ -127,7 +131,7 @@ The libraries prepended with a plus sign were incremented in this version.
librte_pipeline.so.1 librte_pipeline.so.1
librte_pmd_bond.so.1 librte_pmd_bond.so.1
+ librte_pmd_ring.so.2 + librte_pmd_ring.so.2
librte_port.so.1 + librte_port.so.2
librte_power.so.1 librte_power.so.1
librte_reorder.so.1 librte_reorder.so.1
librte_ring.so.1 librte_ring.so.1

View File

@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
EXPORT_MAP := rte_port_version.map EXPORT_MAP := rte_port_version.map
LIBABIVER := 1 LIBABIVER := 2
# #
# all source are stored in SRCS-y # all source are stored in SRCS-y

View File

@ -55,7 +55,7 @@ extern "C" {
* just beyond the end of the mbuf data structure returned by a port * just beyond the end of the mbuf data structure returned by a port
*/ */
#define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset) \ #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) \ #define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset) \
((uint16_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)) ((uint16_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
#define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) \ #define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) \