Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Apr 2026 06:45:04 +0000
Message-ID:  <69f05770.264fc.5860a40d@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by ssaxena:

URL: https://cgit.FreeBSD.org/src/commit/?id=7c450d1127c7f08361f848c0ac57189910da8d3b

commit 7c450d1127c7f08361f848c0ac57189910da8d3b
Author:     Chandrakanth Patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2026-04-26 18:11:31 +0000
Commit:     Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2026-04-28 06:37:06 +0000

    bnxt_en: Address review comments for core SR-IOV support
    
    This patch addresses the code review comments provided for:
    https://reviews.freebsd.org/D56197
    
    * P7 VF PCI ID: rename NETXTREME_E_P7_VF to E_P7_VF (P7/Thor2 line drops the
      Netxtreme name in product strings; other VF device IDs are unchanged).
    * Use the return value of bnxt_vf_parse_schema() in bnxt_iov_vf_add() to
      decide when to call bnxt_set_vf_admin_mac(); make parse_schema() return
      bool and remove the has_admin_mac field.
    * In bnxt_free_vf_resources(), fix indentation after dma_free_coherent() so
      the NULL assignment is clearly separate from the call.
    * In bnxt_hwrm_func_vf_resource_free(), use first_vf_id/last_vf_id in the
      HWRM_FUNC_VF_RESC_FREE loop.
    
    MFC after:      1 month
    Reviewed by:    ssaxena
    Differential Revision: https://reviews.freebsd.org/D56644
---
 sys/dev/bnxt/bnxt_en/bnxt.h       |  2 +-
 sys/dev/bnxt/bnxt_en/bnxt_sriov.c | 31 ++++++++++++++++---------------
 sys/dev/bnxt/bnxt_en/bnxt_sriov.h |  1 -
 sys/dev/bnxt/bnxt_en/if_bnxt.c    |  4 ++--
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h
index 6d00cd4d601d..b15cc65e290e 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt.h
@@ -107,7 +107,7 @@
 #define NETXTREME_E_P5_VF2	0x1807
 #define NETXTREME_E_P5_VF_HV1	0x1808
 #define NETXTREME_E_P5_VF_HV2	0x1809
