2008-04-02 22:00:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 2001-2008, Intel Corporation
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
3. Neither the name of the Intel Corporation nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
/*$FreeBSD$*/
|
2002-02-13 18:19:27 +00:00
|
|
|
|
2005-10-05 10:09:17 +00:00
|
|
|
#ifdef HAVE_KERNEL_OPTION_HEADERS
|
|
|
|
#include "opt_device_polling.h"
|
2008-12-07 21:32:56 +00:00
|
|
|
#include "opt_inet.h"
|
2005-10-05 10:09:17 +00:00
|
|
|
#endif
|
|
|
|
|
2006-02-14 13:11:36 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/endian.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/kthread.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/taskqueue.h>
|
2008-11-26 23:57:23 +00:00
|
|
|
#include <sys/eventhandler.h>
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
2006-02-14 13:11:36 +00:00
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/if_vlan_var.h>
|
|
|
|
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in.h>
|
2006-07-20 04:18:45 +00:00
|
|
|
#include <netinet/if_ether.h>
|
2006-02-14 13:11:36 +00:00
|
|
|
#include <netinet/ip.h>
|
2006-10-28 08:11:07 +00:00
|
|
|
#include <netinet/ip6.h>
|
2006-02-14 13:11:36 +00:00
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <netinet/udp.h>
|
|
|
|
|
2006-09-09 20:05:24 +00:00
|
|
|
#include <machine/in_cksum.h>
|
2006-02-14 13:11:36 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
#include "e1000_api.h"
|
2008-05-21 21:06:17 +00:00
|
|
|
#include "e1000_82571.h"
|
2007-05-04 00:00:12 +00:00
|
|
|
#include "if_em.h"
|
2001-12-02 07:37:17 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
2006-01-20 11:38:25 +00:00
|
|
|
* Set this to one to display debug statistics
|
2001-12-02 07:37:17 +00:00
|
|
|
*********************************************************************/
|
2006-02-15 08:39:50 +00:00
|
|
|
int em_display_debug_stats = 0;
|
2001-12-02 07:37:17 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
2007-05-04 00:00:12 +00:00
|
|
|
* Driver version:
|
2001-12-02 07:37:17 +00:00
|
|
|
*********************************************************************/
|
2008-11-26 23:57:23 +00:00
|
|
|
char em_driver_version[] = "6.9.6";
|
2001-12-02 07:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* PCI Device ID Table
|
|
|
|
*
|
|
|
|
* Used by probe to select devices to load on
|
2007-05-04 00:00:12 +00:00
|
|
|
* Last field stores an index into e1000_strings
|
2001-12-02 07:37:17 +00:00
|
|
|
* Last entry must be all 0s
|
|
|
|
*
|
|
|
|
* { Vendor ID, Device ID, SubVendor ID, SubDevice ID, String Index }
|
|
|
|
*********************************************************************/
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
static em_vendor_info_t em_vendor_info_array[] =
|
|
|
|
{
|
2006-02-15 08:39:50 +00:00
|
|
|
/* Intel(R) PRO/1000 Network Connection */
|
|
|
|
{ 0x8086, E1000_DEV_ID_82540EM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82540EM_LOM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82540EP, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82540EP_LOM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82540EP_LP, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541EI, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541ER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541ER_LOM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541EI_MOBILE, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541GI, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541GI_LF, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82541GI_MOBILE, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82542, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82543GC_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82543GC_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
|
|
|
{ 0x8086, E1000_DEV_ID_82544EI_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82544EI_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82544GC_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82544GC_LOM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
|
|
|
{ 0x8086, E1000_DEV_ID_82545EM_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82545EM_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82545GM_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82545GM_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82545GM_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546EB_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546EB_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546EB_QUAD_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546GB_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546GB_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546GB_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546GB_PCIE, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82546GB_QUAD_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-04-06 17:09:03 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-02-15 08:39:50 +00:00
|
|
|
|
|
|
|
{ 0x8086, E1000_DEV_ID_82547EI, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82547EI_MOBILE, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82547GI, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
|
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2008-05-21 21:06:17 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_SERDES_DUAL,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_SERDES_QUAD,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-08-11 10:58:24 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_QUAD_COPPER,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
2007-05-04 00:00:12 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_QUAD_COPPER_LP,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82571EB_QUAD_FIBER,
|
2006-10-31 15:00:14 +00:00
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
2007-11-20 21:41:22 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82571PT_QUAD_COPPER,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-02-15 08:39:50 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82572EI_COPPER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82572EI_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_82572EI_SERDES, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-04-06 17:09:03 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82572EI, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-02-15 08:39:50 +00:00
|
|
|
|
|
|
|
{ 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},
|
2006-08-03 09:20:11 +00:00
|
|
|
{ 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},
|
2006-04-06 17:09:03 +00:00
|
|
|
{ 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},
|
2006-10-31 15:00:14 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH8_IGP_M_AMT, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-08-03 09:20:11 +00:00
|
|
|
{ 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},
|
2006-10-31 15:00:14 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH8_IFE_GT, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH8_IFE_G, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH8_IGP_M, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-02-15 08:39:50 +00:00
|
|
|
|
2008-05-21 21:06:17 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IGP_M_AMT, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2007-05-04 00:00:12 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IGP_AMT, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IGP_C, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2008-05-21 21:06:17 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IGP_M, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IGP_M_V, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2007-05-04 00:00:12 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IFE, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IFE_GT, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_IFE_G, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2008-05-19 23:01:11 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH9_BM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_82574L, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2008-05-21 21:06:17 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH10_R_BM_LM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH10_R_BM_LF, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH10_R_BM_V, PCI_ANY_ID, PCI_ANY_ID, 0},
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
{ 0x8086, E1000_DEV_ID_ICH10_D_BM_LM, PCI_ANY_ID, PCI_ANY_ID, 0},
|
|
|
|
{ 0x8086, E1000_DEV_ID_ICH10_D_BM_LF, PCI_ANY_ID, PCI_ANY_ID, 0},
|
2006-02-15 08:39:50 +00:00
|
|
|
/* required last entry */
|
|
|
|
{ 0, 0, 0, 0, 0}
|
2001-12-02 07:37:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* Table of branding strings for all supported NICs.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static char *em_strings[] = {
|
2002-06-03 22:30:51 +00:00
|
|
|
"Intel(R) PRO/1000 Network Connection"
|
2001-12-02 07:37:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*********************************************************************
|
2006-01-20 11:38:25 +00:00
|
|
|
* Function prototypes
|
2001-12-02 07:37:17 +00:00
|
|
|
*********************************************************************/
|
2006-02-15 08:39:50 +00:00
|
|
|
static int em_probe(device_t);
|
|
|
|
static int em_attach(device_t);
|
|
|
|
static int em_detach(device_t);
|
|
|
|
static int em_shutdown(device_t);
|
|
|
|
static int em_suspend(device_t);
|
|
|
|
static int em_resume(device_t);
|
|
|
|
static void em_start(struct ifnet *);
|
|
|
|
static void em_start_locked(struct ifnet *ifp);
|
|
|
|
static int em_ioctl(struct ifnet *, u_long, caddr_t);
|
2006-11-09 16:00:18 +00:00
|
|
|
static void em_watchdog(struct adapter *);
|
2006-02-15 08:39:50 +00:00
|
|
|
static void em_init(void *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static void em_init_locked(struct adapter *);
|
2006-02-15 08:39:50 +00:00
|
|
|
static void em_stop(void *);
|
|
|
|
static void em_media_status(struct ifnet *, struct ifmediareq *);
|
|
|
|
static int em_media_change(struct ifnet *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static void em_identify_hardware(struct adapter *);
|
|
|
|
static int em_allocate_pci_resources(struct adapter *);
|
2008-02-29 21:50:11 +00:00
|
|
|
static int em_allocate_legacy(struct adapter *adapter);
|
|
|
|
static int em_allocate_msix(struct adapter *adapter);
|
|
|
|
static int em_setup_msix(struct adapter *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static void em_free_pci_resources(struct adapter *);
|
2006-02-15 08:39:50 +00:00
|
|
|
static void em_local_timer(void *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static int em_hardware_init(struct adapter *);
|
|
|
|
static void em_setup_interface(device_t, struct adapter *);
|
2007-11-20 21:41:22 +00:00
|
|
|
static void em_setup_transmit_structures(struct adapter *);
|
2006-08-03 19:05:04 +00:00
|
|
|
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 *);
|
2007-11-20 21:41:22 +00:00
|
|
|
static void em_tx_purge(struct adapter *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static int em_allocate_receive_structures(struct adapter *);
|
|
|
|
static int em_allocate_transmit_structures(struct adapter *);
|
|
|
|
static int em_rxeof(struct adapter *, int);
|
2005-12-16 08:29:43 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
2006-08-03 19:05:04 +00:00
|
|
|
static int em_fixup_rx(struct adapter *);
|
2005-12-16 08:29:43 +00:00
|
|
|
#endif
|
2007-05-04 00:00:12 +00:00
|
|
|
static void em_receive_checksum(struct adapter *, struct e1000_rx_desc *,
|
2006-02-15 08:39:50 +00:00
|
|
|
struct mbuf *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static void em_transmit_checksum_setup(struct adapter *, struct mbuf *,
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 *, u32 *);
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2008-02-29 21:50:11 +00:00
|
|
|
static bool em_tso_setup(struct adapter *, struct mbuf *,
|
|
|
|
u32 *, u32 *);
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif /* FreeBSD_version >= 700000 */
|
2006-08-03 19:05:04 +00:00
|
|
|
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 *);
|
2006-10-28 08:11:07 +00:00
|
|
|
static int em_get_buf(struct adapter *, int);
|
2008-11-26 23:57:23 +00:00
|
|
|
|
|
|
|
static void em_register_vlan(void *, struct ifnet *, u16);
|
|
|
|
static void em_unregister_vlan(void *, struct ifnet *, u16);
|
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
static int em_xmit(struct adapter *, struct mbuf **);
|
2006-08-03 19:05:04 +00:00
|
|
|
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 *);
|
2007-05-04 00:00:12 +00:00
|
|
|
static void em_82547_move_tail(void *);
|
2006-08-03 19:05:04 +00:00
|
|
|
static int em_dma_malloc(struct adapter *, bus_size_t,
|
2007-05-04 00:00:12 +00:00
|
|
|
struct em_dma_alloc *, int);
|
2006-08-03 19:05:04 +00:00
|
|
|
static void em_dma_free(struct adapter *, struct em_dma_alloc *);
|
|
|
|
static void em_print_debug_info(struct adapter *);
|
2007-11-20 21:41:22 +00:00
|
|
|
static void em_print_nvm_info(struct adapter *);
|
2008-02-29 21:50:11 +00:00
|
|
|
static int em_is_valid_ether_addr(u8 *);
|
2006-02-15 08:39:50 +00:00
|
|
|
static int em_sysctl_stats(SYSCTL_HANDLER_ARGS);
|
|
|
|
static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS);
|
2008-02-29 21:50:11 +00:00
|
|
|
static u32 em_fill_descriptors (bus_addr_t address, u32 length,
|
2006-02-15 08:39:50 +00:00
|
|
|
PDESC_ARRAY desc_array);
|
|
|
|
static int em_sysctl_int_delay(SYSCTL_HANDLER_ARGS);
|
2006-08-03 19:05:04 +00:00
|
|
|
static void em_add_int_delay_sysctl(struct adapter *, const char *,
|
2007-05-04 00:00:12 +00:00
|
|
|
const char *, struct em_int_delay_info *, int, int);
|
|
|
|
/* Management and WOL Support */
|
|
|
|
static void em_init_manageability(struct adapter *);
|
|
|
|
static void em_release_manageability(struct adapter *);
|
|
|
|
static void em_get_hw_control(struct adapter *);
|
|
|
|
static void em_release_hw_control(struct adapter *);
|
|
|
|
static void em_enable_wakeup(device_t);
|
2006-06-06 08:03:49 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
/* Precision Time sync support */
|
|
|
|
static int em_tsync_init(struct adapter *);
|
|
|
|
static void em_tsync_disable(struct adapter *);
|
|
|
|
#endif
|
2008-04-02 22:00:36 +00:00
|
|
|
|
|
|
|
#ifdef EM_LEGACY_IRQ
|
2007-11-20 21:41:22 +00:00
|
|
|
static void em_intr(void *);
|
|
|
|
#else /* FAST IRQ */
|
|
|
|
#if __FreeBSD_version < 700000
|
2008-02-29 21:50:11 +00:00
|
|
|
static void em_irq_fast(void *);
|
2006-10-28 08:11:07 +00:00
|
|
|
#else
|
2008-02-29 21:50:11 +00:00
|
|
|
static int em_irq_fast(void *);
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/* MSIX handlers */
|
|
|
|
static void em_msix_tx(void *);
|
|
|
|
static void em_msix_rx(void *);
|
|
|
|
static void em_msix_link(void *);
|
2007-05-04 00:00:12 +00:00
|
|
|
static void em_add_rx_process_limit(struct adapter *, const char *,
|
|
|
|
const char *, int *, int);
|
2006-10-28 08:11:07 +00:00
|
|
|
static void em_handle_rxtx(void *context, int pending);
|
2008-02-29 21:50:11 +00:00
|
|
|
static void em_handle_rx(void *context, int pending);
|
|
|
|
static void em_handle_tx(void *context, int pending);
|
2006-10-28 08:11:07 +00:00
|
|
|
static void em_handle_link(void *context, int pending);
|
2008-04-02 22:00:36 +00:00
|
|
|
#endif /* EM_LEGACY_IRQ */
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-11-21 12:55:33 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
static poll_handler_t em_poll;
|
|
|
|
#endif /* POLLING */
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
2006-01-20 11:38:25 +00:00
|
|
|
* FreeBSD Device Interface Entry Points
|
2001-12-02 07:37:17 +00:00
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static device_method_t em_methods[] = {
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, em_probe),
|
|
|
|
DEVMETHOD(device_attach, em_attach),
|
|
|
|
DEVMETHOD(device_detach, em_detach),
|
|
|
|
DEVMETHOD(device_shutdown, em_shutdown),
|
2005-12-26 10:39:21 +00:00
|
|
|
DEVMETHOD(device_suspend, em_suspend),
|
|
|
|
DEVMETHOD(device_resume, em_resume),
|
2002-06-03 22:30:51 +00:00
|
|
|
{0, 0}
|
2001-12-02 07:37:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t em_driver = {
|
2006-08-03 19:05:04 +00:00
|
|
|
"em", em_methods, sizeof(struct adapter),
|
2001-12-02 07:37:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t em_devclass;
|
2003-04-15 06:37:30 +00:00
|
|
|
DRIVER_MODULE(em, pci, em_driver, em_devclass, 0, 0);
|
|
|
|
MODULE_DEPEND(em, pci, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(em, ether, 1, 1, 1);
|
2001-12-02 07:37:17 +00:00
|
|
|
|
2003-08-01 17:33:59 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* Tunable default values.
|
|
|
|
*********************************************************************/
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
#define EM_TICKS_TO_USECS(ticks) ((1024 * (ticks) + 500) / 1000)
|
|
|
|
#define EM_USECS_TO_TICKS(usecs) ((1000 * (usecs) + 512) / 1024)
|
2006-10-28 08:11:07 +00:00
|
|
|
#define M_TSO_LEN 66
|
2003-08-01 17:33:59 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Allow common code without TSO */
|
|
|
|
#ifndef CSUM_TSO
|
|
|
|
#define CSUM_TSO 0
|
|
|
|
#endif
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
static int em_tx_int_delay_dflt = EM_TICKS_TO_USECS(EM_TIDV);
|
|
|
|
static int em_rx_int_delay_dflt = EM_TICKS_TO_USECS(EM_RDTR);
|
|
|
|
static int em_tx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_TADV);
|
|
|
|
static int em_rx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_RADV);
|
2005-11-17 10:13:18 +00:00
|
|
|
static int em_rxd = EM_DEFAULT_RXD;
|
|
|
|
static int em_txd = EM_DEFAULT_TXD;
|
2006-08-03 09:20:11 +00:00
|
|
|
static int em_smart_pwr_down = FALSE;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/* Controls whether promiscuous also shows bad packets */
|
|
|
|
static int em_debug_sbp = FALSE;
|
|
|
|
/* Local switch for MSI/MSIX */
|
|
|
|
static int em_enable_msi = TRUE;
|
2003-08-01 17:33:59 +00:00
|
|
|
|
|
|
|
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);
|
2005-11-17 10:13:18 +00:00
|
|
|
TUNABLE_INT("hw.em.rxd", &em_rxd);
|
|
|
|
TUNABLE_INT("hw.em.txd", &em_txd);
|
2006-08-03 09:20:11 +00:00
|
|
|
TUNABLE_INT("hw.em.smart_pwr_down", &em_smart_pwr_down);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
TUNABLE_INT("hw.em.sbp", &em_debug_sbp);
|
|
|
|
TUNABLE_INT("hw.em.enable_msi", &em_enable_msi);
|
2008-02-29 21:50:11 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
#ifndef EM_LEGACY_IRQ
|
2007-05-04 00:00:12 +00:00
|
|
|
/* How many packets rxeof tries to clean at a time */
|
2006-10-28 08:11:07 +00:00
|
|
|
static int em_rx_process_limit = 100;
|
|
|
|
TUNABLE_INT("hw.em.rx_process_limit", &em_rx_process_limit);
|
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Global used in WOL setup with multiport cards */
|
|
|
|
static int global_quad_port_a = 0;
|
2003-08-01 17:33:59 +00:00
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* Device identification routine
|
|
|
|
*
|
|
|
|
* em_probe determines if the driver should be loaded on
|
|
|
|
* adapter based on PCI vendor/device id of the adapter.
|
|
|
|
*
|
2005-03-05 18:30:12 +00:00
|
|
|
* return BUS_PROBE_DEFAULT on success, positive on failure
|
2001-12-02 07:37:17 +00:00
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static int
|
|
|
|
em_probe(device_t dev)
|
|
|
|
{
|
2006-02-15 08:39:50 +00:00
|
|
|
char adapter_name[60];
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 pci_vendor_id = 0;
|
|
|
|
u16 pci_device_id = 0;
|
|
|
|
u16 pci_subvendor_id = 0;
|
|
|
|
u16 pci_subdevice_id = 0;
|
2002-06-03 22:30:51 +00:00
|
|
|
em_vendor_info_t *ent;
|
|
|
|
|
|
|
|
INIT_DEBUGOUT("em_probe: begin");
|
|
|
|
|
|
|
|
pci_vendor_id = pci_get_vendor(dev);
|
|
|
|
if (pci_vendor_id != EM_VENDOR_ID)
|
2006-02-15 08:39:50 +00:00
|
|
|
return (ENXIO);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
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) ||
|
2006-02-15 08:39:50 +00:00
|
|
|
(ent->subvendor_id == PCI_ANY_ID)) &&
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
((pci_subdevice_id == ent->subdevice_id) ||
|
2006-02-15 08:39:50 +00:00
|
|
|
(ent->subdevice_id == PCI_ANY_ID))) {
|
2006-01-20 11:38:25 +00:00
|
|
|
sprintf(adapter_name, "%s %s",
|
|
|
|
em_strings[ent->index],
|
2002-06-03 22:30:51 +00:00
|
|
|
em_driver_version);
|
|
|
|
device_set_desc_copy(dev, adapter_name);
|
2006-02-15 08:39:50 +00:00
|
|
|
return (BUS_PROBE_DEFAULT);
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
ent++;
|
|
|
|
}
|
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (ENXIO);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* Device initialization routine
|
|
|
|
*
|
|
|
|
* The attach entry point is called when the driver is being loaded.
|
2006-01-20 11:38:25 +00:00
|
|
|
* This routine identifies the type of hardware, allocates all resources
|
|
|
|
* and initializes the hardware.
|
|
|
|
*
|
2001-12-02 07:37:17 +00:00
|
|
|
* return 0 on success, positive on failure
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static int
|
|
|
|
em_attach(device_t dev)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter;
|
2006-02-15 08:39:50 +00:00
|
|
|
int tsize, rsize;
|
2003-06-05 17:51:38 +00:00
|
|
|
int error = 0;
|
2007-05-04 00:00:12 +00:00
|
|
|
u16 eeprom_data, device_id;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
INIT_DEBUGOUT("em_attach: begin");
|
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter = device_get_softc(dev);
|
|
|
|
adapter->dev = adapter->osdep.dev = dev;
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_INIT(adapter, device_get_nameunit(dev));
|
|
|
|
EM_TX_LOCK_INIT(adapter, device_get_nameunit(dev));
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_RX_LOCK_INIT(adapter, device_get_nameunit(dev));
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2003-06-05 17:51:38 +00:00
|
|
|
/* SYSCTL stuff */
|
2006-02-15 08:39:50 +00:00
|
|
|
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
2007-11-20 21:41:22 +00:00
|
|
|
OID_AUTO, "debug", CTLTYPE_INT|CTLFLAG_RW, adapter, 0,
|
2006-02-15 08:39:50 +00:00
|
|
|
em_sysctl_debug_info, "I", "Debug Information");
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
2006-08-03 19:05:04 +00:00
|
|
|
OID_AUTO, "stats", CTLTYPE_INT|CTLFLAG_RW, adapter, 0,
|
2006-02-15 08:39:50 +00:00
|
|
|
em_sysctl_stats, "I", "Statistics");
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
callout_init_mtx(&adapter->timer, &adapter->core_mtx, 0);
|
|
|
|
callout_init_mtx(&adapter->tx_fifo_timer, &adapter->tx_mtx, 0);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-17 00:14:03 +00:00
|
|
|
/* Determine hardware and mac info */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_identify_hardware(adapter);
|
2003-08-01 17:33:59 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Setup PCI resources */
|
|
|
|
if (em_allocate_pci_resources(adapter)) {
|
|
|
|
device_printf(dev, "Allocation of PCI resources failed\n");
|
|
|
|
error = ENXIO;
|
|
|
|
goto err_pci;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** For ICH8 and family we need to
|
|
|
|
** map the flash memory, and this
|
|
|
|
** must happen after the MAC is
|
|
|
|
** identified
|
|
|
|
*/
|
|
|
|
if ((adapter->hw.mac.type == e1000_ich8lan) ||
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich10lan) ||
|
2007-05-04 00:00:12 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich9lan)) {
|
|
|
|
int rid = EM_BAR_TYPE_FLASH;
|
2008-02-29 21:50:11 +00:00
|
|
|
adapter->flash = bus_alloc_resource_any(dev,
|
2007-05-04 00:00:12 +00:00
|
|
|
SYS_RES_MEMORY, &rid, RF_ACTIVE);
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->flash == NULL) {
|
|
|
|
device_printf(dev, "Mapping of Flash failed\n");
|
|
|
|
error = ENXIO;
|
|
|
|
goto err_pci;
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
/* This is used in the shared code */
|
2008-02-29 21:50:11 +00:00
|
|
|
adapter->hw.flash_address = (u8 *)adapter->flash;
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->osdep.flash_bus_space_tag =
|
2008-02-29 21:50:11 +00:00
|
|
|
rman_get_bustag(adapter->flash);
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->osdep.flash_bus_space_handle =
|
2008-02-29 21:50:11 +00:00
|
|
|
rman_get_bushandle(adapter->flash);
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Do Shared Code initialization */
|
|
|
|
if (e1000_setup_init_funcs(&adapter->hw, TRUE)) {
|
|
|
|
device_printf(dev, "Setup of Shared code failed\n");
|
|
|
|
error = ENXIO;
|
|
|
|
goto err_pci;
|
|
|
|
}
|
|
|
|
|
|
|
|
e1000_get_bus_info(&adapter->hw);
|
|
|
|
|
2003-08-01 17:33:59 +00:00
|
|
|
/* Set up some sysctls for the tunable interrupt delays */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_add_int_delay_sysctl(adapter, "rx_int_delay",
|
|
|
|
"receive interrupt delay in usecs", &adapter->rx_int_delay,
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_REGISTER(&adapter->hw, E1000_RDTR), em_rx_int_delay_dflt);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_add_int_delay_sysctl(adapter, "tx_int_delay",
|
|
|
|
"transmit interrupt delay in usecs", &adapter->tx_int_delay,
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_REGISTER(&adapter->hw, E1000_TIDV), em_tx_int_delay_dflt);
|
|
|
|
if (adapter->hw.mac.type >= e1000_82540) {
|
2006-08-03 19:05:04 +00:00
|
|
|
em_add_int_delay_sysctl(adapter, "rx_abs_int_delay",
|
2003-08-01 17:33:59 +00:00
|
|
|
"receive interrupt delay limit in usecs",
|
2006-08-03 19:05:04 +00:00
|
|
|
&adapter->rx_abs_int_delay,
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_REGISTER(&adapter->hw, E1000_RADV),
|
2003-08-01 17:33:59 +00:00
|
|
|
em_rx_abs_int_delay_dflt);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_add_int_delay_sysctl(adapter, "tx_abs_int_delay",
|
2003-08-01 17:33:59 +00:00
|
|
|
"transmit interrupt delay limit in usecs",
|
2006-08-03 19:05:04 +00:00
|
|
|
&adapter->tx_abs_int_delay,
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_REGISTER(&adapter->hw, E1000_TADV),
|
2003-08-01 17:33:59 +00:00
|
|
|
em_tx_abs_int_delay_dflt);
|
|
|
|
}
|
2005-11-17 10:13:18 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
#ifndef EM_LEGACY_IRQ
|
2006-10-28 08:11:07 +00:00
|
|
|
/* Sysctls for limiting the amount of work done in the taskqueue */
|
2007-05-04 00:00:12 +00:00
|
|
|
em_add_rx_process_limit(adapter, "rx_processing_limit",
|
2006-10-28 08:11:07 +00:00
|
|
|
"max number of rx packets to process", &adapter->rx_process_limit,
|
|
|
|
em_rx_process_limit);
|
|
|
|
#endif
|
|
|
|
|
2005-11-17 10:13:18 +00:00
|
|
|
/*
|
|
|
|
* Validate number of transmit and receive descriptors. It
|
|
|
|
* must not exceed hardware maximum, and must be multiple
|
2007-05-04 00:00:12 +00:00
|
|
|
* of E1000_DBA_ALIGN.
|
2005-11-17 10:13:18 +00:00
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
if (((em_txd * sizeof(struct e1000_tx_desc)) % EM_DBA_ALIGN) != 0 ||
|
|
|
|
(adapter->hw.mac.type >= e1000_82544 && em_txd > EM_MAX_TXD) ||
|
|
|
|
(adapter->hw.mac.type < e1000_82544 && em_txd > EM_MAX_TXD_82543) ||
|
2005-11-17 10:13:18 +00:00
|
|
|
(em_txd < EM_MIN_TXD)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Using %d TX descriptors instead of %d!\n",
|
|
|
|
EM_DEFAULT_TXD, em_txd);
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_tx_desc = EM_DEFAULT_TXD;
|
2005-11-17 10:13:18 +00:00
|
|
|
} else
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_tx_desc = em_txd;
|
2007-05-04 00:00:12 +00:00
|
|
|
if (((em_rxd * sizeof(struct e1000_rx_desc)) % EM_DBA_ALIGN) != 0 ||
|
|
|
|
(adapter->hw.mac.type >= e1000_82544 && em_rxd > EM_MAX_RXD) ||
|
|
|
|
(adapter->hw.mac.type < e1000_82544 && em_rxd > EM_MAX_RXD_82543) ||
|
2005-11-17 10:13:18 +00:00
|
|
|
(em_rxd < EM_MIN_RXD)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Using %d RX descriptors instead of %d!\n",
|
|
|
|
EM_DEFAULT_RXD, em_rxd);
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_rx_desc = EM_DEFAULT_RXD;
|
2005-11-17 10:13:18 +00:00
|
|
|
} else
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_rx_desc = em_rxd;
|
2005-11-17 10:13:18 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.autoneg = DO_AUTO_NEG;
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.phy.autoneg_wait_to_complete = FALSE;
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT;
|
|
|
|
adapter->rx_buffer_len = 2048;
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_init_script_state_82541(&adapter->hw, TRUE);
|
|
|
|
e1000_set_tbi_compatibility_82543(&adapter->hw, TRUE);
|
|
|
|
|
|
|
|
/* Copper options */
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->hw.phy.media_type == e1000_media_type_copper) {
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.phy.mdix = AUTO_ALL_MODES;
|
|
|
|
adapter->hw.phy.disable_polarity_correction = FALSE;
|
|
|
|
adapter->hw.phy.ms_type = EM_MASTER_SLAVE;
|
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
2007-11-20 21:41:22 +00:00
|
|
|
* Set the frame limits assuming
|
|
|
|
* standard ethernet sized frames.
|
2006-01-20 11:38:25 +00:00
|
|
|
*/
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->max_frame_size = ETHERMTU + ETHER_HDR_LEN + ETHERNET_FCS_SIZE;
|
|
|
|
adapter->min_frame_size = ETH_ZLEN + ETHERNET_FCS_SIZE;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
|
|
|
* This controls when hardware reports transmit completion
|
|
|
|
* status.
|
2003-03-21 21:47:31 +00:00
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.report_tx_early = 1;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
tsize = roundup2(adapter->num_tx_desc * sizeof(struct e1000_tx_desc),
|
2006-08-03 09:20:11 +00:00
|
|
|
EM_DBA_ALIGN);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Allocate Transmit Descriptor ring */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_dma_malloc(adapter, tsize, &adapter->txdma, BUS_DMA_NOWAIT)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to allocate tx_desc memory\n");
|
2003-06-05 17:51:38 +00:00
|
|
|
error = ENOMEM;
|
2006-02-15 08:39:50 +00:00
|
|
|
goto err_tx_desc;
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->tx_desc_base =
|
|
|
|
(struct e1000_tx_desc *)adapter->txdma.dma_vaddr;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
rsize = roundup2(adapter->num_rx_desc * sizeof(struct e1000_rx_desc),
|
2006-08-03 09:20:11 +00:00
|
|
|
EM_DBA_ALIGN);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/* Allocate Receive Descriptor ring */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_dma_malloc(adapter, rsize, &adapter->rxdma, BUS_DMA_NOWAIT)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to allocate rx_desc memory\n");
|
2003-06-05 17:51:38 +00:00
|
|
|
error = ENOMEM;
|
2006-02-15 08:39:50 +00:00
|
|
|
goto err_rx_desc;
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->rx_desc_base =
|
|
|
|
(struct e1000_rx_desc *)adapter->rxdma.dma_vaddr;
|
|
|
|
|
|
|
|
/* Make sure we have a good EEPROM before we read from it */
|
|
|
|
if (e1000_validate_nvm_checksum(&adapter->hw) < 0) {
|
|
|
|
/*
|
|
|
|
** Some PCI-E parts fail the first check due to
|
|
|
|
** the link being in sleep state, call it again,
|
|
|
|
** if it fails a second time its a real issue.
|
|
|
|
*/
|
|
|
|
if (e1000_validate_nvm_checksum(&adapter->hw) < 0) {
|
|
|
|
device_printf(dev,
|
|
|
|
"The EEPROM Checksum Is Not Valid\n");
|
|
|
|
error = EIO;
|
|
|
|
goto err_hw_init;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Initialize the hardware */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_hardware_init(adapter)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to initialize the hardware\n");
|
2003-06-05 17:51:38 +00:00
|
|
|
error = EIO;
|
2006-02-15 08:39:50 +00:00
|
|
|
goto err_hw_init;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2002-07-16 16:55:03 +00:00
|
|
|
/* Copy the permanent MAC address out of the EEPROM */
|
2007-05-04 00:00:12 +00:00
|
|
|
if (e1000_read_mac_addr(&adapter->hw) < 0) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "EEPROM read error while reading MAC"
|
|
|
|
" address\n");
|
2003-06-05 17:51:38 +00:00
|
|
|
error = EIO;
|
2006-02-15 08:39:50 +00:00
|
|
|
goto err_hw_init;
|
2002-07-16 16:55:03 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (!em_is_valid_ether_addr(adapter->hw.mac.addr)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Invalid MAC address\n");
|
|
|
|
error = EIO;
|
|
|
|
goto err_hw_init;
|
|
|
|
}
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Allocate transmit descriptors and buffers */
|
|
|
|
if (em_allocate_transmit_structures(adapter)) {
|
|
|
|
device_printf(dev, "Could not setup transmit structures\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto err_tx_struct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate receive descriptors and buffers */
|
|
|
|
if (em_allocate_receive_structures(adapter)) {
|
|
|
|
device_printf(dev, "Could not setup receive structures\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto err_rx_struct;
|
|
|
|
}
|
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/*
|
|
|
|
** Do interrupt configuration
|
|
|
|
*/
|
|
|
|
if (adapter->msi > 1) /* Do MSI/X */
|
|
|
|
error = em_allocate_msix(adapter);
|
|
|
|
else /* MSI or Legacy */
|
|
|
|
error = em_allocate_legacy(adapter);
|
|
|
|
if (error)
|
|
|
|
goto err_rx_struct;
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Setup OS specific network interface */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_setup_interface(dev, adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Initialize statistics */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_stats_counters(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
adapter->hw.mac.get_link_status = 1;
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-04-06 17:09:03 +00:00
|
|
|
/* Indicate SOL/IDER usage */
|
2007-05-04 00:00:12 +00:00
|
|
|
if (e1000_check_reset_block(&adapter->hw))
|
2006-04-06 17:09:03 +00:00
|
|
|
device_printf(dev,
|
|
|
|
"PHY reset is blocked due to SOL/IDER session.\n");
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Determine if we have to control management hardware */
|
|
|
|
adapter->has_manage = e1000_enable_mng_pass_thru(&adapter->hw);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup Wake-on-Lan
|
|
|
|
*/
|
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
|
|
|
|
case e1000_82542:
|
|
|
|
case e1000_82543:
|
|
|
|
break;
|
|
|
|
case e1000_82546:
|
|
|
|
case e1000_82546_rev_3:
|
|
|
|
case e1000_82571:
|
|
|
|
case e1000_80003es2lan:
|
|
|
|
if (adapter->hw.bus.func == 1)
|
|
|
|
e1000_read_nvm(&adapter->hw,
|
|
|
|
NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
|
|
|
|
else
|
|
|
|
e1000_read_nvm(&adapter->hw,
|
|
|
|
NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
|
|
|
|
eeprom_data &= EM_EEPROM_APME;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* APME bit in EEPROM is mapped to WUC.APME */
|
|
|
|
eeprom_data = E1000_READ_REG(&adapter->hw, E1000_WUC) &
|
|
|
|
E1000_WUC_APME;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (eeprom_data)
|
|
|
|
adapter->wol = E1000_WUFC_MAG;
|
|
|
|
/*
|
|
|
|
* We have the eeprom settings, now apply the special cases
|
|
|
|
* where the eeprom may be wrong or the board won't support
|
|
|
|
* wake on lan on a particular port
|
|
|
|
*/
|
|
|
|
device_id = pci_get_device(dev);
|
|
|
|
switch (device_id) {
|
|
|
|
case E1000_DEV_ID_82546GB_PCIE:
|
|
|
|
adapter->wol = 0;
|
|
|
|
break;
|
|
|
|
case E1000_DEV_ID_82546EB_FIBER:
|
|
|
|
case E1000_DEV_ID_82546GB_FIBER:
|
|
|
|
case E1000_DEV_ID_82571EB_FIBER:
|
|
|
|
/* Wake events only supported on port A for dual fiber
|
|
|
|
* regardless of eeprom setting */
|
|
|
|
if (E1000_READ_REG(&adapter->hw, E1000_STATUS) &
|
|
|
|
E1000_STATUS_FUNC_1)
|
|
|
|
adapter->wol = 0;
|
|
|
|
break;
|
|
|
|
case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
|
|
|
|
case E1000_DEV_ID_82571EB_QUAD_COPPER:
|
|
|
|
case E1000_DEV_ID_82571EB_QUAD_FIBER:
|
|
|
|
case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
|
|
|
|
/* if quad port adapter, disable WoL on all but port A */
|
|
|
|
if (global_quad_port_a != 0)
|
|
|
|
adapter->wol = 0;
|
|
|
|
/* Reset for multiple quad port adapters */
|
|
|
|
if (++global_quad_port_a == 4)
|
|
|
|
global_quad_port_a = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do we need workaround for 82544 PCI-X adapter? */
|
|
|
|
if (adapter->hw.bus.type == e1000_bus_type_pcix &&
|
|
|
|
adapter->hw.mac.type == e1000_82544)
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->pcix_82544 = TRUE;
|
2006-02-15 08:39:50 +00:00
|
|
|
else
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->pcix_82544 = FALSE;
|
2006-02-15 08:39:50 +00:00
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
/* Register for VLAN events */
|
|
|
|
adapter->vlan_attach = EVENTHANDLER_REGISTER(vlan_config,
|
|
|
|
em_register_vlan, 0, EVENTHANDLER_PRI_FIRST);
|
|
|
|
adapter->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig,
|
|
|
|
em_unregister_vlan, 0, EVENTHANDLER_PRI_FIRST);
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Tell the stack that the interface is not active */
|
|
|
|
adapter->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
INIT_DEBUGOUT("em_attach: end");
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
err_rx_struct:
|
|
|
|
em_free_transmit_structures(adapter);
|
|
|
|
err_tx_struct:
|
2003-06-05 17:51:38 +00:00
|
|
|
err_hw_init:
|
2007-05-04 00:00:12 +00:00
|
|
|
em_release_hw_control(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_dma_free(adapter, &adapter->rxdma);
|
2003-06-05 17:51:38 +00:00
|
|
|
err_rx_desc:
|
2006-08-03 19:05:04 +00:00
|
|
|
em_dma_free(adapter, &adapter->txdma);
|
2003-06-05 17:51:38 +00:00
|
|
|
err_tx_desc:
|
|
|
|
err_pci:
|
2006-08-03 19:05:04 +00:00
|
|
|
em_free_pci_resources(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK_DESTROY(adapter);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_RX_LOCK_DESTROY(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_DESTROY(adapter);
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* 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.
|
2006-01-20 11:38:25 +00:00
|
|
|
*
|
2001-12-02 07:37:17 +00:00
|
|
|
* return 0 on success, positive on failure
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static int
|
|
|
|
em_detach(device_t dev)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = device_get_softc(dev);
|
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
INIT_DEBUGOUT("em_detach: begin");
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Make sure VLANS are not using driver */
|
|
|
|
#if __FreeBSD_version >= 700000
|
|
|
|
if (adapter->ifp->if_vlantrunk != NULL) {
|
|
|
|
#else
|
|
|
|
if (adapter->ifp->if_nvlans != 0) {
|
|
|
|
#endif
|
|
|
|
device_printf(dev,"Vlan in use, detach first\n");
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
if (ifp->if_capenable & IFCAP_POLLING)
|
|
|
|
ether_poll_deregister(ifp);
|
|
|
|
#endif
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->in_detach = 1;
|
|
|
|
em_stop(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_phy_hw_reset(&adapter->hw);
|
|
|
|
|
|
|
|
em_release_manageability(adapter);
|
2007-05-30 23:32:21 +00:00
|
|
|
|
|
|
|
if (((adapter->hw.mac.type == e1000_82573) ||
|
|
|
|
(adapter->hw.mac.type == e1000_ich8lan) ||
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich10lan) ||
|
2007-05-30 23:32:21 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich9lan)) &&
|
|
|
|
e1000_check_mng_mode(&adapter->hw))
|
2007-05-04 00:00:12 +00:00
|
|
|
em_release_hw_control(adapter);
|
2007-05-30 23:32:21 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->wol) {
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_WUC, E1000_WUC_PME_EN);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_WUFC, adapter->wol);
|
|
|
|
em_enable_wakeup(dev);
|
|
|
|
}
|
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
|
|
|
EM_CORE_UNLOCK(adapter);
|
2005-10-14 10:34:46 +00:00
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
/* Unregister VLAN events */
|
|
|
|
if (adapter->vlan_attach != NULL)
|
|
|
|
EVENTHANDLER_DEREGISTER(vlan_config, adapter->vlan_attach);
|
|
|
|
if (adapter->vlan_detach != NULL)
|
|
|
|
EVENTHANDLER_DEREGISTER(vlan_unconfig, adapter->vlan_detach);
|
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
ether_ifdetach(adapter->ifp);
|
2006-10-31 17:05:02 +00:00
|
|
|
callout_drain(&adapter->timer);
|
|
|
|
callout_drain(&adapter->tx_fifo_timer);
|
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
em_free_pci_resources(adapter);
|
2004-02-10 21:31:09 +00:00
|
|
|
bus_generic_detach(dev);
|
2005-09-19 03:10:21 +00:00
|
|
|
if_free(ifp);
|
2004-02-10 21:31:09 +00:00
|
|
|
|
2006-10-31 17:21:14 +00:00
|
|
|
em_free_transmit_structures(adapter);
|
|
|
|
em_free_receive_structures(adapter);
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Free Transmit Descriptor ring */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->tx_desc_base) {
|
|
|
|
em_dma_free(adapter, &adapter->txdma);
|
|
|
|
adapter->tx_desc_base = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
/* Free Receive Descriptor ring */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->rx_desc_base) {
|
|
|
|
em_dma_free(adapter, &adapter->rxdma);
|
|
|
|
adapter->rx_desc_base = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK_DESTROY(adapter);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_RX_LOCK_DESTROY(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_DESTROY(adapter);
|
2003-10-10 23:14:21 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Shutdown entry point
|
2002-12-23 19:11:23 +00:00
|
|
|
*
|
2006-01-20 11:38:25 +00:00
|
|
|
**********************************************************************/
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
static int
|
|
|
|
em_shutdown(device_t dev)
|
|
|
|
{
|
2007-05-04 00:00:12 +00:00
|
|
|
return em_suspend(dev);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2005-12-26 10:39:21 +00:00
|
|
|
/*
|
|
|
|
* Suspend/resume device methods.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
em_suspend(device_t dev)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = device_get_softc(dev);
|
2005-12-26 10:39:21 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
|
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_stop(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
em_release_manageability(adapter);
|
2007-05-30 23:32:21 +00:00
|
|
|
|
|
|
|
if (((adapter->hw.mac.type == e1000_82573) ||
|
|
|
|
(adapter->hw.mac.type == e1000_ich8lan) ||
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich10lan) ||
|
2007-05-30 23:32:21 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich9lan)) &&
|
|
|
|
e1000_check_mng_mode(&adapter->hw))
|
2007-05-04 00:00:12 +00:00
|
|
|
em_release_hw_control(adapter);
|
2007-05-30 23:32:21 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->wol) {
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_WUC, E1000_WUC_PME_EN);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_WUFC, adapter->wol);
|
|
|
|
em_enable_wakeup(dev);
|
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2005-12-26 10:39:21 +00:00
|
|
|
|
|
|
|
return bus_generic_suspend(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
em_resume(device_t dev)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = device_get_softc(dev);
|
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2005-12-26 10:39:21 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
em_init_manageability(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
em_start(ifp);
|
2005-12-26 10:39:21 +00:00
|
|
|
|
|
|
|
return bus_generic_resume(dev);
|
|
|
|
}
|
|
|
|
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* Transmit entry point
|
|
|
|
*
|
|
|
|
* em_start is called by the stack to initiate a transmit.
|
|
|
|
* The driver will remain in this routine as long as there are
|
|
|
|
* packets to transmit and transmit resources are available.
|
|
|
|
* In case resources are not available stack is notified and
|
|
|
|
* the packet is requeued.
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
static void
|
2003-09-23 00:18:25 +00:00
|
|
|
em_start_locked(struct ifnet *ifp)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
2006-01-20 11:38:25 +00:00
|
|
|
struct mbuf *m_head;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK_ASSERT(adapter);
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2006-07-20 03:57:58 +00:00
|
|
|
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) !=
|
|
|
|
IFF_DRV_RUNNING)
|
|
|
|
return;
|
2006-08-03 19:05:04 +00:00
|
|
|
if (!adapter->link_active)
|
2006-01-20 11:38:25 +00:00
|
|
|
return;
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
|
2004-11-14 20:20:28 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
|
|
|
|
if (m_head == NULL)
|
|
|
|
break;
|
2004-11-14 20:20:28 +00:00
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Encapsulation can modify our pointer, and or make it
|
|
|
|
* NULL on failure. In that event, we can't requeue.
|
2004-11-14 20:20:28 +00:00
|
|
|
*/
|
2008-02-29 21:50:11 +00:00
|
|
|
if (em_xmit(adapter, &m_head)) {
|
2004-11-14 20:20:28 +00:00
|
|
|
if (m_head == NULL)
|
|
|
|
break;
|
2005-08-09 10:20:02 +00:00
|
|
|
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
2004-07-02 12:16:02 +00:00
|
|
|
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
2003-03-21 21:47:31 +00:00
|
|
|
break;
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2003-03-21 21:47:31 +00:00
|
|
|
/* Send a copy of the frame to the BPF listener */
|
2007-05-09 00:41:45 +00:00
|
|
|
ETHER_BPF_MTAP(ifp, m_head);
|
2006-01-20 11:38:25 +00:00
|
|
|
|
|
|
|
/* Set timeout in case hardware has problems transmitting. */
|
2006-11-09 16:00:18 +00:00
|
|
|
adapter->watchdog_timer = EM_TX_TIMEOUT;
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 00:18:25 +00:00
|
|
|
static void
|
|
|
|
em_start(struct ifnet *ifp)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2005-09-20 14:52:57 +00:00
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
2005-09-20 13:37:17 +00:00
|
|
|
em_start_locked(ifp);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2003-09-23 00:18:25 +00:00
|
|
|
}
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* Ioctl entry point
|
|
|
|
*
|
|
|
|
* em_ioctl is called when the user wants to configure the
|
|
|
|
* interface.
|
|
|
|
*
|
|
|
|
* return 0 on success, positive on failure
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
static int
|
2003-03-21 21:47:31 +00:00
|
|
|
em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
2006-04-06 17:09:03 +00:00
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
2008-11-06 11:00:57 +00:00
|
|
|
#ifdef INET
|
2006-07-20 04:18:45 +00:00
|
|
|
struct ifaddr *ifa = (struct ifaddr *)data;
|
2008-11-06 11:00:57 +00:00
|
|
|
#endif
|
2005-11-24 01:44:49 +00:00
|
|
|
int error = 0;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->in_detach)
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2003-11-14 18:02:25 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
switch (command) {
|
|
|
|
case SIOCSIFADDR:
|
2008-11-06 11:00:57 +00:00
|
|
|
#ifdef INET
|
2006-07-20 04:18:45 +00:00
|
|
|
if (ifa->ifa_addr->sa_family == AF_INET) {
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Since resetting hardware takes a very long time
|
|
|
|
* and results in link renegotiation we only
|
|
|
|
* initialize the hardware only when it is absolutely
|
|
|
|
* required.
|
|
|
|
*/
|
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-07-20 04:18:45 +00:00
|
|
|
}
|
|
|
|
arp_ifinit(ifp, ifa);
|
|
|
|
} else
|
2008-11-06 11:00:57 +00:00
|
|
|
#endif
|
2006-07-20 04:18:45 +00:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
|
|
|
case SIOCSIFMTU:
|
2005-11-24 01:44:49 +00:00
|
|
|
{
|
|
|
|
int max_frame_size;
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 eeprom_data = 0;
|
2005-11-24 01:44:49 +00:00
|
|
|
|
|
|
|
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFMTU (Set Interface MTU)");
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
case e1000_82573:
|
2006-04-06 17:09:03 +00:00
|
|
|
/*
|
|
|
|
* 82573 only supports jumbo frames
|
|
|
|
* if ASPM is disabled.
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_read_nvm(&adapter->hw,
|
|
|
|
NVM_INIT_3GIO_3, 1, &eeprom_data);
|
|
|
|
if (eeprom_data & NVM_WORD1A_ASPM_MASK) {
|
2006-04-06 17:09:03 +00:00
|
|
|
max_frame_size = ETHER_MAX_LEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Allow Jumbo frames - fall thru */
|
2007-05-04 00:00:12 +00:00
|
|
|
case e1000_82571:
|
|
|
|
case e1000_82572:
|
|
|
|
case e1000_ich9lan:
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
case e1000_ich10lan:
|
|
|
|
case e1000_82574:
|
2007-05-04 00:00:12 +00:00
|
|
|
case e1000_80003es2lan: /* Limit Jumbo Frame size */
|
2006-04-06 17:09:03 +00:00
|
|
|
max_frame_size = 9234;
|
2005-11-24 01:44:49 +00:00
|
|
|
break;
|
2007-05-23 20:41:20 +00:00
|
|
|
/* Adapters that do not support jumbo frames */
|
|
|
|
case e1000_82542:
|
2007-05-04 00:00:12 +00:00
|
|
|
case e1000_ich8lan:
|
2006-08-03 09:20:11 +00:00
|
|
|
max_frame_size = ETHER_MAX_LEN;
|
|
|
|
break;
|
2005-11-24 01:44:49 +00:00
|
|
|
default:
|
|
|
|
max_frame_size = MAX_JUMBO_FRAME_SIZE;
|
|
|
|
}
|
|
|
|
if (ifr->ifr_mtu > max_frame_size - ETHER_HDR_LEN -
|
|
|
|
ETHER_CRC_LEN) {
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
error = EINVAL;
|
2005-11-24 01:44:49 +00:00
|
|
|
break;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
2005-11-24 01:44:49 +00:00
|
|
|
|
|
|
|
ifp->if_mtu = ifr->ifr_mtu;
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->max_frame_size =
|
|
|
|
ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
2005-11-24 01:44:49 +00:00
|
|
|
}
|
2003-03-21 21:47:31 +00:00
|
|
|
case SIOCSIFFLAGS:
|
2007-05-04 00:00:12 +00:00
|
|
|
IOCTL_DEBUGOUT("ioctl rcv'd:\
|
|
|
|
SIOCSIFFLAGS (Set Interface Flags)");
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2003-03-21 21:47:31 +00:00
|
|
|
if (ifp->if_flags & IFF_UP) {
|
2006-07-20 04:18:45 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
2006-08-03 19:05:04 +00:00
|
|
|
if ((ifp->if_flags ^ adapter->if_flags) &
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
(IFF_PROMISC | IFF_ALLMULTI)) {
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_promisc(adapter);
|
|
|
|
em_set_promisc(adapter);
|
2006-07-20 04:18:45 +00:00
|
|
|
}
|
|
|
|
} else
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
} else
|
2007-11-26 19:47:03 +00:00
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_stop(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->if_flags = ifp->if_flags;
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2003-03-21 21:47:31 +00:00
|
|
|
break;
|
2002-06-03 22:30:51 +00:00
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
|
|
|
IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI");
|
2005-08-09 10:20:02 +00:00
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_intr(adapter);
|
|
|
|
em_set_multi(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82542 &&
|
|
|
|
adapter->hw.revision_id == E1000_REVISION_2) {
|
2006-08-03 19:05:04 +00:00
|
|
|
em_initialize_receive_unit(adapter);
|
2003-06-05 17:51:38 +00:00
|
|
|
}
|
|
|
|
#ifdef DEVICE_POLLING
|
2006-02-15 08:39:50 +00:00
|
|
|
if (!(ifp->if_capenable & IFCAP_POLLING))
|
2003-06-05 17:51:38 +00:00
|
|
|
#endif
|
2006-08-03 19:05:04 +00:00
|
|
|
em_enable_intr(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SIOCSIFMEDIA:
|
2006-10-31 15:00:14 +00:00
|
|
|
/* Check SOL/IDER usage */
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (e1000_check_reset_block(&adapter->hw)) {
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-10-31 15:00:14 +00:00
|
|
|
device_printf(adapter->dev, "Media change is"
|
2007-05-04 00:00:12 +00:00
|
|
|
" blocked due to SOL/IDER session.\n");
|
2006-10-31 15:00:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
case SIOCGIFMEDIA:
|
2007-05-04 00:00:12 +00:00
|
|
|
IOCTL_DEBUGOUT("ioctl rcv'd: \
|
|
|
|
SIOCxIFMEDIA (Get/Set Interface Media)");
|
2006-08-03 19:05:04 +00:00
|
|
|
error = ifmedia_ioctl(ifp, ifr, &adapter->media, command);
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
|
|
|
case SIOCSIFCAP:
|
2005-11-24 01:44:49 +00:00
|
|
|
{
|
|
|
|
int mask, reinit;
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)");
|
2004-06-04 16:57:18 +00:00
|
|
|
reinit = 0;
|
2002-06-03 22:30:51 +00:00
|
|
|
mask = ifr->ifr_reqcap ^ ifp->if_capenable;
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
if (mask & IFCAP_POLLING) {
|
|
|
|
if (ifr->ifr_reqcap & IFCAP_POLLING) {
|
|
|
|
error = ether_poll_register(em_poll, ifp);
|
|
|
|
if (error)
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_intr(adapter);
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
ifp->if_capenable |= IFCAP_POLLING;
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
} else {
|
|
|
|
error = ether_poll_deregister(ifp);
|
|
|
|
/* Enable interrupt even in error case */
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_enable_intr(adapter);
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
ifp->if_capenable &= ~IFCAP_POLLING;
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-03 22:30:51 +00:00
|
|
|
if (mask & IFCAP_HWCSUM) {
|
2004-04-11 21:01:12 +00:00
|
|
|
ifp->if_capenable ^= IFCAP_HWCSUM;
|
2004-06-04 16:57:18 +00:00
|
|
|
reinit = 1;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2006-10-28 08:11:07 +00:00
|
|
|
if (mask & IFCAP_TSO4) {
|
|
|
|
ifp->if_capenable ^= IFCAP_TSO4;
|
|
|
|
reinit = 1;
|
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
|
2004-06-04 16:57:18 +00:00
|
|
|
if (mask & IFCAP_VLAN_HWTAGGING) {
|
|
|
|
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
|
|
|
|
reinit = 1;
|
|
|
|
}
|
2005-08-09 10:20:02 +00:00
|
|
|
if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING))
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2006-10-28 08:11:07 +00:00
|
|
|
VLAN_CAPABILITIES(ifp);
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
2005-11-24 01:44:49 +00:00
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
/*
|
|
|
|
** IOCTL support for Precision Time (IEEE 1588) Support
|
|
|
|
*/
|
|
|
|
case EM_TIMESYNC_READTS:
|
|
|
|
{
|
|
|
|
u32 rx_ctl, tx_ctl;
|
|
|
|
struct em_tsync_read *tdata;
|
|
|
|
|
|
|
|
tdata = (struct em_tsync_read *) ifr->ifr_data;
|
|
|
|
|
|
|
|
IOCTL_DEBUGOUT("Reading Timestamp\n");
|
|
|
|
|
|
|
|
if (tdata->read_current_time) {
|
|
|
|
getnanotime(&tdata->system_time);
|
|
|
|
tdata->network_time = E1000_READ_REG(&adapter->hw, E1000_SYSTIML);
|
|
|
|
tdata->network_time |=
|
|
|
|
(u64)E1000_READ_REG(&adapter->hw, E1000_SYSTIMH ) << 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
rx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCRXCTL);
|
|
|
|
tx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCTXCTL);
|
|
|
|
|
|
|
|
IOCTL_DEBUGOUT1("RX_CTL value = %u\n", rx_ctl);
|
|
|
|
IOCTL_DEBUGOUT1("TX_CTL value = %u\n", tx_ctl);
|
|
|
|
|
|
|
|
if (rx_ctl & 0x1) {
|
|
|
|
IOCTL_DEBUGOUT("RX timestamp is valid\n");
|
|
|
|
u32 tmp;
|
|
|
|
unsigned char *tmp_cp;
|
|
|
|
|
|
|
|
tdata->rx_valid = 1;
|
|
|
|
tdata->rx_stamp = E1000_READ_REG(&adapter->hw, E1000_RXSTMPL);
|
|
|
|
tdata->rx_stamp |= (u64)E1000_READ_REG(&adapter->hw,
|
|
|
|
E1000_RXSTMPH) << 32;
|
|
|
|
|
|
|
|
tmp = E1000_READ_REG(&adapter->hw, E1000_RXSATRL);
|
|
|
|
tmp_cp = (unsigned char *) &tmp;
|
|
|
|
tdata->srcid[0] = tmp_cp[0];
|
|
|
|
tdata->srcid[1] = tmp_cp[1];
|
|
|
|
tdata->srcid[2] = tmp_cp[2];
|
|
|
|
tdata->srcid[3] = tmp_cp[3];
|
|
|
|
tmp = E1000_READ_REG(&adapter->hw, E1000_RXSATRH);
|
|
|
|
tmp_cp = (unsigned char *) &tmp;
|
|
|
|
tdata->srcid[4] = tmp_cp[0];
|
|
|
|
tdata->srcid[5] = tmp_cp[1];
|
|
|
|
tdata->seqid = tmp >> 16;
|
|
|
|
tdata->seqid = htons(tdata->seqid);
|
|
|
|
} else
|
|
|
|
tdata->rx_valid = 0;
|
|
|
|
|
|
|
|
if (tx_ctl & 0x1) {
|
|
|
|
IOCTL_DEBUGOUT("TX timestamp is valid\n");
|
|
|
|
tdata->tx_valid = 1;
|
|
|
|
tdata->tx_stamp = E1000_READ_REG(&adapter->hw, E1000_TXSTMPL);
|
|
|
|
tdata->tx_stamp |= (u64) E1000_READ_REG(&adapter->hw,
|
|
|
|
E1000_TXSTMPH) << 32;
|
|
|
|
} else
|
|
|
|
tdata->tx_valid = 0;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif /* EM_TIMESYNC */
|
2008-04-02 22:00:36 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
default:
|
2006-07-20 04:18:45 +00:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
|
|
|
break;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2006-11-09 16:00:18 +00:00
|
|
|
* Watchdog timer:
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
2006-11-09 16:00:18 +00:00
|
|
|
* This routine is called from the local timer every second.
|
|
|
|
* As long as transmit descriptors are being cleaned the value
|
|
|
|
* is non-zero and we do nothing. Reaching 0 indicates a tx hang
|
|
|
|
* and we then reset the device.
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
static void
|
2006-11-09 16:00:18 +00:00
|
|
|
em_watchdog(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_ASSERT(adapter);
|
2006-11-09 16:00:18 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
** The timer is set to 5 every time start queues a packet.
|
2007-11-20 21:41:22 +00:00
|
|
|
** Then txeof keeps resetting it as long as it cleans at
|
2007-05-04 00:00:12 +00:00
|
|
|
** least one descriptor.
|
|
|
|
** Finally, anytime all descriptors are clean the timer is
|
|
|
|
** set to 0.
|
|
|
|
*/
|
2008-04-02 22:00:36 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
|
|
|
if ((adapter->watchdog_timer == 0) || (--adapter->watchdog_timer)) {
|
|
|
|
EM_TX_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
return;
|
2008-04-02 22:00:36 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-11-09 16:00:18 +00:00
|
|
|
/* If we are in this routine because of pause frames, then
|
|
|
|
* don't reset the hardware.
|
2006-10-28 08:11:07 +00:00
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
if (E1000_READ_REG(&adapter->hw, E1000_STATUS) &
|
|
|
|
E1000_STATUS_TXOFF) {
|
2006-11-09 16:00:18 +00:00
|
|
|
adapter->watchdog_timer = EM_TX_TIMEOUT;
|
2008-04-02 22:00:36 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2006-10-28 08:11:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (e1000_check_for_link(&adapter->hw) == 0)
|
2006-08-03 19:05:04 +00:00
|
|
|
device_printf(adapter->dev, "watchdog timeout -- resetting\n");
|
2006-11-09 16:00:18 +00:00
|
|
|
adapter->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->watchdog_events++;
|
2008-05-21 21:06:17 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2005-10-20 09:55:49 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(adapter);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* Init entry point
|
|
|
|
*
|
|
|
|
* This routine is used in two ways. It is used by the stack as
|
|
|
|
* init entry point in network interface structure. It is also used
|
2006-01-20 11:38:25 +00:00
|
|
|
* by the driver as a hw/sw initialization routine to get to a
|
2001-12-02 07:37:17 +00:00
|
|
|
* consistent state.
|
|
|
|
*
|
|
|
|
* return 0 on success, positive on failure
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
|
|
|
device_t dev = adapter->dev;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 pba;
|
2004-06-04 16:57:18 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
INIT_DEBUGOUT("em_init: begin");
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_ASSERT(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_stop(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2005-11-24 01:44:49 +00:00
|
|
|
/*
|
|
|
|
* Packet Buffer Allocation (PBA)
|
2004-09-01 23:22:41 +00:00
|
|
|
* Writing PBA sets the receive portion of the buffer
|
|
|
|
* the remainder is used for the transmit buffer.
|
2006-08-03 09:20:11 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2004-09-01 23:22:41 +00:00
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
case e1000_82547:
|
|
|
|
case e1000_82547_rev_2: /* 82547: Total Packet Buffer is 40K */
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->max_frame_size > 8192)
|
2004-09-01 23:22:41 +00:00
|
|
|
pba = E1000_PBA_22K; /* 22K for Rx, 18K for Tx */
|
2005-11-24 01:44:49 +00:00
|
|
|
else
|
|
|
|
pba = E1000_PBA_30K; /* 30K for Rx, 10K for Tx */
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->tx_fifo_head = 0;
|
|
|
|
adapter->tx_head_addr = pba << EM_TX_HEAD_ADDR_SHIFT;
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->tx_fifo_size =
|
|
|
|
(E1000_PBA_40K - pba) << EM_PBA_BYTES_SHIFT;
|
2005-11-24 01:44:49 +00:00
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Total Packet Buffer on these is 48K */
|
|
|
|
case e1000_82571:
|
|
|
|
case e1000_82572:
|
|
|
|
case e1000_80003es2lan:
|
2005-11-24 01:44:49 +00:00
|
|
|
pba = E1000_PBA_32K; /* 32K for Rx, 16K for Tx */
|
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
case e1000_82573: /* 82573: Total Packet Buffer is 32K */
|
2005-11-24 01:44:49 +00:00
|
|
|
pba = E1000_PBA_12K; /* 12K for Rx, 20K for Tx */
|
|
|
|
break;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
case e1000_82574:
|
|
|
|
pba = E1000_PBA_20K; /* 20K for Rx, 20K for Tx */
|
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
case e1000_ich9lan:
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
case e1000_ich10lan:
|
2007-05-04 00:00:12 +00:00
|
|
|
#define E1000_PBA_10K 0x000A
|
|
|
|
pba = E1000_PBA_10K;
|
|
|
|
break;
|
|
|
|
case e1000_ich8lan:
|
2006-08-03 09:20:11 +00:00
|
|
|
pba = E1000_PBA_8K;
|
|
|
|
break;
|
2005-11-24 01:44:49 +00:00
|
|
|
default:
|
|
|
|
/* Devices before 82547 had a Packet Buffer of 64K. */
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->max_frame_size > 8192)
|
2005-11-24 01:44:49 +00:00
|
|
|
pba = E1000_PBA_40K; /* 40K for Rx, 24K for Tx */
|
|
|
|
else
|
|
|
|
pba = E1000_PBA_48K; /* 48K for Rx, 16K for Tx */
|
2004-09-01 23:22:41 +00:00
|
|
|
}
|
2005-11-24 01:44:49 +00:00
|
|
|
|
2004-09-01 23:22:41 +00:00
|
|
|
INIT_DEBUGOUT1("em_init: pba=%dK",pba);
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_PBA, pba);
|
2004-09-01 23:22:41 +00:00
|
|
|
|
2003-11-14 18:02:25 +00:00
|
|
|
/* Get the latest mac address, User can use a LAA */
|
2007-05-04 00:00:12 +00:00
|
|
|
bcopy(IF_LLADDR(adapter->ifp), adapter->hw.mac.addr,
|
|
|
|
ETHER_ADDR_LEN);
|
2006-02-22 14:11:16 +00:00
|
|
|
|
2007-05-09 00:41:45 +00:00
|
|
|
/* Put the address into the Receive Address Array */
|
|
|
|
e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
|
|
|
|
|
|
|
|
/*
|
2007-11-20 21:41:22 +00:00
|
|
|
* With the 82571 adapter, RAR[0] may be overwritten
|
|
|
|
* when the other port is reset, we make a duplicate
|
|
|
|
* in RAR[14] for that eventuality, this assures
|
|
|
|
* the interface continues to function.
|
2007-05-09 00:41:45 +00:00
|
|
|
*/
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82571) {
|
|
|
|
e1000_set_laa_state_82571(&adapter->hw, TRUE);
|
|
|
|
e1000_rar_set(&adapter->hw, adapter->hw.mac.addr,
|
|
|
|
E1000_RAR_ENTRIES - 1);
|
|
|
|
}
|
2007-05-09 00:41:45 +00:00
|
|
|
|
2006-02-22 14:11:16 +00:00
|
|
|
/* Initialize the hardware */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_hardware_init(adapter)) {
|
2006-02-22 14:11:16 +00:00
|
|
|
device_printf(dev, "Unable to initialize the hardware\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(adapter);
|
2003-11-14 18:02:25 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Setup VLAN support, basic and offload if available */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN);
|
2008-11-26 23:57:23 +00:00
|
|
|
|
|
|
|
/* New register interface replaces this but
|
|
|
|
waiting on kernel support to be added */
|
|
|
|
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) &&
|
|
|
|
((ifp->if_capenable & IFCAP_VLAN_HWFILTER) == 0)) {
|
|
|
|
u32 ctrl;
|
|
|
|
ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL);
|
|
|
|
ctrl |= E1000_CTRL_VME;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl);
|
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Set hardware offload abilities */
|
2006-09-21 19:14:51 +00:00
|
|
|
ifp->if_hwassist = 0;
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type >= e1000_82543) {
|
2006-09-21 19:14:51 +00:00
|
|
|
if (ifp->if_capenable & IFCAP_TXCSUM)
|
2007-05-16 00:14:23 +00:00
|
|
|
ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2007-05-16 00:14:23 +00:00
|
|
|
if (ifp->if_capenable & IFCAP_TSO4)
|
|
|
|
ifp->if_hwassist |= CSUM_TSO;
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2006-09-21 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Configure for OS presence */
|
|
|
|
em_init_manageability(adapter);
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Prepare transmit descriptors and buffers */
|
2007-11-20 21:41:22 +00:00
|
|
|
em_setup_transmit_structures(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_initialize_transmit_unit(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Setup Multicast table */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_set_multi(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Prepare receive descriptors and buffers */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_setup_receive_structures(adapter)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Could not setup receive structures\n");
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_stop(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
em_initialize_receive_unit(adapter);
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2006-08-04 07:56:35 +00:00
|
|
|
/* Don't lose promiscuous settings */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_set_promisc(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2005-08-09 10:20:02 +00:00
|
|
|
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
callout_reset(&adapter->timer, hz, em_local_timer, adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_clear_hw_cntrs_base_generic(&adapter->hw);
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/* MSI/X configuration for 82574 */
|
|
|
|
if (adapter->hw.mac.type == e1000_82574) {
|
|
|
|
int tmp;
|
|
|
|
tmp = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT);
|
|
|
|
tmp |= E1000_CTRL_EXT_PBA_CLR;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, tmp);
|
|
|
|
/*
|
|
|
|
** Set the IVAR - interrupt vector routing.
|
|
|
|
** Each nibble represents a vector, high bit
|
|
|
|
** is enable, other 3 bits are the MSIX table
|
|
|
|
** entry, we map RXQ0 to 0, TXQ0 to 1, and
|
|
|
|
** Link (other) to 2, hence the magic number.
|
|
|
|
*/
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IVAR, 0x800A0908);
|
|
|
|
}
|
2008-04-02 22:00:36 +00:00
|
|
|
|
2002-11-25 19:56:16 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
2006-02-15 08:39:50 +00:00
|
|
|
/*
|
|
|
|
* Only enable interrupts if we are not polling, make sure
|
|
|
|
* they are off otherwise.
|
|
|
|
*/
|
|
|
|
if (ifp->if_capenable & IFCAP_POLLING)
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_intr(adapter);
|
2006-02-15 08:39:50 +00:00
|
|
|
else
|
2002-11-25 19:56:16 +00:00
|
|
|
#endif /* DEVICE_POLLING */
|
2006-08-03 19:05:04 +00:00
|
|
|
em_enable_intr(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
/* Initializae IEEE 1588 Precision Time hardware */
|
|
|
|
if ((adapter->hw.mac.type == e1000_82574) ||
|
|
|
|
(adapter->hw.mac.type == e1000_ich10lan))
|
|
|
|
em_tsync_init(adapter);
|
|
|
|
#endif
|
2008-04-02 22:00:36 +00:00
|
|
|
|
2004-02-10 21:31:09 +00:00
|
|
|
/* Don't reset the phy next time init gets called */
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.phy.reset_disable = TRUE;
|
2003-09-23 00:18:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
em_init(void *arg)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = arg;
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_init_locked(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2002-11-25 19:56:16 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
2006-10-28 08:11:07 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Legacy polling routine
|
2006-10-28 08:11:07 +00:00
|
|
|
*
|
|
|
|
*********************************************************************/
|
2006-01-20 11:38:25 +00:00
|
|
|
static void
|
2006-06-06 08:03:49 +00:00
|
|
|
em_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
|
2002-11-25 19:56:16 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 reg_icr;
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
if (cmd == POLL_AND_CHECK_STATUS) {
|
2007-05-04 00:00:12 +00:00
|
|
|
reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR);
|
2006-01-20 11:38:25 +00:00
|
|
|
if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
|
2006-08-03 19:05:04 +00:00
|
|
|
callout_stop(&adapter->timer);
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.get_link_status = 1;
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
callout_reset(&adapter->timer, hz,
|
|
|
|
em_local_timer, adapter);
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
em_rxeof(adapter, count);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_txeof(adapter);
|
2006-01-20 11:38:25 +00:00
|
|
|
|
|
|
|
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
|
|
|
em_start_locked(ifp);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2003-09-23 00:18:25 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif /* DEVICE_POLLING */
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
#ifdef EM_LEGACY_IRQ
|
2006-06-06 08:03:49 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Legacy Interrupt Service routine
|
2006-06-06 08:03:49 +00:00
|
|
|
*
|
|
|
|
*********************************************************************/
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
static void
|
2006-06-06 08:03:49 +00:00
|
|
|
em_intr(void *arg)
|
2003-09-23 00:18:25 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = arg;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 reg_icr;
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2006-06-06 08:03:49 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
if (ifp->if_capenable & IFCAP_POLLING)
|
2006-06-06 08:03:49 +00:00
|
|
|
return;
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
for (;;) {
|
2007-05-04 00:00:12 +00:00
|
|
|
reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR);
|
|
|
|
|
|
|
|
if (adapter->hw.mac.type >= e1000_82571 &&
|
|
|
|
(reg_icr & E1000_ICR_INT_ASSERTED) == 0)
|
2006-06-06 08:03:49 +00:00
|
|
|
break;
|
|
|
|
else if (reg_icr == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: some laptops trigger several spurious interrupts
|
|
|
|
* on em(4) when in the resume cycle. The ICR register
|
|
|
|
* reports all-ones value in this case. Processing such
|
|
|
|
* interrupts would lead to a freeze. I don't know why.
|
|
|
|
*/
|
|
|
|
if (reg_icr == 0xffffffff)
|
|
|
|
break;
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
2006-08-03 19:05:04 +00:00
|
|
|
em_rxeof(adapter, -1);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_txeof(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
}
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
|
|
|
|
/* Link status change */
|
|
|
|
if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
|
2006-08-03 19:05:04 +00:00
|
|
|
callout_stop(&adapter->timer);
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.get_link_status = 1;
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Deal with TX cruft when link lost */
|
|
|
|
em_tx_purge(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
callout_reset(&adapter->timer, hz,
|
|
|
|
em_local_timer, adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (reg_icr & E1000_ICR_RXO)
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->rx_overruns++;
|
2006-06-06 08:03:49 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-06-06 08:03:49 +00:00
|
|
|
|
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
|
|
|
|
!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
2007-11-20 21:41:22 +00:00
|
|
|
em_start(ifp);
|
2002-11-25 19:56:16 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
#else /* EM_FAST_IRQ, then fast interrupt routines only */
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
em_handle_link(void *context, int pending)
|
|
|
|
{
|
|
|
|
struct adapter *adapter = context;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
|
2006-10-31 17:05:02 +00:00
|
|
|
return;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-10-28 08:11:07 +00:00
|
|
|
callout_stop(&adapter->timer);
|
|
|
|
em_update_link_status(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Deal with TX cruft when link lost */
|
|
|
|
em_tx_purge(adapter);
|
2006-10-28 08:11:07 +00:00
|
|
|
callout_reset(&adapter->timer, hz, em_local_timer, adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/* Combined RX/TX handler, used by Legacy and MSI */
|
2006-10-28 08:11:07 +00:00
|
|
|
static void
|
|
|
|
em_handle_rxtx(void *context, int pending)
|
|
|
|
{
|
|
|
|
struct adapter *adapter = context;
|
2008-02-29 21:50:11 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
|
|
|
if (em_rxeof(adapter, adapter->rx_process_limit) != 0)
|
|
|
|
taskqueue_enqueue(adapter->tq, &adapter->rxtx_task);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK(adapter);
|
2006-10-28 08:11:07 +00:00
|
|
|
em_txeof(adapter);
|
|
|
|
|
|
|
|
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
|
|
|
em_start_locked(ifp);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_UNLOCK(adapter);
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
em_enable_intr(adapter);
|
2008-02-29 21:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
em_handle_rx(void *context, int pending)
|
|
|
|
{
|
|
|
|
struct adapter *adapter = context;
|
|
|
|
struct ifnet *ifp = adapter->ifp;
|
|
|
|
|
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
|
|
|
|
(em_rxeof(adapter, adapter->rx_process_limit) != 0))
|
|
|
|
taskqueue_enqueue(adapter->tq, &adapter->rx_task);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
em_handle_tx(void *context, int pending)
|
|
|
|
{
|
|
|
|
struct adapter *adapter = context;
|
|
|
|
struct ifnet *ifp = adapter->ifp;
|
|
|
|
|
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
|
|
|
EM_TX_LOCK(adapter);
|
|
|
|
em_txeof(adapter);
|
|
|
|
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
|
|
|
em_start_locked(ifp);
|
|
|
|
EM_TX_UNLOCK(adapter);
|
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
2008-02-29 21:50:11 +00:00
|
|
|
* Fast Legacy/MSI Combined Interrupt Service routine
|
2006-10-28 08:11:07 +00:00
|
|
|
*
|
|
|
|
*********************************************************************/
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version < 700000
|
|
|
|
#define FILTER_STRAY
|
|
|
|
#define FILTER_HANDLED
|
|
|
|
static void
|
|
|
|
#else
|
2007-02-23 12:19:07 +00:00
|
|
|
static int
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
em_irq_fast(void *arg)
|
2006-10-28 08:11:07 +00:00
|
|
|
{
|
|
|
|
struct adapter *adapter = arg;
|
|
|
|
struct ifnet *ifp;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 reg_icr;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
ifp = adapter->ifp;
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR);
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
/* Hot eject? */
|
|
|
|
if (reg_icr == 0xffffffff)
|
2007-11-20 21:41:22 +00:00
|
|
|
return FILTER_STRAY;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
/* Definitely not our interrupt. */
|
|
|
|
if (reg_icr == 0x0)
|
2007-11-20 21:41:22 +00:00
|
|
|
return FILTER_STRAY;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Starting with the 82571 chip, bit 31 should be used to
|
|
|
|
* determine whether the interrupt belongs to us.
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type >= e1000_82571 &&
|
2006-10-28 08:11:07 +00:00
|
|
|
(reg_icr & E1000_ICR_INT_ASSERTED) == 0)
|
2007-11-20 21:41:22 +00:00
|
|
|
return FILTER_STRAY;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mask interrupts until the taskqueue is finished running. This is
|
|
|
|
* cheap, just assume that it is needed. This also works around the
|
|
|
|
* MSI message reordering errata on certain systems.
|
|
|
|
*/
|
|
|
|
em_disable_intr(adapter);
|
|
|
|
taskqueue_enqueue(adapter->tq, &adapter->rxtx_task);
|
|
|
|
|
|
|
|
/* Link status change */
|
2008-04-02 22:00:36 +00:00
|
|
|
if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
|
|
|
|
adapter->hw.mac.get_link_status = 1;
|
2006-10-28 08:11:07 +00:00
|
|
|
taskqueue_enqueue(taskqueue_fast, &adapter->link_task);
|
2008-04-02 22:00:36 +00:00
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
if (reg_icr & E1000_ICR_RXO)
|
|
|
|
adapter->rx_overruns++;
|
2007-11-20 21:41:22 +00:00
|
|
|
return FILTER_HANDLED;
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
* MSIX Interrupt Service Routines
|
2008-02-29 21:50:11 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#define EM_MSIX_TX 0x00040000
|
|
|
|
#define EM_MSIX_RX 0x00010000
|
|
|
|
#define EM_MSIX_LINK 0x00100000
|
2008-02-29 21:50:11 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
static void
|
|
|
|
em_msix_tx(void *arg)
|
2008-02-29 21:50:11 +00:00
|
|
|
{
|
|
|
|
struct adapter *adapter = arg;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2008-02-29 21:50:11 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
++adapter->tx_irq;
|
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
|
|
|
EM_TX_LOCK(adapter);
|
|
|
|
em_txeof(adapter);
|
|
|
|
EM_TX_UNLOCK(adapter);
|
|
|
|
taskqueue_enqueue(adapter->tq, &adapter->tx_task);
|
|
|
|
}
|
|
|
|
/* Reenable this interrupt */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_TX);
|
|
|
|
return;
|
2008-02-29 21:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
* MSIX RX Interrupt Service routine
|
2008-02-29 21:50:11 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
static void
|
|
|
|
em_msix_rx(void *arg)
|
2008-02-29 21:50:11 +00:00
|
|
|
{
|
|
|
|
struct adapter *adapter = arg;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2008-02-29 21:50:11 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
++adapter->rx_irq;
|
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
|
|
|
|
(em_rxeof(adapter, adapter->rx_process_limit) != 0))
|
|
|
|
taskqueue_enqueue(adapter->tq, &adapter->rx_task);
|
|
|
|
/* Reenable this interrupt */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_RX);
|
|
|
|
return;
|
2008-02-29 21:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* MSIX Link Fast Interrupt Service routine
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
static void
|
|
|
|
em_msix_link(void *arg)
|
2008-02-29 21:50:11 +00:00
|
|
|
{
|
|
|
|
struct adapter *adapter = arg;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
u32 reg_icr;
|
2008-02-29 21:50:11 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
++adapter->link_irq;
|
|
|
|
reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR);
|
2008-02-29 21:50:11 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
|
|
|
|
adapter->hw.mac.get_link_status = 1;
|
2008-02-29 21:50:11 +00:00
|
|
|
taskqueue_enqueue(taskqueue_fast, &adapter->link_task);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
}
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IMS,
|
|
|
|
EM_MSIX_LINK | E1000_IMS_LSC);
|
|
|
|
return;
|
2008-02-29 21:50:11 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif /* EM_FAST_IRQ */
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Media Ioctl callback
|
|
|
|
*
|
|
|
|
* This routine is called whenever the user queries the status of
|
|
|
|
* the interface using ifconfig.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
|
|
|
em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
2007-05-04 00:00:12 +00:00
|
|
|
u_char fiber_type = IFM_1000_SX;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
INIT_DEBUGOUT("em_media_status: begin");
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(adapter);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
ifmr->ifm_status = IFM_AVALID;
|
|
|
|
ifmr->ifm_active = IFM_ETHER;
|
|
|
|
|
2006-09-01 16:08:36 +00:00
|
|
|
if (!adapter->link_active) {
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-11-08 18:14:17 +00:00
|
|
|
return;
|
2006-09-01 16:08:36 +00:00
|
|
|
}
|
2002-11-08 18:14:17 +00:00
|
|
|
|
|
|
|
ifmr->ifm_status |= IFM_ACTIVE;
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
|
|
|
|
(adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) {
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82545)
|
|
|
|
fiber_type = IFM_1000_LX;
|
|
|
|
ifmr->ifm_active |= fiber_type | IFM_FDX;
|
2002-11-08 18:14:17 +00:00
|
|
|
} else {
|
2006-08-03 19:05:04 +00:00
|
|
|
switch (adapter->link_speed) {
|
2002-11-08 18:14:17 +00:00
|
|
|
case 10:
|
|
|
|
ifmr->ifm_active |= IFM_10_T;
|
|
|
|
break;
|
|
|
|
case 100:
|
|
|
|
ifmr->ifm_active |= IFM_100_TX;
|
|
|
|
break;
|
|
|
|
case 1000:
|
|
|
|
ifmr->ifm_active |= IFM_1000_T;
|
|
|
|
break;
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->link_duplex == FULL_DUPLEX)
|
2002-11-08 18:14:17 +00:00
|
|
|
ifmr->ifm_active |= IFM_FDX;
|
|
|
|
else
|
|
|
|
ifmr->ifm_active |= IFM_HDX;
|
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Media Ioctl callback
|
|
|
|
*
|
|
|
|
* This routine is called when the user changes speed/duplex using
|
|
|
|
* media/mediopt option with ifconfig.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static int
|
|
|
|
em_media_change(struct ifnet *ifp)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
|
|
|
struct ifmedia *ifm = &adapter->media;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
|
|
|
INIT_DEBUGOUT("em_media_change: begin");
|
|
|
|
|
|
|
|
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
|
2006-02-15 08:39:50 +00:00
|
|
|
return (EINVAL);
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2002-11-08 18:14:17 +00:00
|
|
|
switch (IFM_SUBTYPE(ifm->ifm_media)) {
|
|
|
|
case IFM_AUTO:
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.autoneg = DO_AUTO_NEG;
|
|
|
|
adapter->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT;
|
2002-11-08 18:14:17 +00:00
|
|
|
break;
|
2006-08-11 10:58:24 +00:00
|
|
|
case IFM_1000_LX:
|
2002-11-08 18:14:17 +00:00
|
|
|
case IFM_1000_SX:
|
|
|
|
case IFM_1000_T:
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.autoneg = DO_AUTO_NEG;
|
|
|
|
adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
|
2002-11-08 18:14:17 +00:00
|
|
|
break;
|
|
|
|
case IFM_100_TX:
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.autoneg = FALSE;
|
|
|
|
adapter->hw.phy.autoneg_advertised = 0;
|
2002-11-08 18:14:17 +00:00
|
|
|
if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.forced_speed_duplex = ADVERTISE_100_FULL;
|
2002-11-08 18:14:17 +00:00
|
|
|
else
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.forced_speed_duplex = ADVERTISE_100_HALF;
|
2002-11-08 18:14:17 +00:00
|
|
|
break;
|
|
|
|
case IFM_10_T:
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.autoneg = FALSE;
|
|
|
|
adapter->hw.phy.autoneg_advertised = 0;
|
2002-11-08 18:14:17 +00:00
|
|
|
if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.forced_speed_duplex = ADVERTISE_10_FULL;
|
2002-11-08 18:14:17 +00:00
|
|
|
else
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.mac.forced_speed_duplex = ADVERTISE_10_HALF;
|
2002-11-08 18:14:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-08-03 19:05:04 +00:00
|
|
|
device_printf(adapter->dev, "Unsupported media type\n");
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
2004-02-10 21:31:09 +00:00
|
|
|
/* As the speed/duplex settings my have changed we need to
|
|
|
|
* reset the PHY.
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.phy.reset_disable = FALSE;
|
2004-02-10 21:31:09 +00:00
|
|
|
|
2006-09-01 16:08:36 +00:00
|
|
|
em_init_locked(adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* This routine maps the mbufs to tx descriptors.
|
|
|
|
*
|
|
|
|
* return 0 on success, positive on failure
|
|
|
|
**********************************************************************/
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
static int
|
2008-02-29 21:50:11 +00:00
|
|
|
em_xmit(struct adapter *adapter, struct mbuf **m_headp)
|
2003-05-02 21:17:08 +00:00
|
|
|
{
|
2005-01-15 20:52:15 +00:00
|
|
|
bus_dma_segment_t segs[EM_MAX_SCATTER];
|
2006-01-20 11:38:25 +00:00
|
|
|
bus_dmamap_t map;
|
2006-10-31 16:19:21 +00:00
|
|
|
struct em_buffer *tx_buffer, *tx_buffer_mapped;
|
2007-05-04 00:00:12 +00:00
|
|
|
struct e1000_tx_desc *ctxd = NULL;
|
2006-01-20 11:38:25 +00:00
|
|
|
struct mbuf *m_head;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 txd_upper, txd_lower, txd_used, txd_saved;
|
2006-10-31 16:19:21 +00:00
|
|
|
int nsegs, i, j, first, last = 0;
|
2006-09-09 06:19:20 +00:00
|
|
|
int error, do_tso, tso_desc = 0;
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version < 700000
|
|
|
|
struct m_tag *mtag;
|
|
|
|
#endif
|
2004-11-12 11:03:07 +00:00
|
|
|
m_head = *m_headp;
|
2006-09-09 06:19:20 +00:00
|
|
|
txd_upper = txd_lower = txd_used = txd_saved = 0;
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2006-09-10 19:23:27 +00:00
|
|
|
do_tso = ((m_head->m_pkthdr.csum_flags & CSUM_TSO) != 0);
|
2007-11-20 21:41:22 +00:00
|
|
|
#else
|
|
|
|
do_tso = 0;
|
|
|
|
#endif
|
2004-11-12 11:03:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*
|
|
|
|
* Force a cleanup if number of TX descriptors
|
|
|
|
* available hits the threshold
|
|
|
|
*/
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->num_tx_desc_avail <= EM_TX_CLEANUP_THRESHOLD) {
|
|
|
|
em_txeof(adapter);
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Now do we at least have a minimal? */
|
|
|
|
if (adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->no_tx_desc_avail1++;
|
2006-10-28 08:11:07 +00:00
|
|
|
return (ENOBUFS);
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
2006-10-28 00:47:55 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
* TSO workaround:
|
|
|
|
* If an mbuf is only header we need
|
|
|
|
* to pull 4 bytes of data into it.
|
2006-09-10 19:23:27 +00:00
|
|
|
*/
|
|
|
|
if (do_tso && (m_head->m_len <= M_TSO_LEN)) {
|
|
|
|
m_head = m_pullup(m_head, M_TSO_LEN + 4);
|
2006-09-11 20:59:01 +00:00
|
|
|
*m_headp = m_head;
|
2007-05-04 00:00:12 +00:00
|
|
|
if (m_head == NULL)
|
2006-09-10 19:23:27 +00:00
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Map the packet for DMA
|
2006-10-31 16:19:21 +00:00
|
|
|
*
|
|
|
|
* Capture the first descriptor index,
|
|
|
|
* this descriptor will have the index
|
|
|
|
* of the EOP which is the only one that
|
|
|
|
* now gets a DONE bit writeback.
|
2006-10-28 08:11:07 +00:00
|
|
|
*/
|
2006-10-31 16:19:21 +00:00
|
|
|
first = adapter->next_avail_tx_desc;
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[first];
|
|
|
|
tx_buffer_mapped = tx_buffer;
|
2006-07-27 00:43:34 +00:00
|
|
|
map = tx_buffer->map;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
error = bus_dmamap_load_mbuf_sg(adapter->txtag, map,
|
|
|
|
*m_headp, segs, &nsegs, BUS_DMA_NOWAIT);
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* There are two types of errors we can (try) to handle:
|
|
|
|
* - EFBIG means the mbuf chain was too long and bus_dma ran
|
|
|
|
* out of segments. Defragment the mbuf chain and try again.
|
|
|
|
* - ENOMEM means bus_dma could not obtain enough bounce buffers
|
|
|
|
* at this point in time. Defer sending and try again later.
|
|
|
|
* All other errors, in particular EINVAL, are fatal and prevent the
|
|
|
|
* mbuf chain from ever going through. Drop it and report error.
|
|
|
|
*/
|
2006-08-14 02:21:26 +00:00
|
|
|
if (error == EFBIG) {
|
|
|
|
struct mbuf *m;
|
|
|
|
|
|
|
|
m = m_defrag(*m_headp, M_DONTWAIT);
|
|
|
|
if (m == NULL) {
|
|
|
|
adapter->mbuf_alloc_failed++;
|
|
|
|
m_freem(*m_headp);
|
|
|
|
*m_headp = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
*m_headp = m;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Try it again */
|
|
|
|
error = bus_dmamap_load_mbuf_sg(adapter->txtag, map,
|
|
|
|
*m_headp, segs, &nsegs, BUS_DMA_NOWAIT);
|
2006-09-29 13:12:38 +00:00
|
|
|
|
|
|
|
if (error == ENOMEM) {
|
|
|
|
adapter->no_tx_dma_setup++;
|
|
|
|
return (error);
|
|
|
|
} else if (error != 0) {
|
2006-08-14 02:21:26 +00:00
|
|
|
adapter->no_tx_dma_setup++;
|
|
|
|
m_freem(*m_headp);
|
|
|
|
*m_headp = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
2006-09-29 13:12:38 +00:00
|
|
|
} else if (error == ENOMEM) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->no_tx_dma_setup++;
|
2006-07-27 00:43:34 +00:00
|
|
|
return (error);
|
2006-09-29 13:12:38 +00:00
|
|
|
} else if (error != 0) {
|
|
|
|
adapter->no_tx_dma_setup++;
|
2006-08-14 02:21:26 +00:00
|
|
|
m_freem(*m_headp);
|
|
|
|
*m_headp = NULL;
|
2006-09-29 13:12:38 +00:00
|
|
|
return (error);
|
2006-08-14 02:21:26 +00:00
|
|
|
}
|
2006-07-27 00:43:34 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
/*
|
|
|
|
* TSO Hardware workaround, if this packet is not
|
|
|
|
* TSO, and is only a single descriptor long, and
|
|
|
|
* it follows a TSO burst, then we need to add a
|
|
|
|
* sentinel descriptor to prevent premature writeback.
|
|
|
|
*/
|
|
|
|
if ((do_tso == 0) && (adapter->tx_tso == TRUE)) {
|
|
|
|
if (nsegs == 1)
|
|
|
|
tso_desc = TRUE;
|
|
|
|
adapter->tx_tso = FALSE;
|
|
|
|
}
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (nsegs > (adapter->num_tx_desc_avail - 2)) {
|
|
|
|
adapter->no_tx_desc_avail2++;
|
2006-10-28 08:11:07 +00:00
|
|
|
bus_dmamap_unload(adapter->txtag, map);
|
|
|
|
return (ENOBUFS);
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
m_head = *m_headp;
|
2006-07-27 00:43:34 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
/* Do hardware assists */
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
|
|
|
if (m_head->m_pkthdr.csum_flags & CSUM_TSO) {
|
|
|
|
error = em_tso_setup(adapter, m_head, &txd_upper, &txd_lower);
|
|
|
|
if (error != TRUE)
|
|
|
|
return (ENXIO); /* something foobar */
|
2007-05-16 00:14:23 +00:00
|
|
|
/* we need to make a final sentinel transmit desc */
|
|
|
|
tso_desc = TRUE;
|
2007-11-20 21:41:22 +00:00
|
|
|
} else
|
|
|
|
#endif
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifndef EM_TIMESYNC
|
2008-04-02 22:00:36 +00:00
|
|
|
/*
|
|
|
|
** Timesync needs to check the packet header
|
|
|
|
** so call checksum code to do so, but don't
|
|
|
|
** penalize the code if not defined.
|
|
|
|
*/
|
|
|
|
if (m_head->m_pkthdr.csum_flags & CSUM_OFFLOAD)
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#endif
|
2007-05-16 00:14:23 +00:00
|
|
|
em_transmit_checksum_setup(adapter, m_head,
|
|
|
|
&txd_upper, &txd_lower);
|
2006-07-27 00:43:34 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
i = adapter->next_avail_tx_desc;
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->pcix_82544)
|
2003-08-27 21:52:37 +00:00
|
|
|
txd_saved = i;
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Set up our transmit descriptors */
|
2006-01-20 11:38:25 +00:00
|
|
|
for (j = 0; j < nsegs; j++) {
|
2006-09-10 19:23:27 +00:00
|
|
|
bus_size_t seg_len;
|
|
|
|
bus_addr_t seg_addr;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* If adapter is 82544 and on PCIX bus */
|
2006-08-03 19:05:04 +00:00
|
|
|
if(adapter->pcix_82544) {
|
2006-01-20 11:38:25 +00:00
|
|
|
DESC_ARRAY desc_array;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 array_elements, counter;
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
|
|
|
* Check the Address and Length combination and
|
|
|
|
* split the data accordingly
|
2003-08-27 21:52:37 +00:00
|
|
|
*/
|
2006-01-20 11:38:25 +00:00
|
|
|
array_elements = em_fill_descriptors(segs[j].ds_addr,
|
2005-11-09 08:43:18 +00:00
|
|
|
segs[j].ds_len, &desc_array);
|
2003-08-27 21:52:37 +00:00
|
|
|
for (counter = 0; counter < array_elements; counter++) {
|
2006-08-03 19:05:04 +00:00
|
|
|
if (txd_used == adapter->num_tx_desc_avail) {
|
|
|
|
adapter->next_avail_tx_desc = txd_saved;
|
|
|
|
adapter->no_tx_desc_avail2++;
|
2006-10-28 08:11:07 +00:00
|
|
|
bus_dmamap_unload(adapter->txtag, map);
|
|
|
|
return (ENOBUFS);
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
tx_buffer = &adapter->tx_buffer_area[i];
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd = &adapter->tx_desc_base[i];
|
|
|
|
ctxd->buffer_addr = htole64(
|
|
|
|
desc_array.descriptor[counter].address);
|
|
|
|
ctxd->lower.data = htole32(
|
2008-02-29 21:50:11 +00:00
|
|
|
(adapter->txd_cmd | txd_lower | (u16)
|
2007-05-04 00:00:12 +00:00
|
|
|
desc_array.descriptor[counter].length));
|
|
|
|
ctxd->upper.data =
|
|
|
|
htole32((txd_upper));
|
2006-10-31 16:19:21 +00:00
|
|
|
last = i;
|
2006-08-03 19:05:04 +00:00
|
|
|
if (++i == adapter->num_tx_desc)
|
2007-05-04 00:00:12 +00:00
|
|
|
i = 0;
|
2006-01-20 11:38:25 +00:00
|
|
|
tx_buffer->m_head = NULL;
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_buffer->next_eop = -1;
|
2006-01-20 11:38:25 +00:00
|
|
|
txd_used++;
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
2003-08-27 21:52:37 +00:00
|
|
|
} else {
|
2006-09-10 19:23:27 +00:00
|
|
|
tx_buffer = &adapter->tx_buffer_area[i];
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd = &adapter->tx_desc_base[i];
|
2006-11-23 00:52:52 +00:00
|
|
|
seg_addr = segs[j].ds_addr;
|
2006-09-10 19:23:27 +00:00
|
|
|
seg_len = segs[j].ds_len;
|
|
|
|
/*
|
|
|
|
** TSO Workaround:
|
|
|
|
** If this is the last descriptor, we want to
|
|
|
|
** split it so we have a small final sentinel
|
|
|
|
*/
|
|
|
|
if (tso_desc && (j == (nsegs -1)) && (seg_len > 8)) {
|
|
|
|
seg_len -= 4;
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->buffer_addr = htole64(seg_addr);
|
|
|
|
ctxd->lower.data = htole32(
|
2006-09-10 19:23:27 +00:00
|
|
|
adapter->txd_cmd | txd_lower | seg_len);
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->upper.data =
|
2006-09-10 19:23:27 +00:00
|
|
|
htole32(txd_upper);
|
|
|
|
if (++i == adapter->num_tx_desc)
|
|
|
|
i = 0;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Now make the sentinel */
|
2006-09-10 19:23:27 +00:00
|
|
|
++txd_used; /* using an extra txd */
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd = &adapter->tx_desc_base[i];
|
2006-09-10 19:23:27 +00:00
|
|
|
tx_buffer = &adapter->tx_buffer_area[i];
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->buffer_addr =
|
|
|
|
htole64(seg_addr + seg_len);
|
|
|
|
ctxd->lower.data = htole32(
|
2006-09-10 19:23:27 +00:00
|
|
|
adapter->txd_cmd | txd_lower | 4);
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->upper.data =
|
2006-09-10 19:23:27 +00:00
|
|
|
htole32(txd_upper);
|
2006-10-31 16:19:21 +00:00
|
|
|
last = i;
|
2006-09-10 19:23:27 +00:00
|
|
|
if (++i == adapter->num_tx_desc)
|
|
|
|
i = 0;
|
|
|
|
} else {
|
2007-05-23 20:41:20 +00:00
|
|
|
ctxd->buffer_addr = htole64(seg_addr);
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->lower.data = htole32(
|
2006-09-10 19:23:27 +00:00
|
|
|
adapter->txd_cmd | txd_lower | seg_len);
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->upper.data =
|
2006-09-10 19:23:27 +00:00
|
|
|
htole32(txd_upper);
|
2006-10-31 16:19:21 +00:00
|
|
|
last = i;
|
2006-09-10 19:23:27 +00:00
|
|
|
if (++i == adapter->num_tx_desc)
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
tx_buffer->m_head = NULL;
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_buffer->next_eop = -1;
|
2003-08-27 21:52:37 +00:00
|
|
|
}
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->next_avail_tx_desc = i;
|
|
|
|
if (adapter->pcix_82544)
|
|
|
|
adapter->num_tx_desc_avail -= txd_used;
|
2006-09-09 06:19:20 +00:00
|
|
|
else {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_tx_desc_avail -= nsegs;
|
2006-09-10 19:23:27 +00:00
|
|
|
if (tso_desc) /* TSO used an extra for sentinel */
|
|
|
|
adapter->num_tx_desc_avail -= txd_used;
|
|
|
|
}
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
** Handle VLAN tag, this is the
|
|
|
|
** biggest difference between
|
|
|
|
** 6.x and 7
|
|
|
|
*/
|
|
|
|
#if __FreeBSD_version < 700000
|
|
|
|
/* Find out if we are in vlan mode. */
|
|
|
|
mtag = VLAN_OUTPUT_TAG(ifp, m_head);
|
|
|
|
if (mtag != NULL) {
|
|
|
|
ctxd->upper.fields.special =
|
|
|
|
htole16(VLAN_TAG_VALUE(mtag));
|
|
|
|
#else /* FreeBSD 7 */
|
2006-10-28 08:11:07 +00:00
|
|
|
if (m_head->m_flags & M_VLANTAG) {
|
2006-01-20 11:38:25 +00:00
|
|
|
/* Set the vlan id. */
|
2007-05-04 00:00:12 +00:00
|
|
|
ctxd->upper.fields.special =
|
2006-10-28 08:11:07 +00:00
|
|
|
htole16(m_head->m_pkthdr.ether_vtag);
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Tell hardware to add tag */
|
|
|
|
ctxd->lower.data |= htole32(E1000_TXD_CMD_VLE);
|
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
tx_buffer->m_head = m_head;
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_buffer_mapped->map = tx_buffer->map;
|
2006-07-27 00:26:20 +00:00
|
|
|
tx_buffer->map = map;
|
2007-05-04 00:00:12 +00:00
|
|
|
bus_dmamap_sync(adapter->txtag, map, BUS_DMASYNC_PREWRITE);
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*
|
|
|
|
* Last Descriptor of Packet
|
2006-10-31 16:19:21 +00:00
|
|
|
* needs End Of Packet (EOP)
|
|
|
|
* and Report Status (RS)
|
2007-05-04 00:00:12 +00:00
|
|
|
*/
|
|
|
|
ctxd->lower.data |=
|
2006-10-31 16:19:21 +00:00
|
|
|
htole32(E1000_TXD_CMD_EOP | E1000_TXD_CMD_RS);
|
|
|
|
/*
|
|
|
|
* Keep track in the first buffer which
|
|
|
|
* descriptor will be written back
|
2006-01-20 11:38:25 +00:00
|
|
|
*/
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_buffer = &adapter->tx_buffer_area[first];
|
|
|
|
tx_buffer->next_eop = last;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Advance the Transmit Descriptor Tail (TDT), this tells the E1000
|
2006-01-20 11:38:25 +00:00
|
|
|
* that this frame is available to transmit.
|
|
|
|
*/
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_sync(adapter->txdma.dma_tag, adapter->txdma.dma_map,
|
2006-02-15 08:39:50 +00:00
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82547 &&
|
2006-09-29 13:54:04 +00:00
|
|
|
adapter->link_duplex == HALF_DUPLEX)
|
2006-10-31 17:05:02 +00:00
|
|
|
em_82547_move_tail(adapter);
|
2006-02-15 08:39:50 +00:00
|
|
|
else {
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDT(0), i);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82547)
|
|
|
|
em_82547_update_fifo_head(adapter,
|
|
|
|
m_head->m_pkthdr.len);
|
|
|
|
}
|
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
if (ctxd->upper.data & E1000_TXD_EXTCMD_TSTAMP) {
|
|
|
|
HW_DEBUGOUT( "@@@ Timestamp bit is set in transmit descriptor\n" );
|
|
|
|
}
|
|
|
|
#endif
|
2007-05-04 00:00:12 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2003-03-21 21:47:31 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* 82547 workaround to avoid controller hang in half-duplex environment.
|
2006-01-20 11:38:25 +00:00
|
|
|
* The workaround is to avoid queuing a large packet that would span
|
2003-03-21 21:47:31 +00:00
|
|
|
* the internal Tx FIFO ring boundary. We need to reset the FIFO pointers
|
2003-10-10 23:14:21 +00:00
|
|
|
* in this case. We do that only when FIFO is quiescent.
|
2003-03-21 21:47:31 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-10-31 17:05:02 +00:00
|
|
|
em_82547_move_tail(void *arg)
|
2003-03-21 21:47:31 +00:00
|
|
|
{
|
2006-10-31 17:05:02 +00:00
|
|
|
struct adapter *adapter = arg;
|
2007-05-04 00:00:12 +00:00
|
|
|
struct e1000_tx_desc *tx_desc;
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 hw_tdt, sw_tdt, length = 0;
|
|
|
|
bool eop = 0;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK_ASSERT(adapter);
|
2003-10-10 23:14:21 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
hw_tdt = E1000_READ_REG(&adapter->hw, E1000_TDT(0));
|
2006-08-03 19:05:04 +00:00
|
|
|
sw_tdt = adapter->next_avail_tx_desc;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
|
|
|
while (hw_tdt != sw_tdt) {
|
2006-08-03 19:05:04 +00:00
|
|
|
tx_desc = &adapter->tx_desc_base[hw_tdt];
|
2003-03-21 21:47:31 +00:00
|
|
|
length += tx_desc->lower.flags.length;
|
|
|
|
eop = tx_desc->lower.data & E1000_TXD_CMD_EOP;
|
2007-05-04 00:00:12 +00:00
|
|
|
if (++hw_tdt == adapter->num_tx_desc)
|
2003-03-21 21:47:31 +00:00
|
|
|
hw_tdt = 0;
|
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
if (eop) {
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_82547_fifo_workaround(adapter, length)) {
|
|
|
|
adapter->tx_fifo_wrk_cnt++;
|
|
|
|
callout_reset(&adapter->tx_fifo_timer, 1,
|
|
|
|
em_82547_move_tail, adapter);
|
2003-09-23 00:18:25 +00:00
|
|
|
break;
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDT(0), hw_tdt);
|
2006-08-03 19:05:04 +00:00
|
|
|
em_82547_update_fifo_head(adapter, length);
|
2003-09-23 00:18:25 +00:00
|
|
|
length = 0;
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_82547_fifo_workaround(struct adapter *adapter, int len)
|
2003-03-21 21:47:31 +00:00
|
|
|
{
|
|
|
|
int fifo_space, fifo_pkt_len;
|
|
|
|
|
2005-11-21 04:17:43 +00:00
|
|
|
fifo_pkt_len = roundup2(len + EM_FIFO_HDR, EM_FIFO_HDR);
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->link_duplex == HALF_DUPLEX) {
|
|
|
|
fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
|
|
|
if (fifo_pkt_len >= (EM_82547_PKT_THRESH + fifo_space)) {
|
2006-08-03 19:05:04 +00:00
|
|
|
if (em_82547_tx_fifo_reset(adapter))
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2006-01-20 11:38:25 +00:00
|
|
|
else
|
2006-02-15 08:39:50 +00:00
|
|
|
return (1);
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_82547_update_fifo_head(struct adapter *adapter, int len)
|
2003-03-21 21:47:31 +00:00
|
|
|
{
|
2005-11-21 04:17:43 +00:00
|
|
|
int fifo_pkt_len = roundup2(len + EM_FIFO_HDR, EM_FIFO_HDR);
|
2003-03-21 21:47:31 +00:00
|
|
|
|
|
|
|
/* tx_fifo_head is always 16 byte aligned */
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->tx_fifo_head += fifo_pkt_len;
|
|
|
|
if (adapter->tx_fifo_head >= adapter->tx_fifo_size) {
|
|
|
|
adapter->tx_fifo_head -= adapter->tx_fifo_size;
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_82547_tx_fifo_reset(struct adapter *adapter)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 tctl;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
if ((E1000_READ_REG(&adapter->hw, E1000_TDT(0)) ==
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDH(0))) &&
|
2007-05-04 00:00:12 +00:00
|
|
|
(E1000_READ_REG(&adapter->hw, E1000_TDFT) ==
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDFH)) &&
|
|
|
|
(E1000_READ_REG(&adapter->hw, E1000_TDFTS) ==
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDFHS)) &&
|
|
|
|
(E1000_READ_REG(&adapter->hw, E1000_TDFPC) == 0)) {
|
2003-03-21 21:47:31 +00:00
|
|
|
/* Disable TX unit */
|
2007-05-04 00:00:12 +00:00
|
|
|
tctl = E1000_READ_REG(&adapter->hw, E1000_TCTL);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TCTL,
|
|
|
|
tctl & ~E1000_TCTL_EN);
|
2003-03-21 21:47:31 +00:00
|
|
|
|
|
|
|
/* Reset FIFO pointers */
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDFT,
|
|
|
|
adapter->tx_head_addr);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDFH,
|
|
|
|
adapter->tx_head_addr);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDFTS,
|
|
|
|
adapter->tx_head_addr);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDFHS,
|
|
|
|
adapter->tx_head_addr);
|
2003-03-21 21:47:31 +00:00
|
|
|
|
|
|
|
/* Re-enable TX unit */
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TCTL, tctl);
|
2006-08-03 19:05:04 +00:00
|
|
|
E1000_WRITE_FLUSH(&adapter->hw);
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->tx_fifo_head = 0;
|
|
|
|
adapter->tx_fifo_reset_cnt++;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (TRUE);
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-02-15 08:39:50 +00:00
|
|
|
return (FALSE);
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_set_promisc(struct adapter *adapter)
|
2002-11-08 18:14:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 reg_rctl;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
2002-11-08 18:14:17 +00:00
|
|
|
|
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
|
|
|
reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/* Turn this on if you want to see bad packets */
|
|
|
|
if (em_debug_sbp)
|
|
|
|
reg_rctl |= E1000_RCTL_SBP;
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
2002-11-08 18:14:17 +00:00
|
|
|
} else if (ifp->if_flags & IFF_ALLMULTI) {
|
|
|
|
reg_rctl |= E1000_RCTL_MPE;
|
|
|
|
reg_rctl &= ~E1000_RCTL_UPE;
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
2006-11-18 23:18:43 +00:00
|
|
|
}
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_promisc(struct adapter *adapter)
|
2002-11-08 18:14:17 +00:00
|
|
|
{
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 reg_rctl;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
2002-11-08 18:14:17 +00:00
|
|
|
|
|
|
|
reg_rctl &= (~E1000_RCTL_UPE);
|
|
|
|
reg_rctl &= (~E1000_RCTL_MPE);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
reg_rctl &= (~E1000_RCTL_SBP);
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* Multicast Update
|
|
|
|
*
|
|
|
|
* This routine is called whenever multicast address list is updated.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_set_multi(struct adapter *adapter)
|
2002-11-08 18:14:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2006-02-15 08:39:50 +00:00
|
|
|
struct ifmultiaddr *ifma;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 reg_rctl = 0;
|
|
|
|
u8 mta[512]; /* Largest MTS is 4096 bits */
|
2006-02-15 08:39:50 +00:00
|
|
|
int mcnt = 0;
|
2006-01-20 11:38:25 +00:00
|
|
|
|
|
|
|
IOCTL_DEBUGOUT("em_set_multi: begin");
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82542 &&
|
|
|
|
adapter->hw.revision_id == E1000_REVISION_2) {
|
|
|
|
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
|
|
|
if (adapter->hw.bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
|
|
|
|
e1000_pci_clear_mwi(&adapter->hw);
|
2006-01-20 11:38:25 +00:00
|
|
|
reg_rctl |= E1000_RCTL_RST;
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
2006-01-20 11:38:25 +00:00
|
|
|
msec_delay(5);
|
|
|
|
}
|
2005-08-03 00:18:35 +00:00
|
|
|
|
|
|
|
IF_ADDR_LOCK(ifp);
|
2006-02-15 08:39:50 +00:00
|
|
|
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
2006-01-20 11:38:25 +00:00
|
|
|
if (ifma->ifma_addr->sa_family != AF_LINK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
|
2007-05-04 00:00:12 +00:00
|
|
|
&mta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
|
2006-01-20 11:38:25 +00:00
|
|
|
mcnt++;
|
|
|
|
}
|
2005-08-03 00:18:35 +00:00
|
|
|
IF_ADDR_UNLOCK(ifp);
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) {
|
2007-05-04 00:00:12 +00:00
|
|
|
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
2006-01-20 11:38:25 +00:00
|
|
|
reg_rctl |= E1000_RCTL_MPE;
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
2006-01-20 11:38:25 +00:00
|
|
|
} else
|
2007-11-20 21:41:22 +00:00
|
|
|
e1000_update_mc_addr_list(&adapter->hw, mta,
|
2007-05-04 00:00:12 +00:00
|
|
|
mcnt, 1, adapter->hw.mac.rar_entry_count);
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82542 &&
|
|
|
|
adapter->hw.revision_id == E1000_REVISION_2) {
|
|
|
|
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
2006-01-20 11:38:25 +00:00
|
|
|
reg_rctl &= ~E1000_RCTL_RST;
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
|
2006-01-20 11:38:25 +00:00
|
|
|
msec_delay(5);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
|
|
|
|
e1000_pci_set_mwi(&adapter->hw);
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* Timer routine
|
|
|
|
*
|
|
|
|
* This routine checks for link status and updates statistics.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
em_local_timer(void *arg)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = arg;
|
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_ASSERT(adapter);
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(adapter);
|
|
|
|
em_update_stats_counters(adapter);
|
2007-05-31 23:36:21 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Reset LAA into RAR[0] on 82571 */
|
|
|
|
if (e1000_get_laa_state_82571(&adapter->hw) == TRUE)
|
2007-05-31 23:36:21 +00:00
|
|
|
e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
|
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
if (em_display_debug_stats && ifp->if_drv_flags & IFF_DRV_RUNNING)
|
2006-08-03 19:05:04 +00:00
|
|
|
em_print_hw_stats(adapter);
|
2007-05-31 23:36:21 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
em_smartspeed(adapter);
|
2007-05-31 23:36:21 +00:00
|
|
|
|
2006-11-09 16:00:18 +00:00
|
|
|
/*
|
|
|
|
* Each second we check the watchdog to
|
|
|
|
* protect against hardware hangs.
|
|
|
|
*/
|
|
|
|
em_watchdog(adapter);
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
callout_reset(&adapter->timer, hz, em_local_timer, adapter);
|
2007-11-20 21:41:22 +00:00
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_link_status(struct adapter *adapter)
|
2002-11-08 18:14:17 +00:00
|
|
|
{
|
2008-04-02 22:00:36 +00:00
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
2006-08-03 19:05:04 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
|
|
|
device_t dev = adapter->dev;
|
2008-04-02 22:00:36 +00:00
|
|
|
u32 link_check = 0;
|
|
|
|
|
|
|
|
/* Get the cached link value or read phy for real */
|
|
|
|
switch (hw->phy.media_type) {
|
|
|
|
case e1000_media_type_copper:
|
|
|
|
if (hw->mac.get_link_status) {
|
|
|
|
/* Do the work to read phy */
|
|
|
|
e1000_check_for_link(hw);
|
|
|
|
link_check = !hw->mac.get_link_status;
|
2008-11-26 23:57:23 +00:00
|
|
|
if (link_check) /* ESB2 fix */
|
|
|
|
e1000_cfg_on_link_up(hw);
|
2008-04-02 22:00:36 +00:00
|
|
|
} else
|
|
|
|
link_check = TRUE;
|
|
|
|
break;
|
|
|
|
case e1000_media_type_fiber:
|
|
|
|
e1000_check_for_link(hw);
|
|
|
|
link_check = (E1000_READ_REG(hw, E1000_STATUS) &
|
|
|
|
E1000_STATUS_LU);
|
|
|
|
break;
|
|
|
|
case e1000_media_type_internal_serdes:
|
|
|
|
e1000_check_for_link(hw);
|
|
|
|
link_check = adapter->hw.mac.serdes_has_link;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case e1000_media_type_unknown:
|
|
|
|
break;
|
|
|
|
}
|
2005-02-04 18:36:04 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
/* Now check for a transition */
|
|
|
|
if (link_check && (adapter->link_active == 0)) {
|
|
|
|
e1000_get_speed_and_duplex(hw, &adapter->link_speed,
|
|
|
|
&adapter->link_duplex);
|
|
|
|
/* Check if we must disable SPEED_MODE bit on PCI-E */
|
|
|
|
if ((adapter->link_speed != SPEED_1000) &&
|
|
|
|
((hw->mac.type == e1000_82571) ||
|
|
|
|
(hw->mac.type == e1000_82572))) {
|
|
|
|
int tarc0;
|
|
|
|
tarc0 = E1000_READ_REG(hw, E1000_TARC(0));
|
|
|
|
tarc0 &= ~SPEED_MODE_BIT;
|
|
|
|
E1000_WRITE_REG(hw, E1000_TARC(0), tarc0);
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
2008-04-02 22:00:36 +00:00
|
|
|
if (bootverbose)
|
|
|
|
device_printf(dev, "Link is up %d Mbps %s\n",
|
|
|
|
adapter->link_speed,
|
|
|
|
((adapter->link_duplex == FULL_DUPLEX) ?
|
|
|
|
"Full Duplex" : "Half Duplex"));
|
|
|
|
adapter->link_active = 1;
|
|
|
|
adapter->smartspeed = 0;
|
|
|
|
ifp->if_baudrate = adapter->link_speed * 1000000;
|
|
|
|
if_link_state_change(ifp, LINK_STATE_UP);
|
|
|
|
} else if (!link_check && (adapter->link_active == 1)) {
|
|
|
|
ifp->if_baudrate = adapter->link_speed = 0;
|
|
|
|
adapter->link_duplex = 0;
|
|
|
|
if (bootverbose)
|
|
|
|
device_printf(dev, "Link is Down\n");
|
|
|
|
adapter->link_active = 0;
|
|
|
|
/* Link down, disable watchdog */
|
|
|
|
adapter->watchdog_timer = FALSE;
|
|
|
|
if_link_state_change(ifp, LINK_STATE_DOWN);
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
2002-11-08 18:14:17 +00:00
|
|
|
* This routine disables all traffic on the adapter by issuing a
|
2006-01-20 11:38:25 +00:00
|
|
|
* global reset on the MAC and deallocates TX/RX buffers.
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
2007-11-26 19:47:03 +00:00
|
|
|
* This routine should always be called with BOTH the CORE
|
|
|
|
* and TX locks.
|
2001-12-02 07:37:17 +00:00
|
|
|
**********************************************************************/
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
static void
|
|
|
|
em_stop(void *arg)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter = arg;
|
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK_ASSERT(adapter);
|
2007-11-26 19:47:03 +00:00
|
|
|
EM_TX_LOCK_ASSERT(adapter);
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2003-08-27 21:52:37 +00:00
|
|
|
INIT_DEBUGOUT("em_stop: begin");
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_intr(adapter);
|
|
|
|
callout_stop(&adapter->timer);
|
|
|
|
callout_stop(&adapter->tx_fifo_timer);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
/* Tell the stack that the interface is no longer active */
|
2005-08-09 10:20:02 +00:00
|
|
|
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
/* Disable IEEE 1588 Time hardware */
|
|
|
|
if ((adapter->hw.mac.type == e1000_82574) ||
|
|
|
|
(adapter->hw.mac.type == e1000_ich10lan))
|
|
|
|
em_tsync_disable(adapter);
|
|
|
|
#endif
|
2008-04-02 22:00:36 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_reset_hw(&adapter->hw);
|
|
|
|
if (adapter->hw.mac.type >= e1000_82544)
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_WUC, 0);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*********************************************************************
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
|
|
|
* Determine hardware revision.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_identify_hardware(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Make sure our PCI config space has the necessary stuff set */
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.bus.pci_cmd_word = pci_read_config(dev, PCIR_COMMAND, 2);
|
2007-09-10 21:50:40 +00:00
|
|
|
if (!((adapter->hw.bus.pci_cmd_word & PCIM_CMD_BUSMASTEREN) &&
|
|
|
|
(adapter->hw.bus.pci_cmd_word & PCIM_CMD_MEMEN))) {
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "Memory Access and/or Bus Master bits "
|
|
|
|
"were not set!\n");
|
|
|
|
adapter->hw.bus.pci_cmd_word |=
|
|
|
|
(PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN);
|
|
|
|
pci_write_config(dev, PCIR_COMMAND,
|
|
|
|
adapter->hw.bus.pci_cmd_word, 2);
|
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Save off the information about this board */
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->hw.vendor_id = pci_get_vendor(dev);
|
|
|
|
adapter->hw.device_id = pci_get_device(dev);
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->hw.revision_id = pci_read_config(dev, PCIR_REVID, 1);
|
|
|
|
adapter->hw.subsystem_vendor_id =
|
|
|
|
pci_read_config(dev, PCIR_SUBVEND_0, 2);
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.subsystem_device_id =
|
|
|
|
pci_read_config(dev, PCIR_SUBDEV_0, 2);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/* Do Shared Code Init and Setup */
|
|
|
|
if (e1000_set_mac_type(&adapter->hw)) {
|
|
|
|
device_printf(dev, "Setup init failure\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_allocate_pci_resources(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2008-02-29 21:50:11 +00:00
|
|
|
int val, rid, error = E1000_SUCCESS;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2005-11-09 08:43:18 +00:00
|
|
|
rid = PCIR_BAR(0);
|
2008-02-29 21:50:11 +00:00
|
|
|
adapter->memory = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
|
2006-02-15 08:39:50 +00:00
|
|
|
&rid, RF_ACTIVE);
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->memory == NULL) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to allocate bus resource: memory\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->osdep.mem_bus_space_tag =
|
2008-02-29 21:50:11 +00:00
|
|
|
rman_get_bustag(adapter->memory);
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->osdep.mem_bus_space_handle =
|
2008-02-29 21:50:11 +00:00
|
|
|
rman_get_bushandle(adapter->memory);
|
|
|
|
adapter->hw.hw_addr = (u8 *)&adapter->osdep.mem_bus_space_handle;
|
2006-02-15 08:39:50 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Only older adapters use IO mapping */
|
2007-09-10 21:50:40 +00:00
|
|
|
if ((adapter->hw.mac.type > e1000_82543) &&
|
2007-05-11 21:36:08 +00:00
|
|
|
(adapter->hw.mac.type < e1000_82571)) {
|
2002-07-16 16:55:03 +00:00
|
|
|
/* Figure our where our IO BAR is ? */
|
2005-11-09 08:43:18 +00:00
|
|
|
for (rid = PCIR_BAR(0); rid < PCIR_CIS;) {
|
2002-07-16 16:55:03 +00:00
|
|
|
val = pci_read_config(dev, rid, 4);
|
2006-10-31 15:00:14 +00:00
|
|
|
if (EM_BAR_TYPE(val) == EM_BAR_TYPE_IO) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->io_rid = rid;
|
2002-07-16 16:55:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
rid += 4;
|
2005-11-09 08:43:18 +00:00
|
|
|
/* check for 64bit BAR */
|
2006-10-31 15:00:14 +00:00
|
|
|
if (EM_BAR_MEM_TYPE(val) == EM_BAR_MEM_TYPE_64BIT)
|
2005-11-09 08:43:18 +00:00
|
|
|
rid += 4;
|
|
|
|
}
|
|
|
|
if (rid >= PCIR_CIS) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to locate IO BAR\n");
|
2005-11-09 08:43:18 +00:00
|
|
|
return (ENXIO);
|
2002-07-16 16:55:03 +00:00
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
adapter->ioport = bus_alloc_resource_any(dev,
|
2007-05-04 00:00:12 +00:00
|
|
|
SYS_RES_IOPORT, &adapter->io_rid, RF_ACTIVE);
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->ioport == NULL) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to allocate bus resource: "
|
|
|
|
"ioport\n");
|
|
|
|
return (ENXIO);
|
2002-07-16 16:55:03 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->hw.io_base = 0;
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->osdep.io_bus_space_tag =
|
2008-02-29 21:50:11 +00:00
|
|
|
rman_get_bustag(adapter->ioport);
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->osdep.io_bus_space_handle =
|
2008-02-29 21:50:11 +00:00
|
|
|
rman_get_bushandle(adapter->ioport);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Init the resource arrays
|
|
|
|
** used by MSIX setup
|
|
|
|
*/
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
adapter->rid[i] = i + 1; /* MSI/X RID starts at 1 */
|
|
|
|
adapter->tag[i] = NULL;
|
|
|
|
adapter->res[i] = NULL;
|
2002-07-16 16:55:03 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*
|
|
|
|
* Setup MSI/X or MSI if PCI Express
|
|
|
|
*/
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
if (em_enable_msi)
|
|
|
|
adapter->msi = em_setup_msix(adapter);
|
2006-01-11 00:30:25 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->hw.back = &adapter->osdep;
|
2006-01-13 08:18:04 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
return (error);
|
2006-01-13 08:18:04 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2008-02-29 21:50:11 +00:00
|
|
|
* Setup the Legacy or MSI Interrupt handler
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
int
|
2008-02-29 21:50:11 +00:00
|
|
|
em_allocate_legacy(struct adapter *adapter)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
2006-10-28 08:11:07 +00:00
|
|
|
device_t dev = adapter->dev;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Manually turn off all interrupts */
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/* Legacy RID is 0 */
|
|
|
|
if (adapter->msi == 0)
|
|
|
|
adapter->rid[0] = 0;
|
|
|
|
|
|
|
|
/* We allocate a single interrupt resource */
|
|
|
|
adapter->res[0] = bus_alloc_resource_any(dev,
|
|
|
|
SYS_RES_IRQ, &adapter->rid[0], RF_SHAREABLE | RF_ACTIVE);
|
|
|
|
if (adapter->res[0] == NULL) {
|
|
|
|
device_printf(dev, "Unable to allocate bus resource: "
|
|
|
|
"interrupt\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
#ifdef EM_LEGACY_IRQ
|
2007-05-04 00:00:12 +00:00
|
|
|
/* We do Legacy setup */
|
2008-02-29 21:50:11 +00:00
|
|
|
if ((error = bus_setup_intr(dev, adapter->res[0],
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version > 700000
|
2007-05-04 00:00:12 +00:00
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, NULL, em_intr, adapter,
|
2007-11-20 21:41:22 +00:00
|
|
|
#else /* 6.X */
|
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, em_intr, adapter,
|
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
&adapter->tag[0])) != 0) {
|
2006-10-28 08:11:07 +00:00
|
|
|
device_printf(dev, "Failed to register interrupt handler");
|
|
|
|
return (error);
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
#else /* FAST_IRQ */
|
2006-10-28 08:11:07 +00:00
|
|
|
/*
|
|
|
|
* Try allocating a fast interrupt and the associated deferred
|
|
|
|
* processing contexts.
|
|
|
|
*/
|
|
|
|
TASK_INIT(&adapter->rxtx_task, 0, em_handle_rxtx, adapter);
|
|
|
|
TASK_INIT(&adapter->link_task, 0, em_handle_link, adapter);
|
|
|
|
adapter->tq = taskqueue_create_fast("em_taskq", M_NOWAIT,
|
|
|
|
taskqueue_thread_enqueue, &adapter->tq);
|
|
|
|
taskqueue_start_threads(&adapter->tq, 1, PI_NET, "%s taskq",
|
|
|
|
device_get_nameunit(adapter->dev));
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version < 700000
|
2008-02-29 21:50:11 +00:00
|
|
|
if ((error = bus_setup_intr(dev, adapter->res[0],
|
|
|
|
INTR_TYPE_NET | INTR_FAST, em_irq_fast, adapter,
|
2007-11-20 21:41:22 +00:00
|
|
|
#else
|
2008-02-29 21:50:11 +00:00
|
|
|
if ((error = bus_setup_intr(dev, adapter->res[0],
|
|
|
|
INTR_TYPE_NET, em_irq_fast, NULL, adapter,
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
&adapter->tag[0])) != 0) {
|
2006-10-28 08:11:07 +00:00
|
|
|
device_printf(dev, "Failed to register fast interrupt "
|
|
|
|
"handler: %d\n", error);
|
|
|
|
taskqueue_free(adapter->tq);
|
|
|
|
adapter->tq = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
2008-04-02 22:00:36 +00:00
|
|
|
#endif /* EM_LEGACY_IRQ */
|
2008-02-29 21:50:11 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Setup the MSIX Interrupt handlers
|
|
|
|
* This is not really Multiqueue, rather
|
|
|
|
* its just multiple interrupt vectors.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
int
|
|
|
|
em_allocate_msix(struct adapter *adapter)
|
2006-01-13 08:18:04 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2008-02-29 21:50:11 +00:00
|
|
|
int error;
|
2006-01-13 08:18:04 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/* Make sure all interrupts are disabled */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
|
|
|
|
|
|
|
|
/* First get the resources */
|
|
|
|
for (int i = 0; i < adapter->msi; i++) {
|
|
|
|
adapter->res[i] = bus_alloc_resource_any(dev,
|
|
|
|
SYS_RES_IRQ, &adapter->rid[i], RF_ACTIVE);
|
|
|
|
if (adapter->res[i] == NULL) {
|
|
|
|
device_printf(dev,
|
|
|
|
"Unable to allocate bus resource: "
|
|
|
|
"MSIX Interrupt\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2006-10-28 00:47:55 +00:00
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now allocate deferred processing contexts.
|
|
|
|
*/
|
|
|
|
TASK_INIT(&adapter->rx_task, 0, em_handle_rx, adapter);
|
|
|
|
TASK_INIT(&adapter->tx_task, 0, em_handle_tx, adapter);
|
|
|
|
TASK_INIT(&adapter->link_task, 0, em_handle_link, adapter);
|
|
|
|
adapter->tq = taskqueue_create_fast("em_taskq", M_NOWAIT,
|
|
|
|
taskqueue_thread_enqueue, &adapter->tq);
|
|
|
|
taskqueue_start_threads(&adapter->tq, 1, PI_NET, "%s taskq",
|
|
|
|
device_get_nameunit(adapter->dev));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* And setup the interrupt handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First slot to RX */
|
|
|
|
if ((error = bus_setup_intr(dev, adapter->res[0],
|
2008-05-19 23:01:11 +00:00
|
|
|
#if __FreeBSD_version > 700000
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, NULL, em_msix_rx, adapter,
|
2008-05-19 23:01:11 +00:00
|
|
|
#else /* 6.X */
|
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, em_msix_rx, adapter,
|
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
&adapter->tag[0])) != 0) {
|
|
|
|
device_printf(dev, "Failed to register RX handler");
|
|
|
|
return (error);
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
|
|
|
|
/* Next TX */
|
|
|
|
if ((error = bus_setup_intr(dev, adapter->res[1],
|
2008-05-19 23:01:11 +00:00
|
|
|
#if __FreeBSD_version > 700000
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, NULL, em_msix_tx, adapter,
|
2008-05-19 23:01:11 +00:00
|
|
|
#else /* 6.X */
|
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, em_msix_tx, adapter,
|
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
&adapter->tag[1])) != 0) {
|
|
|
|
device_printf(dev, "Failed to register TX handler");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And Link */
|
|
|
|
if ((error = bus_setup_intr(dev, adapter->res[2],
|
2008-05-19 23:01:11 +00:00
|
|
|
#if __FreeBSD_version > 700000
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, NULL, em_msix_link, adapter,
|
2008-05-19 23:01:11 +00:00
|
|
|
#else /* 6.X */
|
|
|
|
INTR_TYPE_NET | INTR_MPSAFE, em_msix_link, adapter,
|
|
|
|
#endif
|
2008-02-29 21:50:11 +00:00
|
|
|
&adapter->tag[2])) != 0) {
|
|
|
|
device_printf(dev, "Failed to register TX handler");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
em_free_pci_resources(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
device_t dev = adapter->dev;
|
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/* Make sure the for loop below runs once */
|
|
|
|
if (adapter->msi == 0)
|
|
|
|
adapter->msi = 1;
|
2007-05-17 00:14:03 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
/*
|
|
|
|
* First release all the interrupt resources:
|
|
|
|
* notice that since these are just kept
|
|
|
|
* in an array we can do the same logic
|
|
|
|
* whether its MSIX or just legacy.
|
|
|
|
*/
|
|
|
|
for (int i = 0; i < adapter->msi; i++) {
|
|
|
|
if (adapter->tag[i] != NULL) {
|
|
|
|
bus_teardown_intr(dev, adapter->res[i],
|
|
|
|
adapter->tag[i]);
|
|
|
|
adapter->tag[i] = NULL;
|
|
|
|
}
|
|
|
|
if (adapter->res[i] != NULL) {
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ,
|
|
|
|
adapter->rid[i], adapter->res[i]);
|
|
|
|
}
|
|
|
|
}
|
2006-11-15 20:04:57 +00:00
|
|
|
|
|
|
|
if (adapter->msi)
|
|
|
|
pci_release_msi(dev);
|
2006-02-15 08:39:50 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->msix != NULL)
|
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY,
|
|
|
|
PCIR_BAR(EM_MSIX_BAR), adapter->msix);
|
|
|
|
|
|
|
|
if (adapter->memory != NULL)
|
2007-05-04 00:00:12 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY,
|
2008-02-29 21:50:11 +00:00
|
|
|
PCIR_BAR(0), adapter->memory);
|
2002-07-16 16:55:03 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->flash != NULL)
|
2007-05-04 00:00:12 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY,
|
2008-02-29 21:50:11 +00:00
|
|
|
EM_FLASH, adapter->flash);
|
2006-08-03 09:20:11 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->ioport != NULL)
|
2007-05-04 00:00:12 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
2008-02-29 21:50:11 +00:00
|
|
|
adapter->io_rid, adapter->ioport);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* Setup MSI/X
|
|
|
|
*/
|
2008-02-29 21:50:11 +00:00
|
|
|
static int
|
2007-11-20 21:41:22 +00:00
|
|
|
em_setup_msix(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
device_t dev = adapter->dev;
|
2008-02-29 21:50:11 +00:00
|
|
|
int val = 0;
|
2007-11-20 21:41:22 +00:00
|
|
|
|
|
|
|
if (adapter->hw.mac.type < e1000_82571)
|
2008-02-29 21:50:11 +00:00
|
|
|
return (0);
|
2007-11-20 21:41:22 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/* Setup MSI/X for Hartwell */
|
|
|
|
if (adapter->hw.mac.type == e1000_82574) {
|
|
|
|
/* Map the MSIX BAR */
|
|
|
|
int rid = PCIR_BAR(EM_MSIX_BAR);
|
|
|
|
adapter->msix = bus_alloc_resource_any(dev,
|
|
|
|
SYS_RES_MEMORY, &rid, RF_ACTIVE);
|
|
|
|
if (!adapter->msix) {
|
|
|
|
/* May not be enabled */
|
|
|
|
device_printf(adapter->dev,
|
|
|
|
"Unable to map MSIX table \n");
|
|
|
|
goto msi;
|
|
|
|
}
|
|
|
|
val = pci_msix_count(dev);
|
|
|
|
/*
|
|
|
|
** 82574 can be configured for 5 but
|
|
|
|
** we limit use to 3.
|
|
|
|
*/
|
|
|
|
if (val > 3) val = 3;
|
|
|
|
if ((val) && pci_alloc_msix(dev, &val) == 0) {
|
|
|
|
device_printf(adapter->dev,"Using MSIX interrupts\n");
|
|
|
|
return (val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msi:
|
2007-11-20 21:41:22 +00:00
|
|
|
val = pci_msi_count(dev);
|
|
|
|
if (val == 1 && pci_alloc_msi(dev, &val) == 0) {
|
|
|
|
adapter->msi = 1;
|
|
|
|
device_printf(adapter->dev,"Using MSI interrupt\n");
|
2008-02-29 21:50:11 +00:00
|
|
|
return (val);
|
2007-11-20 21:41:22 +00:00
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
return (0);
|
2007-11-20 21:41:22 +00:00
|
|
|
}
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Initialize the hardware to a configuration
|
|
|
|
* as specified by the adapter structure.
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_hardware_init(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 rx_buffer_size;
|
2005-11-24 01:44:49 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
INIT_DEBUGOUT("em_hardware_init: begin");
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Issue a global reset */
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_reset_hw(&adapter->hw);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-31 23:36:21 +00:00
|
|
|
/* Get control from any management/hw control */
|
|
|
|
if (((adapter->hw.mac.type == e1000_82573) ||
|
|
|
|
(adapter->hw.mac.type == e1000_ich8lan) ||
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich10lan) ||
|
2007-05-31 23:36:21 +00:00
|
|
|
(adapter->hw.mac.type == e1000_ich9lan)) &&
|
|
|
|
e1000_check_mng_mode(&adapter->hw))
|
|
|
|
em_get_hw_control(adapter);
|
|
|
|
|
2003-03-21 21:47:31 +00:00
|
|
|
/* When hardware is reset, fifo_head is also reset */
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->tx_fifo_head = 0;
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2006-08-03 09:20:11 +00:00
|
|
|
/* Set up smart power down as default off on newer adapters. */
|
2007-05-04 00:00:12 +00:00
|
|
|
if (!em_smart_pwr_down && (adapter->hw.mac.type == e1000_82571 ||
|
|
|
|
adapter->hw.mac.type == e1000_82572)) {
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 phy_tmp = 0;
|
2006-08-03 09:20:11 +00:00
|
|
|
|
|
|
|
/* Speed up time to link by disabling smart power down. */
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_read_phy_reg(&adapter->hw,
|
|
|
|
IGP02E1000_PHY_POWER_MGMT, &phy_tmp);
|
2006-08-03 09:20:11 +00:00
|
|
|
phy_tmp &= ~IGP02E1000_PM_SPD;
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_write_phy_reg(&adapter->hw,
|
|
|
|
IGP02E1000_PHY_POWER_MGMT, phy_tmp);
|
2006-08-03 09:20:11 +00:00
|
|
|
}
|
|
|
|
|
2005-11-24 01:44:49 +00:00
|
|
|
/*
|
2006-01-20 11:38:25 +00:00
|
|
|
* These parameters control the automatic generation (Tx) and
|
2005-11-24 01:44:49 +00:00
|
|
|
* response (Rx) to Ethernet PAUSE frames.
|
|
|
|
* - High water mark should allow for at least two frames to be
|
|
|
|
* received after sending an XOFF.
|
|
|
|
* - Low water mark works best when it is very near the high water mark.
|
2006-02-15 08:39:50 +00:00
|
|
|
* This allows the receiver to restart by sending XON when it has
|
|
|
|
* drained a bit. Here we use an arbitary value of 1500 which will
|
|
|
|
* restart after one full frame is pulled from the buffer. There
|
|
|
|
* could be several smaller frames in the buffer and if so they will
|
|
|
|
* not trigger the XON until their total number reduces the buffer
|
|
|
|
* by 1500.
|
2005-11-24 01:44:49 +00:00
|
|
|
* - The pause time is fairly large at 1000 x 512ns = 512 usec.
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
rx_buffer_size = ((E1000_READ_REG(&adapter->hw, E1000_PBA) &
|
|
|
|
0xffff) << 10 );
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.fc.high_water = rx_buffer_size -
|
|
|
|
roundup2(adapter->max_frame_size, 1024);
|
|
|
|
adapter->hw.fc.low_water = adapter->hw.fc.high_water - 1500;
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_80003es2lan)
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.fc.pause_time = 0xFFFF;
|
2006-04-06 17:09:03 +00:00
|
|
|
else
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.fc.pause_time = EM_FC_PAUSE_TIME;
|
|
|
|
adapter->hw.fc.send_xon = TRUE;
|
2008-11-26 23:57:23 +00:00
|
|
|
adapter->hw.fc.requested_mode = e1000_fc_full;
|
2005-11-24 01:44:49 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (e1000_init_hw(&adapter->hw) < 0) {
|
|
|
|
device_printf(dev, "Hardware Initialization Failed\n");
|
2006-02-15 08:39:50 +00:00
|
|
|
return (EIO);
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_check_for_link(&adapter->hw);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Setup networking device structure and register an interface.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_setup_interface(device_t dev, struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2002-06-03 22:30:51 +00:00
|
|
|
struct ifnet *ifp;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
INIT_DEBUGOUT("em_setup_interface: begin");
|
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
ifp = adapter->ifp = if_alloc(IFT_ETHER);
|
2005-06-10 16:49:24 +00:00
|
|
|
if (ifp == NULL)
|
|
|
|
panic("%s: can not if_alloc()", device_get_nameunit(dev));
|
2003-10-31 18:32:15 +00:00
|
|
|
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
2002-06-03 22:30:51 +00:00
|
|
|
ifp->if_mtu = ETHERMTU;
|
|
|
|
ifp->if_init = em_init;
|
2006-08-03 19:05:04 +00:00
|
|
|
ifp->if_softc = adapter;
|
2002-06-03 22:30:51 +00:00
|
|
|
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
|
|
|
ifp->if_ioctl = em_ioctl;
|
|
|
|
ifp->if_start = em_start;
|
2006-08-03 19:05:04 +00:00
|
|
|
IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1);
|
|
|
|
ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1;
|
2004-07-02 12:16:02 +00:00
|
|
|
IFQ_SET_READY(&ifp->if_snd);
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
ether_ifattach(ifp, adapter->hw.mac.addr);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2004-05-20 11:04:09 +00:00
|
|
|
ifp->if_capabilities = ifp->if_capenable = 0;
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type >= e1000_82543) {
|
2007-11-20 21:41:22 +00:00
|
|
|
int version_cap;
|
|
|
|
#if __FreeBSD_version < 700000
|
|
|
|
version_cap = IFCAP_HWCSUM;
|
|
|
|
#else
|
|
|
|
version_cap = IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
|
|
|
|
#endif
|
|
|
|
ifp->if_capabilities |= version_cap;
|
|
|
|
ifp->if_capenable |= version_cap;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2007-05-17 00:14:03 +00:00
|
|
|
/* Identify TSO capable adapters */
|
|
|
|
if ((adapter->hw.mac.type > e1000_82544) &&
|
|
|
|
(adapter->hw.mac.type != e1000_82547))
|
2006-10-28 08:11:07 +00:00
|
|
|
ifp->if_capabilities |= IFCAP_TSO4;
|
2007-05-17 00:14:03 +00:00
|
|
|
/*
|
|
|
|
* By default only enable on PCI-E, this
|
|
|
|
* can be overriden by ifconfig.
|
|
|
|
*/
|
|
|
|
if (adapter->hw.mac.type >= e1000_82571)
|
2006-10-28 08:11:07 +00:00
|
|
|
ifp->if_capenable |= IFCAP_TSO4;
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2003-04-18 17:36:13 +00:00
|
|
|
/*
|
|
|
|
* Tell the upper layer(s) we support long frames.
|
|
|
|
*/
|
|
|
|
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
|
2004-05-20 11:04:09 +00:00
|
|
|
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
|
2007-11-20 21:41:22 +00:00
|
|
|
ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2004-04-11 21:01:12 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
ifp->if_capabilities |= IFCAP_POLLING;
|
|
|
|
#endif
|
2003-03-21 21:47:31 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
2002-06-03 22:30:51 +00:00
|
|
|
* Specify the media types supported by this adapter and register
|
|
|
|
* callbacks to update media and link information
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
ifmedia_init(&adapter->media, IFM_IMASK,
|
|
|
|
em_media_change, em_media_status);
|
2007-11-20 21:41:22 +00:00
|
|
|
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
|
|
|
|
(adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) {
|
2007-05-04 00:00:12 +00:00
|
|
|
u_char fiber_type = IFM_1000_SX; /* default type */
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.mac.type == e1000_82545)
|
2006-08-11 10:58:24 +00:00
|
|
|
fiber_type = IFM_1000_LX;
|
2007-05-04 00:00:12 +00:00
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | fiber_type | IFM_FDX,
|
|
|
|
0, NULL);
|
2006-08-11 10:58:24 +00:00
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | fiber_type, 0, NULL);
|
2002-06-03 22:30:51 +00:00
|
|
|
} else {
|
2006-08-03 19:05:04 +00:00
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T, 0, NULL);
|
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T | IFM_FDX,
|
2002-06-03 22:30:51 +00:00
|
|
|
0, NULL);
|
2006-08-03 19:05:04 +00:00
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | IFM_100_TX,
|
2002-06-03 22:30:51 +00:00
|
|
|
0, NULL);
|
2006-08-03 19:05:04 +00:00
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | IFM_100_TX | IFM_FDX,
|
2002-06-03 22:30:51 +00:00
|
|
|
0, NULL);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->hw.phy.type != e1000_phy_ife) {
|
2006-08-11 10:58:24 +00:00
|
|
|
ifmedia_add(&adapter->media,
|
2006-08-09 20:10:35 +00:00
|
|
|
IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
|
2006-08-11 10:58:24 +00:00
|
|
|
ifmedia_add(&adapter->media,
|
2006-08-09 20:10:35 +00:00
|
|
|
IFM_ETHER | IFM_1000_T, 0, NULL);
|
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
|
|
|
|
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-21 21:47:31 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Workaround for SmartSpeed on 82541 and 82547 controllers
|
|
|
|
*
|
2006-01-20 11:38:25 +00:00
|
|
|
**********************************************************************/
|
2003-03-21 21:47:31 +00:00
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_smartspeed(struct adapter *adapter)
|
2003-03-21 21:47:31 +00:00
|
|
|
{
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 phy_tmp;
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->link_active || (adapter->hw.phy.type != e1000_phy_igp) ||
|
|
|
|
adapter->hw.mac.autoneg == 0 ||
|
|
|
|
(adapter->hw.phy.autoneg_advertised & ADVERTISE_1000_FULL) == 0)
|
2003-03-21 21:47:31 +00:00
|
|
|
return;
|
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->smartspeed == 0) {
|
2006-02-15 08:39:50 +00:00
|
|
|
/* If Master/Slave config fault is asserted twice,
|
|
|
|
* we assume back-to-back */
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_tmp);
|
2006-02-15 08:39:50 +00:00
|
|
|
if (!(phy_tmp & SR_1000T_MS_CONFIG_FAULT))
|
|
|
|
return;
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_tmp);
|
2006-02-15 08:39:50 +00:00
|
|
|
if (phy_tmp & SR_1000T_MS_CONFIG_FAULT) {
|
2008-02-29 21:50:11 +00:00
|
|
|
e1000_read_phy_reg(&adapter->hw,
|
|
|
|
PHY_1000T_CTRL, &phy_tmp);
|
2006-02-15 08:39:50 +00:00
|
|
|
if(phy_tmp & CR_1000T_MS_ENABLE) {
|
|
|
|
phy_tmp &= ~CR_1000T_MS_ENABLE;
|
2008-02-29 21:50:11 +00:00
|
|
|
e1000_write_phy_reg(&adapter->hw,
|
|
|
|
PHY_1000T_CTRL, phy_tmp);
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->smartspeed++;
|
2007-05-04 00:00:12 +00:00
|
|
|
if(adapter->hw.mac.autoneg &&
|
|
|
|
!e1000_phy_setup_autoneg(&adapter->hw) &&
|
2008-02-29 21:50:11 +00:00
|
|
|
!e1000_read_phy_reg(&adapter->hw,
|
|
|
|
PHY_CONTROL, &phy_tmp)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
phy_tmp |= (MII_CR_AUTO_NEG_EN |
|
|
|
|
MII_CR_RESTART_AUTO_NEG);
|
2008-02-29 21:50:11 +00:00
|
|
|
e1000_write_phy_reg(&adapter->hw,
|
|
|
|
PHY_CONTROL, phy_tmp);
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2006-08-03 19:05:04 +00:00
|
|
|
} else if(adapter->smartspeed == EM_SMARTSPEED_DOWNSHIFT) {
|
2006-02-15 08:39:50 +00:00
|
|
|
/* If still no link, perhaps using 2/3 pair cable */
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_tmp);
|
2006-02-15 08:39:50 +00:00
|
|
|
phy_tmp |= CR_1000T_MS_ENABLE;
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_tmp);
|
|
|
|
if(adapter->hw.mac.autoneg &&
|
|
|
|
!e1000_phy_setup_autoneg(&adapter->hw) &&
|
|
|
|
!e1000_read_phy_reg(&adapter->hw, PHY_CONTROL, &phy_tmp)) {
|
2006-02-15 08:39:50 +00:00
|
|
|
phy_tmp |= (MII_CR_AUTO_NEG_EN |
|
|
|
|
MII_CR_RESTART_AUTO_NEG);
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CONTROL, phy_tmp);
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Restart process after EM_SMARTSPEED_MAX iterations */
|
2006-08-03 19:05:04 +00:00
|
|
|
if(adapter->smartspeed++ == EM_SMARTSPEED_MAX)
|
|
|
|
adapter->smartspeed = 0;
|
2003-03-21 21:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-02 21:17:08 +00:00
|
|
|
/*
|
|
|
|
* Manage DMA'able memory.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
2006-01-20 11:38:25 +00:00
|
|
|
{
|
2006-02-15 08:39:50 +00:00
|
|
|
if (error)
|
|
|
|
return;
|
|
|
|
*(bus_addr_t *) arg = segs[0].ds_addr;
|
2003-05-02 21:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-05-04 00:00:12 +00:00
|
|
|
em_dma_malloc(struct adapter *adapter, bus_size_t size,
|
|
|
|
struct em_dma_alloc *dma, int mapflags)
|
2006-02-15 08:39:50 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2006-10-28 08:11:07 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(adapter->dev), /* parent */
|
2007-11-20 21:41:22 +00:00
|
|
|
#else
|
|
|
|
error = bus_dma_tag_create(NULL, /* parent */
|
|
|
|
#endif
|
2006-08-03 09:20:11 +00:00
|
|
|
EM_DBA_ALIGN, 0, /* alignment, bounds */
|
2006-02-15 08:39:50 +00:00
|
|
|
BUS_SPACE_MAXADDR, /* lowaddr */
|
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
|
|
|
size, /* maxsize */
|
|
|
|
1, /* nsegments */
|
|
|
|
size, /* maxsegsize */
|
|
|
|
0, /* flags */
|
|
|
|
NULL, /* lockfunc */
|
|
|
|
NULL, /* lockarg */
|
|
|
|
&dma->dma_tag);
|
|
|
|
if (error) {
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(adapter->dev,
|
|
|
|
"%s: bus_dma_tag_create failed: %d\n",
|
2006-02-15 08:39:50 +00:00
|
|
|
__func__, error);
|
|
|
|
goto fail_0;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(dma->dma_tag, (void**) &dma->dma_vaddr,
|
2007-11-28 23:04:11 +00:00
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &dma->dma_map);
|
2006-02-15 08:39:50 +00:00
|
|
|
if (error) {
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(adapter->dev,
|
|
|
|
"%s: bus_dmamem_alloc(%ju) failed: %d\n",
|
2006-02-15 08:39:50 +00:00
|
|
|
__func__, (uintmax_t)size, error);
|
|
|
|
goto fail_2;
|
|
|
|
}
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2005-11-09 08:43:18 +00:00
|
|
|
dma->dma_paddr = 0;
|
2006-02-15 08:39:50 +00:00
|
|
|
error = bus_dmamap_load(dma->dma_tag, dma->dma_map, dma->dma_vaddr,
|
|
|
|
size, em_dmamap_cb, &dma->dma_paddr, mapflags | BUS_DMA_NOWAIT);
|
|
|
|
if (error || dma->dma_paddr == 0) {
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(adapter->dev,
|
|
|
|
"%s: bus_dmamap_load failed: %d\n",
|
2006-02-15 08:39:50 +00:00
|
|
|
__func__, error);
|
|
|
|
goto fail_3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
2003-05-02 21:17:08 +00:00
|
|
|
|
|
|
|
fail_3:
|
2006-02-15 08:39:50 +00:00
|
|
|
bus_dmamap_unload(dma->dma_tag, dma->dma_map);
|
2003-05-02 21:17:08 +00:00
|
|
|
fail_2:
|
2006-02-15 08:39:50 +00:00
|
|
|
bus_dmamem_free(dma->dma_tag, dma->dma_vaddr, dma->dma_map);
|
|
|
|
bus_dma_tag_destroy(dma->dma_tag);
|
2003-05-02 21:17:08 +00:00
|
|
|
fail_0:
|
2006-02-15 08:39:50 +00:00
|
|
|
dma->dma_map = NULL;
|
|
|
|
dma->dma_tag = NULL;
|
|
|
|
|
|
|
|
return (error);
|
2003-05-02 21:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_dma_free(struct adapter *adapter, struct em_dma_alloc *dma)
|
2003-05-02 21:17:08 +00:00
|
|
|
{
|
2005-11-21 04:17:43 +00:00
|
|
|
if (dma->dma_tag == NULL)
|
|
|
|
return;
|
|
|
|
if (dma->dma_map != NULL) {
|
|
|
|
bus_dmamap_sync(dma->dma_tag, dma->dma_map,
|
|
|
|
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(dma->dma_tag, dma->dma_map);
|
|
|
|
bus_dmamem_free(dma->dma_tag, dma->dma_vaddr, dma->dma_map);
|
|
|
|
dma->dma_map = NULL;
|
|
|
|
}
|
2006-02-15 08:39:50 +00:00
|
|
|
bus_dma_tag_destroy(dma->dma_tag);
|
2005-11-21 04:17:43 +00:00
|
|
|
dma->dma_tag = NULL;
|
2003-05-02 21:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2006-01-20 11:38:25 +00:00
|
|
|
* Allocate memory for tx_buffer structures. The tx_buffer stores all
|
|
|
|
* the information needed to transmit a packet on the wire.
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_allocate_transmit_structures(struct adapter *adapter)
|
2006-10-28 08:11:07 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2005-11-21 04:17:43 +00:00
|
|
|
struct em_buffer *tx_buffer;
|
2007-11-20 21:41:22 +00:00
|
|
|
int error;
|
2005-11-21 04:17:43 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
* Create DMA tags for tx descriptors
|
2006-02-15 08:39:50 +00:00
|
|
|
*/
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
2007-05-04 00:00:12 +00:00
|
|
|
if ((error = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */
|
2007-11-20 21:41:22 +00:00
|
|
|
#else
|
|
|
|
if ((error = bus_dma_tag_create(NULL, /* parent */
|
|
|
|
#endif
|
2006-02-15 08:39:50 +00:00
|
|
|
1, 0, /* alignment, bounds */
|
|
|
|
BUS_SPACE_MAXADDR, /* lowaddr */
|
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
2007-05-04 00:00:12 +00:00
|
|
|
EM_TSO_SIZE, /* maxsize */
|
2006-02-15 08:39:50 +00:00
|
|
|
EM_MAX_SCATTER, /* nsegments */
|
2007-05-04 00:00:12 +00:00
|
|
|
EM_TSO_SEG_SIZE, /* maxsegsize */
|
2006-02-15 08:39:50 +00:00
|
|
|
0, /* flags */
|
|
|
|
NULL, /* lockfunc */
|
|
|
|
NULL, /* lockarg */
|
2006-08-03 19:05:04 +00:00
|
|
|
&adapter->txtag)) != 0) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to allocate TX DMA tag\n");
|
2005-11-21 04:17:43 +00:00
|
|
|
goto fail;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->tx_buffer_area = malloc(sizeof(struct em_buffer) *
|
|
|
|
adapter->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO);
|
|
|
|
if (adapter->tx_buffer_area == NULL) {
|
|
|
|
device_printf(dev, "Unable to allocate tx_buffer memory\n");
|
|
|
|
error = ENOMEM;
|
2005-11-21 04:17:43 +00:00
|
|
|
goto fail;
|
2007-11-20 21:41:22 +00:00
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/* Create the descriptor buffer dma maps */
|
2007-11-20 21:41:22 +00:00
|
|
|
for (int i = 0; i < adapter->num_tx_desc; i++) {
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[i];
|
2006-08-03 19:05:04 +00:00
|
|
|
error = bus_dmamap_create(adapter->txtag, 0, &tx_buffer->map);
|
2005-11-21 04:17:43 +00:00
|
|
|
if (error != 0) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to create TX DMA map\n");
|
2005-11-21 04:17:43 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
tx_buffer->next_eop = -1;
|
2005-11-21 04:17:43 +00:00
|
|
|
}
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
return (0);
|
|
|
|
fail:
|
|
|
|
em_free_transmit_structures(adapter);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* (Re)Initialize transmit structures.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
|
|
|
em_setup_transmit_structures(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
struct em_buffer *tx_buffer;
|
|
|
|
|
|
|
|
/* Clear the old ring contents */
|
|
|
|
bzero(adapter->tx_desc_base,
|
|
|
|
(sizeof(struct e1000_tx_desc)) * adapter->num_tx_desc);
|
|
|
|
|
|
|
|
/* Free any existing TX buffers */
|
|
|
|
for (int i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) {
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[i];
|
|
|
|
bus_dmamap_sync(adapter->txtag, tx_buffer->map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(adapter->txtag, tx_buffer->map);
|
|
|
|
m_freem(tx_buffer->m_head);
|
|
|
|
tx_buffer->m_head = NULL;
|
|
|
|
tx_buffer->next_eop = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset state */
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->next_avail_tx_desc = 0;
|
2006-10-31 16:19:21 +00:00
|
|
|
adapter->next_tx_to_clean = 0;
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_tx_desc_avail = adapter->num_tx_desc;
|
2001-12-02 07:37:17 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_sync(adapter->txdma.dma_tag, adapter->txdma.dma_map,
|
2005-11-21 04:17:43 +00:00
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
return;
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Enable transmit unit.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_initialize_transmit_unit(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 tctl, tarc, tipg = 0;
|
|
|
|
u64 bus_addr;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
INIT_DEBUGOUT("em_initialize_transmit_unit: begin");
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Setup the Base and Length of the Tx Descriptor Ring */
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_addr = adapter->txdma.dma_paddr;
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDLEN(0),
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->num_tx_desc * sizeof(struct e1000_tx_desc));
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDBAH(0),
|
2008-02-29 21:50:11 +00:00
|
|
|
(u32)(bus_addr >> 32));
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDBAL(0),
|
2008-02-29 21:50:11 +00:00
|
|
|
(u32)bus_addr);
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Setup the HW Tx Head and Tail descriptor pointers */
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDT(0), 0);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TDH(0), 0);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
HW_DEBUGOUT2("Base = %x, Length = %x\n",
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDBAL(0)),
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDLEN(0)));
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Set the default values for the Tx Inter Packet Gap timer */
|
2007-05-04 00:00:12 +00:00
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
case e1000_82542:
|
|
|
|
tipg = DEFAULT_82542_TIPG_IPGT;
|
|
|
|
tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
|
|
|
|
tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
|
2006-02-15 08:39:50 +00:00
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
case e1000_80003es2lan:
|
|
|
|
tipg = DEFAULT_82543_TIPG_IPGR1;
|
|
|
|
tipg |= DEFAULT_80003ES2LAN_TIPG_IPGR2 <<
|
2006-04-06 17:09:03 +00:00
|
|
|
E1000_TIPG_IPGR2_SHIFT;
|
|
|
|
break;
|
2006-02-15 08:39:50 +00:00
|
|
|
default:
|
2007-11-20 21:41:22 +00:00
|
|
|
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
|
|
|
|
(adapter->hw.phy.media_type ==
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_media_type_internal_serdes))
|
|
|
|
tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
|
2006-02-15 08:39:50 +00:00
|
|
|
else
|
2007-05-04 00:00:12 +00:00
|
|
|
tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
|
|
|
|
tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
|
|
|
|
tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TIPG, tipg);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TIDV, adapter->tx_int_delay.value);
|
|
|
|
if(adapter->hw.mac.type >= e1000_82540)
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TADV,
|
|
|
|
adapter->tx_abs_int_delay.value);
|
|
|
|
|
|
|
|
if ((adapter->hw.mac.type == e1000_82571) ||
|
|
|
|
(adapter->hw.mac.type == e1000_82572)) {
|
2007-11-20 21:41:22 +00:00
|
|
|
tarc = E1000_READ_REG(&adapter->hw, E1000_TARC(0));
|
2007-05-04 00:00:12 +00:00
|
|
|
tarc |= SPEED_MODE_BIT;
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TARC(0), tarc);
|
2007-05-04 00:00:12 +00:00
|
|
|
} else if (adapter->hw.mac.type == e1000_80003es2lan) {
|
2007-11-20 21:41:22 +00:00
|
|
|
tarc = E1000_READ_REG(&adapter->hw, E1000_TARC(0));
|
2007-05-04 00:00:12 +00:00
|
|
|
tarc |= 1;
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TARC(0), tarc);
|
|
|
|
tarc = E1000_READ_REG(&adapter->hw, E1000_TARC(1));
|
2007-05-04 00:00:12 +00:00
|
|
|
tarc |= 1;
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TARC(1), tarc);
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Program the Transmit Control Register */
|
2007-05-04 00:00:12 +00:00
|
|
|
tctl = E1000_READ_REG(&adapter->hw, E1000_TCTL);
|
|
|
|
tctl &= ~E1000_TCTL_CT;
|
2007-05-30 23:32:21 +00:00
|
|
|
tctl |= (E1000_TCTL_PSP | E1000_TCTL_RTLC | E1000_TCTL_EN |
|
|
|
|
(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT));
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
if (adapter->hw.mac.type >= e1000_82571)
|
|
|
|
tctl |= E1000_TCTL_MULR;
|
|
|
|
|
2006-08-03 09:20:11 +00:00
|
|
|
/* This write will effectively turn on the transmit unit. */
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TCTL, tctl);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Setup Transmit Descriptor Base Settings */
|
2006-10-31 16:19:21 +00:00
|
|
|
adapter->txd_cmd = E1000_TXD_CMD_IFCS;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
if (adapter->tx_int_delay.value > 0)
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->txd_cmd |= E1000_TXD_CMD_IDE;
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Free all transmit related data structures.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_free_transmit_structures(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-02-15 08:39:50 +00:00
|
|
|
struct em_buffer *tx_buffer;
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
INIT_DEBUGOUT("free_transmit_structures: begin");
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->tx_buffer_area != NULL) {
|
2007-11-20 21:41:22 +00:00
|
|
|
for (int i = 0; i < adapter->num_tx_desc; i++) {
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[i];
|
2006-02-15 08:39:50 +00:00
|
|
|
if (tx_buffer->m_head != NULL) {
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_sync(adapter->txtag, tx_buffer->map,
|
2005-11-21 04:17:43 +00:00
|
|
|
BUS_DMASYNC_POSTWRITE);
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_unload(adapter->txtag,
|
2005-11-21 04:17:43 +00:00
|
|
|
tx_buffer->map);
|
2006-02-15 08:39:50 +00:00
|
|
|
m_freem(tx_buffer->m_head);
|
2005-11-21 04:17:43 +00:00
|
|
|
tx_buffer->m_head = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
} else if (tx_buffer->map != NULL)
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_unload(adapter->txtag,
|
2005-11-21 04:17:43 +00:00
|
|
|
tx_buffer->map);
|
|
|
|
if (tx_buffer->map != NULL) {
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_destroy(adapter->txtag,
|
2005-11-21 04:17:43 +00:00
|
|
|
tx_buffer->map);
|
|
|
|
tx_buffer->map = NULL;
|
|
|
|
}
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->tx_buffer_area != NULL) {
|
|
|
|
free(adapter->tx_buffer_area, M_DEVBUF);
|
|
|
|
adapter->tx_buffer_area = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->txtag != NULL) {
|
|
|
|
bus_dma_tag_destroy(adapter->txtag);
|
|
|
|
adapter->txtag = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* The offload context needs to be set when we transfer the first
|
2007-05-04 00:00:12 +00:00
|
|
|
* packet of a particular protocol (TCP/UDP). This routine has been
|
|
|
|
* enhanced to deal with inserted VLAN headers, and IPV6 (not complete)
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
2002-08-26 18:59:16 +00:00
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_transmit_checksum_setup(struct adapter *adapter, struct mbuf *mp,
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 *txd_upper, u32 *txd_lower)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2007-05-04 00:00:12 +00:00
|
|
|
struct e1000_context_desc *TXD;
|
2002-12-23 19:11:23 +00:00
|
|
|
struct em_buffer *tx_buffer;
|
2006-10-28 08:11:07 +00:00
|
|
|
struct ether_vlan_header *eh;
|
2008-02-29 21:50:11 +00:00
|
|
|
struct ip *ip = NULL;
|
2006-10-28 08:11:07 +00:00
|
|
|
struct ip6_hdr *ip6;
|
|
|
|
struct tcp_hdr *th;
|
2008-02-29 21:50:11 +00:00
|
|
|
int curr_txd, ehdrlen;
|
|
|
|
u32 cmd, hdr_len, ip_hlen;
|
|
|
|
u16 etype;
|
|
|
|
u8 ipproto;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
cmd = hdr_len = ipproto = 0;
|
2006-10-28 08:11:07 +00:00
|
|
|
/* Setup checksum offload context. */
|
|
|
|
curr_txd = adapter->next_avail_tx_desc;
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[curr_txd];
|
2007-05-04 00:00:12 +00:00
|
|
|
TXD = (struct e1000_context_desc *) &adapter->tx_desc_base[curr_txd];
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
/*
|
|
|
|
* Determine where frame payload starts.
|
|
|
|
* Jump over vlan headers if already present,
|
|
|
|
* helpful for QinQ too.
|
|
|
|
*/
|
|
|
|
eh = mtod(mp, struct ether_vlan_header *);
|
|
|
|
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
|
|
|
|
etype = ntohs(eh->evl_proto);
|
|
|
|
ehdrlen = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
|
2002-06-03 22:30:51 +00:00
|
|
|
} else {
|
2006-10-28 08:11:07 +00:00
|
|
|
etype = ntohs(eh->evl_encap_proto);
|
|
|
|
ehdrlen = ETHER_HDR_LEN;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
/*
|
|
|
|
* We only support TCP/UDP for IPv4 and IPv6 for the moment.
|
|
|
|
* TODO: Support SCTP too when it hits the tree.
|
2002-06-03 22:30:51 +00:00
|
|
|
*/
|
2006-10-28 08:11:07 +00:00
|
|
|
switch (etype) {
|
|
|
|
case ETHERTYPE_IP:
|
|
|
|
ip = (struct ip *)(mp->m_data + ehdrlen);
|
|
|
|
ip_hlen = ip->ip_hl << 2;
|
|
|
|
|
|
|
|
/* Setup of IP header checksum. */
|
|
|
|
if (mp->m_pkthdr.csum_flags & CSUM_IP) {
|
|
|
|
/*
|
|
|
|
* Start offset for header checksum calculation.
|
|
|
|
* End offset for header checksum calculation.
|
|
|
|
* Offset of place to put the checksum.
|
|
|
|
*/
|
|
|
|
TXD->lower_setup.ip_fields.ipcss = ehdrlen;
|
|
|
|
TXD->lower_setup.ip_fields.ipcse =
|
|
|
|
htole16(ehdrlen + ip_hlen);
|
|
|
|
TXD->lower_setup.ip_fields.ipcso =
|
|
|
|
ehdrlen + offsetof(struct ip, ip_sum);
|
|
|
|
cmd |= E1000_TXD_CMD_IP;
|
|
|
|
*txd_upper |= E1000_TXD_POPTS_IXSM << 8;
|
|
|
|
}
|
2006-09-29 13:37:26 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
if (mp->m_len < ehdrlen + ip_hlen)
|
|
|
|
return; /* failure */
|
2006-09-29 13:37:26 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
hdr_len = ehdrlen + ip_hlen;
|
|
|
|
ipproto = ip->ip_p;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case ETHERTYPE_IPV6:
|
|
|
|
ip6 = (struct ip6_hdr *)(mp->m_data + ehdrlen);
|
|
|
|
ip_hlen = sizeof(struct ip6_hdr); /* XXX: No header stacking. */
|
|
|
|
|
|
|
|
if (mp->m_len < ehdrlen + ip_hlen)
|
|
|
|
return; /* failure */
|
|
|
|
|
|
|
|
/* IPv6 doesn't have a header checksum. */
|
|
|
|
|
|
|
|
hdr_len = ehdrlen + ip_hlen;
|
|
|
|
ipproto = ip6->ip6_nxt;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
break;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
case ETHERTYPE_IEEE1588:
|
|
|
|
*txd_upper |= E1000_TXD_EXTCMD_TSTAMP;
|
|
|
|
break;
|
|
|
|
#endif
|
2006-10-28 08:11:07 +00:00
|
|
|
default:
|
|
|
|
*txd_upper = 0;
|
|
|
|
*txd_lower = 0;
|
|
|
|
return;
|
2006-09-29 13:37:26 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
switch (ipproto) {
|
|
|
|
case IPPROTO_TCP:
|
|
|
|
if (mp->m_pkthdr.csum_flags & CSUM_TCP) {
|
|
|
|
/*
|
|
|
|
* Start offset for payload checksum calculation.
|
|
|
|
* End offset for payload checksum calculation.
|
|
|
|
* Offset of place to put the checksum.
|
|
|
|
*/
|
|
|
|
th = (struct tcp_hdr *)(mp->m_data + hdr_len);
|
|
|
|
TXD->upper_setup.tcp_fields.tucss = hdr_len;
|
|
|
|
TXD->upper_setup.tcp_fields.tucse = htole16(0);
|
|
|
|
TXD->upper_setup.tcp_fields.tucso =
|
|
|
|
hdr_len + offsetof(struct tcphdr, th_sum);
|
|
|
|
cmd |= E1000_TXD_CMD_TCP;
|
|
|
|
*txd_upper |= E1000_TXD_POPTS_TXSM << 8;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IPPROTO_UDP:
|
2008-02-29 21:50:11 +00:00
|
|
|
{
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
void *hdr = (caddr_t) ip + ip_hlen;
|
|
|
|
struct udphdr *uh = (struct udphdr *)hdr;
|
|
|
|
|
|
|
|
if (uh->uh_dport == htons(TSYNC_PORT)) {
|
|
|
|
*txd_upper |= E1000_TXD_EXTCMD_TSTAMP;
|
|
|
|
IOCTL_DEBUGOUT("@@@ Sending Event Packet\n");
|
|
|
|
}
|
|
|
|
#endif
|
2006-10-28 08:11:07 +00:00
|
|
|
if (mp->m_pkthdr.csum_flags & CSUM_UDP) {
|
|
|
|
/*
|
|
|
|
* Start offset for header checksum calculation.
|
|
|
|
* End offset for header checksum calculation.
|
|
|
|
* Offset of place to put the checksum.
|
|
|
|
*/
|
|
|
|
TXD->upper_setup.tcp_fields.tucss = hdr_len;
|
|
|
|
TXD->upper_setup.tcp_fields.tucse = htole16(0);
|
|
|
|
TXD->upper_setup.tcp_fields.tucso =
|
|
|
|
hdr_len + offsetof(struct udphdr, uh_sum);
|
|
|
|
*txd_upper |= E1000_TXD_POPTS_TXSM << 8;
|
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
/* Fall Thru */
|
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-10-28 00:47:55 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
/*
|
|
|
|
** We might be here just for TIMESYNC
|
|
|
|
** which means we don't need the context
|
|
|
|
** descriptor.
|
|
|
|
*/
|
|
|
|
if (!mp->m_pkthdr.csum_flags & CSUM_OFFLOAD)
|
|
|
|
return;
|
|
|
|
#endif
|
2008-04-02 22:00:36 +00:00
|
|
|
*txd_lower = E1000_TXD_CMD_DEXT | /* Extended descr type */
|
|
|
|
E1000_TXD_DTYP_D; /* Data descr */
|
2006-10-28 08:11:07 +00:00
|
|
|
TXD->tcp_seg_setup.data = htole32(0);
|
|
|
|
TXD->cmd_and_length =
|
|
|
|
htole32(adapter->txd_cmd | E1000_TXD_CMD_DEXT | cmd);
|
2002-12-23 19:11:23 +00:00
|
|
|
tx_buffer->m_head = NULL;
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_buffer->next_eop = -1;
|
2002-12-23 19:11:23 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (++curr_txd == adapter->num_tx_desc)
|
2002-12-23 19:11:23 +00:00
|
|
|
curr_txd = 0;
|
2002-08-26 18:59:16 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_tx_desc_avail--;
|
|
|
|
adapter->next_avail_tx_desc = curr_txd;
|
2002-11-08 18:14:17 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
|
|
|
|
#if __FreeBSD_version >= 700000
|
2006-09-09 06:19:20 +00:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Setup work for hardware segmentation offload (TSO)
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
2007-11-20 21:41:22 +00:00
|
|
|
static bool
|
2008-02-29 21:50:11 +00:00
|
|
|
em_tso_setup(struct adapter *adapter, struct mbuf *mp, u32 *txd_upper,
|
|
|
|
u32 *txd_lower)
|
2006-09-10 19:23:27 +00:00
|
|
|
{
|
2007-05-04 00:00:12 +00:00
|
|
|
struct e1000_context_desc *TXD;
|
2006-09-10 19:23:27 +00:00
|
|
|
struct em_buffer *tx_buffer;
|
2006-10-28 08:11:07 +00:00
|
|
|
struct ether_vlan_header *eh;
|
2006-09-10 19:23:27 +00:00
|
|
|
struct ip *ip;
|
2006-10-28 08:11:07 +00:00
|
|
|
struct ip6_hdr *ip6;
|
2006-09-10 19:23:27 +00:00
|
|
|
struct tcphdr *th;
|
2006-10-28 08:11:07 +00:00
|
|
|
int curr_txd, ehdrlen, hdr_len, ip_hlen, isip6;
|
2008-02-29 21:50:11 +00:00
|
|
|
u16 etype;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This function could/should be extended to support IP/IPv6
|
|
|
|
* fragmentation as well. But as they say, one step at a time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine where frame payload starts.
|
|
|
|
* Jump over vlan headers if already present,
|
|
|
|
* helpful for QinQ too.
|
|
|
|
*/
|
|
|
|
eh = mtod(mp, struct ether_vlan_header *);
|
|
|
|
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
|
|
|
|
etype = ntohs(eh->evl_proto);
|
|
|
|
ehdrlen = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
|
|
|
|
} else {
|
|
|
|
etype = ntohs(eh->evl_encap_proto);
|
|
|
|
ehdrlen = ETHER_HDR_LEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure we have at least the IP+TCP header in the first mbuf. */
|
|
|
|
if (mp->m_len < ehdrlen + sizeof(struct ip) + sizeof(struct tcphdr))
|
|
|
|
return FALSE; /* -1 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We only support TCP for IPv4 and IPv6 (notyet) for the moment.
|
|
|
|
* TODO: Support SCTP too when it hits the tree.
|
|
|
|
*/
|
|
|
|
switch (etype) {
|
|
|
|
case ETHERTYPE_IP:
|
|
|
|
isip6 = 0;
|
|
|
|
ip = (struct ip *)(mp->m_data + ehdrlen);
|
|
|
|
if (ip->ip_p != IPPROTO_TCP)
|
|
|
|
return FALSE; /* 0 */
|
|
|
|
ip->ip_len = 0;
|
|
|
|
ip->ip_sum = 0;
|
|
|
|
ip_hlen = ip->ip_hl << 2;
|
|
|
|
if (mp->m_len < ehdrlen + ip_hlen + sizeof(struct tcphdr))
|
|
|
|
return FALSE; /* -1 */
|
|
|
|
th = (struct tcphdr *)((caddr_t)ip + ip_hlen);
|
|
|
|
#if 1
|
|
|
|
th->th_sum = in_pseudo(ip->ip_src.s_addr,
|
|
|
|
ip->ip_dst.s_addr, htons(IPPROTO_TCP));
|
|
|
|
#else
|
|
|
|
th->th_sum = mp->m_pkthdr.csum_data;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case ETHERTYPE_IPV6:
|
|
|
|
isip6 = 1;
|
|
|
|
return FALSE; /* Not supported yet. */
|
|
|
|
ip6 = (struct ip6_hdr *)(mp->m_data + ehdrlen);
|
|
|
|
if (ip6->ip6_nxt != IPPROTO_TCP)
|
|
|
|
return FALSE; /* 0 */
|
|
|
|
ip6->ip6_plen = 0;
|
|
|
|
ip_hlen = sizeof(struct ip6_hdr); /* XXX: no header stacking. */
|
|
|
|
if (mp->m_len < ehdrlen + ip_hlen + sizeof(struct tcphdr))
|
|
|
|
return FALSE; /* -1 */
|
|
|
|
th = (struct tcphdr *)((caddr_t)ip6 + ip_hlen);
|
|
|
|
#if 0
|
|
|
|
th->th_sum = in6_pseudo(ip6->ip6_src, ip->ip6_dst,
|
|
|
|
htons(IPPROTO_TCP)); /* XXX: function notyet. */
|
|
|
|
#else
|
|
|
|
th->th_sum = mp->m_pkthdr.csum_data;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
2006-09-10 19:23:27 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
hdr_len = ehdrlen + ip_hlen + (th->th_off << 2);
|
2006-09-10 19:23:27 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
*txd_lower = (E1000_TXD_CMD_DEXT | /* Extended descr type */
|
|
|
|
E1000_TXD_DTYP_D | /* Data descr type */
|
|
|
|
E1000_TXD_CMD_TSE); /* Do TSE on this packet */
|
2006-09-10 19:23:27 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
/* IP and/or TCP header checksum calculation and insertion. */
|
|
|
|
*txd_upper = ((isip6 ? 0 : E1000_TXD_POPTS_IXSM) |
|
2006-09-10 19:23:27 +00:00
|
|
|
E1000_TXD_POPTS_TXSM) << 8;
|
|
|
|
|
|
|
|
curr_txd = adapter->next_avail_tx_desc;
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[curr_txd];
|
2007-05-04 00:00:12 +00:00
|
|
|
TXD = (struct e1000_context_desc *) &adapter->tx_desc_base[curr_txd];
|
2006-09-10 19:23:27 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
/* IPv6 doesn't have a header checksum. */
|
|
|
|
if (!isip6) {
|
|
|
|
/*
|
|
|
|
* Start offset for header checksum calculation.
|
|
|
|
* End offset for header checksum calculation.
|
|
|
|
* Offset of place put the checksum.
|
|
|
|
*/
|
|
|
|
TXD->lower_setup.ip_fields.ipcss = ehdrlen;
|
|
|
|
TXD->lower_setup.ip_fields.ipcse =
|
|
|
|
htole16(ehdrlen + ip_hlen - 1);
|
|
|
|
TXD->lower_setup.ip_fields.ipcso =
|
|
|
|
ehdrlen + offsetof(struct ip, ip_sum);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Start offset for payload checksum calculation.
|
|
|
|
* End offset for payload checksum calculation.
|
|
|
|
* Offset of place to put the checksum.
|
|
|
|
*/
|
|
|
|
TXD->upper_setup.tcp_fields.tucss =
|
|
|
|
ehdrlen + ip_hlen;
|
2006-09-10 19:23:27 +00:00
|
|
|
TXD->upper_setup.tcp_fields.tucse = 0;
|
2006-10-28 08:11:07 +00:00
|
|
|
TXD->upper_setup.tcp_fields.tucso =
|
|
|
|
ehdrlen + ip_hlen + offsetof(struct tcphdr, th_sum);
|
|
|
|
/*
|
|
|
|
* Payload size per packet w/o any headers.
|
|
|
|
* Length of all headers up to payload.
|
|
|
|
*/
|
2006-09-10 19:23:27 +00:00
|
|
|
TXD->tcp_seg_setup.fields.mss = htole16(mp->m_pkthdr.tso_segsz);
|
|
|
|
TXD->tcp_seg_setup.fields.hdr_len = hdr_len;
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
TXD->cmd_and_length = htole32(adapter->txd_cmd |
|
2006-10-28 08:11:07 +00:00
|
|
|
E1000_TXD_CMD_DEXT | /* Extended descr */
|
|
|
|
E1000_TXD_CMD_TSE | /* TSE context */
|
|
|
|
(isip6 ? 0 : E1000_TXD_CMD_IP) | /* Do IP csum */
|
|
|
|
E1000_TXD_CMD_TCP | /* Do TCP checksum */
|
|
|
|
(mp->m_pkthdr.len - (hdr_len))); /* Total len */
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
tx_buffer->m_head = NULL;
|
2007-05-04 00:00:12 +00:00
|
|
|
tx_buffer->next_eop = -1;
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
if (++curr_txd == adapter->num_tx_desc)
|
|
|
|
curr_txd = 0;
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
adapter->num_tx_desc_avail--;
|
|
|
|
adapter->next_avail_tx_desc = curr_txd;
|
|
|
|
adapter->tx_tso = TRUE;
|
2006-09-09 06:19:20 +00:00
|
|
|
|
2006-09-10 19:23:27 +00:00
|
|
|
return TRUE;
|
2006-09-09 06:19:20 +00:00
|
|
|
}
|
2008-04-02 22:00:36 +00:00
|
|
|
|
2008-02-29 21:50:11 +00:00
|
|
|
#endif /* __FreeBSD_version >= 700000 */
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2002-11-08 18:14:17 +00:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Examine each tx_buffer in the used queue. If the hardware is done
|
|
|
|
* processing the packet then free associated resources. The
|
2002-12-23 19:11:23 +00:00
|
|
|
* tx_buffer is put back on the free queue.
|
2002-11-08 18:14:17 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_txeof(struct adapter *adapter)
|
2002-11-08 18:14:17 +00:00
|
|
|
{
|
2007-05-04 00:00:12 +00:00
|
|
|
int first, last, done, num_avail;
|
|
|
|
struct em_buffer *tx_buffer;
|
|
|
|
struct e1000_tx_desc *tx_desc, *eop_desc;
|
2006-08-03 19:05:04 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_TX_LOCK_ASSERT(adapter);
|
2003-09-23 00:18:25 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (adapter->num_tx_desc_avail == adapter->num_tx_desc)
|
|
|
|
return;
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
num_avail = adapter->num_tx_desc_avail;
|
|
|
|
first = adapter->next_tx_to_clean;
|
|
|
|
tx_desc = &adapter->tx_desc_base[first];
|
|
|
|
tx_buffer = &adapter->tx_buffer_area[first];
|
2006-10-31 16:19:21 +00:00
|
|
|
last = tx_buffer->next_eop;
|
2007-05-04 00:00:12 +00:00
|
|
|
eop_desc = &adapter->tx_desc_base[last];
|
2002-11-08 18:14:17 +00:00
|
|
|
|
2006-10-31 16:19:21 +00:00
|
|
|
/*
|
2007-05-04 00:00:12 +00:00
|
|
|
* What this does is get the index of the
|
|
|
|
* first descriptor AFTER the EOP of the
|
|
|
|
* first packet, that way we can do the
|
|
|
|
* simple comparison on the inner while loop.
|
2006-10-31 16:19:21 +00:00
|
|
|
*/
|
|
|
|
if (++last == adapter->num_tx_desc)
|
2007-05-04 00:00:12 +00:00
|
|
|
last = 0;
|
2006-10-31 16:19:21 +00:00
|
|
|
done = last;
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
bus_dmamap_sync(adapter->txdma.dma_tag, adapter->txdma.dma_map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
while (eop_desc->upper.fields.status & E1000_TXD_STAT_DD) {
|
2006-10-31 16:19:21 +00:00
|
|
|
/* We clean the range of the packet */
|
|
|
|
while (first != done) {
|
2007-05-04 00:00:12 +00:00
|
|
|
tx_desc->upper.data = 0;
|
|
|
|
tx_desc->lower.data = 0;
|
|
|
|
tx_desc->buffer_addr = 0;
|
|
|
|
num_avail++;
|
2006-10-31 16:19:21 +00:00
|
|
|
|
|
|
|
if (tx_buffer->m_head) {
|
|
|
|
ifp->if_opackets++;
|
2007-05-04 00:00:12 +00:00
|
|
|
bus_dmamap_sync(adapter->txtag,
|
|
|
|
tx_buffer->map,
|
2006-10-31 16:19:21 +00:00
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(adapter->txtag,
|
|
|
|
tx_buffer->map);
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
m_freem(tx_buffer->m_head);
|
|
|
|
tx_buffer->m_head = NULL;
|
|
|
|
}
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_buffer->next_eop = -1;
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (++first == adapter->num_tx_desc)
|
2006-10-31 16:19:21 +00:00
|
|
|
first = 0;
|
2006-02-15 08:39:50 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
tx_buffer = &adapter->tx_buffer_area[first];
|
2006-10-31 16:19:21 +00:00
|
|
|
tx_desc = &adapter->tx_desc_base[first];
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2006-10-31 16:19:21 +00:00
|
|
|
/* See if we can continue to the next packet */
|
|
|
|
last = tx_buffer->next_eop;
|
|
|
|
if (last != -1) {
|
2007-05-04 00:00:12 +00:00
|
|
|
eop_desc = &adapter->tx_desc_base[last];
|
2006-10-31 16:19:21 +00:00
|
|
|
/* Get new done point */
|
2007-05-04 00:00:12 +00:00
|
|
|
if (++last == adapter->num_tx_desc) last = 0;
|
2006-10-31 16:19:21 +00:00
|
|
|
done = last;
|
|
|
|
} else
|
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
|
|
|
bus_dmamap_sync(adapter->txdma.dma_tag, adapter->txdma.dma_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
adapter->next_tx_to_clean = first;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have enough room, clear IFF_DRV_OACTIVE to tell the stack
|
|
|
|
* that it is OK to send packets.
|
|
|
|
* If there are no pending descriptors, clear the timeout. Otherwise,
|
|
|
|
* if some descriptors have been freed, restart the timeout.
|
|
|
|
*/
|
|
|
|
if (num_avail > EM_TX_CLEANUP_THRESHOLD) {
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
|
|
|
/* All clean, turn off the timer */
|
2008-02-29 21:50:11 +00:00
|
|
|
if (num_avail == adapter->num_tx_desc) {
|
2006-11-09 16:00:18 +00:00
|
|
|
adapter->watchdog_timer = 0;
|
2008-02-29 21:50:11 +00:00
|
|
|
} else
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Some cleaned, reset the timer */
|
2008-02-29 21:50:11 +00:00
|
|
|
if (num_avail != adapter->num_tx_desc_avail)
|
2006-11-09 16:00:18 +00:00
|
|
|
adapter->watchdog_timer = EM_TX_TIMEOUT;
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
|
|
|
adapter->num_tx_desc_avail = num_avail;
|
2008-02-29 21:50:11 +00:00
|
|
|
return;
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* When Link is lost sometimes there is work still in the TX ring
|
|
|
|
* which will result in a watchdog, rather than allow that do an
|
|
|
|
* attempted cleanup and then reinit here. Note that this has been
|
|
|
|
* seens mostly with fiber adapters.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
|
|
|
em_tx_purge(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
if ((!adapter->link_active) && (adapter->watchdog_timer)) {
|
|
|
|
EM_TX_LOCK(adapter);
|
|
|
|
em_txeof(adapter);
|
|
|
|
EM_TX_UNLOCK(adapter);
|
|
|
|
if (adapter->watchdog_timer) { /* Still not clean? */
|
|
|
|
adapter->watchdog_timer = 0;
|
|
|
|
em_init_locked(adapter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Get a buffer from system mbuf buffer pool.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static int
|
2006-10-28 08:11:07 +00:00
|
|
|
em_get_buf(struct adapter *adapter, int i)
|
2006-01-20 11:38:25 +00:00
|
|
|
{
|
2006-10-28 08:11:07 +00:00
|
|
|
struct mbuf *m;
|
2006-01-20 11:38:25 +00:00
|
|
|
bus_dma_segment_t segs[1];
|
2006-10-28 08:11:07 +00:00
|
|
|
bus_dmamap_t map;
|
2006-01-20 11:38:25 +00:00
|
|
|
struct em_buffer *rx_buffer;
|
|
|
|
int error, nsegs;
|
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
|
|
|
|
if (m == NULL) {
|
|
|
|
adapter->mbuf_cluster_failed++;
|
|
|
|
return (ENOBUFS);
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
m->m_len = m->m_pkthdr.len = MCLBYTES;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->max_frame_size <= (MCLBYTES - ETHER_ALIGN))
|
2006-10-28 08:11:07 +00:00
|
|
|
m_adj(m, ETHER_ALIGN);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
|
|
|
* Using memory from the mbuf cluster pool, invoke the
|
|
|
|
* bus_dma machinery to arrange the memory mapping.
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
error = bus_dmamap_load_mbuf_sg(adapter->rxtag,
|
|
|
|
adapter->rx_sparemap, m, segs, &nsegs, BUS_DMA_NOWAIT);
|
2006-01-20 11:38:25 +00:00
|
|
|
if (error != 0) {
|
2006-10-28 08:11:07 +00:00
|
|
|
m_free(m);
|
2006-01-20 11:38:25 +00:00
|
|
|
return (error);
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
/* If nsegs is wrong then the stack is corrupt. */
|
2005-11-21 04:17:43 +00:00
|
|
|
KASSERT(nsegs == 1, ("Too many segments returned!"));
|
2006-10-28 08:11:07 +00:00
|
|
|
|
|
|
|
rx_buffer = &adapter->rx_buffer_area[i];
|
|
|
|
if (rx_buffer->m_head != NULL)
|
|
|
|
bus_dmamap_unload(adapter->rxtag, rx_buffer->map);
|
|
|
|
|
|
|
|
map = rx_buffer->map;
|
|
|
|
rx_buffer->map = adapter->rx_sparemap;
|
|
|
|
adapter->rx_sparemap = map;
|
2006-10-28 00:47:55 +00:00
|
|
|
bus_dmamap_sync(adapter->rxtag, rx_buffer->map, BUS_DMASYNC_PREREAD);
|
2006-10-28 08:11:07 +00:00
|
|
|
rx_buffer->m_head = m;
|
|
|
|
|
|
|
|
adapter->rx_desc_base[i].buffer_addr = htole64(segs[0].ds_addr);
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
2006-01-20 11:38:25 +00:00
|
|
|
* Allocate memory for rx_buffer structures. Since we use one
|
|
|
|
* rx_buffer per received packet, the maximum number of rx_buffer's
|
|
|
|
* that we'll need is equal to the number of receive descriptors
|
2001-12-02 07:37:17 +00:00
|
|
|
* that we've allocated.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_allocate_receive_structures(struct adapter *adapter)
|
2006-02-15 08:39:50 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2006-02-15 08:39:50 +00:00
|
|
|
struct em_buffer *rx_buffer;
|
|
|
|
int i, error;
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->rx_buffer_area = malloc(sizeof(struct em_buffer) *
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->num_rx_desc, M_DEVBUF, M_NOWAIT | M_ZERO);
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->rx_buffer_area == NULL) {
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Unable to allocate rx_buffer memory\n");
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version >= 700000
|
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */
|
|
|
|
#else
|
|
|
|
error = bus_dma_tag_create(NULL, /* parent */
|
|
|
|
#endif
|
2006-02-15 08:39:50 +00:00
|
|
|
1, 0, /* alignment, bounds */
|
|
|
|
BUS_SPACE_MAXADDR, /* lowaddr */
|
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
2007-05-04 00:00:12 +00:00
|
|
|
MCLBYTES, /* maxsize */
|
2006-02-15 08:39:50 +00:00
|
|
|
1, /* nsegments */
|
2007-05-04 00:00:12 +00:00
|
|
|
MCLBYTES, /* maxsegsize */
|
2006-07-27 00:29:44 +00:00
|
|
|
0, /* flags */
|
2006-02-15 08:39:50 +00:00
|
|
|
NULL, /* lockfunc */
|
|
|
|
NULL, /* lockarg */
|
2006-08-03 19:05:04 +00:00
|
|
|
&adapter->rxtag);
|
2006-02-15 08:39:50 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "%s: bus_dma_tag_create failed %d\n",
|
|
|
|
__func__, error);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/* Create the spare map (used by getbuf) */
|
2006-10-28 08:11:07 +00:00
|
|
|
error = bus_dmamap_create(adapter->rxtag, BUS_DMA_NOWAIT,
|
2007-05-04 00:00:12 +00:00
|
|
|
&adapter->rx_sparemap);
|
2006-10-28 08:11:07 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "%s: bus_dmamap_create failed: %d\n",
|
|
|
|
__func__, error);
|
|
|
|
goto fail;
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
rx_buffer = adapter->rx_buffer_area;
|
|
|
|
for (i = 0; i < adapter->num_rx_desc; i++, rx_buffer++) {
|
|
|
|
error = bus_dmamap_create(adapter->rxtag, BUS_DMA_NOWAIT,
|
2006-02-15 08:39:50 +00:00
|
|
|
&rx_buffer->map);
|
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "%s: bus_dmamap_create failed: %d\n",
|
|
|
|
__func__, error);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
2003-05-02 21:17:08 +00:00
|
|
|
|
2005-11-21 04:17:43 +00:00
|
|
|
fail:
|
2006-08-03 19:05:04 +00:00
|
|
|
em_free_receive_structures(adapter);
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
2007-11-20 21:41:22 +00:00
|
|
|
* (Re)initialize receive structures.
|
2006-01-20 11:38:25 +00:00
|
|
|
*
|
2001-12-02 07:37:17 +00:00
|
|
|
**********************************************************************/
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_setup_receive_structures(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2007-11-20 21:41:22 +00:00
|
|
|
struct em_buffer *rx_buffer;
|
|
|
|
int i, error;
|
2006-10-28 00:47:55 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Reset descriptor ring */
|
2007-05-04 00:00:12 +00:00
|
|
|
bzero(adapter->rx_desc_base,
|
|
|
|
(sizeof(struct e1000_rx_desc)) * adapter->num_rx_desc);
|
2006-10-31 17:21:14 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Free current RX buffers. */
|
|
|
|
rx_buffer = adapter->rx_buffer_area;
|
|
|
|
for (i = 0; i < adapter->num_rx_desc; i++, rx_buffer++) {
|
|
|
|
if (rx_buffer->m_head != NULL) {
|
|
|
|
bus_dmamap_sync(adapter->rxtag, rx_buffer->map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
bus_dmamap_unload(adapter->rxtag, rx_buffer->map);
|
|
|
|
m_freem(rx_buffer->m_head);
|
|
|
|
rx_buffer->m_head = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate new ones. */
|
|
|
|
for (i = 0; i < adapter->num_rx_desc; i++) {
|
|
|
|
error = em_get_buf(adapter, i);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Setup our descriptor pointers */
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->next_rx_desc_to_check = 0;
|
2007-11-20 21:41:22 +00:00
|
|
|
bus_dmamap_sync(adapter->rxdma.dma_tag, adapter->rxdma.dma_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2006-02-15 08:39:50 +00:00
|
|
|
|
|
|
|
return (0);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Enable receive unit.
|
2006-01-20 11:38:25 +00:00
|
|
|
*
|
2001-12-02 07:37:17 +00:00
|
|
|
**********************************************************************/
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#define MAX_INTS_PER_SEC 8000
|
|
|
|
#define DEFAULT_ITR 1000000000/(MAX_INTS_PER_SEC * 256)
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_initialize_receive_unit(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;
|
2008-02-29 21:50:11 +00:00
|
|
|
u64 bus_addr;
|
|
|
|
u32 rctl, rxcsum;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
INIT_DEBUGOUT("em_initialize_receive_unit: begin");
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
/*
|
|
|
|
* Make sure receives are disabled while setting
|
|
|
|
* up the descriptor ring
|
|
|
|
*/
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl & ~E1000_RCTL_EN);
|
2006-10-28 08:11:07 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
if (adapter->hw.mac.type >= e1000_82540) {
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RADV,
|
|
|
|
adapter->rx_abs_int_delay.value);
|
2006-02-15 08:39:50 +00:00
|
|
|
/*
|
|
|
|
* Set the interrupt throttling rate. Value is calculated
|
|
|
|
* as DEFAULT_ITR = 1/(MAX_INTS_PER_SEC * 256ns)
|
|
|
|
*/
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_ITR, DEFAULT_ITR);
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2002-12-23 19:11:23 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/*
|
|
|
|
** When using MSIX interrupts we need to throttle
|
|
|
|
** using the EITR register (82574 only)
|
|
|
|
*/
|
|
|
|
if (adapter->msix)
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
E1000_WRITE_REG(&adapter->hw,
|
|
|
|
E1000_EITR_82574(i), DEFAULT_ITR);
|
|
|
|
|
|
|
|
/* Disable accelerated ackknowledge */
|
|
|
|
if (adapter->hw.mac.type == e1000_82574)
|
|
|
|
E1000_WRITE_REG(&adapter->hw,
|
|
|
|
E1000_RFCTL, E1000_RFCTL_ACK_DIS);
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Setup the Base and Length of the Rx Descriptor Ring */
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_addr = adapter->rxdma.dma_paddr;
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDLEN(0),
|
|
|
|
adapter->num_rx_desc * sizeof(struct e1000_rx_desc));
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDBAH(0),
|
2008-02-29 21:50:11 +00:00
|
|
|
(u32)(bus_addr >> 32));
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDBAL(0),
|
2008-02-29 21:50:11 +00:00
|
|
|
(u32)bus_addr);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Setup the Receive Control Register */
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
|
|
|
|
rctl |= E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_LBM_NO |
|
2002-06-03 22:30:51 +00:00
|
|
|
E1000_RCTL_RDMTS_HALF |
|
2007-05-04 00:00:12 +00:00
|
|
|
(adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/* Make sure VLAN Filters are off */
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl &= ~E1000_RCTL_VFE;
|
2007-11-20 21:41:22 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
if (e1000_tbi_sbp_enabled_82543(&adapter->hw))
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl |= E1000_RCTL_SBP;
|
2007-05-04 00:00:12 +00:00
|
|
|
else
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl &= ~E1000_RCTL_SBP;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
switch (adapter->rx_buffer_len) {
|
2002-07-16 16:55:03 +00:00
|
|
|
default:
|
2007-05-04 00:00:12 +00:00
|
|
|
case 2048:
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl |= E1000_RCTL_SZ_2048;
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
case 4096:
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl |= E1000_RCTL_SZ_4096 |
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_RCTL_BSEX | E1000_RCTL_LPE;
|
2006-01-20 11:38:25 +00:00
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
case 8192:
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl |= E1000_RCTL_SZ_8192 |
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_RCTL_BSEX | E1000_RCTL_LPE;
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
2007-05-04 00:00:12 +00:00
|
|
|
case 16384:
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl |= E1000_RCTL_SZ_16384 |
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_RCTL_BSEX | E1000_RCTL_LPE;
|
2002-06-03 22:30:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-07-16 16:55:03 +00:00
|
|
|
if (ifp->if_mtu > ETHERMTU)
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl |= E1000_RCTL_LPE;
|
2007-05-04 00:00:12 +00:00
|
|
|
else
|
2008-02-29 21:50:11 +00:00
|
|
|
rctl &= ~E1000_RCTL_LPE;
|
2002-07-16 16:55:03 +00:00
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Enable 82543 Receive Checksum Offload for TCP and UDP */
|
2007-05-04 00:00:12 +00:00
|
|
|
if ((adapter->hw.mac.type >= e1000_82543) &&
|
2002-06-03 22:30:51 +00:00
|
|
|
(ifp->if_capenable & IFCAP_RXCSUM)) {
|
2008-02-29 21:50:11 +00:00
|
|
|
rxcsum = E1000_READ_REG(&adapter->hw, E1000_RXCSUM);
|
|
|
|
rxcsum |= (E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RXCSUM, rxcsum);
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*
|
|
|
|
** XXX TEMPORARY WORKAROUND: on some systems with 82573
|
|
|
|
** long latencies are observed, like Lenovo X60. This
|
|
|
|
** change eliminates the problem, but since having positive
|
|
|
|
** values in RDTR is a known source of problems on other
|
|
|
|
** platforms another solution is being sought.
|
|
|
|
*/
|
|
|
|
if (adapter->hw.mac.type == e1000_82573)
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDTR, 0x20);
|
|
|
|
|
2002-06-03 22:30:51 +00:00
|
|
|
/* Enable Receives */
|
2008-02-29 21:50:11 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup the HW Rx Head and
|
|
|
|
* Tail Descriptor Pointers
|
|
|
|
*/
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDH(0), 0);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), adapter->num_rx_desc - 1);
|
2006-10-31 15:00:14 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
return;
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Free receive related data structures.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_free_receive_structures(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2006-02-15 08:39:50 +00:00
|
|
|
struct em_buffer *rx_buffer;
|
|
|
|
int i;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
INIT_DEBUGOUT("free_receive_structures: begin");
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-10-28 08:11:07 +00:00
|
|
|
if (adapter->rx_sparemap) {
|
|
|
|
bus_dmamap_destroy(adapter->rxtag, adapter->rx_sparemap);
|
|
|
|
adapter->rx_sparemap = NULL;
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/* Cleanup any existing buffers */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->rx_buffer_area != NULL) {
|
|
|
|
rx_buffer = adapter->rx_buffer_area;
|
|
|
|
for (i = 0; i < adapter->num_rx_desc; i++, rx_buffer++) {
|
2005-11-21 04:17:43 +00:00
|
|
|
if (rx_buffer->m_head != NULL) {
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_sync(adapter->rxtag, rx_buffer->map,
|
2005-11-21 04:17:43 +00:00
|
|
|
BUS_DMASYNC_POSTREAD);
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_unload(adapter->rxtag,
|
2005-11-21 04:17:43 +00:00
|
|
|
rx_buffer->map);
|
|
|
|
m_freem(rx_buffer->m_head);
|
|
|
|
rx_buffer->m_head = NULL;
|
|
|
|
} else if (rx_buffer->map != NULL)
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_unload(adapter->rxtag,
|
2005-11-21 04:17:43 +00:00
|
|
|
rx_buffer->map);
|
2006-02-15 08:39:50 +00:00
|
|
|
if (rx_buffer->map != NULL) {
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_destroy(adapter->rxtag,
|
2005-11-21 04:17:43 +00:00
|
|
|
rx_buffer->map);
|
|
|
|
rx_buffer->map = NULL;
|
|
|
|
}
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->rx_buffer_area != NULL) {
|
|
|
|
free(adapter->rx_buffer_area, M_DEVBUF);
|
|
|
|
adapter->rx_buffer_area = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->rxtag != NULL) {
|
|
|
|
bus_dma_tag_destroy(adapter->rxtag);
|
|
|
|
adapter->rxtag = NULL;
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* This routine executes in interrupt context. It replenishes
|
|
|
|
* the mbufs in the descriptor and sends data which has been
|
|
|
|
* dma'ed into host memory to upper layer.
|
|
|
|
*
|
2002-12-23 19:11:23 +00:00
|
|
|
* We loop at most count times if count is > 0, or until done if
|
|
|
|
* count < 0.
|
|
|
|
*
|
2001-12-02 07:37:17 +00:00
|
|
|
*********************************************************************/
|
2006-01-11 00:30:25 +00:00
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_rxeof(struct adapter *adapter, int count)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct ifnet *ifp = adapter->ifp;;
|
2006-01-20 11:38:25 +00:00
|
|
|
struct mbuf *mp;
|
2008-02-29 21:50:11 +00:00
|
|
|
u8 status, accept_frame = 0, eop = 0;
|
|
|
|
u16 len, desc_len, prev_len_adj;
|
2006-01-20 11:38:25 +00:00
|
|
|
int i;
|
2007-05-04 00:00:12 +00:00
|
|
|
struct e1000_rx_desc *current_desc;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_RX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
i = adapter->next_rx_desc_to_check;
|
|
|
|
current_desc = &adapter->rx_desc_base[i];
|
|
|
|
bus_dmamap_sync(adapter->rxdma.dma_tag, adapter->rxdma.dma_map,
|
2004-10-19 23:31:44 +00:00
|
|
|
BUS_DMASYNC_POSTREAD);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
if (!((current_desc->status) & E1000_RXD_STAT_DD)) {
|
|
|
|
EM_RX_UNLOCK(adapter);
|
2006-01-11 00:30:25 +00:00
|
|
|
return (0);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2005-10-19 13:34:48 +00:00
|
|
|
while ((current_desc->status & E1000_RXD_STAT_DD) &&
|
2006-01-20 11:38:25 +00:00
|
|
|
(count != 0) &&
|
|
|
|
(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
2005-10-14 11:00:15 +00:00
|
|
|
struct mbuf *m = NULL;
|
2005-11-09 08:43:18 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
mp = adapter->rx_buffer_area[i].m_head;
|
2006-08-14 01:50:54 +00:00
|
|
|
/*
|
|
|
|
* Can't defer bus_dmamap_sync(9) because TBI_ACCEPT
|
|
|
|
* needs to access the last received byte in the mbuf.
|
|
|
|
*/
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_sync(adapter->rxtag, adapter->rx_buffer_area[i].map,
|
2005-11-21 04:17:43 +00:00
|
|
|
BUS_DMASYNC_POSTREAD);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
accept_frame = 1;
|
2003-11-14 18:02:25 +00:00
|
|
|
prev_len_adj = 0;
|
2006-01-20 11:38:25 +00:00
|
|
|
desc_len = le16toh(current_desc->length);
|
2006-08-16 23:55:34 +00:00
|
|
|
status = current_desc->status;
|
|
|
|
if (status & E1000_RXD_STAT_EOP) {
|
2002-11-25 19:56:16 +00:00
|
|
|
count--;
|
2002-06-03 22:30:51 +00:00
|
|
|
eop = 1;
|
2003-11-14 18:02:25 +00:00
|
|
|
if (desc_len < ETHER_CRC_LEN) {
|
2006-01-20 11:38:25 +00:00
|
|
|
len = 0;
|
|
|
|
prev_len_adj = ETHER_CRC_LEN - desc_len;
|
|
|
|
} else
|
|
|
|
len = desc_len - ETHER_CRC_LEN;
|
2002-06-03 22:30:51 +00:00
|
|
|
} else {
|
|
|
|
eop = 0;
|
2003-05-02 21:17:08 +00:00
|
|
|
len = desc_len;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK) {
|
2008-02-29 21:50:11 +00:00
|
|
|
u8 last_byte;
|
|
|
|
u32 pkt_len = desc_len;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->fmp != NULL)
|
|
|
|
pkt_len += adapter->fmp->m_pkthdr.len;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
last_byte = *(mtod(mp, caddr_t) + desc_len - 1);
|
2006-08-16 23:55:34 +00:00
|
|
|
if (TBI_ACCEPT(&adapter->hw, status,
|
2007-11-20 21:41:22 +00:00
|
|
|
current_desc->errors, pkt_len, last_byte,
|
|
|
|
adapter->min_frame_size, adapter->max_frame_size)) {
|
2007-05-04 00:00:12 +00:00
|
|
|
e1000_tbi_adjust_stats_82543(&adapter->hw,
|
2006-08-03 19:05:04 +00:00
|
|
|
&adapter->stats, pkt_len,
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.mac.addr,
|
|
|
|
adapter->max_frame_size);
|
2006-01-20 11:38:25 +00:00
|
|
|
if (len > 0)
|
|
|
|
len--;
|
|
|
|
} else
|
2002-06-03 22:30:51 +00:00
|
|
|
accept_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (accept_frame) {
|
2006-10-28 08:11:07 +00:00
|
|
|
if (em_get_buf(adapter, i) != 0) {
|
|
|
|
ifp->if_iqdrops++;
|
|
|
|
goto discard;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Assign correct length to the current fragment */
|
|
|
|
mp->m_len = len;
|
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
if (adapter->fmp == NULL) {
|
2002-06-03 22:30:51 +00:00
|
|
|
mp->m_pkthdr.len = len;
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->fmp = mp; /* Store the first mbuf */
|
|
|
|
adapter->lmp = mp;
|
2002-06-03 22:30:51 +00:00
|
|
|
} else {
|
|
|
|
/* Chain mbuf's together */
|
|
|
|
mp->m_flags &= ~M_PKTHDR;
|
2006-01-20 11:38:25 +00:00
|
|
|
/*
|
|
|
|
* Adjust length of previous mbuf in chain if
|
|
|
|
* we received less than 4 bytes in the last
|
|
|
|
* descriptor.
|
|
|
|
*/
|
2003-11-14 18:02:25 +00:00
|
|
|
if (prev_len_adj > 0) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->lmp->m_len -= prev_len_adj;
|
|
|
|
adapter->fmp->m_pkthdr.len -=
|
2006-01-20 11:38:25 +00:00
|
|
|
prev_len_adj;
|
2003-11-14 18:02:25 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->lmp->m_next = mp;
|
|
|
|
adapter->lmp = adapter->lmp->m_next;
|
|
|
|
adapter->fmp->m_pkthdr.len += len;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2006-01-20 11:38:25 +00:00
|
|
|
if (eop) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->fmp->m_pkthdr.rcvif = ifp;
|
2005-10-14 10:34:46 +00:00
|
|
|
ifp->if_ipackets++;
|
2006-08-03 19:05:04 +00:00
|
|
|
em_receive_checksum(adapter, current_desc,
|
|
|
|
adapter->fmp);
|
2005-12-16 08:29:43 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->max_frame_size >
|
2006-08-14 00:36:53 +00:00
|
|
|
(MCLBYTES - ETHER_ALIGN) &&
|
2006-08-03 19:05:04 +00:00
|
|
|
em_fixup_rx(adapter) != 0)
|
2005-12-16 08:29:43 +00:00
|
|
|
goto skip;
|
|
|
|
#endif
|
2006-10-28 08:11:07 +00:00
|
|
|
if (status & E1000_RXD_STAT_VP) {
|
2007-11-20 21:41:22 +00:00
|
|
|
#if __FreeBSD_version < 700000
|
|
|
|
VLAN_INPUT_TAG_NEW(ifp, adapter->fmp,
|
|
|
|
(le16toh(current_desc->special) &
|
|
|
|
E1000_RXD_SPC_VLAN_MASK));
|
|
|
|
#else
|
2006-10-28 08:11:07 +00:00
|
|
|
adapter->fmp->m_pkthdr.ether_vtag =
|
2005-11-09 08:43:18 +00:00
|
|
|
(le16toh(current_desc->special) &
|
2006-10-28 08:11:07 +00:00
|
|
|
E1000_RXD_SPC_VLAN_MASK);
|
|
|
|
adapter->fmp->m_flags |= M_VLANTAG;
|
2007-11-20 21:41:22 +00:00
|
|
|
#endif
|
2006-10-28 08:11:07 +00:00
|
|
|
}
|
2005-12-16 08:29:43 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
|
|
|
skip:
|
|
|
|
#endif
|
2006-08-03 19:05:04 +00:00
|
|
|
m = adapter->fmp;
|
|
|
|
adapter->fmp = NULL;
|
|
|
|
adapter->lmp = NULL;
|
2006-01-20 11:38:25 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
} else {
|
2006-10-28 08:11:07 +00:00
|
|
|
ifp->if_ierrors++;
|
|
|
|
discard:
|
|
|
|
/* Reuse loaded DMA map and just update mbuf chain */
|
|
|
|
mp = adapter->rx_buffer_area[i].m_head;
|
|
|
|
mp->m_len = mp->m_pkthdr.len = MCLBYTES;
|
|
|
|
mp->m_data = mp->m_ext.ext_buf;
|
|
|
|
mp->m_next = NULL;
|
2007-11-20 21:41:22 +00:00
|
|
|
if (adapter->max_frame_size <=
|
2007-05-04 00:00:12 +00:00
|
|
|
(MCLBYTES - ETHER_ALIGN))
|
2006-10-28 08:11:07 +00:00
|
|
|
m_adj(mp, ETHER_ALIGN);
|
|
|
|
if (adapter->fmp != NULL) {
|
2006-08-03 19:05:04 +00:00
|
|
|
m_freem(adapter->fmp);
|
2006-10-28 08:11:07 +00:00
|
|
|
adapter->fmp = NULL;
|
|
|
|
adapter->lmp = NULL;
|
|
|
|
}
|
|
|
|
m = NULL;
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2006-08-16 23:55:34 +00:00
|
|
|
/* Zero out the receive descriptors status. */
|
|
|
|
current_desc->status = 0;
|
2006-08-03 19:05:04 +00:00
|
|
|
bus_dmamap_sync(adapter->rxdma.dma_tag, adapter->rxdma.dma_map,
|
2005-10-18 00:42:10 +00:00
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2006-01-20 11:38:25 +00:00
|
|
|
|
|
|
|
/* Advance our pointers to the next descriptor. */
|
2006-08-03 19:05:04 +00:00
|
|
|
if (++i == adapter->num_rx_desc)
|
2005-10-14 11:00:15 +00:00
|
|
|
i = 0;
|
|
|
|
if (m != NULL) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->next_rx_desc_to_check = i;
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
/* Unlock for call into stack */
|
|
|
|
EM_RX_UNLOCK(adapter);
|
2005-10-14 11:00:15 +00:00
|
|
|
(*ifp->if_input)(ifp, m);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_RX_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
i = adapter->next_rx_desc_to_check;
|
2005-10-14 11:00:15 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
current_desc = &adapter->rx_desc_base[i];
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->next_rx_desc_to_check = i;
|
2006-01-11 00:30:25 +00:00
|
|
|
|
|
|
|
/* Advance the E1000's Receive Queue #0 "Tail Pointer". */
|
2006-01-20 11:38:25 +00:00
|
|
|
if (--i < 0)
|
2006-08-03 19:05:04 +00:00
|
|
|
i = adapter->num_rx_desc - 1;
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), i);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
EM_RX_UNLOCK(adapter);
|
2006-01-20 11:38:25 +00:00
|
|
|
if (!((current_desc->status) & E1000_RXD_STAT_DD))
|
2006-01-11 00:30:25 +00:00
|
|
|
return (0);
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2006-01-11 00:30:25 +00:00
|
|
|
return (1);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2005-12-16 08:29:43 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
|
|
|
/*
|
|
|
|
* When jumbo frames are enabled we should realign entire payload on
|
|
|
|
* architecures with strict alignment. This is serious design mistake of 8254x
|
|
|
|
* as it nullifies DMA operations. 8254x just allows RX buffer size to be
|
|
|
|
* 2048/4096/8192/16384. What we really want is 2048 - ETHER_ALIGN to align its
|
|
|
|
* payload. On architecures without strict alignment restrictions 8254x still
|
2006-01-20 11:38:25 +00:00
|
|
|
* performs unaligned memory access which would reduce the performance too.
|
2005-12-16 08:29:43 +00:00
|
|
|
* To avoid copying over an entire frame to align, we allocate a new mbuf and
|
|
|
|
* copy ethernet header to the new mbuf. The new mbuf is prepended into the
|
|
|
|
* existing mbuf chain.
|
|
|
|
*
|
|
|
|
* Be aware, best performance of the 8254x is achived only when jumbo frame is
|
|
|
|
* not used at all on architectures with strict alignment.
|
|
|
|
*/
|
|
|
|
static int
|
2006-08-03 19:05:04 +00:00
|
|
|
em_fixup_rx(struct adapter *adapter)
|
2005-12-16 08:29:43 +00:00
|
|
|
{
|
|
|
|
struct mbuf *m, *n;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = 0;
|
2006-08-03 19:05:04 +00:00
|
|
|
m = adapter->fmp;
|
2005-12-16 08:29:43 +00:00
|
|
|
if (m->m_len <= (MCLBYTES - ETHER_HDR_LEN)) {
|
|
|
|
bcopy(m->m_data, m->m_data + ETHER_HDR_LEN, m->m_len);
|
|
|
|
m->m_data += ETHER_HDR_LEN;
|
|
|
|
} else {
|
|
|
|
MGETHDR(n, M_DONTWAIT, MT_DATA);
|
|
|
|
if (n != NULL) {
|
|
|
|
bcopy(m->m_data, n->m_data, ETHER_HDR_LEN);
|
|
|
|
m->m_data += ETHER_HDR_LEN;
|
|
|
|
m->m_len -= ETHER_HDR_LEN;
|
|
|
|
n->m_len = ETHER_HDR_LEN;
|
|
|
|
M_MOVE_PKTHDR(n, m);
|
|
|
|
n->m_next = m;
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->fmp = n;
|
2005-12-16 08:29:43 +00:00
|
|
|
} else {
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->dropped_pkts++;
|
2006-08-03 19:05:04 +00:00
|
|
|
m_freem(adapter->fmp);
|
|
|
|
adapter->fmp = NULL;
|
2007-05-04 00:00:12 +00:00
|
|
|
error = ENOMEM;
|
2005-12-16 08:29:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2006-01-20 11:38:25 +00:00
|
|
|
* Verify that the hardware indicated that the checksum is valid.
|
2001-12-02 07:37:17 +00:00
|
|
|
* Inform the stack about the status of checksum so that stack
|
|
|
|
* doesn't spend time verifying the checksum.
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
static void
|
2007-05-04 00:00:12 +00:00
|
|
|
em_receive_checksum(struct adapter *adapter,
|
|
|
|
struct e1000_rx_desc *rx_desc, struct mbuf *mp)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2002-06-03 22:30:51 +00:00
|
|
|
/* 82543 or newer only */
|
2007-05-04 00:00:12 +00:00
|
|
|
if ((adapter->hw.mac.type < e1000_82543) ||
|
2002-06-03 22:30:51 +00:00
|
|
|
/* 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) {
|
2006-01-20 11:38:25 +00:00
|
|
|
/* Did it pass? */
|
2002-06-03 22:30:51 +00:00
|
|
|
if (!(rx_desc->errors & E1000_RXD_ERR_TCPE)) {
|
2006-01-20 11:38:25 +00:00
|
|
|
mp->m_pkthdr.csum_flags |=
|
2002-06-03 22:30:51 +00:00
|
|
|
(CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
|
|
|
|
mp->m_pkthdr.csum_data = htons(0xffff);
|
|
|
|
}
|
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
2008-11-26 23:57:23 +00:00
|
|
|
* This routine is run via an vlan
|
|
|
|
* config EVENT
|
2007-11-20 21:41:22 +00:00
|
|
|
*/
|
2006-01-20 11:38:25 +00:00
|
|
|
static void
|
2008-11-26 23:57:23 +00:00
|
|
|
em_register_vlan(void *unused, struct ifnet *ifp, u16 vtag)
|
2002-06-03 22:30:51 +00:00
|
|
|
{
|
2008-11-26 23:57:23 +00:00
|
|
|
struct adapter *adapter = ifp->if_softc;
|
|
|
|
u32 ctrl, rctl, index, vfta;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL);
|
2006-01-20 11:38:25 +00:00
|
|
|
ctrl |= E1000_CTRL_VME;
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl);
|
2008-11-26 23:57:23 +00:00
|
|
|
|
|
|
|
/* Setup for Hardware Filter */
|
|
|
|
rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
|
|
|
rctl |= E1000_RCTL_VFE;
|
|
|
|
rctl &= ~E1000_RCTL_CFIEN;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl);
|
|
|
|
|
|
|
|
/* Make entry in the hardware filter table */
|
|
|
|
index = ((vtag >> 5) & 0x7F);
|
|
|
|
vfta = E1000_READ_REG_ARRAY(&adapter->hw, E1000_VFTA, index);
|
|
|
|
vfta |= (1 << (vtag & 0x1F));
|
|
|
|
E1000_WRITE_REG_ARRAY(&adapter->hw, E1000_VFTA, index, vfta);
|
|
|
|
|
|
|
|
/* Update the frame size */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RLPML,
|
|
|
|
adapter->max_frame_size + VLAN_TAG_SIZE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This routine is run via an vlan
|
|
|
|
* unconfig EVENT
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_unregister_vlan(void *unused, struct ifnet *ifp, u16 vtag)
|
|
|
|
{
|
|
|
|
struct adapter *adapter = ifp->if_softc;
|
|
|
|
u32 index, vfta;
|
|
|
|
|
|
|
|
/* Remove entry in the hardware filter table */
|
|
|
|
index = ((vtag >> 5) & 0x7F);
|
|
|
|
vfta = E1000_READ_REG_ARRAY(&adapter->hw, E1000_VFTA, index);
|
|
|
|
vfta &= ~(1 << (vtag & 0x1F));
|
|
|
|
E1000_WRITE_REG_ARRAY(&adapter->hw, E1000_VFTA, index, vfta);
|
|
|
|
/* Have all vlans unregistered? */
|
|
|
|
if (adapter->ifp->if_vlantrunk == NULL) {
|
|
|
|
u32 rctl;
|
|
|
|
/* Turn off the filter table */
|
|
|
|
rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
|
|
|
|
rctl &= ~E1000_RCTL_VFE;
|
|
|
|
rctl |= E1000_RCTL_CFIEN;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl);
|
|
|
|
/* Reset the frame size */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RLPML,
|
|
|
|
adapter->max_frame_size);
|
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
}
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_enable_intr(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 ims_mask = IMS_ENABLE_MASK;
|
|
|
|
|
|
|
|
if (adapter->msix) {
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
E1000_WRITE_REG(hw, EM_EIAC, EM_MSIX_MASK);
|
|
|
|
ims_mask |= EM_MSIX_MASK;
|
2008-02-29 21:50:11 +00:00
|
|
|
}
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
E1000_WRITE_REG(hw, E1000_IMS, ims_mask);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_disable_intr(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
|
|
|
|
|
|
|
if (adapter->msix)
|
|
|
|
E1000_WRITE_REG(hw, EM_EIAC, 0);
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
|
|
|
|
}
|
2005-01-01 19:57:23 +00:00
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*
|
|
|
|
* Bit of a misnomer, what this really means is
|
|
|
|
* to enable OS management of the system... aka
|
|
|
|
* to disable special hardware management features
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_init_manageability(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
/* A shared code workaround */
|
|
|
|
#define E1000_82542_MANC2H E1000_MANC2H
|
|
|
|
if (adapter->has_manage) {
|
|
|
|
int manc2h = E1000_READ_REG(&adapter->hw, E1000_MANC2H);
|
|
|
|
int manc = E1000_READ_REG(&adapter->hw, E1000_MANC);
|
|
|
|
|
|
|
|
/* disable hardware interception of ARP */
|
|
|
|
manc &= ~(E1000_MANC_ARP_EN);
|
|
|
|
|
|
|
|
/* enable receiving management packets to the host */
|
|
|
|
if (adapter->hw.mac.type >= e1000_82571) {
|
|
|
|
manc |= E1000_MANC_EN_MNG2HOST;
|
|
|
|
#define E1000_MNG2HOST_PORT_623 (1 << 5)
|
|
|
|
#define E1000_MNG2HOST_PORT_664 (1 << 6)
|
|
|
|
manc2h |= E1000_MNG2HOST_PORT_623;
|
|
|
|
manc2h |= E1000_MNG2HOST_PORT_664;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_MANC2H, manc2h);
|
|
|
|
}
|
|
|
|
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_MANC, manc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Give control back to hardware management
|
|
|
|
* controller if there is one.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_release_manageability(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
if (adapter->has_manage) {
|
|
|
|
int manc = E1000_READ_REG(&adapter->hw, E1000_MANC);
|
|
|
|
|
|
|
|
/* re-enable hardware interception of ARP */
|
|
|
|
manc |= E1000_MANC_ARP_EN;
|
|
|
|
|
|
|
|
if (adapter->hw.mac.type >= e1000_82571)
|
|
|
|
manc &= ~E1000_MANC_EN_MNG2HOST;
|
|
|
|
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_MANC, manc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* em_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
|
|
|
|
* For ASF and Pass Through versions of f/w this means that
|
|
|
|
* the driver is loaded. For AMT version (only with 82573)
|
|
|
|
* of the f/w this means that the network i/f is open.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_get_hw_control(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
u32 ctrl_ext, swsm;
|
|
|
|
|
|
|
|
/* Let firmware know the driver has taken over */
|
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
case e1000_82573:
|
|
|
|
swsm = E1000_READ_REG(&adapter->hw, E1000_SWSM);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_SWSM,
|
|
|
|
swsm | E1000_SWSM_DRV_LOAD);
|
|
|
|
break;
|
|
|
|
case e1000_82571:
|
|
|
|
case e1000_82572:
|
|
|
|
case e1000_80003es2lan:
|
|
|
|
case e1000_ich8lan:
|
|
|
|
case e1000_ich9lan:
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
case e1000_ich10lan:
|
2007-05-04 00:00:12 +00:00
|
|
|
ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT,
|
|
|
|
ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* em_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
|
|
|
|
* For ASF and Pass Through versions of f/w this means that the
|
|
|
|
* driver is no longer loaded. For AMT version (only with 82573) i
|
|
|
|
* of the f/w this means that the network i/f is closed.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_release_hw_control(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
u32 ctrl_ext, swsm;
|
|
|
|
|
|
|
|
/* Let firmware taken over control of h/w */
|
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
case e1000_82573:
|
|
|
|
swsm = E1000_READ_REG(&adapter->hw, E1000_SWSM);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_SWSM,
|
|
|
|
swsm & ~E1000_SWSM_DRV_LOAD);
|
|
|
|
break;
|
|
|
|
case e1000_82571:
|
|
|
|
case e1000_82572:
|
|
|
|
case e1000_80003es2lan:
|
|
|
|
case e1000_ich8lan:
|
|
|
|
case e1000_ich9lan:
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
case e1000_ich10lan:
|
2007-05-04 00:00:12 +00:00
|
|
|
ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT);
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT,
|
|
|
|
ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2003-06-05 17:51:38 +00:00
|
|
|
static int
|
2008-02-29 21:50:11 +00:00
|
|
|
em_is_valid_ether_addr(u8 *addr)
|
2003-06-05 17:51:38 +00:00
|
|
|
{
|
2006-02-15 08:39:50 +00:00
|
|
|
char zero_addr[6] = { 0, 0, 0, 0, 0, 0 };
|
2006-01-20 11:38:25 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
if ((addr[0] & 1) || (!bcmp(addr, zero_addr, ETHER_ADDR_LEN))) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (TRUE);
|
2003-06-05 17:51:38 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/*
|
|
|
|
* Enable PCI Wake On Lan capability
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
em_enable_wakeup(device_t dev)
|
|
|
|
{
|
|
|
|
u16 cap, status;
|
|
|
|
u8 id;
|
|
|
|
|
|
|
|
/* First find the capabilities pointer*/
|
|
|
|
cap = pci_read_config(dev, PCIR_CAP_PTR, 2);
|
|
|
|
/* Read the PM Capabilities */
|
|
|
|
id = pci_read_config(dev, cap, 1);
|
|
|
|
if (id != PCIY_PMG) /* Something wrong */
|
|
|
|
return;
|
|
|
|
/* OK, we have the power capabilities, so
|
|
|
|
now get the status register */
|
|
|
|
cap += PCIR_POWER_STATUS;
|
|
|
|
status = pci_read_config(dev, cap, 2);
|
|
|
|
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
|
|
|
pci_write_config(dev, cap, status, 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-27 21:52:37 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* 82544 Coexistence issue workaround.
|
|
|
|
* There are 2 issues.
|
|
|
|
* 1. Transmit Hang issue.
|
|
|
|
* To detect this issue, following equation can be used...
|
2006-02-15 08:39:50 +00:00
|
|
|
* SIZE[3:0] + ADDR[2:0] = SUM[3:0].
|
|
|
|
* If SUM[3:0] is in between 1 to 4, we will have this issue.
|
2003-08-27 21:52:37 +00:00
|
|
|
*
|
|
|
|
* 2. DAC issue.
|
|
|
|
* To detect this issue, following equation can be used...
|
2006-02-15 08:39:50 +00:00
|
|
|
* SIZE[3:0] + ADDR[2:0] = SUM[3:0].
|
|
|
|
* If SUM[3:0] is in between 9 to c, we will have this issue.
|
2003-08-27 21:52:37 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* WORKAROUND:
|
2007-05-04 00:00:12 +00:00
|
|
|
* Make sure we do not have ending address
|
|
|
|
* as 1,2,3,4(Hang) or 9,a,b,c (DAC)
|
2003-08-27 21:52:37 +00:00
|
|
|
*
|
2007-05-04 00:00:12 +00:00
|
|
|
*************************************************************************/
|
2008-02-29 21:50:11 +00:00
|
|
|
static u32
|
|
|
|
em_fill_descriptors (bus_addr_t address, u32 length,
|
2006-02-15 08:39:50 +00:00
|
|
|
PDESC_ARRAY desc_array)
|
|
|
|
{
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 safe_terminator;
|
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
/* Since issue is sensitive to length and address.*/
|
|
|
|
/* Let us first check the address...*/
|
|
|
|
if (length <= 4) {
|
|
|
|
desc_array->descriptor[0].address = address;
|
|
|
|
desc_array->descriptor[0].length = length;
|
|
|
|
desc_array->elements = 1;
|
|
|
|
return (desc_array->elements);
|
|
|
|
}
|
2008-02-29 21:50:11 +00:00
|
|
|
safe_terminator = (u32)((((u32)address & 0x7) +
|
2007-05-04 00:00:12 +00:00
|
|
|
(length & 0xF)) & 0xF);
|
2006-02-15 08:39:50 +00:00
|
|
|
/* if it does not fall between 0x1 to 0x4 and 0x9 to 0xC then return */
|
|
|
|
if (safe_terminator == 0 ||
|
|
|
|
(safe_terminator > 4 &&
|
|
|
|
safe_terminator < 9) ||
|
|
|
|
(safe_terminator > 0xC &&
|
|
|
|
safe_terminator <= 0xF)) {
|
|
|
|
desc_array->descriptor[0].address = address;
|
|
|
|
desc_array->descriptor[0].length = length;
|
|
|
|
desc_array->elements = 1;
|
|
|
|
return (desc_array->elements);
|
|
|
|
}
|
|
|
|
|
|
|
|
desc_array->descriptor[0].address = address;
|
|
|
|
desc_array->descriptor[0].length = length - 4;
|
|
|
|
desc_array->descriptor[1].address = address + (length - 4);
|
|
|
|
desc_array->descriptor[1].length = 4;
|
|
|
|
desc_array->elements = 2;
|
|
|
|
return (desc_array->elements);
|
2003-08-27 21:52:37 +00:00
|
|
|
}
|
|
|
|
|
2001-12-02 07:37:17 +00:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
2006-01-20 11:38:25 +00:00
|
|
|
* Update the board statistics counters.
|
2001-12-02 07:37:17 +00:00
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_update_stats_counters(struct adapter *adapter)
|
2001-12-02 07:37:17 +00:00
|
|
|
{
|
2002-06-03 22:30:51 +00:00
|
|
|
struct ifnet *ifp;
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
if(adapter->hw.phy.media_type == e1000_media_type_copper ||
|
2007-05-04 00:00:12 +00:00
|
|
|
(E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) {
|
|
|
|
adapter->stats.symerrs += E1000_READ_REG(&adapter->hw, E1000_SYMERRS);
|
|
|
|
adapter->stats.sec += E1000_READ_REG(&adapter->hw, E1000_SEC);
|
2006-08-03 19:05:04 +00:00
|
|
|
}
|
2007-05-04 00:00:12 +00:00
|
|
|
adapter->stats.crcerrs += E1000_READ_REG(&adapter->hw, E1000_CRCERRS);
|
|
|
|
adapter->stats.mpc += E1000_READ_REG(&adapter->hw, E1000_MPC);
|
|
|
|
adapter->stats.scc += E1000_READ_REG(&adapter->hw, E1000_SCC);
|
|
|
|
adapter->stats.ecol += E1000_READ_REG(&adapter->hw, E1000_ECOL);
|
|
|
|
|
|
|
|
adapter->stats.mcc += E1000_READ_REG(&adapter->hw, E1000_MCC);
|
|
|
|
adapter->stats.latecol += E1000_READ_REG(&adapter->hw, E1000_LATECOL);
|
|
|
|
adapter->stats.colc += E1000_READ_REG(&adapter->hw, E1000_COLC);
|
|
|
|
adapter->stats.dc += E1000_READ_REG(&adapter->hw, E1000_DC);
|
|
|
|
adapter->stats.rlec += E1000_READ_REG(&adapter->hw, E1000_RLEC);
|
|
|
|
adapter->stats.xonrxc += E1000_READ_REG(&adapter->hw, E1000_XONRXC);
|
|
|
|
adapter->stats.xontxc += E1000_READ_REG(&adapter->hw, E1000_XONTXC);
|
|
|
|
adapter->stats.xoffrxc += E1000_READ_REG(&adapter->hw, E1000_XOFFRXC);
|
|
|
|
adapter->stats.xofftxc += E1000_READ_REG(&adapter->hw, E1000_XOFFTXC);
|
|
|
|
adapter->stats.fcruc += E1000_READ_REG(&adapter->hw, E1000_FCRUC);
|
|
|
|
adapter->stats.prc64 += E1000_READ_REG(&adapter->hw, E1000_PRC64);
|
|
|
|
adapter->stats.prc127 += E1000_READ_REG(&adapter->hw, E1000_PRC127);
|
|
|
|
adapter->stats.prc255 += E1000_READ_REG(&adapter->hw, E1000_PRC255);
|
|
|
|
adapter->stats.prc511 += E1000_READ_REG(&adapter->hw, E1000_PRC511);
|
|
|
|
adapter->stats.prc1023 += E1000_READ_REG(&adapter->hw, E1000_PRC1023);
|
|
|
|
adapter->stats.prc1522 += E1000_READ_REG(&adapter->hw, E1000_PRC1522);
|
|
|
|
adapter->stats.gprc += E1000_READ_REG(&adapter->hw, E1000_GPRC);
|
|
|
|
adapter->stats.bprc += E1000_READ_REG(&adapter->hw, E1000_BPRC);
|
|
|
|
adapter->stats.mprc += E1000_READ_REG(&adapter->hw, E1000_MPRC);
|
|
|
|
adapter->stats.gptc += E1000_READ_REG(&adapter->hw, E1000_GPTC);
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* For the 64-bit byte counters the low dword must be read first. */
|
|
|
|
/* Both registers clear on the read of the high dword */
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->stats.gorc += E1000_READ_REG(&adapter->hw, E1000_GORCH);
|
|
|
|
adapter->stats.gotc += E1000_READ_REG(&adapter->hw, E1000_GOTCH);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
adapter->stats.rnbc += E1000_READ_REG(&adapter->hw, E1000_RNBC);
|
|
|
|
adapter->stats.ruc += E1000_READ_REG(&adapter->hw, E1000_RUC);
|
|
|
|
adapter->stats.rfc += E1000_READ_REG(&adapter->hw, E1000_RFC);
|
|
|
|
adapter->stats.roc += E1000_READ_REG(&adapter->hw, E1000_ROC);
|
|
|
|
adapter->stats.rjc += E1000_READ_REG(&adapter->hw, E1000_RJC);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->stats.tor += E1000_READ_REG(&adapter->hw, E1000_TORH);
|
|
|
|
adapter->stats.tot += E1000_READ_REG(&adapter->hw, E1000_TOTH);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
adapter->stats.tpr += E1000_READ_REG(&adapter->hw, E1000_TPR);
|
|
|
|
adapter->stats.tpt += E1000_READ_REG(&adapter->hw, E1000_TPT);
|
|
|
|
adapter->stats.ptc64 += E1000_READ_REG(&adapter->hw, E1000_PTC64);
|
|
|
|
adapter->stats.ptc127 += E1000_READ_REG(&adapter->hw, E1000_PTC127);
|
|
|
|
adapter->stats.ptc255 += E1000_READ_REG(&adapter->hw, E1000_PTC255);
|
|
|
|
adapter->stats.ptc511 += E1000_READ_REG(&adapter->hw, E1000_PTC511);
|
|
|
|
adapter->stats.ptc1023 += E1000_READ_REG(&adapter->hw, E1000_PTC1023);
|
|
|
|
adapter->stats.ptc1522 += E1000_READ_REG(&adapter->hw, E1000_PTC1522);
|
|
|
|
adapter->stats.mptc += E1000_READ_REG(&adapter->hw, E1000_MPTC);
|
|
|
|
adapter->stats.bptc += E1000_READ_REG(&adapter->hw, E1000_BPTC);
|
|
|
|
|
|
|
|
if (adapter->hw.mac.type >= e1000_82543) {
|
|
|
|
adapter->stats.algnerrc +=
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_ALGNERRC);
|
|
|
|
adapter->stats.rxerrc +=
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RXERRC);
|
|
|
|
adapter->stats.tncrs +=
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TNCRS);
|
|
|
|
adapter->stats.cexterr +=
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_CEXTERR);
|
|
|
|
adapter->stats.tsctc +=
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TSCTC);
|
|
|
|
adapter->stats.tsctfc +=
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TSCTFC);
|
2006-08-03 19:05:04 +00:00
|
|
|
}
|
|
|
|
ifp = adapter->ifp;
|
|
|
|
|
|
|
|
ifp->if_collisions = adapter->stats.colc;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Rx Errors */
|
2007-05-04 00:00:12 +00:00
|
|
|
ifp->if_ierrors = adapter->dropped_pkts + adapter->stats.rxerrc +
|
|
|
|
adapter->stats.crcerrs + adapter->stats.algnerrc +
|
|
|
|
adapter->stats.ruc + adapter->stats.roc +
|
2006-08-14 01:50:54 +00:00
|
|
|
adapter->stats.mpc + adapter->stats.cexterr;
|
2002-06-03 22:30:51 +00:00
|
|
|
|
|
|
|
/* Tx Errors */
|
2007-05-04 00:00:12 +00:00
|
|
|
ifp->if_oerrors = adapter->stats.ecol +
|
|
|
|
adapter->stats.latecol + adapter->watchdog_events;
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* This routine is called only when em_display_debug_stats is enabled.
|
|
|
|
* This routine provides a way to take a look at important statistics
|
|
|
|
* maintained by the driver and hardware.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_print_debug_info(struct adapter *adapter)
|
2006-02-15 08:39:50 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2008-02-29 21:50:11 +00:00
|
|
|
u8 *hw_addr = adapter->hw.hw_addr;
|
2006-02-15 08:39:50 +00:00
|
|
|
|
|
|
|
device_printf(dev, "Adapter hardware address = %p \n", hw_addr);
|
|
|
|
device_printf(dev, "CTRL = 0x%x RCTL = 0x%x \n",
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_READ_REG(&adapter->hw, E1000_CTRL),
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RCTL));
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Packet buffer = Tx=%dk Rx=%dk \n",
|
2007-05-04 00:00:12 +00:00
|
|
|
((E1000_READ_REG(&adapter->hw, E1000_PBA) & 0xffff0000) >> 16),\
|
|
|
|
(E1000_READ_REG(&adapter->hw, E1000_PBA) & 0xffff) );
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Flow control watermarks high = %d low = %d\n",
|
2007-11-20 21:41:22 +00:00
|
|
|
adapter->hw.fc.high_water,
|
|
|
|
adapter->hw.fc.low_water);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "tx_int_delay = %d, tx_abs_int_delay = %d\n",
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TIDV),
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TADV));
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "rx_int_delay = %d, rx_abs_int_delay = %d\n",
|
2007-05-04 00:00:12 +00:00
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RDTR),
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RADV));
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "fifo workaround = %lld, fifo_reset_count = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->tx_fifo_wrk_cnt,
|
|
|
|
(long long)adapter->tx_fifo_reset_cnt);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "hw tdh = %d, hw tdt = %d\n",
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDH(0)),
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TDT(0)));
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "hw rdh = %d, hw rdt = %d\n",
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RDH(0)),
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RDT(0)));
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Num Tx descriptors avail = %d\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->num_tx_desc_avail);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Tx Descriptors not avail1 = %ld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->no_tx_desc_avail1);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Tx Descriptors not avail2 = %ld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->no_tx_desc_avail2);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Std mbuf failed = %ld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->mbuf_alloc_failed);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Std mbuf cluster failed = %ld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->mbuf_cluster_failed);
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "Driver dropped packets = %ld\n",
|
|
|
|
adapter->dropped_pkts);
|
|
|
|
device_printf(dev, "Driver tx dma failure in encap = %ld\n",
|
|
|
|
adapter->no_tx_dma_setup);
|
2003-06-05 17:51:38 +00:00
|
|
|
}
|
2002-06-03 22:30:51 +00:00
|
|
|
|
2003-06-05 17:51:38 +00:00
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_print_hw_stats(struct adapter *adapter)
|
2006-02-15 08:39:50 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
device_t dev = adapter->dev;
|
2006-02-15 08:39:50 +00:00
|
|
|
|
|
|
|
device_printf(dev, "Excessive collisions = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.ecol);
|
2007-05-04 00:00:12 +00:00
|
|
|
#if (DEBUG_HW > 0) /* Dont output these errors normally */
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Symbol errors = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.symerrs);
|
2007-05-04 00:00:12 +00:00
|
|
|
#endif
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Sequence errors = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.sec);
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "Defer count = %lld\n",
|
|
|
|
(long long)adapter->stats.dc);
|
|
|
|
device_printf(dev, "Missed Packets = %lld\n",
|
|
|
|
(long long)adapter->stats.mpc);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Receive No Buffers = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.rnbc);
|
2006-08-03 09:20:11 +00:00
|
|
|
/* RLEC is inaccurate on some hardware, calculate our own. */
|
|
|
|
device_printf(dev, "Receive Length Errors = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
((long long)adapter->stats.roc + (long long)adapter->stats.ruc));
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Receive errors = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.rxerrc);
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "Crc errors = %lld\n",
|
|
|
|
(long long)adapter->stats.crcerrs);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Alignment errors = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.algnerrc);
|
2007-11-20 21:41:22 +00:00
|
|
|
device_printf(dev, "Collision/Carrier extension errors = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.cexterr);
|
|
|
|
device_printf(dev, "RX overruns = %ld\n", adapter->rx_overruns);
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "watchdog timeouts = %ld\n",
|
|
|
|
adapter->watchdog_events);
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
device_printf(dev, "RX MSIX IRQ = %ld TX MSIX IRQ = %ld"
|
|
|
|
" LINK MSIX IRQ = %ld\n", adapter->rx_irq,
|
|
|
|
adapter->tx_irq , adapter->link_irq);
|
2007-05-04 00:00:12 +00:00
|
|
|
device_printf(dev, "XON Rcvd = %lld\n",
|
|
|
|
(long long)adapter->stats.xonrxc);
|
|
|
|
device_printf(dev, "XON Xmtd = %lld\n",
|
|
|
|
(long long)adapter->stats.xontxc);
|
|
|
|
device_printf(dev, "XOFF Rcvd = %lld\n",
|
|
|
|
(long long)adapter->stats.xoffrxc);
|
|
|
|
device_printf(dev, "XOFF Xmtd = %lld\n",
|
|
|
|
(long long)adapter->stats.xofftxc);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Good Packets Rcvd = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.gprc);
|
2006-02-15 08:39:50 +00:00
|
|
|
device_printf(dev, "Good Packets Xmtd = %lld\n",
|
2006-08-03 19:05:04 +00:00
|
|
|
(long long)adapter->stats.gptc);
|
2006-09-10 19:23:27 +00:00
|
|
|
device_printf(dev, "TSO Contexts Xmtd = %lld\n",
|
|
|
|
(long long)adapter->stats.tsctc);
|
|
|
|
device_printf(dev, "TSO Contexts Failed = %lld\n",
|
|
|
|
(long long)adapter->stats.tsctfc);
|
2001-12-02 07:37:17 +00:00
|
|
|
}
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* This routine provides a way to dump out the adapter eeprom,
|
|
|
|
* often a useful debug/service tool. This only dumps the first
|
|
|
|
* 32 words, stuff that matters is in that extent.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
static void
|
|
|
|
em_print_nvm_info(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
u16 eeprom_data;
|
|
|
|
int i, j, row = 0;
|
|
|
|
|
|
|
|
/* Its a bit crude, but it gets the job done */
|
|
|
|
printf("\nInterface EEPROM Dump:\n");
|
|
|
|
printf("Offset\n0x0000 ");
|
|
|
|
for (i = 0, j = 0; i < 32; i++, j++) {
|
|
|
|
if (j == 8) { /* Make the offset block */
|
|
|
|
j = 0; ++row;
|
|
|
|
printf("\n0x00%x0 ",row);
|
|
|
|
}
|
|
|
|
e1000_read_nvm(&adapter->hw, i, 1, &eeprom_data);
|
|
|
|
printf("%04x ", eeprom_data);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2003-06-05 17:51:38 +00:00
|
|
|
static int
|
|
|
|
em_sysctl_debug_info(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter;
|
2006-02-15 08:39:50 +00:00
|
|
|
int error;
|
|
|
|
int result;
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
result = -1;
|
|
|
|
error = sysctl_handle_int(oidp, &result, 0, req);
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
if (error || !req->newptr)
|
|
|
|
return (error);
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
if (result == 1) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter = (struct adapter *)arg1;
|
|
|
|
em_print_debug_info(adapter);
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* This value will cause a hex dump of the
|
|
|
|
* first 32 16-bit words of the EEPROM to
|
|
|
|
* the screen.
|
|
|
|
*/
|
|
|
|
if (result == 2) {
|
|
|
|
adapter = (struct adapter *)arg1;
|
|
|
|
em_print_nvm_info(adapter);
|
|
|
|
}
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2003-06-05 17:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
em_sysctl_stats(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter;
|
2006-02-15 08:39:50 +00:00
|
|
|
int error;
|
|
|
|
int result;
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
result = -1;
|
|
|
|
error = sysctl_handle_int(oidp, &result, 0, req);
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
if (error || !req->newptr)
|
|
|
|
return (error);
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
if (result == 1) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter = (struct adapter *)arg1;
|
|
|
|
em_print_hw_stats(adapter);
|
2006-02-15 08:39:50 +00:00
|
|
|
}
|
2003-06-05 17:51:38 +00:00
|
|
|
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2003-06-05 17:51:38 +00:00
|
|
|
}
|
2003-08-01 17:33:59 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
em_sysctl_int_delay(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
struct em_int_delay_info *info;
|
2006-08-03 19:05:04 +00:00
|
|
|
struct adapter *adapter;
|
2008-02-29 21:50:11 +00:00
|
|
|
u32 regval;
|
2003-08-01 17:33:59 +00:00
|
|
|
int error;
|
|
|
|
int usecs;
|
|
|
|
int ticks;
|
|
|
|
|
|
|
|
info = (struct em_int_delay_info *)arg1;
|
|
|
|
usecs = info->value;
|
|
|
|
error = sysctl_handle_int(oidp, &usecs, 0, req);
|
|
|
|
if (error != 0 || req->newptr == NULL)
|
2006-02-15 08:39:50 +00:00
|
|
|
return (error);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (usecs < 0 || usecs > EM_TICKS_TO_USECS(65535))
|
2006-02-15 08:39:50 +00:00
|
|
|
return (EINVAL);
|
2003-08-01 17:33:59 +00:00
|
|
|
info->value = usecs;
|
2007-05-04 00:00:12 +00:00
|
|
|
ticks = EM_USECS_TO_TICKS(usecs);
|
2005-10-20 09:55:49 +00:00
|
|
|
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter = info->adapter;
|
2003-08-01 17:33:59 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_LOCK(adapter);
|
2006-08-03 19:05:04 +00:00
|
|
|
regval = E1000_READ_OFFSET(&adapter->hw, info->offset);
|
2003-08-01 17:33:59 +00:00
|
|
|
regval = (regval & ~0xffff) | (ticks & 0xffff);
|
|
|
|
/* Handle a few special cases. */
|
|
|
|
switch (info->offset) {
|
|
|
|
case E1000_RDTR:
|
|
|
|
break;
|
|
|
|
case E1000_TIDV:
|
|
|
|
if (ticks == 0) {
|
2006-08-03 19:05:04 +00:00
|
|
|
adapter->txd_cmd &= ~E1000_TXD_CMD_IDE;
|
2003-08-01 17:33:59 +00:00
|
|
|
/* Don't write 0 into the TIDV register. */
|
|
|
|
regval++;
|
|
|
|
} else
|
2008-02-29 21:50:11 +00:00
|
|
|
adapter->txd_cmd |= E1000_TXD_CMD_IDE;
|
2003-08-01 17:33:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-08-03 19:05:04 +00:00
|
|
|
E1000_WRITE_OFFSET(&adapter->hw, info->offset, regval);
|
2007-11-20 21:41:22 +00:00
|
|
|
EM_CORE_UNLOCK(adapter);
|
2006-02-15 08:39:50 +00:00
|
|
|
return (0);
|
2003-08-01 17:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-03 19:05:04 +00:00
|
|
|
em_add_int_delay_sysctl(struct adapter *adapter, const char *name,
|
2006-02-15 08:39:50 +00:00
|
|
|
const char *description, struct em_int_delay_info *info,
|
|
|
|
int offset, int value)
|
2003-08-01 17:33:59 +00:00
|
|
|
{
|
2006-08-03 19:05:04 +00:00
|
|
|
info->adapter = adapter;
|
2003-08-01 17:33:59 +00:00
|
|
|
info->offset = offset;
|
|
|
|
info->value = value;
|
2006-08-03 19:05:04 +00:00
|
|
|
SYSCTL_ADD_PROC(device_get_sysctl_ctx(adapter->dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(adapter->dev)),
|
2003-08-01 17:33:59 +00:00
|
|
|
OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW,
|
|
|
|
info, 0, em_sysctl_int_delay, "I", description);
|
|
|
|
}
|
2006-10-28 08:11:07 +00:00
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
#ifndef EM_LEGACY_IRQ
|
2006-10-28 08:11:07 +00:00
|
|
|
static void
|
2007-05-04 00:00:12 +00:00
|
|
|
em_add_rx_process_limit(struct adapter *adapter, const char *name,
|
2006-10-28 08:11:07 +00:00
|
|
|
const char *description, int *limit, int value)
|
|
|
|
{
|
|
|
|
*limit = value;
|
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(adapter->dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(adapter->dev)),
|
|
|
|
OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW, limit, value, description);
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-02 22:00:36 +00:00
|
|
|
|
This delta has a few important items:
PR 122839 is fixed in both em and in igb
Second, the issue on building modules since the static kernel
build changes is now resolved. I was not able to get the fancier
directory hierarchy working, but this works, both em and igb
build as modules now.
Third, there is now support in em for two new NICs, Hartwell
(or 82574) is a low cost PCIE dual port adapter that has MSIX,
for this release it uses 3 vectors only, RX, TX, and LINK. In
the next release I will add a second TX and RX queue. Also, there
is support here for ICH10, the followon to ICH9. Both of these are
early releases, general availability will follow soon.
Fourth: On Hartwell and ICH10 we now have IEEE 1588 PTP support,
I have implemented this in a provisional way so that early adopters
may try and comment on the functionality. The IOCTL structure may
change. This feature is off by default, you need to edit the Makefile
and add the EM_TIMESYNC define to get the code.
Enjoy all!!
2008-04-25 21:19:41 +00:00
|
|
|
#ifdef EM_TIMESYNC
|
|
|
|
/*
|
|
|
|
* Initialize the Time Sync Feature
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
em_tsync_init(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
device_t dev = adapter->dev;
|
|
|
|
u32 tx_ctl, rx_ctl;
|
|
|
|
|
|
|
|
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TIMINCA, (1<<24) |
|
|
|
|
20833/PICOSECS_PER_TICK);
|
|
|
|
|
|
|
|
adapter->last_stamp = E1000_READ_REG(&adapter->hw, E1000_SYSTIML);
|
|
|
|
adapter->last_stamp |= (u64)E1000_READ_REG(&adapter->hw,
|
|
|
|
E1000_SYSTIMH) << 32ULL;
|
|
|
|
|
|
|
|
/* Enable the TX side */
|
|
|
|
tx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCTXCTL);
|
|
|
|
tx_ctl |= 0x10;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TSYNCTXCTL, tx_ctl);
|
|
|
|
E1000_WRITE_FLUSH(&adapter->hw);
|
|
|
|
|
|
|
|
tx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCTXCTL);
|
|
|
|
if ((tx_ctl & 0x10) == 0) {
|
|
|
|
device_printf(dev, "Failed to enable TX timestamping\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable RX */
|
|
|
|
rx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCRXCTL);
|
|
|
|
rx_ctl |= 0x10; /* Enable the feature */
|
|
|
|
rx_ctl |= 0x0a; /* This value turns on Ver 1 and 2 */
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TSYNCRXCTL, rx_ctl);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ethertype Stamping (Ethertype = 0x88F7)
|
|
|
|
*/
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RXMTRL, htonl(0x440088f7));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Source Port Queue Filter Setup:
|
|
|
|
* this is for UDP port filtering
|
|
|
|
*/
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_RXUDP, htons(TSYNC_PORT));
|
|
|
|
/* Protocol = UDP, enable Timestamp, and filter on source/protocol */
|
|
|
|
|
|
|
|
E1000_WRITE_FLUSH(&adapter->hw);
|
|
|
|
|
|
|
|
rx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCRXCTL);
|
|
|
|
if ((rx_ctl & 0x10) == 0) {
|
|
|
|
device_printf(dev, "Failed to enable RX timestamping\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
device_printf(dev, "IEEE 1588 Precision Time Protocol enabled\n");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable the Time Sync Feature
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
em_tsync_disable(struct adapter *adapter)
|
|
|
|
{
|
|
|
|
u32 tx_ctl, rx_ctl;
|
|
|
|
|
|
|
|
tx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCTXCTL);
|
|
|
|
tx_ctl &= ~0x10;
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TSYNCTXCTL, tx_ctl);
|
|
|
|
E1000_WRITE_FLUSH(&adapter->hw);
|
|
|
|
|
|
|
|
/* Invalidate TX Timestamp */
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_TXSTMPH);
|
|
|
|
|
|
|
|
tx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCTXCTL);
|
|
|
|
if (tx_ctl & 0x10)
|
|
|
|
HW_DEBUGOUT("Failed to disable TX timestamping\n");
|
|
|
|
|
|
|
|
rx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCRXCTL);
|
|
|
|
rx_ctl &= ~0x10;
|
|
|
|
|
|
|
|
E1000_WRITE_REG(&adapter->hw, E1000_TSYNCRXCTL, rx_ctl);
|
|
|
|
E1000_WRITE_FLUSH(&adapter->hw);
|
|
|
|
|
|
|
|
/* Invalidate RX Timestamp */
|
|
|
|
E1000_READ_REG(&adapter->hw, E1000_RXSATRH);
|
|
|
|
|
|
|
|
rx_ctl = E1000_READ_REG(&adapter->hw, E1000_TSYNCRXCTL);
|
|
|
|
if (rx_ctl & 0x10)
|
|
|
|
HW_DEBUGOUT("Failed to disable RX timestamping\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif /* EM_TIMESYNC */
|