DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [dpdk-dev] [PATCH v3 8/9] net/bnxt: fix to support zero mark id along with RSS action
Date: Tue, 28 Jan 2020 13:01:58 -0800
Message-ID: <20200128210159.6972-9-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200128210159.6972-1-ajit.khaparde@broadcom.com>

From: Somnath Kotur <somnath.kotur@broadcom.com>

Certain applications(Ex: OVS-DPDK) can issue rte_flow_create with mark id
set to 0. The mark table entry creation in the driver was assuming
non-zero mark ids. Fix it to have a valid flag for each entry.
Also, it is possible that both RSS flags and cfa_code/ mark id are
set as part of the Rx packet completion descriptor if the 'action'
for a flow is MARK + RSS.
Fix Rx completion processing to look for both fields as opposed to
only either.

Fixes: 94eb699bc82e ("net/bnxt: support flow mark action")

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h      |  9 +++++++--
 drivers/net/bnxt/bnxt_flow.c | 20 +++++++++++++++-----
 drivers/net/bnxt/bnxt_rxr.c  | 25 +++++++++++++++----------
 drivers/net/bnxt/bnxt_rxr.h  |  6 ++++--
 4 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 1a5d542b4..68786a89b 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -470,6 +470,11 @@ struct bnxt_error_recovery_info {
 	uint32_t        last_reset_counter;
 };
 
+struct bnxt_mark_info {
+	uint32_t	mark_id;
+	bool		valid;
+};
+
 /* address space location of register */
 #define BNXT_FW_STATUS_REG_TYPE_MASK	3
 /* register is located in PCIe config space */
@@ -668,10 +673,10 @@ struct bnxt {
 
 	/* Struct to hold adapter error recovery related info */
 	struct bnxt_error_recovery_info *recovery_info;
-#define BNXT_MARK_TABLE_SZ	(sizeof(uint32_t)  * 64 * 1024)
+#define BNXT_MARK_TABLE_SZ	(sizeof(struct bnxt_mark_info)  * 64 * 1024)
 /* TCAM and EM should be 16-bit only. Other modes not supported. */
 #define BNXT_FLOW_ID_MASK	0x0000ffff
-	uint32_t		*mark_table;
+	struct bnxt_mark_info	*mark_table;
 };
 
 int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu);
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index bd6c72623..9fb6dbdd9 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1263,7 +1263,6 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		vnic_id = attr->group;
 
 		BNXT_VALID_VNIC_OR_RET(bp, vnic_id);
-
 		vnic = &bp->vnic_info[vnic_id];
 
 		/* Check if requested RSS config matches RSS config of VNIC
@@ -1641,7 +1640,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 	bool update_flow = false;
 	struct rte_flow *flow;
 	int ret = 0;
-	uint32_t tun_type;
+	uint32_t tun_type, flow_id;
 
 	if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) {
 		rte_flow_error_set(error, EINVAL,
@@ -1773,8 +1772,16 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 			/* TCAM and EM should be 16-bit only.
 			 * Other modes not supported.
 			 */
-			bp->mark_table[filter->flow_id & BNXT_FLOW_ID_MASK] =
-				filter->mark;
+			flow_id = filter->flow_id & BNXT_FLOW_ID_MASK;
+			if (bp->mark_table[flow_id].valid) {
+				PMD_DRV_LOG(ERR,
+					    "Entry for Mark id 0x%x occupied"
+					    " flow id 0x%x\n",
+					    filter->mark, filter->flow_id);
+				goto free_filter;
+			}
+			bp->mark_table[flow_id].valid = true;
+			bp->mark_table[flow_id].mark_id = filter->mark;
 		}
 		bnxt_release_flow_lock(bp);
 		return flow;