-#define NETXTREME_E_P7_VF	0x1819
+#define E_P7_VF	0x1819
 
 #define EVENT_DATA1_RESET_NOTIFY_FATAL(data1)				\
 	(((data1) &							\
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_sriov.c b/sys/dev/bnxt/bnxt_en/bnxt_sriov.c
index 2aeefd9308fb..270c18165fb7 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_sriov.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_sriov.c
@@ -30,7 +30,7 @@ bnxt_set_vf_admin_mac(struct bnxt_softc *softc, struct bnxt_vf_info *vf,
 	return (rc);
 }
 
-static void
+static bool
 bnxt_vf_parse_schema(struct bnxt_softc *softc, struct bnxt_vf_info *vf,
 		     const nvlist_t *params)
 {
@@ -41,7 +41,7 @@ bnxt_vf_parse_schema(struct bnxt_softc *softc, struct bnxt_vf_info *vf,
 	memset(vf->vf_mac_addr, 0, ETHER_ADDR_LEN);
 
 	if (params == NULL)
-		return;
+		return (false);
 
 	if (nvlist_exists(params, "mac-anti-spoof"))
 		vf->spoofchk = nvlist_get_bool(params, "mac-anti-spoof");
@@ -49,18 +49,18 @@ bnxt_vf_parse_schema(struct bnxt_softc *softc, struct bnxt_vf_info *vf,
 		vf->trusted = nvlist_get_bool(params, "trust");
 
 	if (!nvlist_exists(params, "mac-addr"))
-		return;
+		return (false);
 
 	mac = nvlist_get_binary(params, "mac-addr", &maclen);
 
 	if (maclen != ETHER_ADDR_LEN)
-		return;
+		return (false);
 
 	if (!is_valid_ether_addr(mac))
-		return;
+		return (false);
 
 	memcpy(vf->mac_addr, mac, ETHER_ADDR_LEN);
-	vf->has_admin_mac = true;
+	return (true);
 }
 
 /* Add a Virtual Functions */
@@ -74,13 +74,10 @@ bnxt_iov_vf_add(if_ctx_t ctx, uint16_t vfnum, const nvlist_t *params)
 	vf->fw_fid = softc->pf.first_vf_id + vfnum;
 	vf->vfnum = vfnum;
 
-	/* Parse schema */
-	bnxt_vf_parse_schema(softc, vf, params);
-
 	/*
-	 * If user provided MAC, program it into firmware.
+	 * If the schema provided a valid admin MAC, program it into firmware.
 	 */
-	if (vf->has_admin_mac) {
+	if (bnxt_vf_parse_schema(softc, vf, params)) {
 		rc = bnxt_set_vf_admin_mac(softc, vf, vf->mac_addr);
 		if (rc)
 			device_printf(softc->dev,
@@ -113,9 +110,9 @@ void bnxt_free_vf_resources(struct bnxt_softc *softc)
 	for (i = 0; i < softc->pf.hwrm_cmd_req_pages; i++) {
 		if (softc->pf.hwrm_cmd_req_addr[i]) {
 			dma_free_coherent(&softc->pdev->dev, page_size,
-					  softc->pf.hwrm_cmd_req_addr[i],
-					  softc->pf.hwrm_cmd_req_dma_addr[i]);
-					  softc->pf.hwrm_cmd_req_addr[i] = NULL;
+			    softc->pf.hwrm_cmd_req_addr[i],
+			    softc->pf.hwrm_cmd_req_dma_addr[i]);
+			softc->pf.hwrm_cmd_req_addr[i] = NULL;
 		}
 	}
 }
@@ -125,12 +122,16 @@ int
 bnxt_hwrm_func_vf_resource_free(struct bnxt_softc *softc, int num_vfs)
 {
 	int i, rc;
+	int first_vf_id, last_vf_id;
 	struct hwrm_func_vf_resc_free_input req;
 
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_VF_RESC_FREE);
 
+	first_vf_id = softc->pf.first_vf_id;
+	last_vf_id = first_vf_id + num_vfs - 1;
+
 	BNXT_HWRM_LOCK(softc);
-	for (i = softc->pf.first_vf_id; i < softc->pf.first_vf_id + num_vfs; i++) {
+	for (i = first_vf_id; i <= last_vf_id; i++) {
 		req.vf_id = cpu_to_le16(i);
 		rc = _hwrm_send_message(softc, &req, sizeof(req));
 		if (rc)
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_sriov.h b/sys/dev/bnxt/bnxt_en/bnxt_sriov.h
index c0c3d2d70b08..176f54af0aa8 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_sriov.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt_sriov.h
@@ -81,7 +81,6 @@ struct bnxt_vf_info {
 	struct		iflib_dma_info	hwrm_cmd_req;
 	uint16_t	trusted;
 	bool		spoofchk;
-	bool		has_admin_mac;
 };
 
 struct bnxt_resc_map {
diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c
index 80ca53db4782..6618016f3932 100644
--- a/sys/dev/bnxt/bnxt_en/if_bnxt.c
+++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c
@@ -180,7 +180,7 @@ static const pci_vendor_info_t bnxt_vendor_info_array[] =
 	"Broadcom NetXtreme-C Virtual Function for Hyper-V"),
     PVID(BROADCOM_VENDOR_ID, NETXTREME_E_P5_VF_HV2,
 	"Broadcom NetXtreme-C Virtual Function for Hyper-V"),
-    PVID(BROADCOM_VENDOR_ID, NETXTREME_E_P7_VF,
+    PVID(BROADCOM_VENDOR_ID, E_P7_VF,
 	"Broadcom BCM5760X Virtual Function"),
     /* required last entry */
 
@@ -479,7 +479,7 @@ bnxt_is_vf_device(uint16_t device_id)
 	case NETXTREME_E_P5_VF2:
 	case NETXTREME_E_P5_VF_HV1:
 	case NETXTREME_E_P5_VF_HV2:
-	case NETXTREME_E_P7_VF:
+	case E_P7_VF:
 		return true;
 	default:
 		return false;


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f05770.264fc.5860a40d>