1
0
mirror of https://git.FreeBSD.org/src.git synced 2026-06-02 11:24:32 +00:00

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
This commit is contained in:
Chandrakanth Patil
2026-04-26 23:41:31 +05:30
committed by Sumit Saxena
parent c972c5acba
commit 7c450d1127
4 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -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) & \
+16 -15
View File
@@ -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)
-1
View File
@@ -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 {
+2 -2
View File
@@ -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;