Skip to contentSkip to conversation

bnxt_en: Updates for net-next

PATCH In review Michael Chan 2 participants 14 messages Sep 15, 2025 – Sep 16, 2025

Subsystems (3)
lore
Share & tools
lore

Michael Chan

author maintainer
#0 lore raw

cover bnxt_en: Updates for net-next

This series includes some code clean-ups and optimizations. New features include 2 new backing store memory types to collect FW logs for core dumps, dynamic SRIOV resource allocations for RoCE, and ethtool tunable for PFC watchdog.

Anantha Prabhu (1):
bnxt_en: Support for RoCE resources dynamically shared within VFs.

Kalesh AP (4):
bnxt_en: Drop redundant if block in bnxt_dl_flash_update()
bnxt_en: Remove unnecessary VF check in bnxt_hwrm_nvm_req()
bnxt_en: Optimize bnxt_sriov_disable()
bnxt_en: Use VLAN_ETH_HLEN when possible

Kashyap Desai (1):
bnxt_en: Add err_qpc backing store handling

Michael Chan (4):
bnxt_en: Improve bnxt_hwrm_func_backing_store_cfg_v2()
bnxt_en: Improve bnxt_backing_store_cfg_v2()
bnxt_en: Implement ethtool .get_tunable() for
ETHTOOL_PFC_PREVENTION_TOUT
bnxt_en: Implement ethtool .set_tunable() for
ETHTOOL_PFC_PREVENTION_TOUT

Shruti Parab (1):
bnxt_en: Add fw log trace support for 5731X/5741X chips

 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 65 ++++++++++++++-----
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  9 ++-
 .../ethernet/broadcom/bnxt/bnxt_coredump.c    |  4 +-
 .../ethernet/broadcom/bnxt/bnxt_coredump.h    |  2 +
 .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 13 ----
 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 45 ++++++++++++-
 .../net/ethernet/broadcom/bnxt/bnxt_sriov.c   | 21 +++++-
 .../net/ethernet/broadcom/bnxt/bnxt_sriov.h   |  2 +-
 include/linux/bnxt/hsi.h                      | 61 +++++++++++++++++
 9 files changed, 184 insertions(+), 38 deletions(-)
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH 1/11 bnxt_en: Drop redundant if block in bnxt_dl_flash_update()

From: Kalesh AP <[email protected]>

The devlink stack has sanity checks and it invokes flash_update() only if it is supported by the driver. The VF driver does not advertise the support for flash_update in struct devlink_ops. This makes if condition inside bnxt_dl_flash_update() redundant.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +0 -6
index 43fb75806cd6..d0f5507e85aa 100644
@@ -40,12 +40,6 @@ bnxt_dl_flash_update(struct devlink *dl,
 	struct bnxt *bp = bnxt_get_bp_from_dl(dl);
 	int rc;
 
-	if (!BNXT_PF(bp)) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "flash update not supported from a VF");
-		return -EPERM;
-	}
-
 	devlink_flash_update_status_notify(dl, "Preparing to flash", NULL, 0, 0);
 	rc = bnxt_flash_package_from_fw_obj(bp->dev, params->fw, 0, extack);
 	if (!rc)
Signature · 1 line
2.51.0
author maintainer
#2 lore raw

PATCH 2/11 bnxt_en: Remove unnecessary VF check in bnxt_hwrm_nvm_req()

In reply to Michael Chan

From: Kalesh AP <[email protected]>

