if_bnxt: Add support for admin down/up and jumbo

Make ifconfig up/down work, as well as adding support for jumbo frames.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36439
This commit is contained in:
Sumit Saxena 2022-11-04 16:11:10 -06:00 committed by Warner Losh
parent 8945584f93
commit 055196a7d7
5 changed files with 296 additions and 14 deletions

View File

@ -714,6 +714,7 @@ struct bnxt_softc {
struct bnxt_grp_info *grp_info;
struct iflib_dma_info rx_stats[BNXT_MAX_NUM_QUEUES];
int nrxqsets;
uint16_t rx_buf_size;
struct bnxt_cp_ring def_cp_ring;
struct bnxt_cp_ring def_nq_ring;

View File

@ -913,6 +913,29 @@ bnxt_hwrm_set_link_setting(struct bnxt_softc *softc, bool set_pause,
return rc;
}
int
bnxt_hwrm_vnic_set_hds(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
{
struct hwrm_vnic_plcmodes_cfg_input req = {0};
if (!BNXT_CHIP_P5(softc))
return 0;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_PLCMODES_CFG);
/*
* TBD -- Explore these flags
* 1. VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4
* 2. VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6
* 3. req.jumbo_thresh
* 4. req.hds_threshold
*/
req.flags = htole32(HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT);
req.vnic_id = htole16(vnic->id);
return hwrm_send_message(softc, &req, sizeof(req));
}
int
bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
{
@ -950,6 +973,29 @@ bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
return hwrm_send_message(softc, &req, sizeof(req));
}
int
bnxt_hwrm_vnic_free(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
{
struct hwrm_vnic_free_input req = {0};
int rc = 0;
if (vnic->id == (uint16_t)HWRM_NA_SIGNATURE)
return rc;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_FREE);
req.vnic_id = htole32(vnic->id);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
if (rc)
goto fail;
fail:
BNXT_HWRM_UNLOCK(softc);
return (rc);
}
int
bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
{
@ -981,6 +1027,27 @@ bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
return (rc);
}
int
bnxt_hwrm_vnic_ctx_free(struct bnxt_softc *softc, uint16_t ctx_id)
{
struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {0};
int rc = 0;
if (ctx_id == (uint16_t)HWRM_NA_SIGNATURE)
return rc;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_RSS_COS_LB_CTX_FREE);
req.rss_cos_lb_ctx_id = htole16(ctx_id);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
if (rc)
goto fail;
fail:
BNXT_HWRM_UNLOCK(softc);
return rc;
}
int
bnxt_hwrm_vnic_ctx_alloc(struct bnxt_softc *softc, uint16_t *ctx_id)
{
@ -1044,6 +1111,64 @@ bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc, struct bnxt_grp_info *grp)
return rc;
}
int
bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *grp)
{
struct hwrm_ring_grp_free_input req = {0};
int rc = 0;
if (grp->grp_id == (uint16_t)HWRM_NA_SIGNATURE)
return 0;
if (BNXT_CHIP_P5 (softc))
return 0;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_RING_GRP_FREE);
req.ring_group_id = htole32(grp->grp_id);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
if (rc)
goto fail;
fail:
BNXT_HWRM_UNLOCK(softc);
return rc;
}
int bnxt_hwrm_ring_free(struct bnxt_softc *softc, uint32_t ring_type,
struct bnxt_ring *ring, int cmpl_ring_id)
{
struct hwrm_ring_free_input req = {0};
struct hwrm_ring_free_output *resp;
int rc = 0;
uint16_t error_code;
if (ring->phys_id == (uint16_t)HWRM_NA_SIGNATURE)
return 0;
resp = (void *)softc->hwrm_cmd_resp.idi_vaddr;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_RING_FREE);
req.cmpl_ring = htole16(cmpl_ring_id);
req.ring_type = ring_type;
req.ring_id = htole16(ring->phys_id);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
error_code = le16toh(resp->error_code);
if (rc || error_code) {
device_printf(softc->dev, "hwrm_ring_free type %d failed. "
"rc:%x err:%x\n", ring_type, rc, error_code);
if (!rc)
rc = -EIO;
}
BNXT_HWRM_UNLOCK(softc);
return rc;
}
/*
* Ring allocation message to the firmware
*/
@ -1091,8 +1216,7 @@ bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
cp_ring = &softc->rx_cp_rings[idx];
req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
req.rx_buf_size = htole16(
softc->scctx->isc_max_frame_size);
req.rx_buf_size = htole16(softc->rx_buf_size);
req.enables |= htole32(
HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID);
@ -1107,8 +1231,7 @@ bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
req.rx_ring_id = htole16(softc->rx_rings[idx].phys_id);
req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
req.rx_buf_size = htole16(
softc->scctx->isc_max_frame_size);
req.rx_buf_size = htole16(softc->rx_buf_size);
req.enables |= htole32(
HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID |
HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
@ -1145,6 +1268,29 @@ bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
return rc;
}
int
bnxt_hwrm_stat_ctx_free(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr)
{
struct hwrm_stat_ctx_free_input req = {0};
int rc = 0;
if (cpr->stats_ctx_id == HWRM_NA_SIGNATURE)
return rc;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_STAT_CTX_FREE);
req.stat_ctx_id = htole16(cpr->stats_ctx_id);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
if (rc)
goto fail;
fail:
BNXT_HWRM_UNLOCK(softc);
return rc;
}
int
bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr,
uint64_t paddr)
@ -1253,6 +1399,29 @@ bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc,
return hwrm_send_message(softc, &req, sizeof(req));
}
int
bnxt_hwrm_free_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
{
struct hwrm_cfa_l2_filter_free_input req = {0};
int rc = 0;
if (vnic->filter_id == -1)
return rc;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_CFA_L2_FILTER_FREE);
req.l2_filter_id = htole64(vnic->filter_id);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
if (rc)
goto fail;
fail:
BNXT_HWRM_UNLOCK(softc);
return (rc);
}
int
bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
{
@ -1403,12 +1572,12 @@ bnxt_hwrm_vnic_tpa_cfg(struct bnxt_softc *softc)
HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA |
HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN |
HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ;
if (softc->hw_lro.is_mode_gro)
flags |= HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO;
else
flags |= HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE;
req.flags = htole32(flags);
req.enables = htole32(HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS |

View File

@ -43,6 +43,8 @@ int bnxt_alloc_hwrm_dma_mem(struct bnxt_softc *softc);
void bnxt_free_hwrm_dma_mem(struct bnxt_softc *softc);
int bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
struct bnxt_ring *ring);
int bnxt_hwrm_ring_free(struct bnxt_softc *softc, uint32_t type,
struct bnxt_ring *ring, int cmpl_ring_id);
int bnxt_hwrm_ver_get(struct bnxt_softc *softc);
int bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc);
int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc);
@ -54,16 +56,22 @@ int bnxt_hwrm_set_link_setting(struct bnxt_softc *softc, bool set_pause,
bool set_eee, bool set_link);
int bnxt_hwrm_set_pause(struct bnxt_softc *softc);
int bnxt_hwrm_vnic_ctx_alloc(struct bnxt_softc *softc, uint16_t *ctx_id);
int bnxt_hwrm_vnic_ctx_free(struct bnxt_softc *softc, uint16_t ctx_id);
int bnxt_hwrm_vnic_set_hds(struct bnxt_softc *sc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_vnic_free(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr,
uint64_t paddr);
int bnxt_hwrm_stat_ctx_free(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr);
int bnxt_hwrm_port_qstats(struct bnxt_softc *softc);
int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc,
struct bnxt_grp_info *grp);
int bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *gr);
int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc,
struct bnxt_vnic_info *vnic);
int bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_free_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnc);
int bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic,
uint32_t hash_type);
int bnxt_cfg_async_cr(struct bnxt_softc *softc);

