Author: shurd
Date: Wed Sep  6 20:14:34 2017
New Revision: 323232
URL: https://svnweb.freebsd.org/changeset/base/323232

Log:
  bnxt: Use correct firmware call for number of queues supported
  
  1) Based on the suggestion from firmware team, derive
     scctx->isc_ntxqsets_max & scctx->isc_nrxqsets_max based on FUNC_QCFG
     (instead of FUNC_QCAPS).
  2) Bump-up driver version to "1.0.0.2".
  
  Submitted by: Bhargava Chenna Marreddy <[email protected]>
  Reviewed by:  shurd, sbruno
  Approved by:  sbruno (mentor)
  Sponsored by: Broadcom Limited
  Differential Revision:        https://reviews.freebsd.org/D12128

Modified:
  head/sys/dev/bnxt/bnxt.h
  head/sys/dev/bnxt/bnxt_hwrm.c
  head/sys/dev/bnxt/bnxt_hwrm.h
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/bnxt.h
==============================================================================
--- head/sys/dev/bnxt/bnxt.h    Wed Sep  6 20:01:19 2017        (r323231)
+++ head/sys/dev/bnxt/bnxt.h    Wed Sep  6 20:14:34 2017        (r323232)
@@ -519,6 +519,13 @@ struct bnxt_nvram_info {
        struct sysctl_oid       *nvm_oid;
 };
 
+struct bnxt_func_qcfg {
+       uint16_t alloc_completion_rings;
+       uint16_t alloc_tx_rings;
+       uint16_t alloc_rx_rings;
+       uint16_t alloc_vnics;
+};
+
 struct bnxt_softc {
        device_t        dev;
        if_ctx_t        ctx;
@@ -535,6 +542,7 @@ struct bnxt_softc {
        uint32_t                total_msix;
 
        struct bnxt_func_info   func;
+       struct bnxt_func_qcfg   fn_qcfg;
        struct bnxt_pf_info     pf;
        struct bnxt_vf_info     vf;
 

Modified: head/sys/dev/bnxt/bnxt_hwrm.c
==============================================================================
--- head/sys/dev/bnxt/bnxt_hwrm.c       Wed Sep  6 20:01:19 2017        
(r323231)
+++ head/sys/dev/bnxt/bnxt_hwrm.c       Wed Sep  6 20:14:34 2017        
(r323232)
@@ -438,6 +438,31 @@ fail:
        return rc;
 }
 
+int 
+bnxt_hwrm_func_qcfg(struct bnxt_softc *softc)
+{
+        struct hwrm_func_qcfg_input req = {0};
+        struct hwrm_func_qcfg_output *resp =
+           (void *)softc->hwrm_cmd_resp.idi_vaddr;
+       struct bnxt_func_qcfg *fn_qcfg = &softc->fn_qcfg;
+        int rc;
+
+       bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_QCFG);
+        req.fid = htole16(0xffff);
+       BNXT_HWRM_LOCK(softc);
+       rc = _hwrm_send_message(softc, &req, sizeof(req));
+        if (rc)
+               goto fail;
+
+       fn_qcfg->alloc_completion_rings = le16toh(resp->alloc_cmpl_rings);
+       fn_qcfg->alloc_tx_rings = le16toh(resp->alloc_tx_rings);
+       fn_qcfg->alloc_rx_rings = le16toh(resp->alloc_rx_rings);
+       fn_qcfg->alloc_vnics = le16toh(resp->alloc_vnics);
+fail:
+       BNXT_HWRM_UNLOCK(softc);
+        return rc;
+}
+
 int
 bnxt_hwrm_func_reset(struct bnxt_softc *softc)
 {

Modified: head/sys/dev/bnxt/bnxt_hwrm.h
==============================================================================
--- head/sys/dev/bnxt/bnxt_hwrm.h       Wed Sep  6 20:01:19 2017        
(r323231)
+++ head/sys/dev/bnxt/bnxt_hwrm.h       Wed Sep  6 20:14:34 2017        
(r323232)
@@ -43,6 +43,7 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc)
 int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc);
 int bnxt_hwrm_func_drv_unrgtr(struct bnxt_softc *softc, bool shutdown);
 int bnxt_hwrm_func_qcaps(struct bnxt_softc *softc);
+int bnxt_hwrm_func_qcfg(struct bnxt_softc *softc);
 int bnxt_hwrm_func_reset(struct bnxt_softc *softc);
 int bnxt_hwrm_set_link_setting(struct bnxt_softc *, bool set_pause,
     bool set_eee);

Modified: head/sys/dev/bnxt/if_bnxt.c
==============================================================================
--- head/sys/dev/bnxt/if_bnxt.c Wed Sep  6 20:01:19 2017        (r323231)
+++ head/sys/dev/bnxt/if_bnxt.c Wed Sep  6 20:14:34 2017        (r323232)
@@ -287,7 +287,7 @@ static driver_t bnxt_iflib_driver = {
  * iflib shared context
  */
 
-#define BNXT_DRIVER_VERSION    "1.0.0.1"
+#define BNXT_DRIVER_VERSION    "1.0.0.2"
 char bnxt_driver_version[] = BNXT_DRIVER_VERSION;
 extern struct if_txrx bnxt_txrx;
 static struct if_shared_ctx bnxt_sctx_init = {
@@ -702,6 +702,13 @@ bnxt_attach_pre(if_ctx_t ctx)
        if (rc)
                goto failed;
 
+       /* Get the current configuration of this function */
+       rc = bnxt_hwrm_func_qcfg(softc);
+       if (rc) {
+               device_printf(softc->dev, "attach: hwrm func qcfg failed\n");
+               goto failed;
+       }
+
        iflib_set_mac(ctx, softc->func.mac_addr);
 
        scctx->isc_txrx = &bnxt_txrx;
@@ -761,12 +768,16 @@ bnxt_attach_pre(if_ctx_t ctx)
            scctx->isc_nrxd[1];
        scctx->isc_rxqsizes[2] = sizeof(struct rx_prod_pkt_bd) *
            scctx->isc_nrxd[2];
+
        scctx->isc_nrxqsets_max = min(pci_msix_count(softc->dev)-1,
-           softc->func.max_cp_rings - 1);
+           softc->fn_qcfg.alloc_completion_rings - 1);
        scctx->isc_nrxqsets_max = min(scctx->isc_nrxqsets_max,
-           softc->func.max_rx_rings);
-       scctx->isc_ntxqsets_max = min(softc->func.max_rx_rings,
-           softc->func.max_cp_rings - scctx->isc_nrxqsets_max - 1);
+           softc->fn_qcfg.alloc_rx_rings);
+       scctx->isc_nrxqsets_max = min(scctx->isc_nrxqsets_max,
+           softc->fn_qcfg.alloc_vnics);
+       scctx->isc_ntxqsets_max = min(softc->fn_qcfg.alloc_tx_rings,
+           softc->fn_qcfg.alloc_completion_rings - scctx->isc_nrxqsets_max - 
1);
+
        scctx->isc_rss_table_size = HW_HASH_INDEX_SIZE;
        scctx->isc_rss_table_mask = scctx->isc_rss_table_size - 1;
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to