The driver registers the supported configuration parameters with the devlink stack only on the PF using devlink_params_register(). Hence there is no need for a VF check inside bnxt_hwrm_nvm_req().

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +0 -7
index d0f5507e85aa..02961d93ed35 100644
@@ -1074,16 +1074,9 @@ static int __bnxt_hwrm_nvm_req(struct bnxt *bp,
 static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
 			     union devlink_param_value *val)
 {
-	struct hwrm_nvm_get_variable_input *req = msg;
 	const struct bnxt_dl_nvm_param *nvm_param;
 	int i;
 
-	/* Get/Set NVM CFG parameter is supported only on PFs */
-	if (BNXT_VF(bp)) {
-		hwrm_req_drop(bp, req);
-		return -EPERM;
-	}
-
 	for (i = 0; i < ARRAY_SIZE(nvm_params); i++) {
 		nvm_param = &nvm_params[i];
 		if (nvm_param->id == param_id)
Signature · 1 line
2.51.0
author maintainer
#3 lore raw

PATCH 3/11 bnxt_en: Optimize bnxt_sriov_disable()

In reply to Michael Chan

From: Kalesh AP <[email protected]>

bnxt_sriov_disable() is invoked from 2 places:

1. When the user deletes the VFs.
2. During the unload of the PF driver instance.

Inside bnxt_sriov_disable(), driver invokes bnxt_restore_pf_fw_resources() which in turn causes a close/open_nic(). There is no harm doing this in the unload path, although it is inefficient and unnecessary.

Optimize the function to make it more efficient.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c       |  2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 12 ++++++++++--
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
index 5f4f4d99f1e7..a74b50130cc0 100644
@@ -16156,7 +16156,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
 	struct bnxt *bp = netdev_priv(dev);
 
 	if (BNXT_PF(bp))
-		bnxt_sriov_disable(bp);
+		__bnxt_sriov_disable(bp);
 
 	bnxt_rdma_aux_device_del(bp);
 
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +10 -2
index 480e18a32caa..e7fbfeb1a387 100644
@@ -919,7 +919,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
 	return rc;
 }
 
-void bnxt_sriov_disable(struct bnxt *bp)
+void __bnxt_sriov_disable(struct bnxt *bp)
 {
 	u16 num_vfs = pci_num_vf(bp->pdev);
 
@@ -943,6 +943,14 @@ void bnxt_sriov_disable(struct bnxt *bp)
 	devl_unlock(bp->dl);
 
 	bnxt_free_vf_resources(bp);
+}
+
+static void bnxt_sriov_disable(struct bnxt *bp)
+{
+	if (!pci_num_vf(bp->pdev))
+		return;
+
+	__bnxt_sriov_disable(bp);
 
 	/* Reclaim all resources for the PF. */
 	rtnl_lock();
@@ -1321,7 +1329,7 @@ int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)
 	return 0;
 }
 
-void bnxt_sriov_disable(struct bnxt *bp)
+void __bnxt_sriov_disable(struct bnxt *bp)
 {
 }
 
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h +1 -1
index 9a4bacba477b..e4979d729312 100644
@@ -38,7 +38,7 @@ bool bnxt_is_trusted_vf(struct bnxt *bp, struct bnxt_vf_info *vf);
 int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trust);
 int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs);
 int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset);
-void bnxt_sriov_disable(struct bnxt *);
+void __bnxt_sriov_disable(struct bnxt *bp);
 void bnxt_hwrm_exec_fwd_req(struct bnxt *);
 void bnxt_update_vf_mac(struct bnxt *);
 int bnxt_approve_mac(struct bnxt *, const u8 *, bool);
Signature · 1 line
2.51.0
author maintainer
#4 lore raw

PATCH 4/11 bnxt_en: Improve bnxt_hwrm_func_backing_store_cfg_v2()

In reply to Michael Chan

Optimize the loop inside this function that sends the FW message to configure backing store memory for each instance of a memory type. It uses 2 loop counters i and j, but both counters advance at the same time so we can eliminate one of them.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -4
index a74b50130cc0..38a2884f7c78 100644
@@ -9098,7 +9098,7 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
 {
 	struct hwrm_func_backing_store_cfg_v2_input *req;
 	u32 instance_bmap = ctxm->instance_bmap;
-	int i, j, rc = 0, n = 1;
+	int i, rc = 0, n = 1;
 	__le32 *p;
 
 	if (!(ctxm->flags & BNXT_CTX_MEM_TYPE_VALID) || !ctxm->pg_info)
@@ -9128,20 +9128,20 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
 	req->subtype_valid_cnt = ctxm->split_entry_cnt;
 	for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++)
 		p[i] = cpu_to_le32(ctxm->split[i]);
-	for (i = 0, j = 0; j < n && !rc; i++) {
+	for (i = 0; i < n && !rc; i++) {
 		struct bnxt_ctx_pg_info *ctx_pg;
 
 		if (!(instance_bmap & (1 << i)))
 			continue;
 		req->instance = cpu_to_le16(i);
-		ctx_pg = &ctxm->pg_info[j++];
+		ctx_pg = &ctxm->pg_info[i];
 		if (!ctx_pg->entries)
 			continue;
 		req->num_entries = cpu_to_le32(ctx_pg->entries);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				      &req->page_size_pbl_level,
 				      &req->page_dir);
-		if (last && j == n)
+		if (last && i == n - 1)
 			req->flags =
 				cpu_to_le32(FUNC_BACKING_STORE_CFG_V2_REQ_FLAGS_BS_CFG_ALL_DONE);
 		rc = hwrm_req_send(bp, req);
Signature · 1 line
2.51.0
maintainer
#5 lore raw

Re: [PATCH net-next 04/11] bnxt_en: Improve bnxt_hwrm_func_backing_store_cfg_v2()

Quoted 4 lines · Michael Chan

Optimize the loop inside this function that sends the FW message to configure backing store memory for each instance of a memory type. It uses 2 loop counters i and j, but both counters advance at the same time so we can eliminate one of them.

The above statement does not look correct.

drivers/net/ethernet/broadcom/bnxt/bnxt.c static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp, · line 9137

Quoted 13 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -2
@@ -9128,20 +9128,20 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
 	req->subtype_valid_cnt = ctxm->split_entry_cnt;
 	for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++)
 		p[i] = cpu_to_le32(ctxm->split[i]);
