1 /******************************************************************************
3 Copyright (c) 2001-2017, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ******************************************************************************/
37 #include "opt_inet6.h"
43 #include <net/netmap.h>
44 #include <dev/netmap/netmap_kern.h>
46 /************************************************************************
48 ************************************************************************/
49 char ixv_driver_version[] = "2.0.1-k";
51 /************************************************************************
54 * Used by probe to select devices to load on
55 * Last field stores an index into ixv_strings
56 * Last entry must be all 0s
58 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, String Index }
59 ************************************************************************/
60 static pci_vendor_info_t ixv_vendor_info_array[] =
62 PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF, "Intel(R) X520 82599 Virtual Function"),
63 PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF, "Intel(R) X540 Virtual Function"),
64 PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF, "Intel(R) X550 Virtual Function"),
65 PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF, "Intel(R) X552 Virtual Function"),
66 PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF, "Intel(R) X553 Virtual Function"),
67 /* required last entry */
71 /************************************************************************
73 ************************************************************************/
74 static void *ixv_register(device_t);
75 static int ixv_if_attach_pre(if_ctx_t);
76 static int ixv_if_attach_post(if_ctx_t);
77 static int ixv_if_detach(if_ctx_t);
79 static int ixv_if_rx_queue_intr_enable(if_ctx_t, uint16_t);
80 static int ixv_if_tx_queues_alloc(if_ctx_t, caddr_t *, uint64_t *, int, int);
81 static int ixv_if_rx_queues_alloc(if_ctx_t, caddr_t *, uint64_t *, int, int);
82 static void ixv_if_queues_free(if_ctx_t);
83 static void ixv_identify_hardware(if_ctx_t);
84 static void ixv_init_device_features(struct ixgbe_softc *);
85 static int ixv_allocate_pci_resources(if_ctx_t);
86 static void ixv_free_pci_resources(if_ctx_t);
87 static int ixv_setup_interface(if_ctx_t);
88 static void ixv_if_media_status(if_ctx_t, struct ifmediareq *);
89 static int ixv_if_media_change(if_ctx_t);
90 static void ixv_if_update_admin_status(if_ctx_t);
91 static int ixv_if_msix_intr_assign(if_ctx_t, int);
93 static int ixv_if_mtu_set(if_ctx_t, uint32_t);
94 static void ixv_if_init(if_ctx_t);
95 static void ixv_if_local_timer(if_ctx_t, uint16_t);
96 static void ixv_if_stop(if_ctx_t);
97 static int ixv_negotiate_api(struct ixgbe_softc *);
99 static void ixv_initialize_transmit_units(if_ctx_t);
100 static void ixv_initialize_receive_units(if_ctx_t);
101 static void ixv_initialize_rss_mapping(struct ixgbe_softc *);
103 static void ixv_setup_vlan_support(if_ctx_t);
104 static void ixv_configure_ivars(struct ixgbe_softc *);
105 static void ixv_if_enable_intr(if_ctx_t);
106 static void ixv_if_disable_intr(if_ctx_t);
107 static void ixv_if_multi_set(if_ctx_t);
109 static void ixv_if_register_vlan(if_ctx_t, u16);
110 static void ixv_if_unregister_vlan(if_ctx_t, u16);
112 static uint64_t ixv_if_get_counter(if_ctx_t, ift_counter);
113 static bool ixv_if_needs_restart(if_ctx_t, enum iflib_restart_event);
115 static void ixv_save_stats(struct ixgbe_softc *);
116 static void ixv_init_stats(struct ixgbe_softc *);
117 static void ixv_update_stats(struct ixgbe_softc *);
118 static void ixv_add_stats_sysctls(struct ixgbe_softc *);
120 static int ixv_sysctl_debug(SYSCTL_HANDLER_ARGS);
121 static void ixv_set_ivar(struct ixgbe_softc *, u8, u8, s8);
123 static u8 *ixv_mc_array_itr(struct ixgbe_hw *, u8 **, u32 *);
125 /* The MSI-X Interrupt handlers */
126 static int ixv_msix_que(void *);
127 static int ixv_msix_mbx(void *);
129 /************************************************************************
130 * FreeBSD Device Interface Entry Points
131 ************************************************************************/
132 static device_method_t ixv_methods[] = {
133 /* Device interface */
134 DEVMETHOD(device_register, ixv_register),
135 DEVMETHOD(device_probe, iflib_device_probe),
136 DEVMETHOD(device_attach, iflib_device_attach),
137 DEVMETHOD(device_detach, iflib_device_detach),
138 DEVMETHOD(device_shutdown, iflib_device_shutdown),
142 static driver_t ixv_driver = {
143 "ixv", ixv_methods, sizeof(struct ixgbe_softc),
146 devclass_t ixv_devclass;
147 DRIVER_MODULE(ixv, pci, ixv_driver, ixv_devclass, 0, 0);
148 IFLIB_PNP_INFO(pci, ixv_driver, ixv_vendor_info_array);
149 MODULE_DEPEND(ixv, iflib, 1, 1, 1);
150 MODULE_DEPEND(ixv, pci, 1, 1, 1);
151 MODULE_DEPEND(ixv, ether, 1, 1, 1);
153 static device_method_t ixv_if_methods[] = {
154 DEVMETHOD(ifdi_attach_pre, ixv_if_attach_pre),
155 DEVMETHOD(ifdi_attach_post, ixv_if_attach_post),
156 DEVMETHOD(ifdi_detach, ixv_if_detach),
157 DEVMETHOD(ifdi_init, ixv_if_init),
158 DEVMETHOD(ifdi_stop, ixv_if_stop),
159 DEVMETHOD(ifdi_msix_intr_assign, ixv_if_msix_intr_assign),
160 DEVMETHOD(ifdi_intr_enable, ixv_if_enable_intr),
161 DEVMETHOD(ifdi_intr_disable, ixv_if_disable_intr),
162 DEVMETHOD(ifdi_tx_queue_intr_enable, ixv_if_rx_queue_intr_enable),
163 DEVMETHOD(ifdi_rx_queue_intr_enable, ixv_if_rx_queue_intr_enable),
164 DEVMETHOD(ifdi_tx_queues_alloc, ixv_if_tx_queues_alloc),
165 DEVMETHOD(ifdi_rx_queues_alloc, ixv_if_rx_queues_alloc),
166 DEVMETHOD(ifdi_queues_free, ixv_if_queues_free),
167 DEVMETHOD(ifdi_update_admin_status, ixv_if_update_admin_status),
168 DEVMETHOD(ifdi_multi_set, ixv_if_multi_set),
169 DEVMETHOD(ifdi_mtu_set, ixv_if_mtu_set),
170 DEVMETHOD(ifdi_media_status, ixv_if_media_status),
171 DEVMETHOD(ifdi_media_change, ixv_if_media_change),
172 DEVMETHOD(ifdi_timer, ixv_if_local_timer),
173 DEVMETHOD(ifdi_vlan_register, ixv_if_register_vlan),
174 DEVMETHOD(ifdi_vlan_unregister, ixv_if_unregister_vlan),
175 DEVMETHOD(ifdi_get_counter, ixv_if_get_counter),
176 DEVMETHOD(ifdi_needs_restart, ixv_if_needs_restart),
180 static driver_t ixv_if_driver = {
181 "ixv_if", ixv_if_methods, sizeof(struct ixgbe_softc)
185 * TUNEABLE PARAMETERS:
188 /* Flow control setting, default to full */
189 static int ixv_flow_control = ixgbe_fc_full;
190 TUNABLE_INT("hw.ixv.flow_control", &ixv_flow_control);
193 * Header split: this causes the hardware to DMA
194 * the header into a separate mbuf from the payload,
195 * it can be a performance win in some workloads, but
196 * in others it actually hurts, its off by default.
198 static int ixv_header_split = false;
199 TUNABLE_INT("hw.ixv.hdr_split", &ixv_header_split);
202 * Shadow VFTA table, this is needed because
203 * the real filter table gets cleared during
204 * a soft reset and we need to repopulate it.
206 static u32 ixv_shadow_vfta[IXGBE_VFTA_SIZE];
207 extern struct if_txrx ixgbe_txrx;
209 static struct if_shared_ctx ixv_sctx_init = {
210 .isc_magic = IFLIB_MAGIC,
211 .isc_q_align = PAGE_SIZE,/* max(DBA_ALIGN, PAGE_SIZE) */
212 .isc_tx_maxsize = IXGBE_TSO_SIZE + sizeof(struct ether_vlan_header),
213 .isc_tx_maxsegsize = PAGE_SIZE,
214 .isc_tso_maxsize = IXGBE_TSO_SIZE + sizeof(struct ether_vlan_header),
215 .isc_tso_maxsegsize = PAGE_SIZE,
216 .isc_rx_maxsize = MJUM16BYTES,
217 .isc_rx_nsegments = 1,
218 .isc_rx_maxsegsize = MJUM16BYTES,
222 .isc_admin_intrcnt = 1,
223 .isc_vendor_info = ixv_vendor_info_array,
224 .isc_driver_version = ixv_driver_version,
225 .isc_driver = &ixv_if_driver,
226 .isc_flags = IFLIB_IS_VF | IFLIB_TSO_INIT_IP,
228 .isc_nrxd_min = {MIN_RXD},
229 .isc_ntxd_min = {MIN_TXD},
230 .isc_nrxd_max = {MAX_RXD},
231 .isc_ntxd_max = {MAX_TXD},
232 .isc_nrxd_default = {DEFAULT_RXD},
233 .isc_ntxd_default = {DEFAULT_TXD},
237 ixv_register(device_t dev)
239 return (&ixv_sctx_init);
242 /************************************************************************
243 * ixv_if_tx_queues_alloc
244 ************************************************************************/
246 ixv_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs,
247 int ntxqs, int ntxqsets)
249 struct ixgbe_softc *sc = iflib_get_softc(ctx);
250 if_softc_ctx_t scctx = sc->shared;
251 struct ix_tx_queue *que;
254 MPASS(sc->num_tx_queues == ntxqsets);
257 /* Allocate queue structure memory */
259 (struct ix_tx_queue *)malloc(sizeof(struct ix_tx_queue) * ntxqsets,
260 M_DEVBUF, M_NOWAIT | M_ZERO);
261 if (!sc->tx_queues) {
262 device_printf(iflib_get_dev(ctx),
263 "Unable to allocate TX ring memory\n");
267 for (i = 0, que = sc->tx_queues; i < ntxqsets; i++, que++) {
268 struct tx_ring *txr = &que->txr;
271 txr->sc = que->sc = sc;
273 /* Allocate report status array */
274 if (!(txr->tx_rsq = (qidx_t *)malloc(sizeof(qidx_t) * scctx->isc_ntxd[0], M_DEVBUF, M_NOWAIT | M_ZERO))) {
278 for (j = 0; j < scctx->isc_ntxd[0]; j++)
279 txr->tx_rsq[j] = QIDX_INVALID;
280 /* get the virtual and physical address of the hardware queues */
281 txr->tail = IXGBE_VFTDT(txr->me);
282 txr->tx_base = (union ixgbe_adv_tx_desc *)vaddrs[i*ntxqs];
283 txr->tx_paddr = paddrs[i*ntxqs];
286 txr->total_packets = 0;
290 device_printf(iflib_get_dev(ctx), "allocated for %d queues\n",
296 ixv_if_queues_free(ctx);
299 } /* ixv_if_tx_queues_alloc */
301 /************************************************************************
302 * ixv_if_rx_queues_alloc
303 ************************************************************************/
305 ixv_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs,
306 int nrxqs, int nrxqsets)
308 struct ixgbe_softc *sc = iflib_get_softc(ctx);
309 struct ix_rx_queue *que;
312 MPASS(sc->num_rx_queues == nrxqsets);
315 /* Allocate queue structure memory */
317 (struct ix_rx_queue *)malloc(sizeof(struct ix_rx_queue) * nrxqsets,
318 M_DEVBUF, M_NOWAIT | M_ZERO);
319 if (!sc->rx_queues) {
320 device_printf(iflib_get_dev(ctx),
321 "Unable to allocate TX ring memory\n");
326 for (i = 0, que = sc->rx_queues; i < nrxqsets; i++, que++) {
327 struct rx_ring *rxr = &que->rxr;
329 rxr->sc = que->sc = sc;
332 /* get the virtual and physical address of the hw queues */
333 rxr->tail = IXGBE_VFRDT(rxr->me);
334 rxr->rx_base = (union ixgbe_adv_rx_desc *)vaddrs[i];
335 rxr->rx_paddr = paddrs[i*nrxqs];
340 device_printf(iflib_get_dev(ctx), "allocated for %d rx queues\n",
346 ixv_if_queues_free(ctx);
349 } /* ixv_if_rx_queues_alloc */
351 /************************************************************************
353 ************************************************************************/
355 ixv_if_queues_free(if_ctx_t ctx)
357 struct ixgbe_softc *sc = iflib_get_softc(ctx);
358 struct ix_tx_queue *que = sc->tx_queues;
364 for (i = 0; i < sc->num_tx_queues; i++, que++) {
365 struct tx_ring *txr = &que->txr;
366 if (txr->tx_rsq == NULL)
369 free(txr->tx_rsq, M_DEVBUF);
372 if (sc->tx_queues != NULL)
373 free(sc->tx_queues, M_DEVBUF);
375 if (sc->rx_queues != NULL)
376 free(sc->rx_queues, M_DEVBUF);
377 sc->tx_queues = NULL;
378 sc->rx_queues = NULL;
379 } /* ixv_if_queues_free */
381 /************************************************************************
382 * ixv_if_attach_pre - Device initialization routine
384 * Called when the driver is being loaded.
385 * Identifies the type of hardware, allocates all resources
386 * and initializes the hardware.
388 * return 0 on success, positive on failure
389 ************************************************************************/
391 ixv_if_attach_pre(if_ctx_t ctx)
393 struct ixgbe_softc *sc;
395 if_softc_ctx_t scctx;
399 INIT_DEBUGOUT("ixv_attach: begin");
401 /* Allocate, clear, and link in our sc structure */
402 dev = iflib_get_dev(ctx);
403 sc = iflib_get_softc(ctx);
407 scctx = sc->shared = iflib_get_softc_ctx(ctx);
408 sc->media = iflib_get_media(ctx);
411 /* Do base PCI setup - map BAR0 */
412 if (ixv_allocate_pci_resources(ctx)) {
413 device_printf(dev, "ixv_allocate_pci_resources() failed!\n");
419 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
420 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "debug",
421 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
422 sc, 0, ixv_sysctl_debug, "I", "Debug Info");
424 /* Determine hardware revision */
425 ixv_identify_hardware(ctx);
426 ixv_init_device_features(sc);
428 /* Initialize the shared code */
429 error = ixgbe_init_ops_vf(hw);
431 device_printf(dev, "ixgbe_init_ops_vf() failed!\n");
436 /* Setup the mailbox */
437 ixgbe_init_mbx_params_vf(hw);
439 error = hw->mac.ops.reset_hw(hw);
440 if (error == IXGBE_ERR_RESET_FAILED)
441 device_printf(dev, "...reset_hw() failure: Reset Failed!\n");
443 device_printf(dev, "...reset_hw() failed with error %d\n",
450 error = hw->mac.ops.init_hw(hw);
452 device_printf(dev, "...init_hw() failed with error %d\n",
458 /* Negotiate mailbox API version */
459 error = ixv_negotiate_api(sc);
462 "Mailbox API negotiation failed during attach!\n");
466 /* If no mac address was assigned, make a random one */
467 if (!ixv_check_ether_addr(hw->mac.addr)) {
468 ether_gen_addr(iflib_get_ifp(ctx),
469 (struct ether_addr *)hw->mac.addr);
470 bcopy(hw->mac.addr, hw->mac.perm_addr,
471 sizeof(hw->mac.perm_addr));
474 /* Most of the iflib initialization... */
476 iflib_set_mac(ctx, hw->mac.addr);
477 switch (sc->hw.mac.type) {
478 case ixgbe_mac_X550_vf:
479 case ixgbe_mac_X550EM_x_vf:
480 case ixgbe_mac_X550EM_a_vf:
481 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 2;
484 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 1;
486 scctx->isc_txqsizes[0] =
487 roundup2(scctx->isc_ntxd[0] * sizeof(union ixgbe_adv_tx_desc) +
488 sizeof(u32), DBA_ALIGN);
489 scctx->isc_rxqsizes[0] =
490 roundup2(scctx->isc_nrxd[0] * sizeof(union ixgbe_adv_rx_desc),
493 scctx->isc_tx_csum_flags = CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_TSO |
494 CSUM_IP6_TCP | CSUM_IP6_UDP | CSUM_IP6_TSO;
495 scctx->isc_tx_nsegments = IXGBE_82599_SCATTER;
496 scctx->isc_msix_bar = pci_msix_table_bar(dev);
497 scctx->isc_tx_tso_segments_max = scctx->isc_tx_nsegments;
498 scctx->isc_tx_tso_size_max = IXGBE_TSO_SIZE;
499 scctx->isc_tx_tso_segsize_max = PAGE_SIZE;
501 scctx->isc_txrx = &ixgbe_txrx;
504 * Tell the upper layer(s) we support everything the PF
505 * driver does except...
508 scctx->isc_capabilities = IXGBE_CAPS;
509 scctx->isc_capabilities ^= IFCAP_WOL;
510 scctx->isc_capenable = scctx->isc_capabilities;
512 INIT_DEBUGOUT("ixv_if_attach_pre: end");
517 ixv_free_pci_resources(ctx);
520 } /* ixv_if_attach_pre */
523 ixv_if_attach_post(if_ctx_t ctx)
525 struct ixgbe_softc *sc = iflib_get_softc(ctx);
526 device_t dev = iflib_get_dev(ctx);
529 /* Setup OS specific network interface */
530 error = ixv_setup_interface(ctx);
532 device_printf(dev, "Interface setup failed: %d\n", error);
536 /* Do the stats setup */
539 ixv_add_stats_sysctls(sc);
543 } /* ixv_if_attach_post */
545 /************************************************************************
546 * ixv_detach - Device removal routine
548 * Called when the driver is being removed.
549 * Stops the adapter and deallocates all the resources
550 * that were allocated for driver operation.
552 * return 0 on success, positive on failure
553 ************************************************************************/
555 ixv_if_detach(if_ctx_t ctx)
557 INIT_DEBUGOUT("ixv_detach: begin");
559 ixv_free_pci_resources(ctx);
562 } /* ixv_if_detach */
564 /************************************************************************
566 ************************************************************************/
568 ixv_if_mtu_set(if_ctx_t ctx, uint32_t mtu)
570 struct ixgbe_softc *sc = iflib_get_softc(ctx);
571 struct ifnet *ifp = iflib_get_ifp(ctx);
574 IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
575 if (mtu > IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR) {
579 sc->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR;
583 } /* ixv_if_mtu_set */
585 /************************************************************************
586 * ixv_if_init - Init entry point
588 * Used in two ways: It is used by the stack as an init entry
589 * point in network interface structure. It is also used
590 * by the driver as a hw/sw initialization routine to get
591 * to a consistent state.
593 * return 0 on success, positive on failure
594 ************************************************************************/
596 ixv_if_init(if_ctx_t ctx)
598 struct ixgbe_softc *sc = iflib_get_softc(ctx);
599 struct ifnet *ifp = iflib_get_ifp(ctx);
600 device_t dev = iflib_get_dev(ctx);
601 struct ixgbe_hw *hw = &sc->hw;
604 INIT_DEBUGOUT("ixv_if_init: begin");
605 hw->adapter_stopped = false;
606 hw->mac.ops.stop_adapter(hw);
608 /* reprogram the RAR[0] in case user changed it. */
609 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
611 /* Get the latest mac address, User can use a LAA */
612 bcopy(IF_LLADDR(ifp), hw->mac.addr, IXGBE_ETH_LENGTH_OF_ADDRESS);
613 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, 1);
615 /* Reset VF and renegotiate mailbox API version */
616 hw->mac.ops.reset_hw(hw);
617 hw->mac.ops.start_hw(hw);
618 error = ixv_negotiate_api(sc);
621 "Mailbox API negotiation failed in if_init!\n");
625 ixv_initialize_transmit_units(ctx);
627 /* Setup Multicast table */
628 ixv_if_multi_set(ctx);
630 sc->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx);
632 /* Configure RX settings */
633 ixv_initialize_receive_units(ctx);
635 /* Set up VLAN offload and filter */
636 ixv_setup_vlan_support(ctx);
638 /* Set up MSI-X routing */
639 ixv_configure_ivars(sc);
641 /* Set up auto-mask */
642 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_EICS_RTX_QUEUE);
644 /* Set moderation on the Link interrupt */
645 IXGBE_WRITE_REG(hw, IXGBE_VTEITR(sc->vector), IXGBE_LINK_ITR);
650 /* Config/Enable Link */
651 hw->mac.ops.check_link(hw, &sc->link_speed, &sc->link_up,
654 /* And now turn on interrupts */
655 ixv_if_enable_intr(ctx);
660 /************************************************************************
662 ************************************************************************/
664 ixv_enable_queue(struct ixgbe_softc *sc, u32 vector)
666 struct ixgbe_hw *hw = &sc->hw;
667 u32 queue = 1 << vector;
670 mask = (IXGBE_EIMS_RTX_QUEUE & queue);
671 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
672 } /* ixv_enable_queue */
674 /************************************************************************
676 ************************************************************************/
678 ixv_disable_queue(struct ixgbe_softc *sc, u32 vector)
680 struct ixgbe_hw *hw = &sc->hw;
681 u64 queue = (u64)(1 << vector);
684 mask = (IXGBE_EIMS_RTX_QUEUE & queue);
685 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, mask);
686 } /* ixv_disable_queue */
689 /************************************************************************
690 * ixv_msix_que - MSI-X Queue Interrupt Service routine
691 ************************************************************************/
693 ixv_msix_que(void *arg)
695 struct ix_rx_queue *que = arg;
696 struct ixgbe_softc *sc = que->sc;
698 ixv_disable_queue(sc, que->msix);
701 return (FILTER_SCHEDULE_THREAD);
704 /************************************************************************
706 ************************************************************************/
708 ixv_msix_mbx(void *arg)
710 struct ixgbe_softc *sc = arg;
711 struct ixgbe_hw *hw = &sc->hw;
716 /* First get the cause */
717 reg = IXGBE_READ_REG(hw, IXGBE_VTEICS);
718 /* Clear interrupt with write */
719 IXGBE_WRITE_REG(hw, IXGBE_VTEICR, reg);
721 /* Link status change */
722 if (reg & IXGBE_EICR_LSC)
723 iflib_admin_intr_deferred(sc->ctx);
725 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_EIMS_OTHER);
727 return (FILTER_HANDLED);
730 /************************************************************************
731 * ixv_media_status - Media Ioctl callback
733 * Called whenever the user queries the status of
734 * the interface using ifconfig.
735 ************************************************************************/
737 ixv_if_media_status(if_ctx_t ctx, struct ifmediareq * ifmr)
739 struct ixgbe_softc *sc = iflib_get_softc(ctx);
741 INIT_DEBUGOUT("ixv_media_status: begin");
743 iflib_admin_intr_deferred(ctx);
745 ifmr->ifm_status = IFM_AVALID;
746 ifmr->ifm_active = IFM_ETHER;
748 if (!sc->link_active)
751 ifmr->ifm_status |= IFM_ACTIVE;
753 switch (sc->link_speed) {
754 case IXGBE_LINK_SPEED_1GB_FULL:
755 ifmr->ifm_active |= IFM_1000_T | IFM_FDX;
757 case IXGBE_LINK_SPEED_10GB_FULL:
758 ifmr->ifm_active |= IFM_10G_T | IFM_FDX;
760 case IXGBE_LINK_SPEED_100_FULL:
761 ifmr->ifm_active |= IFM_100_TX | IFM_FDX;
763 case IXGBE_LINK_SPEED_10_FULL:
764 ifmr->ifm_active |= IFM_10_T | IFM_FDX;
767 } /* ixv_if_media_status */
769 /************************************************************************
770 * ixv_if_media_change - Media Ioctl callback
772 * Called when the user changes speed/duplex using
773 * media/mediopt option with ifconfig.
774 ************************************************************************/
776 ixv_if_media_change(if_ctx_t ctx)
778 struct ixgbe_softc *sc = iflib_get_softc(ctx);
779 struct ifmedia *ifm = iflib_get_media(ctx);
781 INIT_DEBUGOUT("ixv_media_change: begin");
783 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
786 switch (IFM_SUBTYPE(ifm->ifm_media)) {
790 device_printf(sc->dev, "Only auto media type\n");
795 } /* ixv_if_media_change */
798 /************************************************************************
801 * Negotiate the Mailbox API with the PF;
802 * start with the most featured API first.
803 ************************************************************************/
805 ixv_negotiate_api(struct ixgbe_softc *sc)
807 struct ixgbe_hw *hw = &sc->hw;
808 int mbx_api[] = { ixgbe_mbox_api_11,
810 ixgbe_mbox_api_unknown };
813 while (mbx_api[i] != ixgbe_mbox_api_unknown) {
814 if (ixgbevf_negotiate_api_version(hw, mbx_api[i]) == 0)
820 } /* ixv_negotiate_api */
823 /************************************************************************
824 * ixv_if_multi_set - Multicast Update
826 * Called whenever multicast address list is updated.
827 ************************************************************************/
829 ixv_if_multi_set(if_ctx_t ctx)
831 u8 mta[MAX_NUM_MULTICAST_ADDRESSES * IXGBE_ETH_LENGTH_OF_ADDRESS];
832 struct ixgbe_softc *sc = iflib_get_softc(ctx);
834 struct ifmultiaddr *ifma;
835 if_t ifp = iflib_get_ifp(ctx);
838 IOCTL_DEBUGOUT("ixv_if_multi_set: begin");
840 CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
841 if (ifma->ifma_addr->sa_family != AF_LINK)
843 bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
844 &mta[mcnt * IXGBE_ETH_LENGTH_OF_ADDRESS],
845 IXGBE_ETH_LENGTH_OF_ADDRESS);
851 sc->hw.mac.ops.update_mc_addr_list(&sc->hw, update_ptr, mcnt,
852 ixv_mc_array_itr, true);
853 } /* ixv_if_multi_set */
855 /************************************************************************
858 * An iterator function needed by the multicast shared code.
859 * It feeds the shared code routine the addresses in the
860 * array of ixv_set_multi() one by one.
861 ************************************************************************/
863 ixv_mc_array_itr(struct ixgbe_hw *hw, u8 **update_ptr, u32 *vmdq)
865 u8 *addr = *update_ptr;
870 newptr = addr + IXGBE_ETH_LENGTH_OF_ADDRESS;
871 *update_ptr = newptr;
874 } /* ixv_mc_array_itr */
876 /************************************************************************
877 * ixv_if_local_timer - Timer routine
879 * Checks for link status, updates statistics,
880 * and runs the watchdog check.
881 ************************************************************************/
883 ixv_if_local_timer(if_ctx_t ctx, uint16_t qid)
888 /* Fire off the adminq task */
889 iflib_admin_intr_deferred(ctx);
890 } /* ixv_if_local_timer */
892 /************************************************************************
893 * ixv_if_update_admin_status - Update OS on link state
895 * Note: Only updates the OS on the cached link state.
896 * The real check of the hardware only happens with
898 ************************************************************************/
900 ixv_if_update_admin_status(if_ctx_t ctx)
902 struct ixgbe_softc *sc = iflib_get_softc(ctx);
903 device_t dev = iflib_get_dev(ctx);
906 sc->hw.mac.get_link_status = true;
908 status = ixgbe_check_link(&sc->hw, &sc->link_speed,
909 &sc->link_up, false);
911 if (status != IXGBE_SUCCESS && sc->hw.adapter_stopped == false) {
912 /* Mailbox's Clear To Send status is lost or timeout occurred.
913 * We need reinitialization. */
914 iflib_get_ifp(ctx)->if_init(ctx);
918 if (sc->link_active == false) {
920 device_printf(dev, "Link is up %d Gbps %s \n",
921 ((sc->link_speed == 128) ? 10 : 1),
923 sc->link_active = true;
924 iflib_link_state_change(ctx, LINK_STATE_UP,
927 } else { /* Link down */
928 if (sc->link_active == true) {
930 device_printf(dev, "Link is Down\n");
931 iflib_link_state_change(ctx, LINK_STATE_DOWN, 0);
932 sc->link_active = false;
937 ixv_update_stats(sc);
938 } /* ixv_if_update_admin_status */
941 /************************************************************************
942 * ixv_if_stop - Stop the hardware
944 * Disables all traffic on the adapter by issuing a
945 * global reset on the MAC and deallocates TX/RX buffers.
946 ************************************************************************/
948 ixv_if_stop(if_ctx_t ctx)
950 struct ixgbe_softc *sc = iflib_get_softc(ctx);
951 struct ixgbe_hw *hw = &sc->hw;
953 INIT_DEBUGOUT("ixv_stop: begin\n");
955 ixv_if_disable_intr(ctx);
957 hw->mac.ops.reset_hw(hw);
958 sc->hw.adapter_stopped = false;
959 hw->mac.ops.stop_adapter(hw);
961 /* Update the stack */
963 ixv_if_update_admin_status(ctx);
965 /* reprogram the RAR[0] in case user changed it. */
966 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
970 /************************************************************************
971 * ixv_identify_hardware - Determine hardware revision.
972 ************************************************************************/
974 ixv_identify_hardware(if_ctx_t ctx)
976 struct ixgbe_softc *sc = iflib_get_softc(ctx);
977 device_t dev = iflib_get_dev(ctx);
978 struct ixgbe_hw *hw = &sc->hw;
980 /* Save off the information about this board */
981 hw->vendor_id = pci_get_vendor(dev);
982 hw->device_id = pci_get_device(dev);
983 hw->revision_id = pci_get_revid(dev);
984 hw->subsystem_vendor_id = pci_get_subvendor(dev);
985 hw->subsystem_device_id = pci_get_subdevice(dev);
987 /* A subset of set_mac_type */
988 switch (hw->device_id) {
989 case IXGBE_DEV_ID_82599_VF:
990 hw->mac.type = ixgbe_mac_82599_vf;
992 case IXGBE_DEV_ID_X540_VF:
993 hw->mac.type = ixgbe_mac_X540_vf;
995 case IXGBE_DEV_ID_X550_VF:
996 hw->mac.type = ixgbe_mac_X550_vf;
998 case IXGBE_DEV_ID_X550EM_X_VF:
999 hw->mac.type = ixgbe_mac_X550EM_x_vf;
1001 case IXGBE_DEV_ID_X550EM_A_VF:
1002 hw->mac.type = ixgbe_mac_X550EM_a_vf;
1005 device_printf(dev, "unknown mac type\n");
1006 hw->mac.type = ixgbe_mac_unknown;
1009 } /* ixv_identify_hardware */
1011 /************************************************************************
1012 * ixv_if_msix_intr_assign - Setup MSI-X Interrupt resources and handlers
1013 ************************************************************************/
1015 ixv_if_msix_intr_assign(if_ctx_t ctx, int msix)
1017 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1018 device_t dev = iflib_get_dev(ctx);
1019 struct ix_rx_queue *rx_que = sc->rx_queues;
1020 struct ix_tx_queue *tx_que;
1021 int error, rid, vector = 0;
1024 for (int i = 0; i < sc->num_rx_queues; i++, vector++, rx_que++) {
1027 snprintf(buf, sizeof(buf), "rxq%d", i);
1028 error = iflib_irq_alloc_generic(ctx, &rx_que->que_irq, rid,
1029 IFLIB_INTR_RXTX, ixv_msix_que, rx_que, rx_que->rxr.me, buf);
1032 device_printf(iflib_get_dev(ctx),
1033 "Failed to allocate que int %d err: %d", i, error);
1034 sc->num_rx_queues = i + 1;
1038 rx_que->msix = vector;
1041 for (int i = 0; i < sc->num_tx_queues; i++) {
1042 snprintf(buf, sizeof(buf), "txq%d", i);
1043 tx_que = &sc->tx_queues[i];
1044 tx_que->msix = i % sc->num_rx_queues;
1045 iflib_softirq_alloc_generic(ctx,
1046 &sc->rx_queues[tx_que->msix].que_irq,
1047 IFLIB_INTR_TX, tx_que, tx_que->txr.me, buf);
1050 error = iflib_irq_alloc_generic(ctx, &sc->irq, rid,
1051 IFLIB_INTR_ADMIN, ixv_msix_mbx, sc, 0, "aq");
1053 device_printf(iflib_get_dev(ctx),
1054 "Failed to register admin handler");
1058 sc->vector = vector;
1060 * Due to a broken design QEMU will fail to properly
1061 * enable the guest for MSIX unless the vectors in
1062 * the table are all set up, so we must rewrite the
1063 * ENABLE in the MSIX control register again at this
1064 * point to cause it to successfully initialize us.
1066 if (sc->hw.mac.type == ixgbe_mac_82599_vf) {
1068 pci_find_cap(dev, PCIY_MSIX, &rid);
1069 rid += PCIR_MSIX_CTRL;
1070 msix_ctrl = pci_read_config(dev, rid, 2);
1071 msix_ctrl |= PCIM_MSIXCTRL_MSIX_ENABLE;
1072 pci_write_config(dev, rid, msix_ctrl, 2);
1078 iflib_irq_free(ctx, &sc->irq);
1079 rx_que = sc->rx_queues;
1080 for (int i = 0; i < sc->num_rx_queues; i++, rx_que++)
1081 iflib_irq_free(ctx, &rx_que->que_irq);
1084 } /* ixv_if_msix_intr_assign */
1086 /************************************************************************
1087 * ixv_allocate_pci_resources
1088 ************************************************************************/
1090 ixv_allocate_pci_resources(if_ctx_t ctx)
1092 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1093 device_t dev = iflib_get_dev(ctx);
1097 sc->pci_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
1100 if (!(sc->pci_mem)) {
1101 device_printf(dev, "Unable to allocate bus resource: memory\n");
1105 sc->osdep.mem_bus_space_tag = rman_get_bustag(sc->pci_mem);
1106 sc->osdep.mem_bus_space_handle =
1107 rman_get_bushandle(sc->pci_mem);
1108 sc->hw.hw_addr = (u8 *)&sc->osdep.mem_bus_space_handle;
1111 } /* ixv_allocate_pci_resources */
1113 /************************************************************************
1114 * ixv_free_pci_resources
1115 ************************************************************************/
1117 ixv_free_pci_resources(if_ctx_t ctx)
1119 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1120 struct ix_rx_queue *que = sc->rx_queues;
1121 device_t dev = iflib_get_dev(ctx);
1123 /* Release all MSI-X queue resources */
1124 if (sc->intr_type == IFLIB_INTR_MSIX)
1125 iflib_irq_free(ctx, &sc->irq);
1128 for (int i = 0; i < sc->num_rx_queues; i++, que++) {
1129 iflib_irq_free(ctx, &que->que_irq);
1133 if (sc->pci_mem != NULL)
1134 bus_release_resource(dev, SYS_RES_MEMORY,
1135 rman_get_rid(sc->pci_mem), sc->pci_mem);
1136 } /* ixv_free_pci_resources */
1138 /************************************************************************
1139 * ixv_setup_interface
1141 * Setup networking device structure and register an interface.
1142 ************************************************************************/
1144 ixv_setup_interface(if_ctx_t ctx)
1146 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1147 if_softc_ctx_t scctx = sc->shared;
1148 struct ifnet *ifp = iflib_get_ifp(ctx);
1150 INIT_DEBUGOUT("ixv_setup_interface: begin");
1152 if_setbaudrate(ifp, IF_Gbps(10));
1153 ifp->if_snd.ifq_maxlen = scctx->isc_ntxd[0] - 2;
1156 sc->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR;
1157 ifmedia_add(sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
1158 ifmedia_set(sc->media, IFM_ETHER | IFM_AUTO);
1161 } /* ixv_setup_interface */
1163 /************************************************************************
1164 * ixv_if_get_counter
1165 ************************************************************************/
1167 ixv_if_get_counter(if_ctx_t ctx, ift_counter cnt)
1169 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1170 if_t ifp = iflib_get_ifp(ctx);
1173 case IFCOUNTER_IPACKETS:
1174 return (sc->ipackets);
1175 case IFCOUNTER_OPACKETS:
1176 return (sc->opackets);
1177 case IFCOUNTER_IBYTES:
1178 return (sc->ibytes);
1179 case IFCOUNTER_OBYTES:
1180 return (sc->obytes);
1181 case IFCOUNTER_IMCASTS:
1182 return (sc->imcasts);
1184 return (if_get_counter_default(ifp, cnt));
1186 } /* ixv_if_get_counter */
1188 /* ixv_if_needs_restart - Tell iflib when the driver needs to be reinitialized
1189 * @ctx: iflib context
1190 * @event: event code to check
1192 * Defaults to returning true for every event.
1194 * @returns true if iflib needs to reinit the interface
1197 ixv_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event)
1200 case IFLIB_RESTART_VLAN_CONFIG:
1201 /* XXX: This may not need to return true */
1207 /************************************************************************
1208 * ixv_initialize_transmit_units - Enable transmit unit.
1209 ************************************************************************/
1211 ixv_initialize_transmit_units(if_ctx_t ctx)
1213 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1214 struct ixgbe_hw *hw = &sc->hw;
1215 if_softc_ctx_t scctx = sc->shared;
1216 struct ix_tx_queue *que = sc->tx_queues;
1219 for (i = 0; i < sc->num_tx_queues; i++, que++) {
1220 struct tx_ring *txr = &que->txr;
1221 u64 tdba = txr->tx_paddr;
1225 /* Set WTHRESH to 8, burst writeback */
1226 txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(j));
1227 txdctl |= (8 << 16);
1228 IXGBE_WRITE_REG(hw, IXGBE_VFTXDCTL(j), txdctl);
1230 /* Set the HW Tx Head and Tail indices */
1231 IXGBE_WRITE_REG(&sc->hw, IXGBE_VFTDH(j), 0);
1232 IXGBE_WRITE_REG(&sc->hw, IXGBE_VFTDT(j), 0);
1234 /* Set Tx Tail register */
1235 txr->tail = IXGBE_VFTDT(j);
1237 txr->tx_rs_cidx = txr->tx_rs_pidx;
1238 /* Initialize the last processed descriptor to be the end of
1239 * the ring, rather than the start, so that we avoid an
1240 * off-by-one error when calculating how many descriptors are
1241 * done in the credits_update function.
1243 txr->tx_cidx_processed = scctx->isc_ntxd[0] - 1;
1244 for (int k = 0; k < scctx->isc_ntxd[0]; k++)
1245 txr->tx_rsq[k] = QIDX_INVALID;
1247 /* Set Ring parameters */
1248 IXGBE_WRITE_REG(hw, IXGBE_VFTDBAL(j),
1249 (tdba & 0x00000000ffffffffULL));
1250 IXGBE_WRITE_REG(hw, IXGBE_VFTDBAH(j), (tdba >> 32));
1251 IXGBE_WRITE_REG(hw, IXGBE_VFTDLEN(j),
1252 scctx->isc_ntxd[0] * sizeof(struct ixgbe_legacy_tx_desc));
1253 txctrl = IXGBE_READ_REG(hw, IXGBE_VFDCA_TXCTRL(j));
1254 txctrl &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
1255 IXGBE_WRITE_REG(hw, IXGBE_VFDCA_TXCTRL(j), txctrl);
1258 txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(j));
1259 txdctl |= IXGBE_TXDCTL_ENABLE;
1260 IXGBE_WRITE_REG(hw, IXGBE_VFTXDCTL(j), txdctl);
1264 } /* ixv_initialize_transmit_units */
1266 /************************************************************************
1267 * ixv_initialize_rss_mapping
1268 ************************************************************************/
1270 ixv_initialize_rss_mapping(struct ixgbe_softc *sc)
1272 struct ixgbe_hw *hw = &sc->hw;
1273 u32 reta = 0, mrqc, rss_key[10];
1276 u32 rss_hash_config;
1278 if (sc->feat_en & IXGBE_FEATURE_RSS) {
1279 /* Fetch the configured RSS key */
1280 rss_getkey((uint8_t *)&rss_key);
1282 /* set up random bits */
1283 arc4rand(&rss_key, sizeof(rss_key), 0);
1286 /* Now fill out hash function seeds */
1287 for (i = 0; i < 10; i++)
1288 IXGBE_WRITE_REG(hw, IXGBE_VFRSSRK(i), rss_key[i]);
1290 /* Set up the redirection table */
1291 for (i = 0, j = 0; i < 64; i++, j++) {
1292 if (j == sc->num_rx_queues)
1295 if (sc->feat_en & IXGBE_FEATURE_RSS) {
1297 * Fetch the RSS bucket id for the given indirection
1298 * entry. Cap it at the number of configured buckets
1299 * (which is num_rx_queues.)
1301 queue_id = rss_get_indirection_to_bucket(i);
1302 queue_id = queue_id % sc->num_rx_queues;
1307 * The low 8 bits are for hash value (n+0);
1308 * The next 8 bits are for hash value (n+1), etc.
1311 reta |= ((uint32_t)queue_id) << 24;
1313 IXGBE_WRITE_REG(hw, IXGBE_VFRETA(i >> 2), reta);
1318 /* Perform hash on these packet types */
1319 if (sc->feat_en & IXGBE_FEATURE_RSS)
1320 rss_hash_config = rss_gethashconfig();
1323 * Disable UDP - IP fragments aren't currently being handled
1324 * and so we end up with a mix of 2-tuple and 4-tuple
1327 rss_hash_config = RSS_HASHTYPE_RSS_IPV4
1328 | RSS_HASHTYPE_RSS_TCP_IPV4
1329 | RSS_HASHTYPE_RSS_IPV6
1330 | RSS_HASHTYPE_RSS_TCP_IPV6;
1333 mrqc = IXGBE_MRQC_RSSEN;
1334 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4)
1335 mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4;
1336 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4)
1337 mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_TCP;
1338 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
1339 mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6;
1340 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
1341 mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_TCP;
1342 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
1343 device_printf(sc->dev, "%s: RSS_HASHTYPE_RSS_IPV6_EX defined, but not supported\n",
1345 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6_EX)
1346 device_printf(sc->dev, "%s: RSS_HASHTYPE_RSS_TCP_IPV6_EX defined, but not supported\n",
1348 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
1349 mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
1350 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
1351 mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
1352 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)
1353 device_printf(sc->dev, "%s: RSS_HASHTYPE_RSS_UDP_IPV6_EX defined, but not supported\n",
1355 IXGBE_WRITE_REG(hw, IXGBE_VFMRQC, mrqc);
1356 } /* ixv_initialize_rss_mapping */
1359 /************************************************************************
1360 * ixv_initialize_receive_units - Setup receive registers and features.
1361 ************************************************************************/
1363 ixv_initialize_receive_units(if_ctx_t ctx)
1365 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1366 if_softc_ctx_t scctx;
1367 struct ixgbe_hw *hw = &sc->hw;
1368 struct ifnet *ifp = iflib_get_ifp(ctx);
1369 struct ix_rx_queue *que = sc->rx_queues;
1372 if (ifp->if_mtu > ETHERMTU)
1373 bufsz = 4096 >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
1375 bufsz = 2048 >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
1377 psrtype = IXGBE_PSRTYPE_TCPHDR
1378 | IXGBE_PSRTYPE_UDPHDR
1379 | IXGBE_PSRTYPE_IPV4HDR
1380 | IXGBE_PSRTYPE_IPV6HDR
1381 | IXGBE_PSRTYPE_L2HDR;
1383 if (sc->num_rx_queues > 1)
1386 IXGBE_WRITE_REG(hw, IXGBE_VFPSRTYPE, psrtype);
1388 /* Tell PF our max_frame size */
1389 if (ixgbevf_rlpml_set_vf(hw, sc->max_frame_size) != 0) {
1390 device_printf(sc->dev, "There is a problem with the PF setup. It is likely the receive unit for this VF will not function correctly.\n");
1394 for (int i = 0; i < sc->num_rx_queues; i++, que++) {
1395 struct rx_ring *rxr = &que->rxr;
1396 u64 rdba = rxr->rx_paddr;
1400 /* Disable the queue */
1401 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(j));
1402 rxdctl &= ~IXGBE_RXDCTL_ENABLE;
1403 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(j), rxdctl);
1404 for (int k = 0; k < 10; k++) {
1405 if (IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(j)) &
1406 IXGBE_RXDCTL_ENABLE)
1412 /* Setup the Base and Length of the Rx Descriptor Ring */
1413 IXGBE_WRITE_REG(hw, IXGBE_VFRDBAL(j),
1414 (rdba & 0x00000000ffffffffULL));
1415 IXGBE_WRITE_REG(hw, IXGBE_VFRDBAH(j), (rdba >> 32));
1416 IXGBE_WRITE_REG(hw, IXGBE_VFRDLEN(j),
1417 scctx->isc_nrxd[0] * sizeof(union ixgbe_adv_rx_desc));
1419 /* Reset the ring indices */
1420 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(rxr->me), 0);
1421 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rxr->me), 0);
1423 /* Set up the SRRCTL register */
1424 reg = IXGBE_READ_REG(hw, IXGBE_VFSRRCTL(j));
1425 reg &= ~IXGBE_SRRCTL_BSIZEHDR_MASK;
1426 reg &= ~IXGBE_SRRCTL_BSIZEPKT_MASK;
1428 reg |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
1429 IXGBE_WRITE_REG(hw, IXGBE_VFSRRCTL(j), reg);
1431 /* Capture Rx Tail index */
1432 rxr->tail = IXGBE_VFRDT(rxr->me);
1434 /* Do the queue enabling last */
1435 rxdctl |= IXGBE_RXDCTL_ENABLE | IXGBE_RXDCTL_VME;
1436 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(j), rxdctl);
1437 for (int l = 0; l < 10; l++) {
1438 if (IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(j)) &
1439 IXGBE_RXDCTL_ENABLE)
1445 /* Set the Tail Pointer */
1448 * In netmap mode, we must preserve the buffers made
1449 * available to userspace before the if_init()
1450 * (this is true by default on the TX side, because
1451 * init makes all buffers available to userspace).
1453 * netmap_reset() and the device specific routines
1454 * (e.g. ixgbe_setup_receive_rings()) map these
1455 * buffers at the end of the NIC ring, so here we
1456 * must set the RDT (tail) register to make sure
1457 * they are not overwritten.
1459 * In this driver the NIC ring starts at RDH = 0,
1460 * RDT points to the last slot available for reception (?),
1461 * so RDT = num_rx_desc - 1 means the whole ring is available.
1463 if (ifp->if_capenable & IFCAP_NETMAP) {
1464 struct netmap_adapter *na = NA(ifp);
1465 struct netmap_kring *kring = na->rx_rings[j];
1466 int t = na->num_rx_desc - 1 - nm_kr_rxspace(kring);
1468 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rxr->me), t);
1470 #endif /* DEV_NETMAP */
1471 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rxr->me),
1472 scctx->isc_nrxd[0] - 1);
1476 * Do not touch RSS and RETA settings for older hardware
1477 * as those are shared among PF and all VF.
1479 if (sc->hw.mac.type >= ixgbe_mac_X550_vf)
1480 ixv_initialize_rss_mapping(sc);
1481 } /* ixv_initialize_receive_units */
1483 /************************************************************************
1484 * ixv_setup_vlan_support
1485 ************************************************************************/
1487 ixv_setup_vlan_support(if_ctx_t ctx)
1489 struct ifnet *ifp = iflib_get_ifp(ctx);
1490 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1491 struct ixgbe_hw *hw = &sc->hw;
1492 u32 ctrl, vid, vfta, retry;
1495 * We get here thru if_init, meaning
1496 * a soft reset, this has already cleared
1497 * the VFTA and other state, so if there
1498 * have been no vlan's registered do nothing.
1500 if (sc->num_vlans == 0)
1503 if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
1504 /* Enable the queues */
1505 for (int i = 0; i < sc->num_rx_queues; i++) {
1506 ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
1507 ctrl |= IXGBE_RXDCTL_VME;
1508 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), ctrl);
1510 * Let Rx path know that it needs to store VLAN tag
1511 * as part of extra mbuf info.
1513 sc->rx_queues[i].rxr.vtag_strip = true;
1518 * If filtering VLAN tags is disabled,
1519 * there is no need to fill VLAN Filter Table Array (VFTA).
1521 if ((ifp->if_capenable & IFCAP_VLAN_HWFILTER) == 0)
1525 * A soft reset zero's out the VFTA, so
1526 * we need to repopulate it now.
1528 for (int i = 0; i < IXGBE_VFTA_SIZE; i++) {
1529 if (ixv_shadow_vfta[i] == 0)
1531 vfta = ixv_shadow_vfta[i];
1533 * Reconstruct the vlan id's
1534 * based on the bits set in each
1535 * of the array ints.
1537 for (int j = 0; j < 32; j++) {
1539 if ((vfta & (1 << j)) == 0)
1542 /* Call the shared code mailbox routine */
1543 while (hw->mac.ops.set_vfta(hw, vid, 0, true, false)) {
1549 } /* ixv_setup_vlan_support */
1551 /************************************************************************
1552 * ixv_if_register_vlan
1554 * Run via a vlan config EVENT, it enables us to use the
1555 * HW Filter table since we can get the vlan id. This just
1556 * creates the entry in the soft version of the VFTA, init
1557 * will repopulate the real table.
1558 ************************************************************************/
1560 ixv_if_register_vlan(if_ctx_t ctx, u16 vtag)
1562 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1565 index = (vtag >> 5) & 0x7F;
1567 ixv_shadow_vfta[index] |= (1 << bit);
1569 } /* ixv_if_register_vlan */
1571 /************************************************************************
1572 * ixv_if_unregister_vlan
1574 * Run via a vlan unconfig EVENT, remove our entry
1576 ************************************************************************/
1578 ixv_if_unregister_vlan(if_ctx_t ctx, u16 vtag)
1580 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1583 index = (vtag >> 5) & 0x7F;
1585 ixv_shadow_vfta[index] &= ~(1 << bit);
1587 } /* ixv_if_unregister_vlan */
1589 /************************************************************************
1590 * ixv_if_enable_intr
1591 ************************************************************************/
1593 ixv_if_enable_intr(if_ctx_t ctx)
1595 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1596 struct ixgbe_hw *hw = &sc->hw;
1597 struct ix_rx_queue *que = sc->rx_queues;
1598 u32 mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE);
1600 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
1602 mask = IXGBE_EIMS_ENABLE_MASK;
1603 mask &= ~(IXGBE_EIMS_OTHER | IXGBE_EIMS_LSC);
1604 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, mask);
1606 for (int i = 0; i < sc->num_rx_queues; i++, que++)
1607 ixv_enable_queue(sc, que->msix);
1609 IXGBE_WRITE_FLUSH(hw);
1610 } /* ixv_if_enable_intr */
1612 /************************************************************************
1613 * ixv_if_disable_intr
1614 ************************************************************************/
1616 ixv_if_disable_intr(if_ctx_t ctx)
1618 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1619 IXGBE_WRITE_REG(&sc->hw, IXGBE_VTEIAC, 0);
1620 IXGBE_WRITE_REG(&sc->hw, IXGBE_VTEIMC, ~0);
1621 IXGBE_WRITE_FLUSH(&sc->hw);
1622 } /* ixv_if_disable_intr */
1624 /************************************************************************
1625 * ixv_if_rx_queue_intr_enable
1626 ************************************************************************/
1628 ixv_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid)
1630 struct ixgbe_softc *sc = iflib_get_softc(ctx);
1631 struct ix_rx_queue *que = &sc->rx_queues[rxqid];
1633 ixv_enable_queue(sc, que->rxr.me);
1636 } /* ixv_if_rx_queue_intr_enable */
1638 /************************************************************************
1641 * Setup the correct IVAR register for a particular MSI-X interrupt
1642 * - entry is the register array entry
1643 * - vector is the MSI-X vector for this queue
1644 * - type is RX/TX/MISC
1645 ************************************************************************/
1647 ixv_set_ivar(struct ixgbe_softc *sc, u8 entry, u8 vector, s8 type)
1649 struct ixgbe_hw *hw = &sc->hw;
1652 vector |= IXGBE_IVAR_ALLOC_VAL;
1654 if (type == -1) { /* MISC IVAR */
1655 ivar = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
1658 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, ivar);
1659 } else { /* RX/TX IVARS */
1660 index = (16 * (entry & 1)) + (8 * type);
1661 ivar = IXGBE_READ_REG(hw, IXGBE_VTIVAR(entry >> 1));
1662 ivar &= ~(0xFF << index);
1663 ivar |= (vector << index);
1664 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(entry >> 1), ivar);
1666 } /* ixv_set_ivar */
1668 /************************************************************************
1669 * ixv_configure_ivars
1670 ************************************************************************/
1672 ixv_configure_ivars(struct ixgbe_softc *sc)
1674 struct ix_rx_queue *que = sc->rx_queues;
1676 MPASS(sc->num_rx_queues == sc->num_tx_queues);
1678 for (int i = 0; i < sc->num_rx_queues; i++, que++) {
1679 /* First the RX queue entry */
1680 ixv_set_ivar(sc, i, que->msix, 0);
1681 /* ... and the TX */
1682 ixv_set_ivar(sc, i, que->msix, 1);
1683 /* Set an initial value in EITR */
1684 IXGBE_WRITE_REG(&sc->hw, IXGBE_VTEITR(que->msix),
1685 IXGBE_EITR_DEFAULT);
1688 /* For the mailbox interrupt */
1689 ixv_set_ivar(sc, 1, sc->vector, -1);
1690 } /* ixv_configure_ivars */
1692 /************************************************************************
1695 * The VF stats registers never have a truly virgin
1696 * starting point, so this routine tries to make an
1697 * artificial one, marking ground zero on attach as
1699 ************************************************************************/
1701 ixv_save_stats(struct ixgbe_softc *sc)
1703 if (sc->stats.vf.vfgprc || sc->stats.vf.vfgptc) {
1704 sc->stats.vf.saved_reset_vfgprc +=
1705 sc->stats.vf.vfgprc - sc->stats.vf.base_vfgprc;
1706 sc->stats.vf.saved_reset_vfgptc +=
1707 sc->stats.vf.vfgptc - sc->stats.vf.base_vfgptc;
1708 sc->stats.vf.saved_reset_vfgorc +=
1709 sc->stats.vf.vfgorc - sc->stats.vf.base_vfgorc;
1710 sc->stats.vf.saved_reset_vfgotc +=
1711 sc->stats.vf.vfgotc - sc->stats.vf.base_vfgotc;
1712 sc->stats.vf.saved_reset_vfmprc +=
1713 sc->stats.vf.vfmprc - sc->stats.vf.base_vfmprc;
1715 } /* ixv_save_stats */
1717 /************************************************************************
1719 ************************************************************************/
1721 ixv_init_stats(struct ixgbe_softc *sc)
1723 struct ixgbe_hw *hw = &sc->hw;
1725 sc->stats.vf.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
1726 sc->stats.vf.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
1727 sc->stats.vf.last_vfgorc |=
1728 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
1730 sc->stats.vf.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
1731 sc->stats.vf.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
1732 sc->stats.vf.last_vfgotc |=
1733 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
1735 sc->stats.vf.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
1737 sc->stats.vf.base_vfgprc = sc->stats.vf.last_vfgprc;
1738 sc->stats.vf.base_vfgorc = sc->stats.vf.last_vfgorc;
1739 sc->stats.vf.base_vfgptc = sc->stats.vf.last_vfgptc;
1740 sc->stats.vf.base_vfgotc = sc->stats.vf.last_vfgotc;
1741 sc->stats.vf.base_vfmprc = sc->stats.vf.last_vfmprc;
1742 } /* ixv_init_stats */
1744 #define UPDATE_STAT_32(reg, last, count) \
1746 u32 current = IXGBE_READ_REG(hw, reg); \
1747 if (current < last) \
1748 count += 0x100000000LL; \
1750 count &= 0xFFFFFFFF00000000LL; \
1754 #define UPDATE_STAT_36(lsb, msb, last, count) \
1756 u64 cur_lsb = IXGBE_READ_REG(hw, lsb); \
1757 u64 cur_msb = IXGBE_READ_REG(hw, msb); \
1758 u64 current = ((cur_msb << 32) | cur_lsb); \
1759 if (current < last) \
1760 count += 0x1000000000LL; \
1762 count &= 0xFFFFFFF000000000LL; \
1766 /************************************************************************
1767 * ixv_update_stats - Update the board statistics counters.
1768 ************************************************************************/
1770 ixv_update_stats(struct ixgbe_softc *sc)
1772 struct ixgbe_hw *hw = &sc->hw;
1773 struct ixgbevf_hw_stats *stats = &sc->stats.vf;
1775 UPDATE_STAT_32(IXGBE_VFGPRC, sc->stats.vf.last_vfgprc,
1776 sc->stats.vf.vfgprc);
1777 UPDATE_STAT_32(IXGBE_VFGPTC, sc->stats.vf.last_vfgptc,
1778 sc->stats.vf.vfgptc);
1779 UPDATE_STAT_36(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
1780 sc->stats.vf.last_vfgorc, sc->stats.vf.vfgorc);
1781 UPDATE_STAT_36(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
1782 sc->stats.vf.last_vfgotc, sc->stats.vf.vfgotc);
1783 UPDATE_STAT_32(IXGBE_VFMPRC, sc->stats.vf.last_vfmprc,
1784 sc->stats.vf.vfmprc);
1786 /* Fill out the OS statistics structure */
1787 IXGBE_SET_IPACKETS(sc, stats->vfgprc);
1788 IXGBE_SET_OPACKETS(sc, stats->vfgptc);
1789 IXGBE_SET_IBYTES(sc, stats->vfgorc);
1790 IXGBE_SET_OBYTES(sc, stats->vfgotc);
1791 IXGBE_SET_IMCASTS(sc, stats->vfmprc);
1792 } /* ixv_update_stats */
1794 /************************************************************************
1795 * ixv_add_stats_sysctls - Add statistic sysctls for the VF.
1796 ************************************************************************/
1798 ixv_add_stats_sysctls(struct ixgbe_softc *sc)
1800 device_t dev = sc->dev;
1801 struct ix_tx_queue *tx_que = sc->tx_queues;
1802 struct ix_rx_queue *rx_que = sc->rx_queues;
1803 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
1804 struct sysctl_oid *tree = device_get_sysctl_tree(dev);
1805 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
1806 struct ixgbevf_hw_stats *stats = &sc->stats.vf;
1807 struct sysctl_oid *stat_node, *queue_node;
1808 struct sysctl_oid_list *stat_list, *queue_list;
1810 #define QUEUE_NAME_LEN 32
1811 char namebuf[QUEUE_NAME_LEN];
1813 /* Driver Statistics */
1814 SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "watchdog_events",
1815 CTLFLAG_RD, &sc->watchdog_events, "Watchdog timeouts");
1816 SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "link_irq",
1817 CTLFLAG_RD, &sc->link_irq, "Link MSI-X IRQ Handled");
1819 for (int i = 0; i < sc->num_tx_queues; i++, tx_que++) {
1820 struct tx_ring *txr = &tx_que->txr;
1821 snprintf(namebuf, QUEUE_NAME_LEN, "queue%d", i);
1822 queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf,
1823 CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Queue Name");
1824 queue_list = SYSCTL_CHILDREN(queue_node);
1826 SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tso_tx",
1827 CTLFLAG_RD, &(txr->tso_tx), "TSO Packets");
1828 SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_packets",
1829 CTLFLAG_RD, &(txr->total_packets), "TX Packets");
1832 for (int i = 0; i < sc->num_rx_queues; i++, rx_que++) {
1833 struct rx_ring *rxr = &rx_que->rxr;
1834 snprintf(namebuf, QUEUE_NAME_LEN, "queue%d", i);
1835 queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf,
1836 CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Queue Name");
1837 queue_list = SYSCTL_CHILDREN(queue_node);
1839 SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "irqs",
1840 CTLFLAG_RD, &(rx_que->irqs), "IRQs on queue");
1841 SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_packets",
1842 CTLFLAG_RD, &(rxr->rx_packets), "RX packets");
1843 SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_bytes",
1844 CTLFLAG_RD, &(rxr->rx_bytes), "RX bytes");
1845 SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_discarded",
1846 CTLFLAG_RD, &(rxr->rx_discarded), "Discarded RX packets");
1849 stat_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "mac",
1850 CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
1851 "VF Statistics (read from HW registers)");
1852 stat_list = SYSCTL_CHILDREN(stat_node);
1854 SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_rcvd",
1855 CTLFLAG_RD, &stats->vfgprc, "Good Packets Received");
1856 SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_rcvd",
1857 CTLFLAG_RD, &stats->vfgorc, "Good Octets Received");
1858 SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_rcvd",
1859 CTLFLAG_RD, &stats->vfmprc, "Multicast Packets Received");
1860 SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_txd",
1861 CTLFLAG_RD, &stats->vfgptc, "Good Packets Transmitted");
1862 SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_txd",
1863 CTLFLAG_RD, &stats->vfgotc, "Good Octets Transmitted");
1864 } /* ixv_add_stats_sysctls */
1866 /************************************************************************
1867 * ixv_print_debug_info
1869 * Called only when em_display_debug_stats is enabled.
1870 * Provides a way to take a look at important statistics
1871 * maintained by the driver and hardware.
1872 ************************************************************************/
1874 ixv_print_debug_info(struct ixgbe_softc *sc)
1876 device_t dev = sc->dev;
1877 struct ixgbe_hw *hw = &sc->hw;
1879 device_printf(dev, "Error Byte Count = %u \n",
1880 IXGBE_READ_REG(hw, IXGBE_ERRBC));
1882 device_printf(dev, "MBX IRQ Handled: %lu\n", (long)sc->link_irq);
1883 } /* ixv_print_debug_info */
1885 /************************************************************************
1887 ************************************************************************/
1889 ixv_sysctl_debug(SYSCTL_HANDLER_ARGS)
1891 struct ixgbe_softc *sc;
1895 error = sysctl_handle_int(oidp, &result, 0, req);
1897 if (error || !req->newptr)
1901 sc = (struct ixgbe_softc *)arg1;
1902 ixv_print_debug_info(sc);
1906 } /* ixv_sysctl_debug */
1908 /************************************************************************
1909 * ixv_init_device_features
1910 ************************************************************************/
1912 ixv_init_device_features(struct ixgbe_softc *sc)
1914 sc->feat_cap = IXGBE_FEATURE_NETMAP
1916 | IXGBE_FEATURE_LEGACY_TX;
1918 /* A tad short on feature flags for VFs, atm. */
1919 switch (sc->hw.mac.type) {
1920 case ixgbe_mac_82599_vf:
1922 case ixgbe_mac_X540_vf:
1924 case ixgbe_mac_X550_vf:
1925 case ixgbe_mac_X550EM_x_vf:
1926 case ixgbe_mac_X550EM_a_vf:
1927 sc->feat_cap |= IXGBE_FEATURE_NEEDS_CTXD;
1928 sc->feat_cap |= IXGBE_FEATURE_RSS;
1934 /* Enabled by default... */
1935 /* Is a virtual function (VF) */
1936 if (sc->feat_cap & IXGBE_FEATURE_VF)
1937 sc->feat_en |= IXGBE_FEATURE_VF;
1939 if (sc->feat_cap & IXGBE_FEATURE_NETMAP)
1940 sc->feat_en |= IXGBE_FEATURE_NETMAP;
1941 /* Receive-Side Scaling (RSS) */
1942 if (sc->feat_cap & IXGBE_FEATURE_RSS)
1943 sc->feat_en |= IXGBE_FEATURE_RSS;
1944 /* Needs advanced context descriptor regardless of offloads req'd */
1945 if (sc->feat_cap & IXGBE_FEATURE_NEEDS_CTXD)
1946 sc->feat_en |= IXGBE_FEATURE_NEEDS_CTXD;
1947 } /* ixv_init_device_features */