Page MenuHomeFreeBSD

D58738.1795478143.diff
No OneTemporary

Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None

D58738.1795478143.diff

Index: sys/dev/bnxt/bnxt_en/bnxt_sriov.h
===================================================================
--- sys/dev/bnxt/bnxt_en/bnxt_sriov.h
+++ sys/dev/bnxt/bnxt_en/bnxt_sriov.h
@@ -77,6 +77,7 @@
struct iflib_dma_info hwrm_cmd_req;
uint16_t trusted;
bool spoofchk;
+ bool configured;
};
struct bnxt_resc_map {
@@ -92,6 +93,7 @@
int bnxt_iov_init(if_ctx_t ctx, uint16_t num_vfs, const nvlist_t *params);
void bnxt_iov_uninit(if_ctx_t ctx);
int bnxt_iov_vf_add(if_ctx_t ctx, uint16_t vfnum, const nvlist_t *params);
+int bnxt_vf_status(if_ctx_t ctx, nvlist_t *status);
int bnxt_hwrm_func_vf_resource_free(struct bnxt_softc *softc, int num_vfs);
void bnxt_free_vf_resources(struct bnxt_softc *softc);
int bnxt_create_trusted_vf_sysctls(struct bnxt_softc *softc, uint16_t num_vfs);
Index: sys/dev/bnxt/bnxt_en/bnxt_sriov.c
===================================================================
--- sys/dev/bnxt/bnxt_en/bnxt_sriov.c
+++ sys/dev/bnxt/bnxt_en/bnxt_sriov.c
@@ -71,28 +71,116 @@
{
struct bnxt_softc *softc = iflib_get_softc(ctx);
struct bnxt_vf_info *vf = &softc->pf.vf[vfnum];
+ uint8_t admin_mac[ETHER_ADDR_LEN];
+ bool has_admin_mac;
int rc;
+ BNXT_SRIOV_LOCK(softc);
vf->fw_fid = softc->pf.first_vf_id + vfnum;
vf->vfnum = vfnum;
+ has_admin_mac = bnxt_vf_parse_schema(softc, vf, params);
+ memcpy(admin_mac, vf->mac_addr, sizeof(admin_mac));
+ BNXT_SRIOV_UNLOCK(softc);
/*
* If the schema provided a valid admin MAC, program it into firmware.
*/
- if (bnxt_vf_parse_schema(softc, vf, params)) {
- rc = bnxt_set_vf_admin_mac(softc, vf, vf->mac_addr);
- if (rc)
+ if (has_admin_mac) {
+ rc = bnxt_set_vf_admin_mac(softc, vf, admin_mac);
+ if (rc) {
device_printf(softc->dev,
"vf%u: PF-assigned MAC programming failed (rc=%d), falling back to firmware/default MAC\n",
vfnum, rc);
+ BNXT_SRIOV_LOCK(softc);
+ memset(vf->mac_addr, 0, ETHER_ADDR_LEN);
+ BNXT_SRIOV_UNLOCK(softc);
+ }
}
(void)bnxt_set_vf_trust(softc, vfnum, vf->trusted);
(void)bnxt_set_vf_spoofchk(softc, vfnum, vf->spoofchk);
+ BNXT_SRIOV_LOCK(softc);
+ if (softc->pf.num_vfs != 0 && vfnum < softc->pf.num_vfs)
+ softc->pf.vf[vfnum].configured = true;
+ BNXT_SRIOV_UNLOCK(softc);
+
return 0;
}
+int
+bnxt_vf_status(if_ctx_t ctx, nvlist_t *status)
+{
+ struct bnxt_vf_status {
+ u8 mac[ETHER_ADDR_LEN];
+ u16 num_queues;
+ bool configured;
+ bool allow_set_mac;
+ bool mac_anti_spoof;
+ bool allow_promisc;
+ } snapshot[BNXT_MAX_VFS];
+ struct bnxt_softc *softc;
+ struct bnxt_vf_info *vf;
+ nvlist_t **vfs;
+ u16 num_vfs;
+ int error, i;
+
+ softc = iflib_get_softc(ctx);
+ BNXT_SRIOV_LOCK(softc);
+ num_vfs = softc->pf.num_vfs;
+ if (num_vfs == 0) {
+ BNXT_SRIOV_UNLOCK(softc);
+ return (ENXIO);
+ }
+ MPASS(num_vfs <= BNXT_MAX_VFS);
+ memset(snapshot, 0, sizeof(snapshot));
+ for (i = 0; i < num_vfs; i++) {
+ vf = &softc->pf.vf[i];
+ if (is_valid_ether_addr(vf->mac_addr))
+ memcpy(snapshot[i].mac, vf->mac_addr, ETHER_ADDR_LEN);
+ else if (is_valid_ether_addr(vf->vf_mac_addr))
+ memcpy(snapshot[i].mac, vf->vf_mac_addr,
+ ETHER_ADDR_LEN);
+ snapshot[i].num_queues = vf->min_rx_rings;
+ snapshot[i].configured = vf->configured;
+ snapshot[i].allow_set_mac =
+ (vf->flags & BNXT_VF_TRUST) != 0 ||
+ !is_valid_ether_addr(vf->mac_addr);
+ snapshot[i].mac_anti_spoof =
+ (vf->flags & BNXT_VF_SPOOFCHK) != 0;
+ snapshot[i].allow_promisc =
+ (vf->flags & BNXT_VF_TRUST) != 0;
+ }
+ BNXT_SRIOV_UNLOCK(softc);
+
+ vfs = mallocarray(num_vfs, sizeof(*vfs), M_DEVBUF,
+ M_WAITOK | M_ZERO);
+ for (i = 0; i < num_vfs; i++) {
+ vfs[i] = nvlist_create(0);
+ nvlist_add_number(vfs[i], IFVF_STATUS_INDEX, i);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_CONFIGURED,
+ snapshot[i].configured);
+ nvlist_add_binary(vfs[i], IFVF_STATUS_MAC, snapshot[i].mac,
+ ETHER_ADDR_LEN);
+ if (snapshot[i].num_queues != 0)
+ nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES,
+ snapshot[i].num_queues);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_MAC,
+ snapshot[i].allow_set_mac);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_MAC_ANTI_SPOOF,
+ snapshot[i].mac_anti_spoof);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_PROMISC,
+ snapshot[i].allow_promisc);
+ }
+ nvlist_add_nvlist_array(status, IFVF_STATUS_VFS,
+ (const nvlist_t * const *)vfs, num_vfs);
+ error = nvlist_error(status);
+ for (i = 0; i < num_vfs; i++)
+ nvlist_destroy(vfs[i]);
+ free(vfs, M_DEVBUF);
+ return (error);
+}
+
/* Free driver-side VF resources (called after hwrm_vf_resc_free) */
void bnxt_free_vf_resources(struct bnxt_softc *softc)
{
@@ -363,7 +451,8 @@
}
static int
-bnxt_hwrm_set_trusted_vf(struct bnxt_softc *softc, struct bnxt_vf_info *vf)
+bnxt_hwrm_set_trusted_vf(struct bnxt_softc *softc, struct bnxt_vf_info *vf,
+ bool trusted)
{
struct hwrm_func_cfg_input req = {0};
int rc;
@@ -375,7 +464,7 @@
req.fid = htole16(vf->fw_fid);
- if (vf->flags & BNXT_VF_TRUST)
+ if (trusted)
req.flags = cpu_to_le32(HWRM_FUNC_CFG_INPUT_FLAGS_TRUSTED_VF_ENABLE);
else
req.flags = cpu_to_le32(HWRM_FUNC_CFG_INPUT_FLAGS_TRUSTED_VF_DISABLE);
@@ -402,14 +491,9 @@
}
vf = &softc->pf.vf[vf_id];
- if (trusted)
- vf->flags |= BNXT_VF_TRUST;
- else
- vf->flags &= ~BNXT_VF_TRUST;
-
BNXT_SRIOV_UNLOCK(softc);
- rc = bnxt_hwrm_set_trusted_vf(softc, vf);
+ rc = bnxt_hwrm_set_trusted_vf(softc, vf, trusted);
if (rc == 0) {
BNXT_SRIOV_LOCK(softc);
if (softc->pf.num_vfs != 0 && vf_id < softc->pf.num_vfs) {
@@ -441,7 +525,9 @@
if (is_valid_ether_addr(req->dflt_mac_addr) &&
(trust || !is_valid_ether_addr(vf->mac_addr) ||
ether_addr_equal(req->dflt_mac_addr, vf->mac_addr))) {
+ BNXT_SRIOV_LOCK(softc);
ether_addr_copy(vf->vf_mac_addr, req->dflt_mac_addr);
+ BNXT_SRIOV_UNLOCK(softc);
return bnxt_hwrm_exec_fwd_resp(softc, vf, msg_size);
}
return bnxt_hwrm_fwd_err_resp(softc, vf, msg_size);
Index: sys/dev/bnxt/bnxt_en/if_bnxt.c
===================================================================
--- sys/dev/bnxt/bnxt_en/if_bnxt.c
+++ sys/dev/bnxt/bnxt_en/if_bnxt.c
@@ -371,6 +371,7 @@
DEVMETHOD(ifdi_iov_init, bnxt_iov_init),
DEVMETHOD(ifdi_iov_uninit, bnxt_iov_uninit),
DEVMETHOD(ifdi_iov_vf_add, bnxt_iov_vf_add),
+ DEVMETHOD(ifdi_vf_status, bnxt_vf_status),
#endif
DEVMETHOD_END
};

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 23, 11:55 PM (13 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41942638
Default Alt Text
D58738.1795478143.diff (6 KB)

Event Timeline