DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support
@ 2019-09-03  2:18 Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 01/17] net/bnxt: return standard error codes for HWRM command Ajit Khaparde
                   ` (17 more replies)
  0 siblings, 18 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

Among other changes, this patchset adds support to:
- create filters with RSS action.
- create source MAC filters.
- use user provided priority to place rule appropriately in HW.

This series is dependent on the series "bnxt patchset" submitted earlier
https://patchwork.dpdk.org/project/dpdk/list/?series=6190

Please apply. Thanks

Ajit Khaparde (13):
  net/bnxt: return standard error codes for HWRM command
  net/bnxt: refactor code to allow dynamic creation of VNIC
  net/bnxt: allow flow creation when RSS is enabled
  net/bnxt: add support to create SMAC and inner DMAC filters
  net/bnxt: add support for RSS action
  net/bnxt: parse priority attribute for flow creation
  net/bnxt: delete and flush L2 filters cleanly
  net/bnxt: cleanup vnic after flow validate
  net/bnxt: allow only unicast MAC address filter creation
  net/bnxt: check device is started before flow creation
  net/bnxt: handle flow flush handling
  net/bnxt: handle cleanup if flow creation fails
  net/bnxt: drop untagged frames when specified

Rahul Gupta (1):
  net/bnxt: properly handle ring cleanup in case of error

Somnath Kotur (1):
  net/bnxt: check for invalid VNIC ID in vnic tpa cfg

Venkat Duvvuru (2):
  net/bnxt: validate RSS hash key length
  net/bnxt: synchronize between flow related functions

 drivers/net/bnxt/bnxt.h        |  12 +
 drivers/net/bnxt/bnxt_ethdev.c |  92 ++--
 drivers/net/bnxt/bnxt_filter.c |  18 +-
 drivers/net/bnxt/bnxt_filter.h |  15 +
 drivers/net/bnxt/bnxt_flow.c   | 738 +++++++++++++++++++++++++++++----
 drivers/net/bnxt/bnxt_hwrm.c   | 153 +++++--
 drivers/net/bnxt/bnxt_hwrm.h   |   7 +-
 drivers/net/bnxt/bnxt_ring.c   |  37 ++
 drivers/net/bnxt/bnxt_rxq.c    |  30 +-
 drivers/net/bnxt/bnxt_util.h   |   4 +
 drivers/net/bnxt/bnxt_vnic.c   |  38 +-
 drivers/net/bnxt/bnxt_vnic.h   |   6 +
 12 files changed, 962 insertions(+), 188 deletions(-)

-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 01/17] net/bnxt: return standard error codes for HWRM command
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 02/17] net/bnxt: refactor code to allow dynamic creation of VNIC Ajit Khaparde
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

If the FW returns an error for an HWRM request, it does not necessarily
return standard error codes. Convert these HWRM errors to standard errno.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_hwrm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index bdc84c831..c876ff75c 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -212,8 +212,14 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 		rte_spinlock_unlock(&bp->hwrm_lock); \
 		if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
 			rc = -EACCES; \
-		else if (rc > 0) \
+		else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
+			rc = -ENOSPC; \
+		else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
 			rc = -EINVAL; \
+		else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
+			rc = -ENOTSUP; \
+		else if (rc > 0) \
+			rc = -EIO; \
 		return rc; \
 	} \
 	if (resp->error_code) { \
@@ -234,8 +240,14 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 		rte_spinlock_unlock(&bp->hwrm_lock); \
 		if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
 			rc = -EACCES; \
-		else if (rc > 0) \
+		else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
+			rc = -ENOSPC; \
+		else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
 			rc = -EINVAL; \
+		else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
+			rc = -ENOTSUP; \
+		else if (rc > 0) \
+			rc = -EIO; \
 		return rc; \
 	} \
 } while (0)
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 02/17] net/bnxt: refactor code to allow dynamic creation of VNIC
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 01/17] net/bnxt: return standard error codes for HWRM command Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 03/17] net/bnxt: allow flow creation when RSS is enabled Ajit Khaparde
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru

Refactor code to allow dynamic creation of VNIC for RSS
or Queue Action during flow create.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_ethdev.c | 54 ++++++++++------------------------
 drivers/net/bnxt/bnxt_flow.c   |  5 ++++
 drivers/net/bnxt/bnxt_rxq.c    | 30 ++++++++-----------
 drivers/net/bnxt/bnxt_vnic.c   | 36 +++++++++++++++++++++++
 drivers/net/bnxt/bnxt_vnic.h   |  3 ++
 6 files changed, 73 insertions(+), 56 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 2e662b297..c3938af37 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -460,6 +460,7 @@ struct bnxt {
 
 	unsigned int		rx_nr_rings;
 	unsigned int		rx_cp_nr_rings;
+	unsigned int		rx_num_qs_per_vnic;
 	struct bnxt_rx_queue **rx_queues;
 	const void		*rx_mem_zone;
 	struct rx_port_stats    *hw_rx_port_stats;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 3b190d4e4..6da4a9b09 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -321,17 +321,10 @@ static int bnxt_init_chip(struct bnxt *bp)
 	for (i = 0; i < bp->nr_vnics; i++) {
 		struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
-		uint32_t size = sizeof(*vnic->fw_grp_ids) * bp->max_ring_grps;
 
-		vnic->fw_grp_ids = rte_zmalloc("vnic_fw_grp_ids", size, 0);
-		if (!vnic->fw_grp_ids) {
-			PMD_DRV_LOG(ERR,
-				    "Failed to alloc %d bytes for group ids\n",
-				    size);
-			rc = -ENOMEM;
+		rc = bnxt_vnic_grp_alloc(bp, vnic);
+		if (rc)
 			goto err_out;
-		}
-		memset(vnic->fw_grp_ids, -1, size);
 
 		PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
 			    i, vnic, vnic->fw_grp_ids);
@@ -387,7 +380,7 @@ static int bnxt_init_chip(struct bnxt *bp)
 			goto err_out;
 		}
 
-		for (j = 0; j < bp->rx_nr_rings; j++) {
+		for (j = 0; j < bp->rx_num_qs_per_vnic; j++) {
 			rxq = bp->eth_dev->data->rx_queues[j];
 
 			PMD_DRV_LOG(DEBUG,
@@ -1288,8 +1281,6 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
 	struct bnxt *bp = eth_dev->data->dev_private;
 	struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
 	struct bnxt_vnic_info *vnic;
-	uint16_t hash_type = 0;
-	unsigned int i;
 	int rc;
 
 	rc = is_bnxt_in_error(bp);
@@ -1311,35 +1302,20 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
 	bp->flags |= BNXT_FLAG_UPDATE_HASH;
 	memcpy(&bp->rss_conf, rss_conf, sizeof(*rss_conf));
 
-	if (rss_conf->rss_hf & ETH_RSS_IPV4)
-		hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
-	if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
-		hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
-	if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
-		hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
-	if (rss_conf->rss_hf & ETH_RSS_IPV6)
-		hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
-	if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
-		hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6;
-	if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
-		hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
-
-	/* Update the RSS VNIC(s) */
-	for (i = 0; i < bp->nr_vnics; i++) {
-		vnic = &bp->vnic_info[i];
-		vnic->hash_type = hash_type;
+	/* Update the default RSS VNIC(s) */
+	vnic = &bp->vnic_info[0];
+	vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_conf->rss_hf);
 
-		/*
-		 * Use the supplied key if the key length is
-		 * acceptable and the rss_key is not NULL
-		 */
-		if (rss_conf->rss_key &&
-		    rss_conf->rss_key_len <= HW_HASH_KEY_SIZE)
-			memcpy(vnic->rss_hash_key, rss_conf->rss_key,
-			       rss_conf->rss_key_len);
+	/*
+	 * Use the supplied key if the key length is
+	 * acceptable and the rss_key is not NULL
+	 */
+	if (rss_conf->rss_key && rss_conf->rss_key_len <= HW_HASH_KEY_SIZE)
+		memcpy(vnic->rss_hash_key,
+		       rss_conf->rss_key,
+		       rss_conf->rss_key_len);
 
-		bnxt_hwrm_vnic_rss_cfg(bp, vnic);
-	}
+	bnxt_hwrm_vnic_rss_cfg(bp, vnic);
 	return 0;
 }
 
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index be9b6fad3..0eeff7b33 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1249,6 +1249,11 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 	struct bnxt_vnic_info *vnic = flow->vnic;
 	int ret = 0;
 
+	if (!filter) {
+		ret = -EINVAL;
+		goto done;
+	}
+
 	if (filter->filter_type == HWRM_CFA_TUNNEL_REDIRECT_FILTER &&
 	    filter->enables == filter->tunnel_type) {
 		ret = bnxt_handle_tunnel_redirect_destroy(bp,
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index d6bca7fd4..2e5f2cf29 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -100,6 +100,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
 		}
 	}
 	nb_q_per_grp = bp->rx_cp_nr_rings / pools;
+	bp->rx_num_qs_per_vnic = nb_q_per_grp;
 	PMD_DRV_LOG(DEBUG, "pools = %u nb_q_per_grp = %u\n",
 		    pools, nb_q_per_grp);
 	start_grp_id = 0;
@@ -158,29 +159,16 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
 out:
 	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
 		struct rte_eth_rss_conf *rss = &dev_conf->rx_adv_conf.rss_conf;
-		uint16_t hash_type = 0;
 
 		if (bp->flags & BNXT_FLAG_UPDATE_HASH) {
 			rss = &bp->rss_conf;
 			bp->flags &= ~BNXT_FLAG_UPDATE_HASH;
 		}
 
-		if (rss->rss_hf & ETH_RSS_IPV4)
-			hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
-		if (rss->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
-			hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
-		if (rss->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
-			hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
-		if (rss->rss_hf & ETH_RSS_IPV6)
-			hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
-		if (rss->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
-			hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6;
-		if (rss->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
-			hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
-
 		for (i = 0; i < bp->nr_vnics; i++) {
 			vnic = &bp->vnic_info[i];
-			vnic->hash_type = hash_type;
+			vnic->hash_type =
+				bnxt_rte_to_hwrm_hash_types(rss->rss_hf);
 
 			/*
 			 * Use the supplied key if the key length is
@@ -471,7 +459,12 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 				    vnic, bp->grp_info[rx_queue_id].fw_grp_id);
 		}
 
-		rc = bnxt_vnic_rss_configure(bp, vnic);
+		PMD_DRV_LOG(DEBUG,
+			    "vnic = %p fw_grp_id = %d\n",
+			    vnic, bp->grp_info[rx_queue_id].fw_grp_id);
+		PMD_DRV_LOG(DEBUG, "Rx Queue Count %d\n", vnic->rx_queue_cnt);
+		if (vnic->rx_queue_cnt > 1)
+			rc = bnxt_vnic_rss_configure(bp, vnic);
 	}
 
 	if (rc == 0)
@@ -524,7 +517,10 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		vnic = rxq->vnic;
 		if (BNXT_HAS_RING_GRPS(bp))
 			vnic->fw_grp_ids[rx_queue_id] = INVALID_HW_RING_ID;
-		rc = bnxt_vnic_rss_configure(bp, vnic);
+
+		PMD_DRV_LOG(DEBUG, "Rx Queue Count %d\n", vnic->rx_queue_cnt);
+		if (vnic->rx_queue_cnt > 1)
+			rc = bnxt_vnic_rss_configure(bp, vnic);
 	}
 
 	if (rc == 0)
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 9ea99388b..4f3f9b359 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -222,3 +222,39 @@ int bnxt_alloc_vnic_mem(struct bnxt *bp)
 	bp->vnic_info = vnic_mem;
 	return 0;
 }
+
+int bnxt_vnic_grp_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+	uint32_t size = sizeof(*vnic->fw_grp_ids) * bp->max_ring_grps;
+
+	vnic->fw_grp_ids = rte_zmalloc("vnic_fw_grp_ids", size, 0);
+	if (!vnic->fw_grp_ids) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to alloc %d bytes for group ids\n",
+			    size);
+		return -ENOMEM;
+	}
+	memset(vnic->fw_grp_ids, -1, size);
+
+	return 0;
+}
+
+uint16_t bnxt_rte_to_hwrm_hash_types(uint64_t rte_type)
+{
+	uint16_t hwrm_type = 0;
+
+	if (rte_type & ETH_RSS_IPV4)
+		hwrm_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
+	if (rte_type & ETH_RSS_NONFRAG_IPV4_TCP)
+		hwrm_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
+	if (rte_type & ETH_RSS_NONFRAG_IPV4_UDP)
+		hwrm_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
+	if (rte_type & ETH_RSS_IPV6)
+		hwrm_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
+	if (rte_type & ETH_RSS_NONFRAG_IPV6_TCP)
+		hwrm_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6;
+	if (rte_type & ETH_RSS_NONFRAG_IPV6_UDP)
+		hwrm_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
+
+	return hwrm_type;
+}
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index 16a0d5763..cb2707f36 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -42,6 +42,7 @@ struct bnxt_vnic_info {
 
 	uint16_t	cos_rule;
 	uint16_t	lb_rule;
+	uint16_t	rx_queue_cnt;
 	bool		vlan_strip;
 	bool		func_default;
 	bool		bd_stall;
@@ -63,4 +64,6 @@ void bnxt_free_vnic_attributes(struct bnxt *bp);
 int bnxt_alloc_vnic_attributes(struct bnxt *bp);
 void bnxt_free_vnic_mem(struct bnxt *bp);
 int bnxt_alloc_vnic_mem(struct bnxt *bp);
+int bnxt_vnic_grp_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+uint16_t bnxt_rte_to_hwrm_hash_types(uint64_t rte_type);
 #endif
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 03/17] net/bnxt: allow flow creation when RSS is enabled
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 01/17] net/bnxt: return standard error codes for HWRM command Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 02/17] net/bnxt: refactor code to allow dynamic creation of VNIC Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 04/17] net/bnxt: add support to create SMAC and inner DMAC filters Ajit Khaparde
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru

Currently flow creation is allowed with queue action only
when RSS is disabled. Remove this restriction. Flows can be
created when RSS is enabled.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c |   2 +-
 drivers/net/bnxt/bnxt_flow.c   | 177 +++++++++++++++++++++++++++------
 drivers/net/bnxt/bnxt_vnic.h   |   2 +
 4 files changed, 149 insertions(+), 33 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index c3938af37..f0b1021cd 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -558,6 +558,7 @@ struct bnxt {
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
+uint16_t bnxt_rss_ctxts(const struct bnxt *bp);
 
 int bnxt_map_fw_health_status_regs(struct bnxt *bp);
 uint32_t bnxt_read_fw_status_reg(struct bnxt *bp, uint32_t index);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 6da4a9b09..0c605202c 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -187,7 +187,7 @@ int is_bnxt_in_error(struct bnxt *bp)
  * High level utility functions
  */
 
-static uint16_t bnxt_rss_ctxts(const struct bnxt *bp)
+uint16_t bnxt_rss_ctxts(const struct bnxt *bp)
 {
 	if (!BNXT_CHIP_THOR(bp))
 		return 1;
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 0eeff7b33..9f8894c7c 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -14,6 +14,8 @@
 #include "bnxt.h"
 #include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
+#include "bnxt_ring.h"
+#include "bnxt_rxq.h"
 #include "bnxt_vnic.h"
 #include "bnxt_util.h"
 #include "hsi_struct_def_dpdk.h"
@@ -151,23 +153,13 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 	int use_ntuple;
 	uint32_t en = 0;
 	uint32_t en_ethertype;
-	int dflt_vnic, rc = 0;
+	int dflt_vnic;
 
 	use_ntuple = bnxt_filter_type_check(pattern, error);
 	PMD_DRV_LOG(DEBUG, "Use NTUPLE %d\n", use_ntuple);
 	if (use_ntuple < 0)
 		return use_ntuple;
 
-	if (use_ntuple && (bp->eth_dev->data->dev_conf.rxmode.mq_mode &
-	    ETH_MQ_RX_RSS)) {
-		PMD_DRV_LOG(ERR, "Cannot create ntuple flow on RSS queues\n");
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
-				   "Cannot create flow on RSS queues");
-		rc = -rte_errno;
-		return rc;
-	}
-
 	filter->filter_type = use_ntuple ?
 		HWRM_CFA_NTUPLE_FILTER : HWRM_CFA_EM_FILTER;
 	en_ethertype = use_ntuple ?
@@ -715,17 +707,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr,
 				   "No support for priority.");
 		return -rte_errno;
 	}
-
-	/* Not supported */
-	if (attr->group) {
-		rte_flow_error_set(error,
-				   EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
-				   attr,
-				   "No support for group.");
-		return -rte_errno;
-	}
-
 	return 0;
 }
 
@@ -764,6 +745,50 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,
 	return filter1;
 }
 
+static int bnxt_vnic_prep(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+	struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
+	uint64_t rx_offloads = dev_conf->rxmode.offloads;
+	int rc;
+
+	rc = bnxt_vnic_grp_alloc(bp, vnic);
+	if (rc)
+		goto ret;
+
+	rc = bnxt_hwrm_vnic_alloc(bp, vnic);
+	if (rc) {
+		PMD_DRV_LOG(ERR, "HWRM vnic alloc failure rc: %x\n", rc);
+		goto ret;
+	}
+	bp->nr_vnics++;
+
+	/* RSS context is required only when there is more than one RSS ring */
+	if (vnic->rx_queue_cnt > 1) {
+		rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic, 0 /* ctx_idx 0 */);
+		if (rc) {
+			PMD_DRV_LOG(ERR,
+				    "HWRM vnic ctx alloc failure: %x\n", rc);
+			goto ret;
+		}
+	} else {
+		PMD_DRV_LOG(DEBUG, "No RSS context required\n");
+	}
+
+	if (rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
+		vnic->vlan_strip = true;
+	else
+		vnic->vlan_strip = false;
+
+	rc = bnxt_hwrm_vnic_cfg(bp, vnic);
+	if (rc)
+		goto ret;
+
+	bnxt_hwrm_vnic_plcmode_cfg(bp, vnic);
+
+ret:
+	return rc;
+}
+
 static int
 bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			     const struct rte_flow_item pattern[],
@@ -775,12 +800,14 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	const struct rte_flow_action *act =
 		bnxt_flow_non_void_action(actions);
 	struct bnxt *bp = dev->data->dev_private;
+	struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
 	const struct rte_flow_action_queue *act_q;
 	const struct rte_flow_action_vf *act_vf;
 	struct bnxt_vnic_info *vnic, *vnic0;
 	struct bnxt_filter_info *filter1;
+	struct bnxt_rx_queue *rxq = NULL;
+	int dflt_vnic, vnic_id;
 	uint32_t vf = 0;
-	int dflt_vnic;
 	int rc;
 
 	rc =
@@ -800,7 +827,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
 		/* Allow this flow. Redirect to a VNIC. */
 		act_q = (const struct rte_flow_action_queue *)act->conf;
-		if (act_q->index >= bp->rx_nr_rings) {
+		if (!act_q->index || act_q->index >= bp->rx_nr_rings) {
 			rte_flow_error_set(error,
 					   EINVAL,
 					   RTE_FLOW_ERROR_TYPE_ACTION,
@@ -811,18 +838,78 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		}
 		PMD_DRV_LOG(DEBUG, "Queue index %d\n", act_q->index);
 
-		vnic0 = &bp->vnic_info[0];
-		vnic =  &bp->vnic_info[act_q->index];
+		vnic_id = attr->group;
+		if (!vnic_id) {
+			PMD_DRV_LOG(DEBUG, "Group id is 0\n");
+			vnic_id = act_q->index;
+		}
+
+		vnic = &bp->vnic_info[vnic_id];
 		if (vnic == NULL) {
 			rte_flow_error_set(error,
 					   EINVAL,
 					   RTE_FLOW_ERROR_TYPE_ACTION,
 					   act,
-					   "No matching VNIC for queue ID.");
+					   "No matching VNIC found.");
 			rc = -rte_errno;
 			goto ret;
 		}
+		if (vnic->rx_queue_cnt) {
+			if (vnic->rx_queue_cnt > 1 ||
+			    vnic->start_grp_id != act_q->index) {
+				PMD_DRV_LOG(ERR,
+					    "VNIC already in use\n");
+				rte_flow_error_set(error,
+						   EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   act,
+						   "VNIC already in use");
+				rc = -rte_errno;
+				goto ret;
+			}
+			goto use_vnic;
+		}
+
+		rxq = bp->rx_queues[act_q->index];
+
+		if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) && rxq)
+			goto use_vnic;
+
+		if (!rxq ||
+		    bp->vnic_info[0].fw_grp_ids[act_q->index] !=
+		    INVALID_HW_RING_ID ||
+		    !rxq->rx_deferred_start) {
+			PMD_DRV_LOG(ERR,
+				    "Queue invalid or used with other VNIC\n");
+			rte_flow_error_set(error,
+					   EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "Queue invalid queue or in use");
+			rc = -rte_errno;
+			goto ret;
+		}
+
+use_vnic:
+		rxq->vnic = vnic;
+		vnic->rx_queue_cnt++;
+		vnic->start_grp_id = act_q->index;
+		vnic->end_grp_id = act_q->index;
+		vnic->func_default = 0;	//This is not a default VNIC.
+
+		PMD_DRV_LOG(DEBUG, "VNIC found\n");
+
+		rc = bnxt_vnic_prep(bp, vnic);
+		if (rc)
+			goto ret;
+
+		PMD_DRV_LOG(DEBUG,
+			    "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
+			    act_q->index, vnic, vnic->fw_grp_ids);
 
+		vnic->ff_pool_idx = vnic_id;
+		PMD_DRV_LOG(DEBUG,
+			    "Setting vnic ff_idx %d\n", vnic->ff_pool_idx);
 		filter->dst_id = vnic->fw_vnic_id;
 		filter1 = bnxt_get_l2_filter(bp, filter, vnic);
 		if (filter1 == NULL) {
@@ -989,9 +1076,12 @@ bnxt_match_filter(struct bnxt *bp, struct bnxt_filter_info *nf)
 	struct rte_flow *flow;
 	int i;
 
-	for (i = bp->nr_vnics - 1; i >= 0; i--) {
+	for (i = bp->max_vnics; i >= 0; i--) {
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
+		if (vnic->fw_vnic_id == INVALID_VNIC_ID)
+			continue;
+
 		STAILQ_FOREACH(flow, &vnic->flow_list, next) {
 			mf = flow->filter;
 
@@ -1063,8 +1153,8 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 		 struct rte_flow_error *error)
 {
 	struct bnxt *bp = dev->data->dev_private;
-	struct bnxt_filter_info *filter;
 	struct bnxt_vnic_info *vnic = NULL;
+	struct bnxt_filter_info *filter;
 	bool update_flow = false;
 	struct rte_flow *flow;
 	unsigned int i;
@@ -1161,12 +1251,35 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 		ret = bnxt_hwrm_set_ntuple_filter(bp, filter->dst_id, filter);
 	}
 
-	for (i = 0; i < bp->nr_vnics; i++) {
+	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
-		if (filter->dst_id == vnic->fw_vnic_id)
+		if (vnic->fw_vnic_id != INVALID_VNIC_ID &&
+		    filter->dst_id == vnic->fw_vnic_id) {
+			PMD_DRV_LOG(ERR, "Found matching VNIC Id %d\n",
+				    vnic->ff_pool_idx);
 			break;
+		}
 	}
 done:
+	if (!ret) {
+		flow->filter = filter;
+		flow->vnic = vnic;
+		/* VNIC is set only in case of queue or RSS action */
+		if (vnic) {
+			/*
+			 * RxQ0 is not used for flow filters.
+			 */
+
+			if (update_flow) {
+				ret = -EXDEV;
+				goto free_flow;
+			}
+			STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
+		}
+		PMD_DRV_LOG(ERR, "Successfully created flow.\n");
+		STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
+		return flow;
+	}
 	if (!ret) {
 		flow->filter = filter;
 		flow->vnic = vnic;
@@ -1189,7 +1302,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 		rte_flow_error_set(error, ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 				   "Flow with pattern exists, updating destination queue");
-	else
+	else if (!rte_errno)
 		rte_flow_error_set(error, -ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 				   "Failed to create flow.");
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index cb2707f36..ec3a3ff51 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -9,6 +9,8 @@
 #include <sys/queue.h>
 #include <stdbool.h>
 
+#define INVALID_VNIC_ID		((uint16_t)-1)
+
 struct bnxt_vnic_info {
 	STAILQ_ENTRY(bnxt_vnic_info)	next;
 	uint8_t		ff_pool_idx;
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 04/17] net/bnxt: add support to create SMAC and inner DMAC filters
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (2 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 03/17] net/bnxt: allow flow creation when RSS is enabled Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 05/17] net/bnxt: add support for RSS action Ajit Khaparde
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Somnath Kotur, Rahul Gupta

We are currently creating only outer DMAC filters.
Create SMAC and inner DMAC filters using HWRM_CFA_L2_FILTER_ALLOC.
For this the HWRM_CFA_L2_FILTER_ALLOC has already been updated.

Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  4 ++
 drivers/net/bnxt/bnxt_ethdev.c |  9 +++-
 drivers/net/bnxt/bnxt_filter.h |  8 +++
 drivers/net/bnxt/bnxt_flow.c   | 90 ++++++++++++++++++++++++++++------
 drivers/net/bnxt/bnxt_hwrm.c   | 44 ++++++++++++++++-
 drivers/net/bnxt/bnxt_hwrm.h   |  4 ++
 drivers/net/bnxt/bnxt_util.h   |  4 ++
 7 files changed, 146 insertions(+), 17 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index f0b1021cd..64cc06304 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -445,6 +445,7 @@ struct bnxt {
 #define BNXT_FLAG_NEW_RM			BIT(21)
 #define BNXT_FLAG_INIT_DONE			BIT(22)
 #define BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD	BIT(23)
+#define BNXT_FLAG_ADV_FLOW_MGMT			BIT(24)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
@@ -458,6 +459,9 @@ struct bnxt {
 #define BNXT_HAS_NQ(bp)		BNXT_CHIP_THOR(bp)
 #define BNXT_HAS_RING_GRPS(bp)	(!BNXT_CHIP_THOR(bp))
 
+	uint32_t		flow_flags;
+#define BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN	BIT(0)
+
 	unsigned int		rx_nr_rings;
 	unsigned int		rx_cp_nr_rings;
 	unsigned int		rx_num_qs_per_vnic;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 0c605202c..b72466467 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1006,6 +1006,7 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev,
 
 	filter->mac_index = index;
 	memcpy(filter->l2_addr, mac_addr, RTE_ETHER_ADDR_LEN);
+	filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
 
 	rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter);
 	if (!rc) {
@@ -1674,6 +1675,7 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id)
 	filter->l2_ivlan = vlan_id;
 	filter->l2_ivlan_mask = 0x0FFF;
 	filter->enables |= en;
+	filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
 	rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter);
 	if (rc) {
 		/* Free the newly allocated filter as we were
@@ -1777,7 +1779,8 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,
 
 		memcpy(filter->l2_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
 		memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
-		filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+		filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX |
+			HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
 		filter->enables |=
 			HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
 			HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK;
@@ -4253,6 +4256,10 @@ static int bnxt_init_fw(struct bnxt *bp)
 	if (rc)
 		return -EIO;
 
+	rc = bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(bp);
+	if (rc)
+		return rc;
+
 	rc = bnxt_hwrm_queue_qportcfg(bp);
 	if (rc)
 		return rc;
diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h
index 4fda3f03a..52d3582ba 100644
--- a/drivers/net/bnxt/bnxt_filter.h
+++ b/drivers/net/bnxt/bnxt_filter.h
@@ -9,6 +9,13 @@
 #include <rte_ether.h>
 
 struct bnxt;
+
+#define BNXT_FLOW_L2_VALID_FLAG			BIT(0)
+#define BNXT_FLOW_L2_SRC_VALID_FLAG		BIT(1)
+#define BNXT_FLOW_L2_INNER_SRC_VALID_FLAG	BIT(2)
+#define BNXT_FLOW_L2_DST_VALID_FLAG		BIT(3)
+#define BNXT_FLOW_L2_INNER_DST_VALID_FLAG	BIT(4)
+
 struct bnxt_filter_info {
 	STAILQ_ENTRY(bnxt_filter_info)	next;
 	uint64_t		fw_l2_filter_id;
@@ -28,6 +35,7 @@ struct bnxt_filter_info {
 	uint32_t		enables;
 	uint8_t			l2_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t			l2_addr_mask[RTE_ETHER_ADDR_LEN];
+	uint32_t		valid_flags;
 	uint16_t		l2_ovlan;
 	uint16_t		l2_ovlan_mask;
 	uint16_t		l2_ivlan;
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 9f8894c7c..4ba280fff 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -86,8 +86,9 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[],
 
 	while (item->type != RTE_FLOW_ITEM_TYPE_END) {
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_ANY:
 		case RTE_FLOW_ITEM_TYPE_ETH:
-			use_ntuple = 1;
+			use_ntuple = 0;
 			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			use_ntuple = 0;
@@ -111,9 +112,6 @@ bnxt_filter_type_check(const struct rte_flow_item pattern[],
 			}
 			use_ntuple |= 1;
 			break;
-		case RTE_FLOW_ITEM_TYPE_ANY:
-			use_ntuple = 0;
-			break;
 		default:
 			PMD_DRV_LOG(DEBUG, "Unknown Flow type\n");
 			use_ntuple |= 0;
@@ -146,13 +144,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 	uint8_t vni_mask[] = {0xFF, 0xFF, 0xFF};
 	uint8_t tni_mask[] = {0xFF, 0xFF, 0xFF};
 	const struct rte_flow_item_vf *vf_spec;
-	uint32_t tenant_id_be = 0;
+	uint32_t tenant_id_be = 0, valid_flags = 0;
 	bool vni_masked = 0;
 	bool tni_masked = 0;
+	uint32_t en_ethertype;
+	uint8_t inner = 0;
 	uint32_t vf = 0;
-	int use_ntuple;
 	uint32_t en = 0;
-	uint32_t en_ethertype;
+	int use_ntuple;
 	int dflt_vnic;
 
 	use_ntuple = bnxt_filter_type_check(pattern, error);
@@ -177,6 +176,12 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_ANY:
+			inner =
+			((const struct rte_flow_item_any *)item->spec)->num > 3;
+			if (inner)
+				PMD_DRV_LOG(DEBUG, "Parse inner header\n");
+			break;
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			if (!item->spec || !item->mask)
 				break;
@@ -213,18 +218,24 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->dst)) {
 				rte_memcpy(filter->dst_macaddr,
-					   &eth_spec->dst, 6);
+					   &eth_spec->dst, RTE_ETHER_ADDR_LEN);
 				en |= use_ntuple ?
 					NTUPLE_FLTR_ALLOC_INPUT_EN_DST_MACADDR :
 					EM_FLOW_ALLOC_INPUT_EN_DST_MACADDR;
+				valid_flags |= inner ?
+					BNXT_FLOW_L2_INNER_DST_VALID_FLAG :
+					BNXT_FLOW_L2_DST_VALID_FLAG;
 			}
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->src)) {
 				rte_memcpy(filter->src_macaddr,
-					   &eth_spec->src, 6);
+					   &eth_spec->src, RTE_ETHER_ADDR_LEN);
 				en |= use_ntuple ?
 					NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR :
 					EM_FLOW_ALLOC_INPUT_EN_SRC_MACADDR;
+				valid_flags |= inner ?
+					BNXT_FLOW_L2_INNER_SRC_VALID_FLAG :
+					BNXT_FLOW_L2_SRC_VALID_FLAG;
 			} /*
 			   * else {
 			   *  PMD_DRV_LOG(ERR, "Handle this condition\n");
@@ -669,6 +680,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		item++;
 	}
 	filter->enables = en;
+	filter->valid_flags = valid_flags;
 
 	return 0;
 }
@@ -725,16 +737,44 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,
 	if (memcmp(f0->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN) == 0)
 		return f0;
 
-	/* This flow needs DST MAC which is not same as port/l2 */
-	PMD_DRV_LOG(DEBUG, "Create L2 filter for DST MAC\n");
+	/* Alloc new L2 filter.
+	 * This flow needs MAC filter which does not match port/l2 MAC.
+	 */
 	filter1 = bnxt_get_unused_filter(bp);
 	if (filter1 == NULL)
 		return NULL;
 
-	filter1->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+	filter1->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE;
+	filter1->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+	if (nf->valid_flags & BNXT_FLOW_L2_SRC_VALID_FLAG ||
+	    nf->valid_flags & BNXT_FLOW_L2_DST_VALID_FLAG) {
+		filter1->flags |=
+			HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
+		PMD_DRV_LOG(DEBUG, "Create Outer filter\n");
+	}
+
+	if (nf->valid_flags & BNXT_FLOW_L2_SRC_VALID_FLAG ||
+	    nf->valid_flags & BNXT_FLOW_L2_INNER_SRC_VALID_FLAG) {
+		PMD_DRV_LOG(DEBUG, "Create L2 filter for SRC MAC\n");
+		filter1->flags |=
+			HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_SOURCE_VALID;
+		memcpy(filter1->l2_addr, nf->src_macaddr, RTE_ETHER_ADDR_LEN);
+	} else {
+		PMD_DRV_LOG(DEBUG, "Create L2 filter for DST MAC\n");
+		memcpy(filter1->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN);
+	}
+
+	if (nf->valid_flags & BNXT_FLOW_L2_DST_VALID_FLAG ||
+	    nf->valid_flags & BNXT_FLOW_L2_INNER_DST_VALID_FLAG) {
+		/* Tell the FW where to place the filter in the table. */
+		filter1->pri_hint =
+			HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_BELOW_FILTER;
+		/* This will place the filter in TCAM */
+		filter1->l2_filter_id_hint = (uint64_t)-1;
+	}
+
 	filter1->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
 			L2_FILTER_ALLOC_INPUT_EN_L2_ADDR_MASK;
-	memcpy(filter1->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN);
 	memset(filter1->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
 	rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id,
 				     filter1);
@@ -843,6 +883,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			PMD_DRV_LOG(DEBUG, "Group id is 0\n");
 			vnic_id = act_q->index;
 		}
+		PMD_DRV_LOG(DEBUG, "VNIC found\n");
 
 		vnic = &bp->vnic_info[vnic_id];
 		if (vnic == NULL) {
@@ -917,8 +958,20 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			goto ret;
 		}
 
+		if (!(filter->valid_flags &
+		      ~(BNXT_FLOW_L2_DST_VALID_FLAG |
+			BNXT_FLOW_L2_SRC_VALID_FLAG |
+			BNXT_FLOW_L2_INNER_SRC_VALID_FLAG |
+			BNXT_FLOW_L2_INNER_DST_VALID_FLAG))) {
+			PMD_DRV_LOG(DEBUG, "L2 filter created\n");
+			filter->flags = filter1->flags;
+			filter->enables = filter1->enables;
+			filter->filter_type = HWRM_CFA_L2_FILTER;
+			memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
+			filter->pri_hint = filter1->pri_hint;
+			filter->l2_filter_id_hint = filter1->l2_filter_id_hint;
+		}
 		filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
-		PMD_DRV_LOG(DEBUG, "VNIC found\n");
 		break;
 	case RTE_FLOW_ACTION_TYPE_DROP:
 		vnic0 = &bp->vnic_info[0];
@@ -1009,6 +1062,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 
 		filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
 		break;
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		rte_flow_error_set(error,
+				   ENOTSUP,
+				   RTE_FLOW_ERROR_TYPE_ACTION,
+				   act,
+				   "This action is not supported right now.");
+		rc = -rte_errno;
+		goto ret;
+		//break;
 
 	default:
 		rte_flow_error_set(error,
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index c876ff75c..98a68ec65 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -418,8 +418,6 @@ int bnxt_hwrm_set_l2_filter(struct bnxt *bp,
 	HWRM_PREP(req, CFA_L2_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
 
 	req.flags = rte_cpu_to_le_32(filter->flags);
-	req.flags |=
-	rte_cpu_to_le_32(HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST);
 
 	enables = filter->enables |
 	      HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
@@ -449,6 +447,11 @@ int bnxt_hwrm_set_l2_filter(struct bnxt *bp,
 		req.src_id = rte_cpu_to_le_32(filter->src_id);
 	if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE)
 		req.src_type = filter->src_type;
+	if (filter->pri_hint) {
+		req.pri_hint = filter->pri_hint;
+		req.l2_filter_id_hint =
+			rte_cpu_to_le_64(filter->l2_filter_id_hint);
+	}
 
 	req.enables = rte_cpu_to_le_32(enables);
 
@@ -1019,6 +1022,11 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
 	if (dev_caps_cfg &
 	    HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
 		PMD_DRV_LOG(DEBUG, "FW supports Trusted VFs\n");
+	if (dev_caps_cfg &
+	    HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED) {
+		bp->flags |= BNXT_FLAG_ADV_FLOW_MGMT;
+		PMD_DRV_LOG(DEBUG, "FW supports advanced flow management\n");
+	}
 
 error:
 	HWRM_UNLOCK();
@@ -4858,3 +4866,35 @@ int bnxt_hwrm_fw_reset(struct bnxt *bp)
 
 	return rc;
 }
+
+int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp)
+{
+	struct hwrm_cfa_adv_flow_mgnt_qcaps_output *resp =
+					bp->hwrm_cmd_resp_addr;
+	struct hwrm_cfa_adv_flow_mgnt_qcaps_input req = {0};
+	uint32_t flags = 0;
+	int rc = 0;
+
+	if (!(bp->flags & BNXT_FLAG_ADV_FLOW_MGMT))
+		return rc;
+
+	if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
+		PMD_DRV_LOG(DEBUG,
+			    "Not a PF or trusted VF. Command not supported\n");
+		return 0;
+	}
+
+	HWRM_PREP(req, CFA_ADV_FLOW_MGNT_QCAPS, BNXT_USE_KONG(bp));
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
+
+	HWRM_CHECK_RESULT();
+	flags = rte_le_to_cpu_32(resp->flags);
+	HWRM_UNLOCK();
+
+	if (flags & HWRM_CFA_ADV_FLOW_MGNT_QCAPS_L2_HDR_SRC_FILTER_EN) {
+		bp->flow_flags |= BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN;
+		PMD_DRV_LOG(INFO, "Source L2 header filtering enabled\n");
+	}
+
+	return rc;
+}
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index f3234ae72..47b1e43ac 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -38,6 +38,9 @@ struct bnxt_cp_ring_info;
 #define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC \
 	HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL_STATIC
 
+#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_L2_HDR_SRC_FILTER_EN \
+HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_L2_HEADER_SOURCE_FIELDS_SUPPORTED
+
 #define HWRM_SPEC_CODE_1_8_4		0x10804
 #define HWRM_SPEC_CODE_1_9_0		0x10900
 #define HWRM_SPEC_CODE_1_9_2		0x10902
@@ -209,4 +212,5 @@ int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
 int bnxt_hwrm_fw_reset(struct bnxt *bp);
+int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp);
 #endif
diff --git a/drivers/net/bnxt/bnxt_util.h b/drivers/net/bnxt/bnxt_util.h
index a15b3a1a9..6ded7f657 100644
--- a/drivers/net/bnxt/bnxt_util.h
+++ b/drivers/net/bnxt/bnxt_util.h
@@ -13,4 +13,8 @@
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
 void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
+#ifndef BIT
+#define BIT(a) (1UL << (a))
+#endif /* BIT */
+
 #endif /* _BNXT_UTIL_H_ */
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 05/17] net/bnxt: add support for RSS action
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (3 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 04/17] net/bnxt: add support to create SMAC and inner DMAC filters Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 06/17] net/bnxt: parse priority attribute for flow creation Ajit Khaparde
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru

Add support for RSS action during flow creation.

group id should not be 0 when RSS action is specified. Driver will
return an error for such a flow.

If a group id is used to create a filter with “n” RSS queues, it cannot
be used to create a filter with a different number of RSS queues till
all the flows using that combination are deleted.

While creating a flow if a group id groups a certain Rx queue ids for
RSS, the same group id shall not create a flow with a different group of
Rx queue ids till all the flows belonging to the group ids are deleted.

While creating a flow if a group id groups a certain Rx queue ids for
RSS, the same queue ids shall not be used with a different group id till
all flows created with that group id are deleted.

Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 243 +++++++++++++++++++++++++++++++----
 drivers/net/bnxt/bnxt_vnic.c |   2 +-
 drivers/net/bnxt/bnxt_vnic.h |   1 +
 3 files changed, 219 insertions(+), 27 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 4ba280fff..1328f25bc 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -829,6 +829,60 @@ static int bnxt_vnic_prep(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	return rc;
 }
 
+static int match_vnic_rss_cfg(struct bnxt *bp,
+			      struct bnxt_vnic_info *vnic,
+			      const struct rte_flow_action_rss *rss)
+{
+	unsigned int match = 0, i;
+
+	if (vnic->rx_queue_cnt != rss->queue_num)
+		return -EINVAL;
+
+	for (i = 0; i < rss->queue_num; i++) {
+		if (!bp->rx_queues[rss->queue[i]]->vnic->rx_queue_cnt &&
+		    !bp->rx_queues[rss->queue[i]]->rx_started)
+			return -EINVAL;
+	}
+
+	for (i = 0; i < vnic->rx_queue_cnt; i++) {
+		int j;
+
+		for (j = 0; j < vnic->rx_queue_cnt; j++) {
+			if (bp->grp_info[rss->queue[i]].fw_grp_id ==
+			    vnic->fw_grp_ids[j])
+				match++;
+		}
+	}
+
+	if (match != vnic->rx_queue_cnt) {
+		PMD_DRV_LOG(ERR,
+			    "VNIC queue count %d vs queues matched %d\n",
+			    match, vnic->rx_queue_cnt);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void
+bnxt_update_filter_flags_en(struct bnxt_filter_info *filter,
+			    struct bnxt_filter_info *filter1)
+{
+	if (!(filter->valid_flags &
+	      ~(BNXT_FLOW_L2_DST_VALID_FLAG |
+		BNXT_FLOW_L2_SRC_VALID_FLAG |
+		BNXT_FLOW_L2_INNER_SRC_VALID_FLAG |
+		BNXT_FLOW_L2_INNER_DST_VALID_FLAG))) {
+		filter->flags = filter1->flags;
+		filter->enables = filter1->enables;
+		filter->filter_type = HWRM_CFA_L2_FILTER;
+		memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
+		filter->pri_hint = filter1->pri_hint;
+		filter->l2_filter_id_hint = filter1->l2_filter_id_hint;
+	}
+	filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
+}
+
 static int
 bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			     const struct rte_flow_item pattern[],
@@ -842,12 +896,14 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	struct bnxt *bp = dev->data->dev_private;
 	struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
 	const struct rte_flow_action_queue *act_q;
+	const struct rte_flow_action_rss *rss;
 	const struct rte_flow_action_vf *act_vf;
 	struct bnxt_vnic_info *vnic, *vnic0;
 	struct bnxt_filter_info *filter1;
 	struct bnxt_rx_queue *rxq = NULL;
 	int dflt_vnic, vnic_id;
-	uint32_t vf = 0;
+	unsigned int rss_idx;
+	uint32_t vf = 0, i;
 	int rc;
 
 	rc =
@@ -916,10 +972,13 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) && rxq)
 			goto use_vnic;
 
+		//if (!rxq ||
+		    //bp->vnic_info[0].fw_grp_ids[act_q->index] !=
+		    //INVALID_HW_RING_ID ||
+		    //!rxq->rx_deferred_start) {
 		if (!rxq ||
 		    bp->vnic_info[0].fw_grp_ids[act_q->index] !=
-		    INVALID_HW_RING_ID ||
-		    !rxq->rx_deferred_start) {
+		    INVALID_HW_RING_ID) {
 			PMD_DRV_LOG(ERR,
 				    "Queue invalid or used with other VNIC\n");
 			rte_flow_error_set(error,
@@ -931,8 +990,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			goto ret;
 		}
 
-use_vnic:
 		rxq->vnic = vnic;
+		rxq->rx_started = 1;
 		vnic->rx_queue_cnt++;
 		vnic->start_grp_id = act_q->index;
 		vnic->end_grp_id = act_q->index;
@@ -948,6 +1007,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			    "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
 			    act_q->index, vnic, vnic->fw_grp_ids);
 
+use_vnic:
 		vnic->ff_pool_idx = vnic_id;
 		PMD_DRV_LOG(DEBUG,
 			    "Setting vnic ff_idx %d\n", vnic->ff_pool_idx);
@@ -958,20 +1018,8 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 			goto ret;
 		}
 
-		if (!(filter->valid_flags &
-		      ~(BNXT_FLOW_L2_DST_VALID_FLAG |
-			BNXT_FLOW_L2_SRC_VALID_FLAG |
-			BNXT_FLOW_L2_INNER_SRC_VALID_FLAG |
-			BNXT_FLOW_L2_INNER_DST_VALID_FLAG))) {
-			PMD_DRV_LOG(DEBUG, "L2 filter created\n");
-			filter->flags = filter1->flags;
-			filter->enables = filter1->enables;
-			filter->filter_type = HWRM_CFA_L2_FILTER;
-			memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
-			filter->pri_hint = filter1->pri_hint;
-			filter->l2_filter_id_hint = filter1->l2_filter_id_hint;
-		}
-		filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
+		PMD_DRV_LOG(DEBUG, "L2 filter created\n");
+		bnxt_update_filter_flags_en(filter, filter1);
 		break;
 	case RTE_FLOW_ACTION_TYPE_DROP:
 		vnic0 = &bp->vnic_info[0];
@@ -1063,15 +1111,158 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
 		break;
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		rte_flow_error_set(error,
-				   ENOTSUP,
-				   RTE_FLOW_ERROR_TYPE_ACTION,
-				   act,
-				   "This action is not supported right now.");
-		rc = -rte_errno;
-		goto ret;
-		//break;
+		rss = (const struct rte_flow_action_rss *)act->conf;
+
+		vnic_id = attr->group;
+		if (!vnic_id) {
+			PMD_DRV_LOG(ERR, "Group id cannot be 0\n");
+			rte_flow_error_set(error,
+					   EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ATTR,
+					   NULL,
+					   "Group id cannot be 0");
+			rc = -rte_errno;
+			goto ret;
+		}
+
+		vnic = &bp->vnic_info[vnic_id];
+		if (vnic == NULL) {
+			rte_flow_error_set(error,
+					   EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "No matching VNIC for RSS group.");
+			rc = -rte_errno;
+			goto ret;
+		}
+		PMD_DRV_LOG(DEBUG, "VNIC found\n");
+
+		/* Check if requested RSS config matches RSS config of VNIC
+		 * only if it is not a fresh VNIC configuration.
+		 * Otherwise the existing VNIC configuration can be used.
+		 */
+		if (vnic->rx_queue_cnt) {
+			rc = match_vnic_rss_cfg(bp, vnic, rss);
+			if (rc) {
+				PMD_DRV_LOG(ERR,
+					    "VNIC and RSS config mismatch\n");
+				rte_flow_error_set(error,
+						   EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   act,
+						   "VNIC and RSS cfg mismatch");
+				rc = -rte_errno;
+				goto ret;
+			}
+			goto vnic_found;
+		}
+
+		for (i = 0; i < rss->queue_num; i++) {
+			PMD_DRV_LOG(DEBUG, "RSS action Queue %d\n",
+				    rss->queue[i]);
+
+			if (!rss->queue[i] ||
+			    rss->queue[i] >= bp->rx_nr_rings ||
+			    !bp->rx_queues[rss->queue[i]]) {
+				rte_flow_error_set(error,
+						   EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   act,
+						   "Invalid queue ID for RSS");
+				rc = -rte_errno;
+				goto ret;
+			}
+			rxq = bp->rx_queues[rss->queue[i]];
 
+			//if (bp->vnic_info[0].fw_grp_ids[rss->queue[i]] !=
+			    //INVALID_HW_RING_ID ||
+			    //!rxq->rx_deferred_start) {
+			if (bp->vnic_info[0].fw_grp_ids[rss->queue[i]] !=
+			    INVALID_HW_RING_ID) {
+				PMD_DRV_LOG(ERR,
+					    "queue active with other VNIC\n");
+				rte_flow_error_set(error,
+						   EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   act,
+						   "Invalid queue ID for RSS");
+				rc = -rte_errno;
+				goto ret;
+			}
+
+			rxq->vnic = vnic;
+			rxq->rx_started = 1;
+			vnic->rx_queue_cnt++;
+		}
+
+		vnic->start_grp_id = rss->queue[0];
+		vnic->end_grp_id = rss->queue[rss->queue_num - 1];
+		vnic->func_default = 0;	//This is not a default VNIC.
+
+		rc = bnxt_vnic_prep(bp, vnic);
+		if (rc)
+			goto ret;
+
+		PMD_DRV_LOG(DEBUG,
+			    "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
+			    vnic_id, vnic, vnic->fw_grp_ids);
+
+		vnic->ff_pool_idx = vnic_id;
+		PMD_DRV_LOG(DEBUG,
+			    "Setting vnic ff_pool_idx %d\n", vnic->ff_pool_idx);
+
+		/* This can be done only after vnic_grp_alloc is done. */
+		for (i = 0; i < vnic->rx_queue_cnt; i++) {
+			vnic->fw_grp_ids[i] =
+				bp->grp_info[rss->queue[i]].fw_grp_id;
+			/* Make sure vnic0 does not use these rings. */
+			bp->vnic_info[0].fw_grp_ids[rss->queue[i]] =
+				INVALID_HW_RING_ID;
+		}
+
+		for (rss_idx = 0; rss_idx < HW_HASH_INDEX_SIZE; ) {
+			for (i = 0; i < vnic->rx_queue_cnt; i++)
+				vnic->rss_table[rss_idx++] =
+					vnic->fw_grp_ids[i];
+		}
+
+		/* Configure RSS only if the queue count is > 1 */
+		if (vnic->rx_queue_cnt > 1) {
+			vnic->hash_type =
+				bnxt_rte_to_hwrm_hash_types(rss->types);
+
+			if (!rss->key_len) {
+				/* If hash key has not been specified,
+				 * use random hash key.
+				 */
+				prandom_bytes(vnic->rss_hash_key,
+					      HW_HASH_KEY_SIZE);
+			} else {
+				if (rss->key_len > HW_HASH_KEY_SIZE)
+					memcpy(vnic->rss_hash_key,
+					       rss->key,
+					       HW_HASH_KEY_SIZE);
+				else
+					memcpy(vnic->rss_hash_key,
+					       rss->key,
+					       rss->key_len);
+			}
+			bnxt_hwrm_vnic_rss_cfg(bp, vnic);
+		} else {
+			PMD_DRV_LOG(DEBUG, "No RSS config required\n");
+		}
+
+vnic_found:
+		filter->dst_id = vnic->fw_vnic_id;
+		filter1 = bnxt_get_l2_filter(bp, filter, vnic);
+		if (filter1 == NULL) {
+			rc = -ENOSPC;
+			goto ret;
+		}
+
+		PMD_DRV_LOG(DEBUG, "L2 filter created\n");
+		bnxt_update_filter_flags_en(filter, filter1);
+		break;
 	default:
 		rte_flow_error_set(error,
 				   EINVAL,
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 4f3f9b359..2f0ed1026 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -16,7 +16,7 @@
  * VNIC Functions
  */
 
-static void prandom_bytes(void *dest_ptr, size_t len)
+void prandom_bytes(void *dest_ptr, size_t len)
 {
 	char *dest = (char *)dest_ptr;
 	uint64_t rb;
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index ec3a3ff51..de34b21eb 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -67,5 +67,6 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp);
 void bnxt_free_vnic_mem(struct bnxt *bp);
 int bnxt_alloc_vnic_mem(struct bnxt *bp);
 int bnxt_vnic_grp_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+void prandom_bytes(void *dest_ptr, size_t len);
 uint16_t bnxt_rte_to_hwrm_hash_types(uint64_t rte_type);
 #endif
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 06/17] net/bnxt: parse priority attribute for flow creation
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (4 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 05/17] net/bnxt: add support for RSS action Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 07/17] net/bnxt: delete and flush L2 filters cleanly Ajit Khaparde
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Lance Richardson

Parse priority attribute during flow creation.
This information will be used to give a hint to the FW to
place the flow rule accordingly in the CFA tables.

Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_filter.h |  1 +
 drivers/net/bnxt/bnxt_flow.c   | 25 +++++++++++--------------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h
index 52d3582ba..bcb9d6031 100644
--- a/drivers/net/bnxt/bnxt_filter.h
+++ b/drivers/net/bnxt/bnxt_filter.h
@@ -66,6 +66,7 @@ struct bnxt_filter_info {
 	uint16_t                ip_protocol;
 	uint16_t                ip_addr_type;
 	uint16_t                ethertype;
+	uint32_t		priority;
 };
 
 struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp);
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 1328f25bc..2d107a892 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -225,6 +225,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 				valid_flags |= inner ?
 					BNXT_FLOW_L2_INNER_DST_VALID_FLAG :
 					BNXT_FLOW_L2_DST_VALID_FLAG;
+				filter->priority = attr->priority;
+				PMD_DRV_LOG(DEBUG,
+					    "Creating a priority flow\n");
 			}
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->src)) {
@@ -710,15 +713,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
-		rte_flow_error_set(error,
-				   EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				   attr,
-				   "No support for priority.");
-		return -rte_errno;
-	}
 	return 0;
 }
 
@@ -764,13 +758,16 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,
 		memcpy(filter1->l2_addr, nf->dst_macaddr, RTE_ETHER_ADDR_LEN);
 	}
 
-	if (nf->valid_flags & BNXT_FLOW_L2_DST_VALID_FLAG ||
-	    nf->valid_flags & BNXT_FLOW_L2_INNER_DST_VALID_FLAG) {
+	if (nf->priority &&
+	    (nf->valid_flags & BNXT_FLOW_L2_DST_VALID_FLAG ||
+	     nf->valid_flags & BNXT_FLOW_L2_INNER_DST_VALID_FLAG)) {
 		/* Tell the FW where to place the filter in the table. */
-		filter1->pri_hint =
+		if (nf->priority > 65535) {
+			filter1->pri_hint =
 			HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_BELOW_FILTER;
-		/* This will place the filter in TCAM */
-		filter1->l2_filter_id_hint = (uint64_t)-1;
+			/* This will place the filter in TCAM */
+			filter1->l2_filter_id_hint = (uint64_t)-1;
+		}
 	}
 
 	filter1->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 07/17] net/bnxt: delete and flush L2 filters cleanly
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (5 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 06/17] net/bnxt: parse priority attribute for flow creation Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 08/17] net/bnxt: cleanup vnic after flow validate Ajit Khaparde
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru

Once the last filter associated with a VNIC is deleted when using
RSS action or the Queue action free the VNIC. Also free the RSS
context if the VNIC is using it.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt_filter.c | 18 +++++--------
 drivers/net/bnxt/bnxt_flow.c   | 39 +++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_hwrm.c   | 47 +++++++++++++++++++---------------
 3 files changed, 72 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 0aed29fb0..30ee6344d 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -117,6 +117,13 @@ void bnxt_free_filter_mem(struct bnxt *bp)
 	max_filters = bp->max_l2_ctx;
 	for (i = 0; i < max_filters; i++) {
 		filter = &bp->filter_info[i];
+		if (filter->fw_ntuple_filter_id != ((uint64_t)-1) &&
+		    filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
+			/* Call HWRM to try to free filter again */
+			rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
+		}
+		filter->fw_ntuple_filter_id = UINT64_MAX;
+
 		if (filter->fw_l2_filter_id != ((uint64_t)-1) &&
 		    filter->filter_type == HWRM_CFA_L2_FILTER) {
 			PMD_DRV_LOG(ERR, "L2 filter is not free\n");
@@ -129,17 +136,6 @@ void bnxt_free_filter_mem(struct bnxt *bp)
 		}
 		filter->fw_l2_filter_id = UINT64_MAX;
 
-		if (filter->fw_ntuple_filter_id != ((uint64_t)-1) &&
-		    filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
-			PMD_DRV_LOG(ERR, "NTUPLE filter is not free\n");
-			/* Call HWRM to try to free filter again */
-			rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
-			if (rc)
-				PMD_DRV_LOG(ERR,
-					    "Cannot free NTUPLE filter: %d\n",
-					    rc);
-		}
-		filter->fw_ntuple_filter_id = UINT64_MAX;
 	}
 	STAILQ_INIT(&bp->free_filter_list);
 
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 2d107a892..496edd7ac 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1631,6 +1631,7 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 	ret = bnxt_match_filter(bp, filter);
 	if (ret == 0)
 		PMD_DRV_LOG(ERR, "Could not find matching flow\n");
+
 	if (filter->filter_type == HWRM_CFA_EM_FILTER)
 		ret = bnxt_hwrm_clear_em_filter(bp, filter);
 	if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
@@ -1640,9 +1641,40 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 
 done:
 	if (!ret) {
+		STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next);
 		bnxt_free_filter(bp, filter);
 		STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next);
 		rte_free(flow);
+
+		/* If this was the last flow associated with this vnic,
+		 * switch the queue back to RSS pool.
+		 */
+		if (vnic && STAILQ_EMPTY(&vnic->flow_list)) {
+			rte_free(vnic->fw_grp_ids);
+			if (vnic->rx_queue_cnt > 1) {
+				if (BNXT_CHIP_THOR(bp)) {
+					int j;
+
+					for (j = 0; j < vnic->num_lb_ctxts;
+					     j++) {
+						bnxt_hwrm_vnic_ctx_free(bp,
+                                                                        vnic,
+                                                                        vnic->fw_grp_ids[j]);
+						vnic->fw_grp_ids[j] =
+							INVALID_HW_RING_ID;
+					}
+					vnic->num_lb_ctxts = 0;
+				} else {
+					bnxt_hwrm_vnic_ctx_free(bp,
+								vnic,
+								vnic->rss_rule);
+					vnic->rss_rule = INVALID_HW_RING_ID;
+				}
+			}
+			bnxt_hwrm_vnic_free(bp, vnic);
+			vnic->rx_queue_cnt = 0;
+			bp->nr_vnics--;
+		}
 	} else {
 		rte_flow_error_set(error, -ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -1661,8 +1693,11 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 	unsigned int i;
 	int ret = 0;
 
-	for (i = 0; i < bp->nr_vnics; i++) {
+	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
+		if (vnic->fw_vnic_id == INVALID_VNIC_ID)
+			continue;
+
 		STAILQ_FOREACH(flow, &vnic->flow_list, next) {
 			struct bnxt_filter_info *filter = flow->filter;
 
@@ -1683,6 +1718,8 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 				ret = bnxt_hwrm_clear_em_filter(bp, filter);
 			if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
 				ret = bnxt_hwrm_clear_ntuple_filter(bp, filter);
+			else if (!i)
+				ret = bnxt_hwrm_clear_l2_filter(bp, filter);
 
 			if (ret) {
 				rte_flow_error_set
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 98a68ec65..26559dce1 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -2410,13 +2410,12 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
 	 * Cleanup VNICs in reverse order, to make sure the L2 filter
 	 * from vnic0 is last to be cleaned up.
 	 */
-	for (i = bp->nr_vnics - 1; i >= 0; i--) {
+	for (i = bp->max_vnics - 1; i >= 0; i--) {
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
-		if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
-			PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
-			return;
-		}
+		// If the VNIC ID is invalid we are not currently using the VNIC
+		if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+			continue;
 
 		bnxt_clear_hwrm_vnic_flows(bp, vnic);
 
@@ -4293,23 +4292,31 @@ int bnxt_vnic_rss_configure(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	if (BNXT_CHIP_THOR(bp))
 		return bnxt_vnic_rss_configure_thor(bp, vnic);
 
-	/*
-	 * Fill the RSS hash & redirection table with
-	 * ring group ids for all VNICs
-	 */
-	for (rss_idx = 0, fw_idx = 0; rss_idx < HW_HASH_INDEX_SIZE;
-		rss_idx++, fw_idx++) {
-		for (i = 0; i < bp->rx_cp_nr_rings; i++) {
-			fw_idx %= bp->rx_cp_nr_rings;
-			if (vnic->fw_grp_ids[fw_idx] != INVALID_HW_RING_ID)
-				break;
-			fw_idx++;
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+		return 0;
+
+	if (vnic->rss_table && vnic->hash_type) {
+		/*
+		 * Fill the RSS hash & redirection table with
+		 * ring group ids for all VNICs
+		 */
+		for (rss_idx = 0, fw_idx = 0; rss_idx < HW_HASH_INDEX_SIZE;
+			rss_idx++, fw_idx++) {
+			for (i = 0; i < bp->rx_cp_nr_rings; i++) {
+				fw_idx %= bp->rx_cp_nr_rings;
+				if (vnic->fw_grp_ids[fw_idx] !=
+				    INVALID_HW_RING_ID)
+					break;
+				fw_idx++;
+			}
+			if (i == bp->rx_cp_nr_rings)
+				return 0;
+			vnic->rss_table[rss_idx] = vnic->fw_grp_ids[fw_idx];
 		}
-		if (i == bp->rx_cp_nr_rings)
-			return 0;
-		vnic->rss_table[rss_idx] = vnic->fw_grp_ids[fw_idx];
+		return bnxt_hwrm_vnic_rss_cfg(bp, vnic);
 	}
-	return bnxt_hwrm_vnic_rss_cfg(bp, vnic);
+
+	return 0;
 }
 
 static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal,
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 08/17] net/bnxt: cleanup vnic after flow validate
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (6 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 07/17] net/bnxt: delete and flush L2 filters cleanly Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 09/17] net/bnxt: allow only unicast MAC address filter creation Ajit Khaparde
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru

When an application issues flow validate, we free the temporary
filter that is created. But the vnic is not freed up. This can
potentially interfere with subsequent flow creation. So free the vnic.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 76 +++++++++++++++++++++---------------
 drivers/net/bnxt/bnxt_hwrm.c | 41 ++++++++++++-------
 drivers/net/bnxt/bnxt_hwrm.h |  3 +-
 3 files changed, 73 insertions(+), 47 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 496edd7ac..aed822ee3 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1289,6 +1289,25 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	return rc;
 }
 
+static
+struct bnxt_vnic_info *find_matching_vnic(struct bnxt *bp,
+					  struct bnxt_filter_info *filter)
+{
+	struct bnxt_vnic_info *vnic = NULL;
+	unsigned int i;
+
+	for (i = 0; i < bp->max_vnics; i++) {
+		vnic = &bp->vnic_info[i];
+		if (vnic->fw_vnic_id != INVALID_VNIC_ID &&
+		    filter->dst_id == vnic->fw_vnic_id) {
+			PMD_DRV_LOG(DEBUG, "Found matching VNIC Id %d\n",
+				    vnic->ff_pool_idx);
+			return vnic;
+		}
+	}
+	return NULL;
+}
+
 static int
 bnxt_flow_validate(struct rte_eth_dev *dev,
 		   const struct rte_flow_attr *attr,
@@ -1297,6 +1316,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
 		   struct rte_flow_error *error)
 {
 	struct bnxt *bp = dev->data->dev_private;
+	struct bnxt_vnic_info *vnic = NULL;
 	struct bnxt_filter_info *filter;
 	int ret = 0;
 
@@ -1312,6 +1332,26 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
 
 	ret = bnxt_validate_and_parse_flow(dev, pattern, actions, attr,
 					   error, filter);
+
+	vnic = find_matching_vnic(bp, filter);
+	if (vnic) {
+		if (STAILQ_EMPTY(&vnic->filter)) {
+			rte_free(vnic->fw_grp_ids);
+			bnxt_hwrm_vnic_ctx_free(bp, vnic);
+			bnxt_hwrm_vnic_free(bp, vnic);
+			vnic->rx_queue_cnt = 0;
+			bp->nr_vnics--;
+			PMD_DRV_LOG(DEBUG, "Free VNIC\n");
+		}
+	}
+
+	if (filter->filter_type == HWRM_CFA_EM_FILTER)
+		bnxt_hwrm_clear_em_filter(bp, filter);
+	else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
+		bnxt_hwrm_clear_ntuple_filter(bp, filter);
+	else
+		bnxt_hwrm_clear_l2_filter(bp, filter);
+
 	/* No need to hold on to this filter if we are just validating flow */
 	filter->fw_l2_filter_id = UINT64_MAX;
 	bnxt_free_filter(bp, filter);
@@ -1326,7 +1366,7 @@ bnxt_match_filter(struct bnxt *bp, struct bnxt_filter_info *nf)
 	struct rte_flow *flow;
 	int i;
 
-	for (i = bp->max_vnics; i >= 0; i--) {
+	for (i = bp->max_vnics - 1; i >= 0; i--) {
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
 		if (vnic->fw_vnic_id == INVALID_VNIC_ID)
@@ -1407,7 +1447,6 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 	struct bnxt_filter_info *filter;
 	bool update_flow = false;
 	struct rte_flow *flow;
-	unsigned int i;
 	int ret = 0;
 	uint32_t tun_type;
 
@@ -1501,15 +1540,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 		ret = bnxt_hwrm_set_ntuple_filter(bp, filter->dst_id, filter);
 	}
 
-	for (i = 0; i < bp->max_vnics; i++) {
-		vnic = &bp->vnic_info[i];
-		if (vnic->fw_vnic_id != INVALID_VNIC_ID &&
-		    filter->dst_id == vnic->fw_vnic_id) {
-			PMD_DRV_LOG(ERR, "Found matching VNIC Id %d\n",
-				    vnic->ff_pool_idx);
-			break;
-		}
-	}
+	vnic = find_matching_vnic(bp, filter);
 done:
 	if (!ret) {
 		flow->filter = filter;
@@ -1651,26 +1682,9 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 		 */
 		if (vnic && STAILQ_EMPTY(&vnic->flow_list)) {
 			rte_free(vnic->fw_grp_ids);
-			if (vnic->rx_queue_cnt > 1) {
-				if (BNXT_CHIP_THOR(bp)) {
-					int j;
-
-					for (j = 0; j < vnic->num_lb_ctxts;
-					     j++) {
-						bnxt_hwrm_vnic_ctx_free(bp,
-                                                                        vnic,
-                                                                        vnic->fw_grp_ids[j]);
-						vnic->fw_grp_ids[j] =
-							INVALID_HW_RING_ID;
-					}
-					vnic->num_lb_ctxts = 0;
-				} else {
-					bnxt_hwrm_vnic_ctx_free(bp,
-								vnic,
-								vnic->rss_rule);
-					vnic->rss_rule = INVALID_HW_RING_ID;
-				}
-			}
+			if (vnic->rx_queue_cnt > 1)
+				bnxt_hwrm_vnic_ctx_free(bp, vnic);
+
 			bnxt_hwrm_vnic_free(bp, vnic);
 			vnic->rx_queue_cnt = 0;
 			bp->nr_vnics--;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 26559dce1..a033e2d1e 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1766,8 +1766,9 @@ int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp,
 	return rc;
 }
 
-int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp,
-			    struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
+static
+int _bnxt_hwrm_vnic_ctx_free(struct bnxt *bp,
+			     struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
 {
 	int rc = 0;
 	struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 };
@@ -1790,6 +1791,28 @@ int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp,
 	return rc;
 }
 
+int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+	int rc = 0;
+
+	if (BNXT_CHIP_THOR(bp)) {
+		int j;
+
+		for (j = 0; j < vnic->num_lb_ctxts; j++) {
+			rc = _bnxt_hwrm_vnic_ctx_free(bp,
+						      vnic,
+						      vnic->fw_grp_ids[j]);
+			vnic->fw_grp_ids[j] = INVALID_HW_RING_ID;
+		}
+		vnic->num_lb_ctxts = 0;
+	} else {
+		rc = _bnxt_hwrm_vnic_ctx_free(bp, vnic, vnic->rss_rule);
+		vnic->rss_rule = INVALID_HW_RING_ID;
+	}
+
+	return rc;
+}
+
 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
 	int rc = 0;
@@ -2401,7 +2424,7 @@ void bnxt_free_tunnel_ports(struct bnxt *bp)
 
 void bnxt_free_all_hwrm_resources(struct bnxt *bp)
 {
-	int i, j;
+	int i;
 
 	if (bp->vnic_info == NULL)
 		return;
@@ -2421,17 +2444,7 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
 
 		bnxt_clear_hwrm_vnic_filters(bp, vnic);
 
-		if (BNXT_CHIP_THOR(bp)) {
-			for (j = 0; j < vnic->num_lb_ctxts; j++) {
-				bnxt_hwrm_vnic_ctx_free(bp, vnic,
-							vnic->fw_grp_ids[j]);
-				vnic->fw_grp_ids[j] = INVALID_HW_RING_ID;
-			}
-			vnic->num_lb_ctxts = 0;
-		} else {
-			bnxt_hwrm_vnic_ctx_free(bp, vnic, vnic->rss_rule);
-			vnic->rss_rule = INVALID_HW_RING_ID;
-		}
+		bnxt_hwrm_vnic_ctx_free(bp, vnic);
 
 		bnxt_hwrm_vnic_tpa_cfg(bp, vnic, false);
 
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 47b1e43ac..9fa52be72 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -113,8 +113,7 @@ int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
 int bnxt_hwrm_vnic_qcaps(struct bnxt *bp);
 int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic,
 			     uint16_t ctx_idx);
-int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic,
-			    uint16_t ctx_idx);
+int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
 			   struct bnxt_vnic_info *vnic);
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 09/17] net/bnxt: allow only unicast MAC address filter creation
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (7 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 08/17] net/bnxt: cleanup vnic after flow validate Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 10/17] net/bnxt: properly handle ring cleanup in case of error Ajit Khaparde
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Santoshkumar Karanappa Rastapur

Check if the application is trying to create filters using
broadcast and multicast MAC address and reject it.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index aed822ee3..578081890 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -217,6 +217,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->dst)) {
+				if (!rte_is_unicast_ether_addr(&eth_spec->dst)) {
+					rte_flow_error_set(error,
+							   EINVAL,
+							   RTE_FLOW_ERROR_TYPE_ITEM,
+							   item,
+							   "DMAC is invalid");
+					return -rte_errno;
+				}
 				rte_memcpy(filter->dst_macaddr,
 					   &eth_spec->dst, RTE_ETHER_ADDR_LEN);
 				en |= use_ntuple ?
@@ -231,6 +239,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->src)) {
+				if (!rte_is_unicast_ether_addr(&eth_spec->src)) {
+					rte_flow_error_set(error,
+							   EINVAL,
+							   RTE_FLOW_ERROR_TYPE_ITEM,
+							   item,
+							   "SMAC is invalid");
+					return -rte_errno;
+				}
 				rte_memcpy(filter->src_macaddr,
 					   &eth_spec->src, RTE_ETHER_ADDR_LEN);
 				en |= use_ntuple ?
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 10/17] net/bnxt: properly handle ring cleanup in case of error
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (8 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 09/17] net/bnxt: allow only unicast MAC address filter creation Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 11/17] net/bnxt: check device is started before flow creation Ajit Khaparde
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru, Kalesh Anakkur Purayil

From: Rahul Gupta <rahul.gupta@broadcom.com>

Initialize all rings to INVALID_HW_RING_ID.
This can be used to determine the rings to free if allocation fails.

Signed-off-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ring.c | 37 ++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 119a6919f..f6e81d308 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -637,6 +637,42 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index)
 	return rc;
 }
 
+/* Initialise all rings to -1, its used to free rings later if allocation
+ * of few rings fails.
+ */
+static void bnxt_init_all_rings(struct bnxt *bp)
+{
+	unsigned int i = 0;
+	struct bnxt_rx_queue *rxq;
+	struct bnxt_ring *cp_ring;
+	struct bnxt_ring *ring;
+	struct bnxt_rx_ring_info *rxr;
+	struct bnxt_tx_queue *txq;
+
+	for (i = 0; i < bp->rx_cp_nr_rings; i++) {
+		rxq = bp->rx_queues[i];
+		/* Rx-compl */
+		cp_ring = rxq->cp_ring->cp_ring_struct;
+		cp_ring->fw_ring_id = INVALID_HW_RING_ID;
+		/* Rx-Reg */
+		rxr = rxq->rx_ring;
+		ring = rxr->rx_ring_struct;
+		ring->fw_ring_id = INVALID_HW_RING_ID;
+		/* Rx-AGG */
+		ring = rxr->ag_ring_struct;
+		ring->fw_ring_id = INVALID_HW_RING_ID;
+	}
+	for (i = 0; i < bp->tx_cp_nr_rings; i++) {
+		txq = bp->tx_queues[i];
+		/* Tx cmpl */
+		cp_ring = txq->cp_ring->cp_ring_struct;
+		cp_ring->fw_ring_id = INVALID_HW_RING_ID;
+		/*Tx Ring */
+		ring = txq->tx_ring->tx_ring_struct;
+		ring->fw_ring_id = INVALID_HW_RING_ID;
+	}
+}
+
 /* ring_grp usage:
  * [0] = default completion ring
  * [1 -> +rx_cp_nr_rings] = rx_cp, rx rings
@@ -650,6 +686,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 	int rc = 0;
 
 	bnxt_init_dflt_coal(&coal);
+	bnxt_init_all_rings(bp);
 
 	for (i = 0; i < bp->rx_cp_nr_rings; i++) {
 		struct bnxt_rx_queue *rxq = bp->rx_queues[i];
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 11/17] net/bnxt: check device is started before flow creation
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (9 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 10/17] net/bnxt: properly handle ring cleanup in case of error Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 12/17] net/bnxt: check for invalid VNIC ID in vnic tpa cfg Ajit Khaparde
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Stephen Hemminger, Somnath Kotur, Venkat Duvvuru

Check device is started before flow creation.
Since the vnic data structures aren't created until device start,
the driver dereferences NULL vnic if flow creation is attempted before
device is started,

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 578081890..71a5266ce 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1466,6 +1466,15 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 	int ret = 0;
 	uint32_t tun_type;
 
+	if (!dev->data->dev_started) {
+		rte_flow_error_set(error,
+				   EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "Device must be started");
+		return NULL;
+	}
+
 	flow = rte_zmalloc("bnxt_flow", sizeof(struct rte_flow), 0);
 	if (!flow) {
 		rte_flow_error_set(error, ENOMEM,
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 12/17] net/bnxt: check for invalid VNIC ID in vnic tpa cfg
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (10 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 11/17] net/bnxt: check device is started before flow creation Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 13/17] net/bnxt: handle flow flush handling Ajit Khaparde
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Somnath Kotur, Rahul Gupta, Kalesh Anakkur Purayil

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

If driver init/probe fails as part of cleanup/rollback, we may end
up invoking this HWRM cmd even on an invalid vNIC which will unecessarily
log an error message as the cmd will fail.
Check for invalid ID before issuing the HWRM cmd

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index a033e2d1e..227d893da 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1958,6 +1958,11 @@ int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,
 		return -ENOTSUP;
 	}
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+		PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
+		return 0;
+	}
+
 	HWRM_PREP(req, VNIC_TPA_CFG, BNXT_USE_CHIMP_MB);
 
 	if (enable) {
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 13/17] net/bnxt: handle flow flush handling
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (11 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 12/17] net/bnxt: check for invalid VNIC ID in vnic tpa cfg Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 14/17] net/bnxt: validate RSS hash key length Ajit Khaparde
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru, Kalesh Anakkur Purayil

We are not freeing all the flows when a flow_flush is called.
Iterate through all the flows belonging to all the VNICs in use and
free the filters.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 56 ++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 71a5266ce..9d943cd14 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -907,7 +907,6 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	const struct rte_flow_action *act =
 		bnxt_flow_non_void_action(actions);
 	struct bnxt *bp = dev->data->dev_private;
-	struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
 	const struct rte_flow_action_queue *act_q;
 	const struct rte_flow_action_rss *rss;
 	const struct rte_flow_action_vf *act_vf;
@@ -982,9 +981,6 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 
 		rxq = bp->rx_queues[act_q->index];
 
-		if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) && rxq)
-			goto use_vnic;
-
 		//if (!rxq ||
 		    //bp->vnic_info[0].fw_grp_ids[act_q->index] !=
 		    //INVALID_HW_RING_ID ||
@@ -1567,25 +1563,6 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 
 	vnic = find_matching_vnic(bp, filter);
 done:
-	if (!ret) {
-		flow->filter = filter;
-		flow->vnic = vnic;
-		/* VNIC is set only in case of queue or RSS action */
-		if (vnic) {
-			/*
-			 * RxQ0 is not used for flow filters.
-			 */
-
-			if (update_flow) {
-				ret = -EXDEV;
-				goto free_flow;
-			}
-			STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
-		}
-		PMD_DRV_LOG(ERR, "Successfully created flow.\n");
-		STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
-		return flow;
-	}
 	if (!ret) {
 		flow->filter = filter;
 		flow->vnic = vnic;
@@ -1593,10 +1570,13 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 			ret = -EXDEV;
 			goto free_flow;
 		}
+
+		STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
 		PMD_DRV_LOG(ERR, "Successfully created flow.\n");
 		STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
 		return flow;
 	}
+
 free_filter:
 	bnxt_free_filter(bp, filter);
 free_flow:
@@ -1727,6 +1707,7 @@ static int
 bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 {
 	struct bnxt *bp = dev->data->dev_private;
+	struct bnxt_filter_info *filter = NULL;
 	struct bnxt_vnic_info *vnic;
 	struct rte_flow *flow;
 	unsigned int i;
@@ -1734,11 +1715,12 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 
 	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
-		if (vnic->fw_vnic_id == INVALID_VNIC_ID)
+		if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID)
 			continue;
 
-		STAILQ_FOREACH(flow, &vnic->flow_list, next) {
-			struct bnxt_filter_info *filter = flow->filter;
+		while (!STAILQ_EMPTY(&vnic->flow_list)) {
+			flow = STAILQ_FIRST(&vnic->flow_list);
+			filter = flow->filter;
 
 			if (filter->filter_type ==
 			    HWRM_CFA_TUNNEL_REDIRECT_FILTER &&
@@ -1757,7 +1739,7 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 				ret = bnxt_hwrm_clear_em_filter(bp, filter);
 			if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
 				ret = bnxt_hwrm_clear_ntuple_filter(bp, filter);
-			else if (!i)
+			else if (i)
 				ret = bnxt_hwrm_clear_l2_filter(bp, filter);
 
 			if (ret) {
@@ -1770,10 +1752,28 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 				return -rte_errno;
 			}
 done:
-			bnxt_free_filter(bp, filter);
 			STAILQ_REMOVE(&vnic->flow_list, flow,
 				      rte_flow, next);
+
+			STAILQ_REMOVE(&vnic->filter,
+				      filter,
+				      bnxt_filter_info,
+				      next);
+			bnxt_free_filter(bp, filter);
+
 			rte_free(flow);
+
+			/* If this was the last flow associated with this vnic,
+			 * switch the queue back to RSS pool.
+			 */
+			if (STAILQ_EMPTY(&vnic->flow_list)) {
+				rte_free(vnic->fw_grp_ids);
+				if (vnic->rx_queue_cnt > 1)
+					bnxt_hwrm_vnic_ctx_free(bp, vnic);
+				bnxt_hwrm_vnic_free(bp, vnic);
+				vnic->rx_queue_cnt = 0;
+				bp->nr_vnics--;
+			}
 		}
 	}
 
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 14/17] net/bnxt: validate RSS hash key length
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (12 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 13/17] net/bnxt: handle flow flush handling Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 15/17] net/bnxt: handle cleanup if flow creation fails Ajit Khaparde
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev
  Cc: ferruh.yigit, Venkat Duvvuru, Somnath Kotur, Rahul Gupta,
	Santoshkumar Karanappa Rastapur, Kalesh Anakkur Purayil

From: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>

In bnxt_rss_hash_update_op, driver is proceeding with
bnxt_hwrm_vnic_rss_cfg even though RSS hashkey length is invalid.

This patch fixes the problem by returning -EINVAL when RSS hashkey length
is invalid.

Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index b72466467..5ef2ee0c4 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1308,14 +1308,20 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
 	vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_conf->rss_hf);
 
 	/*
-	 * Use the supplied key if the key length is
-	 * acceptable and the rss_key is not NULL
+	 * If hashkey is not specified, use the previously configured
+	 * hashkey
 	 */
-	if (rss_conf->rss_key && rss_conf->rss_key_len <= HW_HASH_KEY_SIZE)
-		memcpy(vnic->rss_hash_key,
-		       rss_conf->rss_key,
-		       rss_conf->rss_key_len);
+	if (!rss_conf->rss_key)
+		goto rss_config;
 
+	if (rss_conf->rss_key_len != HW_HASH_KEY_SIZE) {
+		PMD_DRV_LOG(ERR,
+			    "Invalid hashkey length, should be 16 bytes\n");
+		return -EINVAL;
+	}
+	memcpy(vnic->rss_hash_key, rss_conf->rss_key, rss_conf->rss_key_len);
+
+rss_config:
 	bnxt_hwrm_vnic_rss_cfg(bp, vnic);
 	return 0;
 }
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 15/17] net/bnxt: handle cleanup if flow creation fails
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (13 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 14/17] net/bnxt: validate RSS hash key length Ajit Khaparde
@ 2019-09-03  2:18 ` Ajit Khaparde
  2019-09-03  2:19 ` [dpdk-dev] [PATCH 16/17] net/bnxt: synchronize between flow related functions Ajit Khaparde
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Venkat Duvvuru, Kalesh Anakkur Purayil

If flow creation fails because of an HWRM command failure or
or some other reason, reset the vnic and rxq info set earlier.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 68 ++++++++++++++++++++++++++++++++----
 1 file changed, 62 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 9d943cd14..8156b5b4b 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -175,6 +175,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			return -rte_errno;
 		}
 
+		if (!item->spec || !item->mask) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM,
+					   item,
+					   "spec/mask is NULL");
+			return -rte_errno;
+		}
+
 		switch (item->type) {
 		case RTE_FLOW_ITEM_TYPE_ANY:
 			inner =
@@ -907,10 +915,10 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 	const struct rte_flow_action *act =
 		bnxt_flow_non_void_action(actions);
 	struct bnxt *bp = dev->data->dev_private;
+	struct bnxt_vnic_info *vnic = NULL, *vnic0 = NULL;
 	const struct rte_flow_action_queue *act_q;
-	const struct rte_flow_action_rss *rss;
 	const struct rte_flow_action_vf *act_vf;
-	struct bnxt_vnic_info *vnic, *vnic0;
+	const struct rte_flow_action_rss *rss;
 	struct bnxt_filter_info *filter1;
 	struct bnxt_rx_queue *rxq = NULL;
 	int dflt_vnic, vnic_id;
@@ -1009,8 +1017,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		PMD_DRV_LOG(DEBUG, "VNIC found\n");
 
 		rc = bnxt_vnic_prep(bp, vnic);
-		if (rc)
+		if (rc)  {
+			rte_flow_error_set(error,
+					   EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "VNIC prep fail");
+			rc = -rte_errno;
 			goto ret;
+		}
 
 		PMD_DRV_LOG(DEBUG,
 			    "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
@@ -1023,7 +1038,12 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		filter->dst_id = vnic->fw_vnic_id;
 		filter1 = bnxt_get_l2_filter(bp, filter, vnic);
 		if (filter1 == NULL) {
-			rc = -ENOSPC;
+			rte_flow_error_set(error,
+					   ENOSPC,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "Filter not available");
+			rc = -rte_errno;
 			goto ret;
 		}
 
@@ -1050,7 +1070,12 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		vnic0 = &bp->vnic_info[0];
 		filter1 = bnxt_get_l2_filter(bp, filter, vnic0);
 		if (filter1 == NULL) {
-			rc = -ENOSPC;
+			rte_flow_error_set(error,
+					   ENOSPC,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "New filter not available");
+			rc = -rte_errno;
 			goto ret;
 		}
 
@@ -1113,6 +1138,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		vnic0 = &bp->vnic_info[0];
 		filter1 = bnxt_get_l2_filter(bp, filter, vnic0);
 		if (filter1 == NULL) {
+			rte_flow_error_set(error,
+					   ENOSPC,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "New filter not available");
 			rc = -ENOSPC;
 			goto ret;
 		}
@@ -1209,8 +1239,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		vnic->func_default = 0;	//This is not a default VNIC.
 
 		rc = bnxt_vnic_prep(bp, vnic);
-		if (rc)
+		if (rc) {
+			rte_flow_error_set(error,
+					   EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "VNIC prep fail");
+			rc = -rte_errno;
 			goto ret;
+		}
 
 		PMD_DRV_LOG(DEBUG,
 			    "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
@@ -1265,6 +1302,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		filter->dst_id = vnic->fw_vnic_id;
 		filter1 = bnxt_get_l2_filter(bp, filter, vnic);
 		if (filter1 == NULL) {
+			rte_flow_error_set(error,
+					   ENOSPC,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "New filter not available");
 			rc = -ENOSPC;
 			goto ret;
 		}
@@ -1297,7 +1339,18 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		rc = -rte_errno;
 		goto ret;
 	}
+
+	return rc;
 ret:
+
+	//TODO: Cleanup according to ACTION TYPE.
+	if (rte_errno)  {
+		if (vnic && STAILQ_EMPTY(&vnic->filter))
+			vnic->rx_queue_cnt = 0;
+
+		if (rxq && !vnic->rx_queue_cnt)
+			rxq->vnic = &bp->vnic_info[0];
+	}
 	return rc;
 }
 
@@ -1344,6 +1397,8 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
 
 	ret = bnxt_validate_and_parse_flow(dev, pattern, actions, attr,
 					   error, filter);
+	if (ret)
+		goto exit;
 
 	vnic = find_matching_vnic(bp, filter);
 	if (vnic) {
@@ -1364,6 +1419,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
 	else
 		bnxt_hwrm_clear_l2_filter(bp, filter);
 
+exit:
 	/* No need to hold on to this filter if we are just validating flow */
 	filter->fw_l2_filter_id = UINT64_MAX;
 	bnxt_free_filter(bp, filter);
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 16/17] net/bnxt: synchronize between flow related functions
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (14 preceding siblings ...)
  2019-09-03  2:18 ` [dpdk-dev] [PATCH 15/17] net/bnxt: handle cleanup if flow creation fails Ajit Khaparde