-	for (i = 0, j = 0; j < n && !rc; i++) {
+	for (i = 0; i < n && !rc; i++) {
 		struct bnxt_ctx_pg_info *ctx_pg;
 
 		if (!(instance_bmap & (1 << i)))
 			continue;
 		req->instance = cpu_to_le16(i);
-		ctx_pg = &ctxm->pg_info[j++];
+		ctx_pg = &ctxm->pg_info[i];

j is incremented only for bit set in instance_bmap, AFAICS this does not introduces functional changes only if instance_bmap has all the bit set.

/P

author maintainer
#6 lore raw

Re: [PATCH net-next 04/11] bnxt_en: Improve bnxt_hwrm_func_backing_store_cfg_v2()

Quoted 17 lines · Paolo Abeni
Quoted 4 lines · Michael Chan

Optimize the loop inside this function that sends the FW message to configure backing store memory for each instance of a memory type. It uses 2 loop counters i and j, but both counters advance at the same time so we can eliminate one of them.

The above statement does not look correct.

Quoted 8 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
@@ -9128,20 +9128,20 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
      req->subtype_valid_cnt = ctxm->split_entry_cnt;
      for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++)
              p[i] = cpu_to_le32(ctxm->split[i]);
-     for (i = 0, j = 0; j < n && !rc; i++) {
+     for (i = 0; i < n && !rc; i++) {
              struct bnxt_ctx_pg_info *ctx_pg;
 
Quoted 10 lines

drivers/net/ethernet/broadcom/bnxt/bnxt.c static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp, · line 9137

Quoted 5 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
              if (!(instance_bmap & (1 << i)))
                      continue;
              req->instance = cpu_to_le16(i);
-             ctx_pg = &ctxm->pg_info[j++];
+             ctx_pg = &ctxm->pg_info[i];

j is incremented only for bit set in instance_bmap, AFAICS this does not introduces functional changes only if instance_bmap has all the bit set.

Yes, you are absolutely right. The original code will skip over zeros in the instance_bmap without incrementing j. Let me rethink this patch or drop this patch. Thanks for the review.

author maintainer
#7 lore raw

PATCH 5/11 bnxt_en: Improve bnxt_backing_store_cfg_v2()

In reply to Michael Chan

Improve the logic that determines the last_type in this function. The different context memory types are configured in a loop. The last_type signals the last context memory type to be configured which requires the ALL_DONE flag to be set for the FW.

The existing logic makes some assumptions that TIM is the last_type when RDMA is enabled or FTQM is the last_type when only L2 is enabled. Improve it to just search for the last_type so that we don't need to make these assumptions that won't necessary be true for future devices.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -7
index 38a2884f7c78..09cc58288e67 100644
@@ -9150,7 +9150,7 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
 	return rc;
 }
 
-static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
+static int bnxt_backing_store_cfg_v2(struct bnxt *bp)
 {
 	struct bnxt_ctx_mem_info *ctx = bp->ctx;
 	struct bnxt_ctx_mem_type *ctxm;
@@ -9176,12 +9176,13 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
 	}
 
 	if (last_type == BNXT_CTX_INV) {
-		if (!ena)
+		for (type = 0; type < BNXT_CTX_MAX; type++) {
+			ctxm = &ctx->ctx_arr[type];
+			if (ctxm->mem_valid)
+				last_type = type;
+		}
+		if (last_type == BNXT_CTX_INV)
 			return 0;
-		else if (ena & FUNC_BACKING_STORE_CFG_REQ_ENABLES_TIM)
-			last_type = BNXT_CTX_MAX - 1;
-		else
-			last_type = BNXT_CTX_L2_MAX - 1;
 	}
 	ctx->ctx_arr[last_type].last = 1;
 
@@ -9411,7 +9412,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
 	ena |= FUNC_BACKING_STORE_CFG_REQ_DFLT_ENABLES;
 
 	if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2)
-		rc = bnxt_backing_store_cfg_v2(bp, ena);
+		rc = bnxt_backing_store_cfg_v2(bp);
 	else
 		rc = bnxt_hwrm_func_backing_store_cfg(bp, ena);
 	if (rc) {
Signature · 1 line
2.51.0
author maintainer
#8 lore raw

PATCH 6/11 bnxt_en: Add fw log trace support for 5731X/5741X chips

In reply to Michael Chan

From: Shruti Parab <[email protected]>

These older chips now support the fw log traces via backing store qcaps_v2. No other backing store memory types are supported besides the fw trace types.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c          | 9 +++++++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h          | 3 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c | 3 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h | 1 +
 4 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -2
index 09cc58288e67..97165624acf5 100644
@@ -265,6 +265,7 @@ const u16 bnxt_bstore_to_trace[] = {
 	[BNXT_CTX_CA1]		= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_CA1_TRACE,
 	[BNXT_CTX_CA2]		= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_CA2_TRACE,
 	[BNXT_CTX_RIGP1]	= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_RIGP1_TRACE,
+	[BNXT_CTX_KONG]		= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_AFM_KONG_HWRM_TRACE,
 };
 
 static struct workqueue_struct *bnxt_pf_wq;
@@ -9158,7 +9159,7 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp)
 	int rc = 0;
 	u16 type;
 
-	for (type = BNXT_CTX_SRT; type <= BNXT_CTX_RIGP1; type++) {
+	for (type = BNXT_CTX_SRT; type <= BNXT_CTX_KONG; type++) {
 		ctxm = &ctx->ctx_arr[type];
 		if (!bnxt_bs_trace_avail(bp, type))
 			continue;
@@ -9309,6 +9310,10 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
 	if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED))
 		return 0;
 
+	ena = 0;
+	if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
+		goto skip_legacy;
+
 	ctxm = &ctx->ctx_arr[BNXT_CTX_QP];
 	l2_qps = ctxm->qp_l2_entries;
 	qp1_qps = ctxm->qp_qp1_entries;
@@ -9317,7 +9322,6 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
 	ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ];
 	srqs = ctxm->srq_l2_entries;
 	max_srqs = ctxm->max_entries;
