if_igb.c (235527) | if_igb.c (238262) |
---|---|
1/****************************************************************************** 2 | 1/****************************************************************************** 2 |
3 Copyright (c) 2001-2011, Intel Corporation | 3 Copyright (c) 2001-2012, Intel Corporation |
4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 13 unchanged lines hidden (view full) --- 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32******************************************************************************/ | 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 13 unchanged lines hidden (view full) --- 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32******************************************************************************/ |
33/*$FreeBSD: stable/9/sys/dev/e1000/if_igb.c 235527 2012-05-16 22:22:52Z jfv $*/ | 33/*$FreeBSD: stable/9/sys/dev/e1000/if_igb.c 238262 2012-07-08 20:35:56Z jfv $*/ |
34 35 36#ifdef HAVE_KERNEL_OPTION_HEADERS 37#include "opt_device_polling.h" 38#include "opt_inet.h" 39#include "opt_inet6.h" 40#include "opt_altq.h" 41#endif --- 53 unchanged lines hidden (view full) --- 95/********************************************************************* 96 * Set this to one to display debug statistics 97 *********************************************************************/ 98int igb_display_debug_stats = 0; 99 100/********************************************************************* 101 * Driver version: 102 *********************************************************************/ | 34 35 36#ifdef HAVE_KERNEL_OPTION_HEADERS 37#include "opt_device_polling.h" 38#include "opt_inet.h" 39#include "opt_inet6.h" 40#include "opt_altq.h" 41#endif --- 53 unchanged lines hidden (view full) --- 95/********************************************************************* 96 * Set this to one to display debug statistics 97 *********************************************************************/ 98int igb_display_debug_stats = 0; 99 100/********************************************************************* 101 * Driver version: 102 *********************************************************************/ |
103char igb_driver_version[] = "version - 2.3.1"; | 103char igb_driver_version[] = "version - 2.3.4"; |
104 105 106/********************************************************************* 107 * PCI Device ID Table 108 * 109 * Used by probe to select devices to load on 110 * Last field stores an index into e1000_strings 111 * Last entry must be all 0s --- 33 unchanged lines hidden (view full) --- 145 { 0x8086, E1000_DEV_ID_DH89XXCC_SFP, PCI_ANY_ID, PCI_ANY_ID, 0}, 146 { 0x8086, E1000_DEV_ID_DH89XXCC_BACKPLANE, 147 PCI_ANY_ID, PCI_ANY_ID, 0}, 148 { 0x8086, E1000_DEV_ID_I350_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0}, 149 { 0x8086, E1000_DEV_ID_I350_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0}, 150 { 0x8086, E1000_DEV_ID_I350_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0}, 151 { 0x8086, E1000_DEV_ID_I350_SGMII, PCI_ANY_ID, PCI_ANY_ID, 0}, 152 { 0x8086, E1000_DEV_ID_I350_VF, PCI_ANY_ID, PCI_ANY_ID, 0}, | 104 105 106/********************************************************************* 107 * PCI Device ID Table 108 * 109 * Used by probe to select devices to load on 110 * Last field stores an index into e1000_strings 111 * Last entry must be all 0s --- 33 unchanged lines hidden (view full) --- 145 { 0x8086, E1000_DEV_ID_DH89XXCC_SFP, PCI_ANY_ID, PCI_ANY_ID, 0}, 146 { 0x8086, E1000_DEV_ID_DH89XXCC_BACKPLANE, 147 PCI_ANY_ID, PCI_ANY_ID, 0}, 148 { 0x8086, E1000_DEV_ID_I350_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0}, 149 { 0x8086, E1000_DEV_ID_I350_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0}, 150 { 0x8086, E1000_DEV_ID_I350_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0}, 151 { 0x8086, E1000_DEV_ID_I350_SGMII, PCI_ANY_ID, PCI_ANY_ID, 0}, 152 { 0x8086, E1000_DEV_ID_I350_VF, PCI_ANY_ID, PCI_ANY_ID, 0}, |
153 { 0x8086, E1000_DEV_ID_I210_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0}, 154 { 0x8086, E1000_DEV_ID_I210_COPPER_IT, PCI_ANY_ID, PCI_ANY_ID, 0}, 155 { 0x8086, E1000_DEV_ID_I210_COPPER_OEM1, 156 PCI_ANY_ID, PCI_ANY_ID, 0}, 157 { 0x8086, E1000_DEV_ID_I210_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0}, 158 { 0x8086, E1000_DEV_ID_I210_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0}, 159 { 0x8086, E1000_DEV_ID_I210_SGMII, PCI_ANY_ID, PCI_ANY_ID, 0}, 160 { 0x8086, E1000_DEV_ID_I211_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0}, |
|
153 /* required last entry */ 154 { 0, 0, 0, 0, 0} 155}; 156 157/********************************************************************* 158 * Table of branding strings for all supported NICs. 159 *********************************************************************/ 160 --- 103 unchanged lines hidden (view full) --- 264static void igb_handle_que(void *context, int pending); 265static void igb_handle_link(void *context, int pending); 266static void igb_handle_link_locked(struct adapter *); 267 268static void igb_set_sysctl_value(struct adapter *, const char *, 269 const char *, int *, int); 270static int igb_set_flowcntl(SYSCTL_HANDLER_ARGS); 271static int igb_sysctl_dmac(SYSCTL_HANDLER_ARGS); | 161 /* required last entry */ 162 { 0, 0, 0, 0, 0} 163}; 164 165/********************************************************************* 166 * Table of branding strings for all supported NICs. 167 *********************************************************************/ 168 --- 103 unchanged lines hidden (view full) --- 272static void igb_handle_que(void *context, int pending); 273static void igb_handle_link(void *context, int pending); 274static void igb_handle_link_locked(struct adapter *); 275 276static void igb_set_sysctl_value(struct adapter *, const char *, 277 const char *, int *, int); 278static int igb_set_flowcntl(SYSCTL_HANDLER_ARGS); 279static int igb_sysctl_dmac(SYSCTL_HANDLER_ARGS); |
280static int igb_sysctl_eee(SYSCTL_HANDLER_ARGS); |
|
272 273#ifdef DEVICE_POLLING 274static poll_handler_t igb_poll; 275#endif /* POLLING */ 276 277/********************************************************************* 278 * FreeBSD Device Interface Entry Points 279 *********************************************************************/ --- 293 unchanged lines hidden (view full) --- 573 } 574 575 /* Some adapter-specific advanced features */ 576 if (adapter->hw.mac.type >= e1000_i350) { 577 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), 578 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), 579 OID_AUTO, "dmac", CTLTYPE_INT|CTLFLAG_RW, 580 adapter, 0, igb_sysctl_dmac, "I", "DMA Coalesce"); | 281 282#ifdef DEVICE_POLLING 283static poll_handler_t igb_poll; 284#endif /* POLLING */ 285 286/********************************************************************* 287 * FreeBSD Device Interface Entry Points 288 *********************************************************************/ --- 293 unchanged lines hidden (view full) --- 582 } 583 584 /* Some adapter-specific advanced features */ 585 if (adapter->hw.mac.type >= e1000_i350) { 586 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), 587 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), 588 OID_AUTO, "dmac", CTLTYPE_INT|CTLFLAG_RW, 589 adapter, 0, igb_sysctl_dmac, "I", "DMA Coalesce"); |
581 igb_set_sysctl_value(adapter, "eee_disabled", 582 "enable Energy Efficient Ethernet", 583 &adapter->hw.dev_spec._82575.eee_disable, 584 TRUE); 585 e1000_set_eee_i350(&adapter->hw); | 590 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), 591 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), 592 OID_AUTO, "eee_disabled", CTLTYPE_INT|CTLFLAG_RW, 593 adapter, 0, igb_sysctl_eee, "I", 594 "Disable Energy Efficient Ethernet"); 595 if (adapter->hw.phy.media_type == e1000_media_type_copper) 596 e1000_set_eee_i350(&adapter->hw); |
586 } 587 588 /* 589 ** Start from a known state, this is 590 ** important in reading the nvm and 591 ** mac from that. 592 */ 593 e1000_reset_hw(&adapter->hw); 594 595 /* Make sure we have a good EEPROM before we read from it */ | 597 } 598 599 /* 600 ** Start from a known state, this is 601 ** important in reading the nvm and 602 ** mac from that. 603 */ 604 e1000_reset_hw(&adapter->hw); 605 606 /* Make sure we have a good EEPROM before we read from it */ |
596 if (e1000_validate_nvm_checksum(&adapter->hw) < 0) { | 607 if (((adapter->hw.mac.type != e1000_i210) && 608 (adapter->hw.mac.type != e1000_i211)) && 609 (e1000_validate_nvm_checksum(&adapter->hw) < 0)) { |
597 /* 598 ** Some PCI-E parts fail the first check due to 599 ** the link being in sleep state, call it again, 600 ** if it fails a second time its a real issue. 601 */ 602 if (e1000_validate_nvm_checksum(&adapter->hw) < 0) { 603 device_printf(dev, 604 "The EEPROM Checksum Is Not Valid\n"); --- 236 unchanged lines hidden (view full) --- 841 } 842 } 843 IGB_CORE_UNLOCK(adapter); 844 845 return bus_generic_resume(dev); 846} 847 848 | 610 /* 611 ** Some PCI-E parts fail the first check due to 612 ** the link being in sleep state, call it again, 613 ** if it fails a second time its a real issue. 614 */ 615 if (e1000_validate_nvm_checksum(&adapter->hw) < 0) { 616 device_printf(dev, 617 "The EEPROM Checksum Is Not Valid\n"); --- 236 unchanged lines hidden (view full) --- 854 } 855 } 856 IGB_CORE_UNLOCK(adapter); 857 858 return bus_generic_resume(dev); 859} 860 861 |
862#if __FreeBSD_version < 800000 863 |
|
849/********************************************************************* 850 * Transmit entry point 851 * 852 * igb_start is called by the stack to initiate a transmit. 853 * The driver will remain in this routine as long as there are 854 * packets to transmit and transmit resources are available. 855 * In case resources are not available stack is notified and 856 * the packet is requeued. --- 60 unchanged lines hidden (view full) --- 917 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 918 IGB_TX_LOCK(txr); 919 igb_start_locked(txr, ifp); 920 IGB_TX_UNLOCK(txr); 921 } 922 return; 923} 924 | 864/********************************************************************* 865 * Transmit entry point 866 * 867 * igb_start is called by the stack to initiate a transmit. 868 * The driver will remain in this routine as long as there are 869 * packets to transmit and transmit resources are available. 870 * In case resources are not available stack is notified and 871 * the packet is requeued. --- 60 unchanged lines hidden (view full) --- 932 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 933 IGB_TX_LOCK(txr); 934 igb_start_locked(txr, ifp); 935 IGB_TX_UNLOCK(txr); 936 } 937 return; 938} 939 |
925#if __FreeBSD_version >= 800000 | 940#else /* __FreeBSD_version >= 800000 */ 941 |
926/* 927** Multiqueue Transmit driver 928** 929*/ 930static int 931igb_mq_start(struct ifnet *ifp, struct mbuf *m) 932{ 933 struct adapter *adapter = ifp->if_softc; 934 struct igb_queue *que; 935 struct tx_ring *txr; 936 int i, err = 0; | 942/* 943** Multiqueue Transmit driver 944** 945*/ 946static int 947igb_mq_start(struct ifnet *ifp, struct mbuf *m) 948{ 949 struct adapter *adapter = ifp->if_softc; 950 struct igb_queue *que; 951 struct tx_ring *txr; 952 int i, err = 0; |
937 bool moveable = TRUE; | |
938 939 /* Which queue to use */ | 953 954 /* Which queue to use */ |
940 if ((m->m_flags & M_FLOWID) != 0) { | 955 if ((m->m_flags & M_FLOWID) != 0) |
941 i = m->m_pkthdr.flowid % adapter->num_queues; | 956 i = m->m_pkthdr.flowid % adapter->num_queues; |
942 moveable = FALSE; 943 } else | 957 else |
944 i = curcpu % adapter->num_queues; 945 946 txr = &adapter->tx_rings[i]; 947 que = &adapter->queues[i]; 948 if (((txr->queue_status & IGB_QUEUE_DEPLETED) == 0) && 949 IGB_TX_TRYLOCK(txr)) { 950 err = igb_mq_start_locked(ifp, txr, m); 951 IGB_TX_UNLOCK(txr); --- 383 unchanged lines hidden (view full) --- 1335 else 1336#endif /* DEVICE_POLLING */ 1337 { 1338 igb_enable_intr(adapter); 1339 E1000_WRITE_REG(&adapter->hw, E1000_ICS, E1000_ICS_LSC); 1340 } 1341 1342 /* Set Energy Efficient Ethernet */ | 958 i = curcpu % adapter->num_queues; 959 960 txr = &adapter->tx_rings[i]; 961 que = &adapter->queues[i]; 962 if (((txr->queue_status & IGB_QUEUE_DEPLETED) == 0) && 963 IGB_TX_TRYLOCK(txr)) { 964 err = igb_mq_start_locked(ifp, txr, m); 965 IGB_TX_UNLOCK(txr); --- 383 unchanged lines hidden (view full) --- 1349 else 1350#endif /* DEVICE_POLLING */ 1351 { 1352 igb_enable_intr(adapter); 1353 E1000_WRITE_REG(&adapter->hw, E1000_ICS, E1000_ICS_LSC); 1354 } 1355 1356 /* Set Energy Efficient Ethernet */ |
1343 1344 e1000_set_eee_i350(&adapter->hw); | 1357 if (adapter->hw.phy.media_type == e1000_media_type_copper) 1358 e1000_set_eee_i350(&adapter->hw); |
1345} 1346 1347static void 1348igb_init(void *arg) 1349{ 1350 struct adapter *adapter = arg; 1351 1352 IGB_CORE_LOCK(adapter); --- 1206 unchanged lines hidden (view full) --- 2559 E1000_WRITE_REG(hw, E1000_GPIE, 2560 E1000_GPIE_MSIX_MODE | E1000_GPIE_EIAME | 2561 E1000_GPIE_PBA | E1000_GPIE_NSICR); 2562 2563 /* Turn on MSIX */ 2564 switch (adapter->hw.mac.type) { 2565 case e1000_82580: 2566 case e1000_i350: | 1359} 1360 1361static void 1362igb_init(void *arg) 1363{ 1364 struct adapter *adapter = arg; 1365 1366 IGB_CORE_LOCK(adapter); --- 1206 unchanged lines hidden (view full) --- 2573 E1000_WRITE_REG(hw, E1000_GPIE, 2574 E1000_GPIE_MSIX_MODE | E1000_GPIE_EIAME | 2575 E1000_GPIE_PBA | E1000_GPIE_NSICR); 2576 2577 /* Turn on MSIX */ 2578 switch (adapter->hw.mac.type) { 2579 case e1000_82580: 2580 case e1000_i350: |
2581 case e1000_i210: 2582 case e1000_i211: |
|
2567 case e1000_vfadapt: 2568 case e1000_vfadapt_i350: 2569 /* RX entries */ 2570 for (int i = 0; i < adapter->num_queues; i++) { 2571 u32 index = i >> 1; 2572 ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index); 2573 que = &adapter->queues[i]; 2574 if (i & 1) { --- 182 unchanged lines hidden (view full) --- 2757 2758/* 2759 * Setup Either MSI/X or MSI 2760 */ 2761static int 2762igb_setup_msix(struct adapter *adapter) 2763{ 2764 device_t dev = adapter->dev; | 2583 case e1000_vfadapt: 2584 case e1000_vfadapt_i350: 2585 /* RX entries */ 2586 for (int i = 0; i < adapter->num_queues; i++) { 2587 u32 index = i >> 1; 2588 ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index); 2589 que = &adapter->queues[i]; 2590 if (i & 1) { --- 182 unchanged lines hidden (view full) --- 2773 2774/* 2775 * Setup Either MSI/X or MSI 2776 */ 2777static int 2778igb_setup_msix(struct adapter *adapter) 2779{ 2780 device_t dev = adapter->dev; |
2765 int rid, want, queues, msgs; | 2781 int rid, want, queues, msgs, maxqueues; |
2766 2767 /* tuneable override */ 2768 if (igb_enable_msix == 0) 2769 goto msi; 2770 2771 /* First try MSI/X */ 2772 rid = PCIR_BAR(IGB_MSIX_BAR); 2773 adapter->msix_mem = bus_alloc_resource_any(dev, --- 14 unchanged lines hidden (view full) --- 2788 } 2789 2790 /* Figure out a reasonable auto config value */ 2791 queues = (mp_ncpus > (msgs-1)) ? (msgs-1) : mp_ncpus; 2792 2793 /* Manual override */ 2794 if (igb_num_queues != 0) 2795 queues = igb_num_queues; | 2782 2783 /* tuneable override */ 2784 if (igb_enable_msix == 0) 2785 goto msi; 2786 2787 /* First try MSI/X */ 2788 rid = PCIR_BAR(IGB_MSIX_BAR); 2789 adapter->msix_mem = bus_alloc_resource_any(dev, --- 14 unchanged lines hidden (view full) --- 2804 } 2805 2806 /* Figure out a reasonable auto config value */ 2807 queues = (mp_ncpus > (msgs-1)) ? (msgs-1) : mp_ncpus; 2808 2809 /* Manual override */ 2810 if (igb_num_queues != 0) 2811 queues = igb_num_queues; |
2796 if (queues > 8) /* max queues */ 2797 queues = 8; | |
2798 | 2812 |
2799 /* Can have max of 4 queues on 82575 */ 2800 if ((adapter->hw.mac.type == e1000_82575) && (queues > 4)) 2801 queues = 4; | 2813 /* Sanity check based on HW */ 2814 switch (adapter->hw.mac.type) { 2815 case e1000_82575: 2816 maxqueues = 4; 2817 break; 2818 case e1000_82576: 2819 case e1000_82580: 2820 case e1000_i350: 2821 maxqueues = 8; 2822 break; 2823 case e1000_i210: 2824 maxqueues = 4; 2825 break; 2826 case e1000_i211: 2827 maxqueues = 2; 2828 break; 2829 default: /* VF interfaces */ 2830 maxqueues = 1; 2831 break; 2832 } 2833 if (queues > maxqueues) 2834 queues = maxqueues; |
2802 | 2835 |
2803 /* Limit the VF devices to one queue */ 2804 if (adapter->vf_ifp) 2805 queues = 1; 2806 | |
2807 /* 2808 ** One vector (RX/TX pair) per queue 2809 ** plus an additional for Link interrupt 2810 */ 2811 want = queues + 1; 2812 if (msgs >= want) 2813 msgs = want; 2814 else { --- 53 unchanged lines hidden (view full) --- 2868 pba &= E1000_RXPBS_SIZE_MASK_82576; 2869 break; 2870 case e1000_82580: 2871 case e1000_i350: 2872 case e1000_vfadapt_i350: 2873 pba = E1000_READ_REG(hw, E1000_RXPBS); 2874 pba = e1000_rxpbs_adjust_82580(pba); 2875 break; | 2836 /* 2837 ** One vector (RX/TX pair) per queue 2838 ** plus an additional for Link interrupt 2839 */ 2840 want = queues + 1; 2841 if (msgs >= want) 2842 msgs = want; 2843 else { --- 53 unchanged lines hidden (view full) --- 2897 pba &= E1000_RXPBS_SIZE_MASK_82576; 2898 break; 2899 case e1000_82580: 2900 case e1000_i350: 2901 case e1000_vfadapt_i350: 2902 pba = E1000_READ_REG(hw, E1000_RXPBS); 2903 pba = e1000_rxpbs_adjust_82580(pba); 2904 break; |
2905 case e1000_i210: 2906 case e1000_i211: 2907 pba = E1000_PBA_34K; |
|
2876 default: 2877 break; 2878 } 2879 2880 /* Special needs in case of Jumbo frames */ 2881 if ((hw->mac.type == e1000_82575) && (ifp->if_mtu > ETHERMTU)) { 2882 u32 tx_space, min_tx, min_rx; 2883 pba = E1000_READ_REG(hw, E1000_PBA); --- 51 unchanged lines hidden (view full) --- 2935 /* Issue a global reset */ 2936 e1000_reset_hw(hw); 2937 E1000_WRITE_REG(hw, E1000_WUC, 0); 2938 2939 if (e1000_init_hw(hw) < 0) 2940 device_printf(dev, "Hardware Initialization Failed\n"); 2941 2942 /* Setup DMA Coalescing */ | 2908 default: 2909 break; 2910 } 2911 2912 /* Special needs in case of Jumbo frames */ 2913 if ((hw->mac.type == e1000_82575) && (ifp->if_mtu > ETHERMTU)) { 2914 u32 tx_space, min_tx, min_rx; 2915 pba = E1000_READ_REG(hw, E1000_PBA); --- 51 unchanged lines hidden (view full) --- 2967 /* Issue a global reset */ 2968 e1000_reset_hw(hw); 2969 E1000_WRITE_REG(hw, E1000_WUC, 0); 2970 2971 if (e1000_init_hw(hw) < 0) 2972 device_printf(dev, "Hardware Initialization Failed\n"); 2973 2974 /* Setup DMA Coalescing */ |
2943 if (hw->mac.type == e1000_i350) { | 2975 if ((hw->mac.type > e1000_82580) && 2976 (hw->mac.type != e1000_i211)) { 2977 u32 dmac; |
2944 u32 reg = ~E1000_DMACR_DMAC_EN; 2945 2946 if (adapter->dmac == 0) { /* Disabling it */ 2947 E1000_WRITE_REG(hw, E1000_DMACR, reg); 2948 goto reset_out; 2949 } 2950 | 2978 u32 reg = ~E1000_DMACR_DMAC_EN; 2979 2980 if (adapter->dmac == 0) { /* Disabling it */ 2981 E1000_WRITE_REG(hw, E1000_DMACR, reg); 2982 goto reset_out; 2983 } 2984 |
2951 hwm = (pba - 4) << 10; 2952 reg = (((pba-6) << E1000_DMACR_DMACTHR_SHIFT) 2953 & E1000_DMACR_DMACTHR_MASK); | 2985 /* Set starting thresholds */ 2986 E1000_WRITE_REG(hw, E1000_DMCTXTH, 0); 2987 E1000_WRITE_REG(hw, E1000_DMCRTRH, 0); |
2954 | 2988 |
2989 hwm = 64 * pba - adapter->max_frame_size / 16; 2990 if (hwm < 64 * (pba - 6)) 2991 hwm = 64 * (pba - 6); 2992 reg = E1000_READ_REG(hw, E1000_FCRTC); 2993 reg &= ~E1000_FCRTC_RTH_COAL_MASK; 2994 reg |= ((hwm << E1000_FCRTC_RTH_COAL_SHIFT) 2995 & E1000_FCRTC_RTH_COAL_MASK); 2996 E1000_WRITE_REG(hw, E1000_FCRTC, reg); 2997 2998 2999 dmac = pba - adapter->max_frame_size / 512; 3000 if (dmac < pba - 10) 3001 dmac = pba - 10; 3002 reg = E1000_READ_REG(hw, E1000_DMACR); 3003 reg &= ~E1000_DMACR_DMACTHR_MASK; 3004 reg = ((dmac << E1000_DMACR_DMACTHR_SHIFT) 3005 & E1000_DMACR_DMACTHR_MASK); |
|
2955 /* transition to L0x or L1 if available..*/ 2956 reg |= (E1000_DMACR_DMAC_EN | E1000_DMACR_DMAC_LX_MASK); | 3006 /* transition to L0x or L1 if available..*/ 3007 reg |= (E1000_DMACR_DMAC_EN | E1000_DMACR_DMAC_LX_MASK); |
2957 | |
2958 /* timer = value in adapter->dmac in 32usec intervals */ 2959 reg |= (adapter->dmac >> 5); 2960 E1000_WRITE_REG(hw, E1000_DMACR, reg); 2961 | 3008 /* timer = value in adapter->dmac in 32usec intervals */ 3009 reg |= (adapter->dmac >> 5); 3010 E1000_WRITE_REG(hw, E1000_DMACR, reg); 3011 |
2962 /* No lower threshold */ 2963 E1000_WRITE_REG(hw, E1000_DMCRTRH, 0); 2964 2965 /* set hwm to PBA - 2 * max frame size */ 2966 E1000_WRITE_REG(hw, E1000_FCRTC, hwm); 2967 | |
2968 /* Set the interval before transition */ 2969 reg = E1000_READ_REG(hw, E1000_DMCTLX); | 3012 /* Set the interval before transition */ 3013 reg = E1000_READ_REG(hw, E1000_DMCTLX); |
2970 reg |= 0x800000FF; /* 255 usec */ | 3014 reg |= 0x80000004; |
2971 E1000_WRITE_REG(hw, E1000_DMCTLX, reg); 2972 2973 /* free space in tx packet buffer to wake from DMA coal */ 2974 E1000_WRITE_REG(hw, E1000_DMCTXTH, 2975 (20480 - (2 * adapter->max_frame_size)) >> 6); 2976 2977 /* make low power state decision controlled by DMA coal */ 2978 reg = E1000_READ_REG(hw, E1000_PCIEMISC); | 3015 E1000_WRITE_REG(hw, E1000_DMCTLX, reg); 3016 3017 /* free space in tx packet buffer to wake from DMA coal */ 3018 E1000_WRITE_REG(hw, E1000_DMCTXTH, 3019 (20480 - (2 * adapter->max_frame_size)) >> 6); 3020 3021 /* make low power state decision controlled by DMA coal */ 3022 reg = E1000_READ_REG(hw, E1000_PCIEMISC); |
2979 E1000_WRITE_REG(hw, E1000_PCIEMISC, 2980 reg | E1000_PCIEMISC_LX_DECISION); | 3023 reg &= ~E1000_PCIEMISC_LX_DECISION; 3024 E1000_WRITE_REG(hw, E1000_PCIEMISC, reg); |
2981 device_printf(dev, "DMA Coalescing enabled\n"); | 3025 device_printf(dev, "DMA Coalescing enabled\n"); |
3026 3027 } else if (hw->mac.type == e1000_82580) { 3028 u32 reg = E1000_READ_REG(hw, E1000_PCIEMISC); 3029 E1000_WRITE_REG(hw, E1000_DMACR, 0); 3030 E1000_WRITE_REG(hw, E1000_PCIEMISC, 3031 reg & ~E1000_PCIEMISC_LX_DECISION); |
|
2982 } 2983 2984reset_out: 2985 E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN); 2986 e1000_get_phy_info(hw); 2987 e1000_check_for_link(hw); 2988 return; 2989} --- 15 unchanged lines hidden (view full) --- 3005 device_printf(dev, "can not allocate ifnet structure\n"); 3006 return (-1); 3007 } 3008 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 3009 ifp->if_init = igb_init; 3010 ifp->if_softc = adapter; 3011 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 3012 ifp->if_ioctl = igb_ioctl; | 3032 } 3033 3034reset_out: 3035 E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN); 3036 e1000_get_phy_info(hw); 3037 e1000_check_for_link(hw); 3038 return; 3039} --- 15 unchanged lines hidden (view full) --- 3055 device_printf(dev, "can not allocate ifnet structure\n"); 3056 return (-1); 3057 } 3058 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 3059 ifp->if_init = igb_init; 3060 ifp->if_softc = adapter; 3061 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 3062 ifp->if_ioctl = igb_ioctl; |
3013 ifp->if_start = igb_start; | |
3014#if __FreeBSD_version >= 800000 3015 ifp->if_transmit = igb_mq_start; 3016 ifp->if_qflush = igb_qflush; | 3063#if __FreeBSD_version >= 800000 3064 ifp->if_transmit = igb_mq_start; 3065 ifp->if_qflush = igb_qflush; |
3017#endif | 3066#else 3067 ifp->if_start = igb_start; |
3018 IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1); 3019 ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1; 3020 IFQ_SET_READY(&ifp->if_snd); | 3068 IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1); 3069 ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1; 3070 IFQ_SET_READY(&ifp->if_snd); |
3071#endif |
|
3021 3022 ether_ifattach(ifp, adapter->hw.mac.addr); 3023 3024 ifp->if_capabilities = ifp->if_capenable = 0; 3025 3026 ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM; 3027 ifp->if_capabilities |= IFCAP_TSO4; 3028 ifp->if_capabilities |= IFCAP_JUMBO_MTU; --- 2905 unchanged lines hidden (view full) --- 5934 /* Do nothing, illegal value */ 5935 adapter->dmac = 0; 5936 return (error); 5937 } 5938 /* Reinit the interface */ 5939 igb_init(adapter); 5940 return (error); 5941} | 3072 3073 ether_ifattach(ifp, adapter->hw.mac.addr); 3074 3075 ifp->if_capabilities = ifp->if_capenable = 0; 3076 3077 ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM; 3078 ifp->if_capabilities |= IFCAP_TSO4; 3079 ifp->if_capabilities |= IFCAP_JUMBO_MTU; --- 2905 unchanged lines hidden (view full) --- 5985 /* Do nothing, illegal value */ 5986 adapter->dmac = 0; 5987 return (error); 5988 } 5989 /* Reinit the interface */ 5990 igb_init(adapter); 5991 return (error); 5992} |
5993 5994/* 5995** Manage Energy Efficient Ethernet: 5996** Control values: 5997** 0/1 - enabled/disabled 5998*/ 5999static int 6000igb_sysctl_eee(SYSCTL_HANDLER_ARGS) 6001{ 6002 struct adapter *adapter = (struct adapter *) arg1; 6003 int error, value; 6004 6005 value = adapter->hw.dev_spec._82575.eee_disable; 6006 error = sysctl_handle_int(oidp, &value, 0, req); 6007 if (error || req->newptr == NULL) 6008 return (error); 6009 IGB_CORE_LOCK(adapter); 6010 adapter->hw.dev_spec._82575.eee_disable = (value != 0); 6011 igb_init_locked(adapter); 6012 IGB_CORE_UNLOCK(adapter); 6013 return (0); 6014} |
|