DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Alejandro Lucero <alejandro.lucero@netronome.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] nfp: support new medatada api
Date: Fri, 18 Aug 2017 16:51:06 +0100	[thread overview]
Message-ID: <37f59d30-57fb-d211-3de6-6fae76628c37@intel.com> (raw)
In-Reply-To: <1502461849-19561-1-git-send-email-alejandro.lucero@netronome.com>

On 8/11/2017 3:30 PM, Alejandro Lucero wrote:
> We need to support how metadata was handled and the new api, which will
> allow to work with different metadata types and data dynamically.

What is the API mentioned?

> 
> Although this patch just supports one type handled by the PMD. Future uses
> regarding firmware apps will extend this support.
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> ---
>  drivers/net/nfp/nfp_net.c      | 37 +++++++++++++++++++++++++++++++------
>  drivers/net/nfp/nfp_net_ctrl.h |  5 +++++
>  drivers/net/nfp/nfp_net_pmd.h  |  2 ++
>  3 files changed, 38 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> index c9895a2..5ea55c7 100644
> --- a/drivers/net/nfp/nfp_net.c
> +++ b/drivers/net/nfp/nfp_net.c
> @@ -1734,6 +1734,8 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw)
>  #define NFP_HASH_OFFSET      ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4)
>  #define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8)
>  
> +#define NFP_DESC_META_LEN(d) (d->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
> +
>  /*
>   * nfp_net_set_hash - Set mbuf hash data
>   *
> @@ -1744,18 +1746,41 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw)
>  nfp_net_set_hash(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
>  		 struct rte_mbuf *mbuf)
>  {
> -	uint32_t hash;
> -	uint32_t hash_type;
>  	struct nfp_net_hw *hw = rxq->hw;
> +	uint8_t *meta_offset;
> +	uint32_t meta_info;
> +	uint32_t hash = 0;
> +	uint32_t hash_type = 0;
>  
>  	if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS))
>  		return;
>  
> -	if (!(rxd->rxd.flags & PCIE_DESC_RX_RSS))
> +	if (NFD_CFG_MAJOR_VERSION_of(hw->ver) <= 3) {

It seems metadata parsing is valid for MAJOR_VERSION > 3, does it make
sense to mention from this in commit log?

> +		if (!(rxd->rxd.flags & PCIE_DESC_RX_RSS))
> +			return;
> +
> +		hash = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_OFFSET);
> +		hash_type = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_TYPE_OFFSET);
> +
> +	} else if (NFP_DESC_META_LEN(rxd)) {
> +		meta_offset = (uint8_t *)mbuf->buf_addr + mbuf->data_off;

It is possible to use rte_pktmbuf_mtod_offset(), result will be same tough.

> +		meta_offset -= NFP_DESC_META_LEN(rxd);
> +		meta_info = rte_be_to_cpu_32(*(uint32_t *)meta_offset);
> +		meta_offset += 4;
> +		/* NFP PMD just supports metadata for hashing */
> +		switch (meta_info & NFP_NET_META_FIELD_MASK) {
> +		case NFP_NET_META_HASH:
> +			meta_info >>= NFP_NET_META_FIELD_SIZE;
> +			hash = rte_be_to_cpu_32(*(uint32_t *)meta_offset);
> +			hash_type = meta_info && NFP_NET_META_FIELD_MASK;

META_FIELD already masked out above, right? Is this META_FIELD again or
just reused macro because of it has same value?

> +			break;
> +		default:
> +			/* Unsupported metadata can be a performance issue */
> +			return;
> +		}
> +	} else {
>  		return;
> -
> -	hash = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_OFFSET);
> -	hash_type = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_TYPE_OFFSET);
> +	}
>  
>  	mbuf->hash.rss = hash;
>  	mbuf->ol_flags |= PKT_RX_RSS_HASH;
> diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
> index 2c50043..becfabd 100644
> --- a/drivers/net/nfp/nfp_net_ctrl.h
> +++ b/drivers/net/nfp/nfp_net_ctrl.h
> @@ -52,6 +52,11 @@
>  /* Offset in Freelist buffer where packet starts on RX */
>  #define NFP_NET_RX_OFFSET               32
>  
> +/* Prepend field types */
> +#define NFP_NET_META_FIELD_SIZE         4
> +#define NFP_NET_META_HASH               1 /* next field carries hash type */
> +#define NFP_NET_META_MARK               2

META_MARK seems not used.

> +
>  /* Hash type pre-pended when a RSS hash was computed */
>  #define NFP_NET_RSS_NONE                0
>  #define NFP_NET_RSS_IPV4                1
> diff --git a/drivers/net/nfp/nfp_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h
> index c6bddaa..df22fa1 100644
> --- a/drivers/net/nfp/nfp_net_pmd.h
> +++ b/drivers/net/nfp/nfp_net_pmd.h
> @@ -283,6 +283,8 @@ struct nfp_net_txq {
>  #define PCIE_DESC_RX_UDP_CSUM_OK        (1 <<  1)
>  #define PCIE_DESC_RX_VLAN               (1 <<  0)
>  
> +#define NFP_NET_META_FIELD_MASK (0xf)

Can represent as following to stress the relation:
#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)

> +
>  struct nfp_net_rx_desc {
>  	union {
>  		/* Freelist descriptor */
> 

  reply	other threads:[~2017-08-18 15:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 14:30 Alejandro Lucero
2017-08-18 15:51 ` Ferruh Yigit [this message]
2017-08-21 13:36   ` Alejandro Lucero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37f59d30-57fb-d211-3de6-6fae76628c37@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=alejandro.lucero@netronome.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).