Skip to contentSkip to conversation

bnxt patchset to improve rte flow support

PATCH Superseded Ajit Khaparde 2 participants 20 messages Sep 3, 2019 – Oct 1, 2019 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover bnxt patchset to improve rte flow support

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(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#1 lore raw

PATCH 1/17 net/bnxt: return standard error codes for HWRM command

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.

---
 drivers/net/bnxt/bnxt_hwrm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_hwrm.c +14 -2
index bdc84c831..c876ff75c 100644
@@ -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)
Signature · 1 line
2.20.1 (Apple Git-117)
#2 lore raw

PATCH 2/17 net/bnxt: refactor code to allow dynamic creation of VNIC

In reply to Ajit Khaparde

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

---
 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(-)
drivers/net/bnxt/bnxt.h +1 -0
index 2e662b297..c3938af37 100644
@@ -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;
drivers/net/bnxt/bnxt_ethdev.c +15 -39

82 lines not on this page · raw message

drivers/net/bnxt/bnxt_flow.c +5 -0
index be9b6fad3..0eeff7b33 100644
@@ -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,
drivers/net/bnxt/bnxt_rxq.c +13 -17
index d6bca7fd4..2e5f2cf29 100644
@@ -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)
drivers/net/bnxt/bnxt_vnic.c +36 -0
index 9ea99388b..4f3f9b359 100644
@@ -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;
+}
drivers/net/bnxt/bnxt_vnic.h +3 -0
index 16a0d5763..cb2707f36 100644
@@ -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
Signature · 1 line
2.20.1 (Apple Git-117)
#3 lore raw

PATCH 3/17 net/bnxt: allow flow creation when RSS is enabled

In reply to Ajit Khaparde

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

---
 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(-)
drivers/net/bnxt/bnxt.h +1 -0
index c3938af37..f0b1021cd 100644
@@ -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);
drivers/net/bnxt/bnxt_ethdev.c +1 -1
index 6da4a9b09..0c605202c 100644
@@ -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;
drivers/net/bnxt/bnxt_flow.c +145 -32

270 lines not on this page · raw message

drivers/net/bnxt/bnxt_vnic.h +2 -0
index cb2707f36..ec3a3ff51 100644
@@ -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;
Signature · 1 line
2.20.1 (Apple Git-117)
#4 lore raw

PATCH 4/17 net/bnxt: add support to create SMAC and inner DMAC filters

In reply to Ajit Khaparde

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.

---
 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(-)
drivers/net/bnxt/bnxt.h +4 -0
index f0b1021cd..64cc06304 100644
@@ -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;
drivers/net/bnxt/bnxt_ethdev.c +8 -1
index 0c605202c..b72466467 100644
@@ -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;
drivers/net/bnxt/bnxt_filter.h +8 -0
index 4fda3f03a..52d3582ba 100644
@@ -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;
drivers/net/bnxt/bnxt_flow.c +76 -14

172 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +42 -2

65 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +4 -0
index f3234ae72..47b1e43ac 100644
@@ -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
drivers/net/bnxt/bnxt_util.h +4 -0
index a15b3a1a9..6ded7f657 100644
@@ -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_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#5 lore raw

PATCH 5/17 net/bnxt: add support for RSS action

In reply to Ajit Khaparde

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.

---
 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(-)
drivers/net/bnxt/bnxt_flow.c +217 -26
index 4ba280fff..1328f25bc 100644
@@ -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,
drivers/net/bnxt/bnxt_vnic.c +1 -1
index 4f3f9b359..2f0ed1026 100644
@@ -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;
drivers/net/bnxt/bnxt_vnic.h +1 -0
index ec3a3ff51..de34b21eb 100644
@@ -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
Signature · 1 line
2.20.1 (Apple Git-117)
#6 lore raw

PATCH 6/17 net/bnxt: parse priority attribute for flow creation

In reply to Ajit Khaparde

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.

---
 drivers/net/bnxt/bnxt_filter.h |  1 +
 drivers/net/bnxt/bnxt_flow.c   | 25 +++++++++++--------------
 2 files changed, 12 insertions(+), 14 deletions(-)
drivers/net/bnxt/bnxt_filter.h +1 -0
index 52d3582ba..bcb9d6031 100644
@@ -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);
drivers/net/bnxt/bnxt_flow.c +11 -14
index 1328f25bc..2d107a892 100644
@@ -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 |
Signature · 1 line
2.20.1 (Apple Git-117)
#7 lore raw

PATCH 7/17 net/bnxt: delete and flush L2 filters cleanly

In reply to Ajit Khaparde

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.

---
 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(-)
