diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-03-27 16:38:14 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-03-27 16:38:14 +0000 |
commit | 8d982b0f2653412ba3d16fac78c8f98a96963394 (patch) | |
tree | fb6c048b37eba75a8e79f4c2ae769fc95e896bfc /sys/dev | |
parent | a63d839b7a4981e0a891868c8b363232c2e20607 (diff) |
remove FreeBSD ifdef bloat.
ok krw@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_em.c | 926 | ||||
-rw-r--r-- | sys/dev/pci/if_em.h | 59 | ||||
-rw-r--r-- | sys/dev/pci/if_em_hw.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_em_hw.h | 10 |
4 files changed, 22 insertions, 979 deletions
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index 417421f62b2..079d048ed71 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ -/* $OpenBSD: if_em.c,v 1.40 2005/03/26 23:04:58 brad Exp $ */ +/* $OpenBSD: if_em.c,v 1.41 2005/03/27 16:38:13 brad Exp $ */ #include "bpfilter.h" #include "vlan.h" @@ -93,68 +93,6 @@ struct em_softc *em_adapter_list = NULL; char em_driver_version[] = "1.7.35"; -#ifdef __FreeBSD__ -/********************************************************************* - * PCI Device ID Table - * - * Used by probe to select devices to load on - * Last field stores an index into em_strings - * Last entry must be all 0s - * - * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, String Index } - *********************************************************************/ - -em_vendor_info_t em_vendor_info_array[] = -{ - /* Intel(R) PRO/1000 Network Connection */ - { 0x8086, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1004, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1008, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1009, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x100C, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x100D, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x100E, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x100F, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1010, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1011, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1012, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1013, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1014, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1015, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1016, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1017, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1018, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1019, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x101A, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x101D, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x101E, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1026, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1027, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1028, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1075, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1076, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1077, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1078, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x1079, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x107A, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x107B, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x107C, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, 0x108A, PCI_ANY_ID, PCI_ANY_ID, 0}, - /* required last entry */ - { 0, 0, 0, 0, 0} -}; - -/********************************************************************* - * Table of branding strings for all supported NICs. - *********************************************************************/ - -char *em_strings[] = { - "Intel(R) PRO/1000 Network Connection" -}; -#endif /* __FreeBSD__ */ - -#ifdef __OpenBSD__ /********************************************************************* * PCI Device ID Table *********************************************************************/ @@ -194,24 +132,14 @@ const struct pci_matchid em_devices[] = { { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82546GB }, { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_PRO_1000_GT } }; -#endif /* __OpenBSD__ */ /********************************************************************* * Function prototypes *********************************************************************/ -#ifdef __FreeBSD__ -int em_probe(device_t); -int em_attach(device_t); -int em_detach(device_t); -int em_shutdown(device_t); -void em_intr(void *); -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ int em_probe(struct device *, void *, void *); void em_attach(struct device *, struct device *, void *); int em_intr(void *); void em_power(int, void *); -#endif /* __OpenBSD__ */ void em_start(struct ifnet *); void em_start_locked(struct ifnet *); int em_ioctl(struct ifnet *, u_long, caddr_t); @@ -226,12 +154,7 @@ int em_allocate_pci_resources(struct em_softc *); void em_free_pci_resources(struct em_softc *); void em_local_timer(void *); int em_hardware_init(struct em_softc *); -#ifdef __FreeBSD__ -void em_setup_interface(device_t, struct em_softc *); -#endif -#ifdef __OpenBSD__ void em_setup_interface(struct em_softc *); -#endif int em_setup_transmit_structures(struct em_softc *); void em_initialize_transmit_unit(struct em_softc *); int em_setup_receive_structures(struct em_softc *); @@ -273,45 +196,14 @@ int em_dma_malloc(struct em_softc *, bus_size_t, void em_dma_free(struct em_softc *, struct em_dma_alloc *); void em_print_debug_info(struct em_softc *); int em_is_valid_ether_addr(u_int8_t *); -#ifdef __FreeBSD__ -int em_sysctl_stats(SYSCTL_HANDLER_ARGS); -int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); -#endif /* __FreeBSD__ */ u_int32_t em_fill_descriptors (u_int64_t address, u_int32_t length, PDESC_ARRAY desc_array); -#ifdef __FreeBSD__ -int em_sysctl_int_delay(SYSCTL_HANDLER_ARGS); -void em_add_int_delay_sysctl(struct em_softc *, const char *, - const char *, struct em_int_delay_info *, - int, int); -#endif /* __FreeBSD__ */ /********************************************************************* - * FreeBSD Device Interface Entry Points + * OpenBSD Device Interface Entry Points *********************************************************************/ -#ifdef __FreeBSD__ -device_method_t em_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, em_probe), - DEVMETHOD(device_attach, em_attach), - DEVMETHOD(device_detach, em_detach), - DEVMETHOD(device_shutdown, em_shutdown), - {0, 0} -}; - -driver_t em_driver = { - "em", em_methods, sizeof(struct em_softc), -}; - -devclass_t em_devclass; -DRIVER_MODULE(em, pci, em_driver, em_devclass, 0, 0); -MODULE_DEPEND(em, pci, 1, 1, 1); -MODULE_DEPEND(em, ether, 1, 1, 1); -#endif /* __FreeBSD__ */ - -#ifdef __OpenBSD__ struct cfattach em_ca = { sizeof(struct em_softc), em_probe, em_attach }; @@ -319,7 +211,6 @@ struct cfattach em_ca = { struct cfdriver em_cd = { 0, "em", DV_IFNET }; -#endif /* __OpenBSD__ */ /********************************************************************* * Tunable default values. @@ -333,13 +224,6 @@ int em_rx_int_delay_dflt = E1000_TICKS_TO_USECS(EM_RDTR); int em_tx_abs_int_delay_dflt = E1000_TICKS_TO_USECS(EM_TADV); int em_rx_abs_int_delay_dflt = E1000_TICKS_TO_USECS(EM_RADV); -#ifdef __FreeBSD__ -TUNABLE_INT("hw.em.tx_int_delay", &em_tx_int_delay_dflt); -TUNABLE_INT("hw.em.rx_int_delay", &em_rx_int_delay_dflt); -TUNABLE_INT("hw.em.tx_abs_int_delay", &em_tx_abs_int_delay_dflt); -TUNABLE_INT("hw.em.rx_abs_int_delay", &em_rx_abs_int_delay_dflt); -#endif /* __FreeBSD__ */ - /********************************************************************* * Device identification routine * @@ -349,52 +233,6 @@ TUNABLE_INT("hw.em.rx_abs_int_delay", &em_rx_abs_int_delay_dflt); * return 0 on success, positive on failure *********************************************************************/ -#ifdef __FreeBSD__ -int -em_probe(device_t dev) -{ - em_vendor_info_t *ent; - - u_int16_t pci_vendor_id = 0; - u_int16_t pci_device_id = 0; - u_int16_t pci_subvendor_id = 0; - u_int16_t pci_subdevice_id = 0; - char adapter_name[60]; - - INIT_DEBUGOUT("em_probe: begin"); - - pci_vendor_id = pci_get_vendor(dev); - if (pci_vendor_id != EM_VENDOR_ID) - return(ENXIO); - - pci_device_id = pci_get_device(dev); - pci_subvendor_id = pci_get_subvendor(dev); - pci_subdevice_id = pci_get_subdevice(dev); - - ent = em_vendor_info_array; - while (ent->vendor_id != 0) { - if ((pci_vendor_id == ent->vendor_id) && - (pci_device_id == ent->device_id) && - - ((pci_subvendor_id == ent->subvendor_id) || - (ent->subvendor_id == PCI_ANY_ID)) && - - ((pci_subdevice_id == ent->subdevice_id) || - (ent->subdevice_id == PCI_ANY_ID))) { - sprintf(adapter_name, "%s, Version - %s", - em_strings[ent->index], - em_driver_version); - device_set_desc_copy(dev, adapter_name); - return(0); - } - ent++; - } - - return(ENXIO); -} -#endif /* __FreeBSD__ */ - -#ifdef __OpenBSD__ int em_probe(struct device *parent, void *match, void *aux) { @@ -403,7 +241,6 @@ em_probe(struct device *parent, void *match, void *aux) return (pci_matchbyid((struct pci_attach_args *)aux, em_devices, sizeof(em_devices)/sizeof(em_devices[0]))); } -#endif /* __OpenBSD__ */ /********************************************************************* * Device initialization routine @@ -415,108 +252,30 @@ em_probe(struct device *parent, void *match, void *aux) * return 0 on success, positive on failure *********************************************************************/ -#ifdef __FreeBSD__ -int -em_attach(device_t dev) -{ - pci_chipset_tag_t pc = pa->pa_pc; -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ void em_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; -#endif /* __OpenBSD__ */ struct em_softc *sc; int tsize, rsize; int error = 0; INIT_DEBUGOUT("em_attach: begin"); -#ifdef __FreeBSD__ - /* Allocate, clear, and link in our sc structure */ - if (!(sc = device_get_softc(dev))) { - printf("em: sc structure allocation failed\n"); - return(ENOMEM); - } - bzero(sc, sizeof(struct em_softc)); - sc->dev = dev; - sc->osdep.dev = dev; - sc->sc_dv.dv_xname = device_get_unit(dev); - EM_LOCK_INIT(sc, device_get_nameunit(dev)); -#endif /* __FreeBSD__ */ - - -#ifdef __OpenBSD__ sc = (struct em_softc *)self; sc->osdep.em_pa = *pa; -#endif if (em_adapter_list != NULL) em_adapter_list->prev = sc; sc->next = em_adapter_list; em_adapter_list = sc; -#ifdef __FreeBSD__ - /* SYSCTL stuff */ - sysctl_ctx_init(&sc->sysctl_ctx); - sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, - SYSCTL_STATIC_CHILDREN(_hw), - OID_AUTO, - device_get_nameunit(dev), - CTLFLAG_RD, - 0, ""); - if (sc->sysctl_tree == NULL) { - error = EIO; - goto err_sysctl; - } - - SYSCTL_ADD_PROC(&sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), - OID_AUTO, "debug_info", CTLTYPE_INT|CTLFLAG_RW, - (void *)sc, 0, - em_sysctl_debug_info, "I", "Debug Information"); - - SYSCTL_ADD_PROC(&sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), - OID_AUTO, "stats", CTLTYPE_INT|CTLFLAG_RW, - (void *)sc, 0, - em_sysctl_stats, "I", "Statistics"); - - callout_init(&sc->timer, CALLOUT_MPSAFE); - callout_init(&sc->tx_fifo_timer, CALLOUT_MPSAFE); -#endif /* __FreeBSD__ */ - -#ifdef __OpenBSD__ timeout_set(&sc->timer_handle, em_local_timer, sc); timeout_set(&sc->tx_fifo_timer_handle, em_82547_move_tail, sc); -#endif /* __OpenBSD__ */ /* Determine hardware revision */ em_identify_hardware(sc); -#ifdef __FreeBSD__ - /* Set up some sysctls for the tunable interrupt delays */ - em_add_int_delay_sysctl(sc, "rx_int_delay", - "receive interrupt delay in usecs", &sc->rx_int_delay, - E1000_REG_OFFSET(&sc->hw, RDTR), em_rx_int_delay_dflt); - em_add_int_delay_sysctl(sc, "tx_int_delay", - "transmit interrupt delay in usecs", &sc->tx_int_delay, - E1000_REG_OFFSET(&sc->hw, TIDV), em_tx_int_delay_dflt); - if (sc->hw.mac_type >= em_82540) { - em_add_int_delay_sysctl(sc, "rx_abs_int_delay", - "receive interrupt delay limit in usecs", - &sc->rx_abs_int_delay, - E1000_REG_OFFSET(&sc->hw, RADV), - em_rx_abs_int_delay_dflt); - em_add_int_delay_sysctl(sc, "tx_abs_int_delay", - "transmit interrupt delay limit in usecs", - &sc->tx_abs_int_delay, - E1000_REG_OFFSET(&sc->hw, TADV), - em_tx_abs_int_delay_dflt); - } -#endif /* __FreeBSD__ */ - /* Parameters (to be read from user) */ sc->num_tx_desc = EM_MIN_TXD; sc->num_rx_desc = EM_MIN_RXD; @@ -552,7 +311,7 @@ em_attach(struct device *parent, struct device *self, void *aux) ETHER_MAX_LEN; sc->hw.min_frame_size = - MINIMUM_ETHERNET_PACKET_SIZE + ETHER_CRC_LEN; + ETHER_MIN_LEN + ETHER_CRC_LEN; /* * This controls when hardware reports transmit completion @@ -568,7 +327,6 @@ em_attach(struct device *parent, struct device *self, void *aux) goto err_pci; } - /* Initialize eeprom parameters */ em_init_eeprom_params(&sc->hw); @@ -636,19 +394,9 @@ em_attach(struct device *parent, struct device *self, void *aux) if (sc->link_active == 1) { em_get_speed_and_duplex(&sc->hw, &sc->link_speed, &sc->link_duplex); -#ifdef __FreeBSD__ - printf("%s: Speed:%d Mbps Duplex:%s\n", - sc->sc_dv.dv_xname, - sc->link_speed, - sc->link_duplex == FULL_DUPLEX ? "Full" : "Half"); - } else - printf("%s: Speed:N/A Duplex:N/A\n", sc->sc_dv.dv_xname); -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ } printf(", address: %s\n", ether_sprintf(sc->interface_data.ac_enaddr)); -#endif /* __OpenBSD__ */ /* Identify 82544 on PCIX */ em_get_bus_info(&sc->hw); @@ -660,13 +408,8 @@ em_attach(struct device *parent, struct device *self, void *aux) sc->pcix_82544 = FALSE; } INIT_DEBUGOUT("em_attach: end"); -#ifdef __FreeBSD__ - return(0); -#endif -#ifdef __OpenBSD__ sc->sc_powerhook = powerhook_establish(em_power, sc); return; -#endif err_mac_addr: err_hw_init: @@ -676,15 +419,8 @@ err_rx_desc: err_tx_desc: err_pci: em_free_pci_resources(sc); -#ifdef __FreeBSD__ - sysctl_ctx_free(&sc->sysctl_ctx); -err_sysctl: - return(error); -#endif /* __FreeBSD__ */ - } -#ifdef __OpenBSD__ void em_power(int why, void *arg) { @@ -697,93 +433,6 @@ em_power(int why, void *arg) em_init(sc); } } -#endif - -/********************************************************************* - * Device removal routine - * - * The detach entry point is called when the driver is being removed. - * This routine stops the adapter and deallocates all the resources - * that were allocated for driver operation. - * - * return 0 on success, positive on failure - *********************************************************************/ - -#ifdef __FreeBSD__ -int -em_detach(device_t dev) -{ - struct em_softc *sc = device_get_softc(dev); - struct ifnet *ifp = &sc->interface_data.ac_if; - EM_LOCK_STATE(); - - INIT_DEBUGOUT("em_detach: begin"); - - EM_LOCK(sc); - sc->in_detach = 1; - em_stop(sc); - em_phy_hw_reset(&sc->hw); - EM_UNLOCK(sc); -#if __FreeBSD_version < 500000 - ether_ifdetach(&sc->interface_data.ac_if, ETHER_BPF_SUPPORTED); -#else - ether_ifdetach(&sc->interface_data.ac_if); -#endif - em_free_pci_resources(sc); - bus_generic_detach(dev); - - /* Free Transmit Descriptor ring */ - if (sc->tx_desc_base) { - em_dma_free(sc, &sc->txdma); - sc->tx_desc_base = NULL; - } - - /* Free Receive Descriptor ring */ - if (sc->rx_desc_base) { - em_dma_free(sc, &sc->rxdma); - sc->rx_desc_base = NULL; - } - - /* Free the sysctl tree */ - sysctl_ctx_free(&sc->sysctl_ctx); - - /* Remove from the sc list */ - if (em_adapter_list == sc) - em_adapter_list = sc->next; - if (sc->next != NULL) - sc->next->prev = sc->prev; - if (sc->prev != NULL) - sc->prev->next = sc->next; - - EM_LOCK_DESTROY(sc); - - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); - ifp->if_timer = 0; - - return(0); -} -#endif /* __FreeBSD__ */ - -/********************************************************************* - * - * Shutdown entry point - * - **********************************************************************/ - -#ifdef __FreeBSD__ -int -em_shutdown(device_t dev) -{ - struct em_softc *sc = device_get_softc(dev); - EM_LOCK_STATE(); - - EM_LOCK(sc); - em_stop(sc); - EM_UNLOCK(sc); - return(0); -} -#endif /* __FreeBSD__ */ - /********************************************************************* * Transmit entry point @@ -860,7 +509,6 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct em_softc *sc = ifp->if_softc; EM_LOCK_STATE(); -#ifdef __OpenBSD__ struct ifaddr *ifa = (struct ifaddr *)data; EM_LOCK(sc); error = ether_ioctl(ifp, &sc->interface_data, command, data); @@ -868,18 +516,10 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data) if (error > 0) return (error); -#endif /* __OpenBSD__ */ if (sc->in_detach) return(error); switch (command) { case SIOCSIFADDR: -#ifdef __FreeBSD__ - case SIOCGIFADDR: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFADDR (Get/Set Interface Addr)"); - ether_ioctl(ifp, command, data); - break; -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFADDR (Set Interface " "Addr)"); ifp->if_flags |= IFF_UP; @@ -894,7 +534,6 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data) break; } break; -#endif /* __OpenBSD__ */ case SIOCSIFMTU: IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFMTU (Set Interface MTU)"); if (ifr->ifr_mtu > MAX_JUMBO_FRAME_SIZE - ETHER_HDR_LEN) { @@ -928,13 +567,11 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data) case SIOCADDMULTI: case SIOCDELMULTI: IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI"); -#ifdef __OpenBSD__ error = (command == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->interface_data) : ether_delmulti(ifr, &sc->interface_data); if (error == ENETRESET) { -#endif /* __OpenBSD__ */ if (ifp->if_flags & IFF_RUNNING) { EM_LOCK(sc); em_disable_intr(sc); @@ -942,36 +579,17 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data) if (sc->hw.mac_type == em_82542_rev2_0) { em_initialize_receive_unit(sc); } -#ifdef DEVICE_POLLING - if (!(ifp->if_flags & IFF_POLLING)) -#endif em_enable_intr(sc); EM_UNLOCK(sc); } -#ifdef __OpenBSD__ error = 0; } -#endif /* __OpenBSD__ */ break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFMEDIA (Get/Set Interface Media)"); error = ifmedia_ioctl(ifp, ifr, &sc->media, command); break; -#ifdef __FreeBSD__ - case SIOCSIFCAP: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)"); - mask = ifr->ifr_reqcap ^ ifp->if_capenable; - if (mask & IFCAP_HWCSUM) { - if (IFCAP_HWCSUM & ifp->if_capenable) - ifp->if_capenable &= ~IFCAP_HWCSUM; - else - ifp->if_capenable |= IFCAP_HWCSUM; - if (ifp->if_flags & IFF_RUNNING) - em_init(sc); - } - break; -#endif /* __FreeBSD__ */ default: IOCTL_DEBUGOUT1("ioctl received: UNKNOWN (0x%x)", (int)command); error = EINVAL; @@ -1075,11 +693,9 @@ em_init_locked(struct em_softc *sc) INIT_DEBUGOUT1("em_init: pba=%dK",pba); E1000_WRITE_REG(&sc->hw, PBA, pba); -#ifdef __FreeBSD__ /* Get the latest mac address, User can use a LAA */ bcopy(sc->interface_data.ac_enaddr, sc->hw.mac_addr, ETHER_ADDR_LEN); -#endif /* __FreeBSD__ */ /* Initialize the hardware */ if (em_hardware_init(sc)) { @@ -1117,30 +733,9 @@ em_init_locked(struct em_softc *sc) ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; -#ifdef __FreeBSD__ - if (sc->hw.mac_type >= em_82543) { - if (ifp->if_capenable & IFCAP_TXCSUM) - ifp->if_hwassist = EM_CHECKSUM_FEATURES; - else - ifp->if_hwassist = 0; - } - - callout_reset(&sc->timer, 2*hz, em_local_timer, sc); -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ timeout_add(&sc->timer_handle, 2*hz); -#endif em_clear_hw_cntrs(&sc->hw); -#ifdef DEVICE_POLLING - /* - * Only enable interrupts if we are not polling, make sure - * they are off otherwise. - */ - if (ifp->if_flags & IFF_POLLING) - em_disable_intr(sc); - else -#endif /* DEVICE_POLLING */ - em_enable_intr(sc); + em_enable_intr(sc); /* Don't reset the phy next time init gets called */ sc->hw.phy_reset_disable = TRUE; @@ -1160,64 +755,12 @@ em_init(void *arg) return; } - -#ifdef DEVICE_POLLING -poll_handler_t em_poll; - -void -em_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count) -{ - struct em_softc *sc = ifp->if_softc; - u_int32_t reg_icr; - - mtx_assert(&sc->mtx, MA_OWNED); - - if (cmd == POLL_DEREGISTER) { /* final call, enable interrupts */ - em_enable_intr(sc); - return; - } - if (cmd == POLL_AND_CHECK_STATUS) { - reg_icr = E1000_READ_REG(&sc->hw, ICR); - if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { - callout_stop(&sc->timer); - sc->hw.get_link_status = 1; - em_check_for_link(&sc->hw); - em_update_link_status(sc); - callout_reset(&sc->timer, 2*hz, em_local_timer, sc); - } - } - if (ifp->if_flags & IFF_RUNNING) { - em_process_receive_interrupts(sc, count); - em_clean_transmit_interrupts(sc); - } - - if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL) - em_start_locked(ifp); -} - -void -em_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) -{ - struct em_softc *sc = ifp->if_softc; - EM_LOCK_STATE(); - - EM_LOCK(sc); - em_poll_locked(ifp, cmd, count); - EM_UNLOCK(sc); -} -#endif /* DEVICE_POLLING */ - /********************************************************************* * * Interrupt Service routine * **********************************************************************/ -#ifdef __FreeBSD__ -void -#endif -#ifdef __OpenBSD__ int -#endif em_intr(void *arg) { u_int32_t loop_cnt = EM_MAX_INTR; @@ -1230,48 +773,19 @@ em_intr(void *arg) ifp = &sc->interface_data.ac_if; -#ifdef DEVICE_POLLING - if (ifp->if_flags & IFF_POLLING) { - EM_UNLOCK(sc); - return; - } - - if (ether_poll_register(em_poll, ifp)) { - em_disable_intr(sc); - em_poll_locked(ifp, 0, 1); - EM_UNLOCK(sc); - return; - } -#endif /* DEVICE_POLLING */ - reg_icr = E1000_READ_REG(&sc->hw, ICR); if (!reg_icr) { EM_UNLOCK(sc); -#ifdef __FreeBSD__ - return; -#endif -#ifdef __OpenBSD__ return (0); -#endif } /* Link status change */ if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { -#ifdef __FreeBSD__ - callout_stop(&sc->timer); -#endif -#ifdef __OpenBSD__ timeout_del(&sc->timer_handle); -#endif sc->hw.get_link_status = 1; em_check_for_link(&sc->hw); em_update_link_status(sc); -#ifdef __FreeBSD__ - callout_reset(&sc->timer, 2*hz, em_local_timer, sc); -#endif -#ifdef __OpenBSD__ timeout_add(&sc->timer_handle, 2*hz); -#endif } while (loop_cnt > 0) { @@ -1282,25 +796,13 @@ em_intr(void *arg) loop_cnt--; } -#ifdef __FreeBSD__ - if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL) -#endif -#ifdef __OpenBSD__ if (ifp->if_flags & IFF_RUNNING && IFQ_IS_EMPTY(&ifp->if_snd) == 0) -#endif em_start_locked(ifp); EM_UNLOCK(sc); -#ifdef __FreeBSD__ - return; -#endif -#ifdef __OpenBSD__ return (1); -#endif } - - /********************************************************************* * * Media Ioctl callback @@ -1351,11 +853,7 @@ em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) ifmr->ifm_active |= IFM_100_TX; break; case 1000: -#if defined(__FreeBSD__) && __FreeBSD_version < 500000 - ifmr->ifm_active |= IFM_1000_TX; -#else ifmr->ifm_active |= IFM_1000_T; -#endif break; } if (sc->link_duplex == FULL_DUPLEX) @@ -1391,11 +889,7 @@ em_media_change(struct ifnet *ifp) sc->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; break; case IFM_1000_SX: -#if defined(__FreeBSD__) && __FreeBSD_version < 500000 - case IFM_1000_TX: -#else case IFM_1000_T: -#endif sc->hw.autoneg = DO_AUTO_NEG; sc->hw.autoneg_advertised = ADVERTISE_1000_FULL; break; @@ -1429,21 +923,6 @@ em_media_change(struct ifnet *ifp) return(0); } -#ifdef __FreeBSD__ -void -em_tx_cb(void *arg, bus_dma_segment_t *seg, int nsegs, bus_size_t mapsize, int error) -{ - struct em_q *q = arg; - - if (error) - return; - KASSERT(nsegs <= EM_MAX_SCATTER, - ("Too many DMA segments returned when mapping tx packet")); - q->nsegs = nsegs; - bcopy(seg, q->segs, nsegs * sizeof(seg[0])); -} -#endif /* __FreeBSD__ */ - /********************************************************************* * * This routine maps the mbufs to tx descriptors. @@ -1507,14 +986,10 @@ em_encap(struct em_softc *sc, struct mbuf *m_head) } -#ifdef __FreeBSD__ - if (ifp->if_hwassist > 0) { - em_transmit_checksum_setup(sc, m_head, - &txd_upper, &txd_lower); - } else -#endif /* __FreeBSD__ */ - txd_upper = txd_lower = 0; - +#if 0 + em_transmit_checksum_setup(sc, m_head, &txd_upper, &txd_lower); +#endif + txd_upper = txd_lower = 0; /* Find out if we are in vlan mode */ #if NVLAN > 0 @@ -1655,13 +1130,7 @@ em_82547_move_tail_locked(struct em_softc *sc) if(eop) { if (em_82547_fifo_workaround(sc, length)) { sc->tx_fifo_wrk_cnt++; -#ifdef __FreeBSD__ - callout_reset(&sc->tx_fifo_timer, 1, - em_82547_move_tail, sc); -#endif -#ifdef __OpenBSD__ timeout_add(&sc->tx_fifo_timer_handle, 1); -#endif break; } E1000_WRITE_REG(&sc->hw, TDT, hw_tdt); @@ -1818,16 +1287,11 @@ em_set_multi(struct em_softc *sc) { u_int32_t reg_rctl = 0; u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * ETH_LENGTH_OF_ADDRESS]; -#ifdef __FreeBSD__ - struct ifmultiaddr *ifma; -#endif int mcnt = 0; struct ifnet *ifp = &sc->interface_data.ac_if; -#ifdef __OpenBSD__ struct arpcom *ac = &sc->interface_data; struct ether_multi *enm; struct ether_multistep step; -#endif /* __OpenBSD__ */ IOCTL_DEBUGOUT("em_set_multi: begin"); @@ -1840,24 +1304,6 @@ em_set_multi(struct em_softc *sc) E1000_WRITE_REG(&sc->hw, RCTL, reg_rctl); msec_delay(5); } - -#ifdef __FreeBSD__ -#if __FreeBSD_version < 500000 - LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { -#else - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { -#endif - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - - if (mcnt == MAX_NUM_MULTICAST_ADDRESSES) break; - - bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), - &mta[mcnt*ETH_LENGTH_OF_ADDRESS], ETH_LENGTH_OF_ADDRESS); - mcnt++; - } -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) { @@ -1871,7 +1317,6 @@ em_set_multi(struct em_softc *sc) mcnt++; ETHER_NEXT_MULTI(step, enm); } -#endif /* __OpenBSD__ */ if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) { reg_rctl = E1000_READ_REG(&sc->hw, RCTL); @@ -1893,7 +1338,6 @@ em_set_multi(struct em_softc *sc) return; } - /********************************************************************* * Timer routine * @@ -1920,12 +1364,7 @@ em_local_timer(void *arg) } em_smartspeed(sc); -#ifdef __FreeBSD__ - callout_reset(&sc->timer, 2*hz, em_local_timer, sc); -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ timeout_add(&sc->timer_handle, 2*hz); -#endif /* __OpenBSD__ */ EM_UNLOCK(sc); return; @@ -2006,25 +1445,17 @@ em_stop(void *arg) INIT_DEBUGOUT("em_stop: begin"); em_disable_intr(sc); em_reset_hw(&sc->hw); -#ifdef __FreeBSD__ - callout_stop(&sc->timer); - callout_stop(&sc->tx_fifo_timer); -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ timeout_del(&sc->timer_handle); timeout_del(&sc->tx_fifo_timer_handle); -#endif /* __OpenBSD__ */ em_free_transmit_structures(sc); em_free_receive_structures(sc); - /* Tell the stack that the interface is no longer active */ ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); return; } - /********************************************************************* * * Determine hardware revision. @@ -2117,13 +1548,7 @@ em_allocate_pci_resources(struct em_softc *sc) return (ENXIO); } -#ifdef __FreeBSD__ - sc->hw.io_base = - rman_get_start(sc->res_ioport); -#endif -#ifdef __OpenBSD__ sc->hw.io_base = 0; -#endif } if (pci_intr_map(pa, &ih)) { @@ -2231,59 +1656,24 @@ em_hardware_init(struct em_softc *sc) * **********************************************************************/ void -#ifdef __FreeBSD__ -em_setup_interface(device_t dev, struct em_softc *sc) -#endif -#ifdef __OpenBSD__ em_setup_interface(struct em_softc *sc) -#endif { struct ifnet *ifp; INIT_DEBUGOUT("em_setup_interface: begin"); ifp = &sc->interface_data.ac_if; -#ifdef __FreeBSD__ - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); -#endif -#ifdef __OpenBSD__ strlcpy(ifp->if_xname, sc->sc_dv.dv_xname, IFNAMSIZ); -#endif ifp->if_baudrate = 1000000000; -#ifdef __FreeBSD__ - ifp->if_init = em_init; -#endif ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = em_ioctl; ifp->if_start = em_start; ifp->if_watchdog = em_watchdog; -#ifdef __FreeBSD__ - ifp->if_snd.ifq_maxlen = sc->num_tx_desc - 1; -#endif -#ifdef __OpenBSD__ IFQ_SET_MAXLEN(&ifp->if_snd, sc->num_tx_desc - 1); IFQ_SET_READY(&ifp->if_snd); -#endif -#ifdef __FreeBSD__ - if (sc->hw.mac_type >= em_82543) { - ifp->if_capabilities = IFCAP_HWCSUM; - ifp->if_capenable = ifp->if_capabilities; - } - - /* - * Tell the upper layer(s) we support long frames. - */ - ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); -#if __FreeBSD_version >= 500000 - ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU; -#endif -#endif /* __FreeBSD__ */ - -#ifdef __OpenBSD__ - ifp->if_capabilities |= IFCAP_VLAN_MTU; -#endif + ifp->if_capabilities = IFCAP_VLAN_MTU; /* * Specify the media types supported by this adapter and register @@ -2311,10 +1701,9 @@ em_setup_interface(struct em_softc *sc) ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&sc->media, IFM_ETHER | IFM_AUTO); -#ifdef __OpenBSD__ if_attach(ifp); ether_ifattach(ifp); -#endif + return; } @@ -2379,53 +1768,18 @@ em_smartspeed(struct em_softc *sc) return; } - /* * Manage DMA'able memory. */ -#ifdef __FreeBSD__ -void -em_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) -{ - if (error) - return; - *(bus_addr_t*) arg = segs->ds_addr; - return; -} -#endif /* __FreeBSD__ */ - int em_dma_malloc(struct em_softc *sc, bus_size_t size, struct em_dma_alloc *dma, int mapflags) { int r; -#ifdef __FreeBSD__ - r = bus_dma_tag_create(NULL, /* parent */ - PAGE_SIZE, 0, /* alignment, bounds */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - size, /* maxsize */ - 1, /* nsegments */ - size, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockarg */ - &dma->dma_tag); - if (r != 0) { - printf("%s: em_dma_malloc: bus_dma_tag_create failed; " - "error %u\n", sc->sc_dv.dv_xname, r); - goto fail_0; - } - - r = bus_dmamap_create(dma->dma_tag, BUS_DMA_NOWAIT, &dma->dma_map); -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ dma->dma_tag = sc->osdep.em_pa.pa_dmat; r = bus_dmamap_create(dma->dma_tag, size, 1, size, 0, BUS_DMA_NOWAIT, &dma->dma_map); -#endif /* __OpenBSD__ */ if (r != 0) { printf("%s: em_dma_malloc: bus_dmamap_create failed; " "error %u\n", sc->sc_dv.dv_xname, r); @@ -2489,7 +1843,6 @@ em_dma_free(struct em_softc *sc, struct em_dma_alloc *dma) bus_dma_tag_destroy(dma->dma_tag); } - /********************************************************************* * * Allocate memory for tx_buffer structures. The tx_buffer stores all @@ -2522,30 +1875,7 @@ em_allocate_transmit_structures(struct em_softc *sc) int em_setup_transmit_structures(struct em_softc *sc) { -#ifdef __FreeBSD__ - /* - * Setup DMA descriptor areas. - */ - if (bus_dma_tag_create(NULL, /* parent */ - PAGE_SIZE, 0, /* alignment, bounds */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MCLBYTES * 8, /* maxsize */ - EM_MAX_SCATTER, /* nsegments */ - MCLBYTES * 8, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockarg */ - &sc->txtag)) { - printf("%s: Unable to allocate TX DMA tag\n", sc->sc_dv.dv_xname); - return (ENOMEM); - } - -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ sc->txtag = sc->osdep.em_pa.pa_dmat; -#endif if (em_allocate_transmit_structures(sc)) return (ENOMEM); @@ -2679,7 +2009,7 @@ em_free_transmit_structures(struct em_softc *sc) * context only if the protocol type changes. * **********************************************************************/ -#ifdef __FreeBSD__ +#if 0 void em_transmit_checksum_setup(struct em_softc *sc, struct mbuf *mp, @@ -2758,7 +2088,7 @@ em_transmit_checksum_setup(struct em_softc *sc, return; } -#endif /* __FreeBSD__ */ +#endif /********************************************************************** * @@ -2918,27 +2248,7 @@ em_allocate_receive_structures(struct em_softc *sc) bzero(sc->rx_buffer_area, sizeof(struct em_buffer) * sc->num_rx_desc); -#ifdef __FreeBSD__ - error = bus_dma_tag_create(NULL, /* parent */ - PAGE_SIZE, 0, /* alignment, bounds */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MCLBYTES, /* maxsize */ - 1, /* nsegments */ - MCLBYTES, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - &sc->rxtag); - if (error != 0) { - printf("%s: em_allocate_receive_structures: " - "bus_dma_tag_create failed; error %u\n", - sc->sc_dv.dv_xname, error); - goto fail_0; - } -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ sc->rxtag = sc->osdep.em_pa.pa_dmat; -#endif rx_buffer = sc->rx_buffer_area; for (i = 0; i < sc->num_rx_desc; i++, rx_buffer++) { @@ -3001,7 +2311,7 @@ void em_initialize_receive_unit(struct em_softc *sc) { u_int32_t reg_rctl; -#ifdef __FreeBSD__ +#if 0 u_int32_t reg_rxcsum; #endif struct ifnet *ifp; @@ -3029,12 +2339,7 @@ em_initialize_receive_unit(struct em_softc *sc) } /* Setup the Base and Length of the Rx Descriptor Ring */ -#ifdef __FreeBSD__ - bus_addr = sc->rxdma.dma_paddr; -#endif -#ifdef __OpenBSD__ bus_addr = sc->rxdma.dma_map->dm_segs[0].ds_addr; -#endif E1000_WRITE_REG(&sc->hw, RDBAL, (u_int32_t)bus_addr); E1000_WRITE_REG(&sc->hw, RDBAH, (u_int32_t)(bus_addr >> 32)); E1000_WRITE_REG(&sc->hw, RDLEN, sc->num_rx_desc * @@ -3072,15 +2377,14 @@ em_initialize_receive_unit(struct em_softc *sc) if (ifp->if_mtu > ETHERMTU) reg_rctl |= E1000_RCTL_LPE; -#ifdef __FreeBSD__ /* Enable 82543 Receive Checksum Offload for TCP and UDP */ - if ((sc->hw.mac_type >= em_82543) && - (ifp->if_capenable & IFCAP_RXCSUM)) { +#if 0 + if (sc->hw.mac_type >= em_82543) { reg_rxcsum = E1000_READ_REG(&sc->hw, RXCSUM); reg_rxcsum |= (E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); E1000_WRITE_REG(&sc->hw, RXCSUM, reg_rxcsum); } -#endif /* __FreeBSD__ */ +#endif /* Enable Receives */ E1000_WRITE_REG(&sc->hw, RCTL, reg_rctl); @@ -3139,11 +2443,6 @@ em_process_receive_interrupts(struct em_softc *sc, int count) { struct ifnet *ifp; struct mbuf *mp; -#ifdef __FreeBSD__ -#if __FreeBSD_version < 500000 - struct ether_header *eh; -#endif -#endif /* __FreeBSD__ */ u_int8_t accept_frame = 0; u_int8_t eop = 0; u_int16_t len, desc_len, prev_len_adj; @@ -3302,7 +2601,6 @@ em_process_receive_interrupts(struct em_softc *sc, int count) sc->fmp->m_pkthdr.rcvif = ifp; ifp->if_ipackets++; -#ifdef __OpenBSD__ #if NBPFILTER > 0 /* * Handle BPF listeners. Let the BPF @@ -3314,37 +2612,6 @@ em_process_receive_interrupts(struct em_softc *sc, int count) em_receive_checksum(sc, current_desc, sc->fmp); ether_input_mbuf(ifp, sc->fmp); -#endif /* __OpenBSD__ */ -#ifdef __FreeBSD__ -#if __FreeBSD_version < 500000 - eh = mtod(sc->fmp, struct ether_header *); - /* Remove ethernet header from mbuf */ - m_adj(sc->fmp, sizeof(struct ether_header)); - em_receive_checksum(sc, current_desc, - sc->fmp); - if (current_desc->status & E1000_RXD_STAT_VP) - VLAN_INPUT_TAG(eh, sc->fmp, - (current_desc->special & - E1000_RXD_SPC_VLAN_MASK)); - else - ether_input(ifp, eh, sc->fmp); -#else - - em_receive_checksum(sc, current_desc, - sc->fmp); - if (current_desc->status & E1000_RXD_STAT_VP) - VLAN_INPUT_TAG(ifp, sc->fmp, - (current_desc->special & - E1000_RXD_SPC_VLAN_MASK), - sc->fmp = NULL); - - if (sc->fmp != NULL) { - EM_UNLOCK(sc); - (*ifp->if_input)(ifp, sc->fmp); - EM_LOCK(sc); - } -#endif -#endif /* __FreeBSD__ */ sc->fmp = NULL; sc->lmp = NULL; } @@ -3386,39 +2653,6 @@ em_receive_checksum(struct em_softc *sc, struct em_rx_desc *rx_desc, struct mbuf *mp) { -#ifdef __FreeBSD__ - /* 82543 or newer only */ - if ((sc->hw.mac_type < em_82543) || - /* Ignore Checksum bit is set */ - (rx_desc->status & E1000_RXD_STAT_IXSM)) { - mp->m_pkthdr.csum_flags = 0; - return; - } - - if (rx_desc->status & E1000_RXD_STAT_IPCS) { - /* Did it pass? */ - if (!(rx_desc->errors & E1000_RXD_ERR_IPE)) { - /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; - - } else { - mp->m_pkthdr.csum_flags = 0; - } - } - - if (rx_desc->status & E1000_RXD_STAT_TCPCS) { - /* Did it pass? */ - if (!(rx_desc->errors & E1000_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - mp->m_pkthdr.csum_data = htons(0xffff); - } - } - - return; -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ /* 82543 or newer only */ if ((sc->hw.mac_type < em_82543) || /* Ignore Checksum bit is set */ @@ -3433,7 +2667,6 @@ em_receive_checksum(struct em_softc *sc, E1000_RXD_STAT_TCPCS|E1000_RXD_ERR_TCPE)) == (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_IPCS)) mp->m_pkthdr.csum |= M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; -#endif /* __OpenBSD__ */ } @@ -3534,21 +2767,6 @@ em_pci_clear_mwi(struct em_hw *hw) } -#ifdef __FreeBSD__ -int32_t -em_io_read(struct em_hw *hw, unsigned long port) -{ - return(inl(port)); -} - -void -em_io_write(struct em_hw *hw, unsigned long port, uint32_t value) -{ - outl(port, value); - return; -} -#endif /* __FreeBSD__ */ - /********************************************************************* * 82544 Coexistence issue workaround. * There are 2 issues. @@ -3690,11 +2908,6 @@ em_update_stats_counters(struct em_softc *sc) ifp = &sc->interface_data.ac_if; /* Fill out the OS statistics structure */ -#ifndef __OpenBSD__ - ifp->if_ibytes = sc->stats.gorcl; - ifp->if_obytes = sc->stats.gotcl; - ifp->if_imcasts = sc->stats.mprc; -#endif ifp->if_collisions = sc->stats.colc; /* Rx Errors */ @@ -3711,7 +2924,6 @@ em_update_stats_counters(struct em_softc *sc) } - /********************************************************************** * * This routine is called only when em_display_debug_stats is enabled. @@ -3810,109 +3022,3 @@ em_print_hw_stats(struct em_softc *sc) return; } - -#ifdef __FreeBSD__ -int -em_sysctl_debug_info(SYSCTL_HANDLER_ARGS) -{ - int error; - int result; - struct em_softc *sc; - - result = -1; - error = sysctl_handle_int(oidp, &result, 0, req); - - if (error || !req->newptr) - return (error); - - if (result == 1) { - sc = (struct em_softc *)arg1; - em_print_debug_info(sc); - } - - return error; -} - - -int -em_sysctl_stats(SYSCTL_HANDLER_ARGS) -{ - int error; - int result; - struct em_softc *sc; - - result = -1; - error = sysctl_handle_int(oidp, &result, 0, req); - - if (error || !req->newptr) - return (error); - - if (result == 1) { - sc = (struct em_softc *)arg1; - em_print_hw_stats(sc); - } - - return error; -} - -int -em_sysctl_int_delay(SYSCTL_HANDLER_ARGS) -{ - struct em_int_delay_info *info; - struct em_softc *sc; - u_int32_t regval; - int error; - int usecs; - int ticks; - int s; - - info = (struct em_int_delay_info *)arg1; - sc = info->sc; - usecs = info->value; - error = sysctl_handle_int(oidp, &usecs, 0, req); - if (error != 0 || req->newptr == NULL) - return error; - if (usecs < 0 || usecs > E1000_TICKS_TO_USECS(65535)) - return EINVAL; - info->value = usecs; - ticks = E1000_USECS_TO_TICKS(usecs); - - s = splimp(); - regval = E1000_READ_OFFSET(&sc->hw, info->offset); - regval = (regval & ~0xffff) | (ticks & 0xffff); - /* Handle a few special cases. */ - switch (info->offset) { - case E1000_RDTR: - case E1000_82542_RDTR: - regval |= E1000_RDT_FPDB; - break; - case E1000_TIDV: - case E1000_82542_TIDV: - if (ticks == 0) { - sc->txd_cmd &= ~E1000_TXD_CMD_IDE; - /* Don't write 0 into the TIDV register. */ - regval++; - } else - sc->txd_cmd |= E1000_TXD_CMD_IDE; - break; - } - E1000_WRITE_OFFSET(&sc->hw, info->offset, regval); - splx(s); - return 0; -} - -void -em_add_int_delay_sysctl(struct em_softc *sc, const char *name, - const char *description, struct em_int_delay_info *info, - int offset, int value) -{ - info->sc = sc; - info->offset = offset; - info->value = value; - SYSCTL_ADD_PROC(&sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), - OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW, - info, 0, em_sysctl_int_delay, "I", description); -} -#endif /* __FreeBSD__ */ - diff --git a/sys/dev/pci/if_em.h b/sys/dev/pci/if_em.h index f1d157a42ac..9cba360fa02 100644 --- a/sys/dev/pci/if_em.h +++ b/sys/dev/pci/if_em.h @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ /* $FreeBSD: if_em.h,v 1.26 2004/09/01 23:22:41 pdeuskar Exp $ */ -/* $OpenBSD: if_em.h,v 1.9 2004/12/08 15:41:46 markus Exp $ */ +/* $OpenBSD: if_em.h,v 1.10 2005/03/27 16:38:13 brad Exp $ */ #ifndef _EM_H_DEFINED_ #define _EM_H_DEFINED_ @@ -220,24 +220,6 @@ POSSIBILITY OF SUCH DAMAGE. #define EM_MAX_SCATTER 64 -/* ****************************************************************************** - * vendor_info_array - * - * This array contains the list of Subvendor/Subdevice IDs on which the driver - * should load. - * - * ******************************************************************************/ -#ifdef __FreeBSD__ -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; -} em_vendor_info_t; -#endif /* __FreeBSD__ */ - - struct em_buffer { struct mbuf *m_head; bus_dmamap_t map; /* bus_dma map for packet */ @@ -245,10 +227,6 @@ struct em_buffer { struct em_q { bus_dmamap_t map; /* bus_dma map for packet */ -#ifdef __FreeBSD__ - int nsegs; /* # of segments/descriptors */ - bus_dma_segment_t segs[EM_MAX_SCATTER]; -#endif /* __FreeBSD__ */ }; /* @@ -301,33 +279,16 @@ struct em_softc { struct em_softc *prev; struct em_hw hw; - /* FreeBSD operating-system-specific structures */ + /* OpenBSD operating-system-specific structures */ struct em_osdep osdep; -#ifdef __FreeBSD__ - struct device *dev; - struct resource *res_memory; - struct resource *res_ioport; - struct resource *res_interrupt; - void *int_handler_tag; -#endif /* __FreeBSD__ */ struct ifmedia media; -#ifdef __FreeBSD__ - struct callout timer; - struct callout tx_fifo_timer; -#endif /* __FreeBSD__ */ int io_rid; -#ifdef __FreeBSD__ - u_int8_t unit; - struct mtx mtx; -#endif /* __FreeBSD__ */ -#ifdef __OpenBSD__ void *sc_intrhand; struct timeout em_intr_enable; struct timeout timer_handle; struct timeout tx_fifo_timer_handle; void *sc_powerhook; -#endif /* __OpenBSD__ */ #ifdef __STRICT_ALIGNMENT /* Used for carrying forward alignment adjustments */ @@ -387,11 +348,6 @@ struct em_softc { struct mbuf *fmp; struct mbuf *lmp; -#ifdef __FreeBSD__ - struct sysctl_ctx_list sysctl_ctx; - struct sysctl_oid *sysctl_tree; -#endif /* __FreeBSD__ */ - /* Misc stats maintained by the driver */ unsigned long dropped_pkts; unsigned long mbuf_alloc_failed; @@ -428,16 +384,6 @@ struct em_softc { struct em_hw_stats stats; }; -#ifdef __FreeBSD__ -#define EM_LOCK_INIT(_sc, _name) \ - mtx_init(&(_sc)->mtx, _name, MTX_NETWORK_LOCK, MTX_DEF) -#define EM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx) -#define EM_LOCK(_sc) mtx_lock(&(_sc)->mtx) -#define EM_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) -#define EM_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED) -#endif /* __FreeBSD__ */ - -#ifdef __OpenBSD__ static inline int spl_use_arg(void *); static inline int spl_use_arg(void *v) { return splnet(); } #define EM_LOCK_INIT(_sc, _name) @@ -446,6 +392,5 @@ static inline int spl_use_arg(void *v) { return splnet(); } #define EM_LOCK(_sc) em_hidden_splnet_s = spl_use_arg(_sc) #define EM_UNLOCK(_sc) splx(em_hidden_splnet_s) #define EM_LOCK_ASSERT(_sc) splassert(IPL_NET) -#endif /* __OpenBSD__ */ #endif /* _EM_H_DEFINED_ */ diff --git a/sys/dev/pci/if_em_hw.c b/sys/dev/pci/if_em_hw.c index f1192a1118b..a2428a01658 100644 --- a/sys/dev/pci/if_em_hw.c +++ b/sys/dev/pci/if_em_hw.c @@ -31,12 +31,12 @@ *******************************************************************************/ -/* $OpenBSD: if_em_hw.c,v 1.7 2005/02/19 18:18:14 jolan Exp $ */ +/* $OpenBSD: if_em_hw.c,v 1.8 2005/03/27 16:38:13 brad Exp $ */ /* if_em_hw.c * Shared functions for accessing and configuring the MAC */ -#ifdef __FreeBSD__ +#if 0 #include <sys/cdefs.h> __FBSDID("$FreeBSD: if_em_hw.c,v 1.15 2004/09/23 22:57:53 cognet Exp $"); #endif @@ -419,9 +419,7 @@ em_reset_hw(struct em_hw *hw) case em_82544: case em_82540: case em_82545: -#if defined(__FreeBSD__) && !defined(__arm__) case em_82546: -#endif case em_82541: case em_82541_rev_2: /* These controllers can't ack the 64-bit write when issuing the diff --git a/sys/dev/pci/if_em_hw.h b/sys/dev/pci/if_em_hw.h index 1926eac6ced..3d9885e2f8c 100644 --- a/sys/dev/pci/if_em_hw.h +++ b/sys/dev/pci/if_em_hw.h @@ -32,7 +32,7 @@ *******************************************************************************/ /* $FreeBSD: if_em_hw.h,v 1.14 2004/09/01 23:22:41 pdeuskar Exp $ */ -/* $OpenBSD: if_em_hw.h,v 1.6 2004/11/16 14:39:14 brad Exp $ */ +/* $OpenBSD: if_em_hw.h,v 1.7 2005/03/27 16:38:13 brad Exp $ */ /* if_em_hw.h * Structures, enums, and macros for the MAC */ @@ -45,7 +45,7 @@ #include <dev/pci/if_em_osdep.h> #ifndef NO_VERSION_CONTROL -#ident "@(#)$RCSfile: if_em_hw.h,v $$Revision: 1.6 $$Date: 2004/11/16 14:39:14 $" +#ident "@(#)$RCSfile: if_em_hw.h,v $$Revision: 1.7 $$Date: 2005/03/27 16:38:13 $" #endif /* Forward declarations of structures used by the shared code */ @@ -329,13 +329,7 @@ void em_pci_clear_mwi(struct em_hw *hw); void em_read_pci_cfg(struct em_hw *hw, uint32_t reg, uint16_t * value); void em_write_pci_cfg(struct em_hw *hw, uint32_t reg, uint16_t * value); /* Port I/O is only supported on 82544 and newer */ -#ifdef __FreeBSD__ -uint32_t em_io_read(struct em_hw *hw, unsigned long port); -#endif /* __FreeBSD__ */ uint32_t em_read_reg_io(struct em_hw *hw, uint32_t offset); -#ifdef __FreeBSD__ -void em_io_write(struct em_hw *hw, unsigned long port, uint32_t value); -#endif /* __FreeBSD__ */ void em_write_reg_io(struct em_hw *hw, uint32_t offset, uint32_t value); int32_t em_config_dsp_after_link_change(struct em_hw *hw, boolean_t link_up); int32_t em_set_d3_lplu_state(struct em_hw *hw, boolean_t active); |