Author: shurd
Date: Thu Sep 21 20:27:43 2017
New Revision: 323874
URL: https://svnweb.freebsd.org/changeset/base/323874

Log:
  bnxt: Fix driver when attached to a VF
  
  - Use HWRM_FUNC_VF_CFG instead of HWRM_FUNC_CFG on VFs
  - Fix NPAR/VF detection
  - Clean up flag definitions
  - Don't allow WoL on VFs
  
  Although the bnxt driver doesn't support SR-IOV so can create VFs yet,
  the PF could be running Linux or ESCi with a VF passed through to a
  FreeBSD guest.  This fixes the driver for that use case.
  
  Submitted by: Siva Kallam <siva.kallam@@broadcom.com>
  Reviewed by:  shurd, sbruno
  Approved by:  sbruno (mentor)
  Sponsored by: Broadcom Limited
  Differential Revision:        https://reviews.freebsd.org/D12410

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    Thu Sep 21 20:16:10 2017        (r323873)
+++ head/sys/dev/bnxt/bnxt.h    Thu Sep 21 20:27:43 2017        (r323874)
@@ -102,7 +102,8 @@ __FBSDID("$FreeBSD$");
 #define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
 
 #define BNXT_NO_MORE_WOL_FILTERS       0xFFFF
-#define bnxt_wol_supported(softc)      ((softc)->flags & BNXT_FLAG_WOL_CAP)
+#define bnxt_wol_supported(softc)      (!((softc)->flags & BNXT_FLAG_VF) && \
+                                         ((softc)->flags & BNXT_FLAG_WOL_CAP ))
 
 /* Completion related defines */
 #define CMP_VALID(cmp, v_bit) \
@@ -393,7 +394,6 @@ struct bnxt_vf_info {
        bus_addr_t      hwrm_cmd_req_dma_addr;
 };
 
-#define BNXT_FLAG_VF           (1<<1)
 
 #define BNXT_PF(softc)         (!((softc)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(softc)         ((softc)->flags & BNXT_FLAG_VF)
@@ -536,8 +536,9 @@ struct bnxt_softc {
        struct bnxt_bar_info    hwrm_bar;
        struct bnxt_bar_info    doorbell_bar;
        struct bnxt_link_info   link_info;
-#define BNXT_FLAG_NPAR         0x1
-#define BNXT_FLAG_WOL_CAP      0x2
+#define BNXT_FLAG_VF           0x0001
+#define BNXT_FLAG_NPAR         0x0002
+#define BNXT_FLAG_WOL_CAP      0x0004
        uint32_t                flags;
        uint32_t                total_msix;
 

Modified: head/sys/dev/bnxt/bnxt_hwrm.c
==============================================================================
--- head/sys/dev/bnxt/bnxt_hwrm.c       Thu Sep 21 20:16:10 2017        
(r323873)
+++ head/sys/dev/bnxt/bnxt_hwrm.c       Thu Sep 21 20:27:43 2017        
(r323874)
@@ -949,18 +949,32 @@ bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnx
 }
 
 int
-bnxt_hwrm_func_cfg(struct bnxt_softc *softc)
+bnxt_cfg_async_cr(struct bnxt_softc *softc)
 {
-       struct hwrm_func_cfg_input req = {0};
+       int rc = 0;
+       
+       if (BNXT_PF(softc)) {
+               struct hwrm_func_cfg_input req = {0};
 
-       bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_CFG);
+               bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_CFG);
 
-       req.fid = 0xffff;
-       req.enables = htole32(HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
+               req.fid = 0xffff;
+               req.enables = 
htole32(HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
+               req.async_event_cr = softc->def_cp_ring.ring.phys_id;
 
-       req.async_event_cr = softc->def_cp_ring.ring.phys_id;
+               rc = hwrm_send_message(softc, &req, sizeof(req));
+       }
+       else {
+               struct hwrm_func_vf_cfg_input req = {0};
 
-       return hwrm_send_message(softc, &req, sizeof(req));
+               bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_VF_CFG);
+
+               req.enables = 
htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
+               req.async_event_cr = softc->def_cp_ring.ring.phys_id;
+
+               rc = hwrm_send_message(softc, &req, sizeof(req));
+       }
+       return rc;
 }
 
 int
@@ -1719,4 +1733,3 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc
 
        return hwrm_send_message(softc, &req, sizeof(req));
 }
-

Modified: head/sys/dev/bnxt/bnxt_hwrm.h
==============================================================================
--- head/sys/dev/bnxt/bnxt_hwrm.h       Thu Sep 21 20:16:10 2017        
(r323873)
+++ head/sys/dev/bnxt/bnxt_hwrm.h       Thu Sep 21 20:27:43 2017        
(r323874)
@@ -61,7 +61,7 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *so
 int bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info 
*vnic);
 int bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic,
     uint32_t hash_type);
-int bnxt_hwrm_func_cfg(struct bnxt_softc *softc);
+int bnxt_cfg_async_cr(struct bnxt_softc *softc);
 int bnxt_hwrm_vnic_tpa_cfg(struct bnxt_softc *softc,
     struct bnxt_vnic_info *vnic, uint32_t flags);
 int bnxt_hwrm_nvm_find_dir_entry(struct bnxt_softc *softc, uint16_t type,

Modified: head/sys/dev/bnxt/if_bnxt.c
==============================================================================
--- head/sys/dev/bnxt/if_bnxt.c Thu Sep 21 20:16:10 2017        (r323873)
+++ head/sys/dev/bnxt/if_bnxt.c Thu Sep 21 20:27:43 2017        (r323874)
@@ -657,7 +657,7 @@ bnxt_attach_pre(if_ctx_t ctx)
        scctx = softc->scctx;
 
        /* TODO: Better way of detecting NPAR/VF is needed */
-       switch (softc->sctx->isc_vendor_info->pvi_device_id) {
+       switch (pci_get_device(softc->dev)) {
        case BCM57402_NPAR:
        case BCM57404_NPAR:
        case BCM57406_NPAR:
@@ -980,7 +980,7 @@ bnxt_init(if_ctx_t ctx)
                goto fail;
 
        /* And now set the default CP ring as the async CP ring */
-       rc = bnxt_hwrm_func_cfg(softc);
+       rc = bnxt_cfg_async_cr(softc);
        if (rc)
                goto fail;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to