diff mbox series

[26/58] net/bnxt: check FW capability to support TRUFLOW

Message ID 20210530085929.29695-27-venkatkumar.duvvuru@broadcom.com (mailing list archive)
State Superseded, archived
Delegated to: Ajit Khaparde
Headers show
Series enhancements to host based flow table management | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Venkat Duvvuru May 30, 2021, 8:58 a.m. UTC
Currently, a devarg (host-based-truflow) is passed while launching
the app to enable truflow feature. However, this mechanism doesn't
give a seamless experience when flow offloads has to work with
firmware that doesn't/does support truflow feature. Also, it's
likely that customers may not want to use devarg to enable flow
offloads.

This patch fixes it by checking for truflow feature support in
device's capabilities and configurations field of the hwrm_ver_get's
response.

Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 doc/guides/nics/bnxt.rst       |  3 +-
 drivers/net/bnxt/bnxt.h        | 10 +++---
 drivers/net/bnxt/bnxt_ethdev.c | 56 ----------------------------------
 drivers/net/bnxt/bnxt_hwrm.c   |  7 ++++-
 4 files changed, 12 insertions(+), 64 deletions(-)
diff mbox series

Patch

diff --git a/doc/guides/nics/bnxt.rst b/doc/guides/nics/bnxt.rst
index 0fb2032447..fef8a7fac9 100644
--- a/doc/guides/nics/bnxt.rst
+++ b/doc/guides/nics/bnxt.rst
@@ -658,8 +658,7 @@  which currently supports basic packet classification in the receive path.
 The feature uses a newly implemented control-plane firmware interface which
 optimizes flow insertions and deletions.
 