drivers/net/bnxt/bnxt_filter.c +7 -11
index 0aed29fb0..30ee6344d 100644
@@ -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);
 
drivers/net/bnxt/bnxt_flow.c +38 -1
index 2d107a892..496edd7ac 100644
@@ -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
drivers/net/bnxt/bnxt_hwrm.c +27 -20

63 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#8 lore raw

PATCH 8/17 net/bnxt: cleanup vnic after flow validate

In reply to Ajit Khaparde

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.

---
 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(-)
drivers/net/bnxt/bnxt_flow.c +45 -31
index 496edd7ac..aed822ee3 100644
@@ -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--;
drivers/net/bnxt/bnxt_hwrm.c +27 -14

65 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +1 -2
index 47b1e43ac..9fa52be72 100644
@@ -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);
Signature · 1 line
2.20.1 (Apple Git-117)
#9 lore raw

PATCH 9/17 net/bnxt: allow only unicast MAC address filter creation

In reply to Ajit Khaparde

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

---
 drivers/net/bnxt/bnxt_flow.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/net/bnxt/bnxt_flow.c +16 -0
index aed822ee3..578081890 100644
@@ -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 ?
Signature · 1 line
2.20.1 (Apple Git-117)
#10 lore raw

PATCH 10/17 net/bnxt: properly handle ring cleanup in case of error

In reply to Ajit Khaparde

From: Rahul Gupta <[email protected]>

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

---
 drivers/net/bnxt/bnxt_ring.c | 37 ++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/net/bnxt/bnxt_ring.c +37 -0
index 119a6919f..f6e81d308 100644
@@ -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];
Signature · 1 line
2.20.1 (Apple Git-117)
#11 lore raw

PATCH 11/17 net/bnxt: check device is started before flow creation

In reply to Ajit Khaparde

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,

---
 drivers/net/bnxt/bnxt_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/net/bnxt/bnxt_flow.c +9 -0
index 578081890..71a5266ce 100644
@@ -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,
Signature · 1 line
2.20.1 (Apple Git-117)
#12 lore raw

PATCH 12/17 net/bnxt: check for invalid VNIC ID in vnic tpa cfg

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

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

---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index a033e2d1e..227d893da 100644
@@ -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) {
Signature · 1 line
2.20.1 (Apple Git-117)
#13 lore raw

PATCH 13/17 net/bnxt: handle flow flush handling

In reply to Ajit Khaparde

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.

---
 drivers/net/bnxt/bnxt_flow.c | 56 ++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
drivers/net/bnxt/bnxt_flow.c +28 -28
index 71a5266ce..9d943cd14 100644
@@ -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--;
+			}
 		}
 	}
 
Signature · 1 line
2.20.1 (Apple Git-117)
#14 lore raw

PATCH 14/17 net/bnxt: validate RSS hash key length

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

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.

---
 drivers/net/bnxt/bnxt_ethdev.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +12 -6
index b72466467..5ef2ee0c4 100644
@@ -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;
 }
Signature · 1 line
2.20.1 (Apple Git-117)
#15 lore raw

PATCH 15/17 net/bnxt: handle cleanup if flow creation fails

In reply to Ajit Khaparde

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

---
 drivers/net/bnxt/bnxt_flow.c | 68 ++++++++++++++++++++++++++++++++----
 1 file changed, 62 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_flow.c +62 -6
index 9d943cd14..8156b5b4b 100644
@@ -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);
Signature · 1 line
2.20.1 (Apple Git-117)
#16 lore raw

PATCH 16/17 net/bnxt: synchronize between flow related functions

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

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.

---
 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(-)
drivers/net/bnxt/bnxt.h +6 -0
index 64cc06304..773227048 100644
@@ -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...) \
drivers/net/bnxt/bnxt_ethdev.c +23 -0
index 5ef2ee0c4..f5cbc0038 100644
@@ -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;
 }
 
drivers/net/bnxt/bnxt_flow.c +40 -9

134 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#17 lore raw

PATCH 17/17 net/bnxt: drop untagged frames when specified

In reply to Ajit Khaparde

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

---
 drivers/net/bnxt/bnxt_filter.h |  6 ++++
 drivers/net/bnxt/bnxt_flow.c   | 61 ++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_filter.h +6 -0
index bcb9d6031..2d10bd728 100644
@@ -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
drivers/net/bnxt/bnxt_flow.c +55 -6

109 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#18 lore raw
In reply to Ajit Khaparde
Quoted 7 lines · Ajit Khaparde

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.

#19 lore raw

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

Quoted 16 lines · Ferruh Yigit
Quoted 7 lines · Ajit Khaparde

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.