From owner-svn-src-all@freebsd.org Thu Sep 21 20:27:45 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0374BE201AB; Thu, 21 Sep 2017 20:27:45 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1D92694E1; Thu, 21 Sep 2017 20:27:44 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8LKRiMG028740; Thu, 21 Sep 2017 20:27:44 GMT (envelope-from shurd@FreeBSD.org) Received: (from shurd@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8LKRhVZ028736; Thu, 21 Sep 2017 20:27:43 GMT (envelope-from shurd@FreeBSD.org) Message-Id: <201709212027.v8LKRhVZ028736@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: shurd set sender to shurd@FreeBSD.org using -f From: Stephen Hurd Date: Thu, 21 Sep 2017 20:27:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323874 - head/sys/dev/bnxt X-SVN-Group: head X-SVN-Commit-Author: shurd X-SVN-Commit-Paths: head/sys/dev/bnxt X-SVN-Commit-Revision: 323874 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2017 20:27:45 -0000 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 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;