@ 2019-09-03  2:19 ` Ajit Khaparde
  2019-09-03  2:19 ` [dpdk-dev] [PATCH 17/17] net/bnxt: drop untagged frames when specified Ajit Khaparde
  2019-10-01 17:02 ` [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ferruh Yigit
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:19 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Venkat Duvvuru, Kalesh Anakkur Purayil

From: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>

Currently, there are four flow related functions, namely
bnxt_flow_create, bnxt_flow_destroy, bnxt_flow_validate,
bnxt_flow_flush. All these functions are not multi-thread safe.

This patch fixes it by synchronizing these functions with a lock.

Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  6 +++++
 drivers/net/bnxt/bnxt_ethdev.c | 23 ++++++++++++++++
 drivers/net/bnxt/bnxt_flow.c   | 49 +++++++++++++++++++++++++++-------
 3 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 64cc06304..773227048 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -462,6 +462,7 @@ struct bnxt {
 	uint32_t		flow_flags;
 #define BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN	BIT(0)
 
+	pthread_mutex_t         flow_lock;
 	unsigned int		rx_nr_rings;
 	unsigned int		rx_cp_nr_rings;
 	unsigned int		rx_num_qs_per_vnic;
@@ -571,6 +572,11 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp);
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
 extern const struct rte_flow_ops bnxt_flow_ops;
+#define bnxt_acquire_flow_lock(bp) \
+	pthread_mutex_lock(&(bp)->flow_lock)
+
+#define bnxt_release_flow_lock(bp) \
+	pthread_mutex_unlock(&(bp)->flow_lock)
 
 extern int bnxt_logtype_driver;
 #define PMD_DRV_LOG_RAW(level, fmt, args...) \
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 5ef2ee0c4..f5cbc0038 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -4297,6 +4297,17 @@ static int bnxt_init_fw(struct bnxt *bp)
 	return 0;
 }
 
+static int
+bnxt_init_locks(struct bnxt *bp)
+{
+	int err;
+
+	err = pthread_mutex_init(&bp->flow_lock, NULL);
+	if (err)
+		PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n");
+	return err;
+}
+
 static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
 {
 	int rc;
@@ -4350,6 +4361,10 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
 	if (rc)
 		return rc;
 
+	rc = bnxt_init_locks(bp);
+	if (rc)
+		return rc;
+
 	return 0;
 }
 
@@ -4430,6 +4445,12 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	return rc;
 }
 
+static void
+bnxt_uninit_locks(struct bnxt *bp)
+{
+	pthread_mutex_destroy(&bp->flow_lock);
+}
+
 static int
 bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 {
@@ -4451,6 +4472,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 		bp->recovery_info = NULL;
 	}
 
+	bnxt_uninit_locks(bp);
+
 	return rc;
 }
 
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 8156b5b4b..d640a923a 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1385,13 +1385,17 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
 	struct bnxt_filter_info *filter;
 	int ret = 0;
 
+	bnxt_acquire_flow_lock(bp);
 	ret = bnxt_flow_args_validate(attr, pattern, actions, error);
-	if (ret != 0)
+	if (ret != 0) {
+		bnxt_release_flow_lock(bp);
 		return ret;
+	}
 
 	filter = bnxt_get_unused_filter(bp);
 	if (filter == NULL) {
 		PMD_DRV_LOG(ERR, "Not enough resources for a new flow.\n");
+		bnxt_release_flow_lock(bp);
 		return -ENOMEM;
 	}
 
@@ -1423,6 +1427,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
 	/* No need to hold on to this filter if we are just validating flow */
 	filter->fw_l2_filter_id = UINT64_MAX;
 	bnxt_free_filter(bp, filter);
+	bnxt_release_flow_lock(bp);
 
 	return ret;
 }
@@ -1535,6 +1540,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 		return flow;
 	}
 
+	bnxt_acquire_flow_lock(bp);
 	ret = bnxt_flow_args_validate(attr, pattern, actions, error);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Not a validate flow.\n");
@@ -1630,6 +1636,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 		STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
 		PMD_DRV_LOG(ERR, "Successfully created flow.\n");
 		STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
+		bnxt_release_flow_lock(bp);
 		return flow;
 	}
 
@@ -1650,6 +1657,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,
 				   "Failed to create flow.");
 	rte_free(flow);
 	flow = NULL;
+	bnxt_release_flow_lock(bp);
 	return flow;
 }
 
@@ -1700,13 +1708,28 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 		  struct rte_flow_error *error)
 {
 	struct bnxt *bp = dev->data->dev_private;
-	struct bnxt_filter_info *filter = flow->filter;
-	struct bnxt_vnic_info *vnic = flow->vnic;
+	struct bnxt_filter_info *filter;
+	struct bnxt_vnic_info *vnic;
 	int ret = 0;
 
+	bnxt_acquire_flow_lock(bp);
+	if (!flow) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Invalid flow: failed to destroy flow.");
+		bnxt_release_flow_lock(bp);
+		return -EINVAL;
+	}
+
+	filter = flow->filter;
+	vnic = flow->vnic;
+
 	if (!filter) {
-		ret = -EINVAL;
-		goto done;
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Invalid flow: failed to destroy flow.");
+		bnxt_release_flow_lock(bp);
+		return -EINVAL;
 	}
 
 	if (filter->filter_type == HWRM_CFA_TUNNEL_REDIRECT_FILTER &&
@@ -1714,10 +1737,12 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 		ret = bnxt_handle_tunnel_redirect_destroy(bp,
 							  filter,
 							  error);
-		if (!ret)
+		if (!ret) {
 			goto done;
-		else
+		} else {
+			bnxt_release_flow_lock(bp);
 			return ret;
+		}
 	}
 
 	ret = bnxt_match_filter(bp, filter);
@@ -1756,6 +1781,7 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 				   "Failed to destroy flow.");
 	}
 
+	bnxt_release_flow_lock(bp);
 	return ret;
 }
 
@@ -1769,6 +1795,7 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 	unsigned int i;
 	int ret = 0;
 
+	bnxt_acquire_flow_lock(bp);
 	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
 		if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID)
@@ -1785,10 +1812,12 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 				bnxt_handle_tunnel_redirect_destroy(bp,
 								    filter,
 								    error);
-				if (!ret)
+				if (!ret) {
 					goto done;
-				else
+				} else {
+					bnxt_release_flow_lock(bp);
 					return ret;
+				}
 			}
 
 			if (filter->filter_type == HWRM_CFA_EM_FILTER)
@@ -1805,6 +1834,7 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 					 RTE_FLOW_ERROR_TYPE_HANDLE,
 					 NULL,
 					 "Failed to flush flow in HW.");
+				bnxt_release_flow_lock(bp);
 				return -rte_errno;
 			}
 done:
@@ -1833,6 +1863,7 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 		}
 	}
 
+	bnxt_release_flow_lock(bp);
 	return ret;
 }
 
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH 17/17] net/bnxt: drop untagged frames when specified
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (15 preceding siblings ...)
  2019-09-03  2:19 ` [dpdk-dev] [PATCH 16/17] net/bnxt: synchronize between flow related functions Ajit Khaparde