-	ena = 0;
 	if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) {
 		pg_lvl = 2;
 		if (BNXT_SW_RES_LMT(bp)) {
@@ -9411,6 +9415,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
 		ena |= FUNC_BACKING_STORE_CFG_REQ_ENABLES_TQM_SP << i;
 	ena |= FUNC_BACKING_STORE_CFG_REQ_DFLT_ENABLES;
 
+skip_legacy:
 	if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2)
 		rc = bnxt_backing_store_cfg_v2(bp);
 	else
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -1
index 1bb2a5de88cd..37c3f6507250 100644
@@ -1968,10 +1968,11 @@ struct bnxt_ctx_mem_type {
 #define BNXT_CTX_CA1	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA1_TRACE
 #define BNXT_CTX_CA2	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA2_TRACE
 #define BNXT_CTX_RIGP1	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RIGP1_TRACE
+#define BNXT_CTX_KONG	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_AFM_KONG_HWRM_TRACE
 
 #define BNXT_CTX_MAX	(BNXT_CTX_TIM + 1)
 #define BNXT_CTX_L2_MAX	(BNXT_CTX_FTQM + 1)
-#define BNXT_CTX_V2_MAX	(BNXT_CTX_RIGP1 + 1)
+#define BNXT_CTX_V2_MAX	(BNXT_CTX_KONG + 1)
 #define BNXT_CTX_INV	((u16)-1)
 
 struct bnxt_ctx_mem_info {
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +2 -1
index 18d6c94d5cb8..a0a37216efb3 100644
@@ -36,6 +36,7 @@ static const u16 bnxt_bstore_to_seg_id[] = {
 	[BNXT_CTX_CA1]			= BNXT_CTX_MEM_SEG_CA1,
 	[BNXT_CTX_CA2]			= BNXT_CTX_MEM_SEG_CA2,
 	[BNXT_CTX_RIGP1]		= BNXT_CTX_MEM_SEG_RIGP1,
+	[BNXT_CTX_KONG]			= BNXT_CTX_MEM_SEG_KONG,
 };
 
 static int bnxt_dbg_hwrm_log_buffer_flush(struct bnxt *bp, u16 type, u32 flags,
@@ -359,7 +360,7 @@ static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset,
 
 	if (buf)
 		buf += offset;
-	for (type = 0 ; type <= BNXT_CTX_RIGP1; type++) {
+	for (type = 0; type <= BNXT_CTX_KONG; type++) {
 		struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
 		bool trace = bnxt_bs_trace_avail(bp, type);
 		u32 seg_id = bnxt_bstore_to_seg_id[type];
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h +1 -0
index d1cd6387f3ab..8d0f58c74cc3 100644
@@ -102,6 +102,7 @@ struct bnxt_driver_segment_record {
 #define BNXT_CTX_MEM_SEG_CA1	0x9
 #define BNXT_CTX_MEM_SEG_CA2	0xa
 #define BNXT_CTX_MEM_SEG_RIGP1	0xb
+#define BNXT_CTX_MEM_SEG_KONG	0xd
 
 #define BNXT_CRASH_DUMP_LEN	(8 << 20)
 
Signature · 1 line
2.51.0
author maintainer
#9 lore raw

PATCH 7/11 bnxt_en: Add err_qpc backing store handling

In reply to Michael Chan

From: Kashyap Desai <[email protected]>

New backing store component err_qpc is added to the existing host logging interface for FW traces.

Allocate the backing store memory if this memory type is supported. Copy this memory when collecting the coredump.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c          | 3 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h          | 3 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c | 3 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h | 1 +
 4 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -1
index 97165624acf5..dba3966c1ebd 100644
@@ -266,6 +266,7 @@ const u16 bnxt_bstore_to_trace[] = {
 	[BNXT_CTX_CA2]		= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_CA2_TRACE,
 	[BNXT_CTX_RIGP1]	= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_RIGP1_TRACE,
 	[BNXT_CTX_KONG]		= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_AFM_KONG_HWRM_TRACE,
+	[BNXT_CTX_QPC]		= DBG_LOG_BUFFER_FLUSH_REQ_TYPE_ERR_QPC_TRACE,
 };
 
 static struct workqueue_struct *bnxt_pf_wq;
@@ -9159,7 +9160,7 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp)
 	int rc = 0;
 	u16 type;
 
-	for (type = BNXT_CTX_SRT; type <= BNXT_CTX_KONG; type++) {
+	for (type = BNXT_CTX_SRT; type <= BNXT_CTX_QPC; type++) {
 		ctxm = &ctx->ctx_arr[type];
 		if (!bnxt_bs_trace_avail(bp, type))
 			continue;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -1
index 37c3f6507250..57a1af40cc19 100644
@@ -1969,10 +1969,11 @@ struct bnxt_ctx_mem_type {
 #define BNXT_CTX_CA2	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA2_TRACE
 #define BNXT_CTX_RIGP1	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RIGP1_TRACE
 #define BNXT_CTX_KONG	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_AFM_KONG_HWRM_TRACE
+#define BNXT_CTX_QPC	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_ERR_QPC_TRACE
 
 #define BNXT_CTX_MAX	(BNXT_CTX_TIM + 1)
 #define BNXT_CTX_L2_MAX	(BNXT_CTX_FTQM + 1)
-#define BNXT_CTX_V2_MAX	(BNXT_CTX_KONG + 1)
+#define BNXT_CTX_V2_MAX (BNXT_CTX_QPC + 1)
 #define BNXT_CTX_INV	((u16)-1)
 
 struct bnxt_ctx_mem_info {
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +2 -1
index a0a37216efb3..0181ab1f2dfd 100644
@@ -37,6 +37,7 @@ static const u16 bnxt_bstore_to_seg_id[] = {
 	[BNXT_CTX_CA2]			= BNXT_CTX_MEM_SEG_CA2,
 	[BNXT_CTX_RIGP1]		= BNXT_CTX_MEM_SEG_RIGP1,
 	[BNXT_CTX_KONG]			= BNXT_CTX_MEM_SEG_KONG,
+	[BNXT_CTX_QPC]			= BNXT_CTX_MEM_SEG_QPC,
 };
 
 static int bnxt_dbg_hwrm_log_buffer_flush(struct bnxt *bp, u16 type, u32 flags,
@@ -360,7 +361,7 @@ static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset,
 
 	if (buf)
 		buf += offset;
-	for (type = 0; type <= BNXT_CTX_KONG; type++) {
+	for (type = 0; type < BNXT_CTX_V2_MAX; type++) {
 		struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
 		bool trace = bnxt_bs_trace_avail(bp, type);
 		u32 seg_id = bnxt_bstore_to_seg_id[type];
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h +1 -0
index 8d0f58c74cc3..c087df88154a 100644
@@ -102,6 +102,7 @@ struct bnxt_driver_segment_record {
 #define BNXT_CTX_MEM_SEG_CA1	0x9
 #define BNXT_CTX_MEM_SEG_CA2	0xa
 #define BNXT_CTX_MEM_SEG_RIGP1	0xb
+#define BNXT_CTX_MEM_SEG_QPC	0xc
 #define BNXT_CTX_MEM_SEG_KONG	0xd
 
 #define BNXT_CRASH_DUMP_LEN	(8 << 20)
Signature · 1 line
2.51.0
author maintainer
#10 lore raw

PATCH 8/11 bnxt_en: Support for RoCE resources dynamically shared within VFs.

In reply to Michael Chan

From: Anantha Prabhu <[email protected]>

Add support for dynamic RoCE SRIOV resource configuration. Instead of statically dividing the RoCE resources by the number of VFs, provide the maximum resources and let the FW dynamically dsitribute to the VFs on the fly.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c       | 8 ++++++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h       | 3 +++
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 +++++++
 3 files changed, 16 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
index dba3966c1ebd..207a74450e38 100644
@@ -9632,10 +9632,10 @@ static int __bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
 
 static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 {
+	u32 flags, flags_ext, flags_ext2, flags_ext3;
+	struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
 	struct hwrm_func_qcaps_output *resp;
 	struct hwrm_func_qcaps_input *req;
-	struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
-	u32 flags, flags_ext, flags_ext2;
 	int rc;
 
 	rc = hwrm_req_init(bp, req, HWRM_FUNC_QCAPS);
@@ -9702,6 +9702,10 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	    (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_ROCE_VF_RESOURCE_MGMT_SUPPORTED))
 		bp->fw_cap |= BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED;
 
+	flags_ext3 = le32_to_cpu(resp->flags_ext3);
+	if (flags_ext3 & FUNC_QCAPS_RESP_FLAGS_EXT3_ROCE_VF_DYN_ALLOC_SUPPORT)
+		bp->fw_cap |= BNXT_FW_CAP_ROCE_VF_DYN_ALLOC_SUPPORT;
+
 	bp->tx_push_thresh = 0;
 	if ((flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED) &&
 	    BNXT_FW_MAJ(bp) > 217)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +3 -0
index 57a1af40cc19..c0f46eaf91c0 100644
@@ -2479,6 +2479,7 @@ struct bnxt {
 	#define BNXT_FW_CAP_ENABLE_RDMA_SRIOV           BIT_ULL(5)
 	#define BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED	BIT_ULL(6)
 	#define BNXT_FW_CAP_KONG_MB_CHNL		BIT_ULL(7)
+	#define BNXT_FW_CAP_ROCE_VF_DYN_ALLOC_SUPPORT	BIT_ULL(8)
 	#define BNXT_FW_CAP_OVS_64BIT_HANDLE		BIT_ULL(10)
 	#define BNXT_FW_CAP_TRUSTED_VF			BIT_ULL(11)
 	#define BNXT_FW_CAP_ERROR_RECOVERY		BIT_ULL(13)
@@ -2523,6 +2524,8 @@ struct bnxt {
 #define BNXT_SUPPORTS_MULTI_RSS_CTX(bp)				\
 	(BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) &&	\
 	 ((bp)->rss_cap & BNXT_RSS_CAP_MULTI_RSS_CTX))
+#define BNXT_ROCE_VF_DYN_ALLOC_CAP(bp)				\
+	((bp)->fw_cap & BNXT_FW_CAP_ROCE_VF_DYN_ALLOC_SUPPORT)
 #define BNXT_SUPPORTS_QUEUE_API(bp)				\
 	(BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) &&	\
 	 ((bp)->fw_cap & BNXT_FW_CAP_VNIC_RE_FLUSH))
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +7 -0
index e7fbfeb1a387..1d8df44c3f9e 100644
@@ -541,6 +541,13 @@ static void bnxt_hwrm_roce_sriov_cfg(struct bnxt *bp, int num_vfs)
 	if (rc)
 		goto err;
 
+	/* In case of VF Dynamic resource allocation, driver will provision
+	 * maximum resources to all the VFs. FW will dynamically allocate
+	 * resources to VFs on the fly, so always divide the resources by 1.
+	 */
+	if (BNXT_ROCE_VF_DYN_ALLOC_CAP(bp))
+		num_vfs = 1;
+
 	cfg_req->fid = cpu_to_le16(0xffff);
 	cfg_req->enables2 =
 		cpu_to_le32(FUNC_CFG_REQ_ENABLES2_ROCE_MAX_AV_PER_VF |
Signature · 1 line
2.51.0
author maintainer
#11 lore raw

PATCH 9/11 bnxt_en: Use VLAN_ETH_HLEN when possible

In reply to Michael Chan

From: Kalesh AP <[email protected]>

Replace ETH_HLEN + VLAN_HLEN with VLAN_ETH_HLEN. Cosmetic change and no functional changes intended.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c       | 4 ++--
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -2
index 207a74450e38..f63e5dd429db 100644
@@ -6838,7 +6838,7 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	req->dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id);
 	req->lb_rule = cpu_to_le16(0xffff);
 vnic_mru:
-	vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN;
+	vnic->mru = bp->dev->mtu + VLAN_ETH_HLEN;
 	req->mru = cpu_to_le16(vnic->mru);
 
 	req->vnic_id = cpu_to_le16(vnic->fw_vnic_id);
@@ -16086,7 +16086,7 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
 	napi_enable_locked(&bnapi->napi);
 	bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons);
 
-	mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN;
+	mru = bp->dev->mtu + VLAN_ETH_HLEN;
 	for (i = 0; i < bp->nr_vnics; i++) {
 		vnic = &bp->vnic_info[i];
 
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +1 -1
index 1d8df44c3f9e..80fed2c07b9e 100644
@@ -741,7 +741,7 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
 				   FUNC_CFG_REQ_ENABLES_NUM_VNICS |
 				   FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS);
 
-	mtu = bp->dev->mtu + ETH_HLEN + VLAN_HLEN;
+	mtu = bp->dev->mtu + VLAN_ETH_HLEN;
 	req->mru = cpu_to_le16(mtu);
 	req->admin_mtu = cpu_to_le16(mtu);
 
Signature · 1 line
2.51.0
author maintainer
#12 lore raw

PATCH 10/11 bnxt_en: Implement ethtool .get_tunable() for ETHTOOL_PFC_PREVENTION_TOUT

In reply to Michael Chan

Return the current PFC watchdog timeout value if it is supported.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 18 +++++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  2 +
 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 21 ++++++++++
 include/linux/bnxt/hsi.h                      | 40 +++++++++++++++++++
 4 files changed, 81 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +18 -0
index f63e5dd429db..47579dc7e080 100644
@@ -14748,6 +14748,23 @@ static bool bnxt_fw_pre_resv_vnics(struct bnxt *bp)
 	return false;
 }
 
+static void bnxt_hwrm_pfcwd_qcaps(struct bnxt *bp)
+{
+	struct hwrm_queue_pfcwd_timeout_qcaps_output *resp;
+	struct hwrm_queue_pfcwd_timeout_qcaps_input *req;
+	int rc;
+
+	bp->max_pfcwd_tmo_ms = 0;
+	rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCWD_TIMEOUT_QCAPS);
+	if (rc)
+		return;
+	resp = hwrm_req_hold(bp, req);
+	rc = hwrm_req_send_silent(bp, req);
+	if (!rc)
+		bp->max_pfcwd_tmo_ms = le16_to_cpu(resp->max_pfcwd_timeout);
+	hwrm_req_drop(bp, req);
+}
+
 static int bnxt_fw_init_one_p1(struct bnxt *bp)
 {
 	int rc;
@@ -14825,6 +14842,7 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp)
 	if (bnxt_fw_pre_resv_vnics(bp))
 		bp->fw_cap |= BNXT_FW_CAP_PRE_RESV_VNICS;
 
+	bnxt_hwrm_pfcwd_qcaps(bp);
 	bnxt_hwrm_func_qcfg(bp);
 	bnxt_hwrm_vnic_qcaps(bp);
 	bnxt_hwrm_port_led_qcaps(bp);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
index c0f46eaf91c0..06a4c2afdf8a 100644
@@ -2426,6 +2426,8 @@ struct bnxt {
 	u8			max_q;
 	u8			num_tc;
 
+	u16			max_pfcwd_tmo_ms;
+
 	u8			tph_mode;
 
 	unsigned int		current_interval;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +21 -0
index 2830a2b17a27..d94a8a2bf0f9 100644
@@ -4399,6 +4399,23 @@ static int bnxt_get_eee(struct net_device *dev, struct ethtool_keee *edata)
 	return 0;
 }
 
+static int bnxt_hwrm_pfcwd_qcfg(struct bnxt *bp, u16 *val)
+{
+	struct hwrm_queue_pfcwd_timeout_qcfg_output *resp;
+	struct hwrm_queue_pfcwd_timeout_qcfg_input *req;
+	int rc;
+
+	rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCWD_TIMEOUT_QCFG);
+	if (rc)
+		return rc;
+	resp = hwrm_req_hold(bp, req);
+	rc = hwrm_req_send(bp, req);
+	if (!rc)
+		*val = le16_to_cpu(resp->pfcwd_timeout_value);
+	hwrm_req_drop(bp, req);
+	return rc;
+}
+
 static int bnxt_set_tunable(struct net_device *dev,
 			    const struct ethtool_tunable *tuna,
 			    const void *data)
@@ -4431,6 +4448,10 @@ static int bnxt_get_tunable(struct net_device *dev,
 	case ETHTOOL_RX_COPYBREAK:
 		*(u32 *)data = bp->rx_copybreak;
 		break;
+	case ETHTOOL_PFC_PREVENTION_TOUT:
+		if (!bp->max_pfcwd_tmo_ms)
+			return -EOPNOTSUPP;
+		return bnxt_hwrm_pfcwd_qcfg(bp, data);
 	default:
 		return -EOPNOTSUPP;
 	}
include/linux/bnxt/hsi.h +40 -0
index 8c5dac3b3ef3..23e7b1290a92 100644
@@ -6751,6 +6751,46 @@ struct hwrm_queue_dscp2pri_cfg_output {
 	u8	valid;
 };
 
+/* hwrm_queue_pfcwd_timeout_qcaps_input (size:128b/16B) */
+struct hwrm_queue_pfcwd_timeout_qcaps_input {
+	__le16	req_type;
+	__le16	cmpl_ring;
+	__le16	seq_id;
+	__le16	target_id;
+	__le64	resp_addr;
+};
+
+/* hwrm_queue_pfcwd_timeout_qcaps_output (size:128b/16B) */
+struct hwrm_queue_pfcwd_timeout_qcaps_output {
+	__le16	error_code;
+	__le16	req_type;
+	__le16	seq_id;
+	__le16	resp_len;
+	__le16	max_pfcwd_timeout;
+	u8	unused_0[5];
+	u8	valid;
+};
+
+/* hwrm_queue_pfcwd_timeout_qcfg_input (size:128b/16B) */
+struct hwrm_queue_pfcwd_timeout_qcfg_input {
+	__le16	req_type;
+	__le16	cmpl_ring;
+	__le16	seq_id;
+	__le16	target_id;
+	__le64	resp_addr;
+};
+
+/* hwrm_queue_pfcwd_timeout_qcfg_output (size:128b/16B) */
+struct hwrm_queue_pfcwd_timeout_qcfg_output {
+	__le16	error_code;
+	__le16	req_type;
+	__le16	seq_id;
+	__le16	resp_len;
+	__le16	pfcwd_timeout_value;
+	u8	unused_0[5];
+	u8	valid;
+};
+
 /* hwrm_vnic_alloc_input (size:192b/24B) */
 struct hwrm_vnic_alloc_input {
 	__le16	req_type;
Signature · 1 line
2.51.0
author maintainer
#13 lore raw

PATCH 11/11 bnxt_en: Implement ethtool .set_tunable() for ETHTOOL_PFC_PREVENTION_TOUT

In reply to Michael Chan

Support the setting of the tunable if it is supported by firmware. The supported range is 0 to the maximum msec value reported by firmware. PFC_STORM_PREVENTION_AUTO is also supported and 0 means it is disabled.

---
 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 24 ++++++++++++++++++-
 include/linux/bnxt/hsi.h                      | 21 ++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +23 -1
index d94a8a2bf0f9..be32ef8f5c96 100644
@@ -4416,12 +4416,25 @@ static int bnxt_hwrm_pfcwd_qcfg(struct bnxt *bp, u16 *val)
 	return rc;
 }
 
+static int bnxt_hwrm_pfcwd_cfg(struct bnxt *bp, u16 val)
+{
+	struct hwrm_queue_pfcwd_timeout_cfg_input *req;
+	int rc;
+
+	rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCWD_TIMEOUT_CFG);
+	if (rc)
+		return rc;
+	req->pfcwd_timeout_value = cpu_to_le16(val);
+	rc = hwrm_req_send(bp, req);
+	return rc;
+}
+
 static int bnxt_set_tunable(struct net_device *dev,
 			    const struct ethtool_tunable *tuna,
 			    const void *data)
 {
 	struct bnxt *bp = netdev_priv(dev);
-	u32 rx_copybreak;
+	u32 rx_copybreak, val;
 
 	switch (tuna->id) {
 	case ETHTOOL_RX_COPYBREAK:
@@ -4434,6 +4447,15 @@ static int bnxt_set_tunable(struct net_device *dev,
 			bp->rx_copybreak = rx_copybreak;
 		}
 		return 0;
+	case ETHTOOL_PFC_PREVENTION_TOUT:
+		if (BNXT_VF(bp) || !bp->max_pfcwd_tmo_ms)
+			return -EOPNOTSUPP;
+
+		val = *(u16 *)data;
+		if (val > bp->max_pfcwd_tmo_ms &&
+		    val != PFC_STORM_PREVENTION_AUTO)
+			return -EINVAL;
+		return bnxt_hwrm_pfcwd_cfg(bp, val);
 	default:
 		return -EOPNOTSUPP;
 	}
include/linux/bnxt/hsi.h +21 -0
index 23e7b1290a92..47c34990cf23 100644
@@ -6771,6 +6771,27 @@ struct hwrm_queue_pfcwd_timeout_qcaps_output {
 	u8	valid;
 };
 
+/* hwrm_queue_pfcwd_timeout_cfg_input (size:192b/24B) */
+struct hwrm_queue_pfcwd_timeout_cfg_input {
+	__le16	req_type;
+	__le16	cmpl_ring;
+	__le16	seq_id;
+	__le16	target_id;
+	__le64	resp_addr;
+	__le16	pfcwd_timeout_value;
+	u8	unused_0[6];
+};
+
+/* hwrm_queue_pfcwd_timeout_cfg_output (size:128b/16B) */
+struct hwrm_queue_pfcwd_timeout_cfg_output {
+	__le16	error_code;
+	__le16	req_type;
+	__le16	seq_id;
+	__le16	resp_len;
+	u8	unused_0[7];
+	u8	valid;
+};
+
 /* hwrm_queue_pfcwd_timeout_qcfg_input (size:128b/16B) */
 struct hwrm_queue_pfcwd_timeout_qcfg_input {
 	__le16	req_type;
Signature · 1 line
2.51.0