diff options
author | Kevin Bowling <kbowling@FreeBSD.org> | 2024-10-14 13:29:55 +0000 |
---|---|---|
committer | Kevin Bowling <kbowling@FreeBSD.org> | 2024-10-14 13:52:31 +0000 |
commit | 542f5d56317e94676cf19cb9d66207bf9a6b6758 (patch) | |
tree | 4e003e4053882613a93a56d629ce665d9c670a10 | |
parent | 1bae9dc584272dd75dc4e04cb5d73be0e9fb562a (diff) | |
download | src-542f5d56317e.tar.gz src-542f5d56317e.zip |
igc: Rename 'struct adapter' to 'struct igc_softc'
Rename the 'struct adapter' to 'struct igc_softc' to avoid type
ambiguity in things like kgdb and make sharing code with e1000 and
ixgbe easier.
MFC after: 1 week
Sponsored by: BBOX.io
-rw-r--r-- | sys/dev/igc/if_igc.c | 970 | ||||
-rw-r--r-- | sys/dev/igc/if_igc.h | 28 | ||||
-rw-r--r-- | sys/dev/igc/igc_txrx.c | 36 |
3 files changed, 517 insertions, 517 deletions
diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c index b927b9e3b260..a55d8b6cbc9c 100644 --- a/sys/dev/igc/if_igc.c +++ b/sys/dev/igc/if_igc.c @@ -111,25 +111,25 @@ static int igc_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid); static void igc_if_multi_set(if_ctx_t ctx); static void igc_if_update_admin_status(if_ctx_t ctx); static void igc_if_debug(if_ctx_t ctx); -static void igc_update_stats_counters(struct igc_adapter *); -static void igc_add_hw_stats(struct igc_adapter *adapter); +static void igc_update_stats_counters(struct igc_softc *); +static void igc_add_hw_stats(struct igc_softc *sc); static int igc_if_set_promisc(if_ctx_t ctx, int flags); static void igc_setup_vlan_hw_support(if_ctx_t ctx); -static void igc_fw_version(struct igc_adapter *); +static void igc_fw_version(struct igc_softc *); static void igc_sbuf_fw_version(struct igc_fw_version *, struct sbuf *); -static void igc_print_fw_version(struct igc_adapter *); +static void igc_print_fw_version(struct igc_softc *); static int igc_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS); static int igc_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); -static void igc_print_nvm_info(struct igc_adapter *); +static void igc_print_nvm_info(struct igc_softc *); static int igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS); static int igc_get_rs(SYSCTL_HANDLER_ARGS); -static void igc_print_debug_info(struct igc_adapter *); +static void igc_print_debug_info(struct igc_softc *); static int igc_is_valid_ether_addr(u8 *); -static void igc_neweitr(struct igc_adapter *, struct igc_rx_queue *, +static void igc_neweitr(struct igc_softc *, struct igc_rx_queue *, struct tx_ring *, struct rx_ring *); /* Management and WOL Support */ -static void igc_get_hw_control(struct igc_adapter *); -static void igc_release_hw_control(struct igc_adapter *); +static void igc_get_hw_control(struct igc_softc *); +static void igc_release_hw_control(struct igc_softc *); static void igc_get_wakeup(if_ctx_t ctx); static void igc_enable_wakeup(if_ctx_t ctx); @@ -146,7 +146,7 @@ static int igc_sysctl_eee(SYSCTL_HANDLER_ARGS); static int igc_get_regs(SYSCTL_HANDLER_ARGS); -static void igc_configure_queues(struct igc_adapter *adapter); +static void igc_configure_queues(struct igc_softc *sc); /********************************************************************* @@ -165,7 +165,7 @@ static device_method_t igc_methods[] = { }; static driver_t igc_driver = { - "igc", igc_methods, sizeof(struct igc_adapter), + "igc", igc_methods, sizeof(struct igc_softc), }; DRIVER_MODULE(igc, pci, igc_driver, 0, 0); @@ -208,7 +208,7 @@ static device_method_t igc_if_methods[] = { }; static driver_t igc_if_driver = { - "igc_if", igc_if_methods, sizeof(struct igc_adapter) + "igc_if", igc_if_methods, sizeof(struct igc_softc) }; /********************************************************************* @@ -295,8 +295,8 @@ static struct if_shared_ctx igc_sctx_init = { static int igc_get_regs(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *adapter = (struct igc_adapter *)arg1; - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = (struct igc_softc *)arg1; + struct igc_hw *hw = &sc->hw; struct sbuf *sb; u32 *regs_buff; int rc; @@ -372,7 +372,7 @@ static int igc_get_regs(SYSCTL_HANDLER_ARGS) #ifdef DUMP_DESCS { - if_softc_ctx_t scctx = adapter->shared; + if_softc_ctx_t scctx = sc->shared; struct rx_ring *rxr = &rx_que->rxr; struct tx_ring *txr = &tx_que->txr; int ntxd = scctx->isc_ntxd[0]; @@ -434,7 +434,7 @@ igc_set_num_queues(if_ctx_t ctx) static int igc_if_attach_pre(if_ctx_t ctx) { - struct igc_adapter *adapter; + struct igc_softc *sc; if_softc_ctx_t scctx; device_t dev; struct igc_hw *hw; @@ -442,59 +442,59 @@ igc_if_attach_pre(if_ctx_t ctx) INIT_DEBUGOUT("igc_if_attach_pre: begin"); dev = iflib_get_dev(ctx); - adapter = iflib_get_softc(ctx); + sc = iflib_get_softc(ctx); - adapter->ctx = adapter->osdep.ctx = ctx; - adapter->dev = adapter->osdep.dev = dev; - scctx = adapter->shared = iflib_get_softc_ctx(ctx); - adapter->media = iflib_get_media(ctx); - hw = &adapter->hw; + sc->ctx = sc->osdep.ctx = ctx; + sc->dev = sc->osdep.dev = dev; + scctx = sc->shared = iflib_get_softc_ctx(ctx); + sc->media = iflib_get_media(ctx); + hw = &sc->hw; /* SYSCTL stuff */ SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "nvm", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - adapter, 0, igc_sysctl_nvm_info, "I", "NVM Information"); + sc, 0, igc_sysctl_nvm_info, "I", "NVM Information"); - adapter->enable_aim = igc_enable_aim; + sc->enable_aim = igc_enable_aim; SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "enable_aim", CTLFLAG_RW, - &adapter->enable_aim, 0, + &sc->enable_aim, 0, "Interrupt Moderation (1=normal, 2=lowlatency)"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "fw_version", CTLTYPE_STRING | CTLFLAG_RD, - adapter, 0, igc_sysctl_print_fw_version, "A", + sc, 0, igc_sysctl_print_fw_version, "A", "Prints FW/NVM Versions"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "debug", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - adapter, 0, igc_sysctl_debug_info, "I", "Debug Information"); + sc, 0, igc_sysctl_debug_info, "I", "Debug Information"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "fc", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - adapter, 0, igc_set_flowcntl, "I", "Flow Control"); + sc, 0, igc_set_flowcntl, "I", "Flow Control"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "reg_dump", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, igc_get_regs, "A", "Dump Registers"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "rs_dump", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, adapter, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, igc_get_rs, "I", "Dump RS indexes"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "dmac", - CTLTYPE_INT | CTLFLAG_RW, adapter, 0, + CTLTYPE_INT | CTLFLAG_RW, sc, 0, igc_sysctl_dmac, "I", "DMA Coalesce"); /* Determine hardware and mac info */ @@ -559,13 +559,13 @@ igc_if_attach_pre(if_ctx_t ctx) * Set the frame limits assuming * standard ethernet sized frames. */ - scctx->isc_max_frame_size = adapter->hw.mac.max_frame_size = + scctx->isc_max_frame_size = sc->hw.mac.max_frame_size = ETHERMTU + ETHER_HDR_LEN + ETHERNET_FCS_SIZE; /* Allocate multicast array memory. */ - adapter->mta = malloc(sizeof(u8) * ETHER_ADDR_LEN * + sc->mta = malloc(sizeof(u8) * ETHER_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES, M_DEVBUF, M_NOWAIT); - if (adapter->mta == NULL) { + if (sc->mta == NULL) { device_printf(dev, "Can not allocate multicast setup array\n"); error = ENOMEM; goto err_late; @@ -577,12 +577,12 @@ igc_if_attach_pre(if_ctx_t ctx) " due to SOL/IDER session.\n"); /* Sysctl for setting Energy Efficient Ethernet */ - adapter->hw.dev_spec._i225.eee_disable = igc_eee_setting; + sc->hw.dev_spec._i225.eee_disable = igc_eee_setting; SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "eee_control", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - adapter, 0, igc_sysctl_eee, "I", + sc, 0, igc_sysctl_eee, "I", "Disable Energy Efficient Ethernet"); /* @@ -622,9 +622,9 @@ igc_if_attach_pre(if_ctx_t ctx) } /* Save the EEPROM/NVM versions */ - igc_fw_version(adapter); + igc_fw_version(sc); - igc_print_fw_version(adapter); + igc_print_fw_version(sc); /* * Get Wake-on-Lan and Management info for later use @@ -633,7 +633,7 @@ igc_if_attach_pre(if_ctx_t ctx) /* Enable only WOL MAGIC by default */ scctx->isc_capenable &= ~IFCAP_WOL; - if (adapter->wol != 0) + if (sc->wol != 0) scctx->isc_capenable |= IFCAP_WOL_MAGIC; iflib_set_mac(ctx, hw->mac.addr); @@ -641,10 +641,10 @@ igc_if_attach_pre(if_ctx_t ctx) return (0); err_late: - igc_release_hw_control(adapter); + igc_release_hw_control(sc); err_pci: igc_free_pci_resources(ctx); - free(adapter->mta, M_DEVBUF); + free(sc->mta, M_DEVBUF); return (error); } @@ -652,8 +652,8 @@ err_pci: static int igc_if_attach_post(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_hw *hw = &sc->hw; int error = 0; /* Setup OS specific network interface */ @@ -665,23 +665,23 @@ igc_if_attach_post(if_ctx_t ctx) igc_reset(ctx); /* Initialize statistics */ - igc_update_stats_counters(adapter); + igc_update_stats_counters(sc); hw->mac.get_link_status = true; igc_if_update_admin_status(ctx); - igc_add_hw_stats(adapter); + igc_add_hw_stats(sc); /* the driver can now take control from firmware */ - igc_get_hw_control(adapter); + igc_get_hw_control(sc); INIT_DEBUGOUT("igc_if_attach_post: end"); return (error); err_late: - igc_release_hw_control(adapter); + igc_release_hw_control(sc); igc_free_pci_resources(ctx); igc_if_queues_free(ctx); - free(adapter->mta, M_DEVBUF); + free(sc->mta, M_DEVBUF); return (error); } @@ -698,13 +698,13 @@ err_late: static int igc_if_detach(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); INIT_DEBUGOUT("igc_if_detach: begin"); - igc_phy_hw_reset(&adapter->hw); + igc_phy_hw_reset(&sc->hw); - igc_release_hw_control(adapter); + igc_release_hw_control(sc); igc_free_pci_resources(ctx); return (0); @@ -728,9 +728,9 @@ igc_if_shutdown(if_ctx_t ctx) static int igc_if_suspend(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); - igc_release_hw_control(adapter); + igc_release_hw_control(sc); igc_enable_wakeup(ctx); return (0); } @@ -747,7 +747,7 @@ static int igc_if_mtu_set(if_ctx_t ctx, uint32_t mtu) { int max_frame_size; - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); if_softc_ctx_t scctx = iflib_get_softc_ctx(ctx); IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFMTU (Set Interface MTU)"); @@ -759,7 +759,7 @@ igc_if_mtu_set(if_ctx_t ctx, uint32_t mtu) return (EINVAL); } - scctx->isc_max_frame_size = adapter->hw.mac.max_frame_size = + scctx->isc_max_frame_size = sc->hw.mac.max_frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; return (0); } @@ -776,8 +776,8 @@ igc_if_mtu_set(if_ctx_t ctx, uint32_t mtu) static void igc_if_init(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct igc_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; if_t ifp = iflib_get_ifp(ctx); struct igc_tx_queue *tx_que; int i; @@ -785,17 +785,17 @@ igc_if_init(if_ctx_t ctx) INIT_DEBUGOUT("igc_if_init: begin"); /* Get the latest mac address, User can use a LAA */ - bcopy(if_getlladdr(ifp), adapter->hw.mac.addr, + bcopy(if_getlladdr(ifp), sc->hw.mac.addr, ETHER_ADDR_LEN); /* Put the address into the Receive Address Array */ - igc_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); + igc_rar_set(&sc->hw, sc->hw.mac.addr, 0); /* Initialize the hardware */ igc_reset(ctx); igc_if_update_admin_status(ctx); - for (i = 0, tx_que = adapter->tx_queues; i < adapter->tx_num_queues; i++, tx_que++) { + for (i = 0, tx_que = sc->tx_queues; i < sc->tx_num_queues; i++, tx_que++) { struct tx_ring *txr = &tx_que->txr; txr->tx_rs_cidx = txr->tx_rs_pidx; @@ -809,7 +809,7 @@ igc_if_init(if_ctx_t ctx) } /* Setup VLAN support, basic and offload if available */ - IGC_WRITE_REG(&adapter->hw, IGC_VET, ETHERTYPE_VLAN); + IGC_WRITE_REG(&sc->hw, IGC_VET, ETHERTYPE_VLAN); /* Prepare transmit descriptors and buffers */ igc_initialize_transmit_unit(ctx); @@ -817,7 +817,7 @@ igc_if_init(if_ctx_t ctx) /* Setup Multicast table */ igc_if_multi_set(ctx); - adapter->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); + sc->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); igc_initialize_receive_unit(ctx); /* Set up VLAN support */ @@ -825,20 +825,20 @@ igc_if_init(if_ctx_t ctx) /* Don't lose promiscuous settings */ igc_if_set_promisc(ctx, if_getflags(ifp)); - igc_clear_hw_cntrs_base_generic(&adapter->hw); + igc_clear_hw_cntrs_base_generic(&sc->hw); - if (adapter->intr_type == IFLIB_INTR_MSIX) /* Set up queue routing */ - igc_configure_queues(adapter); + if (sc->intr_type == IFLIB_INTR_MSIX) /* Set up queue routing */ + igc_configure_queues(sc); /* this clears any pending interrupts */ - IGC_READ_REG(&adapter->hw, IGC_ICR); - IGC_WRITE_REG(&adapter->hw, IGC_ICS, IGC_ICS_LSC); + IGC_READ_REG(&sc->hw, IGC_ICR); + IGC_WRITE_REG(&sc->hw, IGC_ICS, IGC_ICS_LSC); /* the driver can now take control from firmware */ - igc_get_hw_control(adapter); + igc_get_hw_control(sc); /* Set Energy Efficient Ethernet */ - igc_set_eee_i225(&adapter->hw, true, true, true); + igc_set_eee_i225(&sc->hw, true, true, true); } enum eitr_latency_target { @@ -853,7 +853,7 @@ enum eitr_latency_target { * *********************************************************************/ static void -igc_neweitr(struct igc_adapter *sc, struct igc_rx_queue *que, +igc_neweitr(struct igc_softc *sc, struct igc_rx_queue *que, struct tx_ring *txr, struct rx_ring *rxr) { struct igc_hw *hw = &sc->hw; @@ -985,12 +985,12 @@ igc_set_next_eitr: int igc_intr(void *arg) { - struct igc_adapter *adapter = arg; - struct igc_hw *hw = &adapter->hw; - struct igc_rx_queue *que = &adapter->rx_queues[0]; - struct tx_ring *txr = &adapter->tx_queues[0].txr; + struct igc_softc *sc = arg; + struct igc_hw *hw = &sc->hw; + struct igc_rx_queue *que = &sc->rx_queues[0]; + struct tx_ring *txr = &sc->tx_queues[0].txr; struct rx_ring *rxr = &que->rxr; - if_ctx_t ctx = adapter->ctx; + if_ctx_t ctx = sc->ctx; u32 reg_icr; reg_icr = IGC_READ_REG(hw, IGC_ICR); @@ -1019,9 +1019,9 @@ igc_intr(void *arg) igc_handle_link(ctx); if (reg_icr & IGC_ICR_RXO) - adapter->rx_overruns++; + sc->rx_overruns++; - igc_neweitr(adapter, que, txr, rxr); + igc_neweitr(sc, que, txr, rxr); /* Reset state */ txr->tx_bytes = 0; @@ -1035,20 +1035,20 @@ igc_intr(void *arg) static int igc_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_rx_queue *rxq = &adapter->rx_queues[rxqid]; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_rx_queue *rxq = &sc->rx_queues[rxqid]; - IGC_WRITE_REG(&adapter->hw, IGC_EIMS, rxq->eims); + IGC_WRITE_REG(&sc->hw, IGC_EIMS, rxq->eims); return (0); } static int igc_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_tx_queue *txq = &adapter->tx_queues[txqid]; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_tx_queue *txq = &sc->tx_queues[txqid]; - IGC_WRITE_REG(&adapter->hw, IGC_EIMS, txq->eims); + IGC_WRITE_REG(&sc->hw, IGC_EIMS, txq->eims); return (0); } @@ -1061,7 +1061,7 @@ static int igc_msix_que(void *arg) { struct igc_rx_queue *que = arg; - struct igc_adapter *sc = que->adapter; + struct igc_softc *sc = que->sc; struct tx_ring *txr = &sc->tx_queues[que->msix].txr; struct rx_ring *rxr = &que->rxr; @@ -1086,22 +1086,22 @@ igc_msix_que(void *arg) static int igc_msix_link(void *arg) { - struct igc_adapter *adapter = arg; + struct igc_softc *sc = arg; u32 reg_icr; - ++adapter->link_irq; - MPASS(adapter->hw.back != NULL); - reg_icr = IGC_READ_REG(&adapter->hw, IGC_ICR); + ++sc->link_irq; + MPASS(sc->hw.back != NULL); + reg_icr = IGC_READ_REG(&sc->hw, IGC_ICR); if (reg_icr & IGC_ICR_RXO) - adapter->rx_overruns++; + sc->rx_overruns++; if (reg_icr & (IGC_ICR_RXSEQ | IGC_ICR_LSC)) { - igc_handle_link(adapter->ctx); + igc_handle_link(sc->ctx); } - IGC_WRITE_REG(&adapter->hw, IGC_IMS, IGC_IMS_LSC); - IGC_WRITE_REG(&adapter->hw, IGC_EIMS, adapter->link_mask); + IGC_WRITE_REG(&sc->hw, IGC_IMS, IGC_IMS_LSC); + IGC_WRITE_REG(&sc->hw, IGC_EIMS, sc->link_mask); return (FILTER_HANDLED); } @@ -1110,9 +1110,9 @@ static void igc_handle_link(void *context) { if_ctx_t ctx = context; - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); - adapter->hw.mac.get_link_status = true; + sc->hw.mac.get_link_status = true; iflib_admin_intr_deferred(ctx); } @@ -1127,7 +1127,7 @@ igc_handle_link(void *context) static void igc_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); INIT_DEBUGOUT("igc_if_media_status: begin"); @@ -1136,13 +1136,13 @@ igc_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr) ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; - if (!adapter->link_active) { + if (!sc->link_active) { return; } ifmr->ifm_status |= IFM_ACTIVE; - switch (adapter->link_speed) { + switch (sc->link_speed) { case 10: ifmr->ifm_active |= IFM_10_T; break; @@ -1157,7 +1157,7 @@ igc_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr) break; } - if (adapter->link_duplex == FULL_DUPLEX) + if (sc->link_duplex == FULL_DUPLEX) ifmr->ifm_active |= IFM_FDX; else ifmr->ifm_active |= IFM_HDX; @@ -1174,7 +1174,7 @@ igc_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr) static int igc_if_media_change(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); struct ifmedia *ifm = iflib_get_media(ctx); INIT_DEBUGOUT("igc_if_media_change: begin"); @@ -1182,32 +1182,32 @@ igc_if_media_change(if_ctx_t ctx) if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) return (EINVAL); - adapter->hw.mac.autoneg = DO_AUTO_NEG; + sc->hw.mac.autoneg = DO_AUTO_NEG; switch (IFM_SUBTYPE(ifm->ifm_media)) { case IFM_AUTO: - adapter->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT; + sc->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT; break; case IFM_2500_T: - adapter->hw.phy.autoneg_advertised = ADVERTISE_2500_FULL; + sc->hw.phy.autoneg_advertised = ADVERTISE_2500_FULL; break; case IFM_1000_T: - adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; + sc->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; break; case IFM_100_TX: if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) - adapter->hw.phy.autoneg_advertised = ADVERTISE_100_FULL; + sc->hw.phy.autoneg_advertised = ADVERTISE_100_FULL; else - adapter->hw.phy.autoneg_advertised = ADVERTISE_100_HALF; + sc->hw.phy.autoneg_advertised = ADVERTISE_100_HALF; break; case IFM_10_T: if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) - adapter->hw.phy.autoneg_advertised = ADVERTISE_10_FULL; + sc->hw.phy.autoneg_advertised = ADVERTISE_10_FULL; else - adapter->hw.phy.autoneg_advertised = ADVERTISE_10_HALF; + sc->hw.phy.autoneg_advertised = ADVERTISE_10_HALF; break; default: - device_printf(adapter->dev, "Unsupported media type\n"); + device_printf(sc->dev, "Unsupported media type\n"); } igc_if_init(ctx); @@ -1218,12 +1218,12 @@ igc_if_media_change(if_ctx_t ctx) static int igc_if_set_promisc(if_ctx_t ctx, int flags) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); if_t ifp = iflib_get_ifp(ctx); u32 reg_rctl; int mcnt = 0; - reg_rctl = IGC_READ_REG(&adapter->hw, IGC_RCTL); + reg_rctl = IGC_READ_REG(&sc->hw, IGC_RCTL); reg_rctl &= ~(IGC_RCTL_SBP | IGC_RCTL_UPE); if (flags & IFF_ALLMULTI) mcnt = MAX_NUM_MULTICAST_ADDRESSES; @@ -1233,18 +1233,18 @@ igc_if_set_promisc(if_ctx_t ctx, int flags) /* Don't disable if in MAX groups */ if (mcnt < MAX_NUM_MULTICAST_ADDRESSES) reg_rctl &= (~IGC_RCTL_MPE); - IGC_WRITE_REG(&adapter->hw, IGC_RCTL, reg_rctl); + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); if (flags & IFF_PROMISC) { reg_rctl |= (IGC_RCTL_UPE | IGC_RCTL_MPE); /* Turn this on if you want to see bad packets */ if (igc_debug_sbp) reg_rctl |= IGC_RCTL_SBP; - IGC_WRITE_REG(&adapter->hw, IGC_RCTL, reg_rctl); + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); } else if (flags & IFF_ALLMULTI) { reg_rctl |= IGC_RCTL_MPE; reg_rctl &= ~IGC_RCTL_UPE; - IGC_WRITE_REG(&adapter->hw, IGC_RCTL, reg_rctl); + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); } return (0); } @@ -1272,7 +1272,7 @@ igc_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int idx) static void igc_if_multi_set(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); if_t ifp = iflib_get_ifp(ctx); u8 *mta; /* Multicast array memory */ u32 reg_rctl = 0; @@ -1280,12 +1280,12 @@ igc_if_multi_set(if_ctx_t ctx) IOCTL_DEBUGOUT("igc_set_multi: begin"); - mta = adapter->mta; + mta = sc->mta; bzero(mta, sizeof(u8) * ETHER_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES); mcnt = if_foreach_llmaddr(ifp, igc_copy_maddr, mta); - reg_rctl = IGC_READ_REG(&adapter->hw, IGC_RCTL); + reg_rctl = IGC_READ_REG(&sc->hw, IGC_RCTL); if (if_getflags(ifp) & IFF_PROMISC) { reg_rctl |= (IGC_RCTL_UPE | IGC_RCTL_MPE); @@ -1300,9 +1300,9 @@ igc_if_multi_set(if_ctx_t ctx) reg_rctl &= ~(IGC_RCTL_UPE | IGC_RCTL_MPE); if (mcnt < MAX_NUM_MULTICAST_ADDRESSES) - igc_update_mc_addr_list(&adapter->hw, mta, mcnt); + igc_update_mc_addr_list(&sc->hw, mta, mcnt); - IGC_WRITE_REG(&adapter->hw, IGC_RCTL, reg_rctl); + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); } /********************************************************************* @@ -1326,8 +1326,8 @@ igc_if_timer(if_ctx_t ctx, uint16_t qid) static void igc_if_update_admin_status(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_hw *hw = &sc->hw; device_t dev = iflib_get_dev(ctx); u32 link_check, thstat, ctrl; @@ -1351,36 +1351,36 @@ igc_if_update_admin_status(if_ctx_t ctx) } /* Now check for a transition */ - if (link_check && (adapter->link_active == 0)) { - igc_get_speed_and_duplex(hw, &adapter->link_speed, - &adapter->link_duplex); + if (link_check && (sc->link_active == 0)) { + igc_get_speed_and_duplex(hw, &sc->link_speed, + &sc->link_duplex); if (bootverbose) device_printf(dev, "Link is up %d Mbps %s\n", - adapter->link_speed, - ((adapter->link_duplex == FULL_DUPLEX) ? + sc->link_speed, + ((sc->link_duplex == FULL_DUPLEX) ? "Full Duplex" : "Half Duplex")); - adapter->link_active = 1; + sc->link_active = 1; iflib_link_state_change(ctx, LINK_STATE_UP, - IF_Mbps(adapter->link_speed)); - } else if (!link_check && (adapter->link_active == 1)) { - adapter->link_speed = 0; - adapter->link_duplex = 0; - adapter->link_active = 0; + IF_Mbps(sc->link_speed)); + } else if (!link_check && (sc->link_active == 1)) { + sc->link_speed = 0; + sc->link_duplex = 0; + sc->link_active = 0; iflib_link_state_change(ctx, LINK_STATE_DOWN, 0); } - igc_update_stats_counters(adapter); + igc_update_stats_counters(sc); } static void igc_if_watchdog_reset(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); /* * Just count the event; iflib(4) will already trigger a * sufficient reset of the controller. */ - adapter->watchdog_events++; + sc->watchdog_events++; } /********************************************************************* @@ -1392,12 +1392,12 @@ igc_if_watchdog_reset(if_ctx_t ctx) static void igc_if_stop(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); INIT_DEBUGOUT("igc_if_stop: begin"); - igc_reset_hw(&adapter->hw); - IGC_WRITE_REG(&adapter->hw, IGC_WUC, 0); + igc_reset_hw(&sc->hw); + IGC_WRITE_REG(&sc->hw, IGC_WUC, 0); } /********************************************************************* @@ -1409,22 +1409,22 @@ static void igc_identify_hardware(if_ctx_t ctx) { device_t dev = iflib_get_dev(ctx); - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); /* Make sure our PCI config space has the necessary stuff set */ - adapter->hw.bus.pci_cmd_word = pci_read_config(dev, PCIR_COMMAND, 2); + sc->hw.bus.pci_cmd_word = pci_read_config(dev, PCIR_COMMAND, 2); /* Save off the information about this board */ - adapter->hw.vendor_id = pci_get_vendor(dev); - adapter->hw.device_id = pci_get_device(dev); - adapter->hw.revision_id = pci_read_config(dev, PCIR_REVID, 1); - adapter->hw.subsystem_vendor_id = + sc->hw.vendor_id = pci_get_vendor(dev); + sc->hw.device_id = pci_get_device(dev); + sc->hw.revision_id = pci_read_config(dev, PCIR_REVID, 1); + sc->hw.subsystem_vendor_id = pci_read_config(dev, PCIR_SUBVEND_0, 2); - adapter->hw.subsystem_device_id = + sc->hw.subsystem_device_id = pci_read_config(dev, PCIR_SUBDEV_0, 2); /* Do Shared Code Init and Setup */ - if (igc_set_mac_type(&adapter->hw)) { + if (igc_set_mac_type(&sc->hw)) { device_printf(dev, "Setup init failure\n"); return; } @@ -1433,23 +1433,23 @@ igc_identify_hardware(if_ctx_t ctx) static int igc_allocate_pci_resources(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); device_t dev = iflib_get_dev(ctx); int rid; rid = PCIR_BAR(0); - adapter->memory = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + sc->memory = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (adapter->memory == NULL) { + if (sc->memory == NULL) { device_printf(dev, "Unable to allocate bus resource: memory\n"); return (ENXIO); } - adapter->osdep.mem_bus_space_tag = rman_get_bustag(adapter->memory); - adapter->osdep.mem_bus_space_handle = - rman_get_bushandle(adapter->memory); - adapter->hw.hw_addr = (u8 *)&adapter->osdep.mem_bus_space_handle; + sc->osdep.mem_bus_space_tag = rman_get_bustag(sc->memory); + sc->osdep.mem_bus_space_handle = + rman_get_bushandle(sc->memory); + sc->hw.hw_addr = (u8 *)&sc->osdep.mem_bus_space_handle; - adapter->hw.back = &adapter->osdep; + sc->hw.back = &sc->osdep; return (0); } @@ -1462,20 +1462,20 @@ igc_allocate_pci_resources(if_ctx_t ctx) static int igc_if_msix_intr_assign(if_ctx_t ctx, int msix) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_rx_queue *rx_que = adapter->rx_queues; - struct igc_tx_queue *tx_que = adapter->tx_queues; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_rx_queue *rx_que = sc->rx_queues; + struct igc_tx_queue *tx_que = sc->tx_queues; int error, rid, i, vector = 0, rx_vectors; char buf[16]; /* First set up ring resources */ - for (i = 0; i < adapter->rx_num_queues; i++, rx_que++, vector++) { + for (i = 0; i < sc->rx_num_queues; i++, rx_que++, vector++) { rid = vector + 1; snprintf(buf, sizeof(buf), "rxq%d", i); error = iflib_irq_alloc_generic(ctx, &rx_que->que_irq, rid, IFLIB_INTR_RXTX, igc_msix_que, rx_que, rx_que->me, buf); if (error) { device_printf(iflib_get_dev(ctx), "Failed to allocate que int %d err: %d", i, error); - adapter->rx_num_queues = i + 1; + sc->rx_num_queues = i + 1; goto fail; } @@ -1492,14 +1492,14 @@ igc_if_msix_intr_assign(if_ctx_t ctx, int msix) rx_vectors = vector; vector = 0; - for (i = 0; i < adapter->tx_num_queues; i++, tx_que++, vector++) { + for (i = 0; i < sc->tx_num_queues; i++, tx_que++, vector++) { snprintf(buf, sizeof(buf), "txq%d", i); - tx_que = &adapter->tx_queues[i]; + tx_que = &sc->tx_queues[i]; iflib_softirq_alloc_generic(ctx, - &adapter->rx_queues[i % adapter->rx_num_queues].que_irq, + &sc->rx_queues[i % sc->rx_num_queues].que_irq, IFLIB_INTR_TX, tx_que, tx_que->me, buf); - tx_que->msix = (vector % adapter->rx_num_queues); + tx_que->msix = (vector % sc->rx_num_queues); /* * Set the bit to enable interrupt @@ -1512,26 +1512,26 @@ igc_if_msix_intr_assign(if_ctx_t ctx, int msix) /* Link interrupt */ rid = rx_vectors + 1; - error = iflib_irq_alloc_generic(ctx, &adapter->irq, rid, IFLIB_INTR_ADMIN, igc_msix_link, adapter, 0, "aq"); + error = iflib_irq_alloc_generic(ctx, &sc->irq, rid, IFLIB_INTR_ADMIN, igc_msix_link, sc, 0, "aq"); if (error) { device_printf(iflib_get_dev(ctx), "Failed to register admin handler"); goto fail; } - adapter->linkvec = rx_vectors; + sc->linkvec = rx_vectors; return (0); fail: - iflib_irq_free(ctx, &adapter->irq); - rx_que = adapter->rx_queues; - for (int i = 0; i < adapter->rx_num_queues; i++, rx_que++) + iflib_irq_free(ctx, &sc->irq); + rx_que = sc->rx_queues; + for (int i = 0; i < sc->rx_num_queues; i++, rx_que++) iflib_irq_free(ctx, &rx_que->que_irq); return (error); } static void -igc_configure_queues(struct igc_adapter *adapter) +igc_configure_queues(struct igc_softc *sc) { - struct igc_hw *hw = &adapter->hw; + struct igc_hw *hw = &sc->hw; struct igc_rx_queue *rx_que; struct igc_tx_queue *tx_que; u32 ivar = 0, newitr = 0; @@ -1543,10 +1543,10 @@ igc_configure_queues(struct igc_adapter *adapter) /* Turn on MSI-X */ /* RX entries */ - for (int i = 0; i < adapter->rx_num_queues; i++) { + for (int i = 0; i < sc->rx_num_queues; i++) { u32 index = i >> 1; ivar = IGC_READ_REG_ARRAY(hw, IGC_IVAR0, index); - rx_que = &adapter->rx_queues[i]; + rx_que = &sc->rx_queues[i]; if (i & 1) { ivar &= 0xFF00FFFF; ivar |= (rx_que->msix | IGC_IVAR_VALID) << 16; @@ -1557,10 +1557,10 @@ igc_configure_queues(struct igc_adapter *adapter) IGC_WRITE_REG_ARRAY(hw, IGC_IVAR0, index, ivar); } /* TX entries */ - for (int i = 0; i < adapter->tx_num_queues; i++) { + for (int i = 0; i < sc->tx_num_queues; i++) { u32 index = i >> 1; ivar = IGC_READ_REG_ARRAY(hw, IGC_IVAR0, index); - tx_que = &adapter->tx_queues[i]; + tx_que = &sc->tx_queues[i]; if (i & 1) { ivar &= 0x00FFFFFF; ivar |= (tx_que->msix | IGC_IVAR_VALID) << 24; @@ -1569,12 +1569,12 @@ igc_configure_queues(struct igc_adapter *adapter) ivar |= (tx_que->msix | IGC_IVAR_VALID) << 8; } IGC_WRITE_REG_ARRAY(hw, IGC_IVAR0, index, ivar); - adapter->que_mask |= tx_que->eims; + sc->que_mask |= tx_que->eims; } /* And for the link interrupt */ - ivar = (adapter->linkvec | IGC_IVAR_VALID) << 8; - adapter->link_mask = 1 << adapter->linkvec; + ivar = (sc->linkvec | IGC_IVAR_VALID) << 8; + sc->link_mask = 1 << sc->linkvec; IGC_WRITE_REG(hw, IGC_IVAR_MISC, ivar); /* Set the starting interrupt rate */ @@ -1583,8 +1583,8 @@ igc_configure_queues(struct igc_adapter *adapter) newitr |= IGC_EITR_CNT_IGNR; - for (int i = 0; i < adapter->rx_num_queues; i++) { - rx_que = &adapter->rx_queues[i]; + for (int i = 0; i < sc->rx_num_queues; i++) { + rx_que = &sc->rx_queues[i]; IGC_WRITE_REG(hw, IGC_EITR(rx_que->msix), newitr); } @@ -1594,34 +1594,34 @@ igc_configure_queues(struct igc_adapter *adapter) static void igc_free_pci_resources(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_rx_queue *que = adapter->rx_queues; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_rx_queue *que = sc->rx_queues; device_t dev = iflib_get_dev(ctx); /* Release all MSI-X queue resources */ - if (adapter->intr_type == IFLIB_INTR_MSIX) - iflib_irq_free(ctx, &adapter->irq); + if (sc->intr_type == IFLIB_INTR_MSIX) + iflib_irq_free(ctx, &sc->irq); - for (int i = 0; i < adapter->rx_num_queues; i++, que++) { + for (int i = 0; i < sc->rx_num_queues; i++, que++) { iflib_irq_free(ctx, &que->que_irq); } - if (adapter->memory != NULL) { + if (sc->memory != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(adapter->memory), adapter->memory); - adapter->memory = NULL; + rman_get_rid(sc->memory), sc->memory); + sc->memory = NULL; } - if (adapter->flash != NULL) { + if (sc->flash != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(adapter->flash), adapter->flash); - adapter->flash = NULL; + rman_get_rid(sc->flash), sc->flash); + sc->flash = NULL; } - if (adapter->ioport != NULL) { + if (sc->ioport != NULL) { bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(adapter->ioport), adapter->ioport); - adapter->ioport = NULL; + rman_get_rid(sc->ioport), sc->ioport); + sc->ioport = NULL; } } @@ -1638,18 +1638,18 @@ igc_setup_msix(if_ctx_t ctx) * **********************************************************************/ static void -igc_init_dmac(struct igc_adapter *adapter, u32 pba) +igc_init_dmac(struct igc_softc *sc, u32 pba) { - device_t dev = adapter->dev; - struct igc_hw *hw = &adapter->hw; + device_t dev = sc->dev; + struct igc_hw *hw = &sc->hw; u32 dmac, reg = ~IGC_DMACR_DMAC_EN; u16 hwm; u16 max_frame_size; int status; - max_frame_size = adapter->shared->isc_max_frame_size; + max_frame_size = sc->shared->isc_max_frame_size; - if (adapter->dmac == 0) { /* Disabling it */ + if (sc->dmac == 0) { /* Disabling it */ IGC_WRITE_REG(hw, IGC_DMACR, reg); return; } else @@ -1687,9 +1687,9 @@ igc_init_dmac(struct igc_adapter *adapter, u32 pba) status = IGC_READ_REG(hw, IGC_STATUS); if ((status & IGC_STATUS_2P5_SKU) && (!(status & IGC_STATUS_2P5_SKU_OVER))) - reg |= ((adapter->dmac * 5) >> 6); + reg |= ((sc->dmac * 5) >> 6); else - reg |= (adapter->dmac >> 5); + reg |= (sc->dmac >> 5); IGC_WRITE_REG(hw, IGC_DMACR, reg); @@ -1725,21 +1725,21 @@ igc_init_dmac(struct igc_adapter *adapter, u32 pba) /********************************************************************* * * Initialize the hardware to a configuration as specified by the - * adapter structure. + * softc structure. * **********************************************************************/ static void igc_reset(if_ctx_t ctx) { device_t dev = iflib_get_dev(ctx); - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_hw *hw = &sc->hw; u32 rx_buffer_size; u32 pba; INIT_DEBUGOUT("igc_reset: begin"); /* Let the firmware know the OS is in control */ - igc_get_hw_control(adapter); + igc_get_hw_control(sc); /* * Packet Buffer Allocation (PBA) @@ -1766,12 +1766,12 @@ igc_reset(if_ctx_t ctx) */ rx_buffer_size = (pba & 0xffff) << 10; hw->fc.high_water = rx_buffer_size - - roundup2(adapter->hw.mac.max_frame_size, 1024); + roundup2(sc->hw.mac.max_frame_size, 1024); /* 16-byte granularity */ hw->fc.low_water = hw->fc.high_water - 16; - if (adapter->fc) /* locally set flow control value? */ - hw->fc.requested_mode = adapter->fc; + if (sc->fc) /* locally set flow control value? */ + hw->fc.requested_mode = sc->fc; else hw->fc.requested_mode = igc_fc_full; @@ -1790,10 +1790,10 @@ igc_reset(if_ctx_t ctx) } /* Setup DMA Coalescing */ - igc_init_dmac(adapter, pba); + igc_init_dmac(sc, pba); /* Save the final PBA off if it needs to be used elsewhere i.e. AIM */ - adapter->pba = pba; + sc->pba = pba; IGC_WRITE_REG(hw, IGC_VET, ETHERTYPE_VLAN); igc_get_phy_info(hw); @@ -1807,9 +1807,9 @@ igc_reset(if_ctx_t ctx) #define RSSKEYLEN 10 static void -igc_initialize_rss_mapping(struct igc_adapter *adapter) +igc_initialize_rss_mapping(struct igc_softc *sc) { - struct igc_hw *hw = &adapter->hw; + struct igc_hw *hw = &sc->hw; int i; int queue_id; u32 reta; @@ -1846,9 +1846,9 @@ igc_initialize_rss_mapping(struct igc_adapter *adapter) * the case so we don't go out of bounds * indexing arrays and such. */ - queue_id = queue_id % adapter->rx_num_queues; + queue_id = queue_id % sc->rx_num_queues; #else - queue_id = (i % adapter->rx_num_queues); + queue_id = (i % sc->rx_num_queues); #endif /* Adjust if required */ queue_id = queue_id << shift; @@ -1906,13 +1906,13 @@ static int igc_setup_interface(if_ctx_t ctx) { if_t ifp = iflib_get_ifp(ctx); - struct igc_adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct igc_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; INIT_DEBUGOUT("igc_setup_interface: begin"); /* Single Queue */ - if (adapter->tx_num_queues == 1) { + if (sc->tx_num_queues == 1) { if_setsendqlen(ifp, scctx->isc_ntxd[0] - 1); if_setsendqready(ifp); } @@ -1921,44 +1921,44 @@ igc_setup_interface(if_ctx_t ctx) * Specify the media types supported by this adapter and register * callbacks to update media and link information */ - ifmedia_add(adapter->media, IFM_ETHER | IFM_10_T, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | IFM_100_TX, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | IFM_1000_T, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | IFM_2500_T, 0, NULL); - - ifmedia_add(adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(adapter->media, IFM_ETHER | IFM_AUTO); + ifmedia_add(sc->media, IFM_ETHER | IFM_10_T, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | IFM_100_TX, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | IFM_1000_T, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | IFM_2500_T, 0, NULL); + + ifmedia_add(sc->media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(sc->media, IFM_ETHER | IFM_AUTO); return (0); } static int igc_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxqs, int ntxqsets) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct igc_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; int error = IGC_SUCCESS; struct igc_tx_queue *que; int i, j; - MPASS(adapter->tx_num_queues > 0); - MPASS(adapter->tx_num_queues == ntxqsets); + MPASS(sc->tx_num_queues > 0); + MPASS(sc->tx_num_queues == ntxqsets); /* First allocate the top level queue structs */ - if (!(adapter->tx_queues = + if (!(sc->tx_queues = (struct igc_tx_queue *) malloc(sizeof(struct igc_tx_queue) * - adapter->tx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { + sc->tx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n"); return(ENOMEM); } - for (i = 0, que = adapter->tx_queues; i < adapter->tx_num_queues; i++, que++) { + for (i = 0, que = sc->tx_queues; i < sc->tx_num_queues; i++, que++) { /* Set up some basics */ struct tx_ring *txr = &que->txr; - txr->adapter = que->adapter = adapter; + txr->sc = que->sc = sc; que->me = txr->me = i; /* Allocate report status array */ @@ -1976,7 +1976,7 @@ igc_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxq if (bootverbose) device_printf(iflib_get_dev(ctx), - "allocated for %d tx_queues\n", adapter->tx_num_queues); + "allocated for %d tx_queues\n", sc->tx_num_queues); return (0); fail: igc_if_queues_free(ctx); @@ -1986,27 +1986,27 @@ fail: static int igc_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs, int nrxqsets) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); int error = IGC_SUCCESS; struct igc_rx_queue *que; int i; - MPASS(adapter->rx_num_queues > 0); - MPASS(adapter->rx_num_queues == nrxqsets); + MPASS(sc->rx_num_queues > 0); + MPASS(sc->rx_num_queues == nrxqsets); /* First allocate the top level queue structs */ - if (!(adapter->rx_queues = + if (!(sc->rx_queues = (struct igc_rx_queue *) malloc(sizeof(struct igc_rx_queue) * - adapter->rx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { + sc->rx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n"); error = ENOMEM; goto fail; } - for (i = 0, que = adapter->rx_queues; i < nrxqsets; i++, que++) { + for (i = 0, que = sc->rx_queues; i < nrxqsets; i++, que++) { /* Set up some basics */ struct rx_ring *rxr = &que->rxr; - rxr->adapter = que->adapter = adapter; + rxr->sc = que->sc = sc; rxr->que = que; que->me = rxr->me = i; @@ -2017,7 +2017,7 @@ igc_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxq if (bootverbose) device_printf(iflib_get_dev(ctx), - "allocated for %d rx_queues\n", adapter->rx_num_queues); + "allocated for %d rx_queues\n", sc->rx_num_queues); return (0); fail: @@ -2028,12 +2028,12 @@ fail: static void igc_if_queues_free(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_tx_queue *tx_que = adapter->tx_queues; - struct igc_rx_queue *rx_que = adapter->rx_queues; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_tx_queue *tx_que = sc->tx_queues; + struct igc_rx_queue *rx_que = sc->rx_queues; if (tx_que != NULL) { - for (int i = 0; i < adapter->tx_num_queues; i++, tx_que++) { + for (int i = 0; i < sc->tx_num_queues; i++, tx_que++) { struct tx_ring *txr = &tx_que->txr; if (txr->tx_rsq == NULL) break; @@ -2041,19 +2041,19 @@ igc_if_queues_free(if_ctx_t ctx) free(txr->tx_rsq, M_DEVBUF); txr->tx_rsq = NULL; } - free(adapter->tx_queues, M_DEVBUF); - adapter->tx_queues = NULL; + free(sc->tx_queues, M_DEVBUF); + sc->tx_queues = NULL; } if (rx_que != NULL) { - free(adapter->rx_queues, M_DEVBUF); - adapter->rx_queues = NULL; + free(sc->rx_queues, M_DEVBUF); + sc->rx_queues = NULL; } - igc_release_hw_control(adapter); + igc_release_hw_control(sc); - if (adapter->mta != NULL) { - free(adapter->mta, M_DEVBUF); + if (sc->mta != NULL) { + free(sc->mta, M_DEVBUF); } } @@ -2065,20 +2065,20 @@ igc_if_queues_free(if_ctx_t ctx) static void igc_initialize_transmit_unit(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct igc_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; struct igc_tx_queue *que; struct tx_ring *txr; - struct igc_hw *hw = &adapter->hw; + struct igc_hw *hw = &sc->hw; u32 tctl, txdctl = 0; INIT_DEBUGOUT("igc_initialize_transmit_unit: begin"); - for (int i = 0; i < adapter->tx_num_queues; i++, txr++) { + for (int i = 0; i < sc->tx_num_queues; i++, txr++) { u64 bus_addr; caddr_t offp, endp; - que = &adapter->tx_queues[i]; + que = &sc->tx_queues[i]; txr = &que->txr; bus_addr = txr->tx_paddr; @@ -2099,8 +2099,8 @@ igc_initialize_transmit_unit(if_ctx_t ctx) IGC_WRITE_REG(hw, IGC_TDH(i), 0); HW_DEBUGOUT2("Base = %x, Length = %x\n", - IGC_READ_REG(&adapter->hw, IGC_TDBAL(i)), - IGC_READ_REG(&adapter->hw, IGC_TDLEN(i))); + IGC_READ_REG(&sc->hw, IGC_TDBAL(i)), + IGC_READ_REG(&sc->hw, IGC_TDLEN(i))); txdctl = 0; /* clear txdctl */ txdctl |= 0x1f; /* PTHRESH */ @@ -2114,13 +2114,13 @@ igc_initialize_transmit_unit(if_ctx_t ctx) } /* Program the Transmit Control Register */ - tctl = IGC_READ_REG(&adapter->hw, IGC_TCTL); + tctl = IGC_READ_REG(&sc->hw, IGC_TCTL); tctl &= ~IGC_TCTL_CT; tctl |= (IGC_TCTL_PSP | IGC_TCTL_RTLC | IGC_TCTL_EN | (IGC_COLLISION_THRESHOLD << IGC_CT_SHIFT)); /* This write will effectively turn on the transmit unit. */ - IGC_WRITE_REG(&adapter->hw, IGC_TCTL, tctl); + IGC_WRITE_REG(&sc->hw, IGC_TCTL, tctl); } /********************************************************************* @@ -2133,10 +2133,10 @@ igc_initialize_transmit_unit(if_ctx_t ctx) static void igc_initialize_receive_unit(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct igc_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; if_t ifp = iflib_get_ifp(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_hw *hw = &sc->hw; struct igc_rx_queue *que; int i; u32 psize, rctl, rxcsum, srrctl = 0; @@ -2172,31 +2172,31 @@ igc_initialize_receive_unit(if_ctx_t ctx) rxcsum = IGC_READ_REG(hw, IGC_RXCSUM); if (if_getcapenable(ifp) & IFCAP_RXCSUM) { rxcsum |= IGC_RXCSUM_CRCOFL; - if (adapter->tx_num_queues > 1) + if (sc->tx_num_queues > 1) rxcsum |= IGC_RXCSUM_PCSD; else rxcsum |= IGC_RXCSUM_IPPCSE; } else { - if (adapter->tx_num_queues > 1) + if (sc->tx_num_queues > 1) rxcsum |= IGC_RXCSUM_PCSD; else rxcsum &= ~IGC_RXCSUM_TUOFL; } IGC_WRITE_REG(hw, IGC_RXCSUM, rxcsum); - if (adapter->rx_num_queues > 1) - igc_initialize_rss_mapping(adapter); + if (sc->rx_num_queues > 1) + igc_initialize_rss_mapping(sc); if (if_getmtu(ifp) > ETHERMTU) { psize = scctx->isc_max_frame_size; /* are we on a vlan? */ if (if_vlantrunkinuse(ifp)) psize += VLAN_TAG_SIZE; - IGC_WRITE_REG(&adapter->hw, IGC_RLPML, psize); + IGC_WRITE_REG(&sc->hw, IGC_RLPML, psize); } /* Set maximum packet buffer len */ - srrctl |= (adapter->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> + srrctl |= (sc->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> IGC_SRRCTL_BSIZEPKT_SHIFT; /* srrctl above overrides this but set the register to a sane value */ rctl |= IGC_RCTL_SZ_2048; @@ -2207,14 +2207,14 @@ igc_initialize_receive_unit(if_ctx_t ctx) * * This drops frames rather than hanging the RX MAC for all queues. */ - if ((adapter->rx_num_queues > 1) && - (adapter->fc == igc_fc_none || - adapter->fc == igc_fc_rx_pause)) { + if ((sc->rx_num_queues > 1) && + (sc->fc == igc_fc_none || + sc->fc == igc_fc_rx_pause)) { srrctl |= IGC_SRRCTL_DROP_EN; } /* Setup the Base and Length of the Rx Descriptor Rings */ - for (i = 0, que = adapter->rx_queues; i < adapter->rx_num_queues; i++, que++) { + for (i = 0, que = sc->rx_queues; i < sc->rx_num_queues; i++, que++) { struct rx_ring *rxr = &que->rxr; u64 bus_addr = rxr->rx_paddr; u32 rxdctl; @@ -2258,8 +2258,8 @@ igc_initialize_receive_unit(if_ctx_t ctx) static void igc_setup_vlan_hw_support(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_hw *hw = &sc->hw; struct ifnet *ifp = iflib_get_ifp(ctx); u32 reg; @@ -2280,12 +2280,12 @@ igc_setup_vlan_hw_support(if_ctx_t ctx) static void igc_if_intr_enable(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_hw *hw = &sc->hw; u32 mask; - if (__predict_true(adapter->intr_type == IFLIB_INTR_MSIX)) { - mask = (adapter->que_mask | adapter->link_mask); + if (__predict_true(sc->intr_type == IFLIB_INTR_MSIX)) { + mask = (sc->que_mask | sc->link_mask); IGC_WRITE_REG(hw, IGC_EIAC, mask); IGC_WRITE_REG(hw, IGC_EIAM, mask); IGC_WRITE_REG(hw, IGC_EIMS, mask); @@ -2298,10 +2298,10 @@ igc_if_intr_enable(if_ctx_t ctx) static void igc_if_intr_disable(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); - struct igc_hw *hw = &adapter->hw; + struct igc_softc *sc = iflib_get_softc(ctx); + struct igc_hw *hw = &sc->hw; - if (__predict_true(adapter->intr_type == IFLIB_INTR_MSIX)) { + if (__predict_true(sc->intr_type == IFLIB_INTR_MSIX)) { IGC_WRITE_REG(hw, IGC_EIMC, 0xffffffff); IGC_WRITE_REG(hw, IGC_EIAC, 0); } @@ -2316,15 +2316,15 @@ igc_if_intr_disable(if_ctx_t ctx) * this means that the network i/f is open. */ static void -igc_get_hw_control(struct igc_adapter *adapter) +igc_get_hw_control(struct igc_softc *sc) { u32 ctrl_ext; - if (adapter->vf_ifp) + if (sc->vf_ifp) return; - ctrl_ext = IGC_READ_REG(&adapter->hw, IGC_CTRL_EXT); - IGC_WRITE_REG(&adapter->hw, IGC_CTRL_EXT, + ctrl_ext = IGC_READ_REG(&sc->hw, IGC_CTRL_EXT); + IGC_WRITE_REG(&sc->hw, IGC_CTRL_EXT, ctrl_ext | IGC_CTRL_EXT_DRV_LOAD); } @@ -2335,12 +2335,12 @@ igc_get_hw_control(struct igc_adapter *adapter) * f/w this means that the network i/f is closed. */ static void -igc_release_hw_control(struct igc_adapter *adapter) +igc_release_hw_control(struct igc_softc *sc) { u32 ctrl_ext; - ctrl_ext = IGC_READ_REG(&adapter->hw, IGC_CTRL_EXT); - IGC_WRITE_REG(&adapter->hw, IGC_CTRL_EXT, + ctrl_ext = IGC_READ_REG(&sc->hw, IGC_CTRL_EXT); + IGC_WRITE_REG(&sc->hw, IGC_CTRL_EXT, ctrl_ext & ~IGC_CTRL_EXT_DRV_LOAD); return; } @@ -2365,14 +2365,14 @@ igc_is_valid_ether_addr(u8 *addr) static void igc_get_wakeup(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); u16 eeprom_data = 0, apme_mask; apme_mask = IGC_WUC_APME; - eeprom_data = IGC_READ_REG(&adapter->hw, IGC_WUC); + eeprom_data = IGC_READ_REG(&sc->hw, IGC_WUC); if (eeprom_data & apme_mask) - adapter->wol = IGC_WUFC_LNKC; + sc->wol = IGC_WUFC_LNKC; } @@ -2382,7 +2382,7 @@ igc_get_wakeup(if_ctx_t ctx) static void igc_enable_wakeup(if_ctx_t ctx) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); device_t dev = iflib_get_dev(ctx); if_t ifp = iflib_get_ifp(ctx); int error = 0; @@ -2397,30 +2397,30 @@ igc_enable_wakeup(if_ctx_t ctx) * is set with all bits on by default. */ if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0) - adapter->wol &= ~IGC_WUFC_MAG; + sc->wol &= ~IGC_WUFC_MAG; if ((if_getcapenable(ifp) & IFCAP_WOL_UCAST) == 0) - adapter->wol &= ~IGC_WUFC_EX; + sc->wol &= ~IGC_WUFC_EX; if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) == 0) - adapter->wol &= ~IGC_WUFC_MC; + sc->wol &= ~IGC_WUFC_MC; else { - rctl = IGC_READ_REG(&adapter->hw, IGC_RCTL); + rctl = IGC_READ_REG(&sc->hw, IGC_RCTL); rctl |= IGC_RCTL_MPE; - IGC_WRITE_REG(&adapter->hw, IGC_RCTL, rctl); + IGC_WRITE_REG(&sc->hw, IGC_RCTL, rctl); } - if (!(adapter->wol & (IGC_WUFC_EX | IGC_WUFC_MAG | IGC_WUFC_MC))) + if (!(sc->wol & (IGC_WUFC_EX | IGC_WUFC_MAG | IGC_WUFC_MC))) goto pme; /* Advertise the wakeup capability */ - ctrl = IGC_READ_REG(&adapter->hw, IGC_CTRL); + ctrl = IGC_READ_REG(&sc->hw, IGC_CTRL); ctrl |= IGC_CTRL_ADVD3WUC; - IGC_WRITE_REG(&adapter->hw, IGC_CTRL, ctrl); + IGC_WRITE_REG(&sc->hw, IGC_CTRL, ctrl); /* Enable wakeup by the MAC */ - IGC_WRITE_REG(&adapter->hw, IGC_WUC, IGC_WUC_PME_EN); - IGC_WRITE_REG(&adapter->hw, IGC_WUFC, adapter->wol); + IGC_WRITE_REG(&sc->hw, IGC_WUC, IGC_WUC_PME_EN); + IGC_WRITE_REG(&sc->hw, IGC_WUFC, sc->wol); pme: status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2); @@ -2438,104 +2438,104 @@ pme: * **********************************************************************/ static void -igc_update_stats_counters(struct igc_adapter *adapter) -{ - u64 prev_xoffrxc = adapter->stats.xoffrxc; - - adapter->stats.crcerrs += IGC_READ_REG(&adapter->hw, IGC_CRCERRS); - adapter->stats.mpc += IGC_READ_REG(&adapter->hw, IGC_MPC); - adapter->stats.scc += IGC_READ_REG(&adapter->hw, IGC_SCC); - adapter->stats.ecol += IGC_READ_REG(&adapter->hw, IGC_ECOL); - - adapter->stats.mcc += IGC_READ_REG(&adapter->hw, IGC_MCC); - adapter->stats.latecol += IGC_READ_REG(&adapter->hw, IGC_LATECOL); - adapter->stats.colc += IGC_READ_REG(&adapter->hw, IGC_COLC); - adapter->stats.colc += IGC_READ_REG(&adapter->hw, IGC_RERC); - adapter->stats.dc += IGC_READ_REG(&adapter->hw, IGC_DC); - adapter->stats.rlec += IGC_READ_REG(&adapter->hw, IGC_RLEC); - adapter->stats.xonrxc += IGC_READ_REG(&adapter->hw, IGC_XONRXC); - adapter->stats.xontxc += IGC_READ_REG(&adapter->hw, IGC_XONTXC); - adapter->stats.xoffrxc += IGC_READ_REG(&adapter->hw, IGC_XOFFRXC); +igc_update_stats_counters(struct igc_softc *sc) +{ + u64 prev_xoffrxc = sc->stats.xoffrxc; + + sc->stats.crcerrs += IGC_READ_REG(&sc->hw, IGC_CRCERRS); + sc->stats.mpc += IGC_READ_REG(&sc->hw, IGC_MPC); + sc->stats.scc += IGC_READ_REG(&sc->hw, IGC_SCC); + sc->stats.ecol += IGC_READ_REG(&sc->hw, IGC_ECOL); + + sc->stats.mcc += IGC_READ_REG(&sc->hw, IGC_MCC); + sc->stats.latecol += IGC_READ_REG(&sc->hw, IGC_LATECOL); + sc->stats.colc += IGC_READ_REG(&sc->hw, IGC_COLC); + sc->stats.colc += IGC_READ_REG(&sc->hw, IGC_RERC); + sc->stats.dc += IGC_READ_REG(&sc->hw, IGC_DC); + sc->stats.rlec += IGC_READ_REG(&sc->hw, IGC_RLEC); + sc->stats.xonrxc += IGC_READ_REG(&sc->hw, IGC_XONRXC); + sc->stats.xontxc += IGC_READ_REG(&sc->hw, IGC_XONTXC); + sc->stats.xoffrxc += IGC_READ_REG(&sc->hw, IGC_XOFFRXC); /* * For watchdog management we need to know if we have been * paused during the last interval, so capture that here. */ - if (adapter->stats.xoffrxc != prev_xoffrxc) - adapter->shared->isc_pause_frames = 1; - adapter->stats.xofftxc += IGC_READ_REG(&adapter->hw, IGC_XOFFTXC); - adapter->stats.fcruc += IGC_READ_REG(&adapter->hw, IGC_FCRUC); - adapter->stats.prc64 += IGC_READ_REG(&adapter->hw, IGC_PRC64); - adapter->stats.prc127 += IGC_READ_REG(&adapter->hw, IGC_PRC127); - adapter->stats.prc255 += IGC_READ_REG(&adapter->hw, IGC_PRC255); - adapter->stats.prc511 += IGC_READ_REG(&adapter->hw, IGC_PRC511); - adapter->stats.prc1023 += IGC_READ_REG(&adapter->hw, IGC_PRC1023); - adapter->stats.prc1522 += IGC_READ_REG(&adapter->hw, IGC_PRC1522); - adapter->stats.tlpic += IGC_READ_REG(&adapter->hw, IGC_TLPIC); - adapter->stats.rlpic += IGC_READ_REG(&adapter->hw, IGC_RLPIC); - adapter->stats.gprc += IGC_READ_REG(&adapter->hw, IGC_GPRC); - adapter->stats.bprc += IGC_READ_REG(&adapter->hw, IGC_BPRC); - adapter->stats.mprc += IGC_READ_REG(&adapter->hw, IGC_MPRC); - adapter->stats.gptc += IGC_READ_REG(&adapter->hw, IGC_GPTC); + if (sc->stats.xoffrxc != prev_xoffrxc) + sc->shared->isc_pause_frames = 1; + sc->stats.xofftxc += IGC_READ_REG(&sc->hw, IGC_XOFFTXC); + sc->stats.fcruc += IGC_READ_REG(&sc->hw, IGC_FCRUC); + sc->stats.prc64 += IGC_READ_REG(&sc->hw, IGC_PRC64); + sc->stats.prc127 += IGC_READ_REG(&sc->hw, IGC_PRC127); + sc->stats.prc255 += IGC_READ_REG(&sc->hw, IGC_PRC255); + sc->stats.prc511 += IGC_READ_REG(&sc->hw, IGC_PRC511); + sc->stats.prc1023 += IGC_READ_REG(&sc->hw, IGC_PRC1023); + sc->stats.prc1522 += IGC_READ_REG(&sc->hw, IGC_PRC1522); + sc->stats.tlpic += IGC_READ_REG(&sc->hw, IGC_TLPIC); + sc->stats.rlpic += IGC_READ_REG(&sc->hw, IGC_RLPIC); + sc->stats.gprc += IGC_READ_REG(&sc->hw, IGC_GPRC); + sc->stats.bprc += IGC_READ_REG(&sc->hw, IGC_BPRC); + sc->stats.mprc += IGC_READ_REG(&sc->hw, IGC_MPRC); + sc->stats.gptc += IGC_READ_REG(&sc->hw, IGC_GPTC); /* For the 64-bit byte counters the low dword must be read first. */ /* Both registers clear on the read of the high dword */ - adapter->stats.gorc += IGC_READ_REG(&adapter->hw, IGC_GORCL) + - ((u64)IGC_READ_REG(&adapter->hw, IGC_GORCH) << 32); - adapter->stats.gotc += IGC_READ_REG(&adapter->hw, IGC_GOTCL) + - ((u64)IGC_READ_REG(&adapter->hw, IGC_GOTCH) << 32); - - adapter->stats.rnbc += IGC_READ_REG(&adapter->hw, IGC_RNBC); - adapter->stats.ruc += IGC_READ_REG(&adapter->hw, IGC_RUC); - adapter->stats.rfc += IGC_READ_REG(&adapter->hw, IGC_RFC); - adapter->stats.roc += IGC_READ_REG(&adapter->hw, IGC_ROC); - adapter->stats.rjc += IGC_READ_REG(&adapter->hw, IGC_RJC); - - adapter->stats.mgprc += IGC_READ_REG(&adapter->hw, IGC_MGTPRC); - adapter->stats.mgpdc += IGC_READ_REG(&adapter->hw, IGC_MGTPDC); - adapter->stats.mgptc += IGC_READ_REG(&adapter->hw, IGC_MGTPTC); - - adapter->stats.tor += IGC_READ_REG(&adapter->hw, IGC_TORH); - adapter->stats.tot += IGC_READ_REG(&adapter->hw, IGC_TOTH); - - adapter->stats.tpr += IGC_READ_REG(&adapter->hw, IGC_TPR); - adapter->stats.tpt += IGC_READ_REG(&adapter->hw, IGC_TPT); - adapter->stats.ptc64 += IGC_READ_REG(&adapter->hw, IGC_PTC64); - adapter->stats.ptc127 += IGC_READ_REG(&adapter->hw, IGC_PTC127); - adapter->stats.ptc255 += IGC_READ_REG(&adapter->hw, IGC_PTC255); - adapter->stats.ptc511 += IGC_READ_REG(&adapter->hw, IGC_PTC511); - adapter->stats.ptc1023 += IGC_READ_REG(&adapter->hw, IGC_PTC1023); - adapter->stats.ptc1522 += IGC_READ_REG(&adapter->hw, IGC_PTC1522); - adapter->stats.mptc += IGC_READ_REG(&adapter->hw, IGC_MPTC); - adapter->stats.bptc += IGC_READ_REG(&adapter->hw, IGC_BPTC); + sc->stats.gorc += IGC_READ_REG(&sc->hw, IGC_GORCL) + + ((u64)IGC_READ_REG(&sc->hw, IGC_GORCH) << 32); + sc->stats.gotc += IGC_READ_REG(&sc->hw, IGC_GOTCL) + + ((u64)IGC_READ_REG(&sc->hw, IGC_GOTCH) << 32); + + sc->stats.rnbc += IGC_READ_REG(&sc->hw, IGC_RNBC); + sc->stats.ruc += IGC_READ_REG(&sc->hw, IGC_RUC); + sc->stats.rfc += IGC_READ_REG(&sc->hw, IGC_RFC); + sc->stats.roc += IGC_READ_REG(&sc->hw, IGC_ROC); + sc->stats.rjc += IGC_READ_REG(&sc->hw, IGC_RJC); + + sc->stats.mgprc += IGC_READ_REG(&sc->hw, IGC_MGTPRC); + sc->stats.mgpdc += IGC_READ_REG(&sc->hw, IGC_MGTPDC); + sc->stats.mgptc += IGC_READ_REG(&sc->hw, IGC_MGTPTC); + + sc->stats.tor += IGC_READ_REG(&sc->hw, IGC_TORH); + sc->stats.tot += IGC_READ_REG(&sc->hw, IGC_TOTH); + + sc->stats.tpr += IGC_READ_REG(&sc->hw, IGC_TPR); + sc->stats.tpt += IGC_READ_REG(&sc->hw, IGC_TPT); + sc->stats.ptc64 += IGC_READ_REG(&sc->hw, IGC_PTC64); + sc->stats.ptc127 += IGC_READ_REG(&sc->hw, IGC_PTC127); + sc->stats.ptc255 += IGC_READ_REG(&sc->hw, IGC_PTC255); + sc->stats.ptc511 += IGC_READ_REG(&sc->hw, IGC_PTC511); + sc->stats.ptc1023 += IGC_READ_REG(&sc->hw, IGC_PTC1023); + sc->stats.ptc1522 += IGC_READ_REG(&sc->hw, IGC_PTC1522); + sc->stats.mptc += IGC_READ_REG(&sc->hw, IGC_MPTC); + sc->stats.bptc += IGC_READ_REG(&sc->hw, IGC_BPTC); /* Interrupt Counts */ - adapter->stats.iac += IGC_READ_REG(&adapter->hw, IGC_IAC); - adapter->stats.rxdmtc += IGC_READ_REG(&adapter->hw, IGC_RXDMTC); + sc->stats.iac += IGC_READ_REG(&sc->hw, IGC_IAC); + sc->stats.rxdmtc += IGC_READ_REG(&sc->hw, IGC_RXDMTC); - adapter->stats.algnerrc += IGC_READ_REG(&adapter->hw, IGC_ALGNERRC); - adapter->stats.tncrs += IGC_READ_REG(&adapter->hw, IGC_TNCRS); - adapter->stats.htdpmc += IGC_READ_REG(&adapter->hw, IGC_HTDPMC); - adapter->stats.tsctc += IGC_READ_REG(&adapter->hw, IGC_TSCTC); + sc->stats.algnerrc += IGC_READ_REG(&sc->hw, IGC_ALGNERRC); + sc->stats.tncrs += IGC_READ_REG(&sc->hw, IGC_TNCRS); + sc->stats.htdpmc += IGC_READ_REG(&sc->hw, IGC_HTDPMC); + sc->stats.tsctc += IGC_READ_REG(&sc->hw, IGC_TSCTC); } static uint64_t igc_if_get_counter(if_ctx_t ctx, ift_counter cnt) { - struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_softc *sc = iflib_get_softc(ctx); if_t ifp = iflib_get_ifp(ctx); switch (cnt) { case IFCOUNTER_COLLISIONS: - return (adapter->stats.colc); + return (sc->stats.colc); case IFCOUNTER_IERRORS: - return (adapter->dropped_pkts + adapter->stats.rxerrc + - adapter->stats.crcerrs + adapter->stats.algnerrc + - adapter->stats.ruc + adapter->stats.roc + - adapter->stats.mpc + adapter->stats.htdpmc); + return (sc->dropped_pkts + sc->stats.rxerrc + + sc->stats.crcerrs + sc->stats.algnerrc + + sc->stats.ruc + sc->stats.roc + + sc->stats.mpc + sc->stats.htdpmc); case IFCOUNTER_OERRORS: - return (adapter->stats.ecol + adapter->stats.latecol + - adapter->watchdog_events); + return (sc->stats.ecol + sc->stats.latecol + + sc->watchdog_events); default: return (if_get_counter_default(ifp, cnt)); } @@ -2563,11 +2563,11 @@ igc_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event) static int igc_sysctl_reg_handler(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *adapter; + struct igc_softc *sc; u_int val; - adapter = oidp->oid_arg1; - val = IGC_READ_REG(&adapter->hw, oidp->oid_arg2); + sc = oidp->oid_arg1; + val = IGC_READ_REG(&sc->hw, oidp->oid_arg2); return (sysctl_handle_int(oidp, &val, 0, req)); } @@ -2585,11 +2585,11 @@ igc_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS) if (tx) { tque = oidp->oid_arg1; - hw = &tque->adapter->hw; + hw = &tque->sc->hw; reg = IGC_READ_REG(hw, IGC_EITR(tque->me)); } else { rque = oidp->oid_arg1; - hw = &rque->adapter->hw; + hw = &rque->sc->hw; reg = IGC_READ_REG(hw, IGC_EITR(rque->msix)); } @@ -2609,16 +2609,16 @@ igc_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS) * Add sysctl variables, one per statistic, to the system. */ static void -igc_add_hw_stats(struct igc_adapter *adapter) +igc_add_hw_stats(struct igc_softc *sc) { - device_t dev = iflib_get_dev(adapter->ctx); - struct igc_tx_queue *tx_que = adapter->tx_queues; - struct igc_rx_queue *rx_que = adapter->rx_queues; + device_t dev = iflib_get_dev(sc->ctx); + struct igc_tx_queue *tx_que = sc->tx_queues; + struct igc_rx_queue *rx_que = sc->rx_queues; struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev); struct sysctl_oid *tree = device_get_sysctl_tree(dev); struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree); - struct igc_hw_stats *stats = &adapter->stats; + struct igc_hw_stats *stats = &sc->stats; struct sysctl_oid *stat_node, *queue_node, *int_node; struct sysctl_oid_list *stat_list, *queue_list, *int_list; @@ -2628,33 +2628,33 @@ igc_add_hw_stats(struct igc_adapter *adapter) /* Driver Statistics */ SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "dropped", - CTLFLAG_RD, &adapter->dropped_pkts, + CTLFLAG_RD, &sc->dropped_pkts, "Driver dropped packets"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "link_irq", - CTLFLAG_RD, &adapter->link_irq, + CTLFLAG_RD, &sc->link_irq, "Link MSI-X IRQ Handled"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "rx_overruns", - CTLFLAG_RD, &adapter->rx_overruns, + CTLFLAG_RD, &sc->rx_overruns, "RX overruns"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "watchdog_timeouts", - CTLFLAG_RD, &adapter->watchdog_events, + CTLFLAG_RD, &sc->watchdog_events, "Watchdog timeouts"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "device_control", CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, - adapter, IGC_CTRL, igc_sysctl_reg_handler, "IU", + sc, IGC_CTRL, igc_sysctl_reg_handler, "IU", "Device Control Register"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rx_control", CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, - adapter, IGC_RCTL, igc_sysctl_reg_handler, "IU", + sc, IGC_RCTL, igc_sysctl_reg_handler, "IU", "Receiver Control Register"); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "fc_high_water", - CTLFLAG_RD, &adapter->hw.fc.high_water, 0, + CTLFLAG_RD, &sc->hw.fc.high_water, 0, "Flow Control High Watermark"); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "fc_low_water", - CTLFLAG_RD, &adapter->hw.fc.low_water, 0, + CTLFLAG_RD, &sc->hw.fc.low_water, 0, "Flow Control Low Watermark"); - for (int i = 0; i < adapter->tx_num_queues; i++, tx_que++) { + for (int i = 0; i < sc->tx_num_queues; i++, tx_que++) { struct tx_ring *txr = &tx_que->txr; snprintf(namebuf, QUEUE_NAME_LEN, "queue_tx_%d", i); queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf, @@ -2666,11 +2666,11 @@ igc_add_hw_stats(struct igc_adapter *adapter) true, igc_sysctl_interrupt_rate_handler, "IU", "Interrupt Rate"); SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "txd_head", - CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, IGC_TDH(txr->me), igc_sysctl_reg_handler, "IU", "Transmit Descriptor Head"); SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "txd_tail", - CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, IGC_TDT(txr->me), igc_sysctl_reg_handler, "IU", "Transmit Descriptor Tail"); SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, "tx_irq", @@ -2678,7 +2678,7 @@ igc_add_hw_stats(struct igc_adapter *adapter) "Queue MSI-X Transmit Interrupts"); } - for (int j = 0; j < adapter->rx_num_queues; j++, rx_que++) { + for (int j = 0; j < sc->rx_num_queues; j++, rx_que++) { struct rx_ring *rxr = &rx_que->rxr; snprintf(namebuf, QUEUE_NAME_LEN, "queue_rx_%d", j); queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf, @@ -2690,11 +2690,11 @@ igc_add_hw_stats(struct igc_adapter *adapter) false, igc_sysctl_interrupt_rate_handler, "IU", "Interrupt Rate"); SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rxd_head", - CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, IGC_RDH(rxr->me), igc_sysctl_reg_handler, "IU", "Receive Descriptor Head"); SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rxd_tail", - CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, IGC_RDT(rxr->me), igc_sysctl_reg_handler, "IU", "Receive Descriptor Tail"); SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, "rx_irq", @@ -2724,140 +2724,140 @@ igc_add_hw_stats(struct igc_adapter *adapter) CTLFLAG_RD, &stats->colc, "Collision Count"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "symbol_errors", - CTLFLAG_RD, &adapter->stats.symerrs, + CTLFLAG_RD, &sc->stats.symerrs, "Symbol Errors"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "sequence_errors", - CTLFLAG_RD, &adapter->stats.sec, + CTLFLAG_RD, &sc->stats.sec, "Sequence Errors"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "defer_count", - CTLFLAG_RD, &adapter->stats.dc, + CTLFLAG_RD, &sc->stats.dc, "Defer Count"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "missed_packets", - CTLFLAG_RD, &adapter->stats.mpc, + CTLFLAG_RD, &sc->stats.mpc, "Missed Packets"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_length_errors", - CTLFLAG_RD, &adapter->stats.rlec, + CTLFLAG_RD, &sc->stats.rlec, "Receive Length Errors"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_no_buff", - CTLFLAG_RD, &adapter->stats.rnbc, + CTLFLAG_RD, &sc->stats.rnbc, "Receive No Buffers"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_undersize", - CTLFLAG_RD, &adapter->stats.ruc, + CTLFLAG_RD, &sc->stats.ruc, "Receive Undersize"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_fragmented", - CTLFLAG_RD, &adapter->stats.rfc, + CTLFLAG_RD, &sc->stats.rfc, "Fragmented Packets Received "); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_oversize", - CTLFLAG_RD, &adapter->stats.roc, + CTLFLAG_RD, &sc->stats.roc, "Oversized Packets Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_jabber", - CTLFLAG_RD, &adapter->stats.rjc, + CTLFLAG_RD, &sc->stats.rjc, "Recevied Jabber"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_errs", - CTLFLAG_RD, &adapter->stats.rxerrc, + CTLFLAG_RD, &sc->stats.rxerrc, "Receive Errors"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "crc_errs", - CTLFLAG_RD, &adapter->stats.crcerrs, + CTLFLAG_RD, &sc->stats.crcerrs, "CRC errors"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "alignment_errs", - CTLFLAG_RD, &adapter->stats.algnerrc, + CTLFLAG_RD, &sc->stats.algnerrc, "Alignment Errors"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "xon_recvd", - CTLFLAG_RD, &adapter->stats.xonrxc, + CTLFLAG_RD, &sc->stats.xonrxc, "XON Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "xon_txd", - CTLFLAG_RD, &adapter->stats.xontxc, + CTLFLAG_RD, &sc->stats.xontxc, "XON Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "xoff_recvd", - CTLFLAG_RD, &adapter->stats.xoffrxc, + CTLFLAG_RD, &sc->stats.xoffrxc, "XOFF Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "xoff_txd", - CTLFLAG_RD, &adapter->stats.xofftxc, + CTLFLAG_RD, &sc->stats.xofftxc, "XOFF Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "unsupported_fc_recvd", - CTLFLAG_RD, &adapter->stats.fcruc, + CTLFLAG_RD, &sc->stats.fcruc, "Unsupported Flow Control Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mgmt_pkts_recvd", - CTLFLAG_RD, &adapter->stats.mgprc, + CTLFLAG_RD, &sc->stats.mgprc, "Management Packets Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mgmt_pkts_drop", - CTLFLAG_RD, &adapter->stats.mgpdc, + CTLFLAG_RD, &sc->stats.mgpdc, "Management Packets Dropped"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mgmt_pkts_txd", - CTLFLAG_RD, &adapter->stats.mgptc, + CTLFLAG_RD, &sc->stats.mgptc, "Management Packets Transmitted"); /* Packet Reception Stats */ SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "total_pkts_recvd", - CTLFLAG_RD, &adapter->stats.tpr, + CTLFLAG_RD, &sc->stats.tpr, "Total Packets Received "); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_recvd", - CTLFLAG_RD, &adapter->stats.gprc, + CTLFLAG_RD, &sc->stats.gprc, "Good Packets Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_recvd", - CTLFLAG_RD, &adapter->stats.bprc, + CTLFLAG_RD, &sc->stats.bprc, "Broadcast Packets Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_recvd", - CTLFLAG_RD, &adapter->stats.mprc, + CTLFLAG_RD, &sc->stats.mprc, "Multicast Packets Received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rx_frames_64", - CTLFLAG_RD, &adapter->stats.prc64, + CTLFLAG_RD, &sc->stats.prc64, "64 byte frames received "); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rx_frames_65_127", - CTLFLAG_RD, &adapter->stats.prc127, + CTLFLAG_RD, &sc->stats.prc127, "65-127 byte frames received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rx_frames_128_255", - CTLFLAG_RD, &adapter->stats.prc255, + CTLFLAG_RD, &sc->stats.prc255, "128-255 byte frames received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rx_frames_256_511", - CTLFLAG_RD, &adapter->stats.prc511, + CTLFLAG_RD, &sc->stats.prc511, "256-511 byte frames received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rx_frames_512_1023", - CTLFLAG_RD, &adapter->stats.prc1023, + CTLFLAG_RD, &sc->stats.prc1023, "512-1023 byte frames received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rx_frames_1024_1522", - CTLFLAG_RD, &adapter->stats.prc1522, + CTLFLAG_RD, &sc->stats.prc1522, "1023-1522 byte frames received"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_recvd", - CTLFLAG_RD, &adapter->stats.gorc, + CTLFLAG_RD, &sc->stats.gorc, "Good Octets Received"); /* Packet Transmission Stats */ SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_txd", - CTLFLAG_RD, &adapter->stats.gotc, + CTLFLAG_RD, &sc->stats.gotc, "Good Octets Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "total_pkts_txd", - CTLFLAG_RD, &adapter->stats.tpt, + CTLFLAG_RD, &sc->stats.tpt, "Total Packets Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_txd", - CTLFLAG_RD, &adapter->stats.gptc, + CTLFLAG_RD, &sc->stats.gptc, "Good Packets Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_txd", - CTLFLAG_RD, &adapter->stats.bptc, + CTLFLAG_RD, &sc->stats.bptc, "Broadcast Packets Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_txd", - CTLFLAG_RD, &adapter->stats.mptc, + CTLFLAG_RD, &sc->stats.mptc, "Multicast Packets Transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tx_frames_64", - CTLFLAG_RD, &adapter->stats.ptc64, + CTLFLAG_RD, &sc->stats.ptc64, "64 byte frames transmitted "); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tx_frames_65_127", - CTLFLAG_RD, &adapter->stats.ptc127, + CTLFLAG_RD, &sc->stats.ptc127, "65-127 byte frames transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tx_frames_128_255", - CTLFLAG_RD, &adapter->stats.ptc255, + CTLFLAG_RD, &sc->stats.ptc255, "128-255 byte frames transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tx_frames_256_511", - CTLFLAG_RD, &adapter->stats.ptc511, + CTLFLAG_RD, &sc->stats.ptc511, "256-511 byte frames transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tx_frames_512_1023", - CTLFLAG_RD, &adapter->stats.ptc1023, + CTLFLAG_RD, &sc->stats.ptc1023, "512-1023 byte frames transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tx_frames_1024_1522", - CTLFLAG_RD, &adapter->stats.ptc1522, + CTLFLAG_RD, &sc->stats.ptc1522, "1024-1522 byte frames transmitted"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tso_txd", - CTLFLAG_RD, &adapter->stats.tsctc, + CTLFLAG_RD, &sc->stats.tsctc, "TSO Contexts Transmitted"); /* Interrupt Stats */ @@ -2867,16 +2867,16 @@ igc_add_hw_stats(struct igc_adapter *adapter) int_list = SYSCTL_CHILDREN(int_node); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "asserts", - CTLFLAG_RD, &adapter->stats.iac, + CTLFLAG_RD, &sc->stats.iac, "Interrupt Assertion Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "rx_desc_min_thresh", - CTLFLAG_RD, &adapter->stats.rxdmtc, + CTLFLAG_RD, &sc->stats.rxdmtc, "Rx Desc Min Thresh Count"); } static void -igc_fw_version(struct igc_adapter *sc) +igc_fw_version(struct igc_softc *sc) { struct igc_hw *hw = &sc->hw; struct igc_fw_version *fw_ver = &sc->fw_ver; @@ -2916,7 +2916,7 @@ igc_sbuf_fw_version(struct igc_fw_version *fw_ver, struct sbuf *buf) } static void -igc_print_fw_version(struct igc_adapter *sc ) +igc_print_fw_version(struct igc_softc *sc ) { device_t dev = sc->dev; struct sbuf *buf; @@ -2942,7 +2942,7 @@ igc_print_fw_version(struct igc_adapter *sc ) static int igc_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *sc = (struct igc_adapter *)arg1; + struct igc_softc *sc = (struct igc_softc *)arg1; device_t dev = sc->dev; struct sbuf *buf; int error = 0; @@ -2974,7 +2974,7 @@ igc_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS) static int igc_sysctl_nvm_info(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *adapter = (struct igc_adapter *)arg1; + struct igc_softc *sc = (struct igc_softc *)arg1; int error; int result; @@ -2990,13 +2990,13 @@ igc_sysctl_nvm_info(SYSCTL_HANDLER_ARGS) * the screen. */ if (result == 1) - igc_print_nvm_info(adapter); + igc_print_nvm_info(sc); return (error); } static void -igc_print_nvm_info(struct igc_adapter *adapter) +igc_print_nvm_info(struct igc_softc *sc) { u16 eeprom_data; int i, j, row = 0; @@ -3009,7 +3009,7 @@ igc_print_nvm_info(struct igc_adapter *adapter) j = 0; ++row; printf("\n0x00%x0 ",row); } - igc_read_nvm(&adapter->hw, i, 1, &eeprom_data); + igc_read_nvm(&sc->hw, i, 1, &eeprom_data); printf("%04x ", eeprom_data); } printf("\n"); @@ -3028,14 +3028,14 @@ igc_set_flowcntl(SYSCTL_HANDLER_ARGS) { int error; static int input = 3; /* default is full */ - struct igc_adapter *adapter = (struct igc_adapter *) arg1; + struct igc_softc *sc = (struct igc_softc *) arg1; error = sysctl_handle_int(oidp, &input, 0, req); if ((error) || (req->newptr == NULL)) return (error); - if (input == adapter->fc) /* no change? */ + if (input == sc->fc) /* no change? */ return (error); switch (input) { @@ -3043,16 +3043,16 @@ igc_set_flowcntl(SYSCTL_HANDLER_ARGS) case igc_fc_tx_pause: case igc_fc_full: case igc_fc_none: - adapter->hw.fc.requested_mode = input; - adapter->fc = input; + sc->hw.fc.requested_mode = input; + sc->fc = input; break; default: /* Do nothing */ return (error); } - adapter->hw.fc.current_mode = adapter->hw.fc.requested_mode; - igc_force_mac_fc(&adapter->hw); + sc->hw.fc.current_mode = sc->hw.fc.requested_mode; + igc_force_mac_fc(&sc->hw); return (error); } @@ -3066,7 +3066,7 @@ igc_set_flowcntl(SYSCTL_HANDLER_ARGS) static int igc_sysctl_dmac(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *sc = (struct igc_adapter *) arg1; + struct igc_softc *sc = (struct igc_softc *) arg1; int error; error = sysctl_handle_int(oidp, &sc->dmac, 0, req); @@ -3113,16 +3113,16 @@ igc_sysctl_dmac(SYSCTL_HANDLER_ARGS) static int igc_sysctl_eee(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *adapter = (struct igc_adapter *) arg1; + struct igc_softc *sc = (struct igc_softc *) arg1; int error, value; - value = adapter->hw.dev_spec._i225.eee_disable; + value = sc->hw.dev_spec._i225.eee_disable; error = sysctl_handle_int(oidp, &value, 0, req); if (error || req->newptr == NULL) return (error); - adapter->hw.dev_spec._i225.eee_disable = (value != 0); - igc_if_init(adapter->ctx); + sc->hw.dev_spec._i225.eee_disable = (value != 0); + igc_if_init(sc->ctx); return (0); } @@ -3130,7 +3130,7 @@ igc_sysctl_eee(SYSCTL_HANDLER_ARGS) static int igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *adapter; + struct igc_softc *sc; int error; int result; @@ -3141,8 +3141,8 @@ igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS) return (error); if (result == 1) { - adapter = (struct igc_adapter *) arg1; - igc_print_debug_info(adapter); + sc = (struct igc_softc *) arg1; + igc_print_debug_info(sc); } return (error); @@ -3151,7 +3151,7 @@ igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS) static int igc_get_rs(SYSCTL_HANDLER_ARGS) { - struct igc_adapter *adapter = (struct igc_adapter *) arg1; + struct igc_softc *sc = (struct igc_softc *) arg1; int error; int result; @@ -3160,7 +3160,7 @@ igc_get_rs(SYSCTL_HANDLER_ARGS) if (error || !req->newptr || result != 1) return (error); - igc_dump_rs(adapter); + igc_dump_rs(sc); return (error); } @@ -3176,12 +3176,12 @@ igc_if_debug(if_ctx_t ctx) * needed for debugging a problem. -jfv */ static void -igc_print_debug_info(struct igc_adapter *adapter) +igc_print_debug_info(struct igc_softc *sc) { - device_t dev = iflib_get_dev(adapter->ctx); - if_t ifp = iflib_get_ifp(adapter->ctx); - struct tx_ring *txr = &adapter->tx_queues->txr; - struct rx_ring *rxr = &adapter->rx_queues->rxr; + device_t dev = iflib_get_dev(sc->ctx); + if_t ifp = iflib_get_ifp(sc->ctx); + struct tx_ring *txr = &sc->tx_queues->txr; + struct rx_ring *rxr = &sc->rx_queues->rxr; if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) printf("Interface is RUNNING "); @@ -3193,17 +3193,17 @@ igc_print_debug_info(struct igc_adapter *adapter) else printf("and ACTIVE\n"); - for (int i = 0; i < adapter->tx_num_queues; i++, txr++) { + for (int i = 0; i < sc->tx_num_queues; i++, txr++) { device_printf(dev, "TX Queue %d ------\n", i); device_printf(dev, "hw tdh = %d, hw tdt = %d\n", - IGC_READ_REG(&adapter->hw, IGC_TDH(i)), - IGC_READ_REG(&adapter->hw, IGC_TDT(i))); + IGC_READ_REG(&sc->hw, IGC_TDH(i)), + IGC_READ_REG(&sc->hw, IGC_TDT(i))); } - for (int j=0; j < adapter->rx_num_queues; j++, rxr++) { + for (int j=0; j < sc->rx_num_queues; j++, rxr++) { device_printf(dev, "RX Queue %d ------\n", j); device_printf(dev, "hw rdh = %d, hw rdt = %d\n", - IGC_READ_REG(&adapter->hw, IGC_RDH(j)), - IGC_READ_REG(&adapter->hw, IGC_RDT(j))); + IGC_READ_REG(&sc->hw, IGC_RDH(j)), + IGC_READ_REG(&sc->hw, IGC_RDT(j))); } } diff --git a/sys/dev/igc/if_igc.h b/sys/dev/igc/if_igc.h index 94e41104f28e..236a16c4add3 100644 --- a/sys/dev/igc/if_igc.h +++ b/sys/dev/igc/if_igc.h @@ -206,10 +206,10 @@ CSUM_IP_SCTP | CSUM_IP6_UDP | CSUM_IP6_TCP | \ CSUM_IP6_SCTP) /* Offload bits in mbuf flag */ -struct igc_adapter; +struct igc_softc; struct igc_int_delay_info { - struct igc_adapter *adapter; /* Back-pointer to the adapter struct */ + struct igc_softc *sc; /* Back-pointer to the softc struct */ int offset; /* Register offset to read/write */ int value; /* Current value in usecs */ }; @@ -218,9 +218,9 @@ struct igc_int_delay_info { * The transmit ring, one per tx queue */ struct tx_ring { - struct igc_adapter *adapter; + struct igc_softc *sc; struct igc_tx_desc *tx_base; - uint64_t tx_paddr; + uint64_t tx_paddr; qidx_t *tx_rsq; uint8_t me; qidx_t tx_rs_cidx; @@ -253,7 +253,7 @@ struct tx_ring { * The Receive ring, one per rx queue */ struct rx_ring { - struct igc_adapter *adapter; + struct igc_softc *sc; struct igc_rx_queue *que; u32 me; u32 payload; @@ -275,15 +275,15 @@ struct rx_ring { }; struct igc_tx_queue { - struct igc_adapter *adapter; - u32 msix; - u32 eims; /* This queue's EIMS bit */ - u32 me; - struct tx_ring txr; + struct igc_softc *sc; + u32 msix; + u32 eims; /* This queue's EIMS bit */ + u32 me; + struct tx_ring txr; }; struct igc_rx_queue { - struct igc_adapter *adapter; + struct igc_softc *sc; u32 me; u32 msix; u32 eims; @@ -293,8 +293,8 @@ struct igc_rx_queue { struct if_irq que_irq; }; -/* Our adapter structure */ -struct igc_adapter { +/* Our softc structure */ +struct igc_softc { if_t ifp; struct igc_hw hw; @@ -373,7 +373,7 @@ struct igc_adapter { u16 vf_ifp; }; -void igc_dump_rs(struct igc_adapter *); +void igc_dump_rs(struct igc_softc *); #define IGC_RSSRK_SIZE 4 #define IGC_RSSRK_VAL(key, i) (key[(i) * IGC_RSSRK_SIZE] | \ diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c index cd7175f45f34..a95b34702e24 100644 --- a/sys/dev/igc/igc_txrx.c +++ b/sys/dev/igc/igc_txrx.c @@ -80,9 +80,9 @@ struct if_txrx igc_txrx = { }; void -igc_dump_rs(struct igc_adapter *adapter) +igc_dump_rs(struct igc_softc *sc) { - if_softc_ctx_t scctx = adapter->shared; + if_softc_ctx_t scctx = sc->shared; struct igc_tx_queue *que; struct tx_ring *txr; qidx_t i, ntxd, qid, cur; @@ -91,8 +91,8 @@ igc_dump_rs(struct igc_adapter *adapter) printf("\n"); ntxd = scctx->isc_ntxd[0]; - for (qid = 0; qid < adapter->tx_num_queues; qid++) { - que = &adapter->tx_queues[qid]; + for (qid = 0; qid < sc->tx_num_queues; qid++) { + que = &sc->tx_queues[qid]; txr = &que->txr; rs_cidx = txr->tx_rs_cidx; if (rs_cidx != txr->tx_rs_pidx) { @@ -263,7 +263,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len, static int igc_isc_txd_encap(void *arg, if_pkt_info_t pi) { - struct igc_adapter *sc = arg; + struct igc_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct igc_tx_queue *que = &sc->tx_queues[pi->ipi_qsidx]; struct tx_ring *txr = &que->txr; @@ -326,19 +326,19 @@ igc_isc_txd_encap(void *arg, if_pkt_info_t pi) static void igc_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx) { - struct igc_adapter *adapter = arg; - struct igc_tx_queue *que = &adapter->tx_queues[txqid]; + struct igc_softc *sc = arg; + struct igc_tx_queue *que = &sc->tx_queues[txqid]; struct tx_ring *txr = &que->txr; - IGC_WRITE_REG(&adapter->hw, IGC_TDT(txr->me), pidx); + IGC_WRITE_REG(&sc->hw, IGC_TDT(txr->me), pidx); } static int igc_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear) { - struct igc_adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct igc_tx_queue *que = &adapter->tx_queues[txqid]; + struct igc_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct igc_tx_queue *que = &sc->tx_queues[txqid]; struct tx_ring *txr = &que->txr; qidx_t processed = 0; @@ -388,7 +388,7 @@ igc_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear) static void igc_isc_rxd_refill(void *arg, if_rxd_update_t iru) { - struct igc_adapter *sc = arg; + struct igc_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; uint16_t rxqid = iru->iru_qsidx; struct igc_rx_queue *que = &sc->rx_queues[rxqid]; @@ -415,7 +415,7 @@ igc_isc_rxd_refill(void *arg, if_rxd_update_t iru) static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx) { - struct igc_adapter *sc = arg; + struct igc_softc *sc = arg; struct igc_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -425,7 +425,7 @@ igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx) static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) { - struct igc_adapter *sc = arg; + struct igc_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct igc_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -457,9 +457,9 @@ igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) static int igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) { - struct igc_adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct igc_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx]; + struct igc_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct igc_rx_queue *que = &sc->rx_queues[ri->iri_qsidx]; struct rx_ring *rxr = &que->rxr; union igc_adv_rx_desc *rxd; @@ -489,7 +489,7 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) /* Make sure bad packets are discarded */ if (eop && ((staterr & IGC_RXDEXT_STATERR_RXE) != 0)) { - adapter->dropped_pkts++; + sc->dropped_pkts++; ++rxr->rx_discarded; return (EBADMSG); } |