Lines Matching +full:qemu +full:- +full:user +full:- +full:static

3   Copyright (c) 2001-2017, Intel Corporation
48 static const char ixv_driver_version[] = "2.0.1-k";
59 static const pci_vendor_info_t ixv_vendor_info_array[] =
78 static void *ixv_register(device_t);
79 static int ixv_if_attach_pre(if_ctx_t);
80 static int ixv_if_attach_post(if_ctx_t);
81 static int ixv_if_detach(if_ctx_t);
83 static int ixv_if_rx_queue_intr_enable(if_ctx_t, uint16_t);
84 static int ixv_if_tx_queues_alloc(if_ctx_t, caddr_t *, uint64_t *, int,
86 static int ixv_if_rx_queues_alloc(if_ctx_t, caddr_t *, uint64_t *, int,
88 static void ixv_if_queues_free(if_ctx_t);
89 static void ixv_identify_hardware(if_ctx_t);
90 static void ixv_init_device_features(struct ixgbe_softc *);
91 static int ixv_allocate_pci_resources(if_ctx_t);
92 static void ixv_free_pci_resources(if_ctx_t);
93 static int ixv_setup_interface(if_ctx_t);
94 static void ixv_if_media_status(if_ctx_t, struct ifmediareq *);
95 static int ixv_if_media_change(if_ctx_t);
96 static void ixv_if_update_admin_status(if_ctx_t);
97 static int ixv_if_msix_intr_assign(if_ctx_t, int);
99 static int ixv_if_mtu_set(if_ctx_t, uint32_t);
100 static void ixv_if_init(if_ctx_t);
101 static void ixv_if_local_timer(if_ctx_t, uint16_t);
102 static void ixv_if_stop(if_ctx_t);
103 static int ixv_negotiate_api(struct ixgbe_softc *);
105 static void ixv_initialize_transmit_units(if_ctx_t);
106 static void ixv_initialize_receive_units(if_ctx_t);
107 static void ixv_initialize_rss_mapping(struct ixgbe_softc *);
109 static void ixv_setup_vlan_support(if_ctx_t);
110 static void ixv_configure_ivars(struct ixgbe_softc *);
111 static void ixv_if_enable_intr(if_ctx_t);
112 static void ixv_if_disable_intr(if_ctx_t);
113 static void ixv_if_multi_set(if_ctx_t);
115 static void ixv_if_register_vlan(if_ctx_t, u16);
116 static void ixv_if_unregister_vlan(if_ctx_t, u16);
118 static uint64_t ixv_if_get_counter(if_ctx_t, ift_counter);
119 static bool ixv_if_needs_restart(if_ctx_t, enum iflib_restart_event);
121 static void ixv_save_stats(struct ixgbe_softc *);
122 static void ixv_init_stats(struct ixgbe_softc *);
123 static void ixv_update_stats(struct ixgbe_softc *);
124 static void ixv_add_stats_sysctls(struct ixgbe_softc *);
126 static int ixv_sysctl_debug(SYSCTL_HANDLER_ARGS);
127 static void ixv_set_ivar(struct ixgbe_softc *, u8, u8, s8);
129 static u8 *ixv_mc_array_itr(struct ixgbe_hw *, u8 **, u32 *);
131 /* The MSI-X Interrupt handlers */
132 static int ixv_msix_que(void *);
133 static int ixv_msix_mbx(void *);
138 static device_method_t ixv_methods[] = {
148 static driver_t ixv_driver = {
158 static device_method_t ixv_if_methods[] = {
185 static driver_t ixv_if_driver = {
194 static int ixv_flow_control = ixgbe_fc_full;
203 static int ixv_header_split = false;
208 static struct if_shared_ctx ixv_sctx_init = {
235 static void *
244 static int
249 if_softc_ctx_t scctx = sc->shared; in ixv_if_tx_queues_alloc()
253 MPASS(sc->num_tx_queues == ntxqsets); in ixv_if_tx_queues_alloc()
257 sc->tx_queues = in ixv_if_tx_queues_alloc()
260 if (!sc->tx_queues) { in ixv_if_tx_queues_alloc()
266 for (i = 0, que = sc->tx_queues; i < ntxqsets; i++, que++) { in ixv_if_tx_queues_alloc()
267 struct tx_ring *txr = &que->txr; in ixv_if_tx_queues_alloc()
269 txr->me = i; in ixv_if_tx_queues_alloc()
270 txr->sc = que->sc = sc; in ixv_if_tx_queues_alloc()
273 if (!(txr->tx_rsq = (qidx_t *)malloc(sizeof(qidx_t) * in ixv_if_tx_queues_alloc()
274 scctx->isc_ntxd[0], M_DEVBUF, M_NOWAIT | M_ZERO))) { in ixv_if_tx_queues_alloc()
278 for (j = 0; j < scctx->isc_ntxd[0]; j++) in ixv_if_tx_queues_alloc()
279 txr->tx_rsq[j] = QIDX_INVALID; in ixv_if_tx_queues_alloc()
281 txr->tail = IXGBE_VFTDT(txr->me); in ixv_if_tx_queues_alloc()
282 txr->tx_base = (union ixgbe_adv_tx_desc *)vaddrs[i*ntxqs]; in ixv_if_tx_queues_alloc()
283 txr->tx_paddr = paddrs[i*ntxqs]; in ixv_if_tx_queues_alloc()
285 txr->bytes = 0; in ixv_if_tx_queues_alloc()
286 txr->total_packets = 0; in ixv_if_tx_queues_alloc()
291 sc->num_tx_queues); in ixv_if_tx_queues_alloc()
304 static int
312 MPASS(sc->num_rx_queues == nrxqsets); in ixv_if_rx_queues_alloc()
316 sc->rx_queues = in ixv_if_rx_queues_alloc()
319 if (!sc->rx_queues) { in ixv_if_rx_queues_alloc()
326 for (i = 0, que = sc->rx_queues; i < nrxqsets; i++, que++) { in ixv_if_rx_queues_alloc()
327 struct rx_ring *rxr = &que->rxr; in ixv_if_rx_queues_alloc()
328 rxr->me = i; in ixv_if_rx_queues_alloc()
329 rxr->sc = que->sc = sc; in ixv_if_rx_queues_alloc()
333 rxr->tail = IXGBE_VFRDT(rxr->me); in ixv_if_rx_queues_alloc()
334 rxr->rx_base = (union ixgbe_adv_rx_desc *)vaddrs[i]; in ixv_if_rx_queues_alloc()
335 rxr->rx_paddr = paddrs[i*nrxqs]; in ixv_if_rx_queues_alloc()
336 rxr->bytes = 0; in ixv_if_rx_queues_alloc()
337 rxr->que = que; in ixv_if_rx_queues_alloc()
341 sc->num_rx_queues); in ixv_if_rx_queues_alloc()
354 static void
358 struct ix_tx_queue *que = sc->tx_queues; in ixv_if_queues_free()
364 for (i = 0; i < sc->num_tx_queues; i++, que++) { in ixv_if_queues_free()
365 struct tx_ring *txr = &que->txr; in ixv_if_queues_free()
366 if (txr->tx_rsq == NULL) in ixv_if_queues_free()
369 free(txr->tx_rsq, M_DEVBUF); in ixv_if_queues_free()
370 txr->tx_rsq = NULL; in ixv_if_queues_free()
372 if (sc->tx_queues != NULL) in ixv_if_queues_free()
373 free(sc->tx_queues, M_DEVBUF); in ixv_if_queues_free()
375 if (sc->rx_queues != NULL) in ixv_if_queues_free()
376 free(sc->rx_queues, M_DEVBUF); in ixv_if_queues_free()
377 sc->tx_queues = NULL; in ixv_if_queues_free()
378 sc->rx_queues = NULL; in ixv_if_queues_free()
382 * ixv_if_attach_pre - Device initialization routine
390 static int
404 sc->dev = dev; in ixv_if_attach_pre()
405 sc->ctx = ctx; in ixv_if_attach_pre()
406 sc->hw.back = sc; in ixv_if_attach_pre()
407 scctx = sc->shared = iflib_get_softc_ctx(ctx); in ixv_if_attach_pre()
408 sc->media = iflib_get_media(ctx); in ixv_if_attach_pre()
409 hw = &sc->hw; in ixv_if_attach_pre()
411 /* Do base PCI setup - map BAR0 */ in ixv_if_attach_pre()
439 error = hw->mac.ops.reset_hw(hw); in ixv_if_attach_pre()
450 error = hw->mac.ops.init_hw(hw); in ixv_if_attach_pre()
467 error = hw->mac.ops.get_link_state(hw, &sc->link_enabled); in ixv_if_attach_pre()
470 sc->link_enabled = true; in ixv_if_attach_pre()
474 if (!ixv_check_ether_addr(hw->mac.addr)) { in ixv_if_attach_pre()
476 (struct ether_addr *)hw->mac.addr); in ixv_if_attach_pre()
477 bcopy(hw->mac.addr, hw->mac.perm_addr, in ixv_if_attach_pre()
478 sizeof(hw->mac.perm_addr)); in ixv_if_attach_pre()
483 iflib_set_mac(ctx, hw->mac.addr); in ixv_if_attach_pre()
484 switch (sc->hw.mac.type) { in ixv_if_attach_pre()
488 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 2; in ixv_if_attach_pre()
491 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 1; in ixv_if_attach_pre()
493 scctx->isc_txqsizes[0] = in ixv_if_attach_pre()
494 roundup2(scctx->isc_ntxd[0] * sizeof(union ixgbe_adv_tx_desc) + in ixv_if_attach_pre()
496 scctx->isc_rxqsizes[0] = in ixv_if_attach_pre()
497 roundup2(scctx->isc_nrxd[0] * sizeof(union ixgbe_adv_rx_desc), in ixv_if_attach_pre()
500 scctx->isc_tx_csum_flags = CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_TSO | in ixv_if_attach_pre()
502 scctx->isc_tx_nsegments = IXGBE_82599_SCATTER; in ixv_if_attach_pre()
503 scctx->isc_msix_bar = pci_msix_table_bar(dev); in ixv_if_attach_pre()
504 scctx->isc_tx_tso_segments_max = scctx->isc_tx_nsegments; in ixv_if_attach_pre()
505 scctx->isc_tx_tso_size_max = IXGBE_TSO_SIZE; in ixv_if_attach_pre()
506 scctx->isc_tx_tso_segsize_max = PAGE_SIZE; in ixv_if_attach_pre()
508 scctx->isc_txrx = &ixgbe_txrx; in ixv_if_attach_pre()
513 * Wake-on-LAN in ixv_if_attach_pre()
515 scctx->isc_capabilities = IXGBE_CAPS; in ixv_if_attach_pre()
516 scctx->isc_capabilities ^= IFCAP_WOL; in ixv_if_attach_pre()
517 scctx->isc_capenable = scctx->isc_capabilities; in ixv_if_attach_pre()
529 static int
553 * ixv_detach - Device removal routine
561 static int
574 static int
582 if (mtu > IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR) { in ixv_if_mtu_set()
586 sc->max_frame_size = if_getmtu(ifp) + IXGBE_MTU_HDR; in ixv_if_mtu_set()
593 * ixv_if_init - Init entry point
602 static void
608 struct ixgbe_hw *hw = &sc->hw; in ixv_if_init()
612 hw->adapter_stopped = false; in ixv_if_init()
613 hw->mac.ops.stop_adapter(hw); in ixv_if_init()
615 /* reprogram the RAR[0] in case user changed it. */ in ixv_if_init()
616 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV); in ixv_if_init()
618 /* Get the latest mac address, User can use a LAA */ in ixv_if_init()
619 bcopy(if_getlladdr(ifp), hw->mac.addr, IXGBE_ETH_LENGTH_OF_ADDRESS); in ixv_if_init()
620 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, 1); in ixv_if_init()
623 hw->mac.ops.reset_hw(hw); in ixv_if_init()
624 hw->mac.ops.start_hw(hw); in ixv_if_init()
637 sc->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); in ixv_if_init()
645 /* Set up MSI-X routing */ in ixv_if_init()
648 /* Set up auto-mask */ in ixv_if_init()
652 IXGBE_WRITE_REG(hw, IXGBE_VTEITR(sc->vector), IXGBE_LINK_ITR); in ixv_if_init()
658 error = hw->mac.ops.get_link_state(hw, &sc->link_enabled); in ixv_if_init()
661 sc->link_enabled = true; in ixv_if_init()
662 } else if (sc->link_enabled == false) in ixv_if_init()
665 hw->mac.ops.check_link(hw, &sc->link_speed, &sc->link_up, in ixv_if_init()
677 static inline void
680 struct ixgbe_hw *hw = &sc->hw; in ixv_enable_queue()
691 static inline void
694 struct ixgbe_hw *hw = &sc->hw; in ixv_disable_queue()
704 * ixv_msix_que - MSI-X Queue Interrupt Service routine
706 static int
710 struct ixgbe_softc *sc = que->sc; in ixv_msix_que()
712 ixv_disable_queue(sc, que->msix); in ixv_msix_que()
713 ++que->irqs; in ixv_msix_que()
721 static int
725 struct ixgbe_hw *hw = &sc->hw; in ixv_msix_mbx()
728 ++sc->link_irq; in ixv_msix_mbx()
737 iflib_admin_intr_deferred(sc->ctx); in ixv_msix_mbx()
745 * ixv_media_status - Media Ioctl callback
747 * Called whenever the user queries the status of
750 static void
759 ifmr->ifm_status = IFM_AVALID; in ixv_if_media_status()
760 ifmr->ifm_active = IFM_ETHER; in ixv_if_media_status()
762 if (!sc->link_active) in ixv_if_media_status()
765 ifmr->ifm_status |= IFM_ACTIVE; in ixv_if_media_status()
767 switch (sc->link_speed) { in ixv_if_media_status()
769 ifmr->ifm_active |= IFM_1000_T | IFM_FDX; in ixv_if_media_status()
772 ifmr->ifm_active |= IFM_10G_T | IFM_FDX; in ixv_if_media_status()
775 ifmr->ifm_active |= IFM_100_TX | IFM_FDX; in ixv_if_media_status()
778 ifmr->ifm_active |= IFM_10_T | IFM_FDX; in ixv_if_media_status()
784 * ixv_if_media_change - Media Ioctl callback
786 * Called when the user changes speed/duplex using
789 static int
797 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) in ixv_if_media_change()
800 switch (IFM_SUBTYPE(ifm->ifm_media)) { in ixv_if_media_change()
804 device_printf(sc->dev, "Only auto media type\n"); in ixv_if_media_change()
818 static int
821 struct ixgbe_hw *hw = &sc->hw; in ixv_negotiate_api()
840 static u_int
851 * ixv_if_multi_set - Multicast Update
855 static void
870 sc->hw.mac.ops.update_mc_addr_list(&sc->hw, update_ptr, mcnt, in ixv_if_multi_set()
881 static u8 *
896 * ixv_if_local_timer - Timer routine
901 static void
912 * ixv_if_update_admin_status - Update OS on link state
918 static void
925 sc->hw.mac.get_link_status = true; in ixv_if_update_admin_status()
927 status = ixgbe_check_link(&sc->hw, &sc->link_speed, in ixv_if_update_admin_status()
928 &sc->link_up, false); in ixv_if_update_admin_status()
930 if (status != IXGBE_SUCCESS && sc->hw.adapter_stopped == false) { in ixv_if_update_admin_status()
936 if (sc->link_up && sc->link_enabled) { in ixv_if_update_admin_status()
937 if (sc->link_active == false) { in ixv_if_update_admin_status()
940 ((sc->link_speed == 128) ? 10 : 1), in ixv_if_update_admin_status()
942 sc->link_active = true; in ixv_if_update_admin_status()
944 ixgbe_link_speed_to_baudrate(sc->link_speed)); in ixv_if_update_admin_status()
947 if (sc->link_active == true) { in ixv_if_update_admin_status()
951 sc->link_active = false; in ixv_if_update_admin_status()
961 * ixv_if_stop - Stop the hardware
966 static void
970 struct ixgbe_hw *hw = &sc->hw; in ixv_if_stop()
976 hw->mac.ops.reset_hw(hw); in ixv_if_stop()
977 sc->hw.adapter_stopped = false; in ixv_if_stop()
978 hw->mac.ops.stop_adapter(hw); in ixv_if_stop()
981 sc->link_up = false; in ixv_if_stop()
984 /* reprogram the RAR[0] in case user changed it. */ in ixv_if_stop()
985 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV); in ixv_if_stop()
990 * ixv_identify_hardware - Determine hardware revision.
992 static void
997 struct ixgbe_hw *hw = &sc->hw; in ixv_identify_hardware()
1000 hw->vendor_id = pci_get_vendor(dev); in ixv_identify_hardware()
1001 hw->device_id = pci_get_device(dev); in ixv_identify_hardware()
1002 hw->revision_id = pci_get_revid(dev); in ixv_identify_hardware()
1003 hw->subsystem_vendor_id = pci_get_subvendor(dev); in ixv_identify_hardware()
1004 hw->subsystem_device_id = pci_get_subdevice(dev); in ixv_identify_hardware()
1007 switch (hw->device_id) { in ixv_identify_hardware()
1009 hw->mac.type = ixgbe_mac_82599_vf; in ixv_identify_hardware()
1012 hw->mac.type = ixgbe_mac_X540_vf; in ixv_identify_hardware()
1015 hw->mac.type = ixgbe_mac_X550_vf; in ixv_identify_hardware()
1018 hw->mac.type = ixgbe_mac_X550EM_x_vf; in ixv_identify_hardware()
1021 hw->mac.type = ixgbe_mac_X550EM_a_vf; in ixv_identify_hardware()
1025 hw->mac.type = ixgbe_mac_unknown; in ixv_identify_hardware()
1031 * ixv_if_msix_intr_assign - Setup MSI-X Interrupt resources and handlers
1033 static int
1038 struct ix_rx_queue *rx_que = sc->rx_queues; in ixv_if_msix_intr_assign()
1043 for (int i = 0; i < sc->num_rx_queues; i++, vector++, rx_que++) { in ixv_if_msix_intr_assign()
1047 error = iflib_irq_alloc_generic(ctx, &rx_que->que_irq, rid, in ixv_if_msix_intr_assign()
1048 IFLIB_INTR_RXTX, ixv_msix_que, rx_que, rx_que->rxr.me, in ixv_if_msix_intr_assign()
1055 sc->num_rx_queues = i + 1; in ixv_if_msix_intr_assign()
1059 rx_que->msix = vector; in ixv_if_msix_intr_assign()
1062 for (int i = 0; i < sc->num_tx_queues; i++) { in ixv_if_msix_intr_assign()
1064 tx_que = &sc->tx_queues[i]; in ixv_if_msix_intr_assign()
1065 tx_que->msix = i % sc->num_rx_queues; in ixv_if_msix_intr_assign()
1067 &sc->rx_queues[tx_que->msix].que_irq, in ixv_if_msix_intr_assign()
1068 IFLIB_INTR_TX, tx_que, tx_que->txr.me, buf); in ixv_if_msix_intr_assign()
1071 error = iflib_irq_alloc_generic(ctx, &sc->irq, rid, in ixv_if_msix_intr_assign()
1079 sc->vector = vector; in ixv_if_msix_intr_assign()
1081 * Due to a broken design QEMU will fail to properly in ixv_if_msix_intr_assign()
1087 if (sc->hw.mac.type == ixgbe_mac_82599_vf) { in ixv_if_msix_intr_assign()
1103 iflib_irq_free(ctx, &sc->irq); in ixv_if_msix_intr_assign()
1104 rx_que = sc->rx_queues; in ixv_if_msix_intr_assign()
1105 for (int i = 0; i < sc->num_rx_queues; i++, rx_que++) in ixv_if_msix_intr_assign()
1106 iflib_irq_free(ctx, &rx_que->que_irq); in ixv_if_msix_intr_assign()
1114 static int
1122 sc->pci_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in ixv_allocate_pci_resources()
1125 if (!(sc->pci_mem)) { in ixv_allocate_pci_resources()
1131 sc->osdep.mem_bus_space_tag = rman_get_bustag(sc->pci_mem); in ixv_allocate_pci_resources()
1132 sc->osdep.mem_bus_space_handle = rman_get_bushandle(sc->pci_mem); in ixv_allocate_pci_resources()
1133 sc->hw.hw_addr = (u8 *)&sc->osdep.mem_bus_space_handle; in ixv_allocate_pci_resources()
1141 static void
1145 struct ix_rx_queue *que = sc->rx_queues; in ixv_free_pci_resources()
1148 /* Release all MSI-X queue resources */ in ixv_free_pci_resources()
1149 if (sc->intr_type == IFLIB_INTR_MSIX) in ixv_free_pci_resources()
1150 iflib_irq_free(ctx, &sc->irq); in ixv_free_pci_resources()
1153 for (int i = 0; i < sc->num_rx_queues; i++, que++) { in ixv_free_pci_resources()
1154 iflib_irq_free(ctx, &que->que_irq); in ixv_free_pci_resources()
1158 if (sc->pci_mem != NULL) in ixv_free_pci_resources()
1160 rman_get_rid(sc->pci_mem), sc->pci_mem); in ixv_free_pci_resources()
1168 static int
1172 if_softc_ctx_t scctx = sc->shared; in ixv_setup_interface()
1178 if_setsendqlen(ifp, scctx->isc_ntxd[0] - 2); in ixv_setup_interface()
1181 sc->max_frame_size = if_getmtu(ifp) + IXGBE_MTU_HDR; in ixv_setup_interface()
1182 ifmedia_add(sc->media, IFM_ETHER | IFM_AUTO, 0, NULL); in ixv_setup_interface()
1183 ifmedia_set(sc->media, IFM_ETHER | IFM_AUTO); in ixv_setup_interface()
1191 static uint64_t
1199 return (sc->ipackets); in ixv_if_get_counter()
1201 return (sc->opackets); in ixv_if_get_counter()
1203 return (sc->ibytes); in ixv_if_get_counter()
1205 return (sc->obytes); in ixv_if_get_counter()
1207 return (sc->imcasts); in ixv_if_get_counter()
1213 /* ixv_if_needs_restart - Tell iflib when the driver needs to be reinitialized
1221 static bool
1233 * ixv_initialize_transmit_units - Enable transmit unit.
1235 static void
1239 struct ixgbe_hw *hw = &sc->hw; in ixv_initialize_transmit_units()
1240 if_softc_ctx_t scctx = sc->shared; in ixv_initialize_transmit_units()
1241 struct ix_tx_queue *que = sc->tx_queues; in ixv_initialize_transmit_units()
1244 for (i = 0; i < sc->num_tx_queues; i++, que++) { in ixv_initialize_transmit_units()
1245 struct tx_ring *txr = &que->txr; in ixv_initialize_transmit_units()
1246 u64 tdba = txr->tx_paddr; in ixv_initialize_transmit_units()
1248 int j = txr->me; in ixv_initialize_transmit_units()
1256 IXGBE_WRITE_REG(&sc->hw, IXGBE_VFTDH(j), 0); in ixv_initialize_transmit_units()
1257 IXGBE_WRITE_REG(&sc->hw, IXGBE_VFTDT(j), 0); in ixv_initialize_transmit_units()
1260 txr->tail = IXGBE_VFTDT(j); in ixv_initialize_transmit_units()
1262 txr->tx_rs_cidx = txr->tx_rs_pidx; in ixv_initialize_transmit_units()
1265 * off-by-one error when calculating how many descriptors are in ixv_initialize_transmit_units()
1268 txr->tx_cidx_processed = scctx->isc_ntxd[0] - 1; in ixv_initialize_transmit_units()
1269 for (int k = 0; k < scctx->isc_ntxd[0]; k++) in ixv_initialize_transmit_units()
1270 txr->tx_rsq[k] = QIDX_INVALID; in ixv_initialize_transmit_units()
1277 scctx->isc_ntxd[0] * sizeof(struct ixgbe_legacy_tx_desc)); in ixv_initialize_transmit_units()
1294 static void
1297 struct ixgbe_hw *hw = &sc->hw; in ixv_initialize_rss_mapping()
1303 if (sc->feat_en & IXGBE_FEATURE_RSS) { in ixv_initialize_rss_mapping()
1317 if (j == sc->num_rx_queues) in ixv_initialize_rss_mapping()
1320 if (sc->feat_en & IXGBE_FEATURE_RSS) { in ixv_initialize_rss_mapping()
1327 queue_id = queue_id % sc->num_rx_queues; in ixv_initialize_rss_mapping()
1344 if (sc->feat_en & IXGBE_FEATURE_RSS) in ixv_initialize_rss_mapping()
1348 * Disable UDP - IP fragments aren't currently being handled in ixv_initialize_rss_mapping()
1349 * and so we end up with a mix of 2-tuple and 4-tuple in ixv_initialize_rss_mapping()
1368 device_printf(sc->dev, in ixv_initialize_rss_mapping()
1372 device_printf(sc->dev, in ixv_initialize_rss_mapping()
1380 device_printf(sc->dev, in ixv_initialize_rss_mapping()
1386 #define BSIZEPKT_ROUNDUP ((1<<IXGBE_SRRCTL_BSIZEPKT_SHIFT)-1)
1388 * ixv_initialize_receive_units - Setup receive registers and features.
1390 static void
1395 struct ixgbe_hw *hw = &sc->hw; in ixv_initialize_receive_units()
1399 struct ix_rx_queue *que = sc->rx_queues; in ixv_initialize_receive_units()
1402 bufsz = (sc->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> in ixv_initialize_receive_units()
1411 if (sc->num_rx_queues > 1) in ixv_initialize_receive_units()
1417 if (ixgbevf_rlpml_set_vf(hw, sc->max_frame_size) != 0) { in ixv_initialize_receive_units()
1418 device_printf(sc->dev, in ixv_initialize_receive_units()
1423 scctx = sc->shared; in ixv_initialize_receive_units()
1425 for (int i = 0; i < sc->num_rx_queues; i++, que++) { in ixv_initialize_receive_units()
1426 struct rx_ring *rxr = &que->rxr; in ixv_initialize_receive_units()
1427 u64 rdba = rxr->rx_paddr; in ixv_initialize_receive_units()
1429 int j = rxr->me; in ixv_initialize_receive_units()
1448 scctx->isc_nrxd[0] * sizeof(union ixgbe_adv_rx_desc)); in ixv_initialize_receive_units()
1451 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(rxr->me), 0); in ixv_initialize_receive_units()
1452 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rxr->me), 0); in ixv_initialize_receive_units()
1463 rxr->tail = IXGBE_VFRDT(rxr->me); in ixv_initialize_receive_units()
1492 * so RDT = num_rx_desc - 1 means the whole ring is available. in ixv_initialize_receive_units()
1496 struct netmap_kring *kring = na->rx_rings[j]; in ixv_initialize_receive_units()
1497 int t = na->num_rx_desc - 1 - nm_kr_rxspace(kring); in ixv_initialize_receive_units()
1499 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rxr->me), t); in ixv_initialize_receive_units()
1502 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rxr->me), in ixv_initialize_receive_units()
1503 scctx->isc_nrxd[0] - 1); in ixv_initialize_receive_units()
1510 if (sc->hw.mac.type >= ixgbe_mac_X550_vf) in ixv_initialize_receive_units()
1517 static void
1522 struct ixgbe_hw *hw = &sc->hw; in ixv_setup_vlan_support()
1531 if (sc->num_vlans == 0) in ixv_setup_vlan_support()
1536 for (int i = 0; i < sc->num_rx_queues; i++) { in ixv_setup_vlan_support()
1544 sc->rx_queues[i].rxr.vtag_strip = true; in ixv_setup_vlan_support()
1560 if (sc->shadow_vfta[i] == 0) in ixv_setup_vlan_support()
1562 vfta = sc->shadow_vfta[i]; in ixv_setup_vlan_support()
1574 while (hw->mac.ops.set_vfta(hw, vid, 0, true, false)) { in ixv_setup_vlan_support()
1590 static void
1598 sc->shadow_vfta[index] |= (1 << bit); in ixv_if_register_vlan()
1599 ++sc->num_vlans; in ixv_if_register_vlan()
1608 static void
1616 sc->shadow_vfta[index] &= ~(1 << bit); in ixv_if_unregister_vlan()
1617 --sc->num_vlans; in ixv_if_unregister_vlan()
1623 static void
1627 struct ixgbe_hw *hw = &sc->hw; in ixv_if_enable_intr()
1628 struct ix_rx_queue *que = sc->rx_queues; in ixv_if_enable_intr()
1637 for (int i = 0; i < sc->num_rx_queues; i++, que++) in ixv_if_enable_intr()
1638 ixv_enable_queue(sc, que->msix); in ixv_if_enable_intr()
1646 static void
1650 IXGBE_WRITE_REG(&sc->hw, IXGBE_VTEIAC, 0); in ixv_if_disable_intr()
1651 IXGBE_WRITE_REG(&sc->hw, IXGBE_VTEIMC, ~0); in ixv_if_disable_intr()
1652 IXGBE_WRITE_FLUSH(&sc->hw); in ixv_if_disable_intr()
1658 static int
1662 struct ix_rx_queue *que = &sc->rx_queues[rxqid]; in ixv_if_rx_queue_intr_enable()
1664 ixv_enable_queue(sc, que->rxr.me); in ixv_if_rx_queue_intr_enable()
1672 * Setup the correct IVAR register for a particular MSI-X interrupt
1673 * - entry is the register array entry
1674 * - vector is the MSI-X vector for this queue
1675 * - type is RX/TX/MISC
1677 static void
1680 struct ixgbe_hw *hw = &sc->hw; in ixv_set_ivar()
1685 if (type == -1) { /* MISC IVAR */ in ixv_set_ivar()
1702 static void
1705 struct ix_rx_queue *que = sc->rx_queues; in ixv_configure_ivars()
1707 MPASS(sc->num_rx_queues == sc->num_tx_queues); in ixv_configure_ivars()
1709 for (int i = 0; i < sc->num_rx_queues; i++, que++) { in ixv_configure_ivars()
1711 ixv_set_ivar(sc, i, que->msix, 0); in ixv_configure_ivars()
1713 ixv_set_ivar(sc, i, que->msix, 1); in ixv_configure_ivars()
1715 IXGBE_WRITE_REG(&sc->hw, IXGBE_VTEITR(que->msix), in ixv_configure_ivars()
1720 ixv_set_ivar(sc, 1, sc->vector, -1); in ixv_configure_ivars()
1731 static void
1734 if (sc->stats.vf.vfgprc || sc->stats.vf.vfgptc) { in ixv_save_stats()
1735 sc->stats.vf.saved_reset_vfgprc += in ixv_save_stats()
1736 sc->stats.vf.vfgprc - sc->stats.vf.base_vfgprc; in ixv_save_stats()
1737 sc->stats.vf.saved_reset_vfgptc += in ixv_save_stats()
1738 sc->stats.vf.vfgptc - sc->stats.vf.base_vfgptc; in ixv_save_stats()
1739 sc->stats.vf.saved_reset_vfgorc += in ixv_save_stats()
1740 sc->stats.vf.vfgorc - sc->stats.vf.base_vfgorc; in ixv_save_stats()
1741 sc->stats.vf.saved_reset_vfgotc += in ixv_save_stats()
1742 sc->stats.vf.vfgotc - sc->stats.vf.base_vfgotc; in ixv_save_stats()
1743 sc->stats.vf.saved_reset_vfmprc += in ixv_save_stats()
1744 sc->stats.vf.vfmprc - sc->stats.vf.base_vfmprc; in ixv_save_stats()
1751 static void
1754 struct ixgbe_hw *hw = &sc->hw; in ixv_init_stats()
1756 sc->stats.vf.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC); in ixv_init_stats()
1757 sc->stats.vf.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB); in ixv_init_stats()
1758 sc->stats.vf.last_vfgorc |= in ixv_init_stats()
1761 sc->stats.vf.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC); in ixv_init_stats()
1762 sc->stats.vf.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB); in ixv_init_stats()
1763 sc->stats.vf.last_vfgotc |= in ixv_init_stats()
1766 sc->stats.vf.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC); in ixv_init_stats()
1768 sc->stats.vf.base_vfgprc = sc->stats.vf.last_vfgprc; in ixv_init_stats()
1769 sc->stats.vf.base_vfgorc = sc->stats.vf.last_vfgorc; in ixv_init_stats()
1770 sc->stats.vf.base_vfgptc = sc->stats.vf.last_vfgptc; in ixv_init_stats()
1771 sc->stats.vf.base_vfgotc = sc->stats.vf.last_vfgotc; in ixv_init_stats()
1772 sc->stats.vf.base_vfmprc = sc->stats.vf.last_vfmprc; in ixv_init_stats()
1798 * ixv_update_stats - Update the board statistics counters.
1803 struct ixgbe_hw *hw = &sc->hw; in ixv_update_stats()
1804 struct ixgbevf_hw_stats *stats = &sc->stats.vf; in ixv_update_stats()
1806 UPDATE_STAT_32(IXGBE_VFGPRC, sc->stats.vf.last_vfgprc, in ixv_update_stats()
1807 sc->stats.vf.vfgprc); in ixv_update_stats()
1808 UPDATE_STAT_32(IXGBE_VFGPTC, sc->stats.vf.last_vfgptc, in ixv_update_stats()
1809 sc->stats.vf.vfgptc); in ixv_update_stats()
1811 sc->stats.vf.last_vfgorc, sc->stats.vf.vfgorc); in ixv_update_stats()
1813 sc->stats.vf.last_vfgotc, sc->stats.vf.vfgotc); in ixv_update_stats()
1814 UPDATE_STAT_32(IXGBE_VFMPRC, sc->stats.vf.last_vfmprc, in ixv_update_stats()
1815 sc->stats.vf.vfmprc); in ixv_update_stats()
1818 IXGBE_SET_IPACKETS(sc, stats->vfgprc); in ixv_update_stats()
1819 IXGBE_SET_OPACKETS(sc, stats->vfgptc); in ixv_update_stats()
1820 IXGBE_SET_IBYTES(sc, stats->vfgorc); in ixv_update_stats()
1821 IXGBE_SET_OBYTES(sc, stats->vfgotc); in ixv_update_stats()
1822 IXGBE_SET_IMCASTS(sc, stats->vfmprc); in ixv_update_stats()
1826 * ixv_add_stats_sysctls - Add statistic sysctls for the VF.
1828 static void
1831 device_t dev = sc->dev; in ixv_add_stats_sysctls()
1832 struct ix_tx_queue *tx_que = sc->tx_queues; in ixv_add_stats_sysctls()
1833 struct ix_rx_queue *rx_que = sc->rx_queues; in ixv_add_stats_sysctls()
1837 struct ixgbevf_hw_stats *stats = &sc->stats.vf; in ixv_add_stats_sysctls()
1846 CTLFLAG_RD, &sc->watchdog_events, "Watchdog timeouts"); in ixv_add_stats_sysctls()
1848 CTLFLAG_RD, &sc->link_irq, "Link MSI-X IRQ Handled"); in ixv_add_stats_sysctls()
1850 for (int i = 0; i < sc->num_tx_queues; i++, tx_que++) { in ixv_add_stats_sysctls()
1851 struct tx_ring *txr = &tx_que->txr; in ixv_add_stats_sysctls()
1858 CTLFLAG_RD, &(txr->tso_tx), "TSO Packets"); in ixv_add_stats_sysctls()
1860 CTLFLAG_RD, &(txr->total_packets), "TX Packets"); in ixv_add_stats_sysctls()
1863 for (int i = 0; i < sc->num_rx_queues; i++, rx_que++) { in ixv_add_stats_sysctls()
1864 struct rx_ring *rxr = &rx_que->rxr; in ixv_add_stats_sysctls()
1871 CTLFLAG_RD, &(rx_que->irqs), "IRQs on queue"); in ixv_add_stats_sysctls()
1873 CTLFLAG_RD, &(rxr->rx_packets), "RX packets"); in ixv_add_stats_sysctls()
1875 CTLFLAG_RD, &(rxr->rx_bytes), "RX bytes"); in ixv_add_stats_sysctls()
1877 CTLFLAG_RD, &(rxr->rx_discarded), "Discarded RX packets"); in ixv_add_stats_sysctls()
1886 CTLFLAG_RD, &stats->vfgprc, "Good Packets Received"); in ixv_add_stats_sysctls()
1888 CTLFLAG_RD, &stats->vfgorc, "Good Octets Received"); in ixv_add_stats_sysctls()
1890 CTLFLAG_RD, &stats->vfmprc, "Multicast Packets Received"); in ixv_add_stats_sysctls()
1892 CTLFLAG_RD, &stats->vfgptc, "Good Packets Transmitted"); in ixv_add_stats_sysctls()
1894 CTLFLAG_RD, &stats->vfgotc, "Good Octets Transmitted"); in ixv_add_stats_sysctls()
1904 static void
1907 device_t dev = sc->dev; in ixv_print_debug_info()
1908 struct ixgbe_hw *hw = &sc->hw; in ixv_print_debug_info()
1913 device_printf(dev, "MBX IRQ Handled: %lu\n", (long)sc->link_irq); in ixv_print_debug_info()
1919 static int
1925 result = -1; in ixv_sysctl_debug()
1928 if (error || !req->newptr) in ixv_sysctl_debug()
1942 static void
1945 sc->feat_cap = IXGBE_FEATURE_NETMAP | in ixv_init_device_features()
1950 switch (sc->hw.mac.type) { in ixv_init_device_features()
1958 sc->feat_cap |= IXGBE_FEATURE_NEEDS_CTXD; in ixv_init_device_features()
1959 sc->feat_cap |= IXGBE_FEATURE_RSS; in ixv_init_device_features()
1967 if (sc->feat_cap & IXGBE_FEATURE_VF) in ixv_init_device_features()
1968 sc->feat_en |= IXGBE_FEATURE_VF; in ixv_init_device_features()
1970 if (sc->feat_cap & IXGBE_FEATURE_NETMAP) in ixv_init_device_features()
1971 sc->feat_en |= IXGBE_FEATURE_NETMAP; in ixv_init_device_features()
1972 /* Receive-Side Scaling (RSS) */ in ixv_init_device_features()
1973 if (sc->feat_cap & IXGBE_FEATURE_RSS) in ixv_init_device_features()
1974 sc->feat_en |= IXGBE_FEATURE_RSS; in ixv_init_device_features()
1976 if (sc->feat_cap & IXGBE_FEATURE_NEEDS_CTXD) in ixv_init_device_features()
1977 sc->feat_en |= IXGBE_FEATURE_NEEDS_CTXD; in ixv_init_device_features()