@ 2019-09-03  2:19 ` Ajit Khaparde
  2019-10-01 17:02 ` [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ferruh Yigit
  17 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-09-03  2:19 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Rahul Gupta, Somnath Kotur, Kalesh Anakkur Purayil

When a drop action for L2 filters is specified, support it.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt_filter.h |  6 ++++
 drivers/net/bnxt/bnxt_flow.c   | 61 ++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h
index bcb9d6031..2d10bd728 100644
--- a/drivers/net/bnxt/bnxt_filter.h
+++ b/drivers/net/bnxt/bnxt_filter.h
@@ -15,6 +15,8 @@ struct bnxt;
 #define BNXT_FLOW_L2_INNER_SRC_VALID_FLAG	BIT(2)
 #define BNXT_FLOW_L2_DST_VALID_FLAG		BIT(3)
 #define BNXT_FLOW_L2_INNER_DST_VALID_FLAG	BIT(4)
+#define BNXT_FLOW_L2_DROP_FLAG			BIT(5)
+#define BNXT_FLOW_PARSE_INNER_FLAG		BIT(6)
 
 struct bnxt_filter_info {
 	STAILQ_ENTRY(bnxt_filter_info)	next;
@@ -146,4 +148,8 @@ struct bnxt_filter_info *bnxt_get_l2_filter(struct bnxt *bp,
 	HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID
 #define NTUPLE_FLTR_ALLOC_INPUT_EN_MIRROR_VNIC_ID	\
 	HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID
+#define L2_FILTER_ALLOC_INPUT_EN_T_NUM_VLANS \
+	HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_NUM_VLANS
+#define L2_FILTER_ALLOC_INPUT_EN_NUM_VLANS \
+	HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_NUM_VLANS
 #endif
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index d640a923a..50cad5480 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -273,6 +273,8 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 					rte_be_to_cpu_16(eth_spec->type);
 				en |= en_ethertype;
 			}
+			if (inner)
+				valid_flags |= BNXT_FLOW_PARSE_INNER_FLAG;
 
 			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
@@ -794,9 +796,36 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,
 		}
 	}
 
