From owner-svn-src-all@freebsd.org Fri Oct 12 22:40:56 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 489C510CD7D1; Fri, 12 Oct 2018 22:40:56 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F32A67995D; Fri, 12 Oct 2018 22:40:55 +0000 (UTC) (envelope-from erj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EDE9D25ACB; Fri, 12 Oct 2018 22:40:55 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9CMetUQ018077; Fri, 12 Oct 2018 22:40:55 GMT (envelope-from erj@FreeBSD.org) Received: (from erj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9CMesr3018070; Fri, 12 Oct 2018 22:40:54 GMT (envelope-from erj@FreeBSD.org) Message-Id: <201810122240.w9CMesr3018070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: erj set sender to erj@FreeBSD.org using -f From: Eric Joyner Date: Fri, 12 Oct 2018 22:40:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339338 - in head/sys: amd64/conf conf dev/ixl modules modules/iavf modules/ixl modules/ixlv net X-SVN-Group: head X-SVN-Commit-Author: erj X-SVN-Commit-Paths: in head/sys: amd64/conf conf dev/ixl modules modules/iavf modules/ixl modules/ixlv net X-SVN-Commit-Revision: 339338 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.27 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: Fri, 12 Oct 2018 22:40:56 -0000 Author: erj Date: Fri Oct 12 22:40:54 2018 New Revision: 339338 URL: https://svnweb.freebsd.org/changeset/base/339338 Log: ixl/iavf(4): Change ixlv to iavf and update it to use iflib(9) Finishes the conversion of the 40Gb Intel Ethernet drivers to iflib(9) for FreeBSD 12.0, and fixes numerous bugs in both ixl(4) and iavf(4). This commit also re-adds the VF driver to GENERIC since it now compiles and functions. The VF driver name was changed from ixlv(4) to iavf(4) because the VF driver is now intended to be used with future products, not just with Fortville/Fort Park VFs. A man page update that documents these drivers is forthcoming in a separate commit. Reviewed by: sbruno@, kbowling@ Tested by: jeffrey.e.pieper@intel.com Approved by: re (gjb@) Relnotes: yes Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D16429 Added: head/sys/modules/iavf/ head/sys/modules/iavf/Makefile (contents, props changed) Deleted: head/sys/dev/ixl/README head/sys/dev/ixl/ixlv_vc_mgr.h head/sys/modules/ixlv/ Modified: head/sys/amd64/conf/GENERIC head/sys/amd64/conf/NOTES head/sys/conf/files.amd64 head/sys/dev/ixl/i40e_osdep.c head/sys/dev/ixl/if_ixl.c head/sys/dev/ixl/if_ixlv.c head/sys/dev/ixl/ixl.h head/sys/dev/ixl/ixl_debug.h head/sys/dev/ixl/ixl_pf.h head/sys/dev/ixl/ixl_pf_iov.c head/sys/dev/ixl/ixl_pf_iov.h head/sys/dev/ixl/ixl_pf_main.c head/sys/dev/ixl/ixl_pf_qmgr.c head/sys/dev/ixl/ixl_pf_qmgr.h head/sys/dev/ixl/ixl_txrx.c head/sys/dev/ixl/ixlv.h head/sys/dev/ixl/ixlvc.c head/sys/modules/Makefile head/sys/modules/ixl/Makefile head/sys/net/iflib.c head/sys/net/iflib.h head/sys/net/iflib_private.h Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Fri Oct 12 21:59:09 2018 (r339337) +++ head/sys/amd64/conf/GENERIC Fri Oct 12 22:40:54 2018 (r339338) @@ -240,9 +240,8 @@ device de # DEC/Intel DC21x4x (``Tulip'') device em # Intel PRO/1000 Gigabit Ethernet Family device ix # Intel PRO/10GbE PCIE PF Ethernet device ixv # Intel PRO/10GbE PCIE VF Ethernet -device ixl # Intel XL710 40Gbe PCIE Ethernet -#options IXL_IW # Enable iWARP Client Interface in ixl(4) -#device ixlv # Intel XL710 40Gbe VF PCIE Ethernet +device ixl # Intel 700 Series Physical Function +device iavf # Intel Adaptive Virtual Function device le # AMD Am7900 LANCE and Am79C9xx PCnet device ti # Alteon Networks Tigon I/II gigabit Ethernet device txp # 3Com 3cR990 (``Typhoon'') Modified: head/sys/amd64/conf/NOTES ============================================================================== --- head/sys/amd64/conf/NOTES Fri Oct 12 21:59:09 2018 (r339337) +++ head/sys/amd64/conf/NOTES Fri Oct 12 22:40:54 2018 (r339338) @@ -313,8 +313,6 @@ options DRM_DEBUG # Include debug printfs (slow) # iwn: Intel Wireless WiFi Link 1000/105/135/2000/4965/5000/6000/6050 abgn # 802.11 network adapters # Requires the iwn firmware module -# ixl: Intel XL710 40Gbe PCIE Ethernet -# ixlv: Intel XL710 40Gbe VF PCIE Ethernet # mthca: Mellanox HCA InfiniBand # mlx4ib: Mellanox ConnectX HCA InfiniBand # mlx4en: Mellanox ConnectX HCA Ethernet @@ -332,9 +330,8 @@ options ED_SIC device ipw # Intel 2100 wireless NICs. device iwi # Intel 2200BG/2225BG/2915ABG wireless NICs. device iwn # Intel 4965/1000/5000/6000 wireless NICs. -device ixl # Intel XL710 40Gbe PCIE Ethernet -#options IXL_IW # Enable iWARP Client Interface in ixl(4) -#device ixlv # Intel XL710 40Gbe VF PCIE Ethernet +device ixl # Intel 700 Series Physical Function +device iavf # Intel Adaptive Virtual Function device mthca # Mellanox HCA InfiniBand device mlx4 # Shared code module between IB and Ethernet device mlx4ib # Mellanox ConnectX HCA InfiniBand Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Fri Oct 12 21:59:09 2018 (r339337) +++ head/sys/conf/files.amd64 Fri Oct 12 22:40:54 2018 (r339338) @@ -271,25 +271,23 @@ dev/ixl/ixl_pf_iov.c optional ixl pci pci_iov \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_i2c.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -#dev/ixl/ixl_iw.c optional ixl pci \ -# compile-with "${NORMAL_C} -I$S/dev/ixl" -#dev/ixl/if_ixlv.c optional ixlv pci \ -# compile-with "${NORMAL_C} -I$S/dev/ixl" -#dev/ixl/ixlvc.c optional ixlv pci \ -# compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/ixl_txrx.c optional ixl pci | ixlv pci \ +dev/ixl/if_ixlv.c optional iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_osdep.c optional ixl pci | ixlv pci \ +dev/ixl/ixlvc.c optional iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_lan_hmc.c optional ixl pci | ixlv pci \ +dev/ixl/ixl_txrx.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_hmc.c optional ixl pci | ixlv pci \ +dev/ixl/i40e_osdep.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_common.c optional ixl pci | ixlv pci \ +dev/ixl/i40e_lan_hmc.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_nvm.c optional ixl pci | ixlv pci \ +dev/ixl/i40e_hmc.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_adminq.c optional ixl pci | ixlv pci \ +dev/ixl/i40e_common.c optional ixl pci | iavf pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_nvm.c optional ixl pci | iavf pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_adminq.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_dcb.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" Modified: head/sys/dev/ixl/i40e_osdep.c ============================================================================== --- head/sys/dev/ixl/i40e_osdep.c Fri Oct 12 21:59:09 2018 (r339337) +++ head/sys/dev/ixl/i40e_osdep.c Fri Oct 12 22:40:54 2018 (r339338) @@ -161,27 +161,25 @@ i40e_destroy_spinlock(struct i40e_spinlock *lock) mtx_destroy(&lock->mutex); } +static inline int +ixl_ms_scale(int x) +{ + if (hz == 1000) + return (x); + else if (hz > 1000) + return (x*(hz/1000)); + else + return (max(1, x/(1000/hz))); +} + void i40e_msec_pause(int msecs) { - int ticks_to_pause = (msecs * hz) / 1000; - int start_ticks = ticks; - - if (cold || SCHEDULER_STOPPED()) { + if (cold || SCHEDULER_STOPPED()) i40e_msec_delay(msecs); - return; - } - - while (1) { - kern_yield(PRI_USER); - int yielded_ticks = ticks - start_ticks; - if (yielded_ticks > ticks_to_pause) - break; - else if (yielded_ticks < 0 - && (yielded_ticks + INT_MAX + 1 > ticks_to_pause)) { - break; - } - } + else + // ERJ: (msecs * hz) could overflow + pause("ixl", ixl_ms_scale(msecs)); } /* @@ -272,7 +270,5 @@ i40e_write_pci_cfg(struct i40e_hw *hw, u32 reg, u16 va { pci_write_config(((struct i40e_osdep *)hw->back)->dev, reg, value, 2); - - return; } Modified: head/sys/dev/ixl/if_ixl.c ============================================================================== --- head/sys/dev/ixl/if_ixl.c Fri Oct 12 21:59:09 2018 (r339337) +++ head/sys/dev/ixl/if_ixl.c Fri Oct 12 22:40:54 2018 (r339338) @@ -48,7 +48,7 @@ * Driver version *********************************************************************/ #define IXL_DRIVER_VERSION_MAJOR 2 -#define IXL_DRIVER_VERSION_MINOR 0 +#define IXL_DRIVER_VERSION_MINOR 1 #define IXL_DRIVER_VERSION_BUILD 0 #define IXL_DRIVER_VERSION_STRING \ @@ -115,10 +115,11 @@ static void ixl_if_timer(if_ctx_t ctx, uint16_t qid); static void ixl_if_vlan_register(if_ctx_t ctx, u16 vtag); static void ixl_if_vlan_unregister(if_ctx_t ctx, u16 vtag); static uint64_t ixl_if_get_counter(if_ctx_t ctx, ift_counter cnt); -static void ixl_if_vflr_handle(if_ctx_t ctx); -// static void ixl_if_link_intr_enable(if_ctx_t ctx); static int ixl_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req); static int ixl_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data); +#ifdef PCI_IOV +static void ixl_if_vflr_handle(if_ctx_t ctx); +#endif /*** Other ***/ static int ixl_mc_filter_apply(void *arg, struct ifmultiaddr *ifma, int); @@ -137,9 +138,9 @@ static device_method_t ixl_methods[] = { DEVMETHOD(device_detach, iflib_device_detach), DEVMETHOD(device_shutdown, iflib_device_shutdown), #ifdef PCI_IOV - DEVMETHOD(pci_iov_init, ixl_iov_init), - DEVMETHOD(pci_iov_uninit, ixl_iov_uninit), - DEVMETHOD(pci_iov_add_vf, ixl_add_vf), + DEVMETHOD(pci_iov_init, iflib_device_iov_init), + DEVMETHOD(pci_iov_uninit, iflib_device_iov_uninit), + DEVMETHOD(pci_iov_add_vf, iflib_device_iov_add_vf), #endif DEVMETHOD_END }; @@ -169,7 +170,6 @@ static device_method_t ixl_if_methods[] = { DEVMETHOD(ifdi_msix_intr_assign, ixl_if_msix_intr_assign), DEVMETHOD(ifdi_intr_enable, ixl_if_enable_intr), DEVMETHOD(ifdi_intr_disable, ixl_if_disable_intr), - //DEVMETHOD(ifdi_link_intr_enable, ixl_if_link_intr_enable), DEVMETHOD(ifdi_rx_queue_intr_enable, ixl_if_rx_queue_intr_enable), DEVMETHOD(ifdi_tx_queue_intr_enable, ixl_if_tx_queue_intr_enable), DEVMETHOD(ifdi_tx_queues_alloc, ixl_if_tx_queues_alloc), @@ -185,9 +185,14 @@ static device_method_t ixl_if_methods[] = { DEVMETHOD(ifdi_vlan_register, ixl_if_vlan_register), DEVMETHOD(ifdi_vlan_unregister, ixl_if_vlan_unregister), DEVMETHOD(ifdi_get_counter, ixl_if_get_counter), - DEVMETHOD(ifdi_vflr_handle, ixl_if_vflr_handle), DEVMETHOD(ifdi_i2c_req, ixl_if_i2c_req), DEVMETHOD(ifdi_priv_ioctl, ixl_if_priv_ioctl), +#ifdef PCI_IOV + DEVMETHOD(ifdi_iov_init, ixl_if_iov_init), + DEVMETHOD(ifdi_iov_uninit, ixl_if_iov_uninit), + DEVMETHOD(ifdi_iov_vf_add, ixl_if_iov_vf_add), + DEVMETHOD(ifdi_vflr_handle, ixl_if_vflr_handle), +#endif // ifdi_led_func // ifdi_debug DEVMETHOD_END @@ -202,7 +207,7 @@ static driver_t ixl_if_driver = { */ static SYSCTL_NODE(_hw, OID_AUTO, ixl, CTLFLAG_RD, 0, - "IXL driver parameters"); + "ixl driver parameters"); /* * Leave this on unless you need to send flow control @@ -222,6 +227,13 @@ SYSCTL_INT(_hw_ixl, OID_AUTO, i2c_access_method, CTLFL &ixl_i2c_access_method, 0, IXL_SYSCTL_HELP_I2C_METHOD); +static int ixl_enable_vf_loopback = 1; +TUNABLE_INT("hw.ixl.enable_vf_loopback", + &ixl_enable_vf_loopback); +SYSCTL_INT(_hw_ixl, OID_AUTO, enable_vf_loopback, CTLFLAG_RDTUN, + &ixl_enable_vf_loopback, 0, + IXL_SYSCTL_HELP_VF_LOOPBACK); + /* * Different method for processing TX descriptor * completion. @@ -333,9 +345,9 @@ ixl_register(device_t dev) static int ixl_allocate_pci_resources(struct ixl_pf *pf) { - int rid; - struct i40e_hw *hw = &pf->hw; device_t dev = iflib_get_dev(pf->vsi.ctx); + struct i40e_hw *hw = &pf->hw; + int rid; /* Map BAR0 */ rid = PCIR_BAR(0); @@ -386,21 +398,17 @@ ixl_if_attach_pre(if_ctx_t ctx) enum i40e_status_code status; int error = 0; - INIT_DEBUGOUT("ixl_if_attach_pre: begin"); + INIT_DBG_DEV(dev, "begin"); - /* Allocate, clear, and link in our primary soft structure */ dev = iflib_get_dev(ctx); pf = iflib_get_softc(ctx); + vsi = &pf->vsi; vsi->back = pf; pf->dev = dev; hw = &pf->hw; - /* - ** Note this assumes we have a single embedded VSI, - ** this could be enhanced later to allocate multiple - */ - //vsi->dev = pf->dev; + vsi->dev = dev; vsi->hw = &pf->hw; vsi->id = 0; vsi->num_vlans = 0; @@ -545,6 +553,7 @@ ixl_if_attach_pre(if_ctx_t ctx) * sizeof(struct i40e_tx_desc), DBA_ALIGN); scctx->isc_txrx = &ixl_txrx_dwb; } + scctx->isc_txrx->ift_legacy_intr = ixl_intr; scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0] * sizeof(union i40e_32byte_rx_desc), DBA_ALIGN); scctx->isc_msix_bar = PCIR_BAR(IXL_MSIX_BAR); @@ -556,7 +565,7 @@ ixl_if_attach_pre(if_ctx_t ctx) scctx->isc_tx_csum_flags = CSUM_OFFLOAD; scctx->isc_capabilities = scctx->isc_capenable = IXL_CAPS; - INIT_DEBUGOUT("ixl_if_attach_pre: end"); + INIT_DBG_DEV(dev, "end"); return (0); err_mac_hmc: @@ -579,7 +588,7 @@ ixl_if_attach_post(if_ctx_t ctx) int error = 0; enum i40e_status_code status; - INIT_DEBUGOUT("ixl_if_attach_post: begin"); + INIT_DBG_DEV(dev, "begin"); dev = iflib_get_dev(ctx); pf = iflib_get_softc(ctx); @@ -587,6 +596,10 @@ ixl_if_attach_post(if_ctx_t ctx) vsi->ifp = iflib_get_ifp(ctx); hw = &pf->hw; + /* Save off determined number of queues for interface */ + vsi->num_rx_queues = vsi->shared->isc_nrxqsets; + vsi->num_tx_queues = vsi->shared->isc_ntxqsets; + /* Setup OS network interface / ifnet */ if (ixl_setup_interface(dev, pf)) { device_printf(dev, "interface setup failed!\n"); @@ -694,6 +707,10 @@ err: return (error); } +/** + * XXX: iflib always ignores the return value of detach() + * -> This means that this isn't allowed to fail + */ static int ixl_if_detach(if_ctx_t ctx) { @@ -702,7 +719,7 @@ ixl_if_detach(if_ctx_t ctx) struct i40e_hw *hw = &pf->hw; device_t dev = pf->dev; enum i40e_status_code status; -#if defined(PCI_IOV) || defined(IXL_IW) +#ifdef IXL_IW int error; #endif @@ -713,17 +730,10 @@ ixl_if_detach(if_ctx_t ctx) error = ixl_iw_pf_detach(pf); if (error == EBUSY) { device_printf(dev, "iwarp in use; stop it first.\n"); - return (error); + //return (error); } } #endif -#ifdef PCI_IOV - error = pci_iov_detach(dev); - if (error != 0) { - device_printf(dev, "SR-IOV in use; detach first.\n"); - return (error); - } -#endif /* Remove all previously allocated media types */ ifmedia_removeall(vsi->media); @@ -751,7 +761,6 @@ ixl_if_detach(if_ctx_t ctx) return (0); } -/* TODO: Do shutdown-specific stuff here */ static int ixl_if_shutdown(if_ctx_t ctx) { @@ -796,43 +805,13 @@ ixl_if_resume(if_ctx_t ctx) return (0); } -/* Set Report Status queue fields to 0 */ -static void -ixl_init_tx_rsqs(struct ixl_vsi *vsi) -{ - if_softc_ctx_t scctx = vsi->shared; - struct ixl_tx_queue *tx_que; - int i, j; - - for (i = 0, tx_que = vsi->tx_queues; i < vsi->num_tx_queues; i++, tx_que++) { - struct tx_ring *txr = &tx_que->txr; - - txr->tx_rs_cidx = txr->tx_rs_pidx = txr->tx_cidx_processed = 0; - - for (j = 0; j < scctx->isc_ntxd[0]; j++) - txr->tx_rsq[j] = QIDX_INVALID; - } -} - -static void -ixl_init_tx_cidx(struct ixl_vsi *vsi) -{ - struct ixl_tx_queue *tx_que; - int i; - - for (i = 0, tx_que = vsi->tx_queues; i < vsi->num_tx_queues; i++, tx_que++) { - struct tx_ring *txr = &tx_que->txr; - - txr->tx_cidx_processed = 0; - } -} - void ixl_if_init(if_ctx_t ctx) { struct ixl_pf *pf = iflib_get_softc(ctx); struct ixl_vsi *vsi = &pf->vsi; struct i40e_hw *hw = &pf->hw; + struct ifnet *ifp = iflib_get_ifp(ctx); device_t dev = iflib_get_dev(ctx); u8 tmpaddr[ETHER_ADDR_LEN]; int ret; @@ -840,12 +819,12 @@ ixl_if_init(if_ctx_t ctx) /* * If the aq is dead here, it probably means something outside of the driver * did something to the adapter, like a PF reset. - * So rebuild the driver's state here if that occurs. + * So, rebuild the driver's state here if that occurs. */ if (!i40e_check_asq_alive(&pf->hw)) { device_printf(dev, "Admin Queue is down; resetting...\n"); ixl_teardown_hw_structs(pf); - ixl_reset(pf); + ixl_rebuild_hw_structs_after_reset(pf); } /* Get the latest mac address... User might use a LAA */ @@ -872,8 +851,7 @@ ixl_if_init(if_ctx_t ctx) return; } - // TODO: Call iflib setup multicast filters here? - // It's called in ixgbe in D5213 + /* Reconfigure multicast filters in HW */ ixl_if_multi_set(ctx); /* Set up RSS */ @@ -895,8 +873,12 @@ ixl_if_init(if_ctx_t ctx) i40e_aq_set_default_vsi(hw, vsi->seid, NULL); + /* Re-add configure filters to HW */ ixl_reconfigure_filters(vsi); + /* Configure promiscuous mode */ + ixl_if_promisc_set(ctx, if_getflags(ifp)); + #ifdef IXL_IW if (ixl_enable_iwarp && pf->iw_enabled) { ret = ixl_iw_pf_init(pf); @@ -923,7 +905,7 @@ ixl_if_stop(if_ctx_t ctx) #endif ixl_disable_rings_intr(vsi); - ixl_disable_rings(vsi); + ixl_disable_rings(pf, vsi, &pf->qtag); } static int @@ -936,6 +918,9 @@ ixl_if_msix_intr_assign(if_ctx_t ctx, int msix) int err, i, rid, vector = 0; char buf[16]; + MPASS(vsi->shared->isc_nrxqsets > 0); + MPASS(vsi->shared->isc_ntxqsets > 0); + /* Admin Que must use vector 0*/ rid = vector + 1; err = iflib_irq_alloc_generic(ctx, &vsi->irq, rid, IFLIB_INTR_ADMIN, @@ -943,14 +928,14 @@ ixl_if_msix_intr_assign(if_ctx_t ctx, int msix) if (err) { iflib_irq_free(ctx, &vsi->irq); device_printf(iflib_get_dev(ctx), - "Failed to register Admin que handler"); + "Failed to register Admin Que handler"); return (err); } - // TODO: Re-enable this at some point - // iflib_softirq_alloc_generic(ctx, rid, IFLIB_INTR_IOV, pf, 0, "ixl_iov"); + /* Create soft IRQ for handling VFLRs */ + iflib_softirq_alloc_generic(ctx, &pf->iov_irq, IFLIB_INTR_IOV, pf, 0, "iov"); /* Now set up the stations */ - for (i = 0, vector = 1; i < vsi->num_rx_queues; i++, vector++, rx_que++) { + for (i = 0, vector = 1; i < vsi->shared->isc_nrxqsets; i++, vector++, rx_que++) { rid = vector + 1; snprintf(buf, sizeof(buf), "rxq%d", i); @@ -960,7 +945,7 @@ ixl_if_msix_intr_assign(if_ctx_t ctx, int msix) * what's expected in the iflib context? */ if (err) { device_printf(iflib_get_dev(ctx), - "Failed to allocate q int %d err: %d", i, err); + "Failed to allocate queue RX int vector %d, err: %d\n", i, err); vsi->num_rx_queues = i + 1; goto fail; } @@ -969,16 +954,16 @@ ixl_if_msix_intr_assign(if_ctx_t ctx, int msix) bzero(buf, sizeof(buf)); - for (i = 0; i < vsi->num_tx_queues; i++, tx_que++) { + for (i = 0; i < vsi->shared->isc_ntxqsets; i++, tx_que++) { snprintf(buf, sizeof(buf), "txq%d", i); iflib_softirq_alloc_generic(ctx, - &vsi->rx_queues[i % vsi->num_rx_queues].que_irq, + &vsi->rx_queues[i % vsi->shared->isc_nrxqsets].que_irq, IFLIB_INTR_TX, tx_que, tx_que->txr.me, buf); /* TODO: Maybe call a strategy function for this to figure out which * interrupts to map Tx queues to. I don't know if there's an immediately * better way than this other than a user-supplied map, though. */ - tx_que->msix = (i % vsi->num_rx_queues) + 1; + tx_que->msix = (i % vsi->shared->isc_nrxqsets) + 1; } return (0); @@ -1051,11 +1036,10 @@ ixl_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txq { struct ixl_pf *pf = iflib_get_softc(ctx); struct ixl_vsi *vsi = &pf->vsi; - struct i40e_hw *hw = vsi->hw; - struct ixl_tx_queue *tx_que = &vsi->tx_queues[txqid]; + struct i40e_hw *hw = vsi->hw; + struct ixl_tx_queue *tx_que = &vsi->tx_queues[txqid]; ixl_enable_queue(hw, tx_que->msix - 1); - return (0); } @@ -1066,12 +1050,11 @@ ixl_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, struct ixl_vsi *vsi = &pf->vsi; if_softc_ctx_t scctx = vsi->shared; struct ixl_tx_queue *que; - // int i; int i, j, error = 0; - MPASS(vsi->num_tx_queues > 0); + MPASS(scctx->isc_ntxqsets > 0); MPASS(ntxqs == 1); - MPASS(vsi->num_tx_queues == ntxqsets); + MPASS(scctx->isc_ntxqsets == ntxqsets); /* Allocate queue structure memory */ if (!(vsi->tx_queues = @@ -1118,9 +1101,12 @@ ixl_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, struct ixl_rx_queue *que; int i, error = 0; - MPASS(vsi->num_rx_queues > 0); +#ifdef INVARIANTS + if_softc_ctx_t scctx = vsi->shared; + MPASS(scctx->isc_nrxqsets > 0); MPASS(nrxqs == 1); - MPASS(vsi->num_rx_queues == nrxqsets); + MPASS(scctx->isc_nrxqsets == nrxqsets); +#endif /* Allocate queue structure memory */ if (!(vsi->rx_queues = @@ -1156,7 +1142,7 @@ ixl_if_queues_free(if_ctx_t ctx) struct ixl_pf *pf = iflib_get_softc(ctx); struct ixl_vsi *vsi = &pf->vsi; - if (vsi->enable_head_writeback) { + if (!vsi->enable_head_writeback) { struct ixl_tx_queue *que; int i = 0; @@ -1208,6 +1194,20 @@ ixl_update_link_status(struct ixl_pf *pf) } } +static void +ixl_handle_lan_overflow_event(struct ixl_pf *pf, struct i40e_arq_event_info *e) +{ + device_t dev = pf->dev; + u32 rxq_idx, qtx_ctl; + + rxq_idx = (e->desc.params.external.param0 & I40E_PRTDCB_RUPTQ_RXQNUM_MASK) >> + I40E_PRTDCB_RUPTQ_RXQNUM_SHIFT; + qtx_ctl = e->desc.params.external.param1; + + device_printf(dev, "LAN overflow event: global rxq_idx %d\n", rxq_idx); + device_printf(dev, "LAN overflow event: QTX_CTL 0x%08x\n", qtx_ctl); +} + static int ixl_process_adminq(struct ixl_pf *pf, u16 *pending) { @@ -1248,7 +1248,7 @@ ixl_process_adminq(struct ixl_pf *pf, u16 *pending) * aren't currently configured. */ case i40e_aqc_opc_event_lan_overflow: - device_printf(dev, "LAN overflow event\n"); + ixl_handle_lan_overflow_event(pf, &event); break; default: break; @@ -1278,13 +1278,9 @@ ixl_if_update_admin_status(if_ctx_t ctx) if (pf->state & IXL_PF_STATE_MDD_PENDING) ixl_handle_mdd_event(pf); -#ifdef PCI_IOV - if (pf->state & IXL_PF_STATE_VF_RESET_REQ) - iflib_iov_intr_deferred(ctx); -#endif - ixl_process_adminq(pf, &pending); ixl_update_link_status(pf); + ixl_update_stats_counters(pf); /* * If there are still messages to process, reschedule ourselves. @@ -1301,14 +1297,16 @@ ixl_if_multi_set(if_ctx_t ctx) { struct ixl_pf *pf = iflib_get_softc(ctx); struct ixl_vsi *vsi = &pf->vsi; - struct i40e_hw *hw = vsi->hw; - int mcnt = 0, flags; + struct i40e_hw *hw = vsi->hw; + int mcnt = 0, flags; + int del_mcnt; IOCTL_DEBUGOUT("ixl_if_multi_set: begin"); mcnt = if_multiaddr_count(iflib_get_ifp(ctx), MAX_MULTICAST_ADDR); - /* delete existing MC filters */ - ixl_del_multi(vsi); + /* Delete filters for removed multicast addresses */ + del_mcnt = ixl_del_multi(vsi); + vsi->num_macs -= del_mcnt; if (__predict_false(mcnt == MAX_MULTICAST_ADDR)) { i40e_aq_set_vsi_multicast_promiscuous(hw, @@ -1316,13 +1314,17 @@ ixl_if_multi_set(if_ctx_t ctx) return; } /* (re-)install filters for all mcast addresses */ + /* XXX: This bypasses filter count tracking code! */ mcnt = if_multi_apply(iflib_get_ifp(ctx), ixl_mc_filter_apply, vsi); if (mcnt > 0) { + vsi->num_macs += mcnt; flags = (IXL_FILTER_ADD | IXL_FILTER_USED | IXL_FILTER_MC); ixl_add_hw_filters(vsi, flags, mcnt); } + ixl_dbg_filter(pf, "%s: filter mac total: %d\n", + __func__, vsi->num_macs); IOCTL_DEBUGOUT("ixl_if_multi_set: end"); } @@ -1518,32 +1520,11 @@ ixl_if_promisc_set(if_ctx_t ctx, int flags) static void ixl_if_timer(if_ctx_t ctx, uint16_t qid) { - struct ixl_pf *pf = iflib_get_softc(ctx); - //struct i40e_hw *hw = &pf->hw; - //struct ixl_tx_queue *que = &vsi->tx_queues[qid]; - #if 0 - u32 mask; - - /* - ** Check status of the queues - */ - mask = (I40E_PFINT_DYN_CTLN_INTENA_MASK | - I40E_PFINT_DYN_CTLN_SWINT_TRIG_MASK); - - /* If queue param has outstanding work, trigger sw irq */ - // TODO: TX queues in iflib don't use HW interrupts; does this do anything? - if (que->busy) - wr32(hw, I40E_PFINT_DYN_CTLN(que->txr.me), mask); -#endif - if (qid != 0) return; /* Fire off the adminq task */ iflib_admin_intr_deferred(ctx); - - /* Update stats */ - ixl_update_stats_counters(pf); } static void @@ -1612,13 +1593,15 @@ ixl_if_get_counter(if_ctx_t ctx, ift_counter cnt) } } +#ifdef PCI_IOV static void ixl_if_vflr_handle(if_ctx_t ctx) { - IXL_DEV_ERR(iflib_get_dev(ctx), ""); + struct ixl_pf *pf = iflib_get_softc(ctx); - // TODO: call ixl_handle_vflr() + ixl_handle_vflr(pf); } +#endif static int ixl_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req) @@ -1676,6 +1659,7 @@ ixl_save_pf_tunables(struct ixl_pf *pf) pf->dbg_mask = ixl_core_debug_mask; pf->hw.debug_mask = ixl_shared_debug_mask; pf->vsi.enable_head_writeback = !!(ixl_enable_head_writeback); + pf->enable_vf_loopback = !!(ixl_enable_vf_loopback); #if 0 pf->dynamic_rx_itr = ixl_dynamic_rx_itr; pf->dynamic_tx_itr = ixl_dynamic_tx_itr; Modified: head/sys/dev/ixl/if_ixlv.c ============================================================================== --- head/sys/dev/ixl/if_ixlv.c Fri Oct 12 21:59:09 2018 (r339337) +++ head/sys/dev/ixl/if_ixlv.c Fri Oct 12 22:40:54 2018 (r339338) @@ -32,19 +32,19 @@ ******************************************************************************/ /*$FreeBSD$*/ -#include "ixl.h" #include "ixlv.h" /********************************************************************* * Driver version *********************************************************************/ -#define IXLV_DRIVER_VERSION_MAJOR 1 -#define IXLV_DRIVER_VERSION_MINOR 5 -#define IXLV_DRIVER_VERSION_BUILD 4 +#define IAVF_DRIVER_VERSION_MAJOR 2 +#define IAVF_DRIVER_VERSION_MINOR 0 +#define IAVF_DRIVER_VERSION_BUILD 0 -char ixlv_driver_version[] = __XSTRING(IXLV_DRIVER_VERSION_MAJOR) "." - __XSTRING(IXLV_DRIVER_VERSION_MINOR) "." - __XSTRING(IXLV_DRIVER_VERSION_BUILD) "-iflib-k"; +#define IAVF_DRIVER_VERSION_STRING \ + __XSTRING(IAVF_DRIVER_VERSION_MAJOR) "." \ + __XSTRING(IAVF_DRIVER_VERSION_MINOR) "." \ + __XSTRING(IAVF_DRIVER_VERSION_BUILD) "-k" /********************************************************************* * PCI Device ID Table @@ -56,9 +56,9 @@ char ixlv_driver_version[] = __XSTRING(IXLV_DRIVER_VER static pci_vendor_info_t ixlv_vendor_info_array[] = { - {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_VF, 0, 0, 0}, - {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_VF, 0, 0, 0}, - {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_ADAPTIVE_VF, 0, 0, 0}, + PVID(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_VF, "Intel(R) Ethernet Virtual Function 700 Series"), + PVID(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_X722_VF, "Intel(R) Ethernet Virtual Function 700 Series (X722)"), + PVID(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_ADAPTIVE_VF, "Intel(R) Ethernet Adaptive Virtual Function"), /* required last entry */ PVID_END }; @@ -66,7 +66,7 @@ static pci_vendor_info_t ixlv_vendor_info_array[] = /********************************************************************* * Function prototypes *********************************************************************/ -static void *ixlv_register(device_t dev); +static void *ixlv_register(device_t dev); static int ixlv_if_attach_pre(if_ctx_t ctx); static int ixlv_if_attach_post(if_ctx_t ctx); static int ixlv_if_detach(if_ctx_t ctx); @@ -76,7 +76,8 @@ static int ixlv_if_resume(if_ctx_t ctx); static int ixlv_if_msix_intr_assign(if_ctx_t ctx, int msix); static void ixlv_if_enable_intr(if_ctx_t ctx); static void ixlv_if_disable_intr(if_ctx_t ctx); -static int ixlv_if_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid); +static int ixlv_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid); +static int ixlv_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid); static int ixlv_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxqs, int ntxqsets); static int ixlv_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nqs, int nqsets); static void ixlv_if_queues_free(if_ctx_t ctx); @@ -100,8 +101,8 @@ static int ixlv_vf_config(struct ixlv_sc *); static void ixlv_init_filters(struct ixlv_sc *); static void ixlv_free_pci_resources(struct ixlv_sc *); static void ixlv_free_filters(struct ixlv_sc *); -static void ixlv_setup_interface(device_t, struct ixl_vsi *); -static void ixlv_add_sysctls(struct ixlv_sc *); +static void ixlv_setup_interface(device_t, struct ixlv_sc *); +static void ixlv_add_device_sysctls(struct ixlv_sc *); static void ixlv_enable_adminq_irq(struct i40e_hw *); static void ixlv_disable_adminq_irq(struct i40e_hw *); static void ixlv_enable_queue_irq(struct i40e_hw *, int); @@ -113,22 +114,25 @@ static int ixlv_add_mac_filter(struct ixlv_sc *, u8 *, static int ixlv_del_mac_filter(struct ixlv_sc *sc, u8 *macaddr); static int ixlv_msix_que(void *); static int ixlv_msix_adminq(void *); -static void ixlv_do_adminq_locked(struct ixlv_sc *sc); -static void ixl_init_cmd_complete(struct ixl_vc_cmd *, void *, - enum i40e_status_code); -static void ixlv_configure_itr(struct ixlv_sc *); +//static void ixlv_del_multi(struct ixlv_sc *sc); +static void ixlv_init_multi(struct ixlv_sc *sc); +static void ixlv_configure_itr(struct ixlv_sc *sc); -static void ixlv_setup_vlan_filters(struct ixlv_sc *); +static int ixlv_sysctl_rx_itr(SYSCTL_HANDLER_ARGS); +static int ixlv_sysctl_tx_itr(SYSCTL_HANDLER_ARGS); +static int ixlv_sysctl_current_speed(SYSCTL_HANDLER_ARGS); +static int ixlv_sysctl_sw_filter_list(SYSCTL_HANDLER_ARGS); +static int ixlv_sysctl_queue_interrupt_table(SYSCTL_HANDLER_ARGS); +static int ixlv_sysctl_vf_reset(SYSCTL_HANDLER_ARGS); +static int ixlv_sysctl_vflr_reset(SYSCTL_HANDLER_ARGS); -static char *ixlv_vc_speed_to_string(enum virtchnl_link_speed link_speed); -static int ixlv_sysctl_current_speed(SYSCTL_HANDLER_ARGS); +char *ixlv_vc_speed_to_string(enum virtchnl_link_speed link_speed); +static void ixlv_save_tunables(struct ixlv_sc *); +static enum i40e_status_code + ixlv_process_adminq(struct ixlv_sc *, u16 *); +static int ixlv_send_vc_msg(struct ixlv_sc *sc, u32 op); +static int ixlv_send_vc_msg_sleep(struct ixlv_sc *sc, u32 op); -// static void ixlv_add_sysctls(struct ixlv_sc *); -#ifdef IXL_DEBUG -static int ixlv_sysctl_qtx_tail_handler(SYSCTL_HANDLER_ARGS); -static int ixlv_sysctl_qrx_tail_handler(SYSCTL_HANDLER_ARGS); -#endif - /********************************************************************* * FreeBSD Device Interface Entry Points *********************************************************************/ @@ -144,18 +148,22 @@ static device_method_t ixlv_methods[] = { }; static driver_t ixlv_driver = { - "ixlv", ixlv_methods, sizeof(struct ixlv_sc), + "iavf", ixlv_methods, sizeof(struct ixlv_sc), }; devclass_t ixlv_devclass; -DRIVER_MODULE(ixlv, pci, ixlv_driver, ixlv_devclass, 0, 0); +DRIVER_MODULE(iavf, pci, ixlv_driver, ixlv_devclass, 0, 0); MODULE_PNP_INFO("U32:vendor;U32:device;U32:subvendor;U32:subdevice;U32:revision", - pci, ixlv, ixlv_vendor_info_array, + pci, iavf, ixlv_vendor_info_array, nitems(ixlv_vendor_info_array) - 1); -MODULE_DEPEND(ixlv, pci, 1, 1, 1); -MODULE_DEPEND(ixlv, ether, 1, 1, 1); -MODULE_DEPEND(ixlv, iflib, 1, 1, 1); +MODULE_VERSION(iavf, 1); +MODULE_DEPEND(iavf, pci, 1, 1, 1); +MODULE_DEPEND(iavf, ether, 1, 1, 1); +MODULE_DEPEND(iavf, iflib, 1, 1, 1); + +MALLOC_DEFINE(M_IXLV, "iavf", "iavf driver allocations"); + static device_method_t ixlv_if_methods[] = { DEVMETHOD(ifdi_attach_pre, ixlv_if_attach_pre), DEVMETHOD(ifdi_attach_post, ixlv_if_attach_post), @@ -168,14 +176,14 @@ static device_method_t ixlv_if_methods[] = { DEVMETHOD(ifdi_msix_intr_assign, ixlv_if_msix_intr_assign), DEVMETHOD(ifdi_intr_enable, ixlv_if_enable_intr), DEVMETHOD(ifdi_intr_disable, ixlv_if_disable_intr), - DEVMETHOD(ifdi_queue_intr_enable, ixlv_if_queue_intr_enable), + DEVMETHOD(ifdi_rx_queue_intr_enable, ixlv_if_rx_queue_intr_enable), + DEVMETHOD(ifdi_tx_queue_intr_enable, ixlv_if_tx_queue_intr_enable), DEVMETHOD(ifdi_tx_queues_alloc, ixlv_if_tx_queues_alloc), DEVMETHOD(ifdi_rx_queues_alloc, ixlv_if_rx_queues_alloc), DEVMETHOD(ifdi_queues_free, ixlv_if_queues_free), DEVMETHOD(ifdi_update_admin_status, ixlv_if_update_admin_status), DEVMETHOD(ifdi_multi_set, ixlv_if_multi_set), DEVMETHOD(ifdi_mtu_set, ixlv_if_mtu_set), - // DEVMETHOD(ifdi_crcstrip_set, ixlv_if_crcstrip_set), DEVMETHOD(ifdi_media_status, ixlv_if_media_status), DEVMETHOD(ifdi_media_change, ixlv_if_media_change), DEVMETHOD(ifdi_promisc_set, ixlv_if_promisc_set), @@ -187,95 +195,73 @@ static device_method_t ixlv_if_methods[] = { }; static driver_t ixlv_if_driver = { - "ixlv_if", ixlv_if_methods, sizeof(struct ixlv_sc) + "iavf_if", ixlv_if_methods, sizeof(struct ixlv_sc) }; /* ** TUNEABLE PARAMETERS: */ -static SYSCTL_NODE(_hw, OID_AUTO, ixlv, CTLFLAG_RD, 0, - "IXLV driver parameters"); +static SYSCTL_NODE(_hw, OID_AUTO, iavf, CTLFLAG_RD, 0, + "iavf driver parameters"); /* -** Number of descriptors per ring: -** - TX and RX sizes are independently configurable -*/ -static int ixlv_tx_ring_size = IXL_DEFAULT_RING; -TUNABLE_INT("hw.ixlv.tx_ring_size", &ixlv_tx_ring_size); -SYSCTL_INT(_hw_ixlv, OID_AUTO, tx_ring_size, CTLFLAG_RDTUN, - &ixlv_tx_ring_size, 0, "TX Descriptor Ring Size"); - -static int ixlv_rx_ring_size = IXL_DEFAULT_RING; -TUNABLE_INT("hw.ixlv.rx_ring_size", &ixlv_rx_ring_size); -SYSCTL_INT(_hw_ixlv, OID_AUTO, rx_ring_size, CTLFLAG_RDTUN, - &ixlv_rx_ring_size, 0, "TX Descriptor Ring Size"); - -/* Set to zero to auto calculate */ -int ixlv_max_queues = 0; -TUNABLE_INT("hw.ixlv.max_queues", &ixlv_max_queues); -SYSCTL_INT(_hw_ixlv, OID_AUTO, max_queues, CTLFLAG_RDTUN, - &ixlv_max_queues, 0, "Number of Queues"); - -/* * Different method for processing TX descriptor * completion. */ static int ixlv_enable_head_writeback = 0; -TUNABLE_INT("hw.ixlv.enable_head_writeback", +TUNABLE_INT("hw.iavf.enable_head_writeback", &ixlv_enable_head_writeback); -SYSCTL_INT(_hw_ixlv, OID_AUTO, enable_head_writeback, CTLFLAG_RDTUN, +SYSCTL_INT(_hw_iavf, OID_AUTO, enable_head_writeback, CTLFLAG_RDTUN, &ixlv_enable_head_writeback, 0, "For detecting last completed TX descriptor by hardware, use value written by HW instead of checking descriptors"); -/* -** Controls for Interrupt Throttling -** - true/false for dynamic adjustment -** - default values for static ITR -*/ -int ixlv_dynamic_rx_itr = 0; -TUNABLE_INT("hw.ixlv.dynamic_rx_itr", &ixlv_dynamic_rx_itr); -SYSCTL_INT(_hw_ixlv, OID_AUTO, dynamic_rx_itr, CTLFLAG_RDTUN, - &ixlv_dynamic_rx_itr, 0, "Dynamic RX Interrupt Rate"); +static int ixlv_core_debug_mask = 0; +TUNABLE_INT("hw.iavf.core_debug_mask", + &ixlv_core_debug_mask); +SYSCTL_INT(_hw_iavf, OID_AUTO, core_debug_mask, CTLFLAG_RDTUN, + &ixlv_core_debug_mask, 0, + "Display debug statements that are printed in non-shared code"); -int ixlv_dynamic_tx_itr = 0; -TUNABLE_INT("hw.ixlv.dynamic_tx_itr", &ixlv_dynamic_tx_itr); -SYSCTL_INT(_hw_ixlv, OID_AUTO, dynamic_tx_itr, CTLFLAG_RDTUN, - &ixlv_dynamic_tx_itr, 0, "Dynamic TX Interrupt Rate"); +static int ixlv_shared_debug_mask = 0; +TUNABLE_INT("hw.iavf.shared_debug_mask", + &ixlv_shared_debug_mask); +SYSCTL_INT(_hw_iavf, OID_AUTO, shared_debug_mask, CTLFLAG_RDTUN, + &ixlv_shared_debug_mask, 0, + "Display debug statements that are printed in shared code"); int ixlv_rx_itr = IXL_ITR_8K; -TUNABLE_INT("hw.ixlv.rx_itr", &ixlv_rx_itr); -SYSCTL_INT(_hw_ixlv, OID_AUTO, rx_itr, CTLFLAG_RDTUN, +TUNABLE_INT("hw.iavf.rx_itr", &ixlv_rx_itr); +SYSCTL_INT(_hw_iavf, OID_AUTO, rx_itr, CTLFLAG_RDTUN, &ixlv_rx_itr, 0, "RX Interrupt Rate"); int ixlv_tx_itr = IXL_ITR_4K; -TUNABLE_INT("hw.ixlv.tx_itr", &ixlv_tx_itr); -SYSCTL_INT(_hw_ixlv, OID_AUTO, tx_itr, CTLFLAG_RDTUN, +TUNABLE_INT("hw.iavf.tx_itr", &ixlv_tx_itr); +SYSCTL_INT(_hw_iavf, OID_AUTO, tx_itr, CTLFLAG_RDTUN, &ixlv_tx_itr, 0, "TX Interrupt Rate"); -extern struct if_txrx ixl_txrx; +extern struct if_txrx ixl_txrx_hwb; +extern struct if_txrx ixl_txrx_dwb; static struct if_shared_ctx ixlv_sctx_init = { .isc_magic = IFLIB_MAGIC, .isc_q_align = PAGE_SIZE,/* max(DBA_ALIGN, PAGE_SIZE) */ .isc_tx_maxsize = IXL_TSO_SIZE + sizeof(struct ether_vlan_header), - .isc_tx_maxsegsize = PAGE_SIZE, + .isc_tx_maxsegsize = IXL_MAX_DMA_SEG_SIZE, .isc_tso_maxsize = IXL_TSO_SIZE + sizeof(struct ether_vlan_header), - .isc_tso_maxsegsize = PAGE_SIZE, - // TODO: Review the rx_maxsize and rx_maxsegsize params - // Where are they used in iflib? + .isc_tso_maxsegsize = IXL_MAX_DMA_SEG_SIZE, .isc_rx_maxsize = 16384, - .isc_rx_nsegments = 1, - .isc_rx_maxsegsize = 16384, - // TODO: What is isc_nfl for? + .isc_rx_nsegments = IXL_MAX_RX_SEGS, + .isc_rx_maxsegsize = IXL_MAX_DMA_SEG_SIZE, .isc_nfl = 1, .isc_ntxqs = 1, .isc_nrxqs = 1, .isc_admin_intrcnt = 1, .isc_vendor_info = ixlv_vendor_info_array, - .isc_driver_version = ixlv_driver_version, + .isc_driver_version = IAVF_DRIVER_VERSION_STRING, .isc_driver = &ixlv_if_driver, + .isc_flags = IFLIB_NEED_SCRATCH | IFLIB_NEED_ZERO_CSUM | IFLIB_IS_VF, .isc_nrxd_min = {IXL_MIN_RING}, .isc_ntxd_min = {IXL_MIN_RING}, @@ -288,65 +274,83 @@ static struct if_shared_ctx ixlv_sctx_init = { if_shared_ctx_t ixlv_sctx = &ixlv_sctx_init; /*** Functions ***/ - static void * ixlv_register(device_t dev) { return (ixlv_sctx); - } +} static int +ixlv_allocate_pci_resources(struct ixlv_sc *sc) +{ + struct i40e_hw *hw = &sc->hw; + device_t dev = iflib_get_dev(sc->vsi.ctx); + int rid; + + /* Map BAR0 */ + rid = PCIR_BAR(0); + sc->pci_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &rid, RF_ACTIVE); + + if (!(sc->pci_mem)) { + device_printf(dev, "Unable to allocate bus resource: PCI memory\n"); + return (ENXIO); + } + + /* Save off the PCI information */ + hw->vendor_id = pci_get_vendor(dev); + hw->device_id = pci_get_device(dev); + hw->revision_id = pci_read_config(dev, PCIR_REVID, 1); + hw->subsystem_vendor_id = + pci_read_config(dev, PCIR_SUBVEND_0, 2); + hw->subsystem_device_id = + pci_read_config(dev, PCIR_SUBDEV_0, 2); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***