View File

@ -282,7 +282,7 @@ bnxt_isc_rxd_refill(void *sc, if_rxd_update_t iru)
for (i=0; i<count; i++) {
rxbd[pidx].flags_type = htole16(type);
rxbd[pidx].len = htole16(softc->scctx->isc_max_frame_size);
rxbd[pidx].len = htole16(softc->rx_buf_size);
/* No need to byte-swap the opaque value */
rxbd[pidx].opaque = (((rxqid & 0xff) << 24) | (flid << 16)
| (frag_idxs[i]));

View File

@ -1560,6 +1560,8 @@ bnxt_attach_post(if_ctx_t ctx)
softc->scctx->isc_max_frame_size = ifp->if_mtu + ETHER_HDR_LEN +
ETHER_CRC_LEN;
softc->rx_buf_size = min(softc->scctx->isc_max_frame_size, BNXT_PAGE_SIZE);
failed:
return rc;
}
@ -1613,6 +1615,108 @@ bnxt_detach(if_ctx_t ctx)
return 0;
}
static void
bnxt_hwrm_resource_free(struct bnxt_softc *softc)
{
int i, rc = 0;
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
&softc->def_cp_ring.ring,
(uint16_t)HWRM_NA_SIGNATURE);
if (rc)
goto fail;
for (i = 0; i < softc->ntxqsets; i++) {
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_TX,
&softc->tx_rings[i],
softc->tx_cp_rings[i].ring.phys_id);
if (rc)
goto fail;
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
&softc->tx_cp_rings[i].ring,
(uint16_t)HWRM_NA_SIGNATURE);
if (rc)
goto fail;
rc = bnxt_hwrm_stat_ctx_free(softc, &softc->tx_cp_rings[i]);
if (rc)
goto fail;
}
rc = bnxt_hwrm_free_filter(softc, &softc->vnic_info);
if (rc)
goto fail;
rc = bnxt_hwrm_vnic_free(softc, &softc->vnic_info);
if (rc)
goto fail;
rc = bnxt_hwrm_vnic_ctx_free(softc, softc->vnic_info.rss_id);
if (rc)
goto fail;
for (i = 0; i < softc->nrxqsets; i++) {
rc = bnxt_hwrm_ring_grp_free(softc, &softc->grp_info[i]);
if (rc)
goto fail;
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG,
&softc->ag_rings[i],
(uint16_t)HWRM_NA_SIGNATURE);
if (rc)
goto fail;
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_RX,
&softc->rx_rings[i],
softc->rx_cp_rings[i].ring.phys_id);
if (rc)
goto fail;
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
&softc->rx_cp_rings[i].ring,
(uint16_t)HWRM_NA_SIGNATURE);
if (rc)
goto fail;
if (BNXT_CHIP_P5(softc)) {
rc = bnxt_hwrm_ring_free(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ,
&softc->nq_rings[i].ring,
(uint16_t)HWRM_NA_SIGNATURE);
if (rc)
goto fail;
}
rc = bnxt_hwrm_stat_ctx_free(softc, &softc->rx_cp_rings[i]);
if (rc)
goto fail;
}
fail:
return;
}
static void
bnxt_func_reset(struct bnxt_softc *softc)
{
if (!BNXT_CHIP_P5(softc)) {
bnxt_hwrm_func_reset(softc);
return;
}
bnxt_hwrm_resource_free(softc);
return;
}
/* Device configuration */
static void
bnxt_init(if_ctx_t ctx)
@ -1689,8 +1793,6 @@ bnxt_init(if_ctx_t ctx)
goto fail;
softc->db_ops.bnxt_db_rx(&softc->rx_rings[i], 0);
if (!(softc->flags & BNXT_FLAG_TPA))
goto skip_agg_rings;
/* Allocate the AG ring */
rc = bnxt_hwrm_ring_alloc(softc,
HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG,
@ -1698,7 +1800,6 @@ bnxt_init(if_ctx_t ctx)
if (rc)
goto fail;
softc->db_ops.bnxt_db_rx(&softc->ag_rings[i], 0);
skip_agg_rings:
/* Allocate the ring group */
softc->grp_info[i].stats_ctx =
@ -1724,6 +1825,9 @@ bnxt_init(if_ctx_t ctx)
if (rc)
goto fail;
rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
if (rc)
goto fail;
rc = bnxt_hwrm_vnic_set_hds(softc, &softc->vnic_info);
if (rc)
goto fail;
rc = bnxt_hwrm_set_filter(softc, &softc->vnic_info);
@ -1783,7 +1887,7 @@ bnxt_init(if_ctx_t ctx)
return;
fail:
bnxt_hwrm_func_reset(softc);
bnxt_func_reset(softc);
bnxt_clear_ids(softc);
return;
}
@ -1795,8 +1899,7 @@ bnxt_stop(if_ctx_t ctx)
bnxt_do_disable_intr(&softc->def_cp_ring);
bnxt_hwrm_func_reset(softc);
if (!BNXT_CHIP_P5(softc))
bnxt_hwrm_func_reset(softc);
bnxt_func_reset(softc);
bnxt_clear_ids(softc);
return;
}
@ -1853,6 +1956,7 @@ bnxt_mtu_set(if_ctx_t ctx, uint32_t mtu)
return EINVAL;
softc->scctx->isc_max_frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
softc->rx_buf_size = min(softc->scctx->isc_max_frame_size, BNXT_PAGE_SIZE);
return 0;
}