remove mbuf userdata
Subsystems (4)
PATCH v5 6/15 net/dpaa2: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 20 ++++++++++++++++++++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_rxtx.c | 25 ++++++++++++++++++------- 3 files changed, 40 insertions(+), 7 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +20 -0
@@ -8,6 +8,7 @@#include <time.h> #include <net/if.h> +#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_ethdev_driver.h> #include <rte_malloc.h>
@@ -65,6 +66,8 @@ static uint64_t dev_tx_offloads_nodis =/* enable timestamp in mbuf */ bool dpaa2_enable_ts[RTE_MAX_ETHPORTS ]; +uint64_t dpaa2_timestamp_rx_dynflag; +int dpaa2_timestamp_dynfield_offset =-1 ;struct rte_dpaa2_xstats_name_off {char name[RTE_ETH_XSTATS_NAME_SIZE ];
@@ -505,6 +508,7 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)struct rte_eth_conf *eth_conf = &dev->data->dev_conf;uint64_t rx_offloads = eth_conf->rxmode.offloads;uint64_t tx_offloads = eth_conf->txmode.offloads; +int timestamp_rx_dynflag_offset;int rx_l3_csum_offload = false;int rx_l4_csum_offload = false;int tx_l3_csum_offload = false;
@@ -587,7 +591,23 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)#if !defined(RTE_LIBRTE_IEEE1588 ) if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)#endif + { + dpaa2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (dpaa2_timestamp_dynfield_offset <0 ) { +DPAA2_PMD_ERR ("Error to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DPAA2_PMD_ERR ("Error to lookup Rx timestamp flag" ); +return -rte_errno; + } + dpaa2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); dpaa2_enable_ts[dev->data->port_id] = true; + }if (tx_offloads &DEV_TX_OFFLOAD_IPV4_CKSUM ) tx_l3_csum_offload = true;
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
@@ -92,6 +92,8 @@/* enable timestamp in mbuf*/ extern bool dpaa2_enable_ts[]; +extern uint64_t dpaa2_timestamp_rx_dynflag; +extern int dpaa2_timestamp_dynfield_offset;#define DPAA2_QOS_TABLE_RECONFIGURE 1#define DPAA2_FS_TABLE_RECONFIGURE 2
drivers/net/dpaa2/dpaa2_rxtx.c +18 -7
@@ -31,6 +31,13 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf, static void enable_tx_tstamp(struct qbman_fd *fd) __rte_unused; +static inline rte_mbuf_timestamp_t * +dpaa2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + dpaa2_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +#define DPAA2_MBUF_TO_CONTIG_FD (_mbuf, _fd, _bpid) do { \ DPAA2_SET_FD_ADDR(_fd, DPAA2_MBUF_VADDR_TO_IOVA(_mbuf)); \ DPAA2_SET_FD_LEN(_fd, _mbuf->data_len); \
@@ -109,9 +116,10 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd, m->ol_flags |=PKT_RX_RSS_HASH ;if (dpaa2_enable_ts[m->port]) { - m->timestamp = annotation->word2; - m->ol_flags |=PKT_RX_TIMESTAMP ; -DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , m->timestamp); + *dpaa2_timestamp_dynfield (m) = annotation->word2; + m->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp:0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (m)); } DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
@@ -223,9 +231,12 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)else if (BIT_ISSET_AT_POS (annotation->word8,DPAA2_ETH_FAS_L4CE )) mbuf->ol_flags |=PKT_RX_L4_CKSUM_BAD ; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; - mbuf->timestamp = annotation->word2; -DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , mbuf->timestamp); +if (dpaa2_enable_ts[mbuf->port]) { + *dpaa2_timestamp_dynfield (mbuf) = annotation->word2; + mbuf->ol_flags |= dpaa2_timestamp_rx_dynflag; +DPAA2_PMD_DP_DEBUG ("pkt timestamp: 0x%" PRIx64"" , + *dpaa2_timestamp_dynfield (mbuf)); + }/* Check detailed parsing requirement */ if (annotation->word3 &0x7FFFFC3FFFF )
@@ -629,7 +640,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)else bufs[num_rx] =eth_fd_to_mbuf (fd, eth_data->port_id);#if defined(RTE_LIBRTE_IEEE1588 ) - priv->rx_timestamp = bufs[num_rx]->timestamp; + priv->rx_timestamp = *dpaa2_timestamp_dynfield (bufs[num_rx]);#endif if (eth_data->dev_conf.rxmode.offloads &
Signature · 1 line
2.28.0
PATCH v5 7/15 net/mlx5: fix dynamic mbuf offset lookup check
In reply to Thomas MonjalonThe functions rte_mbuf_dynfield_lookup() and rte_mbuf_dynflag_lookup() can return an offset starting with 0 or a negative error code.
In reality the first offsets are probably reserved forever, but for the sake of strict API compliance,
the checks which considered 0 as an error are fixed.
--- drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/mlx5_txq.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -5661,9 +5661,9 @@ mlx5_select_tx_function(struct rte_eth_dev *dev) }if (tx_offloads &DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP &&rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >0 && + (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ) >=0 &&rte_mbuf_dynfield_lookup - (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >0 ) { + (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ) >=0 ) {/* Offload configured, dynamic entities registered. */ olx |=MLX5_TXOFF_CONFIG_TXPP ; }
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -302,7 +302,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id); fine_inline =rte_mbuf_dynflag_lookup (RTE_PMD_MLX5_FINE_GRANULARITY_INLINE ,NULL ); -if (fine_inline >0 ) +if (fine_inline >=0 ) rte_net_mlx5_dynf_inline_mask =1UL << fine_inline;else rte_net_mlx5_dynf_inline_mask =0 ;
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -1305,7 +1305,7 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME ,NULL ); off =rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); -if (nbit >0 && off >=0 && sh->txpp.refcnt) +if (nbit >=0 && off >=0 && sh->txpp.refcnt) mask =1ULL << nbit;for (i =0 ; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i];
Signature · 1 line
2.28.0
PATCH v5 8/15 net/mlx5: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 4 +-- drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- 6 files changed, 118 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +36 -0
@@ -1310,6 +1310,39 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); } +/** +* Lookup mbuf field and flag for Rx timestamp if offload requested. +* +* @param rxq_data +* Datapath struct where field offset and flag mask are stored. +* +* @return +* 0 on success or offload disabled, negative errno otherwise. +*/ +static int +mlx5_rx_timestamp_setup (struct mlx5_rxq_data *rxq_data) +{ +int timestamp_rx_dynflag_offset; + + rxq_data->timestamp_rx_flag =0 ; +if (rxq_data->hw_timestamp ==0 ) +return 0 ; + rxq_data->timestamp_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rxq_data->timestamp_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +DRV_LOG (ERR ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + rxq_data->timestamp_rx_flag =RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; +} +/** * Create a DPDK Rx queue. *
@@ -1492,7 +1525,10 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,mlx5_max_lro_msg_size_adjust (dev, idx, max_lro_size);/* Toggle RX checksum offload if hardware supports it. */ tmpl->rxq.csum = !!(offloads &DEV_RX_OFFLOAD_CHECKSUM ); +/* Configure Rx timestamp. */ tmpl->rxq.hw_timestamp = !!(offloads &DEV_RX_OFFLOAD_TIMESTAMP ); +if (mlx5_rx_timestamp_setup (&tmpl->rxq) !=0 ) + goto error;/* Configure VLAN stripping. */ tmpl->rxq.vlan_strip = !!(offloads &DEV_RX_OFFLOAD_VLAN_STRIP );/* By default, FCS (CRC) is stripped by hardware. */
drivers/net/mlx5/mlx5_rxtx.c +2 -2
@@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt,if (rxq->rt_timestamp) ts =mlx5_txpp_convert_rx_ts (rxq->sh, ts); - pkt->timestamp = ts; - pkt->ol_flags |=PKT_RX_TIMESTAMP ; +mlx5_timestamp_set (pkt, rxq->timestamp_offset, ts); + pkt->ol_flags |= rxq->timestamp_rx_flag; } }
drivers/net/mlx5/mlx5_rxtx.h +19 -0
@@ -151,6 +151,8 @@ struct mlx5_rxq_data {/* CQ (UAR) access lock required for 32bit implementations */ #endif uint32_t tunnel;/* Tunnel information. */ +int timestamp_offset;/* Dynamic mbuf field for timestamp. */ +uint64_t timestamp_rx_flag;/* Dynamic mbuf flag for timestamp. */ uint64_t flow_meta_mask;int32_t flow_meta_offset; } __rte_cache_aligned;
@@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) return ci; } +/** +* Set timestamp in mbuf dynamic field. +* +* @param mbuf +* Structure to write into. +* @param offset +* Dynamic field offset in mbuf structure. +* @param timestamp +* Value to write. +*/ +static __rte_always_inline void +mlx5_timestamp_set (struct rte_mbuf *mbuf,int offset, +rte_mbuf_timestamp_t timestamp) +{ + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; +} +#endif /* RTE_PMD_MLX5_RXTX_H_ */
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +21 -20
65 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +22 -21
71 lines not on this page · raw message
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +18 -17
@@ -251,7 +251,7 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4],__m128i pinfo0, pinfo1;__m128i pinfo, ptype;__m128i ol_flags =_mm_set1_epi32 (rxq->rss_hash *PKT_RX_RSS_HASH | - rxq->hw_timestamp *PKT_RX_TIMESTAMP ); + rxq->hw_timestamp * rxq->timestamp_rx_flag);__m128i cv_flags;const __m128i zero =_mm_setzero_si128 (); const __m128i ptype_mask =
@@ -656,31 +656,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,/* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v (rxq, cqes, opcode, &pkts[pos]);if (rxq->hw_timestamp) { +int offset = rxq->timestamp_offset;if (rxq->rt_timestamp) {struct mlx5_dev_ctx_shared *sh = rxq->sh;uint64_t ts; ts =rte_be_to_cpu_64 (cq[pos].timestamp); - pkts[pos]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p1].timestamp); - pkts[pos +1 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +1 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p2].timestamp); - pkts[pos +2 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +2 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); ts =rte_be_to_cpu_64 (cq[pos + p3].timestamp); - pkts[pos +3 ]->timestamp = -mlx5_txpp_convert_rx_ts (sh, ts); +mlx5_timestamp_set (pkts[pos +3 ], offset, +mlx5_txpp_convert_rx_ts (sh, ts)); }else { - pkts[pos]->timestamp =rte_be_to_cpu_64 - (cq[pos].timestamp); - pkts[pos +1 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p1].timestamp); - pkts[pos +2 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p2].timestamp); - pkts[pos +3 ]->timestamp =rte_be_to_cpu_64 - (cq[pos + p3].timestamp); +mlx5_timestamp_set (pkts[pos], offset, +rte_be_to_cpu_64 (cq[pos].timestamp)); +mlx5_timestamp_set (pkts[pos +1 ], offset, +rte_be_to_cpu_64 (cq[pos + p1].timestamp)); +mlx5_timestamp_set (pkts[pos +2 ], offset, +rte_be_to_cpu_64 (cq[pos + p2].timestamp)); +mlx5_timestamp_set (pkts[pos +3 ], offset, +rte_be_to_cpu_64 (cq[pos + p3].timestamp)); } }if (rxq->dynf_meta) {
Signature · 1 line
2.28.0
PATCH v5 9/15 net/nfb: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/nfb/nfb_rx.c | 23 ++++++++++++++++++++++- drivers/net/nfb/nfb_rx.h | 18 ++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/nfb/nfb_rx.c +22 -1
@@ -5,10 +5,14 @@*/ #include <rte_kvargs.h> +#include <rte_bitops.h> #include "nfb_rx.h" #include "nfb.h" +uint64_t nfb_timestamp_rx_dynflag; +int nfb_timestamp_dynfield_offset =-1 ; +static int timestamp_check_handler(__rte_unused const char *key, const char *value, __rte_unused void *opaque)
@@ -23,6 +27,7 @@ timestamp_check_handler(__rte_unused const char *key,static int nfb_check_timestamp (struct rte_devargs *devargs) { +int timestamp_rx_dynflag_offset;struct rte_kvargs *kvlist;if (devargs ==NULL )
@@ -38,6 +43,7 @@ nfb_check_timestamp(struct rte_devargs *devargs) }/* Timestamps are enabled when there is * key-value pair: enable_timestamp=1 +* TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP */ if (rte_kvargs_process (kvlist,TIMESTAMP_ARG , timestamp_check_handler,NULL ) <0 ) {
@@ -46,6 +52,21 @@ nfb_check_timestamp(struct rte_devargs *devargs) }rte_kvargs_free (kvlist); + nfb_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (nfb_timestamp_dynfield_offset <0 ) { +RTE_LOG (ERR ,PMD ,"Cannot lookup timestamp field\n" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +RTE_LOG (ERR ,PMD ,"Cannot lookup Rx timestamp flag\n" ); +return -rte_errno; + } + nfb_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); +return 1 ; }
@@ -125,7 +146,7 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,else rte_free (rxq); -if (nfb_check_timestamp (dev->device->devargs)) +if (nfb_check_timestamp (dev->device->devargs) >0 ) rxq->flags |=NFB_TIMESTAMP_FLAG ;return ret;
drivers/net/nfb/nfb_rx.h +14 -4
@@ -15,6 +15,16 @@#define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +struct ndp_rx_queue {struct nfb_device *nfb;/* nfb dev structure */ struct ndp_queue *queue;/* rx queue */
@@ -191,15 +201,15 @@ nfb_eth_ndp_rx(void *queue,if (timestamping_enabled) {/* nanoseconds */ - mbuf->timestamp = + *nfb_timestamp_dynfield (mbuf) =rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +4 ))); - mbuf->timestamp <<=32 ; + *nfb_timestamp_dynfield (mbuf) <<=32 ;/* seconds */ - mbuf->timestamp |= + *nfb_timestamp_dynfield (mbuf) |=rte_le_to_cpu_32 (*((uint32_t *) (packets[i].header +8 ))); - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf;
Signature · 1 line
2.28.0
PATCH v5 10/15 net/octeontx2: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_rx.h | 19 ++++++++++++++--- drivers/net/octeontx2/version.map | 7 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-)
drivers/net/octeontx2/otx2_ethdev.c +33 -0
@@ -4,6 +4,7 @@#include <inttypes.h> +#include <rte_bitops.h> #include <rte_ethdev_pci.h> #include <rte_io.h> #include <rte_malloc.h>
@@ -14,6 +15,35 @@#include "otx2_ethdev.h" #include "otx2_ethdev_sec.h" +uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +int rte_pmd_octeontx2_timestamp_dynfield_offset =-1 ; + +static int +otx2_rx_timestamp_setup (uint16_t flags) +{ +int timestamp_rx_dynflag_offset; + +if ((flags &NIX_RX_OFFLOAD_TSTAMP_F ) ==0 ) +return 0 ; + + rte_pmd_octeontx2_timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (rte_pmd_octeontx2_timestamp_dynfield_offset <0 ) { +otx2_err ("Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +otx2_err ("Failed to lookup Rx timestamp flag" ); +return -rte_errno; + } + rte_pmd_octeontx2_timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); + +return 0 ; +} +static inline uint64_t nix_get_rx_offload_capa (struct otx2_eth_dev *dev) {
@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) dev->tx_offload_flags |=nix_tx_offload_flags (eth_dev); dev->rss_info.rss_grps =NIX_RSS_GRPS ; +if (otx2_rx_timestamp_setup (dev->rx_offload_flags) !=0 ) + goto fail_offloads; + nb_rxq =RTE_MAX (data->nb_rx_queues,1 ); nb_txq =RTE_MAX (data->nb_tx_queues,1 );
drivers/net/octeontx2/otx2_rx.h +16 -3
@@ -63,6 +63,18 @@ union mbuf_initializer {uint64_t value; }; +/* variables are exported because this file is included in other drivers */ +extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag; +extern int rte_pmd_octeontx2_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +otx2_timestamp_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + rte_pmd_octeontx2_timestamp_dynfield_offset, + rte_mbuf_timestamp_t *); +} + static __rte_always_inline void otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct otx2_timesync_info *tstamp, const uint16_t flag,
@@ -77,15 +89,16 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. */ - mbuf->timestamp =rte_be_to_cpu_64 (*tstamp_ptr); + *otx2_timestamp_dynfield (mbuf) =rte_be_to_cpu_64 (*tstamp_ptr);/* PKT_RX_IEEE1588_TMST flag needs to be set only in case * PTP packets are received. */ if (mbuf->packet_type ==RTE_PTYPE_L2_ETHER_TIMESYNC ) { - tstamp->rx_tstamp = mbuf->timestamp; + tstamp->rx_tstamp = *otx2_timestamp_dynfield (mbuf); tstamp->rx_ready =1 ; mbuf->ol_flags |=PKT_RX_IEEE1588_PTP | -PKT_RX_IEEE1588_TMST |PKT_RX_TIMESTAMP ; +PKT_RX_IEEE1588_TMST | + rte_pmd_octeontx2_timestamp_rx_dynflag; } } }
drivers/net/octeontx2/version.map +7 -0
@@ -1,3 +1,10 @@ DPDK_21 { local: *; }; + +INTERNAL { + global: + + rte_pmd_octeontx2_timestamp_dynfield_offset; + rte_pmd_octeontx2_timestamp_rx_dynflag; +};
Signature · 1 line
2.28.0
PATCH v5 11/15 net/pcap: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- drivers/net/pcap/rte_eth_pcap.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/net/pcap/rte_eth_pcap.c +26 -3
@@ -18,6 +18,7 @@#include <pcap.h> +#include <rte_bitops.h> #include <rte_cycles.h> #include <rte_ethdev_driver.h> #include <rte_ethdev_vdev.h>
@@ -51,6 +52,9 @@ static uint64_t start_cycles;static uint64_t hz;static uint8_t iface_idx; +static uint64_t timestamp_rx_dynflag; +static int timestamp_dynfield_offset =-1 ; +struct queue_stat {volatile unsigned long pkts;volatile unsigned long bytes;
@@ -265,9 +269,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } mbuf->pkt_len = (uint16_t )header.caplen; - mbuf->timestamp = (uint64_t )header.ts.tv_sec *1000000 - + header.ts.tv_usec; - mbuf->ol_flags |=PKT_RX_TIMESTAMP ; + *RTE_MBUF_DYNFIELD (mbuf, timestamp_dynfield_offset, + rte_mbuf_timestamp_t *) = + (uint64_t )header.ts.tv_sec *1000000 + + header.ts.tv_usec; + mbuf->ol_flags |= timestamp_rx_dynflag; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++;
@@ -656,6 +662,23 @@ eth_dev_stop(struct rte_eth_dev *dev)static int eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { +int timestamp_rx_dynflag_offset; + + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) { +PMD_LOG (ERR ,"Failed to lookup timestamp field" ); +return -rte_errno; + } + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) { +PMD_LOG (ERR ,"Failed lookup Rx timestamp flag" ); +return -rte_errno; + } + timestamp_rx_dynflag = +RTE_BIT64 (timestamp_rx_dynflag_offset); +return 0 ; }
Signature · 1 line
2.28.0
PATCH v5 12/15 app/testpmd: switch timestamp to dynamic mbuf field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced.
--- app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
app/test-pmd/util.c +37 -2
@@ -5,6 +5,7 @@#include <stdio.h> +#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> #include <rte_ether.h>
@@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr)printf ("%s%s" , what, buf); } +static inline bool +is_timestamp_enabled (const struct rte_mbuf *mbuf) +{ +static uint64_t timestamp_rx_dynflag; + +int timestamp_rx_dynflag_offset; + +if (timestamp_rx_dynflag ==0 ) { + timestamp_rx_dynflag_offset =rte_mbuf_dynflag_lookup ( +RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME ,NULL ); +if (timestamp_rx_dynflag_offset <0 ) +return false; + timestamp_rx_dynflag =RTE_BIT64 (timestamp_rx_dynflag_offset); + } + +return (mbuf->ol_flags & timestamp_rx_dynflag) !=0 ; +} + +static inline rte_mbuf_timestamp_t +get_timestamp (const struct rte_mbuf *mbuf) +{ +static int timestamp_dynfield_offset =-1 ; + +if (timestamp_dynfield_offset <0 ) { + timestamp_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (timestamp_dynfield_offset <0 ) +return 0 ; + } + +return *RTE_MBUF_DYNFIELD (mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} +static inline void dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx)
@@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],printf ("hash=0x%x ID=0x%x " , mb->hash.fdir.hash, mb->hash.fdir.id); } -if (ol_flags &PKT_RX_TIMESTAMP ) -printf (" - timestamp %" PRIu64" " , mb->timestamp); +if (is_timestamp_enabled (mb)) +printf (" - timestamp %" PRIu64" " ,get_timestamp (mb));if (ol_flags &PKT_RX_QINQ )printf (" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x" , mb->vlan_tci, mb->vlan_tci_outer);
Signature · 1 line
2.28.0
PATCH v5 13/15 examples/rxtx_callbacks: switch timestamp to dynamic field
In reply to Thomas MonjalonThe mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field.
--- examples/rxtx_callbacks/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +16 -1
@@ -19,6 +19,15 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +static int hwts_dynfield_offset =-1 ; + +static inline rte_mbuf_timestamp_t * +hwts_field (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + hwts_dynfield_offset, rte_mbuf_timestamp_t *); +} +typedef uint64_t tsc_t ;static int tsc_dynfield_offset =-1 ;
@@ -77,7 +86,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,for (i =0 ; i < nb_pkts; i++) { cycles += now - *tsc_field (pkts[i]);if (hw_timestamping) - queue_ticks += ticks - pkts[i]->timestamp; + queue_ticks += ticks - *hwts_field (pkts[i]); } latency_numbers.total_cycles += cycles;
@@ -141,6 +150,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)return -1 ; } port_conf.rxmode.offloads |=DEV_RX_OFFLOAD_TIMESTAMP ; + hwts_dynfield_offset =rte_mbuf_dynfield_lookup ( +RTE_MBUF_DYNFIELD_TIMESTAMP_NAME ,NULL ); +if (hwts_dynfield_offset <0 ) { +printf ("ERROR: Failed to lookup timestamp field\n" ); +return -rte_errno; + } } retval =rte_eth_dev_configure (port, rx_rings, tx_rings, &port_conf);
Signature · 1 line
2.28.0
PATCH v5 14/15 mbuf: remove deprecated timestamp field
In reply to Thomas MonjalonAs announced in the deprecation note, the field timestamp is removed to allow giving more space to the dynamic fields. The related offload flag PKT_RX_TIMESTAMP is also removed.
--- app/test/test_mbuf.c | 1 - doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_20_11.rst | 4 ++++ lib/librte_ethdev/rte_ethdev.h | 4 +++- lib/librte_mbuf/rte_mbuf.c | 2 -- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_mbuf/rte_mbuf_core.h | 12 +----------- 7 files changed, 8 insertions(+), 17 deletions(-)
app/test/test_mbuf.c +0 -1
@@ -1621,7 +1621,6 @@ test_get_rx_ol_flag_name(void)VAL_NAME (PKT_RX_FDIR_FLX ),VAL_NAME (PKT_RX_QINQ_STRIPPED ),VAL_NAME (PKT_RX_LRO ), -VAL_NAME (PKT_RX_TIMESTAMP ),VAL_NAME (PKT_RX_SEC_OFFLOAD ),VAL_NAME (PKT_RX_SEC_OFFLOAD_FAILED ), VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),
doc/guides/rel_notes/deprecation.rst +0 -1
@@ -86,7 +86,6 @@ Deprecation Notices `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_. The following static fields will be moved as dynamic: - - ``timestamp`` - ``seqn`` As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged,
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -445,6 +445,10 @@ API Changes * mbuf: Removed the unioned fields ``userdata`` and ``udata64`` from the structure ``rte_mbuf``. It is replaced with dynamic fields. +* mbuf: Removed the field ``timestamp`` from the structure ``rte_mbuf``. + It is replaced with the dynamic field RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + which was previously used only for Tx. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.
lib/librte_ethdev/rte_ethdev.h +3 -1
@@ -1345,6 +1345,8 @@ struct rte_eth_conf {#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800#define DEV_RX_OFFLOAD_SCATTER 0x00002000/** +* Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME +* and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags. * The mbuf field and flag are registered when the offload is configured. */ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000
@@ -4654,7 +4656,7 @@ int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);* rte_eth_read_clock(port, base_clock); * * Then, convert the raw mbuf timestamp with: -* base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; +* base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq; * * This simple example will not provide a very good accuracy. One must * at least measure multiple times the frequency and do a regression.
lib/librte_mbuf/rte_mbuf.c +0 -2
@@ -764,7 +764,6 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)case PKT_RX_QINQ_STRIPPED :return "PKT_RX_QINQ_STRIPPED" ;case PKT_RX_QINQ :return "PKT_RX_QINQ" ;case PKT_RX_LRO :return "PKT_RX_LRO" ; -case PKT_RX_TIMESTAMP :return "PKT_RX_TIMESTAMP" ;case PKT_RX_SEC_OFFLOAD :return "PKT_RX_SEC_OFFLOAD" ;case PKT_RX_SEC_OFFLOAD_FAILED :return "PKT_RX_SEC_OFFLOAD_FAILED" ;case PKT_RX_OUTER_L4_CKSUM_BAD :return "PKT_RX_OUTER_L4_CKSUM_BAD" ;
@@ -808,7 +807,6 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) { PKT_RX_FDIR_FLX, PKT_RX_FDIR_FLX, NULL }, { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL }, { PKT_RX_LRO, PKT_RX_LRO, NULL }, - { PKT_RX_TIMESTAMP, PKT_RX_TIMESTAMP, NULL }, { PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL }, { PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL }, { PKT_RX_QINQ, PKT_RX_QINQ, NULL },
lib/librte_mbuf/rte_mbuf.h +0 -1
@@ -1108,7 +1108,6 @@ __rte_pktmbuf_copy_hdr(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) mdst->tx_offload = msrc->tx_offload; mdst->hash = msrc->hash; mdst->packet_type = msrc->packet_type; - mdst->timestamp = msrc->timestamp;rte_mbuf_dynfield_copy (mdst, msrc); }
lib/librte_mbuf/rte_mbuf_core.h +1 -11
@@ -149,11 +149,6 @@ extern "C" {*/ #define PKT_RX_LRO (1ULL << 16) -/** -* Indicate that the timestamp field in the mbuf is valid. -*/ -#define PKT_RX_TIMESTAMP (1ULL << 17) -/** * Indicate that security offload processing was applied on the RX packet. */
@@ -589,12 +584,7 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -/** Valid if PKT_RX_TIMESTAMP is set. The unit and time reference -* are not normalized but are always the same for a given port. -* Some devices allow to query rte_eth_read_clock that will return the -* current device timestamp. -*/ -uint64_t timestamp; +uint64_t unused;/* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v5 14/15] mbuf: remove deprecated timestamp field
Quoted 5 lines · Thomas Monjalon
As announced in the deprecation note, the field timestamp is removed to allow giving more space to the dynamic fields. The related offload flag
PKT_RX_TIMESTAMPis also removed.Signed-off-by Thomas Monjalon <[email protected]>
PATCH v5 15/15 mbuf: move pool pointer in hotter first half
In reply to Thomas MonjalonThe mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.
Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */
1 rte_iova_t buf_iova /* 8 + 8 */
/* --- RTE_MARKER64 rearm_data; */
2 uint16_t data_off; /* 16 + 2 */
uint16_t refcnt; /* 18 + 2 */
uint16_t nb_segs; /* 20 + 2 */
uint16_t port; /* 22 + 2 */
3 uint64_t ol_flags; /* 24 + 8 */
/* --- RTE_MARKER rx_descriptor_fields1; */
4 uint32_t union packet_type; /* 32 + 4 */
uint32_t pkt_len; /* 36 + 4 */
5 uint16_t data_len; /* 40 + 2 */
uint16_t vlan_tci; /* 42 + 2 */
5.5 uint64_t union hash; /* 44 + 8 */
6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
uint16_t buf_len; /* 54 + 2 */
7 struct rte_mempool * pool; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mbuf * next; /* 64 + 8 */
9 uint64_t union tx_offload; /* 72 + 8 */
10 uint16_t priv_size; /* 80 + 2 */
uint16_t timesync; /* 82 + 2 */
uint32_t seqn; /* 84 + 4 */
11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */
12 uint64_t dynfield1[4]; /* 96 + 32 */
16 /* --- END 128 */--- doc/guides/rel_notes/deprecation.rst | 5 ----- lib/librte_kni/rte_kni_common.h | 3 ++- lib/librte_mbuf/rte_mbuf_core.h | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -5
@@ -88,11 +88,6 @@ Deprecation Notices - ``seqn`` - As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged, - avoiding impact on vectorized implementation of the driver datapaths, - while evaluating performance gains of a better use of the first cache line. - - * ethdev: the legacy filter API, including ``rte_eth_dev_filter_supported()``, ``rte_eth_dev_filter_ctrl()`` as well as filter types MACVLAN, ETHERTYPE, FLEXIBLE, SYN, NTUPLE, TUNNEL, FDIR,
lib/librte_kni/rte_kni_common.h +2 -1
@@ -84,10 +84,11 @@ struct rte_kni_mbuf {char pad2[4 ];uint32_t pkt_len;/**< Total pkt len: sum of all segment data_len. */ uint16_t data_len;/**< Amount of data in segment buffer. */ +char pad3[14 ]; +void *pool;/* fields on second cache line */ __attribute__((__aligned__ (RTE_CACHE_LINE_MIN_SIZE ))) -void *pool;void *next;/**< Physical address of next mbuf in kernel. */ };
lib/librte_mbuf/rte_mbuf_core.h +2 -3
@@ -584,12 +584,11 @@ struct rte_mbuf {uint16_t buf_len;/**< Length of segment buffer. */ -uint64_t unused; +struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ /* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ struct rte_mbuf *next;/**< Next segment of scattered packet. */ /* fields to support TX offloads */
@@ -646,7 +645,7 @@ struct rte_mbuf {*/ struct rte_mbuf_ext_shared_info *shinfo; -uint64_t dynfield1[3 ];/**< Reserved for dynamic fields. */ +uint64_t dynfield1[4 ];/**< Reserved for dynamic fields. */ } __rte_cache_aligned;/**
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v5 15/15] mbuf: move pool pointer in hotter first half
Quoted 27 lines · Thomas Monjalon
The mempool pointer in the mbuf struct is moved
from the second to the first half.
It should increase performance on most systems having 64-byte cache line, i.e. mbuf is split in two cache lines.
On such system, the first half (also called first cache line) is hotter than the second one where the pool pointer was.Moving this field gives more space to dynfield1.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */ 1 rte_iova_t buf_iova /* 8 + 8 */ /* --- RTE_MARKER64 rearm_data; */ 2 uint16_t data_off; /* 16 + 2 */ uint16_t refcnt; /* 18 + 2 */ uint16_t nb_segs; /* 20 + 2 */ uint16_t port; /* 22 + 2 */ 3 uint64_t ol_flags; /* 24 + 8 */ /* --- RTE_MARKER rx_descriptor_fields1; */ 4 uint32_t union packet_type; /* 32 + 4 */ uint32_t pkt_len; /* 36 + 4 */ 5 uint16_t data_len; /* 40 + 2 */ uint16_t vlan_tci; /* 42 + 2 */ 5.5 uint64_t union hash; /* 44 + 8 */ 6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
Quoted 8 lines
uint16_t buf_len; /* 54 + 2 */
7 struct rte_mempool * pool; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mbuf * next; /* 64 + 8 */
9 uint64_t union tx_offload; /* 72 + 8 */
10 uint16_t priv_size; /* 80 + 2 */
uint16_t timesync; /* 82 + 2 */
uint32_t seqn; /* 84 + 4 */As I understand rebase is required since seqn is already removed (or at least fix here).
Quoted 5 lines
11 struct rte_mbuf_ext_shared_info * shinfo; /* 88 + 8 */ 12 uint64_t dynfield1[4]; /* 96 + 32 */ 16 /* --- END 128 */Signed-off-by Thomas Monjalon <[email protected]>
Taking Konstantin reply into account ('next' is used on free in any case together with 'pool', so the second cache line is accessed in any case), I think that 'next' is a better candidate. Also 'tx_offload' is a better candidate than 'pool'.
I think 'next' is better since it works for both Rx and Tx, but 'tx_offload' is Tx only.
v6 cover remove mbuf userdata
In reply to Thomas MonjalonThe mbuf field userdata (aliased as udata64)
was announced to be removed for two reasons:
- applications, libraries and drivers used the same field for different purposes, with a risk of usage conflict.
- this field always used 8 bytes even if unneeded
Some dynamic fields are created when needed to replace the big static userdata field.
As a consequence, 8 bytes can be re-allocated to dynamic fields.
This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year.
v6:
- ARK field types different for Rx and Tx
- replace macros with inline functions
v5: sent "timestamp series" by mistake
v4 (thanks Jerin, Nithin and Ed):
- move rte_node dynfield offset to hotter context in cache
- move test-eventdev dynfield offset to hotter context in cache
- split ARK user data for Rx and Tx + more ARK fixes
v3 (thanks Olivier):
- use typedef for new field types
- fix node field type
- initialize offsets to -1
- add more inline functions
- inline rte_security_dynfield_is_registered
- add PMD-specific userdata field for ARK
v2 (thanks David & Andrew):
- fix some indentations
- return -rte_errno consistently
- make some type casts more precise
- define dynfield types in macros
- hide field description in rte_security
- do not lookup security dynfield in ipsec-secgw
- do not use the existing timestamp field for other purpose
Ed Czeck (1):
net/ark: switch user data to dynamic mbuf fields
Nithin Dabilpuram (1):
node: switch IPv4 metadata to dynamic mbuf field
Thomas Monjalon (13):
examples: enclose DPDK includes with angle brackets
kni: move header file from EAL
mbuf: fix typo in dynamic field convention note
security: switch metadata to dynamic mbuf field event/sw: switch test counter to dynamic mbuf field net/bnxt: switch CFA code to dynamic mbuf field net/vmxnet3: switch MSS hint to dynamic mbuf field test/distributor: switch sequence to dynamic mbuf field test/graph: switch user data to dynamic mbuf field app/eventdev: switch flow ID to dynamic mbuf field examples/bbdev: switch to dynamic mbuf field examples/rxtx_callbacks: switch TSC to dynamic field
mbuf: remove userdata field
app/test-eventdev/test_order_atq.c | 4 +-
app/test-eventdev/test_order_common.c | 21 ++-
app/test-eventdev/test_order_common.h | 21 +++
app/test-eventdev/test_order_queue.c | 4 +-
app/test/test_distributor.c | 32 ++++-
app/test/test_graph.c | 99 ++++++++------
doc/api/doxy-api-index.md | 1 +
doc/api/doxy-api.conf.in | 1 +
doc/guides/prog_guide/rte_security.rst | 9 +-
doc/guides/rel_notes/deprecation.rst | 1 -
doc/guides/rel_notes/release_20_11.rst | 3 +
doc/guides/sample_app_ug/rxtx_callbacks.rst | 4 +-
drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 5 +-
drivers/event/sw/sw_evdev_selftest.c | 28 +++-
drivers/net/ark/ark_ethdev.c | 39 ++++++
drivers/net/ark/ark_ethdev_rx.c | 3 +-
drivers/net/ark/ark_ethdev_tx.c | 3 +-
drivers/net/ark/meson.build | 2 +
drivers/net/ark/rte_pmd_ark.h | 125 ++++++++++++++++++
drivers/net/ark/version.map | 7 +
drivers/net/bnxt/bnxt_ethdev.c | 19 +++
drivers/net/bnxt/bnxt_rxr.c | 2 +-
drivers/net/bnxt/bnxt_rxr.h | 10 ++
drivers/net/bnxt/rte_pmd_bnxt.h | 3 +
drivers/net/ixgbe/ixgbe_ipsec.c | 5 +-
drivers/net/ixgbe/ixgbe_rxtx.c | 6 +-
drivers/net/octeontx2/otx2_ethdev.h | 1 +
drivers/net/octeontx2/otx2_ethdev_sec.c | 5 +-
drivers/net/octeontx2/otx2_ethdev_sec_tx.h | 2 +-
drivers/net/octeontx2/otx2_rx.h | 2 +-
drivers/net/vmxnet3/vmxnet3_ethdev.c | 15 +++
drivers/net/vmxnet3/vmxnet3_ethdev.h | 11 ++
drivers/net/vmxnet3/vmxnet3_rxtx.c | 9 +-
examples/bbdev_app/main.c | 72 ++++++----
examples/bond/main.c | 11 +-
examples/ipsec-secgw/ipsec-secgw.c | 9 +-
examples/ipsec-secgw/ipsec_worker.c | 12 +-
examples/rxtx_callbacks/main.c | 24 +++-
kernel/linux/kni/meson.build | 2 +-
lib/librte_eal/linux/include/meson.build | 1 -
lib/librte_kni/meson.build | 2 +-
.../include => librte_kni}/rte_kni_common.h | 2 +-
lib/librte_mbuf/rte_mbuf_core.h | 8 +-
lib/librte_mbuf/rte_mbuf_dyn.h | 2 +-
lib/librte_node/ip4_lookup.c | 40 ++++--
lib/librte_node/ip4_lookup_neon.h | 20 ++-
lib/librte_node/ip4_lookup_sse.h | 36 +++--
lib/librte_node/ip4_rewrite.c | 49 +++++--
lib/librte_node/node_private.h | 13 +-
lib/librte_security/rte_security.c | 16 +++
lib/librte_security/rte_security.h | 42 ++++++
lib/librte_security/rte_security_driver.h | 3 +
lib/librte_security/version.map | 2 +
53 files changed, 681 insertions(+), 187 deletions(-)
create mode 100644 drivers/net/ark/rte_pmd_ark.h
rename lib/{librte_eal/linux/include => librte_kni}/rte_kni_common.h (98%)Signature · 1 line
2.28.0
PATCH v6 1/15 examples: enclose DPDK includes with angle brackets
In examples, DPDK header files are external,
so they must be enclosed with angle brackets, not quotes.
--- examples/bbdev_app/main.c | 30 +++++++++++++++--------------- examples/bond/main.c | 11 ++++------- 2 files changed, 19 insertions(+), 22 deletions(-)
examples/bbdev_app/main.c +15 -15
@@ -18,21 +18,21 @@#include <getopt.h> #include <signal.h> -#include "rte_atomic.h" -#include "rte_common.h" -#include "rte_eal.h" -#include "rte_cycles.h" -#include "rte_ether.h" -#include "rte_ethdev.h" -#include "rte_ip.h" -#include "rte_lcore.h" -#include "rte_malloc.h" -#include "rte_mbuf.h" -#include "rte_memory.h" -#include "rte_mempool.h" -#include "rte_log.h" -#include "rte_bbdev.h" -#include "rte_bbdev_op.h" +#include <rte_atomic.h> +#include <rte_common.h> +#include <rte_eal.h> +#include <rte_cycles.h> +#include <rte_ether.h> +#include <rte_ethdev.h> +#include <rte_ip.h> +#include <rte_lcore.h> +#include <rte_malloc.h> +#include <rte_mbuf.h> +#include <rte_memory.h> +#include <rte_mempool.h> +#include <rte_log.h> +#include <rte_bbdev.h> +#include <rte_bbdev_op.h> /* LLR values - negative value for '1' bit */ #define LLR_1_BIT 0x81
examples/bond/main.c +4 -7
@@ -41,6 +41,10 @@#include <rte_tcp.h> #include <rte_arp.h> #include <rte_spinlock.h> +#include <rte_devargs.h> +#include <rte_byteorder.h> +#include <rte_cpuflags.h> +#include <rte_eth_bond.h> #include <cmdline_rdline.h> #include <cmdline_parse.h>
@@ -53,13 +57,6 @@#include "main.h" -#include <rte_devargs.h> - - -#include "rte_byteorder.h" -#include "rte_cpuflags.h" -#include "rte_eth_bond.h" -#define RTE_LOGTYPE_DCB RTE_LOGTYPE_USER1#define NB_MBUF (1024*8)
Signature · 1 line
2.28.0
PATCH v6 2/15 kni: move header file from EAL
In reply to Thomas MonjalonSince the kernel module is not part of EAL anymore, there is no need to have the common KNI header file in EAL. The file rte_kni_common.h is moved to librte_kni.
---
kernel/linux/kni/meson.build | 2 +-
lib/librte_eal/linux/include/meson.build | 1 -
lib/librte_kni/meson.build | 2 +-
lib/{librte_eal/linux/include => librte_kni}/rte_kni_common.h | 0
4 files changed, 2 insertions(+), 3 deletions(-)
rename lib/{librte_eal/linux/include => librte_kni}/rte_kni_common.h (100%)kernel/linux/kni/meson.build +1 -1
@@ -18,7 +18,7 @@ custom_target('rte_kni', 'src=' + meson.current_source_dir(), 'MODULE_CFLAGS=-include ' + meson.source_root() + '/config/rte_config.h' + ' -I' + meson.source_root() + '/lib/librte_eal/include' + - ' -I' + meson.source_root() + '/lib/librte_eal/linux/include' + + ' -I' + meson.source_root() + '/lib/librte_kni' + ' -I' + meson.build_root() + ' -I' + meson.current_source_dir(), 'modules'],
lib/librte_eal/linux/include/meson.build +0 -1
@@ -4,6 +4,5 @@ includes += include_directories('.') headers += files( - 'rte_kni_common.h', 'rte_os.h', )
lib/librte_kni/meson.build +1 -1
@@ -6,5 +6,5 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64') reason = 'only supported on 64-bit linux' endif sources = files('rte_kni.c') -headers = files('rte_kni.h') +headers = files('rte_kni.h', 'rte_kni_common.h') deps += ['ethdev', 'pci']
lib/librte_kni/rte_kni_common.h renamed from lib/librte_eal/linux/include/rte_kni_common.h +0 -0
Signature · 1 line
2.28.0
PATCH v6 3/15 mbuf: fix typo in dynamic field convention note
In reply to Thomas MonjalonReplace "in a in PMD" with "in a PMD".
--- lib/librte_mbuf/rte_mbuf_dyn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_mbuf/rte_mbuf_dyn.h +1 -1
@@ -62,7 +62,7 @@* conventions than function names in dpdk: * - "rte_mbuf_dynfield_<name>" if defined in mbuf library * - "rte_<libname>_dynfield_<name>" if defined in another library -* - "rte_net_<pmd>_dynfield_<name>" if defined in a in PMD +* - "rte_net_<pmd>_dynfield_<name>" if defined in a PMD * - any name that does not start with "rte_" in an application */
Signature · 1 line
2.28.0
PATCH v6 4/15 node: switch IPv4 metadata to dynamic mbuf field
In reply to Thomas MonjalonFrom: Nithin Dabilpuram <[email protected]>
The node_mbuf_priv1 was stored in the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64.
--- lib/librte_node/ip4_lookup.c | 40 ++++++++++++++++++------- lib/librte_node/ip4_lookup_neon.h | 20 ++++++------- lib/librte_node/ip4_lookup_sse.h | 36 +++++++++++------------ lib/librte_node/ip4_rewrite.c | 49 +++++++++++++++++++++++-------- lib/librte_node/node_private.h | 13 ++++++-- 5 files changed, 103 insertions(+), 55 deletions(-)
lib/librte_node/ip4_lookup.c +30 -10
@@ -29,8 +29,23 @@ struct ip4_lookup_node_main {struct rte_lpm *lpm_tbl[RTE_MAX_NUMA_NODES ]; }; +struct ip4_lookup_node_ctx { +/* Socket's LPM table */ +struct rte_lpm *lpm; +/* Dynamic offset to mbuf priv1 */ +int mbuf_priv1_off; +}; + +int node_mbuf_priv1_dynfield_offset =-1 ; +static struct ip4_lookup_node_main ip4_lookup_nm; +#define IP4_LOOKUP_NODE_LPM (ctx) \ + (((struct ip4_lookup_node_ctx *)ctx)->lpm) + +#define IP4_LOOKUP_NODE_PRIV1_OFF (ctx) \ + (((struct ip4_lookup_node_ctx *)ctx)->mbuf_priv1_off) +#if defined(__ARM_NEON)#include "ip4_lookup_neon.h" #elif defined(RTE_ARCH_X86 )
@@ -41,12 +56,13 @@ static uint16_t ip4_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs) { + struct rte_lpm *lpm = IP4_LOOKUP_NODE_LPM(node->ctx); +const int dyn =IP4_LOOKUP_NODE_PRIV1_OFF (node->ctx);struct rte_ipv4_hdr *ipv4_hdr;void **to_next, **from;uint16_t last_spec =0 ;struct rte_mbuf *mbuf;rte_edge_t next_index; -struct rte_lpm *lpm;uint16_t held =0 ;uint32_t drop_nh;int i, rc;
@@ -55,9 +71,6 @@ ip4_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node, next_index =RTE_NODE_IP4_LOOKUP_NEXT_REWRITE ;/* Drop node */ drop_nh = ((uint32_t )RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP ) <<16 ; - -/* Get socket specific LPM from ctx */ - lpm = *((struct rte_lpm **)node->ctx); from = objs;/* Get stream for the speculated next node */
@@ -72,14 +85,14 @@ ip4_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node, ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,sizeof (struct rte_ether_hdr ));/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf, dyn)->ttl = ipv4_hdr->time_to_live; rc =rte_lpm_lookup (lpm,rte_be_to_cpu_32 (ipv4_hdr->dst_addr), &next_hop); next_hop = (rc ==0 ) ? next_hop : drop_nh; -node_mbuf_priv1 (mbuf)->nh = (uint16_t )next_hop; +node_mbuf_priv1 (mbuf, dyn)->nh = (uint16_t )next_hop; next_hop = next_hop >>16 ; next = (uint16_t )next_hop;
@@ -169,15 +182,19 @@ setup_lpm(struct ip4_lookup_node_main *nm, int socket)static int ip4_lookup_node_init (const struct rte_graph *graph,struct rte_node *node) { -struct rte_lpm **lpm_p = (struct rte_lpm **)&node->ctx;uint16_t socket, lcore_id;static uint8_t init_once;int rc;RTE_SET_USED (graph); -RTE_SET_USED (node); +RTE_BUILD_BUG_ON (sizeof (struct ip4_lookup_node_ctx ) >RTE_NODE_CTX_SZ );if (!init_once) { + node_mbuf_priv1_dynfield_offset =rte_mbuf_dynfield_register ( + &node_mbuf_priv1_dynfield_desc); +if (node_mbuf_priv1_dynfield_offset <0 ) +return -rte_errno; +/* Setup LPM tables for all sockets */ RTE_LCORE_FOREACH (lcore_id) {
@@ -192,7 +209,10 @@ ip4_lookup_node_init(const struct rte_graph *graph, struct rte_node *node) } init_once =1 ; } - *lpm_p = ip4_lookup_nm.lpm_tbl[graph->socket]; + +/* Update socket's LPM and mbuf dyn priv1 offset in node ctx */ +IP4_LOOKUP_NODE_LPM (node->ctx) = ip4_lookup_nm.lpm_tbl[graph->socket]; +IP4_LOOKUP_NODE_PRIV1_OFF (node->ctx) = node_mbuf_priv1_dynfield_offset;#if defined(__ARM_NEON) || defined(RTE_ARCH_X86 )if (rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 )
lib/librte_node/ip4_lookup_neon.h +9 -11
@@ -11,12 +11,13 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs) {struct rte_mbuf *mbuf0, *mbuf1, *mbuf2, *mbuf3, **pkts; +struct rte_lpm *lpm =IP4_LOOKUP_NODE_LPM (node->ctx); +const int dyn =IP4_LOOKUP_NODE_PRIV1_OFF (node->ctx);struct rte_ipv4_hdr *ipv4_hdr;void **to_next, **from;uint16_t last_spec =0 ;rte_edge_t next_index;uint16_t n_left_from; -struct rte_lpm *lpm;uint16_t held =0 ;uint32_t drop_nh;rte_xmm_t result;
@@ -30,9 +31,6 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,/* Drop node */ drop_nh = ((uint32_t )RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP ) <<16 ; -/* Get socket specific LPM from ctx */ - lpm = *((struct rte_lpm **)node->ctx); - pkts = (struct rte_mbuf **)objs; from = objs; n_left_from = nb_objs;
@@ -119,10 +117,10 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, priv23.u16[0 ] = result.u16[4 ]; priv23.u16[4 ] = result.u16[6 ]; -node_mbuf_priv1 (mbuf0)->u = priv01.u64[0 ]; -node_mbuf_priv1 (mbuf1)->u = priv01.u64[1 ]; -node_mbuf_priv1 (mbuf2)->u = priv23.u64[0 ]; -node_mbuf_priv1 (mbuf3)->u = priv23.u64[1 ]; +node_mbuf_priv1 (mbuf0, dyn)->u = priv01.u64[0 ]; +node_mbuf_priv1 (mbuf1, dyn)->u = priv01.u64[1 ]; +node_mbuf_priv1 (mbuf2, dyn)->u = priv23.u64[0 ]; +node_mbuf_priv1 (mbuf3, dyn)->u = priv23.u64[1 ];/* Enqueue four to next node */ rte_edge_t fix_spec = ((next_index == result.u16[1]) &&
@@ -197,14 +195,14 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf0, struct rte_ipv4_hdr *,sizeof (struct rte_ether_hdr ));/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf0)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf0)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf0, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf0, dyn)->ttl = ipv4_hdr->time_to_live; rc =rte_lpm_lookup (lpm,rte_be_to_cpu_32 (ipv4_hdr->dst_addr), &next_hop); next_hop = (rc ==0 ) ? next_hop : drop_nh; -node_mbuf_priv1 (mbuf0)->nh = (uint16_t )next_hop; +node_mbuf_priv1 (mbuf0, dyn)->nh = (uint16_t )next_hop; next_hop = next_hop >>16 ; next0 = (uint16_t )next_hop;
lib/librte_node/ip4_lookup_sse.h +17 -19
@@ -11,13 +11,14 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs) {struct rte_mbuf *mbuf0, *mbuf1, *mbuf2, *mbuf3, **pkts; +struct rte_lpm *lpm =IP4_LOOKUP_NODE_LPM (node->ctx); +const int dyn =IP4_LOOKUP_NODE_PRIV1_OFF (node->ctx);rte_edge_t next0, next1, next2, next3, next_index;struct rte_ipv4_hdr *ipv4_hdr;uint32_t ip0, ip1, ip2, ip3;void **to_next, **from;uint16_t last_spec =0 ;uint16_t n_left_from; -struct rte_lpm *lpm;uint16_t held =0 ;uint32_t drop_nh;rte_xmm_t dst;
@@ -29,9 +30,6 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,/* Drop node */ drop_nh = ((uint32_t )RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP ) <<16 ; -/* Get socket specific LPM from ctx */ - lpm = *((struct rte_lpm **)node->ctx); - pkts = (struct rte_mbuf **)objs; from = objs; n_left_from = nb_objs;
@@ -78,24 +76,24 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, sizeof(struct rte_ether_hdr)); ip0 = ipv4_hdr->dst_addr;/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf0)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf0)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf0, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf0, dyn)->ttl = ipv4_hdr->time_to_live;/* Extract DIP of mbuf1 */ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf1, struct rte_ipv4_hdr *,sizeof (struct rte_ether_hdr )); ip1 = ipv4_hdr->dst_addr;/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf1)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf1)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf1, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf1, dyn)->ttl = ipv4_hdr->time_to_live;/* Extract DIP of mbuf2 */ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf2, struct rte_ipv4_hdr *,sizeof (struct rte_ether_hdr )); ip2 = ipv4_hdr->dst_addr;/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf2)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf2)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf2, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf2, dyn)->ttl = ipv4_hdr->time_to_live;/* Extract DIP of mbuf3 */ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf3, struct rte_ipv4_hdr *,
@@ -111,23 +109,23 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, dip =_mm_shuffle_epi8 (dip, bswap_mask);/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf3)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf3)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf3, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf3, dyn)->ttl = ipv4_hdr->time_to_live;/* Perform LPM lookup to get NH and next node */ rte_lpm_lookupx4 (lpm, dip, dst.u32, drop_nh);/* Extract next node id and NH */ -node_mbuf_priv1 (mbuf0)->nh = dst.u32[0 ] &0xFFFF ; +node_mbuf_priv1 (mbuf0, dyn)->nh = dst.u32[0 ] &0xFFFF ; next0 = (dst.u32[0 ] >>16 ); -node_mbuf_priv1 (mbuf1)->nh = dst.u32[1 ] &0xFFFF ; +node_mbuf_priv1 (mbuf1, dyn)->nh = dst.u32[1 ] &0xFFFF ; next1 = (dst.u32[1 ] >>16 ); -node_mbuf_priv1 (mbuf2)->nh = dst.u32[2 ] &0xFFFF ; +node_mbuf_priv1 (mbuf2, dyn)->nh = dst.u32[2 ] &0xFFFF ; next2 = (dst.u32[2 ] >>16 ); -node_mbuf_priv1 (mbuf3)->nh = dst.u32[3 ] &0xFFFF ; +node_mbuf_priv1 (mbuf3, dyn)->nh = dst.u32[3 ] &0xFFFF ; next3 = (dst.u32[3 ] >>16 );/* Enqueue four to next node */
@@ -202,14 +200,14 @@ ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node, ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf0, struct rte_ipv4_hdr *,sizeof (struct rte_ether_hdr ));/* Extract cksum, ttl as ipv4 hdr is in cache */ -node_mbuf_priv1 (mbuf0)->cksum = ipv4_hdr->hdr_checksum; -node_mbuf_priv1 (mbuf0)->ttl = ipv4_hdr->time_to_live; +node_mbuf_priv1 (mbuf0, dyn)->cksum = ipv4_hdr->hdr_checksum; +node_mbuf_priv1 (mbuf0, dyn)->ttl = ipv4_hdr->time_to_live; rc =rte_lpm_lookup (lpm,rte_be_to_cpu_32 (ipv4_hdr->dst_addr), &next_hop); next_hop = (rc ==0 ) ? next_hop : drop_nh; -node_mbuf_priv1 (mbuf0)->nh = next_hop &0xFFFF ; +node_mbuf_priv1 (mbuf0, dyn)->nh = next_hop &0xFFFF ; next0 = (next_hop >>16 );if (unlikely (next_index ^ next0)) {
lib/librte_node/ip4_rewrite.c +37 -12
101 lines not on this page · raw message
lib/librte_node/node_private.h +10 -3
@@ -8,6 +8,7 @@#include <rte_common.h> #include <rte_log.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> extern int rte_node_logtype;#define NODE_LOG (level, node_name, ...) \
@@ -21,7 +22,6 @@ extern int rte_node_logtype;#define node_dbg (node_name, ...) NODE_LOG(DEBUG, node_name, __VA_ARGS__)/** -* * Node mbuf private data to store next hop, ttl and checksum. */ struct node_mbuf_priv1 {
@@ -37,6 +37,13 @@ struct node_mbuf_priv1 { }; }; +static const struct rte_mbuf_dynfield node_mbuf_priv1_dynfield_desc = { + .name ="rte_node_dynfield_priv1" , + .size =sizeof (struct node_mbuf_priv1 ), + .align = __alignof__(struct node_mbuf_priv1 ), +}; +extern int node_mbuf_priv1_dynfield_offset; +/** * Node mbuf private area 2. */
@@ -58,9 +65,9 @@ struct node_mbuf_priv2 {* Pointer to the mbuf_priv1. */ static __rte_always_inline struct node_mbuf_priv1 * -node_mbuf_priv1 (struct rte_mbuf *m) +node_mbuf_priv1 (struct rte_mbuf *m,const int offset) { -return (struct node_mbuf_priv1 *)&m->udata64; + return RTE_MBUF_DYNFIELD(m, offset, struct node_mbuf_priv1 *); }/**
Signature · 1 line
2.28.0
PATCH v6 5/15 security: switch metadata to dynamic mbuf field
In reply to Thomas MonjalonThe device-specific metadata was stored in the deprecated field udata64. It is moved to a dynamic mbuf field in order to allow removal of udata64.
The name rte_security_dynfield is not very descriptive
but it should be replaced later by separate fields for each type of data that drivers pass to the upper layer.
--- doc/guides/prog_guide/rte_security.rst | 9 ++-- drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 5 ++- drivers/net/ixgbe/ixgbe_ipsec.c | 5 ++- drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++- drivers/net/octeontx2/otx2_ethdev.h | 1 + drivers/net/octeontx2/otx2_ethdev_sec.c | 5 ++- drivers/net/octeontx2/otx2_ethdev_sec_tx.h | 2 +- drivers/net/octeontx2/otx2_rx.h | 2 +- examples/ipsec-secgw/ipsec-secgw.c | 9 ++-- examples/ipsec-secgw/ipsec_worker.c | 12 ++++-- lib/librte_security/rte_security.c | 16 +++++++ lib/librte_security/rte_security.h | 42 +++++++++++++++++++ lib/librte_security/rte_security_driver.h | 3 ++ lib/librte_security/version.map | 2 + 14 files changed, 99 insertions(+), 20 deletions(-)
doc/guides/prog_guide/rte_security.rst +5 -4
@@ -125,8 +125,9 @@ ESP/AH headers will be removed from the packet and the received packet will contains the decrypted packet only. The driver Rx path checks the descriptors and based on the crypto status sets additional flags in ``rte_mbuf.ol_flags`` field. The driver would also set device-specific -metadata in ``rte_mbuf.udata64`` field. This will allow the application -to identify the security processing done on the packet. +metadata in ``RTE_SECURITY_DYNFIELD_NAME`` field. +This will allow the application to identify the security processing +done on the packet. .. note::
@@ -568,8 +569,8 @@ security session which processed the packet. .. note:: - In case of inline processed packets, ``rte_mbuf.udata64`` field would be - used by the driver to relay information on the security processing + In case of inline processed packets, ``RTE_SECURITY_DYNFIELD_NAME`` field + would be used by the driver to relay information on the security processing associated with the packet. In ingress, the driver would set this in Rx path while in egress, ``rte_security_set_pkt_metadata()`` would perform a similar operation. The application is expected not to modify the field
drivers/crypto/octeontx2/otx2_cryptodev_sec.c +4 -1
@@ -455,6 +455,9 @@ otx2_crypto_sec_session_create(void *device,if (conf->action_type !=RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL )return -ENOTSUP ; +if (rte_security_dynfield_register () <0 ) +return -rte_errno; +if (rte_mempool_get (mempool, (void **)&priv)) {otx2_err ("Could not allocate security session private data" );return -ENOMEM ;
@@ -514,7 +517,7 @@ otx2_crypto_sec_set_pkt_mdata(void *device __rte_unused, struct rte_mbuf *m, void *params __rte_unused) {/* Set security session as the pkt metadata */ - m->udata64 = (uint64_t)session; + *rte_security_dynfield (m ) = (rte_security_dynfield_t )session;return 0 ; }
drivers/net/ixgbe/ixgbe_ipsec.c +4 -1
@@ -484,7 +484,8 @@ ixgbe_crypto_update_mb(void *device __rte_unused,get_sec_session_private_data (session);if (ic_session->op ==IXGBE_OP_AUTHENTICATED_ENCRYPTION ) {union ixgbe_crypto_tx_desc_md *mdata = - (union ixgbe_crypto_tx_desc_md *)&m->udata64; + (union ixgbe_crypto_tx_desc_md *) +rte_security_dynfield (m); mdata->enc =1 ; mdata->sa_idx = ic_session->sa_index; mdata->pad_len =ixgbe_crypto_compute_pad_len (m);
@@ -751,5 +752,7 @@ ixgbe_ipsec_ctx_create(struct rte_eth_dev *dev)return -ENOMEM ; } } +if (rte_security_dynfield_register () <0 ) +return -rte_errno;return 0 ; }
drivers/net/ixgbe/ixgbe_rxtx.c +4 -2
@@ -34,6 +34,7 @@#include <rte_mbuf.h> #include <rte_ether.h> #include <rte_ethdev_driver.h> +#include <rte_security_driver.h> #include <rte_prefetch.h> #include <rte_udp.h> #include <rte_tcp.h>
@@ -694,7 +695,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,if (use_ipsec) {union ixgbe_crypto_tx_desc_md *ipsec_mdata = (union ixgbe_crypto_tx_desc_md *) - &tx_pkt->udata64; +rte_security_dynfield (tx_pkt); tx_offload.sa_idx = ipsec_mdata->sa_idx; tx_offload.sec_pad_len = ipsec_mdata->pad_len; }
@@ -859,7 +860,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, }ixgbe_set_xmit_ctx (txq, ctx_txd, tx_ol_req, - tx_offload, &tx_pkt->udata64); + tx_offload, +rte_security_dynfield (tx_pkt)); txe->last_id = tx_last; tx_id = txe->next_id;
drivers/net/octeontx2/otx2_ethdev.h +1 -0
@@ -13,6 +13,7 @@#include <rte_kvargs.h> #include <rte_mbuf.h> #include <rte_mempool.h> +#include <rte_security_driver.h> #include <rte_string_fns.h> #include <rte_time.h>
drivers/net/octeontx2/otx2_ethdev_sec.c +4 -1
@@ -684,7 +684,7 @@ otx2_eth_sec_set_pkt_mdata(void *device __rte_unused, struct rte_mbuf *m, void *params __rte_unused) {/* Set security session as the pkt metadata */ - m->udata64 = (uint64_t)session; + *rte_security_dynfield (m ) = (rte_security_dynfield_t )session;return 0 ; }
@@ -831,6 +831,9 @@ otx2_eth_sec_init(struct rte_eth_dev *eth_dev) !(dev->rx_offloads & DEV_RX_OFFLOAD_SECURITY))return 0 ; +if (rte_security_dynfield_register () <0 ) +return -rte_errno; + nb_sa = dev->ipsec_in_max_spi; mz_sz = nb_sa * sa_width;in_sa_mz_name_get (name,RTE_MEMZONE_NAMESIZE , port);
drivers/net/octeontx2/otx2_ethdev_sec_tx.h +1 -1
@@ -55,7 +55,7 @@ otx2_sec_event_tx(struct otx2_ssogws *ws, struct rte_event *ev,struct nix_iova_s nix_iova; } *sd; - priv =get_sec_session_private_data ((void *)(m->udata64)); + priv =get_sec_session_private_data ((void *)(*rte_security_dynfield (m))); sess = &priv->ipsec.ip; sa = &sess->out_sa;
drivers/net/octeontx2/otx2_rx.h +1 -1
@@ -241,7 +241,7 @@ nix_rx_sec_mbuf_update(const struct nix_cqe_hdr_s *cq, struct rte_mbuf *m, spi = cq->tag &0xFFFFF ; sa =nix_rx_sec_sa_get (lookup_mem, spi, m->port); - m->udata64 = (uint64_t )sa->userdata; + *rte_security_dynfield (m) = sa->udata64; data = rte_pktmbuf_mtod(m, char *);
examples/ipsec-secgw/ipsec-secgw.c +4 -5
@@ -426,7 +426,8 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)* with the security session. */ -if (pkt->ol_flags &PKT_RX_SEC_OFFLOAD ) { +if (pkt->ol_flags &PKT_RX_SEC_OFFLOAD && +rte_security_dynfield_is_registered ()) {struct ipsec_sa *sa;struct ipsec_mbuf_metadata *priv; struct rte_security_ctx *ctx = (struct rte_security_ctx *)
@@ -436,10 +437,8 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)/* Retrieve the userdata registered. Here, the userdata * registered is the SA pointer. */ - - sa = (struct ipsec_sa *) -rte_security_get_userdata (ctx, pkt->udata64); - + sa = (struct ipsec_sa *)rte_security_get_userdata (ctx, + *rte_security_dynfield (pkt));if (sa ==NULL ) {/* userdata could not be retrieved */ return ;
examples/ipsec-secgw/ipsec_worker.c +8 -4
@@ -208,7 +208,7 @@ process_ipsec_ev_inbound(struct ipsec_ctx *ctx, struct route_table *rt, "Inbound security offload failed\n"); goto drop_pkt_and_exit; } - sa = pkt->userdata; + sa = *(struct ipsec_sa **)rte_security_dynfield (pkt); }/* Check if we have a match */
@@ -226,7 +226,7 @@ process_ipsec_ev_inbound(struct ipsec_ctx *ctx, struct route_table *rt, "Inbound security offload failed\n"); goto drop_pkt_and_exit; } - sa = pkt->userdata; + sa = *(struct ipsec_sa **)rte_security_dynfield (pkt); }/* Check if we have a match */
@@ -357,7 +357,8 @@ process_ipsec_ev_outbound(struct ipsec_ctx *ctx, struct route_table *rt, }if (sess->security.ol_flags &RTE_SECURITY_TX_OLOAD_NEED_MDATA ) - pkt->userdata = sess->security.ses; + *(struct rte_security_session **)rte_security_dynfield (pkt) = + sess->security.ses;/* Mark the packet for Tx security offload */ pkt->ol_flags |=PKT_TX_SEC_OFFLOAD ;
@@ -465,7 +466,10 @@ ipsec_wrkr_non_burst_int_port_drv_mode(struct eh_event_link_info *links, }/* Save security session */ - pkt->userdata = sess_tbl[port_id]; +if (rte_security_dynfield_is_registered ()) + *(struct rte_security_session **) +rte_security_dynfield (pkt) = + sess_tbl[port_id];/* Mark the packet for Tx security offload */ pkt->ol_flags |=PKT_TX_SEC_OFFLOAD ;
lib/librte_security/rte_security.c +16 -0
@@ -23,6 +23,22 @@RTE_PTR_OR_ERR_RET (p1->p2->p3, last_retval); \ } while (0) +#define RTE_SECURITY_DYNFIELD_NAME "rte_security_dynfield_metadata" +int rte_security_dynfield_offset =-1 ; + +int +rte_security_dynfield_register (void ) +{ +static const struct rte_mbuf_dynfield dynfield_desc = { + .name =RTE_SECURITY_DYNFIELD_NAME , + .size =sizeof (rte_security_dynfield_t), + .align = __alignof__(rte_security_dynfield_t ), + }; + rte_security_dynfield_offset = +rte_mbuf_dynfield_register (&dynfield_desc); +return rte_security_dynfield_offset; +} +struct rte_security_session * rte_security_session_create(struct rte_security_ctx *instance, struct rte_security_session_conf *conf,
lib/librte_security/rte_security.h +42 -0
54 lines not on this page · raw message
lib/librte_security/rte_security_driver.h +3 -0
@@ -89,6 +89,9 @@ typedef int (*security_session_stats_get_t)(void *device,struct rte_security_session *sess, struct rte_security_stats *stats); +__rte_experimental +int rte_security_dynfield_register(void); +/** * Update the mbuf with provided metadata. *
lib/librte_security/version.map +2 -0
@@ -15,6 +15,8 @@ DPDK_21 { EXPERIMENTAL { global: + rte_security_dynfield_offset; + rte_security_dynfield_register; rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update;
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v6 05/15] security: switch metadata to dynamic mbuf field
Quoted 10 lines · Thomas Monjalon
The device-specific metadata was stored in the deprecated field udata64. It is moved to a dynamic mbuf field in order to allow removal of udata64.
The name
rte_security_dynfieldis not very descriptive
but it should be replaced later by separate fields for each type of data that drivers pass to the upper layer.Signed-off-by Thomas Monjalon <[email protected]>Acked-by Haiyue Wang <[email protected]>
We have a regression in the mbuf unit test when running with probed ixgbe devices (UNH lab).
The problem is that the security dyn field is registered when probing the ixgbe devices.
The unit test fails later while checking one of its own registered dynfield offset.
I can reproduce the issue by stopping at this patch in the series and adding the below diff.
The problem can be seen with the whole series applied, there is only a difference in reported dynfield offsets.
app/test/test_mbuf.c +2 -0
@@ -33,6 +33,7 @@#include <rte_ip.h> #include <rte_tcp.h> #include <rte_mbuf_dyn.h> +#include <rte_security_driver.h> #include "test.h"
@@ -2589,6 +2590,7 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)int ret;printf ("Test mbuf dynamic fields and flags\n" ); +rte_security_dynfield_register ();rte_mbuf_dyn_dump (stdout); offset =rte_mbuf_dynfield_register (&dynfield);
Then:
# DPDK_TEST=mbuf_autotest ./build/app/test/dpdk-test
EAL: Detected 8 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: No available hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
APP: HPET is not enabled, using TSC as default timer RTE>>mbuf_autotest
Test mbuf dynamic fields and flags
Reserved fields:
name=rte_security_dynfield_metadata offset=112 size=8 align=8 flags=0
Reserved flags:
Free space in mbuf (0 = occupied, value = free zone alignment):
0000: 00 00 00 00 00 00 00 00
0008: 00 00 00 00 00 00 00 00
0010: 00 00 00 00 00 00 00 00
0018: 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00
0028: 00 00 00 00 00 00 00 00
0030: 00 00 00 00 00 00 00 00
0038: 00 00 00 00 00 00 00 00
0040: 00 00 00 00 00 00 00 00
0048: 00 00 00 00 00 00 00 00
0050: 00 00 00 00 00 00 00 00
0058: 00 00 00 00 00 00 00 00
0060: 00 00 00 00 00 00 00 00
0068: 00 00 00 00 00 00 00 00
0070: 00 00 00 00 00 00 00 00
0078: 08 08 08 08 08 08 08 08
Free bit in mbuf->ol_flags (0 = occupied, 1 = free):
0000: 0 0 0 0 0 0 0 0
0008: 0 0 0 0 0 0 0 0
0010: 0 0 0 0 0 0 0 1
0018: 1 1 1 1 1 1 1 1
0020: 1 1 1 1 1 1 1 1
0028: 1 0 0 0 0 0 0 0
0030: 0 0 0 0 0 0 0 0
0038: 0 0 0 0 0 0 0 0
mbuf test FAILED (l.2615): <failed to register dynamic field 3, offset=-1: No such file or directory>
mbuf dynflag test failed
Test Failed
A lazy fix is to simply ask for registering a field at offset sizeof(dynfield) - 1 .. what do you think?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v6 05/15] security: switch metadata to dynamic mbuf field
Quoted 2 lines · David Marchand
A lazy fix is to simply ask for registering a field at offset sizeof(dynfield) - 1 .. what do you think?
I meant sizeof(struct rte_mbuf) - 1.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v6 05/15] security: switch metadata to dynamic mbuf field
In reply to David Marchand31/10/2020 09:56, David Marchand:
Quoted 93 lines · Thomas Monjalon
Quoted 10 lines
The device-specific metadata was stored in the deprecated field udata64. It is moved to a dynamic mbuf field in order to allow removal of udata64.
The name
rte_security_dynfieldis not very descriptive
but it should be replaced later by separate fields for each type of data that drivers pass to the upper layer.Signed-off-by Thomas Monjalon <[email protected]>Acked-by Haiyue Wang <[email protected]>We have a regression in the mbuf unit test when running with probed ixgbe devices (UNH lab).
The problem is that the security dyn field is registered when probing the ixgbe devices.
The unit test fails later while checking one of its own registered dynfield offset.I can reproduce the issue by stopping at this patch in the series and adding the below diff.
The problem can be seen with the whole series applied, there is only a difference in reported dynfield offsets.app/test/test_mbuf.c +2
-0@@ -33,6 +33,7 @@#include <rte_ip.h> #include <rte_tcp.h> #include <rte_mbuf_dyn.h> +#include <rte_security_driver.h> #include "test.h" @@ -2589,6 +2590,7 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)int ret;printf ("Test mbuf dynamic fields and flags\n" ); +rte_security_dynfield_register ();rte_mbuf_dyn_dump (stdout); offset =rte_mbuf_dynfield_register (&dynfield);Then:
# DPDK_TEST=mbuf_autotest ./build/app/test/dpdk-test
EAL: Detected 8 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket/var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: No available hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
APP: HPET is not enabled, using TSC as default timer RTE>>mbuf_autotest
Test mbuf dynamic fields and flags
Reserved fields:
name=rte_security_dynfield_metadata offset=112 size=8 align=8 flags=0
Reserved flags:
Free space in mbuf (0 = occupied, value = free zone alignment):
0000: 00 00 00 00 00 00 00 00
0008: 00 00 00 00 00 00 00 00
0010: 00 00 00 00 00 00 00 00
0018: 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00
0028: 00 00 00 00 00 00 00 00
0030: 00 00 00 00 00 00 00 00
0038: 00 00 00 00 00 00 00 00
0040: 00 00 00 00 00 00 00 00
0048: 00 00 00 00 00 00 00 00
0050: 00 00 00 00 00 00 00 00
0058: 00 00 00 00 00 00 00 00
0060: 00 00 00 00 00 00 00 00
0068: 00 00 00 00 00 00 00 00
0070: 00 00 00 00 00 00 00 00
0078: 08 08 08 08 08 08 08 08
Free bit inmbuf->ol_flags(0 = occupied, 1 = free):
0000: 0 0 0 0 0 0 0 0
0008: 0 0 0 0 0 0 0 0
0010: 0 0 0 0 0 0 0 1
0018: 1 1 1 1 1 1 1 1
0020: 1 1 1 1 1 1 1 1
0028: 1 0 0 0 0 0 0 0
0030: 0 0 0 0 0 0 0 0
0038: 0 0 0 0 0 0 0 0
mbuf test FAILED (l.2615): <failed to register dynamic field 3, offset=-1: No such file or directory>
mbuf dynflag test failed
Test Failed
Quoted 2 lines
A lazy fix is to simply ask for registering a field at offset sizeof(dynfield) - 1 .. what do you think?
I think any offset could be registered,
so it looks more correct to skip the failure if rte_errno is EBUSY. I did this fix:
https://patches.dpdk.org/patch/83175/
PATCH v6 6/15 event/sw: switch test counter to dynamic mbuf field
In reply to Thomas MonjalonThe test worker_loopback used the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64.
--- drivers/event/sw/sw_evdev_selftest.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev_selftest.c +25 -3
@@ -40,6 +40,16 @@ struct test {uint32_t service_id; }; +typedef uint8_t counter_dynfield_t ; +static int counter_dynfield_offset =-1 ; + +static inline counter_dynfield_t * +counter_field (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, \ + counter_dynfield_offset, counter_dynfield_t *); +} +static struct rte_event release_ev; static inline struct rte_mbuf *
@@ -2987,8 +2997,8 @@ worker_loopback_worker_fn(void *arg) } ev[i].queue_id =0 ; - ev[i].mbuf->udata64++; -if (ev[i].mbuf->udata64 !=16 ) { + (*counter_field (ev[i].mbuf))++; +if (*counter_field (ev[i].mbuf) !=16 ) { ev[i].op =RTE_EVENT_OP_FORWARD ; enqd =rte_event_enqueue_burst (evdev, port, &ev[i],1 );
@@ -3028,7 +3038,7 @@ worker_loopback_producer_fn(void *arg) m =rte_pktmbuf_alloc (t->mbuf_pool); }while (m ==NULL ); - m->udata64 =0 ; + *counter_field (m) =0 ;struct rte_event ev = { .op =RTE_EVENT_OP_NEW ,
@@ -3061,6 +3071,18 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release)int err;int w_lcore, p_lcore; +static const struct rte_mbuf_dynfield counter_dynfield_desc = { + .name ="rte_event_sw_dynfield_selftest_counter" , + .size =sizeof (counter_dynfield_t), + .align = __alignof__(counter_dynfield_t ), + }; + counter_dynfield_offset = +rte_mbuf_dynfield_register (&counter_dynfield_desc); +if (counter_dynfield_offset <0 ) { +printf ("Error registering mbuf field\n" ); +return -rte_errno; + } +if (init (t,8 ,2 ) <0 ||create_atomic_qids (t,8 ) <0 ) {printf ("%d: Error initializing device\n" , __LINE__);
Signature · 1 line
2.28.0
Re: [dpdk-dev] [PATCH v6 06/15] event/sw: switch test counter to dynamic mbuf field
Quoted 10 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, October 30, 2020 5:45 PM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Van Haaren, Harry <[email protected]>
Subject: [PATCH v6 06/15] event/sw: switch test counter to dynamic mbuf field
Quoted 5 lines
The test
worker_loopbackused the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Review fine, tests fine, thanks!
PATCH v6 7/15 net/ark: switch user data to dynamic mbuf fields
In reply to Thomas MonjalonFrom: Ed Czeck <[email protected]>
The second field of metadata is reserved for user data which was using a deprecated mbuf field.
It is moved to dynamic fields in order to allow removal of udata64.
The use of meta data must be enabled with a compile-time flag RTE_PMD_ARK_{TX,RX}_USERDATA_ENABLE.
User data on Tx and Rx paths can be defined and used separately.
--- doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + drivers/net/ark/ark_ethdev.c | 39 ++++++++++ drivers/net/ark/ark_ethdev_rx.c | 3 +- drivers/net/ark/ark_ethdev_tx.c | 3 +- drivers/net/ark/meson.build | 2 + drivers/net/ark/rte_pmd_ark.h | 125 ++++++++++++++++++++++++++++++++ drivers/net/ark/version.map | 7 ++ 8 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ark/rte_pmd_ark.h
doc/api/doxy-api-index.md +1 -0
@@ -41,6 +41,7 @@ The public API headers are grouped by topics: [vhost] (@ref rte_vhost.h), [vdpa] (@ref rte_vdpa.h), [KNI] (@ref rte_kni.h), + [ark] (@ref rte_pmd_ark.h), [ixgbe] (@ref rte_pmd_ixgbe.h), [i40e] (@ref rte_pmd_i40e.h), [ice] (@ref rte_pmd_ice.h),
doc/api/doxy-api.conf.in +1 -0
@@ -8,6 +8,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/drivers/bus/vdev \ @TOPDIR@/drivers/crypto/scheduler \ @TOPDIR@/drivers/mempool/dpaa2 \ + @TOPDIR@/drivers/net/ark \ @TOPDIR@/drivers/net/bnxt \ @TOPDIR@/drivers/net/bonding \ @TOPDIR@/drivers/net/dpaa \
drivers/net/ark/ark_ethdev.c +39 -0
@@ -10,6 +10,7 @@#include <rte_ethdev_pci.h> #include <rte_kvargs.h> +#include "rte_pmd_ark.h" #include "ark_global.h" #include "ark_logs.h" #include "ark_ethdev_tx.h"
@@ -78,6 +79,9 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);#define ARK_TX_MAX_QUEUE (4096 * 4)#define ARK_TX_MIN_QUEUE (256) +int rte_pmd_ark_rx_userdata_dynfield_offset =-1 ; +int rte_pmd_ark_tx_userdata_dynfield_offset =-1 ; +static const char *const valid_arguments[] = {ARK_PKTGEN_ARG ,ARK_PKTCHKR_ARG ,
@@ -245,6 +249,16 @@ eth_ark_dev_init(struct rte_eth_dev *dev)int ret;int port_count =1 ;int p; +static const struct rte_mbuf_dynfield ark_tx_userdata_dynfield_desc = { + .name =RTE_PMD_ARK_TX_USERDATA_DYNFIELD_NAME , + .size =sizeof (rte_pmd_ark_tx_userdata_t), + .align = __alignof__(rte_pmd_ark_tx_userdata_t ), + }; +static const struct rte_mbuf_dynfield ark_rx_userdata_dynfield_desc = { + .name =RTE_PMD_ARK_RX_USERDATA_DYNFIELD_NAME , + .size =sizeof (rte_pmd_ark_rx_userdata_t), + .align = __alignof__(rte_pmd_ark_rx_userdata_t ), + }; ark->eth_dev = dev;
@@ -254,6 +268,31 @@ eth_ark_dev_init(struct rte_eth_dev *dev) ret =check_for_ext (ark);if (ret)return ret; + +/* Extra mbuf fields for user data */ +if (RTE_PMD_ARK_TX_USERDATA_ENABLE ) { + rte_pmd_ark_tx_userdata_dynfield_offset = +rte_mbuf_dynfield_register (&ark_tx_userdata_dynfield_desc); +if (rte_pmd_ark_tx_userdata_dynfield_offset <0 ) { +ARK_PMD_LOG (ERR , +"Failed to register mbuf field for tx userdata\n" ); +return -rte_errno; + } +ARK_PMD_LOG (INFO ,"Registered TX-meta dynamic field at %d\n" , + rte_pmd_ark_tx_userdata_dynfield_offset); + } +if (RTE_PMD_ARK_RX_USERDATA_ENABLE ) { + rte_pmd_ark_rx_userdata_dynfield_offset = +rte_mbuf_dynfield_register (&ark_rx_userdata_dynfield_desc); +if (rte_pmd_ark_rx_userdata_dynfield_offset <0 ) { +ARK_PMD_LOG (ERR , +"Failed to register mbuf field for rx userdata\n" ); +return -rte_errno; + } +ARK_PMD_LOG (INFO ,"Registered RX-meta dynamic field at %d\n" , + rte_pmd_ark_rx_userdata_dynfield_offset); + } + pci_dev =RTE_ETH_DEV_TO_PCI (dev);rte_eth_copy_pci_info (dev, pci_dev); dev->data->dev_flags |=RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS ;
drivers/net/ark/ark_ethdev_rx.c +2 -1
@@ -4,6 +4,7 @@#include <unistd.h> +#include "rte_pmd_ark.h" #include "ark_ethdev_rx.h" #include "ark_global.h" #include "ark_logs.h"
@@ -272,7 +273,7 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; mbuf->timestamp = meta->timestamp; - mbuf->udata64 = meta->user_data; +rte_pmd_ark_mbuf_rx_userdata_set (mbuf, meta->user_data);if (ARK_DEBUG_CORE ) {/* debug sanity checks */ if ((meta->pkt_len > (1024 * 16)) ||
drivers/net/ark/ark_ethdev_tx.c +2 -1
@@ -4,6 +4,7 @@#include <unistd.h> +#include "rte_pmd_ark.h" #include "ark_ethdev_tx.h" #include "ark_global.h" #include "ark_mpu.h"
@@ -70,7 +71,7 @@ eth_ark_tx_meta_from_mbuf(struct ark_tx_meta *meta, uint8_t flags) { meta->physaddr =rte_mbuf_data_iova (mbuf); - meta->user1 = (uint32_t )mbuf->udata64; + meta->user1 =rte_pmd_ark_mbuf_tx_userdata_get (mbuf); meta->data_len =rte_pktmbuf_data_len (mbuf); meta->flags = flags; }
drivers/net/ark/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel Corporation +headers = files('rte_pmd_ark.h') + sources = files('ark_ddm.c', 'ark_ethdev.c', 'ark_ethdev_rx.c',
drivers/net/ark/rte_pmd_ark.h new file +125 -0
125 lines not on this page · raw message
drivers/net/ark/version.map +7 -0
@@ -1,3 +1,10 @@ DPDK_21 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pmd_ark_tx_userdata_dynfield_offset; + rte_pmd_ark_rx_userdata_dynfield_offset; +};
Signature · 1 line
2.28.0
PATCH v6 8/15 net/bnxt: switch CFA code to dynamic mbuf field
In reply to Thomas MonjalonThe CFA code from mark was stored in the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64.
Note: the new field has 32 bits, smaller than udata64.
--- drivers/net/bnxt/bnxt_ethdev.c | 19 +++++++++++++++++++ drivers/net/bnxt/bnxt_rxr.c | 2 +- drivers/net/bnxt/bnxt_rxr.h | 10 ++++++++++ drivers/net/bnxt/rte_pmd_bnxt.h | 3 +++ 4 files changed, 33 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +19 -0
@@ -31,6 +31,7 @@#include "bnxt_nvm_defs.h" #include "bnxt_tf_common.h" #include "ulp_flow_db.h" +#include "rte_pmd_bnxt.h" #define DRV_MODULE_NAME "bnxt" static const char bnxt_version[] =
@@ -163,6 +164,8 @@ static const char *const bnxt_dev_args[] = {*/ #define BNXT_DEVARG_REP_FC_F2R_INVALID (rep_fc_f2r) ((rep_fc_f2r) > 1) +int bnxt_cfa_code_dynfield_offset =-1 ; +/* * max_num_kflows must be >= 32 * and must be a power-of-2 supported value
@@ -6021,6 +6024,22 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) pci_dev->id.device_id == BROADCOM_DEV_ID_58802_VF) bp->flags |= BNXT_FLAG_STINGRAY; +if (BNXT_TRUFLOW_EN (bp)) { +/* extra mbuf field is required to store CFA code from mark */ +static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = { + .name =RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME , + .size =sizeof (bnxt_cfa_code_dynfield_t), + .align = __alignof__(bnxt_cfa_code_dynfield_t ), + }; + bnxt_cfa_code_dynfield_offset = +rte_mbuf_dynfield_register (&bnxt_cfa_code_dynfield_desc); +if (bnxt_cfa_code_dynfield_offset <0 ) { +PMD_DRV_LOG (ERR , +"Failed to register mbuf field for TruFlow mark\n" ); +return -rte_errno; + } + } + rc =bnxt_init_board (eth_dev);if (rc) { PMD_DRV_LOG(ERR,
drivers/net/bnxt/bnxt_rxr.c +1 -1
@@ -606,7 +606,7 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,return mark_id;/* Got the mark, write it to the mbuf and return */ mbuf->hash.fdir.hi = mark_id; - mbuf->udata64 = (cfa_code &0xffffffffull ) <<32 ; + *bnxt_cfa_code_dynfield (mbuf) = cfa_code &0xffffffffull ; mbuf->hash.fdir.id = rxcmp1->cfa_code; mbuf->ol_flags |=PKT_RX_FDIR |PKT_RX_FDIR_ID ;return mark_id;
drivers/net/bnxt/bnxt_rxr.h +10 -0
@@ -95,6 +95,16 @@ void bnxt_set_mark_in_mbuf(struct bnxt *bp,struct rx_pkt_cmpl_hi *rxcmp1, struct rte_mbuf *mbuf); +typedef uint32_t bnxt_cfa_code_dynfield_t ; +extern int bnxt_cfa_code_dynfield_offset; + +static inline bnxt_cfa_code_dynfield_t * +bnxt_cfa_code_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + bnxt_cfa_code_dynfield_offset, bnxt_cfa_code_dynfield_t *); +} +#define BNXT_RX_META_CFA_CODE_SHIFT 19#define BNXT_CFA_CODE_META_SHIFT 16#define BNXT_RX_META_CFA_CODE_INT_ACT_REC_BIT 0x8000000
drivers/net/bnxt/rte_pmd_bnxt.h +3 -0
@@ -9,6 +9,9 @@#include <rte_ethdev.h> #include <rte_ether.h> +/** mbuf dynamic field where CFA code is stored */ +#define RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME "rte_net_bnxt_dynfield_cfa_code" +/* * Response sent back to the caller after callback */
Signature · 1 line
2.28.0
PATCH v6 9/15 net/vmxnet3: switch MSS hint to dynamic mbuf field
In reply to Thomas MonjalonThe segment count, used for MSS guess,
was stored in the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.
--- drivers/net/vmxnet3/vmxnet3_ethdev.c | 15 +++++++++++++++ drivers/net/vmxnet3/vmxnet3_ethdev.h | 11 +++++++++++ drivers/net/vmxnet3/vmxnet3_rxtx.c | 9 +++++---- 3 files changed, 31 insertions(+), 4 deletions(-)
drivers/net/vmxnet3/vmxnet3_ethdev.c +15 -0
@@ -59,6 +59,8 @@ DEV_RX_OFFLOAD_JUMBO_FRAME | \ DEV_RX_OFFLOAD_RSS_HASH) +int vmxnet3_segs_dynfield_offset =-1 ; +static int eth_vmxnet3_dev_init (struct rte_eth_dev *eth_dev);static int eth_vmxnet3_dev_uninit (struct rte_eth_dev *eth_dev);static int vmxnet3_dev_configure (struct rte_eth_dev *dev);
@@ -233,6 +235,11 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)struct vmxnet3_hw *hw = eth_dev->data->dev_private;uint32_t mac_hi, mac_lo, ver;struct rte_eth_link link; +static const struct rte_mbuf_dynfield vmxnet3_segs_dynfield_desc = { + .name =VMXNET3_SEGS_DYNFIELD_NAME , + .size =sizeof (vmxnet3_segs_dynfield_t), + .align = __alignof__(vmxnet3_segs_dynfield_t ), + };PMD_INIT_FUNC_TRACE ();
@@ -242,6 +249,14 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_prepare = vmxnet3_prep_pkts; pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +/* extra mbuf field is required to guess MSS */ + vmxnet3_segs_dynfield_offset = +rte_mbuf_dynfield_register (&vmxnet3_segs_dynfield_desc); +if (vmxnet3_segs_dynfield_offset <0 ) { +PMD_INIT_LOG (ERR ,"Cannot register mbuf field." ); +return -rte_errno; + } +/* * for secondary processes, we don't initialize any further as primary * has already done this work.
drivers/net/vmxnet3/vmxnet3_ethdev.h +11 -0
@@ -193,4 +193,15 @@ uint16_t vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t vmxnet3_prep_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +#define VMXNET3_SEGS_DYNFIELD_NAME "rte_net_vmxnet3_dynfield_segs" +typedef uint8_t vmxnet3_segs_dynfield_t ; +extern int vmxnet3_segs_dynfield_offset; + +static inline vmxnet3_segs_dynfield_t * +vmxnet3_segs_dynfield (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, \ + vmxnet3_segs_dynfield_offset, vmxnet3_segs_dynfield_t *); +} +#endif /* _VMXNET3_ETHDEV_H_ */
drivers/net/vmxnet3/vmxnet3_rxtx.c +5 -4
@@ -674,6 +674,7 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,struct rte_ipv6_hdr *ipv6_hdr;struct rte_tcp_hdr *tcp_hdr;char *ptr; +uint8_t segs;RTE_ASSERT (rcd->tcp);
@@ -710,9 +711,9 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd, tcp_hdr = (struct rte_tcp_hdr *)(ptr + hlen); hlen += (tcp_hdr->data_off &0xf0 ) >>2 ; -if (rxm->udata64 >1 ) -return (rte_pktmbuf_pkt_len (rxm) - hlen + - rxm->udata64 -1 ) / rxm->udata64; + segs = *vmxnet3_segs_dynfield (rxm); +if (segs >1 ) +return (rte_pktmbuf_pkt_len (rxm) - hlen + segs -1 ) / segs;else return hw->mtu - hlen +sizeof (struct rte_ether_hdr ); }
@@ -737,7 +738,7 @@ vmxnet3_rx_offload(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd, (const Vmxnet3_RxCompDescExt *)rcd; rxm->tso_segsz = rcde->mss; - rxm->udata64 = rcde->segCnt; + *vmxnet3_segs_dynfield (rxm) = rcde->segCnt; ol_flags |=PKT_RX_LRO ; } }else {/* Offloads set in eop */
Signature · 1 line
2.28.0
PATCH v6 10/15 test/distributor: switch sequence to dynamic mbuf field
In reply to Thomas MonjalonThe test used the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.
--- app/test/test_distributor.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
app/test/test_distributor.c +27 -5
@@ -10,6 +10,7 @@#include <rte_errno.h> #include <rte_mempool.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_distributor.h> #include <rte_string_fns.h>
@@ -17,6 +18,15 @@#define BURST 32#define BIG_BATCH 1024 +typedef uint32_t seq_dynfield_t ; +static int seq_dynfield_offset =-1 ; + +static inline seq_dynfield_t * +seq_field (struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, seq_dynfield_offset, seq_dynfield_t *); +} +struct worker_params {char name[64 ];struct rte_distributor *dist;
@@ -578,7 +588,7 @@ handle_and_mark_work(void *arg)__atomic_fetch_add (&worker_stats[id].handled_packets, num, __ATOMIC_RELAXED);for (i =0 ; i < num; i++) - buf[i]->udata64 += id +1 ; + *seq_field (buf[i]) += id +1 ; num =rte_distributor_get_pkt (db, id, buf, buf, num); }
@@ -631,10 +641,10 @@ sanity_mark_test(struct worker_params *wp, struct rte_mempool *p) << shift; }/* Assign a sequence number to each packet. The sequence is shifted, -* so that lower bits of the udate64 will hold mark from worker. +* so that lower bits will hold mark from worker. */ for (i =0 ; i < buf_count; i++) - bufs[i]->udata64 = i << seq_shift; + *seq_field (bufs[i]) = i << seq_shift; count =0 ;for (i =0 ; i < buf_count/burst; i++) {
@@ -660,8 +670,8 @@ sanity_mark_test(struct worker_params *wp, struct rte_mempool *p)/* Sort returned packets by sent order (sequence numbers). */ for (i =0 ; i < buf_count; i++) { - seq = returns[i]->udata64 >> seq_shift; - id = returns[i]->udata64 - (seq << seq_shift); + seq = *seq_field (returns[i]) >> seq_shift; + id = *seq_field (returns[i]) - (seq << seq_shift); sorted[seq] = id; }
@@ -805,6 +815,18 @@ test_distributor(void)static struct rte_mempool *p;int i; +static const struct rte_mbuf_dynfield seq_dynfield_desc = { + .name ="test_distributor_dynfield_seq" , + .size =sizeof (seq_dynfield_t), + .align = __alignof__(seq_dynfield_t ), + }; + seq_dynfield_offset = +rte_mbuf_dynfield_register (&seq_dynfield_desc); +if (seq_dynfield_offset <0 ) { +printf ("Error registering mbuf field\n" ); +return TEST_FAILED ; + } +if (rte_lcore_count () <2 ) {printf ("Not enough cores for distributor_autotest, expecting at least 2\n" );return TEST_SKIPPED ;
Signature · 1 line
2.28.0
PATCH v6 11/15 test/graph: switch user data to dynamic mbuf field
In reply to Thomas MonjalonThe test used the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.
--- app/test/test_graph.c | 99 ++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 38 deletions(-)
app/test/test_graph.c +61 -38
@@ -12,6 +12,7 @@#include <rte_graph.h> #include <rte_graph_worker.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_random.h> #include "test.h"
@@ -39,6 +40,16 @@ static uint16_t test_node3_worker(struct rte_graph *graph,#define MBUFF_SIZE 512#define MAX_NODES 4 +typedef uint64_t graph_dynfield_t ; +static int graph_dynfield_offset =-1 ; + +static inline graph_dynfield_t * +graph_field (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, \ + graph_dynfield_offset, graph_dynfield_t *); +} +static struct rte_mbuf mbuf[MAX_NODES +1 ][MBUFF_SIZE ];static void *mbuf_p[MAX_NODES +1 ][MBUFF_SIZE ];static rte_graph_t graph_id;
@@ -162,9 +173,9 @@ test_node_worker_source(struct rte_graph *graph, struct rte_node *node, next_stream =rte_node_next_stream_get (graph, node, next, obj_node0);for (i =0 ; i < obj_node0; i++) { data = &mbuf[0 ][i]; - data->udata64 = ((uint64_t )tm->test_node[0 ].idx <<32 ) | i; + *graph_field (data) = ((uint64_t )tm->test_node[0 ].idx <<32 ) | i;if ((i +1 ) == obj_node0) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 ); next_stream[i] = &mbuf[0 ][i]; }rte_node_next_stream_put (graph, node, next, obj_node0);
@@ -175,9 +186,9 @@ test_node_worker_source(struct rte_graph *graph, struct rte_node *node, next_stream =rte_node_next_stream_get (graph, node, next, obj_node1);for (i =0 ; i < obj_node1; i++) { data = &mbuf[0 ][obj_node0 + i]; - data->udata64 = ((uint64_t )tm->test_node[1 ].idx <<32 ) | i; + *graph_field (data) = ((uint64_t )tm->test_node[1 ].idx <<32 ) | i;if ((i +1 ) == obj_node1) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 ); next_stream[i] = &mbuf[0 ][obj_node0 + i]; }
@@ -205,23 +216,23 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,for (i =0 ; i < nb_objs; i++) { data = (struct rte_mbuf *)objs[i]; -if ((data->udata64 >>32 ) != tm->test_node[0 ].idx) { +if ((*graph_field (data) >>32 ) != tm->test_node[0 ].idx) {printf ("Data idx miss match at node 0, expected" " = %u got = %u\n" , tm->test_node[0 ].idx, - (uint32_t )(data->udata64 >>32 )); + (uint32_t )(*graph_field (data) >>32 )); goto end; } -if ((data->udata64 &0xffff ) != (i - count)) { +if ((*graph_field (data) &0xffff ) != (i - count)) {printf ("Expected buff count miss match at " "node 0\n" ); goto end; } -if (data->udata64 & (0x1 <<16 )) +if (*graph_field (data) & (0x1 <<16 )) count = i +1 ; -if (data->udata64 & (0x1 <<17 )) +if (*graph_field (data) & (0x1 <<17 )) second_pass =1 ; }
@@ -233,12 +244,12 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs, obj_node0 = nb_objs * obj_node0 *0.01 ;for (i =0 ; i < obj_node0; i++) { data = &mbuf[1 ][i]; - data->udata64 = + *graph_field (data) = ((uint64_t )tm->test_node[1 ].idx <<32 ) | i;if ((i +1 ) == obj_node0) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 );if (second_pass) - data->udata64 |= (1 <<17 ); + *graph_field (data) |= (1 <<17 ); }rte_node_enqueue (graph, node,0 , (void **)&mbuf_p[1 ][0 ], obj_node0);
@@ -246,12 +257,12 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs, obj_node1 = nb_objs - obj_node0;for (i =0 ; i < obj_node1; i++) { data = &mbuf[1 ][obj_node0 + i]; - data->udata64 = + *graph_field (data) = ((uint64_t )tm->test_node[2 ].idx <<32 ) | i;if ((i +1 ) == obj_node1) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 );if (second_pass) - data->udata64 |= (1 <<17 ); + *graph_field (data) |= (1 <<17 ); }rte_node_enqueue (graph, node,1 , (void **)&mbuf_p[1 ][obj_node0], obj_node1);
@@ -285,22 +296,22 @@ test_node1_worker(struct rte_graph *graph, struct rte_node *node, void **objs, fn_calls[2 ] +=1 ;for (i =0 ; i < nb_objs; i++) { data = (struct rte_mbuf *)objs[i]; -if ((data->udata64 >>32 ) != tm->test_node[1 ].idx) { +if ((*graph_field (data) >>32 ) != tm->test_node[1 ].idx) {printf ("Data idx miss match at node 1, expected = %u" " got = %u\n" , tm->test_node[1 ].idx, - (uint32_t )(data->udata64 >>32 )); + (uint32_t )(*graph_field (data) >>32 )); goto end; } -if ((data->udata64 &0xffff ) != (i - count)) { +if ((*graph_field (data) &0xffff ) != (i - count)) {printf ("Expected buff count miss match at node 1\n" ); goto end; } -if (data->udata64 & (0x1 <<16 )) +if (*graph_field (data) & (0x1 <<16 )) count = i +1 ; -if (data->udata64 & (0x1 <<17 )) +if (*graph_field (data) & (0x1 <<17 )) second_pass =1 ; }
@@ -312,11 +323,11 @@ test_node1_worker(struct rte_graph *graph, struct rte_node *node, void **objs, obj_node0 = nb_objs;for (i =0 ; i < obj_node0; i++) { data = &mbuf[2 ][i]; - data->udata64 = ((uint64_t )tm->test_node[2 ].idx <<32 ) | i; + *graph_field (data) = ((uint64_t )tm->test_node[2 ].idx <<32 ) | i;if ((i +1 ) == obj_node0) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 );if (second_pass) - data->udata64 |= (1 <<17 ); + *graph_field (data) |= (1 <<17 ); }rte_node_enqueue (graph, node,0 , (void **)&mbuf_p[2 ][0 ], obj_node0);
@@ -339,22 +350,22 @@ test_node2_worker(struct rte_graph *graph, struct rte_node *node, void **objs, fn_calls[3 ] +=1 ;for (i =0 ; i < nb_objs; i++) { data = (struct rte_mbuf *)objs[i]; -if ((data->udata64 >>32 ) != tm->test_node[2 ].idx) { +if ((*graph_field (data) >>32 ) != tm->test_node[2 ].idx) {printf ("Data idx miss match at node 2, expected = %u" " got = %u\n" , tm->test_node[2 ].idx, - (uint32_t )(data->udata64 >>32 )); + (uint32_t )(*graph_field (data) >>32 )); goto end; } -if ((data->udata64 &0xffff ) != (i - count)) { +if ((*graph_field (data) &0xffff ) != (i - count)) {printf ("Expected buff count miss match at node 2\n" ); goto end; } -if (data->udata64 & (0x1 <<16 )) +if (*graph_field (data) & (0x1 <<16 )) count = i +1 ; -if (data->udata64 & (0x1 <<17 )) +if (*graph_field (data) & (0x1 <<17 )) second_pass =1 ; }
@@ -367,10 +378,10 @@ test_node2_worker(struct rte_graph *graph, struct rte_node *node, void **objs, obj_node0 = nb_objs;for (i =0 ; i < obj_node0; i++) { data = &mbuf[3 ][i]; - data->udata64 = + *graph_field (data) = ((uint64_t )tm->test_node[3 ].idx <<32 ) | i;if ((i +1 ) == obj_node0) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 ); }rte_node_enqueue (graph, node,0 , (void **)&mbuf_p[3 ][0 ], obj_node0);
@@ -395,22 +406,22 @@ test_node3_worker(struct rte_graph *graph, struct rte_node *node, void **objs, fn_calls[4 ] +=1 ;for (i =0 ; i < nb_objs; i++) { data = (struct rte_mbuf *)objs[i]; -if ((data->udata64 >>32 ) != tm->test_node[3 ].idx) { +if ((*graph_field (data) >>32 ) != tm->test_node[3 ].idx) {printf ("Data idx miss match at node 3, expected = %u" " got = %u\n" , tm->test_node[3 ].idx, - (uint32_t )(data->udata64 >>32 )); + (uint32_t )(*graph_field (data) >>32 )); goto end; } -if ((data->udata64 &0xffff ) != (i - count)) { +if ((*graph_field (data) &0xffff ) != (i - count)) {printf ("Expected buff count miss match at node 3\n" ); goto end; } -if (data->udata64 & (0x1 <<16 )) +if (*graph_field (data) & (0x1 <<16 )) count = i +1 ; -if (data->udata64 & (0x1 <<17 )) +if (*graph_field (data) & (0x1 <<17 )) second_pass =1 ; }
@@ -426,11 +437,11 @@ test_node3_worker(struct rte_graph *graph, struct rte_node *node, void **objs, obj_node0 = nb_objs *2 ;for (i =0 ; i < obj_node0; i++) { data = &mbuf[4 ][i]; - data->udata64 = + *graph_field (data) = ((uint64_t )tm->test_node[0 ].idx <<32 ) | i; - data->udata64 |= (1 <<17 ); + *graph_field (data) |= (1 <<17 );if ((i +1 ) == obj_node0) - data->udata64 |= (1 <<16 ); + *graph_field (data) |= (1 <<16 ); }rte_node_enqueue (graph, node,0 , (void **)&mbuf_p[4 ][0 ], obj_node0);
@@ -765,6 +776,18 @@ graph_setup(void) {int i, j; +static const struct rte_mbuf_dynfield graph_dynfield_desc = { + .name ="test_graph_dynfield" , + .size =sizeof (graph_dynfield_t), + .align = __alignof__(graph_dynfield_t ), + }; + graph_dynfield_offset = +rte_mbuf_dynfield_register (&graph_dynfield_desc); +if (graph_dynfield_offset <0 ) { +printf ("Cannot register mbuf field\n" ); +return TEST_FAILED ; + } +for (i =0 ; i <=MAX_NODES ; i++) {for (j =0 ; j <MBUFF_SIZE ; j++) mbuf_p[i][j] = &mbuf[i][j];
Signature · 1 line
2.28.0
PATCH v6 12/15 app/eventdev: switch flow ID to dynamic mbuf field
In reply to Thomas MonjalonThe order test stored the flow ID in the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64.
--- app/test-eventdev/test_order_atq.c | 4 ++-- app/test-eventdev/test_order_common.c | 21 +++++++++++++++------ app/test-eventdev/test_order_common.h | 21 +++++++++++++++++++++ app/test-eventdev/test_order_queue.c | 4 ++-- 4 files changed, 40 insertions(+), 10 deletions(-)
app/test-eventdev/test_order_atq.c +2 -2
@@ -35,7 +35,7 @@ order_atq_worker(void *arg, const bool flow_id_cap) }if (!flow_id_cap) - ev.flow_id = ev.mbuf->udata64; +order_flow_id_copy_from_mbuf (t, &ev);if (ev.sub_event_type ==0 ) {/* stage 0 from producer */ order_atq_process_stage_0 (&ev);
@@ -72,7 +72,7 @@ order_atq_worker_burst(void *arg, const bool flow_id_cap)for (i =0 ; i < nb_rx; i++) {if (!flow_id_cap) - ev[i].flow_id = ev[i].mbuf->udata64; +order_flow_id_copy_from_mbuf (t, &ev[i]);if (ev[i].sub_event_type ==0 ) {/*stage 0 */ order_atq_process_stage_0 (&ev[i]);
app/test-eventdev/test_order_common.c +15 -6
@@ -46,13 +46,10 @@ order_producer(void *arg)if (m ==NULL )continue ; -const uint32_t flow = (uintptr_t )m % nb_flows; +const flow_id_t flow = (uintptr_t )m % nb_flows;/* Maintain seq number per flow */ m->seqn = producer_flow_seq[flow]++; - m->udata64 = flow; - - ev.flow_id = flow; - ev.mbuf = m; +order_flow_id_save (t, flow, m, &ev);while (rte_event_enqueue_burst (dev_id, port, &ev,1 ) !=1 ) {if (t->err)
@@ -138,6 +135,12 @@ int order_test_setup(struct evt_test *test, struct evt_options *opt) { void *test_order; +struct test_order *t; +static const struct rte_mbuf_dynfield flow_id_dynfield_desc = { + .name ="test_event_dynfield_flow_id" , + .size =sizeof (flow_id_t), + .align = __alignof__(flow_id_t ), + }; test_order =rte_zmalloc_socket (test->name,sizeof (struct test_order ),RTE_CACHE_LINE_SIZE , opt->socket_id);
@@ -146,8 +149,14 @@ order_test_setup(struct evt_test *test, struct evt_options *opt) goto nomem; } test->test_priv = test_order; + t =evt_test_priv (test); -struct test_order *t =evt_test_priv (test); + t->flow_id_dynfield_offset = +rte_mbuf_dynfield_register (&flow_id_dynfield_desc); +if (t->flow_id_dynfield_offset <0 ) { +evt_err ("failed to register mbuf field" ); +return -rte_errno; + } t->producer_flow_seq = rte_zmalloc_socket("test_producer_flow_seq", sizeof(*t->producer_flow_seq) * opt->nb_flows,
app/test-eventdev/test_order_common.h +21 -0
@@ -13,6 +13,7 @@#include <rte_lcore.h> #include <rte_malloc.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include "evt_common.h" #include "evt_options.h"
@@ -20,6 +21,8 @@#define BURST_SIZE 16 +typedef uint32_t flow_id_t ; +struct test_order ;struct worker_data {
@@ -49,6 +52,7 @@ struct test_order {uint32_t nb_flows;uint64_t nb_pkts;struct rte_mempool *pool; +int flow_id_dynfield_offset;struct prod_data prod;struct worker_data worker[EVT_MAX_PORTS ];uint32_t *producer_flow_seq;
@@ -56,6 +60,23 @@ struct test_order {struct evt_options *opt; } __rte_cache_aligned; +static inline void +order_flow_id_copy_from_mbuf (struct test_order *t,struct rte_event *event) +{ + event->flow_id = *RTE_MBUF_DYNFIELD (event->mbuf, + t->flow_id_dynfield_offset, flow_id_t *); +} + +static inline void +order_flow_id_save (struct test_order *t,flow_id_t flow_id, +struct rte_mbuf *mbuf,struct rte_event *event) +{ + *RTE_MBUF_DYNFIELD (mbuf, + t->flow_id_dynfield_offset, flow_id_t *) = flow_id; + event->flow_id = flow_id; + event->mbuf = mbuf; +} +static inline int order_nb_event_ports (struct evt_options *opt) {
app/test-eventdev/test_order_queue.c +2 -2
@@ -35,7 +35,7 @@ order_queue_worker(void *arg, const bool flow_id_cap) }if (!flow_id_cap) - ev.flow_id = ev.mbuf->udata64; +order_flow_id_copy_from_mbuf (t, &ev);if (ev.queue_id ==0 ) {/* from ordered queue */ order_queue_process_stage_0 (&ev);
@@ -73,7 +73,7 @@ order_queue_worker_burst(void *arg, const bool flow_id_cap)for (i =0 ; i < nb_rx; i++) {if (!flow_id_cap) - ev[i].flow_id = ev[i].mbuf->udata64; +order_flow_id_copy_from_mbuf (t, &ev[i]);if (ev[i].queue_id ==0 ) {/* from ordered queue */ order_queue_process_stage_0 (&ev[i]);
Signature · 1 line
2.28.0
PATCH v6 13/15 examples/bbdev: switch to dynamic mbuf field
In reply to Thomas MonjalonThe example used the deprecated mbuf field udata64 as input mbuf pointer. It is moved to a dynamic field in order to allow removal of udata64.
--- examples/bbdev_app/main.c | 42 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-)
examples/bbdev_app/main.c +32 -10
@@ -28,6 +28,7 @@#include <rte_lcore.h> #include <rte_malloc.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #include <rte_memory.h> #include <rte_mempool.h> #include <rte_log.h>
@@ -59,6 +60,15 @@ } \ }while (0 ) +static int input_dynfield_offset = -1; + +static inline struct rte_mbuf ** +mbuf_input (struct rte_mbuf *mbuf) +{ +return RTE_MBUF_DYNFIELD (mbuf, + input_dynfield_offset, struct rte_mbuf **); +} +static const struct rte_eth_conf port_conf = { .rxmode = { .mq_mode =ETH_MQ_RX_NONE ,
@@ -294,11 +304,11 @@ pktmbuf_free_bulk(struct rte_mbuf **mbufs, unsigned int nb_to_free) }static inline void -pktmbuf_userdata_free_bulk (struct rte_mbuf **mbufs,unsigned int nb_to_free) +pktmbuf_input_free_bulk (struct rte_mbuf **mbufs,unsigned int nb_to_free) {unsigned int i;for (i =0 ; i < nb_to_free; ++i) { -struct rte_mbuf *rx_pkt = mbufs[i]->userdata; +struct rte_mbuf *rx_pkt = *mbuf_input (mbufs[i]);rte_pktmbuf_free (rx_pkt);rte_pktmbuf_free (mbufs[i]); }
@@ -429,7 +439,7 @@ verify_data(struct rte_mbuf **mbufs, uint16_t num_pkts)uint16_t i;for (i =0 ; i < num_pkts; ++i) {struct rte_mbuf *out = mbufs[i]; -struct rte_mbuf *in = out->userdata; +struct rte_mbuf *in = *mbuf_input (out); if (memcmp(rte_pktmbuf_mtod_offset(in, uint8_t *, sizeof(struct rte_ether_hdr)),
@@ -731,7 +741,7 @@ run_encoding(struct lcore_conf *lcore_conf)rte_pktmbuf_data_len (rx_pkts_burst[i]) -sizeof (struct rte_ether_hdr );/* save input mbuf pointer for later comparison */ - enc_out_pkts[i]->userdata = rx_pkts_burst[i]; + *mbuf_input (enc_out_pkts[i]) = rx_pkts_burst[i];/* copy ethernet header */ rte_pktmbuf_reset (enc_out_pkts[i]);
@@ -775,7 +785,7 @@ run_encoding(struct lcore_conf *lcore_conf) nb_enq =rte_bbdev_enqueue_enc_ops (bbdev_id, enc_queue_id, bbdev_ops_burst, nb_rx);if (unlikely (nb_enq < nb_rx)) { -pktmbuf_userdata_free_bulk (&enc_out_pkts[nb_enq], +pktmbuf_input_free_bulk (&enc_out_pkts[nb_enq], nb_rx - nb_enq);rte_bbdev_enc_op_free_bulk (&bbdev_ops_burst[nb_enq], nb_rx - nb_enq);
@@ -805,7 +815,7 @@ run_encoding(struct lcore_conf *lcore_conf) nb_sent =rte_ring_enqueue_burst (enc_to_dec_ring, (void **)enc_out_pkts, nb_deq,NULL );if (unlikely (nb_sent < nb_deq)) { -pktmbuf_userdata_free_bulk (&enc_out_pkts[nb_sent], +pktmbuf_input_free_bulk (&enc_out_pkts[nb_sent], nb_deq - nb_sent); lcore_stats->enc_to_dec_lost_packets += nb_deq - nb_sent; }
@@ -842,7 +852,7 @@ run_decoding(struct lcore_conf *lcore_conf)if (unlikely (rte_bbdev_dec_op_alloc_bulk (bbdev_op_pool, bbdev_ops_burst, nb_recv) !=0 )) { -pktmbuf_userdata_free_bulk (recv_pkts_burst, nb_recv); +pktmbuf_input_free_bulk (recv_pkts_burst, nb_recv); lcore_stats->rx_lost_packets += nb_recv;return ; }
@@ -871,7 +881,7 @@ run_decoding(struct lcore_conf *lcore_conf) nb_enq =rte_bbdev_enqueue_dec_ops (bbdev_id, bbdev_queue_id, bbdev_ops_burst, nb_recv);if (unlikely (nb_enq < nb_recv)) { -pktmbuf_userdata_free_bulk (&recv_pkts_burst[nb_enq], +pktmbuf_input_free_bulk (&recv_pkts_burst[nb_enq], nb_recv - nb_enq);rte_bbdev_dec_op_free_bulk (&bbdev_ops_burst[nb_enq], nb_recv - nb_enq);
@@ -898,12 +908,12 @@ run_decoding(struct lcore_conf *lcore_conf)/* Free the RX mbufs after verification */ for (i =0 ; i < nb_deq; ++i) -rte_pktmbuf_free (recv_pkts_burst[i]->userdata); +rte_pktmbuf_free (*mbuf_input (recv_pkts_burst[i]));/* Transmit the packets */ nb_tx =rte_eth_tx_burst (port_id, tx_queue_id, recv_pkts_burst, nb_deq);if (unlikely (nb_tx < nb_deq)) { -pktmbuf_userdata_free_bulk (&recv_pkts_burst[nb_tx], +pktmbuf_input_free_bulk (&recv_pkts_burst[nb_tx], nb_deq - nb_tx); lcore_stats->tx_lost_packets += nb_deq - nb_tx; }
@@ -1046,6 +1056,12 @@ main(int argc, char **argv)bool stats_thread_started = false;unsigned int main_lcore_id =rte_get_main_lcore (); +static const struct rte_mbuf_dynfield input_dynfield_desc = { + .name ="example_bbdev_dynfield_input" , + .size =sizeof (struct rte_mbuf *), + .align = __alignof__(struct rte_mbuf *), + }; +rte_atomic16_init (&global_exit_flag); sigret =signal (SIGTERM , signal_handler);
@@ -1115,6 +1131,12 @@ main(int argc, char **argv)if (bbdev_mbuf_mempool ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create ethdev mbuf mempool\n" ); +/* register mbuf field to store input pointer */ + input_dynfield_offset = +rte_mbuf_dynfield_register (&input_dynfield_desc); +if (input_dynfield_offset <0 ) +rte_exit (EXIT_FAILURE ,"Cannot register mbuf field\n" ); +/* initialize ports */ ret =initialize_ports (&app_params, ethdev_mbuf_mempool);
Signature · 1 line
2.28.0
PATCH v6 14/15 examples/rxtx_callbacks: switch TSC to dynamic field
In reply to Thomas MonjalonThe example used the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.
--- doc/guides/sample_app_ug/rxtx_callbacks.rst | 4 ++-- examples/rxtx_callbacks/main.c | 24 +++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-)
doc/guides/sample_app_ug/rxtx_callbacks.rst +2 -2
@@ -152,7 +152,7 @@ all packets received: uint64_t now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) - pkts[i]->udata64 = now; + *tsc_field(pkts[i]) = now; return nb_pkts; }
@@ -179,7 +179,7 @@ packets prior to transmission: unsigned i; for (i = 0; i < nb_pkts; i++) - cycles += now - pkts[i]->udata64; + cycles += now - *tsc_field(pkts[i]); latency_numbers.total_cycles += cycles; latency_numbers.total_pkts += nb_pkts;
examples/rxtx_callbacks/main.c +22 -2
@@ -10,6 +10,7 @@#include <rte_cycles.h> #include <rte_lcore.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #define RX_RING_SIZE 1024#define TX_RING_SIZE 1024
@@ -18,6 +19,15 @@#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +typedef uint64_t tsc_t ; +static int tsc_dynfield_offset =-1 ; + +static inline tsc_t * +tsc_field (struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, tsc_dynfield_offset, tsc_t *); +} +static const char usage[] ="%s EAL_ARGS -- [-t]\n" ;
@@ -47,7 +57,7 @@ add_timestamps(uint16_t port __rte_unused, uint16_t qidx __rte_unused,uint64_t now =rte_rdtsc ();for (i =0 ; i < nb_pkts; i++) - pkts[i]->udata64 = now; + *tsc_field (pkts[i]) = now;return nb_pkts; }
@@ -65,7 +75,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,rte_eth_read_clock (port, &ticks);for (i =0 ; i < nb_pkts; i++) { - cycles += now - pkts[i]->udata64; + cycles += now - *tsc_field (pkts[i]);if (hw_timestamping) queue_ticks += ticks - pkts[i]->timestamp; }
@@ -261,6 +271,11 @@ main(int argc, char *argv[]) };int opt, option_index; +static const struct rte_mbuf_dynfield tsc_dynfield_desc = { + .name ="example_bbdev_dynfield_tsc" , + .size =sizeof (tsc_t), + .align = __alignof__(tsc_t ), + };/* init EAL */ int ret =rte_eal_init (argc, argv);
@@ -292,6 +307,11 @@ main(int argc, char *argv[])if (mbuf_pool ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create mbuf pool\n" ); + tsc_dynfield_offset = +rte_mbuf_dynfield_register (&tsc_dynfield_desc); +if (tsc_dynfield_offset <0 ) +rte_exit (EXIT_FAILURE ,"Cannot register mbuf field\n" ); +/* initialize all ports */ RTE_ETH_FOREACH_DEV (portid) if (port_init(portid, mbuf_pool) != 0)
Signature · 1 line
2.28.0
PATCH v6 15/15 mbuf: remove userdata field
In reply to Thomas MonjalonAs announced in the deprecation note, the field userdata / udata64 is removed to give more space to the dynamic fields.
This is how the mbuf layout looks like (pahole-style):
word type name byte size
0 void * buf_addr; /* 0 + 8 */
1 rte_iova_t buf_iova /* 8 + 8 */
/* --- RTE_MARKER64 rearm_data; */
2 uint16_t data_off; /* 16 + 2 */
uint16_t refcnt; /* 18 + 2 */
uint16_t nb_segs; /* 20 + 2 */
uint16_t port; /* 22 + 2 */
3 uint64_t ol_flags; /* 24 + 8 */
/* --- RTE_MARKER rx_descriptor_fields1; */
4 uint32_t union packet_type; /* 32 + 4 */
uint32_t pkt_len; /* 36 + 4 */
5 uint16_t data_len; /* 40 + 2 */
uint16_t vlan_tci; /* 42 + 2 */
5.5 uint64_t union hash; /* 44 + 8 */
6.5 uint16_t vlan_tci_outer; /* 52 + 2 */
uint16_t buf_len; /* 54 + 2 */
7 uint64_t timestamp; /* 56 + 8 */
/* --- RTE_MARKER cacheline1; */
8 struct rte_mempool * pool; /* 64 + 8 */
9 struct rte_mbuf * next; /* 72 + 8 */
10 uint64_t union tx_offload; /* 80 + 8 */
11 uint16_t priv_size; /* 88 + 2 */
uint16_t timesync; /* 90 + 2 */
uint32_t seqn; /* 92 + 4 */
12 struct rte_mbuf_ext_shared_info * shinfo; /* 96 + 8 */
13 uint64_t dynfield1[3]; /* 104 + 24 */
16 /* --- END 128 */--- doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_20_11.rst | 3 +++ lib/librte_kni/rte_kni_common.h | 2 +- lib/librte_mbuf/rte_mbuf_core.h | 8 +------- 4 files changed, 5 insertions(+), 9 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -1
@@ -87,7 +87,6 @@ Deprecation Notices The following static fields will be moved as dynamic: - ``timestamp`` - - ``userdata`` / ``udata64`` - ``seqn`` As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged,
doc/guides/rel_notes/release_20_11.rst +3 -0
@@ -442,6 +442,9 @@ API Changes the structures ``rte_mbuf`` and ``rte_mbuf_ext_shared_info``. The field ``refcnt`` is remaining from the old unions. +* mbuf: Removed the unioned fields ``userdata`` and ``udata64`` + from the structure ``rte_mbuf``. It is replaced with dynamic fields. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem.
lib/librte_kni/rte_kni_common.h +1 -1
@@ -86,7 +86,7 @@ struct rte_kni_mbuf {uint16_t data_len;/**< Amount of data in segment buffer. */ /* fields on second cache line */ - char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE))); + __attribute__((__aligned__ (RTE_CACHE_LINE_MIN_SIZE )))void *pool;void *next;/**< Physical address of next mbuf in kernel. */ };
lib/librte_mbuf/rte_mbuf_core.h +1 -7
@@ -599,12 +599,6 @@ struct rte_mbuf {/* second cache line - fields only used in slow path or on TX */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -RTE_STD_C11 - union { -void *userdata;/**< Can be used for external metadata */ -uint64_t udata64;/**< Allow 8-byte userdata on 32-bit */ - }; -struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ struct rte_mbuf *next;/**< Next segment of scattered packet. */
@@ -662,7 +656,7 @@ struct rte_mbuf {*/ struct rte_mbuf_ext_shared_info *shinfo; -uint64_t dynfield1[2 ];/**< Reserved for dynamic fields. */ +uint64_t dynfield1[3 ];/**< Reserved for dynamic fields. */ } __rte_cache_aligned;/**
Signature · 1 line
2.28.0
Thomas Monjalon
Applied30/10/2020 18:44, Thomas Monjalon:
Quoted 6 lines
The mbuf field userdata (aliased as udata64)
was announced to be removed for two reasons:
- applications, libraries and drivers used the same field for different purposes, with a risk of usage conflict.
- this field always used 8 bytes even if unneeded
Quoted 6 lines
Some dynamic fields are created when needed to replace the big static userdata field.
As a consequence, 8 bytes can be re-allocated to dynamic fields.This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year.
Applied
Quoted 7 lines · Thomas Monjalon
30/10/2020 18:44, Thomas Monjalon:
Quoted 6 lines
The mbuf field userdata (aliased as udata64)
was announced to be removed for two reasons:
- applications, libraries and drivers used the same field for different purposes, with a risk of usage conflict.
- this field always used 8 bytes even if unneeded
Quoted 9 lines
Quoted 6 lines
Some dynamic fields are created when needed to replace the big static userdata field.
As a consequence, 8 bytes can be re-allocated to dynamic fields.This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year.
Applied
The new txgbe driver in the next-net is also using ‘udata64’, that also needs to be updated. cc'ed txgbe maintainer.
01/11/2020 00:36, Ferruh Yigit:
Quoted 12 lines · Thomas Monjalon
Quoted 11 lines
30/10/2020 18:44, Thomas Monjalon:
Quoted 10 lines
The mbuf field userdata (aliased as udata64)
was announced to be removed for two reasons:
- applications, libraries and drivers used the same field for different purposes, with a risk of usage conflict.
- this field always used 8 bytes even if unneededSome dynamic fields are created when needed to replace the big static userdata field.
As a consequence, 8 bytes can be re-allocated to dynamic fields.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
This mbuf layout change is important to allow adding more features (consuming more dynamic fields) during the next year.
Applied
The new txgbe driver in the next-net is also using ‘udata64’, that also needs to be updated. cc'ed txgbe maintainer.
That's a pity it did not take into account the deprecation notice. What kind of hack is it used for?
Can it be simply removed to allow quick merging of the PMD?
Quoted 6 lines · Thomas Monjalon
Quoted 2 lines
The new txgbe driver in the next-net is also using ‘udata64’, that also needs to be updated. cc'ed txgbe maintainer.
That's a pity it did not take into account the deprecation notice. What kind of hack is it used for?
Can it be simply removed to allow quick merging of the PMD?
+1 for removing.
It seems to be a provision for future features, as this field is simply passed to an internal function that does not use it.
$ git grep -C 2 udata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c: tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txe->last_id = tx_last;
$ git grep -C 2 txgbe_set_xmit_ctx drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c-static inline void drivers/net/txgbe/txgbe_rxtx.c:txgbe_set_xmit_ctx(struct txgbe_tx_queue *txq, drivers/net/txgbe/txgbe_rxtx.c- volatile struct txgbe_tx_ctx_desc *ctx_txd, drivers/net/txgbe/txgbe_rxtx.c- uint64_t ol_flags, union txgbe_tx_offload tx_offload, -- drivers/net/txgbe/txgbe_rxtx.c- } drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c: txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c- tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c-
$ git grep -w mdata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c: __rte_unused uint64_t *mdata)
Signature · 1 line
David Marchand
Quoted 42 lines · David Marchand
Quoted 6 lines · Thomas Monjalon
Quoted 2 lines
The new txgbe driver in the next-net is also using ‘udata64’, that also needs to be updated. cc'ed txgbe maintainer.
That's a pity it did not take into account the deprecation notice. What kind of hack is it used for?
Can it be simply removed to allow quick merging of the PMD?+1 for removing.
It seems to be a provision for future features, as this field is simply passed to an internal function that does not use it.
$ git grep -C 2 udata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c: tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txe->last_id = tx_last;$ git grep -C 2 txgbe_set_xmit_ctx drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c-static inline void drivers/net/txgbe/txgbe_rxtx.c:txgbe_set_xmit_ctx(struct txgbe_tx_queue *txq, drivers/net/txgbe/txgbe_rxtx.c- volatile struct txgbe_tx_ctx_desc *ctx_txd, drivers/net/txgbe/txgbe_rxtx.c- uint64_t ol_flags, union txgbe_tx_offload tx_offload, -- drivers/net/txgbe/txgbe_rxtx.c- } drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c: txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c- tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c-
Quoted 6 lines
$ git grep -w mdata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c: __rte_unused uint64_t *mdata)--
David Marchand
Thanks for review.
It can be just simply removed in txgbe driver.
Quoted 47 lines · Jiawen Wu
Quoted 46 lines · David Marchand
Quoted 6 lines · Thomas Monjalon
Quoted 2 lines
The new txgbe driver in the next-net is also using ‘udata64’, that also needs to be updated. cc'ed txgbe maintainer.
That's a pity it did not take into account the deprecation notice. What kind of hack is it used for?
Can it be simply removed to allow quick merging of the PMD?+1 for removing.
It seems to be a provision for future features, as this field is simply passed to an internal function that does not use it.
$ git grep -C 2 udata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c: tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txe->last_id = tx_last;$ git grep -C 2 txgbe_set_xmit_ctx drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c-static inline void drivers/net/txgbe/txgbe_rxtx.c:txgbe_set_xmit_ctx(struct txgbe_tx_queue *txq, drivers/net/txgbe/txgbe_rxtx.c- volatile struct txgbe_tx_ctx_desc *ctx_txd, drivers/net/txgbe/txgbe_rxtx.c- uint64_t ol_flags, union txgbe_tx_offload tx_offload, -- drivers/net/txgbe/txgbe_rxtx.c- } drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c: txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c- tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c-$ git grep -w mdata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c: __rte_unused uint64_t *mdata)
Quoted 6 lines
Quoted 2 lines
--
David MarchandThanks for review.
It can be just simply removed in txgbe driver.
OK, I will remove it in the next-net.
Quoted 48 lines · Ferruh Yigit
Quoted 47 lines · Jiawen Wu
Quoted 46 lines · David Marchand
Quoted 6 lines · Thomas Monjalon
Quoted 2 lines
The new txgbe driver in the next-net is also using ‘udata64’, that also needs to be updated. cc'ed txgbe maintainer.
That's a pity it did not take into account the deprecation notice. What kind of hack is it used for?
Can it be simply removed to allow quick merging of the PMD?+1 for removing.
It seems to be a provision for future features, as this field is simply passed to an internal function that does not use it.
$ git grep -C 2 udata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c: tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c- txe->last_id = tx_last;$ git grep -C 2 txgbe_set_xmit_ctx drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c-static inline void drivers/net/txgbe/txgbe_rxtx.c:txgbe_set_xmit_ctx(struct txgbe_tx_queue *txq, drivers/net/txgbe/txgbe_rxtx.c- volatile struct txgbe_tx_ctx_desc *ctx_txd, drivers/net/txgbe/txgbe_rxtx.c- uint64_t ol_flags, union txgbe_tx_offload tx_offload,Signature · 10 lines
drivers/net/txgbe/txgbe_rxtx.c- } drivers/net/txgbe/txgbe_rxtx.c- drivers/net/txgbe/txgbe_rxtx.c: txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req, drivers/net/txgbe/txgbe_rxtx.c- tx_offload, &tx_pkt->udata64); drivers/net/txgbe/txgbe_rxtx.c- $ git grep -w mdata drivers/net/txgbe/ drivers/net/txgbe/txgbe_rxtx.c: __rte_unused uint64_t *mdata)
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Signature · 1 line
David MarchandThanks for review.
It can be just simply removed in txgbe driver.OK, I will remove it in the next-net.
Applied following:
diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c index b35b7de1cb..4d8b43423d 100644
--- a/drivers/net/txgbe/txgbe_rxtx.c
+++ b/drivers/net/txgbe/txgbe_rxtx.c
@@ -281,8 +281,7 @@ txgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf
**tx_pkts,
static inline void
txgbe_set_xmit_ctx(struct txgbe_tx_queue *txq,
volatile struct txgbe_tx_ctx_desc *ctx_txd,
- uint64_t ol_flags, union txgbe_tx_offload tx_offload,
- __rte_unused uint64_t *mdata)
+ uint64_t ol_flags, union txgbe_tx_offload tx_offload)
{
union txgbe_tx_offload tx_offload_mask;
uint32_t type_tucmd_mlhl; @@ -861,7 +860,7 @@ txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
}
txgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req,
- tx_offload, &tx_pkt->udata64);
+ tx_offload);
txe->last_id = tx_last;
tx_id = txe->next_id;