> -----Original Message-----
> From: Zeng, ZhichaoX <zhichaox.z...@intel.com>
> Sent: Thursday, December 21, 2023 3:28 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zh...@intel.com>; Zeng, ZhichaoX
> <zhichaox.z...@intel.com>; Wu, Jingjing <jingjing...@intel.com>; Xing, Beilei
> <beilei.x...@intel.com>
> Subject: [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar
> 
> This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
> whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor to
> send LLDP packet.
> 
> Signed-off-by: Zhichao Zeng <zhichaox.z...@intel.com>
> ---
>  drivers/net/iavf/iavf_ethdev.c |  1 +
>  drivers/net/iavf/iavf_rxtx.c   | 16 ++++++++++++++--
>  drivers/net/iavf/iavf_rxtx.h   |  3 +++
>  3 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c 
> index
> d1edb0dd5c..1be248926c 100644
> --- a/drivers/net/iavf/iavf_ethdev.c
> +++ b/drivers/net/iavf/iavf_ethdev.c
> @@ -41,6 +41,7 @@
>  #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
>  uint64_t iavf_timestamp_dynflag;
>  int iavf_timestamp_dynfield_offset = -1;
> +int iavf_tx_lldp_dynfield_offset = -1;
> 
>  static const char * const iavf_valid_args[] = {
>       IAVF_PROTO_XTR_ARG,
> diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index
> f19aa14646..3107102911 100644
> --- a/drivers/net/iavf/iavf_rxtx.c
> +++ b/drivers/net/iavf/iavf_rxtx.c
> @@ -2418,8 +2418,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
> 
>  /* Check if the context descriptor is needed for TX offloading */  static 
> inline
> uint16_t -iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
> +iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
>  {
> +     uint64_t flags = mb->ol_flags;
>       if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
>           RTE_MBUF_F_TX_TUNNEL_MASK |
> RTE_MBUF_F_TX_OUTER_IP_CKSUM |
>           RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
> @@ -2427,6 +2428,12 @@ iavf_calc_context_desc(uint64_t flags, uint8_t
> vlan_flag)
>       if (flags & RTE_MBUF_F_TX_VLAN &&
>           vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
>               return 1;
> +
> +     if (iavf_tx_lldp_dynfield_offset ==
> +             rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL))
> +             if (*RTE_MBUF_DYNFIELD(mb,

Its not necessary to lookup the dynamic field at data path which consume 
considerable CPU cycles that impact the performance.
the dynamic field offset can be decided during dev_start.


> +                     iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
> +                     return 1;
>       return 0;
>  }
> 
> @@ -2446,6 +2453,11 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t
> *field, struct rte_mbuf *m,
>                       << IAVF_TXD_CTX_QW1_CMD_SHIFT;
>       }
> 
> +     if (*RTE_MBUF_DYNFIELD(m,
> +             iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
> +             cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
> +                     << IAVF_TXD_CTX_QW1_CMD_SHIFT;
> +
>       *field |= cmd;
>  }
> 
> @@ -2826,7 +2838,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf
> **tx_pkts, uint16_t nb_pkts)
> 
>               nb_desc_data = mb->nb_segs;
>               nb_desc_ctx =
> -                     iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
> +                     iavf_calc_context_desc(mb, txq->vlan_flag);
>               nb_desc_ipsec = !!(mb->ol_flags &
> RTE_MBUF_F_TX_SEC_OFFLOAD);
> 
>               /**
> diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index
> f432f9d956..f6954a83c2 100644
> --- a/drivers/net/iavf/iavf_rxtx.h
> +++ b/drivers/net/iavf/iavf_rxtx.h
> @@ -107,8 +107,11 @@
>  #define IAVF_MAX_DATA_PER_TXD \
>       (IAVF_TXD_QW1_TX_BUF_SZ_MASK >>
> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
> 
> +#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
> +
>  extern uint64_t iavf_timestamp_dynflag;  extern int
> iavf_timestamp_dynfield_offset;
> +extern int iavf_tx_lldp_dynfield_offset;

It may not necessary to expose the offset value, as IAVF_TX_LLDP_DYNFIELD is 
the contract between
application and PMD already.

Reply via email to