Index: sys/dev/bnxt/bnxt_en/bnxt.h =================================================================== --- sys/dev/bnxt/bnxt_en/bnxt.h +++ sys/dev/bnxt/bnxt_en/bnxt.h @@ -95,9 +95,18 @@ #define NETXTREME_C_VF1 0x16cb #define NETXTREME_C_VF2 0x16e1 #define NETXTREME_C_VF3 0x16e5 -#define NETXTREME_E_VF1 0x16c1 -#define NETXTREME_E_VF2 0x16d3 -#define NETXTREME_E_VF3 0x16dc + +#define NETXTREME_E_VF1 0x1606 +#define NETXTREME_E_VF2 0x1609 +#define NETXTREME_E_VF3 0x16c1 +#define NETXTREME_E_VF4 0x16d3 +#define NETXTREME_E_VF5 0x16dc + +#define NETXTREME_E_P5_VF1 0x1806 +#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 EVENT_DATA1_RESET_NOTIFY_FATAL(data1) \ (((data1) & \ @@ -1392,5 +1401,8 @@ int bnxt_dcb_ieee_delapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app); int bnxt_dcb_ieee_listapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app, size_t nitems, int *num_inputs); +int bnxt_hwrm_reserve_rings(struct bnxt_softc *softc); +void bnxt_set_flags_by_devid(struct bnxt_softc *softc); +static inline bool bnxt_is_vf_device(uint16_t device_id); #endif /* _BNXT_H */ Index: sys/dev/bnxt/bnxt_en/bnxt_hwrm.h =================================================================== --- sys/dev/bnxt/bnxt_en/bnxt_hwrm.h +++ sys/dev/bnxt/bnxt_en/bnxt_hwrm.h @@ -141,4 +141,5 @@ int _hwrm_send_message(struct bnxt_softc *, void *, uint32_t); int hwrm_send_message(struct bnxt_softc *, void *, uint32_t); void bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *, void *, uint16_t); +int bnxt_hwrm_reserve_vf_rings(struct bnxt_softc *softc); #endif Index: sys/dev/bnxt/bnxt_en/bnxt_hwrm.c =================================================================== --- sys/dev/bnxt/bnxt_en/bnxt_hwrm.c +++ sys/dev/bnxt/bnxt_en/bnxt_hwrm.c @@ -2246,6 +2246,37 @@ return hwrm_send_message(softc, &req, sizeof(req)); } +#define BNXT_VF_MIN_RSS_CTX 1 +#define BNXT_VF_MAX_RSS_CTX 1 +#define BNXT_VF_MIN_L2_CTX 1 +#define BNXT_VF_MAX_L2_CTX 4 + +int +bnxt_hwrm_reserve_vf_rings(struct bnxt_softc *softc) +{ + struct hwrm_func_vf_cfg_input req = {0}; + + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_VF_CFG); + + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS); + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_CMPL_RINGS); + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_TX_RINGS); + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RX_RINGS); + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS); + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_STAT_CTXS); + req.enables |= htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_L2_CTXS); + req.num_rsscos_ctxs = htole16(0x8); + req.num_cmpl_rings = htole16(BNXT_MAX_NUM_QUEUES * 2); + req.num_tx_rings = htole16(BNXT_MAX_NUM_QUEUES); + req.num_rx_rings = htole16(BNXT_MAX_NUM_QUEUES); + req.num_vnics = htole16(BNXT_MAX_NUM_QUEUES); + req.num_stat_ctxs = htole16(BNXT_MAX_NUM_QUEUES * 2); + + req.num_l2_ctxs = htole16(BNXT_VF_MAX_L2_CTX); + + return hwrm_send_message(softc, &req, sizeof(req)); +} + int bnxt_cfg_async_cr(struct bnxt_softc *softc) { 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 @@ -168,6 +168,22 @@ "Broadcom NetXtreme-E Ethernet Virtual Function"), PVID(BROADCOM_VENDOR_ID, NETXTREME_E_VF3, "Broadcom NetXtreme-E Ethernet Virtual Function"), + + PVID(BROADCOM_VENDOR_ID, NETXTREME_E_VF4, + "Broadcom NetXtreme-E Ethernet Virtual Function"), + PVID(BROADCOM_VENDOR_ID, NETXTREME_E_VF5, + "Broadcom NetXtreme-E Ethernet Virtual Function"), + PVID(BROADCOM_VENDOR_ID, NETXTREME_E_P5_VF1, + "Broadcom BCM5750X NetXtreme-E Ethernet Virtual Function"), + PVID(BROADCOM_VENDOR_ID, NETXTREME_E_P5_VF2, + "Broadcom BCM5750X NetXtreme-E Ethernet Virtual Function"), + PVID(BROADCOM_VENDOR_ID, NETXTREME_E_P5_VF_HV1, + "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, + "Broadcom BCM5760X Virtual Function"), + /* required last entry */ PVID_END @@ -388,7 +404,6 @@ PAGE_SIZE / sizeof(struct cmpl_base) * 16}, .isc_ntxd_max = {BNXT_MAX_TXD, BNXT_MAX_TXD, BNXT_MAX_TXD}, - .isc_admin_intrcnt = BNXT_ROCE_IRQ_COUNT, .isc_vendor_info = bnxt_vendor_info_array, .isc_driver_version = bnxt_driver_version, }; @@ -401,10 +416,13 @@ /* * Device Methods */ - static void * bnxt_register(device_t dev) { + uint16_t device_id = pci_get_device(dev); + + if (!bnxt_is_vf_device(device_id)) + bnxt_sctx_init.isc_admin_intrcnt = BNXT_ROCE_IRQ_COUNT; return (&bnxt_sctx_init); } @@ -2059,7 +2077,8 @@ } if (BNXT_CHIP_P5_PLUS(bp)) - bnxt_hwrm_reserve_pf_rings(bp); + bnxt_hwrm_reserve_rings(bp); + /* Get the current configuration of this function */ rc = bnxt_hwrm_func_qcfg(bp); if (rc) { @@ -2346,24 +2365,47 @@ return rc; } +inline int +bnxt_hwrm_reserve_rings(struct bnxt_softc *softc) +{ + if (BNXT_PF(softc)) + return bnxt_hwrm_reserve_pf_rings(softc); + else + return bnxt_hwrm_reserve_vf_rings(softc); +} -/* Device setup and teardown */ -static int -bnxt_attach_pre(if_ctx_t ctx) +static inline bool +bnxt_is_vf_device(uint16_t device_id) { - struct bnxt_softc *softc = iflib_get_softc(ctx); - if_softc_ctx_t scctx; - int rc = 0; + switch (device_id) { + case NETXTREME_C_VF1: + case NETXTREME_C_VF2: + case NETXTREME_C_VF3: + case NETXTREME_E_VF1: + case NETXTREME_E_VF2: + case NETXTREME_E_VF3: + case NETXTREME_E_VF4: + case NETXTREME_E_VF5: + case NETXTREME_E_P5_VF1: + case NETXTREME_E_P5_VF2: + case NETXTREME_E_P5_VF_HV1: + case NETXTREME_E_P5_VF_HV2: + case NETXTREME_E_P7_VF: + return true; + default: + return false; + } +} - softc->ctx = ctx; - softc->dev = iflib_get_dev(ctx); - softc->media = iflib_get_media(ctx); - softc->scctx = iflib_get_softc_ctx(ctx); - softc->sctx = iflib_get_sctx(ctx); - scctx = softc->scctx; +void +bnxt_set_flags_by_devid(struct bnxt_softc *softc) +{ + uint16_t device_id = pci_get_device(softc->dev); + + if (bnxt_is_vf_device(device_id)) + softc->flags |= BNXT_FLAG_VF; - /* TODO: Better way of detecting NPAR/VF is needed */ - switch (pci_get_device(softc->dev)) { + switch (device_id) { case BCM57402_NPAR: case BCM57404_NPAR: case BCM57406_NPAR: @@ -2374,24 +2416,31 @@ case BCM57414_NPAR2: case BCM57416_NPAR1: case BCM57416_NPAR2: - case BCM57504_NPAR: softc->flags |= BNXT_FLAG_NPAR; break; - case NETXTREME_C_VF1: - case NETXTREME_C_VF2: - case NETXTREME_C_VF3: - case NETXTREME_E_VF1: - case NETXTREME_E_VF2: - case NETXTREME_E_VF3: - softc->flags |= BNXT_FLAG_VF; - break; } +} +/* Device setup and teardown */ +static int +bnxt_attach_pre(if_ctx_t ctx) +{ + struct bnxt_softc *softc = iflib_get_softc(ctx); + if_softc_ctx_t scctx; + int rc = 0; + + softc->ctx = ctx; + softc->dev = iflib_get_dev(ctx); + softc->media = iflib_get_media(ctx); + softc->scctx = iflib_get_softc_ctx(ctx); + softc->sctx = iflib_get_sctx(ctx); + scctx = softc->scctx; softc->domain = pci_get_domain(softc->dev); softc->bus = pci_get_bus(softc->dev); softc->slot = pci_get_slot(softc->dev); softc->function = pci_get_function(softc->dev); softc->dev_fn = PCI_DEVFN(softc->slot, softc->function); + bnxt_set_flags_by_devid(softc); if (bnxt_num_pfs == 0) SLIST_INIT(&pf_list); @@ -2446,9 +2495,6 @@ goto ver_fail; } - /* Now perform a function reset */ - rc = bnxt_hwrm_func_reset(softc); - if ((softc->flags & BNXT_FLAG_SHORT_CMD) || softc->hwrm_max_ext_req_len > BNXT_HWRM_MAX_REQ_LEN) { rc = bnxt_alloc_hwrm_short_cmd_req(softc); @@ -2456,6 +2502,9 @@ goto hwrm_short_cmd_alloc_fail; } + /* Now perform a function reset */ + rc = bnxt_hwrm_func_reset(softc); + if ((softc->ver_info->chip_num == BCM57508) || (softc->ver_info->chip_num == BCM57504) || (softc->ver_info->chip_num == BCM57504_NPAR) || @@ -2599,8 +2648,10 @@ /* Get the queue config */ bnxt_get_wol_settings(softc); + if (BNXT_CHIP_P5_PLUS(softc)) - bnxt_hwrm_reserve_pf_rings(softc); + bnxt_hwrm_reserve_rings(softc); + rc = bnxt_hwrm_func_qcfg(softc); if (rc) { device_printf(softc->dev, "attach: hwrm func qcfg failed\n"); @@ -2629,6 +2680,7 @@ device_printf(softc->dev, "WARNING: ntxd0 (%d) should be at least 2 * ntxd1 (%d). Driver may be unstable\n", scctx->isc_ntxd[0], scctx->isc_ntxd[1]); + scctx->isc_txqsizes[0] = sizeof(struct cmpl_base) * scctx->isc_ntxd[0]; scctx->isc_txqsizes[1] = sizeof(struct tx_bd_short) * scctx->isc_ntxd[1]; @@ -4356,7 +4408,10 @@ { struct bnxt_softc *softc = iflib_get_softc(ctx); uint8_t *data = i2c->data; - int rc; + int rc = 0; + + if (BNXT_VF(softc)) + return -EOPNOTSUPP; /* No point in going further if phy status indicates * module is not inserted or if it is powered down or