diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c --- a/sys/dev/e1000/em_txrx.c +++ b/sys/dev/e1000/em_txrx.c @@ -42,9 +42,9 @@ /********************************************************************* * Local Function prototypes *********************************************************************/ -static int em_tso_setup(struct adapter *adapter, if_pkt_info_t pi, u32 *txd_upper, +static int em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, u32 *txd_upper, u32 *txd_lower); -static int em_transmit_checksum_setup(struct adapter *adapter, if_pkt_info_t pi, +static int em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi, u32 *txd_upper, u32 *txd_lower); static int em_isc_txd_encap(void *arg, if_pkt_info_t pi); static void em_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx); @@ -91,9 +91,9 @@ extern if_shared_ctx_t em_sctx; void -em_dump_rs(struct adapter *adapter) +em_dump_rs(struct e1000_softc *sc) { - if_softc_ctx_t scctx = adapter->shared; + if_softc_ctx_t scctx = sc->shared; struct em_tx_queue *que; struct tx_ring *txr; qidx_t i, ntxd, qid, cur; @@ -102,8 +102,8 @@ 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) { @@ -132,10 +132,10 @@ * **********************************************************************/ static int -em_tso_setup(struct adapter *adapter, if_pkt_info_t pi, u32 *txd_upper, u32 *txd_lower) +em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, u32 *txd_upper, u32 *txd_lower) { - if_softc_ctx_t scctx = adapter->shared; - struct em_tx_queue *que = &adapter->tx_queues[pi->ipi_qsidx]; + if_softc_ctx_t scctx = sc->shared; + struct em_tx_queue *que = &sc->tx_queues[pi->ipi_qsidx]; struct tx_ring *txr = &que->txr; struct e1000_context_desc *TXD; int cur, hdr_len; @@ -178,7 +178,7 @@ TXD->tcp_seg_setup.fields.mss = htole16(pi->ipi_tso_segsz); TXD->tcp_seg_setup.fields.hdr_len = hdr_len; - TXD->cmd_and_length = htole32(adapter->txd_cmd | + TXD->cmd_and_length = htole32(sc->txd_cmd | E1000_TXD_CMD_DEXT | /* Extended descr */ E1000_TXD_CMD_TSE | /* TSE context */ E1000_TXD_CMD_IP | /* Do IP csum */ @@ -189,7 +189,7 @@ if (++cur == scctx->isc_ntxd[0]) { cur = 0; } - DPRINTF(iflib_get_dev(adapter->ctx), "%s: pidx: %d cur: %d\n", __FUNCTION__, pi->ipi_pidx, cur); + DPRINTF(iflib_get_dev(sc->ctx), "%s: pidx: %d cur: %d\n", __FUNCTION__, pi->ipi_pidx, cur); return (cur); } @@ -215,11 +215,11 @@ **********************************************************************/ static int -em_transmit_checksum_setup(struct adapter *adapter, if_pkt_info_t pi, u32 *txd_upper, u32 *txd_lower) +em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi, u32 *txd_upper, u32 *txd_lower) { struct e1000_context_desc *TXD = NULL; - if_softc_ctx_t scctx = adapter->shared; - struct em_tx_queue *que = &adapter->tx_queues[pi->ipi_qsidx]; + if_softc_ctx_t scctx = sc->shared; + struct em_tx_queue *que = &sc->tx_queues[pi->ipi_qsidx]; struct tx_ring *txr = &que->txr; int csum_flags = pi->ipi_csum_flags; int cur, hdr_len; @@ -227,7 +227,7 @@ cur = pi->ipi_pidx; hdr_len = pi->ipi_ehdrlen + pi->ipi_ip_hlen; - cmd = adapter->txd_cmd; + cmd = sc->txd_cmd; /* * The 82574L can only remember the *last* context used @@ -237,7 +237,7 @@ * second note. */ if (DONT_FORCE_CTX && - adapter->tx_num_queues == 1 && + sc->tx_num_queues == 1 && txr->csum_lhlen == pi->ipi_ehdrlen && txr->csum_iphlen == pi->ipi_ip_hlen && txr->csum_flags == csum_flags) { @@ -293,7 +293,7 @@ if (++cur == scctx->isc_ntxd[0]) { cur = 0; } - DPRINTF(iflib_get_dev(adapter->ctx), "checksum_setup csum_flags=%x txd_upper=%x txd_lower=%x hdr_len=%d cmd=%x\n", + DPRINTF(iflib_get_dev(sc->ctx), "checksum_setup csum_flags=%x txd_upper=%x txd_lower=%x hdr_len=%d cmd=%x\n", csum_flags, *txd_upper, *txd_lower, hdr_len, cmd); return (cur); } @@ -301,7 +301,7 @@ static int em_isc_txd_encap(void *arg, if_pkt_info_t pi) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct em_tx_queue *que = &sc->tx_queues[pi->ipi_qsidx]; struct tx_ring *txr = &que->txr; @@ -348,7 +348,7 @@ } DPRINTF(iflib_get_dev(sc->ctx), "encap: set up tx: nsegs=%d first=%d i=%d\n", nsegs, first, i); - /* XXX adapter->pcix_82544 -- lem_fill_descriptors */ + /* XXX sc->pcix_82544 -- lem_fill_descriptors */ /* Set up our transmit descriptors */ for (j = 0; j < nsegs; j++) { @@ -416,19 +416,19 @@ static void em_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx) { - struct adapter *adapter = arg; - struct em_tx_queue *que = &adapter->tx_queues[txqid]; + struct e1000_softc *sc = arg; + struct em_tx_queue *que = &sc->tx_queues[txqid]; struct tx_ring *txr = &que->txr; - E1000_WRITE_REG(&adapter->hw, E1000_TDT(txr->me), pidx); + E1000_WRITE_REG(&sc->hw, E1000_TDT(txr->me), pidx); } static int em_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear) { - struct adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct em_tx_queue *que = &adapter->tx_queues[txqid]; + struct e1000_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct em_tx_queue *que = &sc->tx_queues[txqid]; struct tx_ring *txr = &que->txr; qidx_t processed = 0; @@ -461,7 +461,7 @@ if (delta < 0) delta += ntxd; MPASS(delta > 0); - DPRINTF(iflib_get_dev(adapter->ctx), + DPRINTF(iflib_get_dev(sc->ctx), "%s: cidx_processed=%u cur=%u clear=%d delta=%d\n", __FUNCTION__, prev, cur, clear, delta); @@ -483,7 +483,7 @@ static void lem_isc_rxd_refill(void *arg, if_rxd_update_t iru) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct em_rx_queue *que = &sc->rx_queues[iru->iru_qsidx]; struct rx_ring *rxr = &que->rxr; @@ -511,7 +511,7 @@ static void em_isc_rxd_refill(void *arg, if_rxd_update_t iru) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; uint16_t rxqid = iru->iru_qsidx; struct em_rx_queue *que = &sc->rx_queues[rxqid]; @@ -540,7 +540,7 @@ static void em_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; struct em_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -550,7 +550,7 @@ static int lem_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct em_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -575,7 +575,7 @@ static int em_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct em_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -600,9 +600,9 @@ static int lem_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) { - struct adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct em_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx]; + struct e1000_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct em_rx_queue *que = &sc->rx_queues[ri->iri_qsidx]; struct rx_ring *rxr = &que->rxr; struct e1000_rx_desc *rxd; u16 len; @@ -628,7 +628,7 @@ /* Make sure bad packets are discarded */ if (errors & E1000_RXD_ERR_FRAME_ERR_MASK) { - adapter->dropped_pkts++; + sc->dropped_pkts++; /* XXX fixup if common */ return (EBADMSG); } @@ -645,7 +645,7 @@ } while (!eop); /* XXX add a faster way to look this up */ - if (adapter->hw.mac.type >= e1000_82543) + if (sc->hw.mac.type >= e1000_82543) em_receive_checksum(status, errors, ri); if (status & E1000_RXD_STAT_VP) { @@ -661,9 +661,9 @@ static int em_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) { - struct adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct em_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx]; + struct e1000_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct em_rx_queue *que = &sc->rx_queues[ri->iri_qsidx]; struct rx_ring *rxr = &que->rxr; union e1000_rx_desc_extended *rxd; @@ -691,7 +691,7 @@ /* Make sure bad packets are discarded */ if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) { - adapter->dropped_pkts++; + sc->dropped_pkts++; return EBADMSG; } diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -27,6 +27,10 @@ */ /*$FreeBSD$*/ + +#ifndef _EM_H_DEFINED_ +#define _EM_H_DEFINED_ + #include "opt_ddb.h" #include "opt_inet.h" #include "opt_inet6.h" @@ -42,9 +46,7 @@ #include #include #endif -#if __FreeBSD_version >= 800000 #include -#endif #include #include #include @@ -95,11 +97,6 @@ #include "e1000_82571.h" #include "ifdi_if.h" - -#ifndef _EM_H_DEFINED_ -#define _EM_H_DEFINED_ - - /* Tunables */ /* @@ -114,11 +111,11 @@ * desscriptors should meet the following condition. * (num_tx_desc * sizeof(struct e1000_tx_desc)) % 128 == 0 */ -#define EM_MIN_TXD 128 -#define EM_MAX_TXD 4096 -#define EM_DEFAULT_TXD 1024 +#define EM_MIN_TXD 128 +#define EM_MAX_TXD 4096 +#define EM_DEFAULT_TXD 1024 #define EM_DEFAULT_MULTI_TXD 4096 -#define IGB_MAX_TXD 4096 +#define IGB_MAX_TXD 4096 /* * EM_MAX_RXD - Maximum number of receive Descriptors @@ -133,11 +130,11 @@ * desscriptors should meet the following condition. * (num_tx_desc * sizeof(struct e1000_tx_desc)) % 128 == 0 */ -#define EM_MIN_RXD 128 -#define EM_MAX_RXD 4096 -#define EM_DEFAULT_RXD 1024 +#define EM_MIN_RXD 128 +#define EM_MAX_RXD 4096 +#define EM_DEFAULT_RXD 1024 #define EM_DEFAULT_MULTI_RXD 4096 -#define IGB_MAX_RXD 4096 +#define IGB_MAX_RXD 4096 /* * EM_TIDV - Transmit Interrupt Delay Value @@ -149,7 +146,7 @@ * system is reporting dropped transmits, this value may be set too high * causing the driver to run out of available transmit descriptors. */ -#define EM_TIDV 64 +#define EM_TIDV 64 /* * EM_TADV - Transmit Absolute Interrupt Delay Value @@ -163,7 +160,7 @@ * along with EM_TIDV, may improve traffic throughput in specific * network conditions. */ -#define EM_TADV 64 +#define EM_TADV 64 /* * EM_RDTR - Receive Interrupt Delay Timer (Packet Timer) @@ -184,7 +181,7 @@ * restoring the network connection. To eliminate the potential * for the hang ensure that EM_RDTR is set to 0. */ -#define EM_RDTR 0 +#define EM_RDTR 0 /* * Receive Interrupt Absolute Delay Timer (Not valid for 82542/82543/82544) @@ -197,14 +194,14 @@ * along with EM_RDTR, may improve traffic throughput in specific network * conditions. */ -#define EM_RADV 64 +#define EM_RADV 64 /* * This parameter controls whether or not autonegotation is enabled. * 0 - Disable autonegotiation * 1 - Enable autonegotiation */ -#define DO_AUTO_NEG 1 +#define DO_AUTO_NEG 1 /* * This parameter control whether or not the driver will wait for @@ -212,13 +209,13 @@ * 1 - Wait for autonegotiation to complete * 0 - Don't wait for autonegotiation to complete */ -#define WAIT_FOR_AUTO_NEG_DEFAULT 0 +#define WAIT_FOR_AUTO_NEG_DEFAULT 0 /* Tunables -- End */ #define AUTONEG_ADV_DEFAULT (ADVERTISE_10_HALF | ADVERTISE_10_FULL | \ - ADVERTISE_100_HALF | ADVERTISE_100_FULL | \ - ADVERTISE_1000_FULL) + ADVERTISE_100_HALF | ADVERTISE_100_FULL | \ + ADVERTISE_1000_FULL) #define AUTO_ALL_MODES 0 @@ -226,38 +223,37 @@ #define EM_MASTER_SLAVE e1000_ms_hw_default /* - * Micellaneous constants + * Miscellaneous constants */ -#define EM_VENDOR_ID 0x8086 -#define EM_FLASH 0x0014 - -#define EM_JUMBO_PBA 0x00000028 -#define EM_DEFAULT_PBA 0x00000030 -#define EM_SMARTSPEED_DOWNSHIFT 3 -#define EM_SMARTSPEED_MAX 15 -#define EM_MAX_LOOP 10 - -#define MAX_NUM_MULTICAST_ADDRESSES 128 -#define PCI_ANY_ID (~0U) -#define ETHER_ALIGN 2 -#define EM_FC_PAUSE_TIME 0x0680 -#define EM_EEPROM_APME 0x400; -#define EM_82544_APME 0x0004; - +#define EM_VENDOR_ID 0x8086 +#define EM_FLASH 0x0014 + +#define EM_JUMBO_PBA 0x00000028 +#define EM_DEFAULT_PBA 0x00000030 +#define EM_SMARTSPEED_DOWNSHIFT 3 +#define EM_SMARTSPEED_MAX 15 +#define EM_MAX_LOOP 10 + +#define MAX_NUM_MULTICAST_ADDRESSES 128 +#define PCI_ANY_ID (~0U) +#define ETHER_ALIGN 2 +#define EM_FC_PAUSE_TIME 0x0680 +#define EM_EEPROM_APME 0x400; +#define EM_82544_APME 0x0004; /* Support AutoMediaDetect for Marvell M88 PHY in i354 */ #define IGB_MEDIA_RESET (1 << 0) /* Define the starting Interrupt rate per Queue */ -#define IGB_INTS_PER_SEC 8000 -#define IGB_DEFAULT_ITR ((1000000/IGB_INTS_PER_SEC) << 2) +#define IGB_INTS_PER_SEC 8000 +#define IGB_DEFAULT_ITR ((1000000/IGB_INTS_PER_SEC) << 2) -#define IGB_LINK_ITR 2000 -#define I210_LINK_DELAY 1000 +#define IGB_LINK_ITR 2000 +#define I210_LINK_DELAY 1000 -#define IGB_TXPBSIZE 20408 -#define IGB_HDR_BUF 128 -#define IGB_PKTTYPE_MASK 0x0000FFF0 +#define IGB_TXPBSIZE 20408 +#define IGB_HDR_BUF 128 +#define IGB_PKTTYPE_MASK 0x0000FFF0 #define IGB_DMCTLX_DCFLUSH_DIS 0x80000000 /* Disable DMA Coalesce Flush */ /* @@ -272,22 +268,22 @@ #define EM_TX_IDLE 0x00000000 #define EM_TX_BUSY 0x00000001 #define EM_TX_HUNG 0x80000000 -#define EM_TX_MAXTRIES 10 +#define EM_TX_MAXTRIES 10 #define PCICFG_DESC_RING_STATUS 0xe4 -#define FLUSH_DESC_REQUIRED 0x100 +#define FLUSH_DESC_REQUIRED 0x100 #define IGB_RX_PTHRESH ((hw->mac.type == e1000_i354) ? 12 : \ - ((hw->mac.type <= e1000_82576) ? 16 : 8)) + ((hw->mac.type <= e1000_82576) ? 16 : 8)) #define IGB_RX_HTHRESH 8 #define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \ - (adapter->intr_type == IFLIB_INTR_MSIX)) ? 1 : 4) + (sc->intr_type == IFLIB_INTR_MSIX)) ? 1 : 4) #define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8) #define IGB_TX_HTHRESH 1 #define IGB_TX_WTHRESH ((hw->mac.type != e1000_82575 && \ - (adapter->intr_type == IFLIB_INTR_MSIX) ? 1 : 16) + sc->intr_type == IFLIB_INTR_MSIX) ? 1 : 16) /* * TDBA/RDBA should be aligned on 16 byte boundary. But TDLEN/RDLEN should be @@ -301,10 +297,10 @@ */ #define TARC_COMPENSATION_MODE (1 << 7) /* Compensation Mode */ #define TARC_SPEED_MODE_BIT (1 << 21) /* On PCI-E MACs only */ -#define TARC_MQ_FIX (1 << 23) | \ - (1 << 24) | \ - (1 << 25) /* Handle errata in MQ mode */ -#define TARC_ERRATA_BIT (1 << 26) /* Note from errata on 82574 */ +#define TARC_MQ_FIX (1 << 23) | \ + (1 << 24) | \ + (1 << 25) /* Handle errata in MQ mode */ +#define TARC_ERRATA_BIT (1 << 26) /* Note from errata on 82574 */ /* PCI Config defines */ #define EM_BAR_TYPE(v) ((v) & EM_BAR_TYPE_MASK) @@ -317,38 +313,32 @@ #define EM_BAR_MEM_TYPE_32BIT 0x00000000 #define EM_BAR_MEM_TYPE_64BIT 0x00000004 -/* More backward compatibility */ -#if __FreeBSD_version < 900000 -#define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD -#endif - /* Defines for printing debug information */ -#define DEBUG_INIT 0 -#define DEBUG_IOCTL 0 -#define DEBUG_HW 0 - -#define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n") -#define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A) -#define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B) -#define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n") -#define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A) -#define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B) -#define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n") -#define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A) -#define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B) +#define DEBUG_INIT 0 +#define DEBUG_IOCTL 0 +#define DEBUG_HW 0 + +#define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n") +#define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A) +#define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B) +#define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n") +#define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A) +#define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B) +#define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n") +#define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A) +#define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B) #define EM_MAX_SCATTER 40 #define EM_VFTA_SIZE 128 -#define EM_TSO_SIZE 65535 +#define EM_TSO_SIZE 65535 #define EM_TSO_SEG_SIZE 4096 /* Max dma segment size */ -#define ETH_ZLEN 60 +#define ETH_ZLEN 60 #define EM_CSUM_OFFLOAD (CSUM_IP | CSUM_IP_UDP | CSUM_IP_TCP) /* Offload bits in mbuf flag */ #define IGB_CSUM_OFFLOAD (CSUM_IP | CSUM_IP_UDP | CSUM_IP_TCP | \ - CSUM_IP_SCTP | CSUM_IP6_UDP | CSUM_IP6_TCP | \ - CSUM_IP6_SCTP) /* Offload bits in mbuf flag */ - + CSUM_IP_SCTP | CSUM_IP6_UDP | CSUM_IP6_TCP | \ + CSUM_IP6_SCTP) /* Offload bits in mbuf flag */ -#define IGB_PKTTYPE_MASK 0x0000FFF0 +#define IGB_PKTTYPE_MASK 0x0000FFF0 #define IGB_DMCTLX_DCFLUSH_DIS 0x80000000 /* Disable DMA Coalesce Flush */ /* @@ -357,7 +347,7 @@ * the em driver only 82574 uses MSI-X we can * solve it just using this define. */ -#define EM_EIAC 0x000DC +#define EM_EIAC 0x000DC /* * 82574 only reports 3 MSI-X vectors by default; * defines assisting with making it report 5 are @@ -367,21 +357,21 @@ #define EM_NVM_MSIX_N_MASK (0x7 << EM_NVM_MSIX_N_SHIFT) #define EM_NVM_MSIX_N_SHIFT 7 -struct adapter; +struct e1000_softc; struct em_int_delay_info { - struct adapter *adapter; /* Back-pointer to the adapter struct */ - int offset; /* Register offset to read/write */ - int value; /* Current value in usecs */ + struct e1000_softc *sc; /* Back-pointer to the sc struct */ + int offset; /* Register offset to read/write */ + int value; /* Current value in usecs */ }; /* * The transmit ring, one per tx queue */ struct tx_ring { - struct adapter *adapter; + struct e1000_softc *sc; struct e1000_tx_desc *tx_base; - uint64_t tx_paddr; + uint64_t tx_paddr; qidx_t *tx_rsq; bool tx_tso; /* last tx was tso */ uint8_t me; @@ -389,9 +379,9 @@ qidx_t tx_rs_pidx; qidx_t tx_cidx_processed; /* Interrupt resources */ - void *tag; - struct resource *res; - unsigned long tx_irq; + void *tag; + struct resource *res; + unsigned long tx_irq; /* Saved csum offloading context information */ int csum_flags; @@ -403,100 +393,100 @@ int csum_pktlen; uint32_t csum_txd_upper; - uint32_t csum_txd_lower; /* last field */ + uint32_t csum_txd_lower; /* last field */ }; /* * The Receive ring, one per rx queue */ struct rx_ring { - struct adapter *adapter; - struct em_rx_queue *que; - u32 me; - u32 payload; - union e1000_rx_desc_extended *rx_base; - uint64_t rx_paddr; - - /* Interrupt resources */ - void *tag; - struct resource *res; + struct e1000_softc *sc; + struct em_rx_queue *que; + u32 me; + u32 payload; + union e1000_rx_desc_extended *rx_base; + uint64_t rx_paddr; + + /* Interrupt resources */ + void *tag; + struct resource *res; bool discard; - /* Soft stats */ - unsigned long rx_irq; - unsigned long rx_discarded; - unsigned long rx_packets; - unsigned long rx_bytes; + /* Soft stats */ + unsigned long rx_irq; + unsigned long rx_discarded; + unsigned long rx_packets; + unsigned long rx_bytes; }; struct em_tx_queue { - struct adapter *adapter; - u32 msix; - u32 eims; /* This queue's EIMS bit */ - u32 me; - struct tx_ring txr; + struct e1000_softc *sc; + u32 msix; + u32 eims; /* This queue's EIMS bit */ + u32 me; + struct tx_ring txr; }; struct em_rx_queue { - struct adapter *adapter; - u32 me; - u32 msix; - u32 eims; - struct rx_ring rxr; - u64 irqs; - struct if_irq que_irq; + struct e1000_softc *sc; + u32 me; + u32 msix; + u32 eims; + struct rx_ring rxr; + u64 irqs; + struct if_irq que_irq; }; -/* Our adapter structure */ -struct adapter { +/* Our softc structure */ +struct e1000_softc { struct ifnet *ifp; struct e1000_hw hw; - if_softc_ctx_t shared; - if_ctx_t ctx; -#define tx_num_queues shared->isc_ntxqsets -#define rx_num_queues shared->isc_nrxqsets -#define intr_type shared->isc_intr + if_softc_ctx_t shared; + if_ctx_t ctx; +#define tx_num_queues shared->isc_ntxqsets +#define rx_num_queues shared->isc_nrxqsets +#define intr_type shared->isc_intr /* FreeBSD operating-system-specific structures. */ - struct e1000_osdep osdep; - device_t dev; - struct cdev *led_dev; + struct e1000_osdep osdep; + device_t dev; + struct cdev *led_dev; - struct em_tx_queue *tx_queues; - struct em_rx_queue *rx_queues; - struct if_irq irq; + struct em_tx_queue *tx_queues; + struct em_rx_queue *rx_queues; + struct if_irq irq; - struct resource *memory; - struct resource *flash; - struct resource *ioport; + struct resource *memory; + struct resource *flash; + struct resource *ioport; - struct resource *res; - void *tag; - u32 linkvec; - u32 ivars; + struct resource *res; + void *tag; + u32 linkvec; + u32 ivars; struct ifmedia *media; - int msix; - int if_flags; - int em_insert_vlan_header; - u32 ims; - bool in_detach; + int msix; + int if_flags; + int em_insert_vlan_header; + u32 ims; + bool in_detach; u32 flags; /* Task for FAST handling */ - struct grouptask link_task; + struct grouptask link_task; - u16 num_vlans; - u32 txd_cmd; + u16 num_vlans; + u32 txd_cmd; - u32 tx_process_limit; - u32 rx_process_limit; + u32 tx_process_limit; + u32 rx_process_limit; u32 rx_mbuf_sz; /* Management and WOL features */ u32 wol; - bool has_manage; - bool has_amt; + bool has_manage; + bool has_amt; /* Multicast array memory */ u8 *mta; @@ -544,18 +534,18 @@ * ********************************************************************************/ typedef struct _em_vendor_info_t { - unsigned int vendor_id; - unsigned int device_id; - unsigned int subvendor_id; - unsigned int subdevice_id; - unsigned int index; + unsigned int vendor_id; + unsigned int device_id; + unsigned int subvendor_id; + unsigned int subdevice_id; + unsigned int index; } em_vendor_info_t; -void em_dump_rs(struct adapter *); +void em_dump_rs(struct e1000_softc *); #define EM_RSSRK_SIZE 4 #define EM_RSSRK_VAL(key, i) (key[(i) * EM_RSSRK_SIZE] | \ - key[(i) * EM_RSSRK_SIZE + 1] << 8 | \ - key[(i) * EM_RSSRK_SIZE + 2] << 16 | \ - key[(i) * EM_RSSRK_SIZE + 3] << 24) + key[(i) * EM_RSSRK_SIZE + 1] << 8 | \ + key[(i) * EM_RSSRK_SIZE + 2] << 16 | \ + key[(i) * EM_RSSRK_SIZE + 3] << 24) #endif /* _EM_H_DEFINED_ */ diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -294,33 +294,33 @@ static void em_if_multi_set(if_ctx_t ctx); static void em_if_update_admin_status(if_ctx_t ctx); static void em_if_debug(if_ctx_t ctx); -static void em_update_stats_counters(struct adapter *); -static void em_add_hw_stats(struct adapter *adapter); +static void em_update_stats_counters(struct e1000_softc *); +static void em_add_hw_stats(struct e1000_softc *); static int em_if_set_promisc(if_ctx_t ctx, int flags); -static bool em_if_vlan_filter_capable(struct adapter *); -static bool em_if_vlan_filter_used(struct adapter *); -static void em_if_vlan_filter_enable(struct adapter *); -static void em_if_vlan_filter_disable(struct adapter *); -static void em_if_vlan_filter_write(struct adapter *); -static void em_setup_vlan_hw_support(struct adapter *); +static bool em_if_vlan_filter_capable(struct e1000_softc *); +static bool em_if_vlan_filter_used(struct e1000_softc *); +static void em_if_vlan_filter_enable(struct e1000_softc *); +static void em_if_vlan_filter_disable(struct e1000_softc *); +static void em_if_vlan_filter_write(struct e1000_softc *); +static void em_setup_vlan_hw_support(struct e1000_softc *); static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); -static void em_print_nvm_info(struct adapter *); +static void em_print_nvm_info(struct e1000_softc *); static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); static int em_get_rs(SYSCTL_HANDLER_ARGS); -static void em_print_debug_info(struct adapter *); +static void em_print_debug_info(struct e1000_softc *); static int em_is_valid_ether_addr(u8 *); static int em_sysctl_int_delay(SYSCTL_HANDLER_ARGS); -static void em_add_int_delay_sysctl(struct adapter *, const char *, +static void em_add_int_delay_sysctl(struct e1000_softc *, const char *, const char *, struct em_int_delay_info *, int, int); /* Management and WOL Support */ -static void em_init_manageability(struct adapter *); -static void em_release_manageability(struct adapter *); -static void em_get_hw_control(struct adapter *); -static void em_release_hw_control(struct adapter *); +static void em_init_manageability(struct e1000_softc *); +static void em_release_manageability(struct e1000_softc *); +static void em_get_hw_control(struct e1000_softc *); +static void em_release_hw_control(struct e1000_softc *); static void em_get_wakeup(if_ctx_t ctx); static void em_enable_wakeup(if_ctx_t ctx); -static int em_enable_phy_wakeup(struct adapter *); -static void em_disable_aspm(struct adapter *); +static int em_enable_phy_wakeup(struct e1000_softc *); +static void em_disable_aspm(struct e1000_softc *); int em_intr(void *arg); @@ -337,8 +337,8 @@ static int em_get_regs(SYSCTL_HANDLER_ARGS); -static void lem_smartspeed(struct adapter *adapter); -static void igb_configure_queues(struct adapter *adapter); +static void lem_smartspeed(struct e1000_softc *); +static void igb_configure_queues(struct e1000_softc *); /********************************************************************* @@ -370,7 +370,7 @@ static driver_t em_driver = { - "em", em_methods, sizeof(struct adapter), + "em", em_methods, sizeof(struct e1000_softc), }; static devclass_t em_devclass; @@ -383,7 +383,7 @@ IFLIB_PNP_INFO(pci, em, em_vendor_info_array); static driver_t igb_driver = { - "igb", igb_methods, sizeof(struct adapter), + "igb", igb_methods, sizeof(struct e1000_softc), }; static devclass_t igb_devclass; @@ -430,7 +430,7 @@ }; static driver_t em_if_driver = { - "em_if", em_if_methods, sizeof(struct adapter) + "em_if", em_if_methods, sizeof(struct e1000_softc) }; static device_method_t igb_if_methods[] = { @@ -468,7 +468,7 @@ }; static driver_t igb_if_driver = { - "igb_if", igb_if_methods, sizeof(struct adapter) + "igb_if", igb_if_methods, sizeof(struct e1000_softc) }; /********************************************************************* @@ -609,8 +609,8 @@ static int em_get_regs(SYSCTL_HANDLER_ARGS) { - struct adapter *adapter = (struct adapter *)arg1; - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = (struct e1000_softc *)arg1; + struct e1000_hw *hw = &sc->hw; struct sbuf *sb; u32 *regs_buff; int rc; @@ -690,7 +690,7 @@ #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]; @@ -734,11 +734,11 @@ static int em_set_num_queues(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); int maxqueues; /* Sanity check based on HW */ - switch (adapter->hw.mac.type) { + switch (sc->hw.mac.type) { case e1000_82576: case e1000_82580: case e1000_i350: @@ -788,7 +788,7 @@ static int em_if_attach_pre(if_ctx_t ctx) { - struct adapter *adapter; + struct e1000_softc *sc; if_softc_ctx_t scctx; device_t dev; struct e1000_hw *hw; @@ -796,42 +796,42 @@ INIT_DEBUGOUT("em_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; - adapter->tx_process_limit = scctx->isc_ntxd[0]; + sc->tx_process_limit = scctx->isc_ntxd[0]; /* 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, em_sysctl_nvm_info, "I", "NVM Information"); + sc, 0, em_sysctl_nvm_info, "I", "NVM Information"); 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, em_sysctl_debug_info, "I", "Debug Information"); + sc, 0, em_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, em_set_flowcntl, "I", "Flow Control"); + sc, 0, em_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, em_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, em_get_rs, "I", "Dump RS indexes"); /* Determine hardware and mac info */ @@ -938,19 +938,19 @@ (hw->mac.type == e1000_pch2lan) || (hw->mac.type == e1000_pch_lpt)) { int rid = EM_BAR_TYPE_FLASH; - adapter->flash = bus_alloc_resource_any(dev, + sc->flash = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (adapter->flash == NULL) { + if (sc->flash == NULL) { device_printf(dev, "Mapping of Flash failed\n"); error = ENXIO; goto err_pci; } /* This is used in the shared code */ - hw->flash_address = (u8 *)adapter->flash; - adapter->osdep.flash_bus_space_tag = - rman_get_bustag(adapter->flash); - adapter->osdep.flash_bus_space_handle = - rman_get_bushandle(adapter->flash); + hw->flash_address = (u8 *)sc->flash; + sc->osdep.flash_bus_space_tag = + rman_get_bustag(sc->flash); + sc->osdep.flash_bus_space_handle = + rman_get_bushandle(sc->flash); } /* ** In the new SPT device flash is not a @@ -959,10 +959,10 @@ ** FLASH read/write macros in the shared code. */ else if (hw->mac.type >= e1000_pch_spt) { - adapter->osdep.flash_bus_space_tag = - adapter->osdep.mem_bus_space_tag; - adapter->osdep.flash_bus_space_handle = - adapter->osdep.mem_bus_space_handle + sc->osdep.flash_bus_space_tag = + sc->osdep.mem_bus_space_tag; + sc->osdep.flash_bus_space_handle = + sc->osdep.mem_bus_space_handle + E1000_FLASH_BASE_ADDR; } @@ -979,25 +979,25 @@ e1000_get_bus_info(hw); /* Set up some sysctls for the tunable interrupt delays */ - em_add_int_delay_sysctl(adapter, "rx_int_delay", - "receive interrupt delay in usecs", &adapter->rx_int_delay, + em_add_int_delay_sysctl(sc, "rx_int_delay", + "receive interrupt delay in usecs", &sc->rx_int_delay, E1000_REGISTER(hw, E1000_RDTR), em_rx_int_delay_dflt); - em_add_int_delay_sysctl(adapter, "tx_int_delay", - "transmit interrupt delay in usecs", &adapter->tx_int_delay, + em_add_int_delay_sysctl(sc, "tx_int_delay", + "transmit interrupt delay in usecs", &sc->tx_int_delay, E1000_REGISTER(hw, E1000_TIDV), em_tx_int_delay_dflt); - em_add_int_delay_sysctl(adapter, "rx_abs_int_delay", + em_add_int_delay_sysctl(sc, "rx_abs_int_delay", "receive interrupt delay limit in usecs", - &adapter->rx_abs_int_delay, + &sc->rx_abs_int_delay, E1000_REGISTER(hw, E1000_RADV), em_rx_abs_int_delay_dflt); - em_add_int_delay_sysctl(adapter, "tx_abs_int_delay", + em_add_int_delay_sysctl(sc, "tx_abs_int_delay", "transmit interrupt delay limit in usecs", - &adapter->tx_abs_int_delay, + &sc->tx_abs_int_delay, E1000_REGISTER(hw, E1000_TADV), em_tx_abs_int_delay_dflt); - em_add_int_delay_sysctl(adapter, "itr", + em_add_int_delay_sysctl(sc, "itr", "interrupt delay limit in usecs/4", - &adapter->tx_itr, + &sc->tx_itr, E1000_REGISTER(hw, E1000_ITR), DEFAULT_ITR); @@ -1030,9 +1030,9 @@ hw->mac.report_tx_early = 1; /* 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; @@ -1049,7 +1049,7 @@ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "eee_control", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - adapter, 0, em_sysctl_eee, "I", + sc, 0, em_sysctl_eee, "I", "Disable Energy Efficient Ethernet"); /* @@ -1083,7 +1083,7 @@ } if (!em_is_valid_ether_addr(hw->mac.addr)) { - if (adapter->vf_ifp) { + if (sc->vf_ifp) { ether_gen_addr(iflib_get_ifp(ctx), (struct ether_addr *)hw->mac.addr); } else { @@ -1103,7 +1103,7 @@ /* 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); @@ -1111,10 +1111,10 @@ return (0); err_late: - em_release_hw_control(adapter); + em_release_hw_control(sc); err_pci: em_free_pci_resources(ctx); - free(adapter->mta, M_DEVBUF); + free(sc->mta, M_DEVBUF); return (error); } @@ -1122,28 +1122,28 @@ static int em_if_attach_post(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; int error = 0; /* Setup OS specific network interface */ error = em_setup_interface(ctx); if (error != 0) { - device_printf(adapter->dev, "Interface setup failed: %d\n", error); + device_printf(sc->dev, "Interface setup failed: %d\n", error); goto err_late; } em_reset(ctx); /* Initialize statistics */ - em_update_stats_counters(adapter); + em_update_stats_counters(sc); hw->mac.get_link_status = 1; em_if_update_admin_status(ctx); - em_add_hw_stats(adapter); + em_add_hw_stats(sc); /* Non-AMT based hardware can now take control from firmware */ - if (adapter->has_manage && !adapter->has_amt) - em_get_hw_control(adapter); + if (sc->has_manage && !sc->has_amt) + em_get_hw_control(sc); INIT_DEBUGOUT("em_if_attach_post: end"); @@ -1166,17 +1166,17 @@ static int em_if_detach(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); INIT_DEBUGOUT("em_if_detach: begin"); - e1000_phy_hw_reset(&adapter->hw); + e1000_phy_hw_reset(&sc->hw); - em_release_manageability(adapter); - em_release_hw_control(adapter); + em_release_manageability(sc); + em_release_hw_control(sc); em_free_pci_resources(ctx); - free(adapter->mta, M_DEVBUF); - adapter->mta = NULL; + free(sc->mta, M_DEVBUF); + sc->mta = NULL; return (0); } @@ -1199,10 +1199,10 @@ static int em_if_suspend(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); - em_release_manageability(adapter); - em_release_hw_control(adapter); + em_release_manageability(sc); + em_release_hw_control(sc); em_enable_wakeup(ctx); return (0); } @@ -1210,12 +1210,12 @@ static int em_if_resume(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); - if (adapter->hw.mac.type == e1000_pch2lan) - e1000_resume_workarounds_pchlan(&adapter->hw); + if (sc->hw.mac.type == e1000_pch2lan) + e1000_resume_workarounds_pchlan(&sc->hw); em_if_init(ctx); - em_init_manageability(adapter); + em_init_manageability(sc); return(0); } @@ -1224,12 +1224,12 @@ em_if_mtu_set(if_ctx_t ctx, uint32_t mtu) { int max_frame_size; - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_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)"); - switch (adapter->hw.mac.type) { + switch (sc->hw.mac.type) { case e1000_82571: case e1000_82572: case e1000_ich9lan: @@ -1256,7 +1256,7 @@ max_frame_size = ETHER_MAX_LEN; break; default: - if (adapter->hw.mac.type >= igb_mac_min) + if (sc->hw.mac.type >= igb_mac_min) max_frame_size = 9234; else /* lem */ max_frame_size = MAX_JUMBO_FRAME_SIZE; @@ -1265,7 +1265,7 @@ 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); } @@ -1282,8 +1282,8 @@ static void em_if_init(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct e1000_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; struct ifnet *ifp = iflib_get_ifp(ctx); struct em_tx_queue *tx_que; int i; @@ -1291,11 +1291,11 @@ INIT_DEBUGOUT("em_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 */ - e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); + e1000_rar_set(&sc->hw, sc->hw.mac.addr, 0); /* * With the 82571 adapter, RAR[0] may be overwritten @@ -1303,9 +1303,9 @@ * in RAR[14] for that eventuality, this assures * the interface continues to function. */ - if (adapter->hw.mac.type == e1000_82571) { - e1000_set_laa_state_82571(&adapter->hw, true); - e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, + if (sc->hw.mac.type == e1000_82571) { + e1000_set_laa_state_82571(&sc->hw, true); + e1000_rar_set(&sc->hw, sc->hw.mac.addr, E1000_RAR_ENTRIES - 1); } @@ -1314,7 +1314,7 @@ em_reset(ctx); em_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; @@ -1328,14 +1328,14 @@ } /* Setup VLAN support, basic and offload if available */ - E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN); + E1000_WRITE_REG(&sc->hw, E1000_VET, ETHERTYPE_VLAN); /* Clear bad data from Rx FIFOs */ - if (adapter->hw.mac.type >= igb_mac_min) - e1000_rx_fifo_flush_base(&adapter->hw); + if (sc->hw.mac.type >= igb_mac_min) + e1000_rx_fifo_flush_base(&sc->hw); /* Configure for OS presence */ - em_init_manageability(adapter); + em_init_manageability(sc); /* Prepare transmit descriptors and buffers */ em_initialize_transmit_unit(ctx); @@ -1343,42 +1343,42 @@ /* Setup Multicast table */ em_if_multi_set(ctx); - adapter->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); + sc->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); em_initialize_receive_unit(ctx); /* Set up VLAN support and filter */ - em_setup_vlan_hw_support(adapter); + em_setup_vlan_hw_support(sc); /* Don't lose promiscuous settings */ em_if_set_promisc(ctx, if_getflags(ifp)); - e1000_clear_hw_cntrs_base_generic(&adapter->hw); + e1000_clear_hw_cntrs_base_generic(&sc->hw); /* MSI-X configuration for 82574 */ - if (adapter->hw.mac.type == e1000_82574) { - int tmp = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); + if (sc->hw.mac.type == e1000_82574) { + int tmp = E1000_READ_REG(&sc->hw, E1000_CTRL_EXT); tmp |= E1000_CTRL_EXT_PBA_CLR; - E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, tmp); + E1000_WRITE_REG(&sc->hw, E1000_CTRL_EXT, tmp); /* Set the IVAR - interrupt vector routing. */ - E1000_WRITE_REG(&adapter->hw, E1000_IVAR, adapter->ivars); - } else if (adapter->intr_type == IFLIB_INTR_MSIX) /* Set up queue routing */ - igb_configure_queues(adapter); + E1000_WRITE_REG(&sc->hw, E1000_IVAR, sc->ivars); + } else if (sc->intr_type == IFLIB_INTR_MSIX) /* Set up queue routing */ + igb_configure_queues(sc); /* this clears any pending interrupts */ - E1000_READ_REG(&adapter->hw, E1000_ICR); - E1000_WRITE_REG(&adapter->hw, E1000_ICS, E1000_ICS_LSC); + E1000_READ_REG(&sc->hw, E1000_ICR); + E1000_WRITE_REG(&sc->hw, E1000_ICS, E1000_ICS_LSC); /* AMT based hardware can now take control from firmware */ - if (adapter->has_manage && adapter->has_amt) - em_get_hw_control(adapter); + if (sc->has_manage && sc->has_amt) + em_get_hw_control(sc); /* Set Energy Efficient Ethernet */ - if (adapter->hw.mac.type >= igb_mac_min && - adapter->hw.phy.media_type == e1000_media_type_copper) { - if (adapter->hw.mac.type == e1000_i354) - e1000_set_eee_i354(&adapter->hw, true, true); + if (sc->hw.mac.type >= igb_mac_min && + sc->hw.phy.media_type == e1000_media_type_copper) { + if (sc->hw.mac.type == e1000_i354) + e1000_set_eee_i354(&sc->hw, true, true); else - e1000_set_eee_i350(&adapter->hw, true, true); + e1000_set_eee_i350(&sc->hw, true, true); } } @@ -1390,11 +1390,11 @@ int em_intr(void *arg) { - struct adapter *adapter = arg; - if_ctx_t ctx = adapter->ctx; + struct e1000_softc *sc = arg; + if_ctx_t ctx = sc->ctx; u32 reg_icr; - reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR); + reg_icr = E1000_READ_REG(&sc->hw, E1000_ICR); /* Hot eject? */ if (reg_icr == 0xffffffff) @@ -1408,7 +1408,7 @@ * Starting with the 82571 chip, bit 31 should be used to * determine whether the interrupt belongs to us. */ - if (adapter->hw.mac.type >= e1000_82571 && + if (sc->hw.mac.type >= e1000_82571 && (reg_icr & E1000_ICR_INT_ASSERTED) == 0) return FILTER_STRAY; @@ -1425,7 +1425,7 @@ em_handle_link(ctx); if (reg_icr & E1000_ICR_RXO) - adapter->rx_overruns++; + sc->rx_overruns++; return (FILTER_SCHEDULE_THREAD); } @@ -1433,40 +1433,40 @@ static int em_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_rx_queue *rxq = &adapter->rx_queues[rxqid]; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_rx_queue *rxq = &sc->rx_queues[rxqid]; - E1000_WRITE_REG(&adapter->hw, E1000_IMS, rxq->eims); + E1000_WRITE_REG(&sc->hw, E1000_IMS, rxq->eims); return (0); } static int em_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_tx_queue *txq = &adapter->tx_queues[txqid]; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_tx_queue *txq = &sc->tx_queues[txqid]; - E1000_WRITE_REG(&adapter->hw, E1000_IMS, txq->eims); + E1000_WRITE_REG(&sc->hw, E1000_IMS, txq->eims); return (0); } static int igb_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_rx_queue *rxq = &adapter->rx_queues[rxqid]; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_rx_queue *rxq = &sc->rx_queues[rxqid]; - E1000_WRITE_REG(&adapter->hw, E1000_EIMS, rxq->eims); + E1000_WRITE_REG(&sc->hw, E1000_EIMS, rxq->eims); return (0); } static int igb_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_tx_queue *txq = &adapter->tx_queues[txqid]; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_tx_queue *txq = &sc->tx_queues[txqid]; - E1000_WRITE_REG(&adapter->hw, E1000_EIMS, txq->eims); + E1000_WRITE_REG(&sc->hw, E1000_EIMS, txq->eims); return (0); } @@ -1493,29 +1493,29 @@ static int em_msix_link(void *arg) { - struct adapter *adapter = arg; + struct e1000_softc *sc = arg; u32 reg_icr; bool notlink = false; - ++adapter->link_irq; - MPASS(adapter->hw.back != NULL); - reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR); + ++sc->link_irq; + MPASS(sc->hw.back != NULL); + reg_icr = E1000_READ_REG(&sc->hw, E1000_ICR); if (reg_icr & E1000_ICR_RXO) - adapter->rx_overruns++; + sc->rx_overruns++; if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) - em_handle_link(adapter->ctx); + em_handle_link(sc->ctx); else notlink = true; /* Re-arm for other/spurious interrupts */ - if (notlink && adapter->hw.mac.type >= igb_mac_min) { - E1000_WRITE_REG(&adapter->hw, E1000_IMS, E1000_IMS_LSC); - E1000_WRITE_REG(&adapter->hw, E1000_EIMS, adapter->link_mask); - } else if (adapter->hw.mac.type == e1000_82574) { + if (notlink && sc->hw.mac.type >= igb_mac_min) { + E1000_WRITE_REG(&sc->hw, E1000_IMS, E1000_IMS_LSC); + E1000_WRITE_REG(&sc->hw, E1000_EIMS, sc->link_mask); + } else if (sc->hw.mac.type == e1000_82574) { if (notlink) - E1000_WRITE_REG(&adapter->hw, E1000_IMS, E1000_IMS_LSC | + E1000_WRITE_REG(&sc->hw, E1000_IMS, E1000_IMS_LSC | E1000_IMS_OTHER); /* * Because we must read the ICR for this interrupt it may @@ -1523,7 +1523,7 @@ * simply create a soft interrupt for all these vectors. */ if (reg_icr) - E1000_WRITE_REG(&adapter->hw, E1000_ICS, adapter->ims); + E1000_WRITE_REG(&sc->hw, E1000_ICS, sc->ims); } return (FILTER_HANDLED); @@ -1533,9 +1533,9 @@ em_handle_link(void *context) { if_ctx_t ctx = context; - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); - adapter->hw.mac.get_link_status = 1; + sc->hw.mac.get_link_status = 1; iflib_admin_intr_deferred(ctx); } @@ -1550,7 +1550,7 @@ static void em_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); u_char fiber_type = IFM_1000_SX; INIT_DEBUGOUT("em_if_media_status: begin"); @@ -1560,19 +1560,19 @@ ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; - if (!adapter->link_active) { + if (!sc->link_active) { return; } ifmr->ifm_status |= IFM_ACTIVE; - if ((adapter->hw.phy.media_type == e1000_media_type_fiber) || - (adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) { - if (adapter->hw.mac.type == e1000_82545) + if ((sc->hw.phy.media_type == e1000_media_type_fiber) || + (sc->hw.phy.media_type == e1000_media_type_internal_serdes)) { + if (sc->hw.mac.type == e1000_82545) fiber_type = IFM_1000_LX; ifmr->ifm_active |= fiber_type | IFM_FDX; } else { - switch (adapter->link_speed) { + switch (sc->link_speed) { case 10: ifmr->ifm_active |= IFM_10_T; break; @@ -1583,7 +1583,7 @@ ifmr->ifm_active |= IFM_1000_T; break; } - if (adapter->link_duplex == FULL_DUPLEX) + if (sc->link_duplex == FULL_DUPLEX) ifmr->ifm_active |= IFM_FDX; else ifmr->ifm_active |= IFM_HDX; @@ -1601,7 +1601,7 @@ static int em_if_media_change(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); struct ifmedia *ifm = iflib_get_media(ctx); INIT_DEBUGOUT("em_if_media_change: begin"); @@ -1611,33 +1611,33 @@ switch (IFM_SUBTYPE(ifm->ifm_media)) { case IFM_AUTO: - adapter->hw.mac.autoneg = DO_AUTO_NEG; - adapter->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT; + sc->hw.mac.autoneg = DO_AUTO_NEG; + sc->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT; break; case IFM_1000_LX: case IFM_1000_SX: case IFM_1000_T: - adapter->hw.mac.autoneg = DO_AUTO_NEG; - adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; + sc->hw.mac.autoneg = DO_AUTO_NEG; + sc->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; break; case IFM_100_TX: - adapter->hw.mac.autoneg = false; - adapter->hw.phy.autoneg_advertised = 0; + sc->hw.mac.autoneg = false; + sc->hw.phy.autoneg_advertised = 0; if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) - adapter->hw.mac.forced_speed_duplex = ADVERTISE_100_FULL; + sc->hw.mac.forced_speed_duplex = ADVERTISE_100_FULL; else - adapter->hw.mac.forced_speed_duplex = ADVERTISE_100_HALF; + sc->hw.mac.forced_speed_duplex = ADVERTISE_100_HALF; break; case IFM_10_T: - adapter->hw.mac.autoneg = false; - adapter->hw.phy.autoneg_advertised = 0; + sc->hw.mac.autoneg = false; + sc->hw.phy.autoneg_advertised = 0; if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) - adapter->hw.mac.forced_speed_duplex = ADVERTISE_10_FULL; + sc->hw.mac.forced_speed_duplex = ADVERTISE_10_FULL; else - adapter->hw.mac.forced_speed_duplex = ADVERTISE_10_HALF; + sc->hw.mac.forced_speed_duplex = ADVERTISE_10_HALF; break; default: - device_printf(adapter->dev, "Unsupported media type\n"); + device_printf(sc->dev, "Unsupported media type\n"); } em_if_init(ctx); @@ -1648,12 +1648,12 @@ static int em_if_set_promisc(if_ctx_t ctx, int flags) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); struct ifnet *ifp = iflib_get_ifp(ctx); u32 reg_rctl; int mcnt = 0; - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); + reg_rctl = E1000_READ_REG(&sc->hw, E1000_RCTL); reg_rctl &= ~(E1000_RCTL_SBP | E1000_RCTL_UPE); if (flags & IFF_ALLMULTI) mcnt = MAX_NUM_MULTICAST_ADDRESSES; @@ -1662,23 +1662,23 @@ if (mcnt < MAX_NUM_MULTICAST_ADDRESSES) reg_rctl &= (~E1000_RCTL_MPE); - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); if (flags & IFF_PROMISC) { reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); - em_if_vlan_filter_disable(adapter); + em_if_vlan_filter_disable(sc); /* Turn this on if you want to see bad packets */ if (em_debug_sbp) reg_rctl |= E1000_RCTL_SBP; - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); } else { if (flags & IFF_ALLMULTI) { reg_rctl |= E1000_RCTL_MPE; reg_rctl &= ~E1000_RCTL_UPE; - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); } - if (em_if_vlan_filter_used(adapter)) - em_if_vlan_filter_enable(adapter); + if (em_if_vlan_filter_used(sc)) + em_if_vlan_filter_enable(sc); } return (0); } @@ -1705,7 +1705,7 @@ static void em_if_multi_set(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); struct ifnet *ifp = iflib_get_ifp(ctx); u8 *mta; /* Multicast array memory */ u32 reg_rctl = 0; @@ -1713,22 +1713,22 @@ IOCTL_DEBUGOUT("em_set_multi: begin"); - mta = adapter->mta; + mta = sc->mta; bzero(mta, sizeof(u8) * ETHER_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES); - if (adapter->hw.mac.type == e1000_82542 && - adapter->hw.revision_id == E1000_REVISION_2) { - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); - if (adapter->hw.bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) - e1000_pci_clear_mwi(&adapter->hw); + if (sc->hw.mac.type == e1000_82542 && + sc->hw.revision_id == E1000_REVISION_2) { + reg_rctl = E1000_READ_REG(&sc->hw, E1000_RCTL); + if (sc->hw.bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) + e1000_pci_clear_mwi(&sc->hw); reg_rctl |= E1000_RCTL_RST; - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); msec_delay(5); } mcnt = if_foreach_llmaddr(ifp, em_copy_maddr, mta); - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); + reg_rctl = E1000_READ_REG(&sc->hw, E1000_RCTL); if (if_getflags(ifp) & IFF_PROMISC) reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); @@ -1739,19 +1739,19 @@ } else reg_rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE); - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); if (mcnt < MAX_NUM_MULTICAST_ADDRESSES) - e1000_update_mc_addr_list(&adapter->hw, mta, mcnt); + e1000_update_mc_addr_list(&sc->hw, mta, mcnt); - if (adapter->hw.mac.type == e1000_82542 && - adapter->hw.revision_id == E1000_REVISION_2) { - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); + if (sc->hw.mac.type == e1000_82542 && + sc->hw.revision_id == E1000_REVISION_2) { + reg_rctl = E1000_READ_REG(&sc->hw, E1000_RCTL); reg_rctl &= ~E1000_RCTL_RST; - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); msec_delay(5); - if (adapter->hw.bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) - e1000_pci_set_mwi(&adapter->hw); + if (sc->hw.bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) + e1000_pci_set_mwi(&sc->hw); } } @@ -1776,8 +1776,8 @@ static void em_if_update_admin_status(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; device_t dev = iflib_get_dev(ctx); u32 link_check, thstat, ctrl; @@ -1822,11 +1822,11 @@ } /* Now check for a transition */ - if (link_check && (adapter->link_active == 0)) { - e1000_get_speed_and_duplex(hw, &adapter->link_speed, - &adapter->link_duplex); + if (link_check && (sc->link_active == 0)) { + e1000_get_speed_and_duplex(hw, &sc->link_speed, + &sc->link_duplex); /* Check if we must disable SPEED_MODE bit on PCI-E */ - if ((adapter->link_speed != SPEED_1000) && + if ((sc->link_speed != SPEED_1000) && ((hw->mac.type == e1000_82571) || (hw->mac.type == e1000_82572))) { int tarc0; @@ -1836,11 +1836,11 @@ } 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; - adapter->smartspeed = 0; + sc->link_active = 1; + sc->smartspeed = 0; if ((ctrl & E1000_CTRL_EXT_LINK_MODE_MASK) == E1000_CTRL_EXT_LINK_MODE_GMII && (thstat & E1000_THSTAT_LINK_THROTTLE)) @@ -1854,44 +1854,44 @@ if (hw->dev_spec._82575.media_changed && hw->mac.type >= igb_mac_min) { hw->dev_spec._82575.media_changed = false; - adapter->flags |= IGB_MEDIA_RESET; + sc->flags |= IGB_MEDIA_RESET; em_reset(ctx); } 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); } - em_update_stats_counters(adapter); + em_update_stats_counters(sc); /* Reset LAA into RAR[0] on 82571 */ if (hw->mac.type == e1000_82571 && e1000_get_laa_state_82571(hw)) e1000_rar_set(hw, hw->mac.addr, 0); if (hw->mac.type < em_mac_min) - lem_smartspeed(adapter); + lem_smartspeed(sc); else if (hw->mac.type >= igb_mac_min && - adapter->intr_type == IFLIB_INTR_MSIX) { - E1000_WRITE_REG(&adapter->hw, E1000_IMS, E1000_IMS_LSC); - E1000_WRITE_REG(&adapter->hw, E1000_EIMS, adapter->link_mask); + sc->intr_type == IFLIB_INTR_MSIX) { + E1000_WRITE_REG(&sc->hw, E1000_IMS, E1000_IMS_LSC); + E1000_WRITE_REG(&sc->hw, E1000_EIMS, sc->link_mask); } else if (hw->mac.type == e1000_82574 && - adapter->intr_type == IFLIB_INTR_MSIX) + sc->intr_type == IFLIB_INTR_MSIX) E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_LSC | E1000_IMS_OTHER); } static void em_if_watchdog_reset(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_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++; } /********************************************************************* @@ -1903,16 +1903,16 @@ static void em_if_stop(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); INIT_DEBUGOUT("em_if_stop: begin"); - e1000_reset_hw(&adapter->hw); - if (adapter->hw.mac.type >= e1000_82544) - E1000_WRITE_REG(&adapter->hw, E1000_WUFC, 0); + e1000_reset_hw(&sc->hw); + if (sc->hw.mac.type >= e1000_82544) + E1000_WRITE_REG(&sc->hw, E1000_WUFC, 0); - e1000_led_off(&adapter->hw); - e1000_cleanup_led(&adapter->hw); + e1000_led_off(&sc->hw); + e1000_cleanup_led(&sc->hw); } /********************************************************************* @@ -1924,56 +1924,56 @@ em_identify_hardware(if_ctx_t ctx) { device_t dev = iflib_get_dev(ctx); - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_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 (e1000_set_mac_type(&adapter->hw)) { + if (e1000_set_mac_type(&sc->hw)) { device_printf(dev, "Setup init failure\n"); return; } /* Are we a VF device? */ - if ((adapter->hw.mac.type == e1000_vfadapt) || - (adapter->hw.mac.type == e1000_vfadapt_i350)) - adapter->vf_ifp = 1; + if ((sc->hw.mac.type == e1000_vfadapt) || + (sc->hw.mac.type == e1000_vfadapt_i350)) + sc->vf_ifp = 1; else - adapter->vf_ifp = 0; + sc->vf_ifp = 0; } static int em_allocate_pci_resources(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); device_t dev = iflib_get_dev(ctx); int rid, val; 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; /* Only older adapters use IO mapping */ - if (adapter->hw.mac.type < em_mac_min && - adapter->hw.mac.type > e1000_82543) { + if (sc->hw.mac.type < em_mac_min && + sc->hw.mac.type > e1000_82543) { /* Figure our where our IO BAR is ? */ for (rid = PCIR_BAR(0); rid < PCIR_CIS;) { val = pci_read_config(dev, rid, 4); @@ -1989,21 +1989,21 @@ device_printf(dev, "Unable to locate IO BAR\n"); return (ENXIO); } - adapter->ioport = bus_alloc_resource_any(dev, SYS_RES_IOPORT, + sc->ioport = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); - if (adapter->ioport == NULL) { + if (sc->ioport == NULL) { device_printf(dev, "Unable to allocate bus resource: " "ioport\n"); return (ENXIO); } - adapter->hw.io_base = 0; - adapter->osdep.io_bus_space_tag = - rman_get_bustag(adapter->ioport); - adapter->osdep.io_bus_space_handle = - rman_get_bushandle(adapter->ioport); + sc->hw.io_base = 0; + sc->osdep.io_bus_space_tag = + rman_get_bustag(sc->ioport); + sc->osdep.io_bus_space_handle = + rman_get_bushandle(sc->ioport); } - adapter->hw.back = &adapter->osdep; + sc->hw.back = &sc->osdep; return (0); } @@ -2016,20 +2016,20 @@ static int em_if_msix_intr_assign(if_ctx_t ctx, int msix) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_rx_queue *rx_que = adapter->rx_queues; - struct em_tx_queue *tx_que = adapter->tx_queues; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_rx_queue *rx_que = sc->rx_queues; + struct em_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, em_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; } @@ -2041,11 +2041,11 @@ * are for RX0 and RX1, note this has * NOTHING to do with the MSI-X vector */ - if (adapter->hw.mac.type == e1000_82574) { + if (sc->hw.mac.type == e1000_82574) { rx_que->eims = 1 << (20 + i); - adapter->ims |= rx_que->eims; - adapter->ivars |= (8 | rx_que->msix) << (i * 4); - } else if (adapter->hw.mac.type == e1000_82575) + sc->ims |= rx_que->eims; + sc->ivars |= (8 | rx_que->msix) << (i * 4); + } else if (sc->hw.mac.type == e1000_82575) rx_que->eims = E1000_EICR_TX_QUEUE0 << vector; else rx_que->eims = 1 << vector; @@ -2053,14 +2053,14 @@ 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 @@ -2068,11 +2068,11 @@ * are for TX0 and TX1, note this has * NOTHING to do with the MSI-X vector */ - if (adapter->hw.mac.type == e1000_82574) { + if (sc->hw.mac.type == e1000_82574) { tx_que->eims = 1 << (22 + i); - adapter->ims |= tx_que->eims; - adapter->ivars |= (8 | tx_que->msix) << (8 + (i * 4)); - } else if (adapter->hw.mac.type == e1000_82575) { + sc->ims |= tx_que->eims; + sc->ivars |= (8 | tx_que->msix) << (8 + (i * 4)); + } else if (sc->hw.mac.type == e1000_82575) { tx_que->eims = E1000_EICR_TX_QUEUE0 << i; } else { tx_que->eims = 1 << i; @@ -2081,33 +2081,33 @@ /* Link interrupt */ rid = rx_vectors + 1; - error = iflib_irq_alloc_generic(ctx, &adapter->irq, rid, IFLIB_INTR_ADMIN, em_msix_link, adapter, 0, "aq"); + error = iflib_irq_alloc_generic(ctx, &sc->irq, rid, IFLIB_INTR_ADMIN, em_msix_link, sc, 0, "aq"); if (error) { device_printf(iflib_get_dev(ctx), "Failed to register admin handler"); goto fail; } - adapter->linkvec = rx_vectors; - if (adapter->hw.mac.type < igb_mac_min) { - adapter->ivars |= (8 | rx_vectors) << 16; - adapter->ivars |= 0x80000000; + sc->linkvec = rx_vectors; + if (sc->hw.mac.type < igb_mac_min) { + sc->ivars |= (8 | rx_vectors) << 16; + sc->ivars |= 0x80000000; /* Enable the "Other" interrupt type for link status change */ - adapter->ims |= E1000_IMS_OTHER; + sc->ims |= E1000_IMS_OTHER; } 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 -igb_configure_queues(struct adapter *adapter) +igb_configure_queues(struct e1000_softc *sc) { - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; struct em_rx_queue *rx_que; struct em_tx_queue *tx_que; u32 tmp, ivar = 0, newitr = 0; @@ -2128,10 +2128,10 @@ case e1000_vfadapt: case e1000_vfadapt_i350: /* 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 = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index); - rx_que = &adapter->rx_queues[i]; + rx_que = &sc->rx_queues[i]; if (i & 1) { ivar &= 0xFF00FFFF; ivar |= (rx_que->msix | E1000_IVAR_VALID) << 16; @@ -2142,10 +2142,10 @@ E1000_WRITE_REG_ARRAY(hw, E1000_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 = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index); - tx_que = &adapter->tx_queues[i]; + tx_que = &sc->tx_queues[i]; if (i & 1) { ivar &= 0x00FFFFFF; ivar |= (tx_que->msix | E1000_IVAR_VALID) << 24; @@ -2154,20 +2154,20 @@ ivar |= (tx_que->msix | E1000_IVAR_VALID) << 8; } E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar); - adapter->que_mask |= tx_que->eims; + sc->que_mask |= tx_que->eims; } /* And for the link interrupt */ - ivar = (adapter->linkvec | E1000_IVAR_VALID) << 8; - adapter->link_mask = 1 << adapter->linkvec; + ivar = (sc->linkvec | E1000_IVAR_VALID) << 8; + sc->link_mask = 1 << sc->linkvec; E1000_WRITE_REG(hw, E1000_IVAR_MISC, ivar); break; case e1000_82576: /* 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 & 0x7; /* Each IVAR has two entries */ ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index); - rx_que = &adapter->rx_queues[i]; + rx_que = &sc->rx_queues[i]; if (i < 8) { ivar &= 0xFFFFFF00; ivar |= rx_que->msix | E1000_IVAR_VALID; @@ -2176,13 +2176,13 @@ ivar |= (rx_que->msix | E1000_IVAR_VALID) << 16; } E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar); - adapter->que_mask |= rx_que->eims; + sc->que_mask |= rx_que->eims; } /* 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 & 0x7; /* Each IVAR has two entries */ ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index); - tx_que = &adapter->tx_queues[i]; + tx_que = &sc->tx_queues[i]; if (i < 8) { ivar &= 0xFFFF00FF; ivar |= (tx_que->msix | E1000_IVAR_VALID) << 8; @@ -2191,12 +2191,12 @@ ivar |= (tx_que->msix | E1000_IVAR_VALID) << 24; } E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar); - adapter->que_mask |= tx_que->eims; + sc->que_mask |= tx_que->eims; } /* And for the link interrupt */ - ivar = (adapter->linkvec | E1000_IVAR_VALID) << 8; - adapter->link_mask = 1 << adapter->linkvec; + ivar = (sc->linkvec | E1000_IVAR_VALID) << 8; + sc->link_mask = 1 << sc->linkvec; E1000_WRITE_REG(hw, E1000_IVAR_MISC, ivar); break; @@ -2210,20 +2210,20 @@ E1000_WRITE_REG(hw, E1000_CTRL_EXT, tmp); /* Queues */ - 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]; tmp = E1000_EICR_RX_QUEUE0 << i; tmp |= E1000_EICR_TX_QUEUE0 << i; rx_que->eims = tmp; E1000_WRITE_REG_ARRAY(hw, E1000_MSIXBM(0), i, rx_que->eims); - adapter->que_mask |= rx_que->eims; + sc->que_mask |= rx_que->eims; } /* Link */ - E1000_WRITE_REG(hw, E1000_MSIXBM(adapter->linkvec), + E1000_WRITE_REG(hw, E1000_MSIXBM(sc->linkvec), E1000_EIMS_OTHER); - adapter->link_mask |= E1000_EIMS_OTHER; + sc->link_mask |= E1000_EIMS_OTHER; default: break; } @@ -2237,8 +2237,8 @@ else newitr |= E1000_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]; E1000_WRITE_REG(hw, E1000_EITR(rx_que->msix), newitr); } @@ -2248,36 +2248,36 @@ static void em_free_pci_resources(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_rx_queue *que = adapter->rx_queues; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_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); if (que != NULL) { - 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; } } @@ -2285,9 +2285,9 @@ static int em_setup_msix(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); - if (adapter->hw.mac.type == e1000_82574) { + if (sc->hw.mac.type == e1000_82574) { em_enable_vectors_82574(ctx); } return (0); @@ -2299,58 +2299,58 @@ * **********************************************************************/ static void -lem_smartspeed(struct adapter *adapter) +lem_smartspeed(struct e1000_softc *sc) { u16 phy_tmp; - if (adapter->link_active || (adapter->hw.phy.type != e1000_phy_igp) || - adapter->hw.mac.autoneg == 0 || - (adapter->hw.phy.autoneg_advertised & ADVERTISE_1000_FULL) == 0) + if (sc->link_active || (sc->hw.phy.type != e1000_phy_igp) || + sc->hw.mac.autoneg == 0 || + (sc->hw.phy.autoneg_advertised & ADVERTISE_1000_FULL) == 0) return; - if (adapter->smartspeed == 0) { + if (sc->smartspeed == 0) { /* If Master/Slave config fault is asserted twice, * we assume back-to-back */ - e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_tmp); + e1000_read_phy_reg(&sc->hw, PHY_1000T_STATUS, &phy_tmp); if (!(phy_tmp & SR_1000T_MS_CONFIG_FAULT)) return; - e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_tmp); + e1000_read_phy_reg(&sc->hw, PHY_1000T_STATUS, &phy_tmp); if (phy_tmp & SR_1000T_MS_CONFIG_FAULT) { - e1000_read_phy_reg(&adapter->hw, + e1000_read_phy_reg(&sc->hw, PHY_1000T_CTRL, &phy_tmp); if(phy_tmp & CR_1000T_MS_ENABLE) { phy_tmp &= ~CR_1000T_MS_ENABLE; - e1000_write_phy_reg(&adapter->hw, + e1000_write_phy_reg(&sc->hw, PHY_1000T_CTRL, phy_tmp); - adapter->smartspeed++; - if(adapter->hw.mac.autoneg && - !e1000_copper_link_autoneg(&adapter->hw) && - !e1000_read_phy_reg(&adapter->hw, + sc->smartspeed++; + if(sc->hw.mac.autoneg && + !e1000_copper_link_autoneg(&sc->hw) && + !e1000_read_phy_reg(&sc->hw, PHY_CONTROL, &phy_tmp)) { phy_tmp |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); - e1000_write_phy_reg(&adapter->hw, + e1000_write_phy_reg(&sc->hw, PHY_CONTROL, phy_tmp); } } } return; - } else if(adapter->smartspeed == EM_SMARTSPEED_DOWNSHIFT) { + } else if(sc->smartspeed == EM_SMARTSPEED_DOWNSHIFT) { /* If still no link, perhaps using 2/3 pair cable */ - e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_tmp); + e1000_read_phy_reg(&sc->hw, PHY_1000T_CTRL, &phy_tmp); phy_tmp |= CR_1000T_MS_ENABLE; - e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_tmp); - if(adapter->hw.mac.autoneg && - !e1000_copper_link_autoneg(&adapter->hw) && - !e1000_read_phy_reg(&adapter->hw, PHY_CONTROL, &phy_tmp)) { + e1000_write_phy_reg(&sc->hw, PHY_1000T_CTRL, phy_tmp); + if(sc->hw.mac.autoneg && + !e1000_copper_link_autoneg(&sc->hw) && + !e1000_read_phy_reg(&sc->hw, PHY_CONTROL, &phy_tmp)) { phy_tmp |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); - e1000_write_phy_reg(&adapter->hw, PHY_CONTROL, phy_tmp); + e1000_write_phy_reg(&sc->hw, PHY_CONTROL, phy_tmp); } } /* Restart process after EM_SMARTSPEED_MAX iterations */ - if(adapter->smartspeed++ == EM_SMARTSPEED_MAX) - adapter->smartspeed = 0; + if(sc->smartspeed++ == EM_SMARTSPEED_MAX) + sc->smartspeed = 0; } /********************************************************************* @@ -2359,10 +2359,10 @@ * **********************************************************************/ static void -igb_init_dmac(struct adapter *adapter, u32 pba) +igb_init_dmac(struct e1000_softc *sc, u32 pba) { - device_t dev = adapter->dev; - struct e1000_hw *hw = &adapter->hw; + device_t dev = sc->dev; + struct e1000_hw *hw = &sc->hw; u32 dmac, reg = ~E1000_DMACR_DMAC_EN; u16 hwm; u16 max_frame_size; @@ -2370,10 +2370,10 @@ if (hw->mac.type == e1000_i211) return; - max_frame_size = adapter->shared->isc_max_frame_size; + max_frame_size = sc->shared->isc_max_frame_size; if (hw->mac.type > e1000_82580) { - if (adapter->dmac == 0) { /* Disabling it */ + if (sc->dmac == 0) { /* Disabling it */ E1000_WRITE_REG(hw, E1000_DMACR, reg); return; } else @@ -2413,11 +2413,11 @@ int status = E1000_READ_REG(hw, E1000_STATUS); if ((status & E1000_STATUS_2P5_SKU) && (!(status & E1000_STATUS_2P5_SKU_OVER))) - reg |= ((adapter->dmac * 5) >> 6); + reg |= ((sc->dmac * 5) >> 6); else - reg |= (adapter->dmac >> 5); + reg |= (sc->dmac >> 5); } else { - reg |= (adapter->dmac >> 5); + reg |= (sc->dmac >> 5); } E1000_WRITE_REG(hw, E1000_DMACR, reg); @@ -2465,22 +2465,22 @@ /********************************************************************* * * Initialize the hardware to a configuration as specified by the - * adapter structure. + * sc structure. * **********************************************************************/ static void em_reset(if_ctx_t ctx) { device_t dev = iflib_get_dev(ctx); - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); struct ifnet *ifp = iflib_get_ifp(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; u16 rx_buffer_size; u32 pba; INIT_DEBUGOUT("em_reset: begin"); /* Let the firmware know the OS is in control */ - em_get_hw_control(adapter); + em_get_hw_control(sc); /* Set up smart power down as default off on newer adapters. */ if (!em_smart_pwr_down && (hw->mac.type == e1000_82571 || @@ -2619,8 +2619,8 @@ roundup2(hw->mac.max_frame_size, 1024); hw->fc.low_water = hw->fc.high_water - 1500; - 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 = e1000_fc_full; @@ -2698,12 +2698,12 @@ E1000_WRITE_REG(hw, E1000_WUC, 0); } else { E1000_WRITE_REG(hw, E1000_WUFC, 0); - em_disable_aspm(adapter); + em_disable_aspm(sc); } - if (adapter->flags & IGB_MEDIA_RESET) { + if (sc->flags & IGB_MEDIA_RESET) { e1000_setup_init_funcs(hw, true); e1000_get_bus_info(hw); - adapter->flags &= ~IGB_MEDIA_RESET; + sc->flags &= ~IGB_MEDIA_RESET; } /* and a re-init */ if (e1000_init_hw(hw) < 0) { @@ -2711,7 +2711,7 @@ return; } if (hw->mac.type >= igb_mac_min) - igb_init_dmac(adapter, pba); + igb_init_dmac(sc, pba); E1000_WRITE_REG(hw, E1000_VET, ETHERTYPE_VLAN); e1000_get_phy_info(hw); @@ -2725,11 +2725,11 @@ #define RSSKEYLEN 10 static void -em_initialize_rss_mapping(struct adapter *adapter) +em_initialize_rss_mapping(struct e1000_softc *sc) { uint8_t rss_key[4 * RSSKEYLEN]; uint32_t reta = 0; - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; int i; /* @@ -2750,7 +2750,7 @@ for (i = 0; i < sizeof(reta); ++i) { uint32_t q; - q = (i % adapter->rx_num_queues) << 7; + q = (i % sc->rx_num_queues) << 7; reta |= q << (8 * i); } @@ -2766,9 +2766,9 @@ } static void -igb_initialize_rss_mapping(struct adapter *adapter) +igb_initialize_rss_mapping(struct e1000_softc *sc) { - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; int i; int queue_id; u32 reta; @@ -2809,9 +2809,9 @@ * 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; @@ -2869,13 +2869,13 @@ em_setup_interface(if_ctx_t ctx) { struct ifnet *ifp = iflib_get_ifp(ctx); - struct adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct e1000_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; INIT_DEBUGOUT("em_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); } @@ -2884,54 +2884,54 @@ * Specify the media types supported by this adapter and register * callbacks to update media and link information */ - if (adapter->hw.phy.media_type == e1000_media_type_fiber || - adapter->hw.phy.media_type == e1000_media_type_internal_serdes) { + if (sc->hw.phy.media_type == e1000_media_type_fiber || + sc->hw.phy.media_type == e1000_media_type_internal_serdes) { u_char fiber_type = IFM_1000_SX; /* default type */ - if (adapter->hw.mac.type == e1000_82545) + if (sc->hw.mac.type == e1000_82545) fiber_type = IFM_1000_LX; - ifmedia_add(adapter->media, IFM_ETHER | fiber_type | IFM_FDX, 0, NULL); - ifmedia_add(adapter->media, IFM_ETHER | fiber_type, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | fiber_type | IFM_FDX, 0, NULL); + ifmedia_add(sc->media, IFM_ETHER | fiber_type, 0, NULL); } else { - 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); - if (adapter->hw.phy.type != e1000_phy_ife) { - 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(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); + if (sc->hw.phy.type != e1000_phy_ife) { + 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(adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(adapter->media, IFM_ETHER | IFM_AUTO); + ifmedia_add(sc->media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(sc->media, IFM_ETHER | IFM_AUTO); return (0); } static int em_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxqs, int ntxqsets) { - struct adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct e1000_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; int error = E1000_SUCCESS; struct em_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 em_tx_queue *) malloc(sizeof(struct em_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 */ @@ -2949,7 +2949,7 @@ 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: em_if_queues_free(ctx); @@ -2959,27 +2959,27 @@ static int em_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs, int nrxqsets) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); int error = E1000_SUCCESS; struct em_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 em_rx_queue *) malloc(sizeof(struct em_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; @@ -2990,7 +2990,7 @@ 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: @@ -3001,12 +3001,12 @@ static void em_if_queues_free(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct em_tx_queue *tx_que = adapter->tx_queues; - struct em_rx_queue *rx_que = adapter->rx_queues; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct em_tx_queue *tx_que = sc->tx_queues; + struct em_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; @@ -3014,13 +3014,13 @@ 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; } } @@ -3032,20 +3032,20 @@ static void em_initialize_transmit_unit(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct e1000_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; struct em_tx_queue *que; struct tx_ring *txr; - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; u32 tctl, txdctl = 0, tarc, tipg = 0; INIT_DEBUGOUT("em_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; @@ -3103,11 +3103,11 @@ } E1000_WRITE_REG(hw, E1000_TIPG, tipg); - E1000_WRITE_REG(hw, E1000_TIDV, adapter->tx_int_delay.value); + E1000_WRITE_REG(hw, E1000_TIDV, sc->tx_int_delay.value); if(hw->mac.type >= e1000_82540) E1000_WRITE_REG(hw, E1000_TADV, - adapter->tx_abs_int_delay.value); + sc->tx_abs_int_delay.value); if (hw->mac.type == e1000_82571 || hw->mac.type == e1000_82572) { tarc = E1000_READ_REG(hw, E1000_TARC(0)); @@ -3124,7 +3124,7 @@ } else if (hw->mac.type == e1000_82574) { tarc = E1000_READ_REG(hw, E1000_TARC(0)); tarc |= TARC_ERRATA_BIT; - if ( adapter->tx_num_queues > 1) { + if ( sc->tx_num_queues > 1) { tarc |= (TARC_COMPENSATION_MODE | TARC_MQ_FIX); E1000_WRITE_REG(hw, E1000_TARC(0), tarc); E1000_WRITE_REG(hw, E1000_TARC(1), tarc); @@ -3132,8 +3132,8 @@ E1000_WRITE_REG(hw, E1000_TARC(0), tarc); } - if (adapter->tx_int_delay.value > 0) - adapter->txd_cmd |= E1000_TXD_CMD_IDE; + if (sc->tx_int_delay.value > 0) + sc->txd_cmd |= E1000_TXD_CMD_IDE; /* Program the Transmit Control Register */ tctl = E1000_READ_REG(hw, E1000_TCTL); @@ -3171,10 +3171,10 @@ static void em_initialize_receive_unit(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - if_softc_ctx_t scctx = adapter->shared; + struct e1000_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = sc->shared; struct ifnet *ifp = iflib_get_ifp(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; struct em_rx_queue *que; int i; uint32_t rctl, rxcsum; @@ -3211,7 +3211,7 @@ if (hw->mac.type >= e1000_82540) { E1000_WRITE_REG(hw, E1000_RADV, - adapter->rx_abs_int_delay.value); + sc->rx_abs_int_delay.value); /* * Set the interrupt throttling rate. Value is calculated @@ -3219,7 +3219,7 @@ */ E1000_WRITE_REG(hw, E1000_ITR, DEFAULT_ITR); } - E1000_WRITE_REG(hw, E1000_RDTR, adapter->rx_int_delay.value); + E1000_WRITE_REG(hw, E1000_RDTR, sc->rx_int_delay.value); if (hw->mac.type >= em_mac_min) { uint32_t rfctl; @@ -3258,14 +3258,14 @@ rxcsum &= ~E1000_RXCSUM_IPV6OFL; } - if (adapter->rx_num_queues > 1) { + if (sc->rx_num_queues > 1) { /* RSS hash needed in the Rx descriptor */ rxcsum |= E1000_RXCSUM_PCSD; if (hw->mac.type >= igb_mac_min) - igb_initialize_rss_mapping(adapter); + igb_initialize_rss_mapping(sc); else - em_initialize_rss_mapping(adapter); + em_initialize_rss_mapping(sc); } E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum); @@ -3279,12 +3279,12 @@ if (hw->mac.type == e1000_82573) E1000_WRITE_REG(hw, E1000_RDTR, 0x20); - 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; /* Setup the Base and Length of the Rx Descriptor Ring */ u64 bus_addr = rxr->rx_paddr; #if 0 - u32 rdt = adapter->rx_num_queues -1; /* default */ + u32 rdt = sc->rx_num_queues -1; /* default */ #endif E1000_WRITE_REG(hw, E1000_RDLEN(i), @@ -3308,7 +3308,7 @@ u32 rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(0)); E1000_WRITE_REG(hw, E1000_RXDCTL(0), rxdctl | 3); } else if (hw->mac.type == e1000_82574) { - for (int i = 0; i < adapter->rx_num_queues; i++) { + for (int i = 0; i < sc->rx_num_queues; i++) { u32 rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(i)); rxdctl |= 0x20; /* PTHRESH */ rxdctl |= 4 << 8; /* HTHRESH */ @@ -3325,14 +3325,14 @@ if (ifp->if_vlantrunk != NULL) psize += VLAN_TAG_SIZE; - if (adapter->vf_ifp) + if (sc->vf_ifp) e1000_rlpml_set_vf(hw, psize); else E1000_WRITE_REG(hw, E1000_RLPML, psize); } /* Set maximum packet buffer len */ - srrctl |= (adapter->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> + srrctl |= (sc->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> E1000_SRRCTL_BSIZEPKT_SHIFT; /* @@ -3341,13 +3341,13 @@ * * This drops frames rather than hanging the RX MAC for all queues. */ - if ((adapter->rx_num_queues > 1) && - (adapter->fc == e1000_fc_none || - adapter->fc == e1000_fc_rx_pause)) { + if ((sc->rx_num_queues > 1) && + (sc->fc == e1000_fc_none || + sc->fc == e1000_fc_rx_pause)) { srrctl |= E1000_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; @@ -3387,11 +3387,11 @@ /* Set up packet buffer size, overridden by per queue srrctl on igb */ if (hw->mac.type < igb_mac_min) { - if (adapter->rx_mbuf_sz > 2048 && adapter->rx_mbuf_sz <= 4096) + if (sc->rx_mbuf_sz > 2048 && sc->rx_mbuf_sz <= 4096) rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; - else if (adapter->rx_mbuf_sz > 4096 && adapter->rx_mbuf_sz <= 8192) + else if (sc->rx_mbuf_sz > 4096 && sc->rx_mbuf_sz <= 8192) rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; - else if (adapter->rx_mbuf_sz > 8192) + else if (sc->rx_mbuf_sz > 8192) rctl |= E1000_RCTL_SZ_16384 | E1000_RCTL_BSEX; else { rctl |= E1000_RCTL_SZ_2048; @@ -3418,33 +3418,33 @@ static void em_if_vlan_register(if_ctx_t ctx, u16 vtag) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); u32 index, bit; index = (vtag >> 5) & 0x7F; bit = vtag & 0x1F; - adapter->shadow_vfta[index] |= (1 << bit); - ++adapter->num_vlans; - em_if_vlan_filter_write(adapter); + sc->shadow_vfta[index] |= (1 << bit); + ++sc->num_vlans; + em_if_vlan_filter_write(sc); } static void em_if_vlan_unregister(if_ctx_t ctx, u16 vtag) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); u32 index, bit; index = (vtag >> 5) & 0x7F; bit = vtag & 0x1F; - adapter->shadow_vfta[index] &= ~(1 << bit); - --adapter->num_vlans; - em_if_vlan_filter_write(adapter); + sc->shadow_vfta[index] &= ~(1 << bit); + --sc->num_vlans; + em_if_vlan_filter_write(sc); } static bool -em_if_vlan_filter_capable(struct adapter *adapter) +em_if_vlan_filter_capable(struct e1000_softc *sc) { - if_softc_ctx_t scctx = adapter->shared; + if_softc_ctx_t scctx = sc->shared; if ((scctx->isc_capenable & IFCAP_VLAN_HWFILTER) && !em_disable_crc_stripping) @@ -3454,22 +3454,22 @@ } static bool -em_if_vlan_filter_used(struct adapter *adapter) +em_if_vlan_filter_used(struct e1000_softc *sc) { - if (!em_if_vlan_filter_capable(adapter)) + if (!em_if_vlan_filter_capable(sc)) return (false); for (int i = 0; i < EM_VFTA_SIZE; i++) - if (adapter->shadow_vfta[i] != 0) + if (sc->shadow_vfta[i] != 0) return (true); return (false); } static void -em_if_vlan_filter_enable(struct adapter *adapter) +em_if_vlan_filter_enable(struct e1000_softc *sc) { - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; u32 reg; reg = E1000_READ_REG(hw, E1000_RCTL); @@ -3479,9 +3479,9 @@ } static void -em_if_vlan_filter_disable(struct adapter *adapter) +em_if_vlan_filter_disable(struct e1000_softc *sc) { - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; u32 reg; reg = E1000_READ_REG(hw, E1000_RCTL); @@ -3490,42 +3490,42 @@ } static void -em_if_vlan_filter_write(struct adapter *adapter) +em_if_vlan_filter_write(struct e1000_softc *sc) { - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; - if (adapter->vf_ifp) + if (sc->vf_ifp) return; /* Disable interrupts for lem-class devices during the filter change */ if (hw->mac.type < em_mac_min) - em_if_intr_disable(adapter->ctx); + em_if_intr_disable(sc->ctx); for (int i = 0; i < EM_VFTA_SIZE; i++) - if (adapter->shadow_vfta[i] != 0) { + if (sc->shadow_vfta[i] != 0) { /* XXXKB: incomplete VF support, we return early above */ - if (adapter->vf_ifp) - e1000_vfta_set_vf(hw, adapter->shadow_vfta[i], true); + if (sc->vf_ifp) + e1000_vfta_set_vf(hw, sc->shadow_vfta[i], true); else - e1000_write_vfta(hw, i, adapter->shadow_vfta[i]); + e1000_write_vfta(hw, i, sc->shadow_vfta[i]); } /* Re-enable interrupts for lem-class devices */ if (hw->mac.type < em_mac_min) - em_if_intr_enable(adapter->ctx); + em_if_intr_enable(sc->ctx); } static void -em_setup_vlan_hw_support(struct adapter *adapter) +em_setup_vlan_hw_support(struct e1000_softc *sc) { - if_softc_ctx_t scctx = adapter->shared; - struct e1000_hw *hw = &adapter->hw; + if_softc_ctx_t scctx = sc->shared; + struct e1000_hw *hw = &sc->hw; u32 reg; /* XXXKB: Return early if we are a VF until VF decap and filter management * is ready and tested. */ - if (adapter->vf_ifp) + if (sc->vf_ifp) return; if (scctx->isc_capenable & IFCAP_VLAN_HWTAGGING && @@ -3540,8 +3540,8 @@ } /* If we aren't doing HW filtering, we're done */ - if (!em_if_vlan_filter_capable(adapter)) { - em_if_vlan_filter_disable(adapter); + if (!em_if_vlan_filter_capable(sc)) { + em_if_vlan_filter_disable(sc); return; } @@ -3549,22 +3549,22 @@ * A soft reset zero's out the VFTA, so * we need to repopulate it now. */ - em_if_vlan_filter_write(adapter); + em_if_vlan_filter_write(sc); /* Enable the Filter Table */ - em_if_vlan_filter_enable(adapter); + em_if_vlan_filter_enable(sc); } static void em_if_intr_enable(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; u32 ims_mask = IMS_ENABLE_MASK; - if (adapter->intr_type == IFLIB_INTR_MSIX) { - E1000_WRITE_REG(hw, EM_EIAC, adapter->ims); - ims_mask |= adapter->ims; + if (sc->intr_type == IFLIB_INTR_MSIX) { + E1000_WRITE_REG(hw, EM_EIAC, sc->ims); + ims_mask |= sc->ims; } E1000_WRITE_REG(hw, E1000_IMS, ims_mask); E1000_WRITE_FLUSH(hw); @@ -3573,10 +3573,10 @@ static void em_if_intr_disable(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; - if (adapter->intr_type == IFLIB_INTR_MSIX) + if (sc->intr_type == IFLIB_INTR_MSIX) E1000_WRITE_REG(hw, EM_EIAC, 0); E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); E1000_WRITE_FLUSH(hw); @@ -3585,12 +3585,12 @@ static void igb_if_intr_enable(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_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); E1000_WRITE_REG(hw, E1000_EIAC, mask); E1000_WRITE_REG(hw, E1000_EIAM, mask); E1000_WRITE_REG(hw, E1000_EIMS, mask); @@ -3603,10 +3603,10 @@ static void igb_if_intr_disable(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; - if (__predict_true(adapter->intr_type == IFLIB_INTR_MSIX)) { + if (__predict_true(sc->intr_type == IFLIB_INTR_MSIX)) { E1000_WRITE_REG(hw, E1000_EIMC, 0xffffffff); E1000_WRITE_REG(hw, E1000_EIAC, 0); } @@ -3620,13 +3620,13 @@ * to disable special hardware management features */ static void -em_init_manageability(struct adapter *adapter) +em_init_manageability(struct e1000_softc *sc) { /* A shared code workaround */ #define E1000_82542_MANC2H E1000_MANC2H - if (adapter->has_manage) { - int manc2h = E1000_READ_REG(&adapter->hw, E1000_MANC2H); - int manc = E1000_READ_REG(&adapter->hw, E1000_MANC); + if (sc->has_manage) { + int manc2h = E1000_READ_REG(&sc->hw, E1000_MANC2H); + int manc = E1000_READ_REG(&sc->hw, E1000_MANC); /* disable hardware interception of ARP */ manc &= ~(E1000_MANC_ARP_EN); @@ -3637,8 +3637,8 @@ #define E1000_MNG2HOST_PORT_664 (1 << 6) manc2h |= E1000_MNG2HOST_PORT_623; manc2h |= E1000_MNG2HOST_PORT_664; - E1000_WRITE_REG(&adapter->hw, E1000_MANC2H, manc2h); - E1000_WRITE_REG(&adapter->hw, E1000_MANC, manc); + E1000_WRITE_REG(&sc->hw, E1000_MANC2H, manc2h); + E1000_WRITE_REG(&sc->hw, E1000_MANC, manc); } } @@ -3647,16 +3647,16 @@ * controller if there is one. */ static void -em_release_manageability(struct adapter *adapter) +em_release_manageability(struct e1000_softc *sc) { - if (adapter->has_manage) { - int manc = E1000_READ_REG(&adapter->hw, E1000_MANC); + if (sc->has_manage) { + int manc = E1000_READ_REG(&sc->hw, E1000_MANC); /* re-enable hardware interception of ARP */ manc |= E1000_MANC_ARP_EN; manc &= ~E1000_MANC_EN_MNG2HOST; - E1000_WRITE_REG(&adapter->hw, E1000_MANC, manc); + E1000_WRITE_REG(&sc->hw, E1000_MANC, manc); } } @@ -3667,22 +3667,22 @@ * this means that the network i/f is open. */ static void -em_get_hw_control(struct adapter *adapter) +em_get_hw_control(struct e1000_softc *sc) { u32 ctrl_ext, swsm; - if (adapter->vf_ifp) + if (sc->vf_ifp) return; - if (adapter->hw.mac.type == e1000_82573) { - swsm = E1000_READ_REG(&adapter->hw, E1000_SWSM); - E1000_WRITE_REG(&adapter->hw, E1000_SWSM, + if (sc->hw.mac.type == e1000_82573) { + swsm = E1000_READ_REG(&sc->hw, E1000_SWSM); + E1000_WRITE_REG(&sc->hw, E1000_SWSM, swsm | E1000_SWSM_DRV_LOAD); return; } /* else */ - ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); - E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, + ctrl_ext = E1000_READ_REG(&sc->hw, E1000_CTRL_EXT); + E1000_WRITE_REG(&sc->hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD); } @@ -3693,22 +3693,22 @@ * f/w this means that the network i/f is closed. */ static void -em_release_hw_control(struct adapter *adapter) +em_release_hw_control(struct e1000_softc *sc) { u32 ctrl_ext, swsm; - if (!adapter->has_manage) + if (!sc->has_manage) return; - if (adapter->hw.mac.type == e1000_82573) { - swsm = E1000_READ_REG(&adapter->hw, E1000_SWSM); - E1000_WRITE_REG(&adapter->hw, E1000_SWSM, + if (sc->hw.mac.type == e1000_82573) { + swsm = E1000_READ_REG(&sc->hw, E1000_SWSM); + E1000_WRITE_REG(&sc->hw, E1000_SWSM, swsm & ~E1000_SWSM_DRV_LOAD); return; } /* else */ - ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); - E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, + ctrl_ext = E1000_READ_REG(&sc->hw, E1000_CTRL_EXT); + E1000_WRITE_REG(&sc->hw, E1000_CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD); return; } @@ -3733,45 +3733,45 @@ static void em_get_wakeup(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); device_t dev = iflib_get_dev(ctx); u16 eeprom_data = 0, device_id, apme_mask; - adapter->has_manage = e1000_enable_mng_pass_thru(&adapter->hw); + sc->has_manage = e1000_enable_mng_pass_thru(&sc->hw); apme_mask = EM_EEPROM_APME; - switch (adapter->hw.mac.type) { + switch (sc->hw.mac.type) { case e1000_82542: case e1000_82543: break; case e1000_82544: - e1000_read_nvm(&adapter->hw, + e1000_read_nvm(&sc->hw, NVM_INIT_CONTROL2_REG, 1, &eeprom_data); apme_mask = EM_82544_APME; break; case e1000_82546: case e1000_82546_rev_3: - if (adapter->hw.bus.func == 1) { - e1000_read_nvm(&adapter->hw, + if (sc->hw.bus.func == 1) { + e1000_read_nvm(&sc->hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); break; } else - e1000_read_nvm(&adapter->hw, + e1000_read_nvm(&sc->hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); break; case e1000_82573: case e1000_82583: - adapter->has_amt = true; + sc->has_amt = true; /* FALLTHROUGH */ case e1000_82571: case e1000_82572: case e1000_80003es2lan: - if (adapter->hw.bus.func == 1) { - e1000_read_nvm(&adapter->hw, + if (sc->hw.bus.func == 1) { + e1000_read_nvm(&sc->hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); break; } else - e1000_read_nvm(&adapter->hw, + e1000_read_nvm(&sc->hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); break; case e1000_ich8lan: @@ -3791,16 +3791,16 @@ case e1000_vfadapt: case e1000_vfadapt_i350: apme_mask = E1000_WUC_APME; - adapter->has_amt = true; - eeprom_data = E1000_READ_REG(&adapter->hw, E1000_WUC); + sc->has_amt = true; + eeprom_data = E1000_READ_REG(&sc->hw, E1000_WUC); break; default: - e1000_read_nvm(&adapter->hw, + e1000_read_nvm(&sc->hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); break; } if (eeprom_data & apme_mask) - adapter->wol = (E1000_WUFC_MAG | E1000_WUFC_MC); + sc->wol = (E1000_WUFC_MAG | E1000_WUFC_MC); /* * We have the eeprom settings, now apply the special cases * where the eeprom may be wrong or the board won't support @@ -3809,20 +3809,20 @@ device_id = pci_get_device(dev); switch (device_id) { case E1000_DEV_ID_82546GB_PCIE: - adapter->wol = 0; + sc->wol = 0; break; case E1000_DEV_ID_82546EB_FIBER: case E1000_DEV_ID_82546GB_FIBER: /* Wake events only supported on port A for dual fiber * regardless of eeprom setting */ - if (E1000_READ_REG(&adapter->hw, E1000_STATUS) & + if (E1000_READ_REG(&sc->hw, E1000_STATUS) & E1000_STATUS_FUNC_1) - adapter->wol = 0; + sc->wol = 0; break; case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: /* if quad port adapter, disable WoL on all but port A */ if (global_quad_port_a != 0) - adapter->wol = 0; + sc->wol = 0; /* Reset for multiple quad port adapters */ if (++global_quad_port_a == 4) global_quad_port_a = 0; @@ -3830,16 +3830,16 @@ case E1000_DEV_ID_82571EB_FIBER: /* Wake events only supported on port A for dual fiber * regardless of eeprom setting */ - if (E1000_READ_REG(&adapter->hw, E1000_STATUS) & + if (E1000_READ_REG(&sc->hw, E1000_STATUS) & E1000_STATUS_FUNC_1) - adapter->wol = 0; + sc->wol = 0; break; case E1000_DEV_ID_82571EB_QUAD_COPPER: case E1000_DEV_ID_82571EB_QUAD_FIBER: case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: /* if quad port adapter, disable WoL on all but port A */ if (global_quad_port_a != 0) - adapter->wol = 0; + sc->wol = 0; /* Reset for multiple quad port adapters */ if (++global_quad_port_a == 4) global_quad_port_a = 0; @@ -3855,7 +3855,7 @@ static void em_enable_wakeup(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); device_t dev = iflib_get_dev(ctx); if_t ifp = iflib_get_ifp(ctx); int error = 0; @@ -3870,53 +3870,53 @@ * is set with all bits on by default. */ if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0) - adapter->wol &= ~E1000_WUFC_MAG; + sc->wol &= ~E1000_WUFC_MAG; if ((if_getcapenable(ifp) & IFCAP_WOL_UCAST) == 0) - adapter->wol &= ~E1000_WUFC_EX; + sc->wol &= ~E1000_WUFC_EX; if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) == 0) - adapter->wol &= ~E1000_WUFC_MC; + sc->wol &= ~E1000_WUFC_MC; else { - rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); + rctl = E1000_READ_REG(&sc->hw, E1000_RCTL); rctl |= E1000_RCTL_MPE; - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl); + E1000_WRITE_REG(&sc->hw, E1000_RCTL, rctl); } - if (!(adapter->wol & (E1000_WUFC_EX | E1000_WUFC_MAG | E1000_WUFC_MC))) + if (!(sc->wol & (E1000_WUFC_EX | E1000_WUFC_MAG | E1000_WUFC_MC))) goto pme; /* Advertise the wakeup capability */ - ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL); + ctrl = E1000_READ_REG(&sc->hw, E1000_CTRL); ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3); - E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl); + E1000_WRITE_REG(&sc->hw, E1000_CTRL, ctrl); /* Keep the laser running on Fiber adapters */ - if (adapter->hw.phy.media_type == e1000_media_type_fiber || - adapter->hw.phy.media_type == e1000_media_type_internal_serdes) { - ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); + if (sc->hw.phy.media_type == e1000_media_type_fiber || + sc->hw.phy.media_type == e1000_media_type_internal_serdes) { + ctrl_ext = E1000_READ_REG(&sc->hw, E1000_CTRL_EXT); ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA; - E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, ctrl_ext); + E1000_WRITE_REG(&sc->hw, E1000_CTRL_EXT, ctrl_ext); } - if ((adapter->hw.mac.type == e1000_ich8lan) || - (adapter->hw.mac.type == e1000_pchlan) || - (adapter->hw.mac.type == e1000_ich9lan) || - (adapter->hw.mac.type == e1000_ich10lan)) - e1000_suspend_workarounds_ich8lan(&adapter->hw); + if ((sc->hw.mac.type == e1000_ich8lan) || + (sc->hw.mac.type == e1000_pchlan) || + (sc->hw.mac.type == e1000_ich9lan) || + (sc->hw.mac.type == e1000_ich10lan)) + e1000_suspend_workarounds_ich8lan(&sc->hw); - if ( adapter->hw.mac.type >= e1000_pchlan) { - error = em_enable_phy_wakeup(adapter); + if ( sc->hw.mac.type >= e1000_pchlan) { + error = em_enable_phy_wakeup(sc); if (error) goto pme; } else { /* Enable wakeup by the MAC */ - E1000_WRITE_REG(&adapter->hw, E1000_WUC, E1000_WUC_PME_EN); - E1000_WRITE_REG(&adapter->hw, E1000_WUFC, adapter->wol); + E1000_WRITE_REG(&sc->hw, E1000_WUC, E1000_WUC_PME_EN); + E1000_WRITE_REG(&sc->hw, E1000_WUFC, sc->wol); } - if (adapter->hw.phy.type == e1000_phy_igp_3) - e1000_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); + if (sc->hw.phy.type == e1000_phy_igp_3) + e1000_igp3_phy_powerdown_workaround_ich8lan(&sc->hw); pme: status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2); @@ -3933,9 +3933,9 @@ * require thing to be copied into the phy */ static int -em_enable_phy_wakeup(struct adapter *adapter) +em_enable_phy_wakeup(struct e1000_softc *sc) { - struct e1000_hw *hw = &adapter->hw; + struct e1000_hw *hw = &sc->hw; u32 mreg, ret = 0; u16 preg; @@ -3973,10 +3973,10 @@ /* enable PHY wakeup in MAC register */ E1000_WRITE_REG(hw, E1000_WUC, E1000_WUC_PHY_WAKE | E1000_WUC_PME_EN | E1000_WUC_APME); - E1000_WRITE_REG(hw, E1000_WUFC, adapter->wol); + E1000_WRITE_REG(hw, E1000_WUFC, sc->wol); /* configure and enable PHY wakeup in PHY registers */ - e1000_write_phy_reg(hw, BM_WUFC, adapter->wol); + e1000_write_phy_reg(hw, BM_WUFC, sc->wol); e1000_write_phy_reg(hw, BM_WUC, E1000_WUC_PME_EN); /* activate PHY wakeup */ @@ -4005,14 +4005,14 @@ static void em_if_led_func(if_ctx_t ctx, int onoff) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); if (onoff) { - e1000_setup_led(&adapter->hw); - e1000_led_on(&adapter->hw); + e1000_setup_led(&sc->hw); + e1000_led_on(&sc->hw); } else { - e1000_led_off(&adapter->hw); - e1000_cleanup_led(&adapter->hw); + e1000_led_off(&sc->hw); + e1000_cleanup_led(&sc->hw); } } @@ -4020,13 +4020,13 @@ * Disable the L0S and L1 LINK states */ static void -em_disable_aspm(struct adapter *adapter) +em_disable_aspm(struct e1000_softc *sc) { int base, reg; u16 link_cap,link_ctrl; - device_t dev = adapter->dev; + device_t dev = sc->dev; - switch (adapter->hw.mac.type) { + switch (sc->hw.mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: @@ -4053,120 +4053,120 @@ * **********************************************************************/ static void -em_update_stats_counters(struct adapter *adapter) +em_update_stats_counters(struct e1000_softc *sc) { - u64 prev_xoffrxc = adapter->stats.xoffrxc; + u64 prev_xoffrxc = sc->stats.xoffrxc; - if(adapter->hw.phy.media_type == e1000_media_type_copper || - (E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) { - adapter->stats.symerrs += E1000_READ_REG(&adapter->hw, E1000_SYMERRS); - adapter->stats.sec += E1000_READ_REG(&adapter->hw, E1000_SEC); + if(sc->hw.phy.media_type == e1000_media_type_copper || + (E1000_READ_REG(&sc->hw, E1000_STATUS) & E1000_STATUS_LU)) { + sc->stats.symerrs += E1000_READ_REG(&sc->hw, E1000_SYMERRS); + sc->stats.sec += E1000_READ_REG(&sc->hw, E1000_SEC); } - adapter->stats.crcerrs += E1000_READ_REG(&adapter->hw, E1000_CRCERRS); - adapter->stats.mpc += E1000_READ_REG(&adapter->hw, E1000_MPC); - adapter->stats.scc += E1000_READ_REG(&adapter->hw, E1000_SCC); - adapter->stats.ecol += E1000_READ_REG(&adapter->hw, E1000_ECOL); - - adapter->stats.mcc += E1000_READ_REG(&adapter->hw, E1000_MCC); - adapter->stats.latecol += E1000_READ_REG(&adapter->hw, E1000_LATECOL); - adapter->stats.colc += E1000_READ_REG(&adapter->hw, E1000_COLC); - adapter->stats.dc += E1000_READ_REG(&adapter->hw, E1000_DC); - adapter->stats.rlec += E1000_READ_REG(&adapter->hw, E1000_RLEC); - adapter->stats.xonrxc += E1000_READ_REG(&adapter->hw, E1000_XONRXC); - adapter->stats.xontxc += E1000_READ_REG(&adapter->hw, E1000_XONTXC); - adapter->stats.xoffrxc += E1000_READ_REG(&adapter->hw, E1000_XOFFRXC); + sc->stats.crcerrs += E1000_READ_REG(&sc->hw, E1000_CRCERRS); + sc->stats.mpc += E1000_READ_REG(&sc->hw, E1000_MPC); + sc->stats.scc += E1000_READ_REG(&sc->hw, E1000_SCC); + sc->stats.ecol += E1000_READ_REG(&sc->hw, E1000_ECOL); + + sc->stats.mcc += E1000_READ_REG(&sc->hw, E1000_MCC); + sc->stats.latecol += E1000_READ_REG(&sc->hw, E1000_LATECOL); + sc->stats.colc += E1000_READ_REG(&sc->hw, E1000_COLC); + sc->stats.dc += E1000_READ_REG(&sc->hw, E1000_DC); + sc->stats.rlec += E1000_READ_REG(&sc->hw, E1000_RLEC); + sc->stats.xonrxc += E1000_READ_REG(&sc->hw, E1000_XONRXC); + sc->stats.xontxc += E1000_READ_REG(&sc->hw, E1000_XONTXC); + sc->stats.xoffrxc += E1000_READ_REG(&sc->hw, E1000_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 += E1000_READ_REG(&adapter->hw, E1000_XOFFTXC); - adapter->stats.fcruc += E1000_READ_REG(&adapter->hw, E1000_FCRUC); - adapter->stats.prc64 += E1000_READ_REG(&adapter->hw, E1000_PRC64); - adapter->stats.prc127 += E1000_READ_REG(&adapter->hw, E1000_PRC127); - adapter->stats.prc255 += E1000_READ_REG(&adapter->hw, E1000_PRC255); - adapter->stats.prc511 += E1000_READ_REG(&adapter->hw, E1000_PRC511); - adapter->stats.prc1023 += E1000_READ_REG(&adapter->hw, E1000_PRC1023); - adapter->stats.prc1522 += E1000_READ_REG(&adapter->hw, E1000_PRC1522); - adapter->stats.gprc += E1000_READ_REG(&adapter->hw, E1000_GPRC); - adapter->stats.bprc += E1000_READ_REG(&adapter->hw, E1000_BPRC); - adapter->stats.mprc += E1000_READ_REG(&adapter->hw, E1000_MPRC); - adapter->stats.gptc += E1000_READ_REG(&adapter->hw, E1000_GPTC); + if (sc->stats.xoffrxc != prev_xoffrxc) + sc->shared->isc_pause_frames = 1; + sc->stats.xofftxc += E1000_READ_REG(&sc->hw, E1000_XOFFTXC); + sc->stats.fcruc += E1000_READ_REG(&sc->hw, E1000_FCRUC); + sc->stats.prc64 += E1000_READ_REG(&sc->hw, E1000_PRC64); + sc->stats.prc127 += E1000_READ_REG(&sc->hw, E1000_PRC127); + sc->stats.prc255 += E1000_READ_REG(&sc->hw, E1000_PRC255); + sc->stats.prc511 += E1000_READ_REG(&sc->hw, E1000_PRC511); + sc->stats.prc1023 += E1000_READ_REG(&sc->hw, E1000_PRC1023); + sc->stats.prc1522 += E1000_READ_REG(&sc->hw, E1000_PRC1522); + sc->stats.gprc += E1000_READ_REG(&sc->hw, E1000_GPRC); + sc->stats.bprc += E1000_READ_REG(&sc->hw, E1000_BPRC); + sc->stats.mprc += E1000_READ_REG(&sc->hw, E1000_MPRC); + sc->stats.gptc += E1000_READ_REG(&sc->hw, E1000_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 += E1000_READ_REG(&adapter->hw, E1000_GORCL) + - ((u64)E1000_READ_REG(&adapter->hw, E1000_GORCH) << 32); - adapter->stats.gotc += E1000_READ_REG(&adapter->hw, E1000_GOTCL) + - ((u64)E1000_READ_REG(&adapter->hw, E1000_GOTCH) << 32); - - adapter->stats.rnbc += E1000_READ_REG(&adapter->hw, E1000_RNBC); - adapter->stats.ruc += E1000_READ_REG(&adapter->hw, E1000_RUC); - adapter->stats.rfc += E1000_READ_REG(&adapter->hw, E1000_RFC); - adapter->stats.roc += E1000_READ_REG(&adapter->hw, E1000_ROC); - adapter->stats.rjc += E1000_READ_REG(&adapter->hw, E1000_RJC); - - adapter->stats.tor += E1000_READ_REG(&adapter->hw, E1000_TORH); - adapter->stats.tot += E1000_READ_REG(&adapter->hw, E1000_TOTH); - - adapter->stats.tpr += E1000_READ_REG(&adapter->hw, E1000_TPR); - adapter->stats.tpt += E1000_READ_REG(&adapter->hw, E1000_TPT); - adapter->stats.ptc64 += E1000_READ_REG(&adapter->hw, E1000_PTC64); - adapter->stats.ptc127 += E1000_READ_REG(&adapter->hw, E1000_PTC127); - adapter->stats.ptc255 += E1000_READ_REG(&adapter->hw, E1000_PTC255); - adapter->stats.ptc511 += E1000_READ_REG(&adapter->hw, E1000_PTC511); - adapter->stats.ptc1023 += E1000_READ_REG(&adapter->hw, E1000_PTC1023); - adapter->stats.ptc1522 += E1000_READ_REG(&adapter->hw, E1000_PTC1522); - adapter->stats.mptc += E1000_READ_REG(&adapter->hw, E1000_MPTC); - adapter->stats.bptc += E1000_READ_REG(&adapter->hw, E1000_BPTC); + sc->stats.gorc += E1000_READ_REG(&sc->hw, E1000_GORCL) + + ((u64)E1000_READ_REG(&sc->hw, E1000_GORCH) << 32); + sc->stats.gotc += E1000_READ_REG(&sc->hw, E1000_GOTCL) + + ((u64)E1000_READ_REG(&sc->hw, E1000_GOTCH) << 32); + + sc->stats.rnbc += E1000_READ_REG(&sc->hw, E1000_RNBC); + sc->stats.ruc += E1000_READ_REG(&sc->hw, E1000_RUC); + sc->stats.rfc += E1000_READ_REG(&sc->hw, E1000_RFC); + sc->stats.roc += E1000_READ_REG(&sc->hw, E1000_ROC); + sc->stats.rjc += E1000_READ_REG(&sc->hw, E1000_RJC); + + sc->stats.tor += E1000_READ_REG(&sc->hw, E1000_TORH); + sc->stats.tot += E1000_READ_REG(&sc->hw, E1000_TOTH); + + sc->stats.tpr += E1000_READ_REG(&sc->hw, E1000_TPR); + sc->stats.tpt += E1000_READ_REG(&sc->hw, E1000_TPT); + sc->stats.ptc64 += E1000_READ_REG(&sc->hw, E1000_PTC64); + sc->stats.ptc127 += E1000_READ_REG(&sc->hw, E1000_PTC127); + sc->stats.ptc255 += E1000_READ_REG(&sc->hw, E1000_PTC255); + sc->stats.ptc511 += E1000_READ_REG(&sc->hw, E1000_PTC511); + sc->stats.ptc1023 += E1000_READ_REG(&sc->hw, E1000_PTC1023); + sc->stats.ptc1522 += E1000_READ_REG(&sc->hw, E1000_PTC1522); + sc->stats.mptc += E1000_READ_REG(&sc->hw, E1000_MPTC); + sc->stats.bptc += E1000_READ_REG(&sc->hw, E1000_BPTC); /* Interrupt Counts */ - adapter->stats.iac += E1000_READ_REG(&adapter->hw, E1000_IAC); - adapter->stats.icrxptc += E1000_READ_REG(&adapter->hw, E1000_ICRXPTC); - adapter->stats.icrxatc += E1000_READ_REG(&adapter->hw, E1000_ICRXATC); - adapter->stats.ictxptc += E1000_READ_REG(&adapter->hw, E1000_ICTXPTC); - adapter->stats.ictxatc += E1000_READ_REG(&adapter->hw, E1000_ICTXATC); - adapter->stats.ictxqec += E1000_READ_REG(&adapter->hw, E1000_ICTXQEC); - adapter->stats.ictxqmtc += E1000_READ_REG(&adapter->hw, E1000_ICTXQMTC); - adapter->stats.icrxdmtc += E1000_READ_REG(&adapter->hw, E1000_ICRXDMTC); - adapter->stats.icrxoc += E1000_READ_REG(&adapter->hw, E1000_ICRXOC); - - if (adapter->hw.mac.type >= e1000_82543) { - adapter->stats.algnerrc += - E1000_READ_REG(&adapter->hw, E1000_ALGNERRC); - adapter->stats.rxerrc += - E1000_READ_REG(&adapter->hw, E1000_RXERRC); - adapter->stats.tncrs += - E1000_READ_REG(&adapter->hw, E1000_TNCRS); - adapter->stats.cexterr += - E1000_READ_REG(&adapter->hw, E1000_CEXTERR); - adapter->stats.tsctc += - E1000_READ_REG(&adapter->hw, E1000_TSCTC); - adapter->stats.tsctfc += - E1000_READ_REG(&adapter->hw, E1000_TSCTFC); + sc->stats.iac += E1000_READ_REG(&sc->hw, E1000_IAC); + sc->stats.icrxptc += E1000_READ_REG(&sc->hw, E1000_ICRXPTC); + sc->stats.icrxatc += E1000_READ_REG(&sc->hw, E1000_ICRXATC); + sc->stats.ictxptc += E1000_READ_REG(&sc->hw, E1000_ICTXPTC); + sc->stats.ictxatc += E1000_READ_REG(&sc->hw, E1000_ICTXATC); + sc->stats.ictxqec += E1000_READ_REG(&sc->hw, E1000_ICTXQEC); + sc->stats.ictxqmtc += E1000_READ_REG(&sc->hw, E1000_ICTXQMTC); + sc->stats.icrxdmtc += E1000_READ_REG(&sc->hw, E1000_ICRXDMTC); + sc->stats.icrxoc += E1000_READ_REG(&sc->hw, E1000_ICRXOC); + + if (sc->hw.mac.type >= e1000_82543) { + sc->stats.algnerrc += + E1000_READ_REG(&sc->hw, E1000_ALGNERRC); + sc->stats.rxerrc += + E1000_READ_REG(&sc->hw, E1000_RXERRC); + sc->stats.tncrs += + E1000_READ_REG(&sc->hw, E1000_TNCRS); + sc->stats.cexterr += + E1000_READ_REG(&sc->hw, E1000_CEXTERR); + sc->stats.tsctc += + E1000_READ_REG(&sc->hw, E1000_TSCTC); + sc->stats.tsctfc += + E1000_READ_REG(&sc->hw, E1000_TSCTFC); } } static uint64_t em_if_get_counter(if_ctx_t ctx, ift_counter cnt) { - struct adapter *adapter = iflib_get_softc(ctx); + struct e1000_softc *sc = iflib_get_softc(ctx); struct ifnet *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.cexterr); + return (sc->dropped_pkts + sc->stats.rxerrc + + sc->stats.crcerrs + sc->stats.algnerrc + + sc->stats.ruc + sc->stats.roc + + sc->stats.mpc + sc->stats.cexterr); 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)); } @@ -4195,11 +4195,11 @@ static int em_sysctl_reg_handler(SYSCTL_HANDLER_ARGS) { - struct adapter *adapter; + struct e1000_softc *sc; u_int val; - adapter = oidp->oid_arg1; - val = E1000_READ_REG(&adapter->hw, oidp->oid_arg2); + sc = oidp->oid_arg1; + val = E1000_READ_REG(&sc->hw, oidp->oid_arg2); return (sysctl_handle_int(oidp, &val, 0, req)); } @@ -4207,16 +4207,16 @@ * Add sysctl variables, one per statistic, to the system. */ static void -em_add_hw_stats(struct adapter *adapter) +em_add_hw_stats(struct e1000_softc *sc) { - device_t dev = iflib_get_dev(adapter->ctx); - struct em_tx_queue *tx_que = adapter->tx_queues; - struct em_rx_queue *rx_que = adapter->rx_queues; + device_t dev = iflib_get_dev(sc->ctx); + struct em_tx_queue *tx_que = sc->tx_queues; + struct em_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 e1000_hw_stats *stats = &adapter->stats; + struct e1000_hw_stats *stats = &sc->stats; struct sysctl_oid *stat_node, *queue_node, *int_node; struct sysctl_oid_list *stat_list, *queue_list, *int_list; @@ -4226,33 +4226,33 @@ /* 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, E1000_CTRL, em_sysctl_reg_handler, "IU", + sc, E1000_CTRL, em_sysctl_reg_handler, "IU", "Device Control Register"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rx_control", CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, - adapter, E1000_RCTL, em_sysctl_reg_handler, "IU", + sc, E1000_RCTL, em_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, @@ -4260,11 +4260,11 @@ queue_list = SYSCTL_CHILDREN(queue_node); SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "txd_head", - CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, E1000_TDH(txr->me), em_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, E1000_TDT(txr->me), em_sysctl_reg_handler, "IU", "Transmit Descriptor Tail"); SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, "tx_irq", @@ -4272,7 +4272,7 @@ "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, @@ -4280,11 +4280,11 @@ queue_list = SYSCTL_CHILDREN(queue_node); SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rxd_head", - CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, E1000_RDH(rxr->me), em_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, E1000_RDT(rxr->me), em_sysctl_reg_handler, "IU", "Receive Descriptor Tail"); SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, "rx_irq", @@ -4314,132 +4314,132 @@ 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_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"); /* On 82575 these are collision counts */ SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "coll_ext_errs", - CTLFLAG_RD, &adapter->stats.cexterr, + CTLFLAG_RD, &sc->stats.cexterr, "Collision/Carrier extension 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"); /* 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"); SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "tso_ctx_fail", - CTLFLAG_RD, &adapter->stats.tsctfc, + CTLFLAG_RD, &sc->stats.tsctfc, "TSO Contexts Failed"); @@ -4450,39 +4450,39 @@ 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_pkt_timer", - CTLFLAG_RD, &adapter->stats.icrxptc, + CTLFLAG_RD, &sc->stats.icrxptc, "Interrupt Cause Rx Pkt Timer Expire Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "rx_abs_timer", - CTLFLAG_RD, &adapter->stats.icrxatc, + CTLFLAG_RD, &sc->stats.icrxatc, "Interrupt Cause Rx Abs Timer Expire Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "tx_pkt_timer", - CTLFLAG_RD, &adapter->stats.ictxptc, + CTLFLAG_RD, &sc->stats.ictxptc, "Interrupt Cause Tx Pkt Timer Expire Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "tx_abs_timer", - CTLFLAG_RD, &adapter->stats.ictxatc, + CTLFLAG_RD, &sc->stats.ictxatc, "Interrupt Cause Tx Abs Timer Expire Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "tx_queue_empty", - CTLFLAG_RD, &adapter->stats.ictxqec, + CTLFLAG_RD, &sc->stats.ictxqec, "Interrupt Cause Tx Queue Empty Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "tx_queue_min_thresh", - CTLFLAG_RD, &adapter->stats.ictxqmtc, + CTLFLAG_RD, &sc->stats.ictxqmtc, "Interrupt Cause Tx Queue Min Thresh Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "rx_desc_min_thresh", - CTLFLAG_RD, &adapter->stats.icrxdmtc, + CTLFLAG_RD, &sc->stats.icrxdmtc, "Interrupt Cause Rx Desc Min Thresh Count"); SYSCTL_ADD_UQUAD(ctx, int_list, OID_AUTO, "rx_overrun", - CTLFLAG_RD, &adapter->stats.icrxoc, + CTLFLAG_RD, &sc->stats.icrxoc, "Interrupt Cause Receiver Overrun Count"); } @@ -4496,7 +4496,7 @@ static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS) { - struct adapter *adapter = (struct adapter *)arg1; + struct e1000_softc *sc = (struct e1000_softc *)arg1; int error; int result; @@ -4512,13 +4512,13 @@ * the screen. */ if (result == 1) - em_print_nvm_info(adapter); + em_print_nvm_info(sc); return (error); } static void -em_print_nvm_info(struct adapter *adapter) +em_print_nvm_info(struct e1000_softc *sc) { u16 eeprom_data; int i, j, row = 0; @@ -4531,7 +4531,7 @@ j = 0; ++row; printf("\n0x00%x0 ",row); } - e1000_read_nvm(&adapter->hw, i, 1, &eeprom_data); + e1000_read_nvm(&sc->hw, i, 1, &eeprom_data); printf("%04x ", eeprom_data); } printf("\n"); @@ -4541,7 +4541,7 @@ em_sysctl_int_delay(SYSCTL_HANDLER_ARGS) { struct em_int_delay_info *info; - struct adapter *adapter; + struct e1000_softc *sc; u32 regval; int error, usecs, ticks; @@ -4557,9 +4557,9 @@ if (info->offset == E1000_ITR) /* units are 256ns here */ ticks *= 4; - adapter = info->adapter; + sc = info->sc; - regval = E1000_READ_OFFSET(&adapter->hw, info->offset); + regval = E1000_READ_OFFSET(&sc->hw, info->offset); regval = (regval & ~0xffff) | (ticks & 0xffff); /* Handle a few special cases. */ switch (info->offset) { @@ -4567,27 +4567,27 @@ break; case E1000_TIDV: if (ticks == 0) { - adapter->txd_cmd &= ~E1000_TXD_CMD_IDE; + sc->txd_cmd &= ~E1000_TXD_CMD_IDE; /* Don't write 0 into the TIDV register. */ regval++; } else - adapter->txd_cmd |= E1000_TXD_CMD_IDE; + sc->txd_cmd |= E1000_TXD_CMD_IDE; break; } - E1000_WRITE_OFFSET(&adapter->hw, info->offset, regval); + E1000_WRITE_OFFSET(&sc->hw, info->offset, regval); return (0); } static void -em_add_int_delay_sysctl(struct adapter *adapter, const char *name, +em_add_int_delay_sysctl(struct e1000_softc *sc, const char *name, const char *description, struct em_int_delay_info *info, int offset, int value) { - info->adapter = adapter; + info->sc = sc; info->offset = offset; info->value = value; - SYSCTL_ADD_PROC(device_get_sysctl_ctx(adapter->dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(adapter->dev)), + SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc->dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, name, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, info, 0, em_sysctl_int_delay, "I", description); } @@ -4605,14 +4605,14 @@ { int error; static int input = 3; /* default is full */ - struct adapter *adapter = (struct adapter *) arg1; + struct e1000_softc *sc = (struct e1000_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) { @@ -4620,16 +4620,16 @@ case e1000_fc_tx_pause: case e1000_fc_full: case e1000_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; - e1000_force_mac_fc(&adapter->hw); + sc->hw.fc.current_mode = sc->hw.fc.requested_mode; + e1000_force_mac_fc(&sc->hw); return (error); } @@ -4641,15 +4641,15 @@ static int em_sysctl_eee(SYSCTL_HANDLER_ARGS) { - struct adapter *adapter = (struct adapter *) arg1; + struct e1000_softc *sc = (struct e1000_softc *) arg1; int error, value; - value = adapter->hw.dev_spec.ich8lan.eee_disable; + value = sc->hw.dev_spec.ich8lan.eee_disable; error = sysctl_handle_int(oidp, &value, 0, req); if (error || req->newptr == NULL) return (error); - adapter->hw.dev_spec.ich8lan.eee_disable = (value != 0); - em_if_init(adapter->ctx); + sc->hw.dev_spec.ich8lan.eee_disable = (value != 0); + em_if_init(sc->ctx); return (0); } @@ -4657,7 +4657,7 @@ static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS) { - struct adapter *adapter; + struct e1000_softc *sc; int error; int result; @@ -4668,8 +4668,8 @@ return (error); if (result == 1) { - adapter = (struct adapter *) arg1; - em_print_debug_info(adapter); + sc = (struct e1000_softc *) arg1; + em_print_debug_info(sc); } return (error); @@ -4678,7 +4678,7 @@ static int em_get_rs(SYSCTL_HANDLER_ARGS) { - struct adapter *adapter = (struct adapter *) arg1; + struct e1000_softc *sc = (struct e1000_softc *) arg1; int error; int result; @@ -4687,7 +4687,7 @@ if (error || !req->newptr || result != 1) return (error); - em_dump_rs(adapter); + em_dump_rs(sc); return (error); } @@ -4703,12 +4703,12 @@ * needed for debugging a problem. -jfv */ static void -em_print_debug_info(struct adapter *adapter) +em_print_debug_info(struct e1000_softc *sc) { - device_t dev = iflib_get_dev(adapter->ctx); - struct ifnet *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); + struct ifnet *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 "); @@ -4720,18 +4720,18 @@ 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", - E1000_READ_REG(&adapter->hw, E1000_TDH(i)), - E1000_READ_REG(&adapter->hw, E1000_TDT(i))); + E1000_READ_REG(&sc->hw, E1000_TDH(i)), + E1000_READ_REG(&sc->hw, E1000_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", - E1000_READ_REG(&adapter->hw, E1000_RDH(j)), - E1000_READ_REG(&adapter->hw, E1000_RDT(j))); + E1000_READ_REG(&sc->hw, E1000_RDH(j)), + E1000_READ_REG(&sc->hw, E1000_RDT(j))); } } @@ -4743,8 +4743,8 @@ static void em_enable_vectors_82574(if_ctx_t ctx) { - struct adapter *adapter = iflib_get_softc(ctx); - struct e1000_hw *hw = &adapter->hw; + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; device_t dev = iflib_get_dev(ctx); u16 edata; diff --git a/sys/dev/e1000/igb_txrx.c b/sys/dev/e1000/igb_txrx.c --- a/sys/dev/e1000/igb_txrx.c +++ b/sys/dev/e1000/igb_txrx.c @@ -89,7 +89,7 @@ uint32_t *olinfo_status) { struct e1000_adv_tx_context_desc *TXD; - struct adapter *adapter = txr->adapter; + struct e1000_softc *sc = txr->sc; uint32_t type_tucmd_mlhl = 0, vlan_macip_lens = 0; uint32_t mss_l4len_idx = 0; uint32_t paylen; @@ -132,7 +132,7 @@ mss_l4len_idx |= (pi->ipi_tso_segsz << E1000_ADVTXD_MSS_SHIFT); mss_l4len_idx |= (pi->ipi_tcp_hlen << E1000_ADVTXD_L4LEN_SHIFT); /* 82575 needs the queue index added */ - if (adapter->hw.mac.type == e1000_82575) + if (sc->hw.mac.type == e1000_82575) mss_l4len_idx |= txr->me << 4; TXD->mss_l4len_idx = htole32(mss_l4len_idx); @@ -154,7 +154,7 @@ uint32_t *olinfo_status) { struct e1000_adv_tx_context_desc *TXD; - struct adapter *adapter = txr->adapter; + struct e1000_softc *sc = txr->sc; uint32_t vlan_macip_lens, type_tucmd_mlhl; uint32_t mss_l4len_idx; mss_l4len_idx = vlan_macip_lens = type_tucmd_mlhl = 0; @@ -221,7 +221,7 @@ } /* 82575 needs the queue index added */ - if (adapter->hw.mac.type == e1000_82575) + if (sc->hw.mac.type == e1000_82575) mss_l4len_idx = txr->me << 4; /* Now copy bits into descriptor */ @@ -236,7 +236,7 @@ static int igb_isc_txd_encap(void *arg, if_pkt_info_t pi) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct em_tx_queue *que = &sc->tx_queues[pi->ipi_qsidx]; struct tx_ring *txr = &que->txr; @@ -299,19 +299,19 @@ static void igb_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx) { - struct adapter *adapter = arg; - struct em_tx_queue *que = &adapter->tx_queues[txqid]; + struct e1000_softc *sc = arg; + struct em_tx_queue *que = &sc->tx_queues[txqid]; struct tx_ring *txr = &que->txr; - E1000_WRITE_REG(&adapter->hw, E1000_TDT(txr->me), pidx); + E1000_WRITE_REG(&sc->hw, E1000_TDT(txr->me), pidx); } static int igb_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear) { - struct adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct em_tx_queue *que = &adapter->tx_queues[txqid]; + struct e1000_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct em_tx_queue *que = &sc->tx_queues[txqid]; struct tx_ring *txr = &que->txr; qidx_t processed = 0; @@ -361,7 +361,7 @@ static void igb_isc_rxd_refill(void *arg, if_rxd_update_t iru) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; uint16_t rxqid = iru->iru_qsidx; struct em_rx_queue *que = &sc->rx_queues[rxqid]; @@ -388,7 +388,7 @@ static void igb_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; struct em_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -398,7 +398,7 @@ static int igb_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) { - struct adapter *sc = arg; + struct e1000_softc *sc = arg; if_softc_ctx_t scctx = sc->shared; struct em_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; @@ -430,9 +430,9 @@ static int igb_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) { - struct adapter *adapter = arg; - if_softc_ctx_t scctx = adapter->shared; - struct em_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx]; + struct e1000_softc *sc = arg; + if_softc_ctx_t scctx = sc->shared; + struct em_rx_queue *que = &sc->rx_queues[ri->iri_qsidx]; struct rx_ring *rxr = &que->rxr; union e1000_adv_rx_desc *rxd; @@ -460,8 +460,8 @@ rxd->wb.upper.status_error = 0; eop = ((staterr & E1000_RXD_STAT_EOP) == E1000_RXD_STAT_EOP); - if (((adapter->hw.mac.type == e1000_i350) || - (adapter->hw.mac.type == e1000_i354)) && + if (((sc->hw.mac.type == e1000_i350) || + (sc->hw.mac.type == e1000_i354)) && (staterr & E1000_RXDEXT_STATERR_LB)) vtag = be16toh(rxd->wb.upper.vlan); else @@ -469,7 +469,7 @@ /* Make sure bad packets are discarded */ if (eop && ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) != 0)) { - adapter->dropped_pkts++; + sc->dropped_pkts++; ++rxr->rx_discarded; return (EBADMSG); }