-	filter1->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
+	if (nf->valid_flags & (BNXT_FLOW_L2_DST_VALID_FLAG |
+			       BNXT_FLOW_L2_SRC_VALID_FLAG |
+			       BNXT_FLOW_L2_INNER_SRC_VALID_FLAG |
+			       BNXT_FLOW_L2_INNER_DST_VALID_FLAG)) {
+		filter1->enables =
+			HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
 			L2_FILTER_ALLOC_INPUT_EN_L2_ADDR_MASK;
-	memset(filter1->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
+		memset(filter1->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
+	}
+
+	if (nf->valid_flags & BNXT_FLOW_L2_DROP_FLAG) {
+		filter1->flags |=
+			HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_DROP;
+		if (nf->ethertype == RTE_ETHER_TYPE_IPV4) {
+			/* Num VLANs for drop filter will/should be 0.
+			 * If the req is memset to 0, then the count will
+			 * be automatically set to 0.
+			 */
+			if (nf->valid_flags & BNXT_FLOW_PARSE_INNER_FLAG) {
+				filter1->enables |=
+					L2_FILTER_ALLOC_INPUT_EN_T_NUM_VLANS;
+			} else {
+				filter1->enables |=
+					L2_FILTER_ALLOC_INPUT_EN_NUM_VLANS;
+				filter1->flags |=
+				HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
+			}
+		}
+	}
+
 	rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id,
 				     filter1);
 	if (rc) {
@@ -893,7 +922,9 @@ bnxt_update_filter_flags_en(struct bnxt_filter_info *filter,
 	      ~(BNXT_FLOW_L2_DST_VALID_FLAG |
 		BNXT_FLOW_L2_SRC_VALID_FLAG |
 		BNXT_FLOW_L2_INNER_SRC_VALID_FLAG |
-		BNXT_FLOW_L2_INNER_DST_VALID_FLAG))) {
+		BNXT_FLOW_L2_INNER_DST_VALID_FLAG |
+		BNXT_FLOW_L2_DROP_FLAG |
+		BNXT_FLOW_PARSE_INNER_FLAG))) {
 		filter->flags = filter1->flags;
 		filter->enables = filter1->enables;
 		filter->filter_type = HWRM_CFA_L2_FILTER;
@@ -1052,19 +1083,27 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		break;
 	case RTE_FLOW_ACTION_TYPE_DROP:
 		vnic0 = &bp->vnic_info[0];
+		filter->dst_id = vnic0->fw_vnic_id;
+		filter->valid_flags |= BNXT_FLOW_L2_DROP_FLAG;
 		filter1 = bnxt_get_l2_filter(bp, filter, vnic0);
 		if (filter1 == NULL) {
+			rte_flow_error_set(error,
+					   ENOSPC,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "Filter not available");
 			rc = -ENOSPC;
 			goto ret;
 		}
 
-		filter->fw_l2_filter_id = filter1->fw_l2_filter_id;
 		if (filter->filter_type == HWRM_CFA_EM_FILTER)
 			filter->flags =
 				HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_DROP;
-		else
+		else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
 			filter->flags =
 				HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DROP;
+
+		bnxt_update_filter_flags_en(filter, filter1);
 		break;
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		vnic0 = &bp->vnic_info[0];
@@ -1758,6 +1797,15 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 
 done:
 	if (!ret) {
+		/* If it is a L2 drop filter, when the filter is created,
+		 * the FW updates the BC/MC records.
+		 * Once this filter is removed, issue the set_rx_mask command
+		 * to reset the BC/MC records in the HW to the settings
+		 * before the drop counter is created.
+		 */
+		if (filter->valid_flags & BNXT_FLOW_L2_DROP_FLAG)
+			bnxt_set_rx_mask_no_vlan(bp, &bp->vnic_info[0]);
+
 		STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next);
 		bnxt_free_filter(bp, filter);
 		STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next);
