DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 4/5] net/nfp: use flag bits to control parsing meta data
Date: Tue,  5 Mar 2024 10:29:22 +0800	[thread overview]
Message-ID: <20240305022923.891544-5-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240305022923.891544-1-chaoyong.he@corigine.com>

From: Long Wu <long.wu@corigine.com>

Use flag bits to indicate whether meta data exists and determine
whether it needs to be parsed.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_net_meta.c | 22 ++++++++++++++++++----
 drivers/net/nfp/nfp_net_meta.h |  1 -
 drivers/net/nfp/nfp_rxtx.c     |  2 +-
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index 2ec20aba7d..b39c55a868 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -27,13 +27,16 @@ nfp_net_meta_parse_chained(uint8_t *meta_base,
 
 	meta_info = rte_be_to_cpu_32(meta_header);
 	meta_offset = meta_base + 4;
+	meta->flags = 0;
 
 	for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, meta_offset += 4) {
 		switch (meta_info & NFP_NET_META_FIELD_MASK) {
 		case NFP_NET_META_PORTID:
+			meta->flags |= (1 << NFP_NET_META_PORTID);
 			meta->port_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
 			break;
 		case NFP_NET_META_HASH:
+			meta->flags |= (1 << NFP_NET_META_HASH);
 			/* Next field type is about the hash type */
 			meta_info >>= NFP_NET_META_FIELD_SIZE;
 			/* Hash value is in the data field */
@@ -41,6 +44,7 @@ nfp_net_meta_parse_chained(uint8_t *meta_base,
 			meta->hash_type = meta_info & NFP_NET_META_FIELD_MASK;
 			break;
 		case NFP_NET_META_VLAN:
+			meta->flags |= (1 << NFP_NET_META_VLAN);
 			vlan_info = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
 			meta->vlan[meta->vlan_layer].offload =
 					vlan_info >> NFP_NET_META_VLAN_OFFLOAD;
@@ -50,8 +54,8 @@ nfp_net_meta_parse_chained(uint8_t *meta_base,
 			meta->vlan_layer++;
 			break;
 		case NFP_NET_META_IPSEC:
+			meta->flags |= (1 << NFP_NET_META_IPSEC);
 			meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
-			meta->ipsec_type = meta_info & NFP_NET_META_FIELD_MASK;
 			break;
 		case NFP_NET_META_MARK:
 			meta->flags |= (1 << NFP_NET_META_MARK);
@@ -77,6 +81,7 @@ nfp_net_meta_parse_single(uint8_t *meta_base,
 		rte_be32_t meta_header,
 		struct nfp_net_meta_parsed *meta)
 {
+	meta->flags |= (1 << NFP_NET_META_HASH);
 	meta->hash_type = rte_be_to_cpu_32(meta_header);
 	meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4));
 }
@@ -92,6 +97,9 @@ nfp_net_meta_parse_hash(const struct nfp_net_meta_parsed *meta,
 	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return;
 
+	if (((meta->flags >> NFP_NET_META_HASH) & 0x1) == 0)
+		return;
+
 	mbuf->hash.rss = meta->hash;
 	mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
 }
@@ -109,6 +117,9 @@ nfp_net_meta_parse_vlan(const struct nfp_net_meta_parsed *meta,
 	if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
+	if (((meta->flags >> NFP_NET_META_VLAN) & 0x1) == 0)
+		return;
+
 	/*
 	 * The firmware support two ways to send the VLAN info (with priority) :
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
@@ -156,6 +167,9 @@ nfp_net_meta_parse_qinq(const struct nfp_net_meta_parsed *meta,
 			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
+	if (((meta->flags >> NFP_NET_META_VLAN) & 0x1) == 0)
+		return;
+
 	if (meta->vlan_layer < NFP_NET_META_MAX_VLANS)
 		return;
 
@@ -184,12 +198,12 @@ nfp_net_meta_parse_ipsec(struct nfp_net_meta_parsed *meta,
 	struct nfp_net_hw *hw;
 	struct nfp_tx_ipsec_desc_msg *desc_md;
 
+	if (((meta->flags >> NFP_NET_META_IPSEC) & 0x1) == 0)
+		return;
+
 	hw = rxq->hw;
 	sa_idx = meta->sa_idx;
 
-	if (meta->ipsec_type != NFP_NET_META_IPSEC)
-		return;
-
 	if (sa_idx >= NFP_NET_IPSEC_MAX_SA_CNT) {
 		mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
 	} else {
diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h
index 1d26b089d5..69d08cf3a7 100644
--- a/drivers/net/nfp/nfp_net_meta.h
+++ b/drivers/net/nfp/nfp_net_meta.h
@@ -77,7 +77,6 @@ struct nfp_net_meta_parsed {
 	uint32_t mark_id;         /**< Mark id value */
 	uint16_t flags;           /**< Bitmap to indicate if meta exist */
 	uint8_t hash_type;        /**< RSS hash type */
-	uint8_t ipsec_type;       /**< IPsec type */
 	uint8_t vlan_layer;       /**< The valid number of value in @vlan[] */
 	/**
 	 * Holds information parses from NFP_NET_META_VLAN.
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 716a6af34f..65ae19212d 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -497,7 +497,7 @@ nfp_net_recv_pkts(void *rx_queue,
 		mb->next = NULL;
 		mb->port = rxq->port_id;
 
-		struct nfp_net_meta_parsed meta = {};
+		struct nfp_net_meta_parsed meta;
 		nfp_net_meta_parse(rxds, rxq, hw, mb, &meta);
 
 		nfp_net_parse_ptype(rxq, rxds, mb);
-- 
2.39.1


  parent reply	other threads:[~2024-03-05  2:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05  2:29 [PATCH 0/5] add new meta data module Chaoyong He
2024-03-05  2:29 ` [PATCH 1/5] net/nfp: create " Chaoyong He
2024-03-05  2:29 ` [PATCH 2/5] net/nfp: uniform variable name format Chaoyong He
2024-03-05  2:29 ` [PATCH 3/5] net/nfp: uniform function " Chaoyong He
2024-03-05  2:29 ` Chaoyong He [this message]
2024-03-05  2:29 ` [PATCH 5/5] net/nfp: use big-endian meta data for packet Chaoyong He
2024-03-12 12:05 ` [PATCH 0/5] add new meta data module Ferruh Yigit

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=20240305022923.891544-5-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    /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).