From: Viacheslav Ovsiienko Date: Tue, 5 Nov 2019 14:19:31 +0000 (+0000) Subject: ethdev: move egress metadata to dynamic field X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9bf26e1318e3cd7a04115c8201255505e90cab83;p=dpdk.git ethdev: move egress metadata to dynamic field The dynamic mbuf fields were introduced by [1]. The egress metadata is good candidate to be moved from statically allocated field tx_metadata to dynamic one. Because mbufs are used in half-duplex fashion only, it is safe to share this dynamic field with ingress metadata. The shared dynamic field contains either egress (if application going to transmit mbuf with tx_burst) or ingress (if mbuf is received with rx_burst) metadata and can be accessed by RTE_FLOW_DYNF_METADATA() macro or with rte_flow_dynf_metadata_set() and rte_flow_dynf_metadata_get() helper routines. PKT_TX_DYNF_METADATA/PKT_RX_DYNF_METADATA flag will be set along with the data. The mbuf dynamic field must be registered by calling rte_flow_dynf_metadata_register() prior accessing the data. The availability of dynamic mbuf metadata field can be checked with rte_flow_dynf_metadata_avail() routine. DEV_TX_OFFLOAD_MATCH_METADATA offload and configuration flag is removed. The metadata support in PMDs is engaged on dynamic field registration. Metadata feature is getting complex. We might have some set of actions and items that might be supported by PMDs in multiple combinations, the supported values and masks are the subjects to query by perfroming trials (with rte_flow_validate). [1] http://patches.dpdk.org/patch/62040/ Signed-off-by: Viacheslav Ovsiienko Acked-by: Andrew Rybchenko Acked-by: Olivier Matz Acked-by: Ori Kam --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 74e02d6813..85fdb4c598 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -18718,12 +18718,13 @@ cmd_config_tx_metadata_specific_parsed(void *parsed_result, if (port_id_is_invalid(res->port_id, ENABLED_WARN)) return; - ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); + ports[res->port_id].tx_metadata = res->value; /* Add/remove callback to insert valid metadata in every Tx packet. */ if (ports[res->port_id].tx_metadata) add_tx_md_callback(res->port_id); else remove_tx_md_callback(res->port_id); + rte_flow_dynf_metadata_register(); } cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 38acbc58a2..5ba974162c 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1119,10 +1119,6 @@ init_config(void) DEV_TX_OFFLOAD_MBUF_FAST_FREE)) port->dev_conf.txmode.offloads &= ~DEV_TX_OFFLOAD_MBUF_FAST_FREE; - if (!(port->dev_info.tx_offload_capa & - DEV_TX_OFFLOAD_MATCH_METADATA)) - port->dev_conf.txmode.offloads &= - ~DEV_TX_OFFLOAD_MATCH_METADATA; if (numa_support) { if (port_numa[pid] != NUMA_NO_CONFIG) port_per_socket[port_numa[pid]]++; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ec10a1a35a..419997f7c9 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -193,7 +193,7 @@ struct rte_port { struct softnic_port softport; /**< softnic params */ #endif /**< metadata value to insert in Tx packets. */ - rte_be32_t tx_metadata; + uint32_t tx_metadata; const struct rte_eth_rxtx_callback *tx_set_md_cb[MAX_QUEUE_ID+1]; }; diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index 56075b33ed..cf41864d54 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -82,8 +82,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], mb->vlan_tci, mb->vlan_tci_outer); else if (ol_flags & PKT_RX_VLAN) printf(" - VLAN tci=0x%x", mb->vlan_tci); - if (ol_flags & PKT_TX_METADATA) - printf(" - Tx metadata: 0x%x", mb->tx_metadata); + if (ol_flags & PKT_TX_DYNF_METADATA) + printf(" - Tx metadata: 0x%x", + *RTE_FLOW_DYNF_METADATA(mb)); if (ol_flags & PKT_RX_DYNF_METADATA) printf(" - Rx metadata: 0x%x", *RTE_FLOW_DYNF_METADATA(mb)); @@ -188,10 +189,12 @@ tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue, * Add metadata value to every Tx packet, * and set ol_flags accordingly. */ - for (i = 0; i < nb_pkts; i++) { - pkts[i]->tx_metadata = ports[port_id].tx_metadata; - pkts[i]->ol_flags |= PKT_TX_METADATA; - } + if (rte_flow_dynf_metadata_avail()) + for (i = 0; i < nb_pkts; i++) { + *RTE_FLOW_DYNF_METADATA(pkts[i]) = + ports[port_id].tx_metadata; + pkts[i]->ol_flags |= PKT_TX_DYNF_METADATA; + } return nb_pkts; } diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index 854bc26d8f..61ecffc184 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -1669,7 +1669,6 @@ test_get_tx_ol_flag_name(void) VAL_NAME(PKT_TX_SEC_OFFLOAD), VAL_NAME(PKT_TX_UDP_SEG), VAL_NAME(PKT_TX_OUTER_UDP_CKSUM), - VAL_NAME(PKT_TX_METADATA), }; /* Test case to check with valid flag */ diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 1f72cc717b..ac0020e44d 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -692,7 +692,7 @@ Item: ``META`` Matches 32 bit metadata item set. On egress, metadata can be set either by mbuf metadata field with -PKT_TX_METADATA flag or ``SET_META`` action. On ingress, ``SET_META`` +PKT_TX_DYNF_METADATA flag or ``SET_META`` action. On ingress, ``SET_META`` action sets metadata for a packet and the metadata will be reported via ``metadata`` dynamic field of ``rte_mbuf`` with PKT_RX_DYNF_METADATA flag. @@ -2532,8 +2532,8 @@ Action: ``SET_META`` Set metadata. Item ``META`` matches metadata. -Metadata set by mbuf metadata field with PKT_TX_METADATA flag on egress will be -overridden by this action. On ingress, the metadata will be carried by +Metadata set by mbuf metadata field with PKT_TX_DYNF_METADATA flag on egress +will be overridden by this action. On ingress, the metadata will be carried by ``metadata`` dynamic field of ``rte_mbuf`` which can be accessed by ``RTE_FLOW_DYNF_METADATA()``. PKT_RX_DYNF_METADATA flag will be set along with the data. diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index e1fc953bda..21dc3d2c25 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -397,6 +397,11 @@ API Changes is the minor compatibility issue for applications in case of 32-bit values supported. +* ethdev: the tx_metadata mbuf field is moved to dymanic one. + PKT_TX_METADATA flag is replaced with PKT_TX_DYNF_METADATA. + DEV_TX_OFFLOAD_MATCH_METADATA offload flag is removed, now metadata + support in PMD is engaged on dynamic field registration. + * event: The function ``rte_event_eth_tx_adapter_enqueue`` takes an additional input as ``flags``. Flag ``RTE_EVENT_ETH_TX_ADAPTER_ENQUEUE_SAME_DEST`` which has been introduced in this release is used when used when all the packets diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index b49175e5a4..42c265f217 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -820,7 +820,7 @@ flow_dv_convert_action_set_reg * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_dv_validate_item_meta(struct rte_eth_dev *dev, +flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, const struct rte_flow_item *item, const struct rte_flow_attr *attr, struct rte_flow_error *error) @@ -828,17 +828,10 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev, const struct rte_flow_item_meta *spec = item->spec; const struct rte_flow_item_meta *mask = item->mask; const struct rte_flow_item_meta nic_mask = { - .data = RTE_BE32(UINT32_MAX) + .data = UINT32_MAX }; int ret; - uint64_t offloads = dev->data->dev_conf.txmode.offloads; - if (!(offloads & DEV_TX_OFFLOAD_MATCH_METADATA)) - return rte_flow_error_set(error, EPERM, - RTE_FLOW_ERROR_TYPE_ITEM, - NULL, - "match on metadata offload " - "configuration is off for this port"); if (!spec) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, @@ -4816,10 +4809,10 @@ flow_dv_translate_item_meta(void *matcher, void *key, meta_m = &rte_flow_item_meta_mask; meta_v = (const void *)item->spec; if (meta_v) { - MLX5_SET(fte_match_set_misc2, misc2_m, metadata_reg_a, - rte_be_to_cpu_32(meta_m->data)); - MLX5_SET(fte_match_set_misc2, misc2_v, metadata_reg_a, - rte_be_to_cpu_32(meta_v->data & meta_m->data)); + MLX5_SET(fte_match_set_misc2, misc2_m, + metadata_reg_a, meta_m->data); + MLX5_SET(fte_match_set_misc2, misc2_v, + metadata_reg_a, meta_v->data & meta_m->data); } } diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 7f99f22620..887e283c18 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -2279,8 +2279,8 @@ mlx5_tx_eseg_none(struct mlx5_txq_data *restrict txq __rte_unused, es->swp_offs = txq_mbuf_to_swp(loc, &es->swp_flags, olx); /* Fill metadata field if needed. */ es->metadata = MLX5_TXOFF_CONFIG(METADATA) ? - loc->mbuf->ol_flags & PKT_TX_METADATA ? - loc->mbuf->tx_metadata : 0 : 0; + loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ? + *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0; /* Engage VLAN tag insertion feature if requested. */ if (MLX5_TXOFF_CONFIG(VLAN) && loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) { @@ -2339,8 +2339,8 @@ mlx5_tx_eseg_dmin(struct mlx5_txq_data *restrict txq __rte_unused, es->swp_offs = txq_mbuf_to_swp(loc, &es->swp_flags, olx); /* Fill metadata field if needed. */ es->metadata = MLX5_TXOFF_CONFIG(METADATA) ? - loc->mbuf->ol_flags & PKT_TX_METADATA ? - loc->mbuf->tx_metadata : 0 : 0; + loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ? + *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0; static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) + sizeof(rte_v128u32_t)), @@ -2432,8 +2432,8 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *restrict txq, es->swp_offs = txq_mbuf_to_swp(loc, &es->swp_flags, olx); /* Fill metadata field if needed. */ es->metadata = MLX5_TXOFF_CONFIG(METADATA) ? - loc->mbuf->ol_flags & PKT_TX_METADATA ? - loc->mbuf->tx_metadata : 0 : 0; + loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ? + *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0; static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) + sizeof(rte_v128u32_t)), @@ -2626,8 +2626,8 @@ mlx5_tx_eseg_mdat(struct mlx5_txq_data *restrict txq, es->swp_offs = txq_mbuf_to_swp(loc, &es->swp_flags, olx); /* Fill metadata field if needed. */ es->metadata = MLX5_TXOFF_CONFIG(METADATA) ? - loc->mbuf->ol_flags & PKT_TX_METADATA ? - loc->mbuf->tx_metadata : 0 : 0; + loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ? + *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0; static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) + sizeof(rte_v128u32_t)), @@ -3698,8 +3698,8 @@ mlx5_tx_match_empw(struct mlx5_txq_data *restrict txq __rte_unused, return false; /* Fill metadata field if needed. */ if (MLX5_TXOFF_CONFIG(METADATA) && - es->metadata != (loc->mbuf->ol_flags & PKT_TX_METADATA ? - loc->mbuf->tx_metadata : 0)) + es->metadata != (loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ? + *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0)) return false; /* There must be no VLAN packets in eMPW loop. */ if (MLX5_TXOFF_CONFIG(VLAN)) @@ -5147,7 +5147,7 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) */ olx |= MLX5_TXOFF_CONFIG_EMPW; } - if (tx_offloads & DEV_TX_OFFLOAD_MATCH_METADATA) { + if (rte_flow_dynf_metadata_avail()) { /* We should support Flow metadata. */ olx |= MLX5_TXOFF_CONFIG_METADATA; } diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.h b/drivers/net/mlx5/mlx5_rxtx_vec.h index b54ff72d4c..85e0bd5441 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec.h @@ -19,12 +19,6 @@ DEV_TX_OFFLOAD_TCP_CKSUM | \ DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) -/* HW offload capabilities of vectorized Tx. */ -#define MLX5_VEC_TX_OFFLOAD_CAP \ - (MLX5_VEC_TX_CKSUM_OFFLOAD_CAP | \ - DEV_TX_OFFLOAD_MATCH_METADATA | \ - DEV_TX_OFFLOAD_MULTI_SEGS) - /* * Compile time sanity check for vectorized functions. */ diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index dfc379c076..97991f0c04 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -128,10 +128,6 @@ mlx5_get_tx_port_offloads(struct rte_eth_dev *dev) offloads |= (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | DEV_TX_OFFLOAD_GRE_TNL_TSO); } -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - if (config->dv_flow_en) - offloads |= DEV_TX_OFFLOAD_MATCH_METADATA; -#endif return offloads; } diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 11e7632283..652c369e54 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -161,7 +161,6 @@ static const struct { RTE_TX_OFFLOAD_BIT2STR(UDP_TNL_TSO), RTE_TX_OFFLOAD_BIT2STR(IP_TNL_TSO), RTE_TX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM), - RTE_TX_OFFLOAD_BIT2STR(MATCH_METADATA), }; #undef RTE_TX_OFFLOAD_BIT2STR diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 83ccbabc9e..44d77b332e 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1145,11 +1145,6 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000 /** Device supports outer UDP checksum */ #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000 -/** - * Device supports match on metadata Tx offload.. - * Application must set PKT_TX_METADATA and mbuf metadata field. - */ -#define DEV_TX_OFFLOAD_MATCH_METADATA 0x00200000 #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001 /**< Device supports Rx queue setup after device started*/ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 934c3e15ed..452d359a16 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -1277,12 +1277,12 @@ rte_flow_item_icmp6_nd_opt_tla_eth_mask = { /** * RTE_FLOW_ITEM_TYPE_META * - * Matches a specified metadata value. On egress, metadata can be set either by - * mbuf tx_metadata field with PKT_TX_METADATA flag or - * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META sets - * metadata for a packet and the metadata will be reported via mbuf metadata - * dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf field must be - * registered in advance by rte_flow_dynf_metadata_register(). + * Matches a specified metadata value. On egress, metadata can be set + * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or + * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META + * sets metadata for a packet and the metadata will be reported via mbuf + * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf + * field must be registered in advance by rte_flow_dynf_metadata_register(). */ struct rte_flow_item_meta { uint32_t data; @@ -2512,8 +2512,8 @@ struct rte_flow_action_set_tag { * * RTE_FLOW_ACTION_TYPE_SET_META * - * Set metadata. Metadata set by mbuf tx_metadata field with - * PKT_TX_METADATA flag on egress will be overridden by this action. On + * Set metadata. Metadata set by mbuf metadata dynamic field with + * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On * ingress, the metadata will be carried by mbuf metadata dynamic field * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be * registered in advance by rte_flow_dynf_metadata_register(). @@ -2540,8 +2540,9 @@ extern uint64_t rte_flow_dynf_metadata_mask; #define RTE_FLOW_DYNF_METADATA(m) \ RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *) -/* Mbuf dynamic flag for metadata. */ +/* Mbuf dynamic flags for metadata. */ #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask) +#define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask) __rte_experimental static inline uint32_t diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 8c51dc1a00..35df1c4c38 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -670,7 +670,6 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask) case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD"; case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG"; case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM"; - case PKT_TX_METADATA: return "PKT_TX_METADATA"; default: return NULL; } } @@ -707,7 +706,6 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL }, { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL }, { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL }, - { PKT_TX_METADATA, PKT_TX_METADATA, NULL }, }; const char *name; unsigned int i; diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h index 3022701461..9a8557d1cc 100644 --- a/lib/librte_mbuf/rte_mbuf_core.h +++ b/lib/librte_mbuf/rte_mbuf_core.h @@ -187,15 +187,10 @@ extern "C" { /* add new RX flags here, don't forget to update PKT_FIRST_FREE */ #define PKT_FIRST_FREE (1ULL << 23) -#define PKT_LAST_FREE (1ULL << 39) +#define PKT_LAST_FREE (1ULL << 40) /* add new TX flags here, don't forget to update PKT_LAST_FREE */ -/** - * Indicate that the metadata field in the mbuf is in use. - */ -#define PKT_TX_METADATA (1ULL << 40) - /** * Outer UDP checksum offload flag. This flag is used for enabling * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to @@ -389,8 +384,7 @@ extern "C" { PKT_TX_MACSEC | \ PKT_TX_SEC_OFFLOAD | \ PKT_TX_UDP_SEG | \ - PKT_TX_OUTER_UDP_CKSUM | \ - PKT_TX_METADATA) + PKT_TX_OUTER_UDP_CKSUM) /** * Mbuf having an external buffer attached. shinfo in mbuf must be filled. @@ -601,17 +595,6 @@ struct rte_mbuf { /**< User defined tags. See rte_distributor_process() */ uint32_t usr; } hash; /**< hash information */ - struct { - /** - * Application specific metadata value - * for egress flow rule match. - * Valid if PKT_TX_METADATA is set. - * Located here to allow conjunct use - * with hash.sched.hi. - */ - uint32_t tx_metadata; - uint32_t reserved; - }; }; /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ is set. */