@@ -1850,6 +1857,7 @@ _bnxt_flow_destroy(struct bnxt *bp,
 	struct bnxt_filter_info *filter;
 	struct bnxt_vnic_info *vnic;
 	int ret = 0;
+	uint32_t flow_id;
 
 	filter = flow->filter;
 	vnic = flow->vnic;
@@ -1868,7 +1876,9 @@ _bnxt_flow_destroy(struct bnxt *bp,
 		PMD_DRV_LOG(ERR, "Could not find matching flow\n");
 
 	if (filter->valid_flags & BNXT_FLOW_MARK_FLAG) {
-		bp->mark_table[filter->flow_id & BNXT_FLOW_ID_MASK] = 0;
+		flow_id = filter->flow_id & BNXT_FLOW_ID_MASK;
+		memset(&bp->mark_table[flow_id], 0,
+		       sizeof(bp->mark_table[flow_id]));
 		filter->flow_id = 0;
 	}
 
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 1ae0c3c38..1960b0515 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -488,11 +488,10 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 	if (flags_type & RX_PKT_CMPL_FLAGS_RSS_VALID) {
 		mbuf->hash.rss = rxcmp->rss_hash;
 		mbuf->ol_flags |= PKT_RX_RSS_HASH;
-	} else {
-		mbuf->hash.fdir.id = bnxt_get_cfa_code_or_mark_id(rxq->bp,
-								  rxcmp1);
-		mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
 	}
+
+	bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
+
 #ifdef RTE_LIBRTE_IEEE1588
 	if (unlikely((flags_type & RX_PKT_CMPL_FLAGS_MASK) ==
 		     RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP)) {
@@ -897,8 +896,9 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
 	return 0;
 }
 
-uint32_t bnxt_get_cfa_code_or_mark_id(struct bnxt *bp,
-				      struct rx_pkt_cmpl_hi *rxcmp1)
+void bnxt_set_mark_in_mbuf(struct bnxt *bp,
+			   struct rx_pkt_cmpl_hi *rxcmp1,
+			   struct rte_mbuf *mbuf)
 {
 	uint32_t cfa_code = 0;
 	uint8_t meta_fmt =  0;
@@ -907,10 +907,13 @@ uint32_t bnxt_get_cfa_code_or_mark_id(struct bnxt *bp,
 
 	cfa_code = rte_le_to_cpu_16(rxcmp1->cfa_code);
 	if (!cfa_code)
-		return 0;
+		return;
 
-	if (cfa_code && !bp->mark_table[cfa_code])
-		return cfa_code;
+	if (cfa_code && !bp->mark_table[cfa_code].valid) {
+		PMD_DRV_LOG(WARNING, "Invalid mark_tbl entry! cfa_code: 0x%x\n",
+			    cfa_code);
+		return;
+	}
 
 	flags2 = rte_le_to_cpu_16(rxcmp1->flags2);
 	meta = rte_le_to_cpu_32(rxcmp1->metadata);
@@ -932,5 +935,7 @@ uint32_t bnxt_get_cfa_code_or_mark_id(struct bnxt *bp,
 		 */
 		meta_fmt >>= BNXT_CFA_META_FMT_EM_EEM_SHFT;
 	}
-	return bp->mark_table[cfa_code];
+
+	mbuf->hash.fdir.hi = bp->mark_table[cfa_code].mark_id;
+	mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
 }
diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h
index bf860020c..d10dae25a 100644
--- a/drivers/net/bnxt/bnxt_rxr.h
+++ b/drivers/net/bnxt/bnxt_rxr.h
@@ -226,8 +226,10 @@ uint16_t bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 int bnxt_rxq_vec_setup(struct bnxt_rx_queue *rxq);
 #endif
 
-uint32_t bnxt_get_cfa_code_or_mark_id(struct bnxt *bp,
-				      struct rx_pkt_cmpl_hi *rxcmp1);
+void bnxt_set_mark_in_mbuf(struct bnxt *bp,
+			   struct rx_pkt_cmpl_hi *rxcmp1,
+			   struct rte_mbuf *mbuf);
+
 #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
-- 
2.21.0 (Apple Git-122.2)


  parent reply	other threads:[~2020-01-28 21:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28  7:29 [dpdk-dev] [PATCH v2 0/9] bnxt patchset Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 1/9] net/bnxt: fix bnxt_alloc_filter() to use a common routine Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 2/9] net/bnxt: fix bumping of L2 filter reference count Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 3/9] net/bnxt: fix to allow group ID 0 for RSS action Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 4/9] net/bnxt: remove redundant if statement Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 5/9] net/bnxt: remove redundant macro Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 6/9] net/bnxt: remove unnecessary structure variable Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 7/9] net/bnxt: remove a redundant variable Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 8/9] net/bnxt: fix to support zero mark id along with RSS action Somnath Kotur
2020-01-28  7:29 ` [dpdk-dev] [PATCH 9/9] net/bnxt: fix coverity warnings Somnath Kotur
2020-01-28 21:01 ` [dpdk-dev] [PATCH v3 0/9] bnxt patch set Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 1/9] net/bnxt: fix alloc filter to use a common routine Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 2/9] net/bnxt: fix bumping of L2 filter reference count Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 3/9] net/bnxt: fix to allow group ID 0 for RSS action Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 4/9] net/bnxt: remove redundant if statement Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 5/9] net/bnxt: remove redundant macro Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 6/9] net/bnxt: remove unnecessary structure variable Ajit Khaparde
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 7/9] net/bnxt: remove a redundant variable Ajit Khaparde
2020-01-28 21:01   ` Ajit Khaparde [this message]
2020-01-28 21:01   ` [dpdk-dev] [PATCH v3 9/9] net/bnxt: fix coverity warnings Ajit Khaparde
2020-01-29 12:30     ` Ferruh Yigit
2020-01-28 21:07   ` [dpdk-dev] [PATCH v3 0/9] bnxt patch set Ajit Khaparde

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=20200128210159.6972-9-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=somnath.kotur@broadcom.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git