-This is a tech preview feature, and is disabled by default. It can be enabled
-using bnxt devargs. For ex: "-a 0000:0d:00.0,host-based-truflow=1”.
+This is a tech preview feature.
 
 This feature is currently supported on Whitney+ and Stingray devices.
 
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index db67bff127..882f577848 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -645,10 +645,9 @@  struct bnxt {
 #define BNXT_FLAG_RX_VECTOR_PKT_MODE		BIT(24)
 #define BNXT_FLAG_FLOW_XSTATS_EN		BIT(25)
 #define BNXT_FLAG_DFLT_MAC_SET			BIT(26)
-#define BNXT_FLAG_TRUFLOW_EN			BIT(27)
-#define BNXT_FLAG_GFID_ENABLE			BIT(28)
-#define BNXT_FLAG_RFS_NEEDS_VNIC		BIT(29)
-#define BNXT_FLAG_FLOW_CFA_RFS_RING_TBL_IDX_V2	BIT(30)
+#define BNXT_FLAG_GFID_ENABLE			BIT(27)
+#define BNXT_FLAG_RFS_NEEDS_VNIC		BIT(28)
+#define BNXT_FLAG_FLOW_CFA_RFS_RING_TBL_IDX_V2	BIT(29)
 #define BNXT_RFS_NEEDS_VNIC(bp)	((bp)->flags & BNXT_FLAG_RFS_NEEDS_VNIC)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
@@ -664,7 +663,6 @@  struct bnxt {
 #define BNXT_HAS_RING_GRPS(bp)	(!BNXT_CHIP_P5(bp))
 #define BNXT_FLOW_XSTATS_EN(bp)	((bp)->flags & BNXT_FLAG_FLOW_XSTATS_EN)
 #define BNXT_HAS_DFLT_MAC_SET(bp)      ((bp)->flags & BNXT_FLAG_DFLT_MAC_SET)
-#define BNXT_TRUFLOW_EN(bp)	((bp)->flags & BNXT_FLAG_TRUFLOW_EN)
 #define BNXT_GFID_ENABLED(bp)	((bp)->flags & BNXT_FLAG_GFID_ENABLE)
 
 	uint32_t			flags2;
@@ -686,6 +684,8 @@  struct bnxt {
 #define BNXT_FW_CAP_ADV_FLOW_MGMT	BIT(5)
 #define BNXT_FW_CAP_ADV_FLOW_COUNTERS	BIT(6)
 #define BNXT_FW_CAP_LINK_ADMIN		BIT(7)
+#define BNXT_FW_CAP_TRUFLOW_EN		BIT(8)
+#define BNXT_TRUFLOW_EN(bp)	((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN)
 
 	pthread_mutex_t         flow_lock;
 
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 3778e28cca..a0e0ba5884 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -87,7 +87,6 @@  static const struct rte_pci_id bnxt_pci_id_map[] = {
 	{ .vendor_id = 0, /* sentinel */ },
 };
 
-#define BNXT_DEVARG_TRUFLOW	"host-based-truflow"
 #define BNXT_DEVARG_FLOW_XSTAT	"flow-xstat"
 #define BNXT_DEVARG_MAX_NUM_KFLOWS  "max-num-kflows"
 #define BNXT_DEVARG_REPRESENTOR	"representor"
@@ -100,7 +99,6 @@  static const struct rte_pci_id bnxt_pci_id_map[] = {
 
 static const char *const bnxt_dev_args[] = {
 	BNXT_DEVARG_REPRESENTOR,
-	BNXT_DEVARG_TRUFLOW,
 	BNXT_DEVARG_FLOW_XSTAT,
 	BNXT_DEVARG_MAX_NUM_KFLOWS,
 	BNXT_DEVARG_REP_BASED_PF,
@@ -112,12 +110,6 @@  static const char *const bnxt_dev_args[] = {
 	NULL
 };
 
-/*
- * truflow == false to disable the feature
- * truflow == true to enable the feature
- */
-#define	BNXT_DEVARG_TRUFLOW_INVALID(truflow)	((truflow) > 1)
-
 /*
  * flow_xstat == false to disable the feature
  * flow_xstat == true to enable the feature
@@ -5182,45 +5174,6 @@  static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
 	return 0;
 }
 
-static int
-bnxt_parse_devarg_truflow(__rte_unused const char *key,
-			  const char *value, void *opaque_arg)
-{
-	struct bnxt *bp = opaque_arg;
-	unsigned long truflow;
-	char *end = NULL;
-
-	if (!value || !opaque_arg) {
-		PMD_DRV_LOG(ERR,
-			    "Invalid parameter passed to truflow devargs.\n");
-		return -EINVAL;
-	}
-
-	truflow = strtoul(value, &end, 10);
-	if (end == NULL || *end != '\0' ||
-	    (truflow == ULONG_MAX && errno == ERANGE)) {
-		PMD_DRV_LOG(ERR,
-			    "Invalid parameter passed to truflow devargs.\n");
-		return -EINVAL;
-	}
-
-	if (BNXT_DEVARG_TRUFLOW_INVALID(truflow)) {
-		PMD_DRV_LOG(ERR,
-			    "Invalid value passed to truflow devargs.\n");
-		return -EINVAL;
-	}
-
-	if (truflow) {
-		bp->flags |= BNXT_FLAG_TRUFLOW_EN;
-		PMD_DRV_LOG(INFO, "Host-based truflow feature enabled.\n");
-	} else {
-		bp->flags &= ~BNXT_FLAG_TRUFLOW_EN;
-		PMD_DRV_LOG(INFO, "Host-based truflow feature disabled.\n");
-	}
-
-	return 0;
-}
-
 static int
 bnxt_parse_devarg_flow_xstat(__rte_unused const char *key,
 			     const char *value, void *opaque_arg)
@@ -5528,15 +5481,6 @@  bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs)
 	if (kvlist == NULL)
 		return -EINVAL;
 
-	/*
-	 * Handler for "truflow" devarg.
-	 * Invoked as for ex: "-a 0000:00:0d.0,host-based-truflow=1"
-	 */
-	ret = rte_kvargs_process(kvlist, BNXT_DEVARG_TRUFLOW,
-				 bnxt_parse_devarg_truflow, bp);
-	if (ret)
-		goto err;
-
 	/*
 	 * Handler for "flow_xstat" devarg.
 	 * Invoked as for ex: "-a 0000:00:0d.0,flow_xstat=1"
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 931ecea77c..4505321778 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1345,6 +1345,12 @@  int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
 		bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_COUNTERS;
 	}
 
+	if (dev_caps_cfg &
+	    HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TRUFLOW_SUPPORTED) {
+		PMD_DRV_LOG(DEBUG, "Host-based truflow feature enabled.\n");
+		bp->fw_cap |= BNXT_FW_CAP_TRUFLOW_EN;
+	}
+
 error:
 	HWRM_UNLOCK();
 	return rc;
@@ -4561,7 +4567,6 @@  int bnxt_hwrm_erase_nvram_directory(struct bnxt *bp, uint8_t index)
 	return rc;
 }
 
-
 int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,
 			  uint16_t dir_ordinal, uint16_t dir_ext,
 			  uint16_t dir_attr, const uint8_t *data,