Date: Thu, 3 Aug 2006 22:15:17 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 103143 for review Message-ID: <200608032215.k73MFHx4084054@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=103143 Change 103143 by jb@jb_freebsd2 on 2006/08/03 22:15:01 Back out the breakage introduced by the IFC. It seems there is a battle for control of this driver in current. I'll stay out of that and stick with this version for the time being. I can't do without a functional 'em' on sun4v and it is just a waste of my time having to deal with commit wars over white space. My branch now ignores src/sys/dev/em. Affected files ... .. //depot/projects/dtrace/src/sys/dev/em/README#4 edit .. //depot/projects/dtrace/src/sys/dev/em/if_em.c#9 edit .. //depot/projects/dtrace/src/sys/dev/em/if_em.h#5 edit .. //depot/projects/dtrace/src/sys/dev/em/if_em_hw.c#6 edit .. //depot/projects/dtrace/src/sys/dev/em/if_em_hw.h#4 edit .. //depot/projects/dtrace/src/sys/dev/em/if_em_osdep.h#5 edit Differences ... ==== //depot/projects/dtrace/src/sys/dev/em/README#4 (text+ko) ==== @@ -1,8 +1,9 @@ -$FreeBSD: src/sys/dev/em/README,v 1.13 2006/08/03 09:20:11 glebius Exp $ +//depot/projects/dtrace/src/sys/dev/em/README#2 - integrate change 100573 (text+ko) +$FreeBSD: src/sys/dev/em/README,v 1.12 2006/04/06 17:09:02 glebius Exp $ FreeBSD* Driver for the Intel(R) PRO/1000 Family of Adapters ============================================================ -May 2, 2006 +January 4, 2006 Contents @@ -22,7 +23,8 @@ ======== This file describes the FreeBSD* driver for the Intel(R) PRO/1000 Family of -Adapters. This driver has been developed for use with FreeBSD, Release 6.x. +Adapters. This driver has been developed for use with FreeBSD, Release 4.11 +and greater and Release 5.4. For questions related to hardware requirements, refer to the documentation supplied with your Intel PRO/1000 adapter. All hardware requirements listed @@ -44,8 +46,7 @@ NOTE: Mobile adapters are not fully supported. -NOTE: The Intel(R) 82562v 10/100 Network Connection only provides 10/100 -support. + Building and Installation ========================= @@ -92,14 +93,14 @@ cp Makefile.kernel /usr/src/sys/modules/em/Makefile - Edit the /usr/src/sys/conf/files file, and add the following lines only if + Edit the /usr/src/sys/conf/files.i386 file, and add the following lines only if they don't already exist: dev/em/if_em.c optional em dev/em/if_em_hw.c optional em - Remove the following lines from the /usr/src/sys/conf/files file, + Remove the following lines from the /usr/src/sys/conf/files.i386 file, if they exist: dev/em/if_em_fxhw.c optional em @@ -230,13 +231,6 @@ - Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or loss of link. - - The following adapters do not support Jumbo Frames: - Intel(R) 82562V 10/100 Network Connection - Intel(R) 82566DM Gigabit Network Connection - Intel(R) 82566DC Gigabit Network Connection - Intel(R) 82566MM Gigabit Network Connection - Intel(R) 82566MC Gigabit Network Connection - VLANs ----- ==== //depot/projects/dtrace/src/sys/dev/em/if_em.c#9 (text+ko) ==== @@ -1,6 +1,7 @@ +//depot/projects/dtrace/src/sys/dev/em/if_em.c#7 - edit change 102692 (text+ko) /************************************************************************** -Copyright (c) 2001-2006, Intel Corporation +Copyright (c) 2001-2005, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,7 +32,7 @@ ***************************************************************************/ -/*$FreeBSD: src/sys/dev/em/if_em.c,v 1.124 2006/08/03 19:05:04 pdeuskar Exp $*/ +/*$FreeBSD: src/sys/dev/em/if_em.c,v 1.119 2006/07/20 04:18:45 yongari Exp $*/ #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_device_polling.h" @@ -86,7 +87,7 @@ * Driver version *********************************************************************/ -char em_driver_version[] = "Version - 6.0.5"; +char em_driver_version[] = "Version - 5.1.5"; /********************************************************************* @@ -159,17 +160,10 @@ { 0x8086, E1000_DEV_ID_82573E, PCI_ANY_ID, PCI_ANY_ID, 0}, { 0x8086, E1000_DEV_ID_82573E_IAMT, PCI_ANY_ID, PCI_ANY_ID, 0}, { 0x8086, E1000_DEV_ID_82573L, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, E1000_DEV_ID_80003ES2LAN_COPPER_SPT, - PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, E1000_DEV_ID_80003ES2LAN_SERDES_SPT, - PCI_ANY_ID, PCI_ANY_ID, 0}, { 0x8086, E1000_DEV_ID_80003ES2LAN_COPPER_DPT, PCI_ANY_ID, PCI_ANY_ID, 0}, { 0x8086, E1000_DEV_ID_80003ES2LAN_SERDES_DPT, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, E1000_DEV_ID_ICH8_IGP_AMT, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, E1000_DEV_ID_ICH8_IGP_C, PCI_ANY_ID, PCI_ANY_ID, 0}, - { 0x8086, E1000_DEV_ID_ICH8_IFE, PCI_ANY_ID, PCI_ANY_ID, 0}, /* required last entry */ { 0, 0, 0, 0, 0} @@ -197,64 +191,64 @@ static int em_ioctl(struct ifnet *, u_long, caddr_t); static void em_watchdog(struct ifnet *); static void em_init(void *); -static void em_init_locked(struct adapter *); +static void em_init_locked(struct em_softc *); static void em_stop(void *); static void em_media_status(struct ifnet *, struct ifmediareq *); static int em_media_change(struct ifnet *); -static void em_identify_hardware(struct adapter *); -static int em_allocate_pci_resources(struct adapter *); -static int em_allocate_intr(struct adapter *); -static void em_free_intr(struct adapter *); -static void em_free_pci_resources(struct adapter *); +static void em_identify_hardware(struct em_softc *); +static int em_allocate_pci_resources(struct em_softc *); +static int em_allocate_intr(struct em_softc *); +static void em_free_intr(struct em_softc *); +static void em_free_pci_resources(struct em_softc *); static void em_local_timer(void *); -static int em_hardware_init(struct adapter *); -static void em_setup_interface(device_t, struct adapter *); -static int em_setup_transmit_structures(struct adapter *); -static void em_initialize_transmit_unit(struct adapter *); -static int em_setup_receive_structures(struct adapter *); -static void em_initialize_receive_unit(struct adapter *); -static void em_enable_intr(struct adapter *); -static void em_disable_intr(struct adapter *); -static void em_free_transmit_structures(struct adapter *); -static void em_free_receive_structures(struct adapter *); -static void em_update_stats_counters(struct adapter *); -static void em_txeof(struct adapter *); -static int em_allocate_receive_structures(struct adapter *); -static int em_allocate_transmit_structures(struct adapter *); -static int em_rxeof(struct adapter *, int); +static int em_hardware_init(struct em_softc *); +static void em_setup_interface(device_t, struct em_softc *); +static int em_setup_transmit_structures(struct em_softc *); +static void em_initialize_transmit_unit(struct em_softc *); +static int em_setup_receive_structures(struct em_softc *); +static void em_initialize_receive_unit(struct em_softc *); +static void em_enable_intr(struct em_softc *); +static void em_disable_intr(struct em_softc *); +static void em_free_transmit_structures(struct em_softc *); +static void em_free_receive_structures(struct em_softc *); +static void em_update_stats_counters(struct em_softc *); +static void em_txeof(struct em_softc *); +static int em_allocate_receive_structures(struct em_softc *); +static int em_allocate_transmit_structures(struct em_softc *); +static int em_rxeof(struct em_softc *, int); #ifndef __NO_STRICT_ALIGNMENT -static int em_fixup_rx(struct adapter *); +static int em_fixup_rx(struct em_softc *); #endif -static void em_receive_checksum(struct adapter *, struct em_rx_desc *, +static void em_receive_checksum(struct em_softc *, struct em_rx_desc *, struct mbuf *); -static void em_transmit_checksum_setup(struct adapter *, struct mbuf *, +static void em_transmit_checksum_setup(struct em_softc *, struct mbuf *, uint32_t *, uint32_t *); -static void em_set_promisc(struct adapter *); -static void em_disable_promisc(struct adapter *); -static void em_set_multi(struct adapter *); -static void em_print_hw_stats(struct adapter *); -static void em_update_link_status(struct adapter *); -static int em_get_buf(int i, struct adapter *, struct mbuf *); -static void em_enable_vlans(struct adapter *); -static void em_disable_vlans(struct adapter *); -static int em_encap(struct adapter *, struct mbuf **); -static void em_smartspeed(struct adapter *); -static int em_82547_fifo_workaround(struct adapter *, int); -static void em_82547_update_fifo_head(struct adapter *, int); -static int em_82547_tx_fifo_reset(struct adapter *); +static void em_set_promisc(struct em_softc *); +static void em_disable_promisc(struct em_softc *); +static void em_set_multi(struct em_softc *); +static void em_print_hw_stats(struct em_softc *); +static void em_update_link_status(struct em_softc *); +static int em_get_buf(int i, struct em_softc *, struct mbuf *); +static void em_enable_vlans(struct em_softc *); +static void em_disable_vlans(struct em_softc *); +static int em_encap(struct em_softc *, struct mbuf **); +static void em_smartspeed(struct em_softc *); +static int em_82547_fifo_workaround(struct em_softc *, int); +static void em_82547_update_fifo_head(struct em_softc *, int); +static int em_82547_tx_fifo_reset(struct em_softc *); static void em_82547_move_tail(void *arg); -static void em_82547_move_tail_locked(struct adapter *); -static int em_dma_malloc(struct adapter *, bus_size_t, +static void em_82547_move_tail_locked(struct em_softc *); +static int em_dma_malloc(struct em_softc *, bus_size_t, struct em_dma_alloc *, int); -static void em_dma_free(struct adapter *, struct em_dma_alloc *); -static void em_print_debug_info(struct adapter *); +static void em_dma_free(struct em_softc *, struct em_dma_alloc *); +static void em_print_debug_info(struct em_softc *); static int em_is_valid_ether_addr(uint8_t *); static int em_sysctl_stats(SYSCTL_HANDLER_ARGS); static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); static uint32_t em_fill_descriptors (bus_addr_t address, uint32_t length, PDESC_ARRAY desc_array); 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 em_softc *, const char *, const char *, struct em_int_delay_info *, int, int); /* @@ -266,7 +260,7 @@ static void em_intr(void *); #else static void em_intr_fast(void *); -static void em_add_int_process_limit(struct adapter *, const char *, +static void em_add_int_process_limit(struct em_softc *, const char *, const char *, int *, int); static void em_handle_rxtx(void *context, int pending); static void em_handle_link(void *context, int pending); @@ -288,7 +282,7 @@ }; static driver_t em_driver = { - "em", em_methods, sizeof(struct adapter), + "em", em_methods, sizeof(struct em_softc), }; static devclass_t em_devclass; @@ -309,7 +303,6 @@ static int em_rx_abs_int_delay_dflt = E1000_TICKS_TO_USECS(EM_RADV); static int em_rxd = EM_DEFAULT_RXD; static int em_txd = EM_DEFAULT_TXD; -static int em_smart_pwr_down = FALSE; TUNABLE_INT("hw.em.tx_int_delay", &em_tx_int_delay_dflt); TUNABLE_INT("hw.em.rx_int_delay", &em_rx_int_delay_dflt); @@ -317,7 +310,6 @@ TUNABLE_INT("hw.em.rx_abs_int_delay", &em_rx_abs_int_delay_dflt); TUNABLE_INT("hw.em.rxd", &em_rxd); TUNABLE_INT("hw.em.txd", &em_txd); -TUNABLE_INT("hw.em.smart_pwr_down", &em_smart_pwr_down); #ifndef DEVICE_POLLING static int em_rx_process_limit = 100; TUNABLE_INT("hw.em.rx_process_limit", &em_rx_process_limit); @@ -387,199 +379,199 @@ static int em_attach(device_t dev) { - struct adapter *adapter; + struct em_softc *sc; int tsize, rsize; int error = 0; INIT_DEBUGOUT("em_attach: begin"); - adapter = device_get_softc(dev); - adapter->dev = adapter->osdep.dev = dev; - EM_LOCK_INIT(adapter, device_get_nameunit(dev)); + sc = device_get_softc(dev); + sc->dev = sc->osdep.dev = dev; + EM_LOCK_INIT(sc, device_get_nameunit(dev)); /* SYSCTL stuff */ SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "debug_info", CTLTYPE_INT|CTLFLAG_RW, adapter, 0, + OID_AUTO, "debug_info", CTLTYPE_INT|CTLFLAG_RW, 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, "stats", CTLTYPE_INT|CTLFLAG_RW, adapter, 0, + OID_AUTO, "stats", CTLTYPE_INT|CTLFLAG_RW, sc, 0, em_sysctl_stats, "I", "Statistics"); - callout_init(&adapter->timer, CALLOUT_MPSAFE); - callout_init(&adapter->tx_fifo_timer, CALLOUT_MPSAFE); + callout_init(&sc->timer, CALLOUT_MPSAFE); + callout_init(&sc->tx_fifo_timer, CALLOUT_MPSAFE); /* Determine hardware revision */ - em_identify_hardware(adapter); + em_identify_hardware(sc); /* 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, - E1000_REG_OFFSET(&adapter->hw, RDTR), em_rx_int_delay_dflt); - em_add_int_delay_sysctl(adapter, "tx_int_delay", - "transmit interrupt delay in usecs", &adapter->tx_int_delay, - E1000_REG_OFFSET(&adapter->hw, TIDV), em_tx_int_delay_dflt); - if (adapter->hw.mac_type >= em_82540) { - em_add_int_delay_sysctl(adapter, "rx_abs_int_delay", + 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", - &adapter->rx_abs_int_delay, - E1000_REG_OFFSET(&adapter->hw, RADV), + &sc->rx_abs_int_delay, + E1000_REG_OFFSET(&sc->hw, 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, - E1000_REG_OFFSET(&adapter->hw, TADV), + &sc->tx_abs_int_delay, + E1000_REG_OFFSET(&sc->hw, TADV), em_tx_abs_int_delay_dflt); } #ifndef DEVICE_POLLING /* Sysctls for limiting the amount of work done in the taskqueue */ - em_add_int_process_limit(adapter, "rx_processing_limit", - "max number of rx packets to process", &adapter->rx_process_limit, + em_add_int_process_limit(sc, "rx_processing_limit", + "max number of rx packets to process", &sc->rx_process_limit, em_rx_process_limit); #endif /* * Validate number of transmit and receive descriptors. It * must not exceed hardware maximum, and must be multiple - * of EM_DBA_ALIGN. + * of E1000_DBA_ALIGN. */ - if (((em_txd * sizeof(struct em_tx_desc)) % EM_DBA_ALIGN) != 0 || - (adapter->hw.mac_type >= em_82544 && em_txd > EM_MAX_TXD) || - (adapter->hw.mac_type < em_82544 && em_txd > EM_MAX_TXD_82543) || + if (((em_txd * sizeof(struct em_tx_desc)) % E1000_DBA_ALIGN) != 0 || + (sc->hw.mac_type >= em_82544 && em_txd > EM_MAX_TXD) || + (sc->hw.mac_type < em_82544 && em_txd > EM_MAX_TXD_82543) || (em_txd < EM_MIN_TXD)) { device_printf(dev, "Using %d TX descriptors instead of %d!\n", EM_DEFAULT_TXD, em_txd); - adapter->num_tx_desc = EM_DEFAULT_TXD; + sc->num_tx_desc = EM_DEFAULT_TXD; } else - adapter->num_tx_desc = em_txd; - if (((em_rxd * sizeof(struct em_rx_desc)) % EM_DBA_ALIGN) != 0 || - (adapter->hw.mac_type >= em_82544 && em_rxd > EM_MAX_RXD) || - (adapter->hw.mac_type < em_82544 && em_rxd > EM_MAX_RXD_82543) || + sc->num_tx_desc = em_txd; + if (((em_rxd * sizeof(struct em_rx_desc)) % E1000_DBA_ALIGN) != 0 || + (sc->hw.mac_type >= em_82544 && em_rxd > EM_MAX_RXD) || + (sc->hw.mac_type < em_82544 && em_rxd > EM_MAX_RXD_82543) || (em_rxd < EM_MIN_RXD)) { device_printf(dev, "Using %d RX descriptors instead of %d!\n", EM_DEFAULT_RXD, em_rxd); - adapter->num_rx_desc = EM_DEFAULT_RXD; + sc->num_rx_desc = EM_DEFAULT_RXD; } else - adapter->num_rx_desc = em_rxd; + sc->num_rx_desc = em_rxd; - adapter->hw.autoneg = DO_AUTO_NEG; - adapter->hw.wait_autoneg_complete = WAIT_FOR_AUTO_NEG_DEFAULT; - adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; - adapter->hw.tbi_compatibility_en = TRUE; - adapter->rx_buffer_len = EM_RXBUFFER_2048; + sc->hw.autoneg = DO_AUTO_NEG; + sc->hw.wait_autoneg_complete = WAIT_FOR_AUTO_NEG_DEFAULT; + sc->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; + sc->hw.tbi_compatibility_en = TRUE; + sc->rx_buffer_len = EM_RXBUFFER_2048; - adapter->hw.phy_init_script = 1; - adapter->hw.phy_reset_disable = FALSE; + sc->hw.phy_init_script = 1; + sc->hw.phy_reset_disable = FALSE; #ifndef EM_MASTER_SLAVE - adapter->hw.master_slave = em_ms_hw_default; + sc->hw.master_slave = em_ms_hw_default; #else - adapter->hw.master_slave = EM_MASTER_SLAVE; + sc->hw.master_slave = EM_MASTER_SLAVE; #endif /* * Set the max frame size assuming standard ethernet * sized frames. */ - adapter->hw.max_frame_size = ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; + sc->hw.max_frame_size = ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; - adapter->hw.min_frame_size = MINIMUM_ETHERNET_PACKET_SIZE + ETHER_CRC_LEN; + sc->hw.min_frame_size = MINIMUM_ETHERNET_PACKET_SIZE + ETHER_CRC_LEN; /* * This controls when hardware reports transmit completion * status. */ - adapter->hw.report_tx_early = 1; - if (em_allocate_pci_resources(adapter)) { + sc->hw.report_tx_early = 1; + if (em_allocate_pci_resources(sc)) { device_printf(dev, "Allocation of PCI resources failed\n"); error = ENXIO; goto err_pci; } /* Initialize eeprom parameters */ - em_init_eeprom_params(&adapter->hw); + em_init_eeprom_params(&sc->hw); - tsize = roundup2(adapter->num_tx_desc * sizeof(struct em_tx_desc), - EM_DBA_ALIGN); + tsize = roundup2(sc->num_tx_desc * sizeof(struct em_tx_desc), + E1000_DBA_ALIGN); /* Allocate Transmit Descriptor ring */ - if (em_dma_malloc(adapter, tsize, &adapter->txdma, BUS_DMA_NOWAIT)) { + if (em_dma_malloc(sc, tsize, &sc->txdma, BUS_DMA_NOWAIT)) { device_printf(dev, "Unable to allocate tx_desc memory\n"); error = ENOMEM; goto err_tx_desc; } - adapter->tx_desc_base = (struct em_tx_desc *)adapter->txdma.dma_vaddr; + sc->tx_desc_base = (struct em_tx_desc *)sc->txdma.dma_vaddr; - rsize = roundup2(adapter->num_rx_desc * sizeof(struct em_rx_desc), - EM_DBA_ALIGN); + rsize = roundup2(sc->num_rx_desc * sizeof(struct em_rx_desc), + E1000_DBA_ALIGN); /* Allocate Receive Descriptor ring */ - if (em_dma_malloc(adapter, rsize, &adapter->rxdma, BUS_DMA_NOWAIT)) { + if (em_dma_malloc(sc, rsize, &sc->rxdma, BUS_DMA_NOWAIT)) { device_printf(dev, "Unable to allocate rx_desc memory\n"); error = ENOMEM; goto err_rx_desc; } - adapter->rx_desc_base = (struct em_rx_desc *)adapter->rxdma.dma_vaddr; + sc->rx_desc_base = (struct em_rx_desc *)sc->rxdma.dma_vaddr; /* Initialize the hardware */ - if (em_hardware_init(adapter)) { + if (em_hardware_init(sc)) { device_printf(dev, "Unable to initialize the hardware\n"); error = EIO; goto err_hw_init; } /* Copy the permanent MAC address out of the EEPROM */ - if (em_read_mac_addr(&adapter->hw) < 0) { + if (em_read_mac_addr(&sc->hw) < 0) { device_printf(dev, "EEPROM read error while reading MAC" " address\n"); error = EIO; goto err_hw_init; } - if (!em_is_valid_ether_addr(adapter->hw.mac_addr)) { + if (!em_is_valid_ether_addr(sc->hw.mac_addr)) { device_printf(dev, "Invalid MAC address\n"); error = EIO; goto err_hw_init; } /* Setup OS specific network interface */ - em_setup_interface(dev, adapter); + em_setup_interface(dev, sc); - em_allocate_intr(adapter); + em_allocate_intr(sc); /* Initialize statistics */ - em_clear_hw_cntrs(&adapter->hw); - em_update_stats_counters(adapter); - adapter->hw.get_link_status = 1; - em_update_link_status(adapter); + em_clear_hw_cntrs(&sc->hw); + em_update_stats_counters(sc); + sc->hw.get_link_status = 1; + em_update_link_status(sc); /* Indicate SOL/IDER usage */ - if (em_check_phy_reset_block(&adapter->hw)) + if (em_check_phy_reset_block(&sc->hw)) device_printf(dev, "PHY reset is blocked due to SOL/IDER session.\n"); /* Identify 82544 on PCIX */ - em_get_bus_info(&adapter->hw); - if(adapter->hw.bus_type == em_bus_type_pcix && adapter->hw.mac_type == em_82544) - adapter->pcix_82544 = TRUE; + em_get_bus_info(&sc->hw); + if(sc->hw.bus_type == em_bus_type_pcix && sc->hw.mac_type == em_82544) + sc->pcix_82544 = TRUE; else - adapter->pcix_82544 = FALSE; + sc->pcix_82544 = FALSE; INIT_DEBUGOUT("em_attach: end"); return (0); err_hw_init: - em_dma_free(adapter, &adapter->rxdma); + em_dma_free(sc, &sc->rxdma); err_rx_desc: - em_dma_free(adapter, &adapter->txdma); + em_dma_free(sc, &sc->txdma); err_tx_desc: err_pci: - em_free_intr(adapter); - em_free_pci_resources(adapter); - EM_LOCK_DESTROY(adapter); + em_free_intr(sc); + em_free_pci_resources(sc); + EM_LOCK_DESTROY(sc); return (error); } @@ -597,8 +589,8 @@ static int em_detach(device_t dev) { - struct adapter *adapter = device_get_softc(dev); - struct ifnet *ifp = adapter->ifp; + struct em_softc *sc = device_get_softc(dev); + struct ifnet *ifp = sc->ifp; INIT_DEBUGOUT("em_detach: begin"); @@ -607,31 +599,31 @@ ether_poll_deregister(ifp); #endif - em_free_intr(adapter); - EM_LOCK(adapter); - adapter->in_detach = 1; - em_stop(adapter); - em_phy_hw_reset(&adapter->hw); - EM_UNLOCK(adapter); - ether_ifdetach(adapter->ifp); + em_free_intr(sc); + EM_LOCK(sc); + sc->in_detach = 1; + em_stop(sc); + em_phy_hw_reset(&sc->hw); + EM_UNLOCK(sc); + ether_ifdetach(sc->ifp); - em_free_pci_resources(adapter); + em_free_pci_resources(sc); bus_generic_detach(dev); if_free(ifp); /* Free Transmit Descriptor ring */ - if (adapter->tx_desc_base) { - em_dma_free(adapter, &adapter->txdma); - adapter->tx_desc_base = NULL; + if (sc->tx_desc_base) { + em_dma_free(sc, &sc->txdma); + sc->tx_desc_base = NULL; } /* Free Receive Descriptor ring */ - if (adapter->rx_desc_base) { - em_dma_free(adapter, &adapter->rxdma); - adapter->rx_desc_base = NULL; + if (sc->rx_desc_base) { + em_dma_free(sc, &sc->rxdma); + sc->rx_desc_base = NULL; } - EM_LOCK_DESTROY(adapter); + EM_LOCK_DESTROY(sc); return (0); } @@ -645,10 +637,10 @@ static int em_shutdown(device_t dev) { - struct adapter *adapter = device_get_softc(dev); - EM_LOCK(adapter); - em_stop(adapter); - EM_UNLOCK(adapter); + struct em_softc *sc = device_get_softc(dev); + EM_LOCK(sc); + em_stop(sc); + EM_UNLOCK(sc); return (0); } @@ -658,11 +650,11 @@ static int em_suspend(device_t dev) { - struct adapter *adapter = device_get_softc(dev); + struct em_softc *sc = device_get_softc(dev); - EM_LOCK(adapter); - em_stop(adapter); - EM_UNLOCK(adapter); + EM_LOCK(sc); + em_stop(sc); + EM_UNLOCK(sc); return bus_generic_suspend(dev); } @@ -670,15 +662,15 @@ static int em_resume(device_t dev) { - struct adapter *adapter = device_get_softc(dev); - struct ifnet *ifp = adapter->ifp; + struct em_softc *sc = device_get_softc(dev); + struct ifnet *ifp = sc->ifp; - EM_LOCK(adapter); - em_init_locked(adapter); + EM_LOCK(sc); + em_init_locked(sc); if ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING)) em_start_locked(ifp); - EM_UNLOCK(adapter); + EM_UNLOCK(sc); return bus_generic_resume(dev); } @@ -697,15 +689,15 @@ static void em_start_locked(struct ifnet *ifp) { - struct adapter *adapter = ifp->if_softc; + struct em_softc *sc = ifp->if_softc; struct mbuf *m_head; - EM_LOCK_ASSERT(adapter); + EM_LOCK_ASSERT(sc); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return; - if (!adapter->link_active) + if (!sc->link_active) return; while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { @@ -717,7 +709,7 @@ * em_encap() can modify our pointer, and or make it NULL on * failure. In that event, we can't requeue. */ - if (em_encap(adapter, &m_head)) { + if (em_encap(sc, &m_head)) { if (m_head == NULL) break; ifp->if_drv_flags |= IFF_DRV_OACTIVE; @@ -736,12 +728,12 @@ static void em_start(struct ifnet *ifp) { - struct adapter *adapter = ifp->if_softc; + struct em_softc *sc = ifp->if_softc; - EM_LOCK(adapter); + EM_LOCK(sc); if (ifp->if_drv_flags & IFF_DRV_RUNNING) em_start_locked(ifp); - EM_UNLOCK(adapter); + EM_UNLOCK(sc); } /********************************************************************* @@ -756,12 +748,12 @@ static int em_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { - struct adapter *adapter = ifp->if_softc; + struct em_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; int error = 0; - if (adapter->in_detach) + if (sc->in_detach) return (error); switch (command) { @@ -777,9 +769,9 @@ */ ifp->if_flags |= IFF_UP; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { - EM_LOCK(adapter); - em_init_locked(adapter); - EM_UNLOCK(adapter); + EM_LOCK(sc); + em_init_locked(sc); + EM_UNLOCK(sc); } arp_ifinit(ifp, ifa); } else @@ -792,14 +784,14 @@ IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFMTU (Set Interface MTU)"); - EM_LOCK(adapter); - switch (adapter->hw.mac_type) { + EM_LOCK(sc); + switch (sc->hw.mac_type) { case em_82573: /* * 82573 only supports jumbo frames * if ASPM is disabled. */ - em_read_eeprom(&adapter->hw, EEPROM_INIT_3GIO_3, 1, + em_read_eeprom(&sc->hw, EEPROM_INIT_3GIO_3, 1, &eeprom_data); if (eeprom_data & EEPROM_WORD1A_ASPM_MASK) { max_frame_size = ETHER_MAX_LEN; @@ -811,68 +803,64 @@ case em_80003es2lan: /* Limit Jumbo Frame size */ max_frame_size = 9234; break; - case em_ich8lan: - /* ICH8 does not support jumbo frames */ - max_frame_size = ETHER_MAX_LEN; - break; default: max_frame_size = MAX_JUMBO_FRAME_SIZE; } if (ifr->ifr_mtu > max_frame_size - ETHER_HDR_LEN - ETHER_CRC_LEN) { - EM_UNLOCK(adapter); + EM_UNLOCK(sc); error = EINVAL; break; } ifp->if_mtu = ifr->ifr_mtu; - adapter->hw.max_frame_size = + sc->hw.max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - em_init_locked(adapter); - EM_UNLOCK(adapter); + em_init_locked(sc); + EM_UNLOCK(sc); break; } case SIOCSIFFLAGS: IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFFLAGS (Set Interface Flags)"); - EM_LOCK(adapter); + EM_LOCK(sc); if (ifp->if_flags & IFF_UP) { if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) { - if ((ifp->if_flags ^ adapter->if_flags) & + if ((ifp->if_flags ^ sc->if_flags) & IFF_PROMISC) { - em_disable_promisc(adapter); - em_set_promisc(adapter); + em_disable_promisc(sc); + em_set_promisc(sc); } } else - em_init_locked(adapter); + em_init_locked(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - em_stop(adapter); + em_stop(sc); } } - adapter->if_flags = ifp->if_flags; - EM_UNLOCK(adapter); + sc->if_flags = ifp->if_flags; + EM_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI"); if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - EM_LOCK(adapter); - em_disable_intr(adapter); - em_set_multi(adapter); - if (adapter->hw.mac_type == em_82542_rev2_0) { - em_initialize_receive_unit(adapter); + EM_LOCK(sc); + em_disable_intr(sc); + em_set_multi(sc); + if (sc->hw.mac_type == em_82542_rev2_0) { + em_initialize_receive_unit(sc); } #ifdef DEVICE_POLLING if (!(ifp->if_capenable & IFCAP_POLLING)) #endif - em_enable_intr(adapter); - EM_UNLOCK(adapter); + em_enable_intr(sc); + EM_UNLOCK(sc); } break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFMEDIA (Get/Set Interface Media)"); - error = ifmedia_ioctl(ifp, ifr, &adapter->media, command); + error = ifmedia_ioctl(ifp, ifr, &sc->media, command); break; case SIOCSIFCAP: { @@ -887,17 +875,17 @@ error = ether_poll_register(em_poll, ifp); if (error) return (error); - EM_LOCK(adapter); - em_disable_intr(adapter); + EM_LOCK(sc); + em_disable_intr(sc); ifp->if_capenable |= IFCAP_POLLING; - EM_UNLOCK(adapter); + EM_UNLOCK(sc); } else { error = ether_poll_deregister(ifp); /* Enable interrupt even in error case */ - EM_LOCK(adapter); - em_enable_intr(adapter); + EM_LOCK(sc); + em_enable_intr(sc); ifp->if_capenable &= ~IFCAP_POLLING; - EM_UNLOCK(adapter); + EM_UNLOCK(sc); } } #endif @@ -910,7 +898,7 @@ reinit = 1; } if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING)) - em_init(adapter); + em_init(sc); VLAN_CAPABILITIES(ifp); break; } @@ -932,26 +920,26 @@ static void em_watchdog(struct ifnet *ifp) { - struct adapter *adapter = ifp->if_softc; + struct em_softc *sc = ifp->if_softc; - EM_LOCK(adapter); + EM_LOCK(sc); /* If we are in this routine because of pause frames, then * don't reset the hardware. */ - if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_TXOFF) { + if (E1000_READ_REG(&sc->hw, STATUS) & E1000_STATUS_TXOFF) { ifp->if_timer = EM_TX_TIMEOUT; - EM_UNLOCK(adapter); + EM_UNLOCK(sc); return; } - if (em_check_for_link(&adapter->hw) == 0) - device_printf(adapter->dev, "watchdog timeout -- resetting\n"); + if (em_check_for_link(&sc->hw) == 0) + device_printf(sc->dev, "watchdog timeout -- resetting\n"); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - adapter->watchdog_events++; + sc->watchdog_events++; - em_init_locked(adapter); - EM_UNLOCK(adapter); + em_init_locked(sc); + EM_UNLOCK(sc); } /********************************************************************* @@ -966,39 +954,33 @@ **********************************************************************/ static void -em_init_locked(struct adapter *adapter) +em_init_locked(struct em_softc *sc) { - struct ifnet *ifp = adapter->ifp; - device_t dev = adapter->dev; + struct ifnet *ifp = sc->ifp; + device_t dev = sc->dev; uint32_t pba; INIT_DEBUGOUT("em_init: begin"); - EM_LOCK_ASSERT(adapter); + EM_LOCK_ASSERT(sc); - em_stop(adapter); + em_stop(sc); /* * Packet Buffer Allocation (PBA) * Writing PBA sets the receive portion of the buffer * the remainder is used for the transmit buffer. - * - * Devices before the 82547 had a Packet Buffer of 64K. - * Default allocation: PBA=48K for Rx, leaving 16K for Tx. - * After the 82547 the buffer was reduced to 40K. - * Default allocation: PBA=30K for Rx, leaving 10K for Tx. - * Note: default does not leave enough room for Jumbo Frame >10k. */ - switch (adapter->hw.mac_type) { + switch (sc->hw.mac_type) { case em_82547: case em_82547_rev_2: /* 82547: Total Packet Buffer is 40K */ - if (adapter->hw.max_frame_size > EM_RXBUFFER_8192) + if (sc->hw.max_frame_size > EM_RXBUFFER_8192) pba = E1000_PBA_22K; /* 22K for Rx, 18K for Tx */ else pba = E1000_PBA_30K; /* 30K for Rx, 10K for Tx */ - adapter->tx_fifo_head = 0; - adapter->tx_head_addr = pba << EM_TX_HEAD_ADDR_SHIFT; - adapter->tx_fifo_size = (E1000_PBA_40K - pba) << EM_PBA_BYTES_SHIFT; + sc->tx_fifo_head = 0; + sc->tx_head_addr = pba << EM_TX_HEAD_ADDR_SHIFT; + sc->tx_fifo_size = (E1000_PBA_40K - pba) << EM_PBA_BYTES_SHIFT; break; case em_80003es2lan: /* 80003es2lan: Total Packet Buffer is 48K */ case em_82571: /* 82571: Total Packet Buffer is 48K */ @@ -1009,90 +991,87 @@ /* Jumbo frames not supported */ pba = E1000_PBA_12K; /* 12K for Rx, 20K for Tx */ break; - case em_ich8lan: - pba = E1000_PBA_8K; - break; default: /* Devices before 82547 had a Packet Buffer of 64K. */ - if(adapter->hw.max_frame_size > EM_RXBUFFER_8192) + if(sc->hw.max_frame_size > EM_RXBUFFER_8192) pba = E1000_PBA_40K; /* 40K for Rx, 24K for Tx */ else pba = E1000_PBA_48K; /* 48K for Rx, 16K for Tx */ } INIT_DEBUGOUT1("em_init: pba=%dK",pba); - E1000_WRITE_REG(&adapter->hw, PBA, pba); + E1000_WRITE_REG(&sc->hw, PBA, pba); /* Get the latest mac address, User can use a LAA */ - bcopy(IF_LLADDR(adapter->ifp), adapter->hw.mac_addr, ETHER_ADDR_LEN); + bcopy(IF_LLADDR(sc->ifp), sc->hw.mac_addr, ETHER_ADDR_LEN); /* Initialize the hardware */ - if (em_hardware_init(adapter)) { + if (em_hardware_init(sc)) { device_printf(dev, "Unable to initialize the hardware\n"); return; } - em_update_link_status(adapter); + em_update_link_status(sc); if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) - em_enable_vlans(adapter); + em_enable_vlans(sc); /* Prepare transmit descriptors and buffers */ - if (em_setup_transmit_structures(adapter)) { >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608032215.k73MFHx4084054>