@@ -1766,7 +1814,8 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,
 		/* If this was the last flow associated with this vnic,
 		 * switch the queue back to RSS pool.
 		 */
-		if (vnic && STAILQ_EMPTY(&vnic->flow_list)) {
+		if (vnic && !vnic->func_default &&
+		    STAILQ_EMPTY(&vnic->flow_list)) {
 			rte_free(vnic->fw_grp_ids);
 			if (vnic->rx_queue_cnt > 1)
 				bnxt_hwrm_vnic_ctx_free(bp, vnic);
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support
  2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
                   ` (16 preceding siblings ...)
  2019-09-03  2:19 ` [dpdk-dev] [PATCH 17/17] net/bnxt: drop untagged frames when specified Ajit Khaparde
@ 2019-10-01 17:02 ` Ferruh Yigit
  2019-10-01 17:32   ` Ajit Khaparde
  17 siblings, 1 reply; 20+ messages in thread
From: Ferruh Yigit @ 2019-10-01 17:02 UTC (permalink / raw)
  To: Ajit Khaparde, dev

On 9/3/2019 3:18 AM, Ajit Khaparde wrote:
> Among other changes, this patchset adds support to:
> - create filters with RSS action.
> - create source MAC filters.
> - use user provided priority to place rule appropriately in HW.
> 
> This series is dependent on the series "bnxt patchset" submitted earlier
> https://patchwork.dpdk.org/project/dpdk/list/?series=6190

Hi Ajit,

I am updating almost all bnxt patchsets as changes requested, because of the
dependency chain and first patchset in the chain needs updating.
Please ping me if I am missing something.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support
  2019-10-01 17:02 ` [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ferruh Yigit
@ 2019-10-01 17:32   ` Ajit Khaparde
  0 siblings, 0 replies; 20+ messages in thread
From: Ajit Khaparde @ 2019-10-01 17:32 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

Ferruh. Yes. We are working on that already. Thanks

On Tue, Oct 1, 2019 at 10:02 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> On 9/3/2019 3:18 AM, Ajit Khaparde wrote:
> > Among other changes, this patchset adds support to:
> > - create filters with RSS action.
> > - create source MAC filters.
> > - use user provided priority to place rule appropriately in HW.
> >
> > This series is dependent on the series "bnxt patchset" submitted earlier
> > https://patchwork.dpdk.org/project/dpdk/list/?series=6190
>
> Hi Ajit,
>
> I am updating almost all bnxt patchsets as changes requested, because of
> the
> dependency chain and first patchset in the chain needs updating.
> Please ping me if I am missing something.
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-10-01 17:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03  2:18 [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 01/17] net/bnxt: return standard error codes for HWRM command Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 02/17] net/bnxt: refactor code to allow dynamic creation of VNIC Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 03/17] net/bnxt: allow flow creation when RSS is enabled Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 04/17] net/bnxt: add support to create SMAC and inner DMAC filters Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 05/17] net/bnxt: add support for RSS action Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 06/17] net/bnxt: parse priority attribute for flow creation Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 07/17] net/bnxt: delete and flush L2 filters cleanly Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 08/17] net/bnxt: cleanup vnic after flow validate Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 09/17] net/bnxt: allow only unicast MAC address filter creation Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 10/17] net/bnxt: properly handle ring cleanup in case of error Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 11/17] net/bnxt: check device is started before flow creation Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 12/17] net/bnxt: check for invalid VNIC ID in vnic tpa cfg Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 13/17] net/bnxt: handle flow flush handling Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 14/17] net/bnxt: validate RSS hash key length Ajit Khaparde
2019-09-03  2:18 ` [dpdk-dev] [PATCH 15/17] net/bnxt: handle cleanup if flow creation fails Ajit Khaparde
2019-09-03  2:19 ` [dpdk-dev] [PATCH 16/17] net/bnxt: synchronize between flow related functions Ajit Khaparde
2019-09-03  2:19 ` [dpdk-dev] [PATCH 17/17] net/bnxt: drop untagged frames when specified Ajit Khaparde
2019-10-01 17:02 ` [dpdk-dev] [PATCH 00/17] bnxt patchset to improve rte flow support Ferruh Yigit
2019-10-01 17:32   ` Ajit Khaparde

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).