Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/e1000/if_em.c
| Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | |||||
| static int igb_if_rx_queue_intr_enable(if_ctx_t, uint16_t); | static int igb_if_rx_queue_intr_enable(if_ctx_t, uint16_t); | ||||
| static int igb_if_tx_queue_intr_enable(if_ctx_t, uint16_t); | static int igb_if_tx_queue_intr_enable(if_ctx_t, uint16_t); | ||||
| static void em_if_multi_set(if_ctx_t); | static void em_if_multi_set(if_ctx_t); | ||||
| static void em_if_update_admin_status(if_ctx_t); | static void em_if_update_admin_status(if_ctx_t); | ||||
| static void em_if_debug(if_ctx_t); | static void em_if_debug(if_ctx_t); | ||||
| static void em_update_stats_counters(struct e1000_softc *); | static void em_update_stats_counters(struct e1000_softc *); | ||||
| static void em_add_hw_stats(struct e1000_softc *); | static void em_add_hw_stats(struct e1000_softc *); | ||||
| static int em_if_set_promisc(if_ctx_t, int); | static int em_if_set_promisc(if_ctx_t, int); | ||||
| static bool em_if_vlan_filter_capable(struct e1000_softc *); | static bool em_if_vlan_filter_capable(if_ctx_t); | ||||
| static bool em_if_vlan_filter_used(struct e1000_softc *); | static bool em_if_vlan_filter_used(if_ctx_t); | ||||
| static void em_if_vlan_filter_enable(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_disable(struct e1000_softc *); | ||||
| static void em_if_vlan_filter_write(struct e1000_softc *); | static void em_if_vlan_filter_write(struct e1000_softc *); | ||||
| static void em_setup_vlan_hw_support(struct e1000_softc *); | static void em_setup_vlan_hw_support(if_ctx_t ctx); | ||||
| static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); | static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); | ||||
| static void em_print_nvm_info(struct e1000_softc *); | static void em_print_nvm_info(struct e1000_softc *); | ||||
| static void em_fw_version_locked(if_ctx_t); | static void em_fw_version_locked(if_ctx_t); | ||||
| static void em_sbuf_fw_version(struct e1000_fw_version *, struct sbuf *); | static void em_sbuf_fw_version(struct e1000_fw_version *, struct sbuf *); | ||||
| static void em_print_fw_version(struct e1000_softc *); | static void em_print_fw_version(struct e1000_softc *); | ||||
| static int em_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS); | static int em_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS); | ||||
| static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); | static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); | ||||
| static int em_get_rs(SYSCTL_HANDLER_ARGS); | static int em_get_rs(SYSCTL_HANDLER_ARGS); | ||||
| ▲ Show 20 Lines • Show All 596 Lines • ▼ Show 20 Lines | if (hw->mac.type >= igb_mac_min) { | ||||
| } | } | ||||
| } else { | } else { | ||||
| scctx->isc_txqsizes[0] = roundup2((scctx->isc_ntxd[0] + 1) * sizeof(struct e1000_tx_desc), EM_DBA_ALIGN); | scctx->isc_txqsizes[0] = roundup2((scctx->isc_ntxd[0] + 1) * sizeof(struct e1000_tx_desc), EM_DBA_ALIGN); | ||||
| scctx->isc_rxqsizes[0] = roundup2((scctx->isc_nrxd[0] + 1) * sizeof(struct e1000_rx_desc), EM_DBA_ALIGN); | scctx->isc_rxqsizes[0] = roundup2((scctx->isc_nrxd[0] + 1) * sizeof(struct e1000_rx_desc), EM_DBA_ALIGN); | ||||
| scctx->isc_txd_size[0] = sizeof(struct e1000_tx_desc); | scctx->isc_txd_size[0] = sizeof(struct e1000_tx_desc); | ||||
| scctx->isc_rxd_size[0] = sizeof(struct e1000_rx_desc); | scctx->isc_rxd_size[0] = sizeof(struct e1000_rx_desc); | ||||
| scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP; | scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP; | ||||
| scctx->isc_txrx = &lem_txrx; | scctx->isc_txrx = &lem_txrx; | ||||
| scctx->isc_capabilities = scctx->isc_capenable = LEM_CAPS; | scctx->isc_capabilities = LEM_CAPS; | ||||
| if (hw->mac.type < e1000_82543) | if (hw->mac.type < e1000_82543) | ||||
| scctx->isc_capenable &= ~(IFCAP_HWCSUM|IFCAP_VLAN_HWCSUM); | scctx->isc_capabilities &= ~(IFCAP_HWCSUM|IFCAP_VLAN_HWCSUM); | ||||
| /* 82541ER doesn't do HW tagging */ | /* 82541ER doesn't do HW tagging */ | ||||
| if (hw->device_id == E1000_DEV_ID_82541ER || hw->device_id == E1000_DEV_ID_82541ER_LOM) | if (hw->device_id == E1000_DEV_ID_82541ER || hw->device_id == E1000_DEV_ID_82541ER_LOM) | ||||
| scctx->isc_capenable &= ~IFCAP_VLAN_HWTAGGING; | scctx->isc_capabilities &= ~IFCAP_VLAN_HWTAGGING; | ||||
| /* INTx only */ | /* INTx only */ | ||||
| scctx->isc_msix_bar = 0; | scctx->isc_msix_bar = 0; | ||||
| scctx->isc_capenable = scctx->isc_capabilities; | |||||
| } | } | ||||
| /* Setup PCI resources */ | /* Setup PCI resources */ | ||||
markj: Stray newline. | |||||
Done Inline ActionsThanks, I'll apply this before committing vmaffione: Thanks, I'll apply this before committing | |||||
| if (em_allocate_pci_resources(ctx)) { | if (em_allocate_pci_resources(ctx)) { | ||||
| device_printf(dev, "Allocation of PCI resources failed\n"); | device_printf(dev, "Allocation of PCI resources failed\n"); | ||||
| error = ENXIO; | error = ENXIO; | ||||
| goto err_pci; | goto err_pci; | ||||
| } | } | ||||
| /* | /* | ||||
| ** For ICH8 and family we need to | ** For ICH8 and family we need to | ||||
| ▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | em_if_init(if_ctx_t ctx) | ||||
| /* Setup Multicast table */ | /* Setup Multicast table */ | ||||
| em_if_multi_set(ctx); | em_if_multi_set(ctx); | ||||
| sc->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); | sc->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); | ||||
| em_initialize_receive_unit(ctx); | em_initialize_receive_unit(ctx); | ||||
| /* Set up VLAN support and filter */ | /* Set up VLAN support and filter */ | ||||
| em_setup_vlan_hw_support(sc); | em_setup_vlan_hw_support(ctx); | ||||
| /* Don't lose promiscuous settings */ | /* Don't lose promiscuous settings */ | ||||
| em_if_set_promisc(ctx, if_getflags(ifp)); | em_if_set_promisc(ctx, if_getflags(ifp)); | ||||
| e1000_clear_hw_cntrs_base_generic(&sc->hw); | e1000_clear_hw_cntrs_base_generic(&sc->hw); | ||||
| /* MSI-X configuration for 82574 */ | /* MSI-X configuration for 82574 */ | ||||
| if (sc->hw.mac.type == e1000_82574) { | if (sc->hw.mac.type == e1000_82574) { | ||||
| int tmp = E1000_READ_REG(&sc->hw, E1000_CTRL_EXT); | int tmp = E1000_READ_REG(&sc->hw, E1000_CTRL_EXT); | ||||
| ▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | if (em_debug_sbp) | ||||
| reg_rctl |= E1000_RCTL_SBP; | reg_rctl |= E1000_RCTL_SBP; | ||||
| E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); | E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); | ||||
| } else { | } else { | ||||
| if (flags & IFF_ALLMULTI) { | if (flags & IFF_ALLMULTI) { | ||||
| reg_rctl |= E1000_RCTL_MPE; | reg_rctl |= E1000_RCTL_MPE; | ||||
| reg_rctl &= ~E1000_RCTL_UPE; | reg_rctl &= ~E1000_RCTL_UPE; | ||||
| E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); | E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); | ||||
| } | } | ||||
| if (em_if_vlan_filter_used(sc)) | if (em_if_vlan_filter_used(ctx)) | ||||
| em_if_vlan_filter_enable(sc); | em_if_vlan_filter_enable(sc); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static u_int | static u_int | ||||
| em_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int idx) | em_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int idx) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,542 Lines • ▼ Show 20 Lines | if (hw->mac.type == e1000_82574) { | ||||
| /* Disable accelerated acknowledge */ | /* Disable accelerated acknowledge */ | ||||
| rfctl |= E1000_RFCTL_ACK_DIS; | rfctl |= E1000_RFCTL_ACK_DIS; | ||||
| } | } | ||||
| E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); | E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); | ||||
| } | } | ||||
| /* Set up L3 and L4 csum Rx descriptor offloads */ | /* Set up L3 and L4 csum Rx descriptor offloads */ | ||||
| rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); | rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); | ||||
| if (scctx->isc_capenable & IFCAP_RXCSUM) { | if (if_getcapenable(ifp) & IFCAP_RXCSUM) { | ||||
| rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; | rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; | ||||
| if (hw->mac.type > e1000_82575) | if (hw->mac.type > e1000_82575) | ||||
| rxcsum |= E1000_RXCSUM_CRCOFL; | rxcsum |= E1000_RXCSUM_CRCOFL; | ||||
| else if (hw->mac.type < em_mac_min && | else if (hw->mac.type < em_mac_min && | ||||
| scctx->isc_capenable & IFCAP_HWCSUM_IPV6) | if_getcapenable(ifp) & IFCAP_HWCSUM_IPV6) | ||||
| rxcsum |= E1000_RXCSUM_IPV6OFL; | rxcsum |= E1000_RXCSUM_IPV6OFL; | ||||
| } else { | } else { | ||||
| rxcsum &= ~(E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); | rxcsum &= ~(E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); | ||||
| if (hw->mac.type > e1000_82575) | if (hw->mac.type > e1000_82575) | ||||
| rxcsum &= ~E1000_RXCSUM_CRCOFL; | rxcsum &= ~E1000_RXCSUM_CRCOFL; | ||||
| else if (hw->mac.type < em_mac_min) | else if (hw->mac.type < em_mac_min) | ||||
| rxcsum &= ~E1000_RXCSUM_IPV6OFL; | rxcsum &= ~E1000_RXCSUM_IPV6OFL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | em_if_vlan_unregister(if_ctx_t ctx, u16 vtag) | ||||
| index = (vtag >> 5) & 0x7F; | index = (vtag >> 5) & 0x7F; | ||||
| bit = vtag & 0x1F; | bit = vtag & 0x1F; | ||||
| sc->shadow_vfta[index] &= ~(1 << bit); | sc->shadow_vfta[index] &= ~(1 << bit); | ||||
| --sc->num_vlans; | --sc->num_vlans; | ||||
| em_if_vlan_filter_write(sc); | em_if_vlan_filter_write(sc); | ||||
| } | } | ||||
| static bool | static bool | ||||
| em_if_vlan_filter_capable(struct e1000_softc *sc) | em_if_vlan_filter_capable(if_ctx_t ctx) | ||||
| { | { | ||||
| if_softc_ctx_t scctx = sc->shared; | if_t ifp = iflib_get_ifp(ctx); | ||||
| if ((scctx->isc_capenable & IFCAP_VLAN_HWFILTER) && | if ((if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) && | ||||
| !em_disable_crc_stripping) | !em_disable_crc_stripping) | ||||
| return (true); | return (true); | ||||
| return (false); | return (false); | ||||
| } | } | ||||
| static bool | static bool | ||||
| em_if_vlan_filter_used(struct e1000_softc *sc) | em_if_vlan_filter_used(if_ctx_t ctx) | ||||
| { | { | ||||
| if (!em_if_vlan_filter_capable(sc)) | struct e1000_softc *sc = iflib_get_softc(ctx); | ||||
| if (!em_if_vlan_filter_capable(ctx)) | |||||
| return (false); | return (false); | ||||
| for (int i = 0; i < EM_VFTA_SIZE; i++) | for (int i = 0; i < EM_VFTA_SIZE; i++) | ||||
| if (sc->shadow_vfta[i] != 0) | if (sc->shadow_vfta[i] != 0) | ||||
| return (true); | return (true); | ||||
| return (false); | return (false); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | for (int i = 0; i < EM_VFTA_SIZE; i++) | ||||
| } | } | ||||
| /* Re-enable interrupts for lem-class devices */ | /* Re-enable interrupts for lem-class devices */ | ||||
| if (hw->mac.type < em_mac_min) | if (hw->mac.type < em_mac_min) | ||||
| em_if_intr_enable(sc->ctx); | em_if_intr_enable(sc->ctx); | ||||
| } | } | ||||
| static void | static void | ||||
| em_setup_vlan_hw_support(struct e1000_softc *sc) | em_setup_vlan_hw_support(if_ctx_t ctx) | ||||
| { | { | ||||
| if_softc_ctx_t scctx = sc->shared; | struct e1000_softc *sc = iflib_get_softc(ctx); | ||||
| struct e1000_hw *hw = &sc->hw; | struct e1000_hw *hw = &sc->hw; | ||||
| struct ifnet *ifp = iflib_get_ifp(ctx); | |||||
| u32 reg; | u32 reg; | ||||
| /* XXXKB: Return early if we are a VF until VF decap and filter management | /* XXXKB: Return early if we are a VF until VF decap and filter management | ||||
| * is ready and tested. | * is ready and tested. | ||||
| */ | */ | ||||
| if (sc->vf_ifp) | if (sc->vf_ifp) | ||||
| return; | return; | ||||
| if (scctx->isc_capenable & IFCAP_VLAN_HWTAGGING && | if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING && | ||||
| !em_disable_crc_stripping) { | !em_disable_crc_stripping) { | ||||
| reg = E1000_READ_REG(hw, E1000_CTRL); | reg = E1000_READ_REG(hw, E1000_CTRL); | ||||
| reg |= E1000_CTRL_VME; | reg |= E1000_CTRL_VME; | ||||
| E1000_WRITE_REG(hw, E1000_CTRL, reg); | E1000_WRITE_REG(hw, E1000_CTRL, reg); | ||||
| } else { | } else { | ||||
| reg = E1000_READ_REG(hw, E1000_CTRL); | reg = E1000_READ_REG(hw, E1000_CTRL); | ||||
| reg &= ~E1000_CTRL_VME; | reg &= ~E1000_CTRL_VME; | ||||
| E1000_WRITE_REG(hw, E1000_CTRL, reg); | E1000_WRITE_REG(hw, E1000_CTRL, reg); | ||||
| } | } | ||||
| /* If we aren't doing HW filtering, we're done */ | /* If we aren't doing HW filtering, we're done */ | ||||
| if (!em_if_vlan_filter_capable(sc)) { | if (!em_if_vlan_filter_capable(ctx)) { | ||||
| em_if_vlan_filter_disable(sc); | em_if_vlan_filter_disable(sc); | ||||
| return; | return; | ||||
| } | } | ||||
| /* | /* | ||||
| * A soft reset zero's out the VFTA, so | * A soft reset zero's out the VFTA, so | ||||
| * we need to repopulate it now. | * we need to repopulate it now. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 1,335 Lines • Show Last 20 Lines | |||||
Stray newline.