Commit 5c55930b authored by Linus Torvalds's avatar Linus Torvalds

Merge http://gkernel.bkbits.net/net-drivers-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents a63ca30f c20e48a5
Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
==============================================================
April 9, 2002
September 16, 2002
Contents
......@@ -19,26 +19,9 @@ In This Release
===============
This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of
Adapters, version 2.0.x. This driver includes support for Itanium(TM)-based
Adapters, version 2.1.x. This driver includes support for Itanium(TM)-based
systems.
New for this release:
- Additional ethtool functionality, including link status test and EEPROM
read/write. A third-party application can use the ethtool interface to
get and set driver parameters.
- Support for Zero copy on 82550-based adapters. This feature provides
faster data throughput and significant CPU usage improvement in systems
that use the relevant system call (sendfile(2)).
- Support for large MTU-enabling interface (1504 bytes) with kernel's
VLAN module
- Support for polling on RX
- Support for Wake On LAN* on 82550 and 82559-based adapters
Supported Adapters
==================
......@@ -96,8 +79,7 @@ CNR PRO/100 VE Desktop Adapter A10386-xxx, A10725-xxx,
To verify that your adapter is supported, find the board ID number on the
adapter. Look for a label that has a barcode and a number in the format
123456-001 (six digits hyphen three digits). Match this to the list of
numbers above.
A12345-001. Match this to the list of numbers above.
For more information on how to identify your adapter, go to the Adapter &
Driver ID Guide at:
......@@ -106,15 +88,20 @@ Driver ID Guide at:
For the latest Intel PRO/100 network driver for Linux, see:
http://appsr.intel.com/scripts-df/support_intel.asp
http://downloadfinder.intel.com/scripts-df/support_intel.asp
Command Line Parameters
=======================
The following parameters are used by entering them on the command line with
the modprobe or insmod command. For example, with two Intel PRO/100 PCI
adapters, entering:
The following optional parameters are used by entering them on the command
line with the modprobe or insmod command using this syntax:
modprobe e100 [<option>=<VAL1>,<VAL2>,...]
insmod e100 [<option>=<VAL1>,<VAL2>,...]
For example, with two Intel PRO/100 PCI adapters, entering:
modprobe e100 TxDescriptors=32,128
......@@ -122,16 +109,20 @@ loads the e100 driver with 32 TX resources for the first adapter and 128 TX
resources for the second adapter. This configuration favors the second
adapter. The driver supports up to 16 network adapters concurrently.
The default value for each parameter is generally the recommended setting,
unless otherwise noted.
NOTE: Giving any command line option the value "-1" causes the driver to use
the appropriate default value for that option, as if no value was
specified.
BundleMax
Valid Range: 0x1-0xFFFF
Valid Range: 1-65535
Default Value: 6
This parameter holds the maximum number of packets in a bundle. Suggested
values range from 2 to 10. See "CPU Cycle Saver."
This parameter holds the maximum number of small packets (less than 128
bytes) in a bundle. Suggested values range from 2 to 10. See "CPU Cycle
Saver."
BundleSmallFr
Valid Range: 0-1 (0=off, 1=on)
......@@ -142,48 +133,33 @@ Default Value: 0
e100_speed_duplex
Valid Range: 0-4 (1=10half;2=10full;3=100half;4=100full)
Default Value: 0
The default value of 0 is set to auto-negotiate if the link partner is set
to auto-negotiate. If the link partner is forced, e100_speed_duplex
defaults to half-duplex.
The default value of 0 sets the adapter to auto-negotiate. Other values
set the adapter to forced speed and duplex.
Example usage: insmod e100.o e100_speed_duplex=4,4 (for two adapters)
flow_control
Valid Range: 0-1 (0=off, 1=on)
Default Value: 0
This parameter controls the automatic generation(Tx) and response(Rx) to
Ethernet PAUSE frames. flow_control should NOT be set to 1 when the e100
Ethernet PAUSE frames. flow_control should NOT be set to 1 when the
adapter is connected to an interface that does not support Ethernet PAUSE
frames and when the e100_speed_duplex parameter is NOT set to zero.
IntDelay
Valid Range: 0-0xFFFF (0=off)
Valid Range: 0-65535 (0=off)
Default Value: 1536
This parameter holds the number of time units (in adapter terminology)
until the adapter generates an interrupt. The recommended value for
IntDelay is 0x600 (upon initialization). Suggested values range from
0x200h to 0x800. See "CPU Cycle Saver."
IntDelay is 1536 (upon initialization). Suggested values range from
512 to 2048. See "CPU Cycle Saver."
IFS
Valid Range: 0-1 (0=off, 1=on)
Default Value: 1
Inter Frame Spacing (IFS) aims to reduce the number of Ethernet frame
collisions by altering the time between frame transmissions. When IFS is
enabled the driver tries to find an optimal IFS value. However, some
switches function better when IFS is disabled.
PollingMaxWork
Valid Range: 1-1024 (max number of RxDescriptors)
Default Value: Specified number of RxDescriptors
This value specifies the maximum number of receive packets that are
processed on a single polling call. This parameter is invalid if
RxCongestionControl is set to 0.
RxCongestionControl
Valid Range: 0-1 (0=off, 1=on)
Default Value: 1
1 enables polling mode. When the link is congested, the driver can decide
to handle received packets by polling them, instead of waiting until
interrupts occur.
enabled the driver tries to find an optimal IFS value. It is used only at
half duplex.
RxDescriptors
Valid Range: 8-1024
......@@ -200,13 +176,15 @@ Default Value: 64
Increasing this value allows the protocol stack to queue more transmits at
the driver level. The maximum value for Itanium-based systems is 64.
ucode (not available for 82557-based adapters)
ucode
Valid Range: 0-1 (0=off, 1=on)
Default Value: 0 for 82558-based adapters
1 for 82559(and higher)-based adapters
1 for 82559, 82550, and 82551-based adapters
On uploads the micro code to the adapter, which enables CPU Cycle Saver.
See the section "CPU Cycle Saver" below.
Example usage: insmod e100.o ucode=0 (does not reduce CPU usage)
Example usage: insmod e100.o ucode=1
Not available on 82557-based adapters.
XsumRX
Valid Range: 0-1 (0=off, 1=on)
......@@ -214,6 +192,8 @@ Default Value: 1
On allows Rx checksum offloading for TCP/UDP packets. Requires that the
hardware support this feature.
Not available on 82557 and 82558-based adapters.
CPU Cycle Saver
================
......@@ -234,10 +214,11 @@ switching to and from the driver.
CPU Cycle Saver consists of these arguments: IntDelay, BundleMax and
BundleSmallFr. When IntDelay is increased, the adapter waits longer for
frames to arrive before generating the interrupt. By increasing BundleMax,
the network adapter waits for the number of frames specified to arrive before
generating the interrupt. When BundleSmallFr is disabled, the adapter does
not bundle packets that are smaller than 128 bytes. Such small packets are
often, but not always, control packets that are better served immediately.
the network adapter waits for the number of small frames (less than 128 bytes)
specified to arrive before generating the interrupt. When BundleSmallFr is
disabled, the adapter does not bundle small packets. Such small packets are
often, but not always, control packets that are better served immediately;
therefore, BundleSmallFr is disabled by default.
For most users, it is recommended that CPU Cycle Saver be used with the
default values specified in the Command Line Parameters section. However, in
......@@ -249,7 +230,7 @@ ucode=0.
Support
=======
For general information and support, go to the Intel support website at:
For general information, go to the Intel support website at:
http://support.intel.com
......
Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters
===============================================================
August 6, 2002
October 12, 2002
Contents
......@@ -20,7 +20,7 @@ In This Release
===============
This file describes the Linux* Base Driver for the Intel(R) PRO/1000 Family
of Adapters, version 4.3.x. This driver includes support for
of Adapters, version 4.4.x. This driver includes support for
Itanium(TM)-based systems.
This release version includes the following:
......@@ -32,7 +32,7 @@ This release version includes the following:
default in supporting kernels. It is not supported on the Intel(R)
PRO/1000 Gigabit Server Adapter.
New features include:
Features include:
- Support for the 82545 and 82546-based adapters listed below
......@@ -144,8 +144,7 @@ Default Value: 80
RxIntDelay
Valid Range: 0-65535 (0=off)
Default Value: 0 (82542, 82543, and 82544-based adapters)
128 (82540, 82545, and 82546-based adapters)
Default Value: 0
This value delays the generation of receive interrupts in units of 1.024
microseconds. Receive interrupt reduction can improve CPU efficiency if
properly tuned for specific network traffic. Increasing this value adds
......@@ -154,13 +153,12 @@ Default Value: 0 (82542, 82543, and 82544-based adapters)
may be set too high, causing the driver to run out of available receive
descriptors.
CAUTION: When setting RxIntDelay to a value other than 0, adapters based
on the Intel 82543 and 82544 LAN controllers may hang (stop
transmitting) under certain network conditions. If this occurs a
message is logged in the system event log. In addition, the
controller is automatically reset, restoring the network
connection. To eliminate the potential for the hang ensure that
RxIntDelay is set to 0.
CAUTION: When setting RxIntDelay to a value other than 0, adapters may
hang (stop transmitting) under certain network conditions. If
this occurs a NETDEV WATCHDOG message is logged in the system
event log. In addition, the controller is automatically reset,
restoring the network connection. To eliminate the potential for
the hang ensure that RxIntDelay is set to 0.
RxAbsIntDelay (82540, 82545, and 82546-based adapters only)
Valid Range: 0-65535 (0=off)
......
......@@ -121,7 +121,6 @@
#define E100_DEFAULT_CPUSAVER_BUNDLE_MAX 6
#define E100_DEFAULT_CPUSAVER_INTERRUPT_DELAY 0x600
#define E100_DEFAULT_BUNDLE_SMALL_FR false
#define E100_DEFAULT_RX_CONGESTION_CONTROL true
/* end of configurables */
......@@ -146,8 +145,6 @@ struct driver_stats {
unsigned long xmt_tco_pkts;
unsigned long rcv_tco_pkts;
unsigned long rx_intr_pkts;
unsigned long rx_tasklet_pkts;
unsigned long poll_intr_switch;
};
/* TODO: kill me when we can do C99 */
......@@ -838,7 +835,6 @@ typedef struct _bd_dma_able_t {
#define PRM_FC 0x00000004
#define PRM_IFS 0x00000008
#define PRM_BUNDLE_SMALL 0x00000010
#define PRM_RX_CONG 0x00000020
struct cfg_params {
int e100_speed_duplex;
......@@ -847,7 +843,6 @@ struct cfg_params {
int IntDelay;
int BundleMax;
int ber;
int PollingMaxWork;
u32 b_params;
};
struct ethtool_lpbk_data{
......@@ -949,8 +944,6 @@ struct e100_private {
u32 speed_duplex_caps; /* adapter's speed/duplex capabilities */
struct tasklet_struct polling_tasklet;
/* WOL params for ethtool */
u32 wolsupported;
u32 wolopts;
......@@ -961,6 +954,7 @@ struct e100_private {
#ifdef CONFIG_PM
u32 pci_state[16];
#endif
char ifname[IFNAMSIZ];
};
#define E100_AUTONEG 0
......
......@@ -45,6 +45,15 @@
**********************************************************************/
/* Change Log
*
* 2.1.24 10/7/02
* o Bug fix: Wrong files under /proc/net/PRO_LAN_Adapters/ when interface
* name is changed
* o Bug fix: Rx skb corruption when Rx polling code and Rx interrupt code
* are executing during stress traffic at shared interrupt system.
* Removed Rx polling code
* o Added detailed printk if selftest failed when insmod
* o Removed misleading printks
*
* 2.1.12 8/2/02
* o Feature: ethtool register dump
......@@ -62,25 +71,6 @@
* o Bug fix: PHY loopback diagnostic fails
*
* 2.1.6 7/5/02
* o Added device ID support for Dell LOM.
* o Added device ID support for 82511QM mobile nics.
* o Bug fix: ethtool get/set EEPROM routines modified to use byte
* addressing rather than word addressing.
* o Feature: added MDIX mode support for 82550 and up.
* o Bug fix: added reboot notifer to setup WOL settings when
* shutting system down.
* o Cleanup: removed yield() redefinition (Andrew Morton,
* akpm@zip.com.au).
* o Bug fix: flow control now working when link partner is
* autoneg capable but not flow control capable.
* o Bug fix: added check for corrupted EEPROM
* o Bug fix: don't report checksum offloading for the older
* controllers that don't support the feature.
* o Bug fix: calculate cable diagnostics when link goes down
* rather than when queuering /proc file.
* o Cleanup: move mdi_access_lock to local get/set mdi routines.
*
* 2.0.30 5/30/02
*/
#include <linux/config.h>
......@@ -94,8 +84,8 @@
#include "e100_vendor.h"
#ifdef CONFIG_PROC_FS
extern int e100_create_proc_subdir(struct e100_private *);
extern void e100_remove_proc_subdir(struct e100_private *);
extern int e100_create_proc_subdir(struct e100_private *, char *);
extern void e100_remove_proc_subdir(struct e100_private *, char *);
#else
#define e100_create_proc_subdir(X) 0
#define e100_remove_proc_subdir(X) do {} while(0)
......@@ -145,7 +135,7 @@ static void e100_non_tx_background(unsigned long);
/* Global Data structures and variables */
char e100_copyright[] __devinitdata = "Copyright (c) 2002 Intel Corporation";
char e100_driver_version[]="2.1.15-k1";
char e100_driver_version[]="2.1.24-k1";
const char *e100_full_driver_name = "Intel(R) PRO/100 Network Driver";
char e100_short_driver_name[] = "e100";
static int e100nics = 0;
......@@ -154,12 +144,19 @@ static int e100nics = 0;
static int e100_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
static int e100_suspend(struct pci_dev *pcid, u32 state);
static int e100_resume(struct pci_dev *pcid);
struct notifier_block e100_notifier = {
struct notifier_block e100_notifier_reboot = {
notifier_call: e100_notify_reboot,
next: NULL,
priority: 0
};
#endif
static int e100_notify_netdev(struct notifier_block *, unsigned long event, void *ptr);
struct notifier_block e100_notifier_netdev = {
notifier_call: e100_notify_netdev,
next: NULL,
priority: 0
};
static void e100_get_mdix_status(struct e100_private *bdp);
......@@ -349,9 +346,7 @@ e100_alloc_skbs(struct e100_private *bdp)
}
void e100_tx_srv(struct e100_private *);
u32 e100_rx_srv(struct e100_private *, u32, int *);
void e100_polling_tasklet(unsigned long);
u32 e100_rx_srv(struct e100_private *);
void e100_watchdog(struct net_device *);
static void e100_do_hwi(struct net_device *);
......@@ -379,9 +374,6 @@ E100_PARAM(IntDelay, "Value for CPU saver's interrupt delay");
E100_PARAM(BundleSmallFr, "Disable or enable interrupt bundling of small frames");
E100_PARAM(BundleMax, "Maximum number for CPU saver's packet bundling");
E100_PARAM(IFS, "Disable or enable the adaptive IFS algorithm");
E100_PARAM(RxCongestionControl, "Disable or enable switch to polling mode");
E100_PARAM(PollingMaxWork, "Max number of receive packets processed on single "
"polling call");
/**
* e100_exec_cmd - issue a comand
......@@ -656,6 +648,8 @@ e100_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
if ((rc = register_netdev(dev)) != 0) {
goto err_pci;
}
memcpy(bdp->ifname, dev->name, IFNAMSIZ);
bdp->ifname[IFNAMSIZ-1] = 0;
bdp->device_type = ent->driver_data;
printk(KERN_NOTICE
......@@ -674,7 +668,7 @@ e100_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
bdp->cable_status = "Not available";
}
if (e100_create_proc_subdir(bdp) < 0) {
if (e100_create_proc_subdir(bdp, bdp->ifname) < 0) {
printk(KERN_ERR "e100: Failed to create proc dir for %s\n",
bdp->device->name);
}
......@@ -738,7 +732,7 @@ e100_remove1(struct pci_dev *pcid)
unregister_netdev(dev);
e100_remove_proc_subdir(bdp);
e100_remove_proc_subdir(bdp, bdp->ifname);
e100_sw_reset(bdp, PORT_SELECTIVE_RESET);
......@@ -772,10 +766,12 @@ e100_init_module(void)
int ret;
ret = pci_module_init(&e100_driver);
#ifdef CONFIG_PM
if(ret >= 0)
register_reboot_notifier(&e100_notifier);
#endif
if(ret >= 0) {
#ifdef CONFIG_PM
register_reboot_notifier(&e100_notifier_reboot);
#endif
register_netdevice_notifier(&e100_notifier_netdev);
}
return ret;
}
......@@ -784,8 +780,9 @@ static void __exit
e100_cleanup_module(void)
{
#ifdef CONFIG_PM
unregister_reboot_notifier(&e100_notifier);
#endif
unregister_reboot_notifier(&e100_notifier_reboot);
#endif
unregister_netdevice_notifier(&e100_notifier_netdev);
pci_unregister_driver(&e100_driver);
}
......@@ -856,14 +853,6 @@ e100_check_options(int board, struct e100_private *bdp)
0xFFFF, E100_DEFAULT_CPUSAVER_BUNDLE_MAX,
"CPU saver bundle max value");
e100_set_bool_option(bdp, RxCongestionControl[board], PRM_RX_CONG,
E100_DEFAULT_RX_CONGESTION_CONTROL,
"Rx Congestion Control value");
e100_set_int_option(&(bdp->params.PollingMaxWork),
PollingMaxWork[board], 1, E100_MAX_RFD,
bdp->params.RxDescriptors,
"Polling Max Work value");
}
/**
......@@ -991,11 +980,6 @@ e100_open(struct net_device *dev)
del_timer_sync(&bdp->watchdog_timer);
goto err_exit;
}
if (bdp->params.b_params & PRM_RX_CONG) {
DECLARE_TASKLET(polling_tasklet,
e100_polling_tasklet, (unsigned long) bdp);
bdp->polling_tasklet = polling_tasklet;
}
bdp->intr_mask = 0;
e100_set_intr_mask(bdp);
......@@ -1024,10 +1008,6 @@ e100_close(struct net_device *dev)
free_irq(dev->irq, dev);
e100_clear_pools(bdp);
if (bdp->params.b_params & PRM_RX_CONG) {
tasklet_kill(&(bdp->polling_tasklet));
}
/* set the isolate flag to false, so e100_open can be called */
bdp->driver_isolated = false;
......@@ -1263,12 +1243,21 @@ e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static unsigned char __devinit
e100_init(struct e100_private *bdp)
{
u32 st_timeout = 0;
u32 st_result = 0;
e100_sw_init(bdp);
if (!e100_selftest(bdp, NULL, NULL)) {
printk(KERN_ERR "e100: selftest failed\n");
if (!e100_selftest(bdp, &st_timeout, &st_result)) {
if (st_timeout) {
printk(KERN_ERR "e100: selftest timeout\n");
} else {
printk(KERN_ERR "e100: selftest failed. Results: %x\n",
st_result);
}
return false;
}
else
printk(KERN_DEBUG "e100: selftest OK.\n");
/* read the MAC address from the eprom */
e100_rd_eaddr(bdp);
......@@ -1802,47 +1791,6 @@ e100_manage_adaptive_ifs(struct e100_private *bdp)
}
}
void
e100_polling_tasklet(unsigned long ptr)
{
struct e100_private *bdp = (struct e100_private *) ptr;
unsigned int rx_congestion = 0;
u32 skb_cnt;
/* the device is closed, don't continue or else bad things may happen. */
if (!netif_running(bdp->device)) {
return;
}
read_lock(&(bdp->isolate_lock));
if (bdp->driver_isolated) {
tasklet_schedule(&(bdp->polling_tasklet));
goto exit;
}
e100_alloc_skbs(bdp);
skb_cnt = e100_rx_srv(bdp, bdp->params.PollingMaxWork, &rx_congestion);
bdp->drv_stats.rx_tasklet_pkts += skb_cnt;
if (rx_congestion || skb_cnt) {
tasklet_schedule(&(bdp->polling_tasklet));
} else {
bdp->intr_mask &= ~SCB_INT_MASK;
bdp->drv_stats.poll_intr_switch++;
}
bdp->tx_count = 0; /* restart tx interrupt batch count */
e100_tx_srv(bdp);
e100_set_intr_mask(bdp);
exit:
read_unlock(&(bdp->isolate_lock));
}
/**
* e100intr - interrupt handler
* @irq: the IRQ number
......@@ -1892,18 +1840,8 @@ e100intr(int irq, void *dev_inst, struct pt_regs *regs)
/* do recv work if any */
if (intr_status &
(SCB_STATUS_ACK_FR | SCB_STATUS_ACK_RNR | SCB_STATUS_ACK_SWI)) {
int rx_congestion;
bdp->drv_stats.rx_intr_pkts +=
e100_rx_srv(bdp, 0, &rx_congestion);
if ((bdp->params.b_params & PRM_RX_CONG) && rx_congestion) {
bdp->intr_mask |= SCB_INT_MASK;
tasklet_schedule(&(bdp->polling_tasklet));
bdp->drv_stats.poll_intr_switch++;
}
}
(SCB_STATUS_ACK_FR | SCB_STATUS_ACK_RNR | SCB_STATUS_ACK_SWI))
bdp->drv_stats.rx_intr_pkts += e100_rx_srv(bdp);
/* clean up after tx'ed packets */
if (intr_status & (SCB_STATUS_ACK_CNA | SCB_STATUS_ACK_CX)) {
......@@ -1997,8 +1935,7 @@ e100_tx_srv(struct e100_private *bdp)
* It returns the number of serviced RFDs.
*/
u32
e100_rx_srv(struct e100_private *bdp, u32 max_number_of_rfds,
int *rx_congestion)
e100_rx_srv(struct e100_private *bdp)
{
rfd_t *rfd; /* new rfd, received rfd */
int i;
......@@ -2009,10 +1946,6 @@ e100_rx_srv(struct e100_private *bdp, u32 max_number_of_rfds,
struct rx_list_elem *rx_struct;
u32 rfd_cnt = 0;
if (rx_congestion) {
*rx_congestion = 0;
}
dev = bdp->device;
/* current design of rx is as following:
......@@ -2027,9 +1960,6 @@ e100_rx_srv(struct e100_private *bdp, u32 max_number_of_rfds,
* (watchdog trigger SWI intr and isr should allocate new skbs)
*/
for (i = 0; i < bdp->params.RxDescriptors; i++) {
if (max_number_of_rfds && (rfd_cnt >= max_number_of_rfds)) {
break;
}
if (list_empty(&(bdp->active_rx_list))) {
break;
}
......@@ -2094,20 +2024,12 @@ e100_rx_srv(struct e100_private *bdp, u32 max_number_of_rfds,
} else {
skb->ip_summed = CHECKSUM_NONE;
}
switch (netif_rx(skb)) {
case NET_RX_BAD:
break;
case NET_RX_DROP:
case NET_RX_CN_MOD:
case NET_RX_CN_HIGH:
if (bdp->params.b_params & PRM_RX_CONG) {
if (rx_congestion) {
*rx_congestion = 1;
}
}
/* FALL THROUGH TO STATISTICS UPDATE */
break;
default:
bdp->drv_stats.net_stats.rx_bytes += skb->len;
break;
......@@ -3032,11 +2954,6 @@ e100_print_brd_conf(struct e100_private *bdp)
" Mem:0x%08lx IRQ:%d Speed:%d Mbps Dx:%s\n",
(unsigned long) bdp->device->mem_start,
bdp->device->irq, 0, "N/A");
/* Auto negotiation failed so we should display an error */
printk(KERN_NOTICE " Failed to detect cable link\n");
printk(KERN_NOTICE " Speed and duplex will be determined "
"at time of connection\n");
}
/* Print the string if checksum Offloading was enabled */
......@@ -4176,11 +4093,34 @@ e100_non_tx_background(unsigned long ptr)
spin_unlock_bh(&(bdp->bd_non_tx_lock));
}
int e100_notify_netdev(struct notifier_block *nb, unsigned long event, void *p)
{
struct e100_private *bdp;
struct net_device *netdev = p;
if(netdev == NULL)
return NOTIFY_DONE;
switch(event) {
case NETDEV_CHANGENAME:
if(netdev->open == e100_open) {
bdp = netdev->priv;
/* rename the proc nodes the easy way */
e100_remove_proc_subdir(bdp, bdp->ifname);
memcpy(bdp->ifname, netdev->name, IFNAMSIZ);
bdp->ifname[IFNAMSIZ-1] = 0;
e100_create_proc_subdir(bdp, bdp->ifname);
}
break;
}
return NOTIFY_DONE;
}
#ifdef CONFIG_PM
static int
e100_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
{
struct pci_dev *pdev = NULL;
struct pci_dev *pdev;
switch(event) {
case SYS_DOWN:
......
......@@ -249,8 +249,6 @@ static e100_proc_entry e100_proc_list[] = {
{"Rx_TCO_Packets", read_gen_ulong, 0, bdp_drv_off(rcv_tco_pkts)},
{"\n",},
{"Rx_Interrupt_Packets", read_gen_ulong, 0, bdp_drv_off(rx_intr_pkts)},
{"Rx_Polling_Packets", read_gen_ulong, 0, bdp_drv_off(rx_tasklet_pkts)},
{"Polling_Interrupt_Switch", read_gen_ulong, 0, bdp_drv_off(poll_intr_switch)},
{"Identify_Adapter", 0, write_blink_led_timer, 0},
{"", 0, 0, 0}
};
......@@ -291,7 +289,7 @@ read_info(char *page, char **start, off_t off, int count, int *eof, void *data)
return generic_read(page, start, off, count, eof, len);
}
static struct proc_dir_entry * __devinit
static struct proc_dir_entry *
create_proc_rw(char *name, void *data, struct proc_dir_entry *parent,
read_proc_t * read_proc, write_proc_t * write_proc)
{
......@@ -318,7 +316,7 @@ create_proc_rw(char *name, void *data, struct proc_dir_entry *parent,
}
void
e100_remove_proc_subdir(struct e100_private *bdp)
e100_remove_proc_subdir(struct e100_private *bdp, char *name)
{
e100_proc_entry *pe;
char info[256];
......@@ -329,8 +327,8 @@ e100_remove_proc_subdir(struct e100_private *bdp)
return;
}
len = strlen(bdp->device->name);
strncpy(info, bdp->device->name, sizeof (info));
len = strlen(bdp->ifname);
strncpy(info, bdp->ifname, sizeof (info));
strncat(info + len, ".info", sizeof (info) - len);
if (bdp->proc_parent) {
......@@ -341,7 +339,7 @@ e100_remove_proc_subdir(struct e100_private *bdp)
remove_proc_entry(pe->name, bdp->proc_parent);
}
remove_proc_entry(bdp->device->name, adapters_proc_dir);
remove_proc_entry(bdp->ifname, adapters_proc_dir);
bdp->proc_parent = NULL;
}
......@@ -351,7 +349,7 @@ e100_remove_proc_subdir(struct e100_private *bdp)
e100_proc_cleanup();
}
int __devinit
int
e100_create_proc_subdir(struct e100_private *bdp)
{
struct proc_dir_entry *dev_dir;
......@@ -366,7 +364,7 @@ e100_create_proc_subdir(struct e100_private *bdp)
return -ENOMEM;
}
strncpy(info, bdp->device->name, sizeof (info));
strncpy(info, bdp->ifname, sizeof (info));
len = strlen(info);
strncat(info + len, ".info", sizeof (info) - len);
......@@ -376,12 +374,12 @@ e100_create_proc_subdir(struct e100_private *bdp)
return -ENOMEM;
}
dev_dir = create_proc_entry(bdp->device->name, S_IFDIR,
dev_dir = create_proc_entry(bdp->ifname, S_IFDIR,
adapters_proc_dir);
bdp->proc_parent = dev_dir;
if (!dev_dir) {
e100_remove_proc_subdir(bdp);
e100_remove_proc_subdir(bdp, bdp->ifname);
return -ENOMEM;
}
......@@ -396,7 +394,7 @@ e100_create_proc_subdir(struct e100_private *bdp)
if (!(create_proc_rw(pe->name, data, dev_dir,
pe->read_proc, pe->write_proc))) {
e100_remove_proc_subdir(bdp);
e100_remove_proc_subdir(bdp, bdp->ifname);
return -ENOMEM;
}
}
......
......@@ -95,6 +95,15 @@ struct e1000_adapter;
#define E1000_RXBUFFER_8192 8192
#define E1000_RXBUFFER_16384 16384
/* Flow Control High-Watermark: 43464 bytes */
#define E1000_FC_HIGH_THRESH 0xA9C8
/* Flow Control Low-Watermark: 43456 bytes */
#define E1000_FC_LOW_THRESH 0xA9C0
/* Flow Control Pause Time: 858 usec */
#define E1000_FC_PAUSE_TIME 0x0680
/* How many Tx Descriptors do we need to call netif_wake_queue ? */
#define E1000_TX_QUEUE_WAKE 16
/* How many Rx Buffers do we bundle into one write to the hardware ? */
......@@ -194,5 +203,6 @@ struct e1000_adapter {
uint32_t pci_state[16];
char ifname[IFNAMSIZ];
};
#endif /* _E1000_H_ */
......@@ -117,7 +117,8 @@ e1000_ethtool_sset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
if(ecmd->autoneg == AUTONEG_ENABLE) {
hw->autoneg = 1;
hw->autoneg_advertised = (ecmd->advertising & 0x002F);
hw->autoneg_advertised = 0x002F;
ecmd->advertising = 0x002F;
} else {
hw->autoneg = 0;
switch(ecmd->speed + ecmd->duplex) {
......@@ -210,7 +211,7 @@ e1000_ethtool_geeprom(struct e1000_adapter *adapter,
struct e1000_hw *hw = &adapter->hw;
int i, max_len, first_word, last_word;
if(eeprom->len == 0)
if(eeprom->len == 0)
return -EINVAL;
eeprom->magic = hw->vendor_id | (hw->device_id << 16);
......@@ -228,6 +229,7 @@ e1000_ethtool_geeprom(struct e1000_adapter *adapter,
for(i = 0; i <= (last_word - first_word); i++)
e1000_read_eeprom(hw, first_word + i, &eeprom_buff[i]);
return 0;
}
......@@ -290,7 +292,6 @@ e1000_ethtool_gwol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
case E1000_DEV_ID_82543GC_FIBER:
case E1000_DEV_ID_82543GC_COPPER:
case E1000_DEV_ID_82544EI_FIBER:
default:
wol->supported = 0;
wol->wolopts = 0;
return;
......@@ -304,14 +305,7 @@ e1000_ethtool_gwol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
}
/* Fall Through */
case E1000_DEV_ID_82544EI_COPPER:
case E1000_DEV_ID_82544GC_COPPER:
case E1000_DEV_ID_82544GC_LOM:
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82545EM_COPPER:
case E1000_DEV_ID_82545EM_FIBER:
case E1000_DEV_ID_82546EB_COPPER:
default:
wol->supported = WAKE_PHY | WAKE_UCAST |
WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
......@@ -340,7 +334,6 @@ e1000_ethtool_swol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
case E1000_DEV_ID_82543GC_FIBER:
case E1000_DEV_ID_82543GC_COPPER:
case E1000_DEV_ID_82544EI_FIBER:
default:
return wol->wolopts ? -EOPNOTSUPP : 0;
case E1000_DEV_ID_82546EB_FIBER:
......@@ -349,14 +342,7 @@ e1000_ethtool_swol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
return wol->wolopts ? -EOPNOTSUPP : 0;
/* Fall Through */
case E1000_DEV_ID_82544EI_COPPER:
case E1000_DEV_ID_82544GC_COPPER:
case E1000_DEV_ID_82544GC_LOM:
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82545EM_COPPER:
case E1000_DEV_ID_82545EM_FIBER:
case E1000_DEV_ID_82546EB_COPPER:
default:
if(wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE))
return -EOPNOTSUPP;
......@@ -518,7 +504,8 @@ e1000_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
if(copy_from_user(&eeprom, addr, sizeof(eeprom)))
return -EFAULT;
if((err = e1000_ethtool_geeprom(adapter, &eeprom, eeprom_buff))<0)
if((err = e1000_ethtool_geeprom(adapter,
&eeprom, eeprom_buff)))
return err;
if(copy_to_user(addr, &eeprom, sizeof(eeprom)))
......
......@@ -47,9 +47,9 @@ static void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
static void e1000_shift_out_ee_bits(struct e1000_hw *hw, uint16_t data, uint16_t count);
static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw);
static void e1000_setup_eeprom(struct e1000_hw *hw);
static void e1000_standby_eeprom(struct e1000_hw *hw);
static void e1000_clock_eeprom(struct e1000_hw *hw);
static void e1000_cleanup_eeprom(struct e1000_hw *hw);
static void e1000_standby_eeprom(struct e1000_hw *hw);
static int32_t e1000_id_led_init(struct e1000_hw * hw);
/******************************************************************************
......@@ -88,6 +88,9 @@ e1000_set_mac_type(struct e1000_hw *hw)
break;
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82540EP:
case E1000_DEV_ID_82540EP_LOM:
case E1000_DEV_ID_82540EP_LP:
hw->mac_type = e1000_82540;
break;
case E1000_DEV_ID_82545EM_COPPER:
......@@ -655,14 +658,17 @@ e1000_setup_copper_link(struct e1000_hw *hw)
return -E1000_ERR_PHY;
}
phy_data |= M88E1000_EPSCR_TX_CLK_25;
/* Configure Master and Slave downshift values */
phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
if(e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data) < 0) {
DEBUGOUT("PHY Write Error\n");
return -E1000_ERR_PHY;
if (hw->phy_revision < M88E1011_I_REV_4) {
/* Configure Master and Slave downshift values */
phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
if(e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data) < 0) {
DEBUGOUT("PHY Write Error\n");
return -E1000_ERR_PHY;
}
}
/* SW Reset the PHY so all changes take effect */
......@@ -1008,7 +1014,6 @@ e1000_phy_force_speed_duplex(struct e1000_hw *hw)
/* Write the configured values back to the Device Control Reg. */
E1000_WRITE_REG(hw, CTRL, ctrl);
/* Write the MII Control Register with the new PHY configuration. */
if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) {
DEBUGOUT("PHY Read Error\n");
return -E1000_ERR_PHY;
......@@ -1023,9 +1028,11 @@ e1000_phy_force_speed_duplex(struct e1000_hw *hw)
return -E1000_ERR_PHY;
}
DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data);
/* Need to reset the PHY or these changes will be ignored */
mii_ctrl_reg |= MII_CR_RESET;
/* Write back the modified PHY MII control register. */
if(e1000_write_phy_reg(hw, PHY_CTRL, mii_ctrl_reg) < 0) {
DEBUGOUT("PHY Write Error\n");
return -E1000_ERR_PHY;
......@@ -2100,7 +2107,8 @@ e1000_detect_gig_phy(struct e1000_hw *hw)
return -E1000_ERR_PHY;
}
hw->phy_id |= (uint32_t) (phy_id_low & PHY_REVISION_MASK);
hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
switch(hw->mac_type) {
case e1000_82543:
if(hw->phy_id == M88E1000_E_PHY_ID) match = TRUE;
......@@ -2242,7 +2250,7 @@ e1000_raise_ee_clk(struct e1000_hw *hw,
uint32_t *eecd)
{
/* Raise the clock input to the EEPROM (by setting the SK bit), and then
* wait 50 microseconds.
* wait <delay> microseconds.
*/
*eecd = *eecd | E1000_EECD_SK;
E1000_WRITE_REG(hw, EECD, *eecd);
......@@ -2331,11 +2339,11 @@ e1000_shift_in_ee_bits(struct e1000_hw *hw)
uint32_t i;
uint16_t data;
/* In order to read a register from the EEPROM, we need to shift 16 bits
* in from the EEPROM. Bits are "shifted in" by raising the clock input to
* the EEPROM (setting the SK bit), and then reading the value of the "DO"
* bit. During this "shifting in" process the "DI" bit should always be
* clear..
/* In order to read a register from the EEPROM, we need to shift 'count'
* bits in from the EEPROM. Bits are "shifted in" by raising the clock
* input to the EEPROM (setting the SK bit), and then reading the value of
* the "DO" bit. During this "shifting in" process the "DI" bit should
* always be clear.
*/
eecd = E1000_READ_REG(hw, EECD);
......@@ -3140,6 +3148,9 @@ e1000_setup_led(struct e1000_hw *hw)
ledctl |= (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED0_MODE_SHIFT);
E1000_WRITE_REG(hw, LEDCTL, ledctl);
break;
case E1000_DEV_ID_82540EP:
case E1000_DEV_ID_82540EP_LOM:
case E1000_DEV_ID_82540EP_LP:
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82545EM_COPPER:
......@@ -3173,6 +3184,9 @@ e1000_cleanup_led(struct e1000_hw *hw)
case E1000_DEV_ID_82544GC_LOM:
/* No cleanup necessary */
break;
case E1000_DEV_ID_82540EP:
case E1000_DEV_ID_82540EP_LOM:
case E1000_DEV_ID_82540EP_LP:
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82545EM_COPPER:
......@@ -3223,6 +3237,9 @@ e1000_led_on(struct e1000_hw *hw)
ctrl |= E1000_CTRL_SWDPIO0;
E1000_WRITE_REG(hw, CTRL, ctrl);
break;
case E1000_DEV_ID_82540EP:
case E1000_DEV_ID_82540EP_LOM:
case E1000_DEV_ID_82540EP_LP:
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82545EM_COPPER:
......@@ -3270,6 +3287,9 @@ e1000_led_off(struct e1000_hw *hw)
ctrl |= E1000_CTRL_SWDPIO0;
E1000_WRITE_REG(hw, CTRL, ctrl);
break;
case E1000_DEV_ID_82540EP:
case E1000_DEV_ID_82540EP_LOM:
case E1000_DEV_ID_82540EP_LP:
case E1000_DEV_ID_82540EM:
case E1000_DEV_ID_82540EM_LOM:
case E1000_DEV_ID_82545EM_COPPER:
......
......@@ -237,20 +237,23 @@ void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value);
e1000_write_reg_io((a), E1000_##reg, val)
/* PCI Device IDs */
#define E1000_DEV_ID_82542 0x1000
#define E1000_DEV_ID_82543GC_FIBER 0x1001
#define E1000_DEV_ID_82543GC_COPPER 0x1004
#define E1000_DEV_ID_82544EI_COPPER 0x1008
#define E1000_DEV_ID_82544EI_FIBER 0x1009
#define E1000_DEV_ID_82544GC_COPPER 0x100C
#define E1000_DEV_ID_82544GC_LOM 0x100D
#define E1000_DEV_ID_82540EM 0x100E
#define E1000_DEV_ID_82540EM_LOM 0x1015
#define E1000_DEV_ID_82545EM_COPPER 0x100F
#define E1000_DEV_ID_82545EM_FIBER 0x1011
#define E1000_DEV_ID_82546EB_COPPER 0x1010
#define E1000_DEV_ID_82546EB_FIBER 0x1012
#define NUM_DEV_IDS 13
#define E1000_DEV_ID_82542 0x1000
#define E1000_DEV_ID_82543GC_FIBER 0x1001
#define E1000_DEV_ID_82543GC_COPPER 0x1004
#define E1000_DEV_ID_82544EI_COPPER 0x1008
#define E1000_DEV_ID_82544EI_FIBER 0x1009
#define E1000_DEV_ID_82544GC_COPPER 0x100C
#define E1000_DEV_ID_82544GC_LOM 0x100D
#define E1000_DEV_ID_82540EM 0x100E
#define E1000_DEV_ID_82540EM_LOM 0x1015
#define E1000_DEV_ID_82540EP_LOM 0x1016
#define E1000_DEV_ID_82540EP 0x1017
#define E1000_DEV_ID_82540EP_LP 0x101E
#define E1000_DEV_ID_82545EM_COPPER 0x100F
#define E1000_DEV_ID_82545EM_FIBER 0x1011
#define E1000_DEV_ID_82546EB_COPPER 0x1010
#define E1000_DEV_ID_82546EB_FIBER 0x1012
#define NUM_DEV_IDS 16
#define NODE_ADDRESS_SIZE 6
#define ETH_LENGTH_OF_ADDRESS 6
......@@ -851,6 +854,7 @@ struct e1000_hw {
e1000_bus_type bus_type;
uint32_t io_base;
uint32_t phy_id;
uint32_t phy_revision;
uint32_t phy_addr;
uint32_t original_fc;
uint32_t txcw;
......@@ -1755,6 +1759,7 @@ struct e1000_hw {
#define M88E1011_I_PHY_ID 0x01410C20
#define M88E1000_12_PHY_ID M88E1000_E_PHY_ID
#define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
#define M88E1011_I_REV_4 0x04
/* Miscellaneous PHY bit definitions. */
#define PHY_PREAMBLE 0xFFFFFFFF
......
......@@ -30,6 +30,19 @@
#include "e1000.h"
/* Change Log
*
* 4.4.12 10/15/02
* o Clean up: use members of pci_device rather than direct calls to
* pci_read_config_word.
* o Bug fix: changed default flow control settings.
* o Clean up: ethtool file now has an inclusive list for adapters in the
* Wake-On-LAN capabilities instead of an exclusive list.
* o Bug fix: miscellaneous WoL bug fixes.
* o Added software interrupt for clearing rx ring
* o Bug fix: easier to undo "forcing" of 1000/fd using ethtool.
* o Now setting netdev->mem_end in e1000_probe.
* o Clean up: Moved tx_timeout from interrupt context to process context
* using schedule_task.
*
* o Feature: merged in modified NAPI patch from Robert Olsson
* <Robert.Olsson@its.uu.se> Uppsala Univeristy, Sweden.
......@@ -47,31 +60,13 @@
* o Feature: exposed two Tx and one Rx interrupt delay knobs for finer
* control over interurpt rate tuning.
* o Misc ethtool bug fixes.
*
* 4.3.2 7/5/02
* o Bug fix: perform controller reset using I/O rather than mmio because
* some chipsets try to perform a 64-bit write, but the controller ignores
* the upper 32-bit write once the reset is intiated by the lower 32-bit
* write, causing a master abort.
* o Bug fix: fixed jumbo frames sized from 1514 to 2048.
* o ASF support: disable ARP when driver is loaded or resumed; enable when
* driver is removed or suspended.
* o Bug fix: changed default setting for RxIntDelay to 0 for 82542/3/4
* controllers to workaround h/w errata where controller will hang when
* RxIntDelay <> 0 under certian network conditions.
* o Clean up: removed unused and undocumented user-settable settings for
* PHY.
* o Bug fix: ethtool GEEPROM was using byte address rather than word
* addressing.
* o Feature: added support for ethtool SEEPROM.
* o Feature: added support for entropy pool.
*
* 4.2.17 5/30/02
* 4.3.2 7/5/02
*/
char e1000_driver_name[] = "e1000";
char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
char e1000_driver_version[] = "4.3.15-k1";
char e1000_driver_version[] = "4.4.12-k1";
char e1000_copyright[] = "Copyright (c) 1999-2002 Intel Corporation.";
/* e1000_pci_tbl - PCI Device ID Table
......@@ -113,6 +108,9 @@ static struct pci_device_id e1000_pci_tbl[] __devinitdata = {
{0x8086, 0x1011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x1010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x1012, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x1016, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x1017, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x101E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
/* required last entry */
{0,}
};
......@@ -179,17 +177,24 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
static int e1000_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
static int e1000_notify_netdev(struct notifier_block *, unsigned long event, void *ptr);
static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
#ifdef CONFIG_PM
static int e1000_resume(struct pci_dev *pdev);
#endif
struct notifier_block e1000_notifier = {
struct notifier_block e1000_notifier_reboot = {
.notifier_call = e1000_notify_reboot,
.next = NULL,
.priority = 0
};
struct notifier_block e1000_notifier_netdev = {
.notifier_call = e1000_notify_netdev,
.next = NULL,
.priority = 0
};
/* Exported from other modules */
extern void e1000_check_options(struct e1000_adapter *adapter);
......@@ -230,8 +235,10 @@ e1000_init_module(void)
printk(KERN_INFO "%s\n", e1000_copyright);
ret = pci_module_init(&e1000_driver);
if(ret >= 0)
register_reboot_notifier(&e1000_notifier);
if(ret >= 0) {
register_reboot_notifier(&e1000_notifier_reboot);
register_netdevice_notifier(&e1000_notifier_netdev);
}
return ret;
}
......@@ -247,7 +254,8 @@ module_init(e1000_init_module);
static void __exit
e1000_exit_module(void)
{
unregister_reboot_notifier(&e1000_notifier);
unregister_reboot_notifier(&e1000_notifier_reboot);
unregister_netdevice_notifier(&e1000_notifier_netdev);
pci_unregister_driver(&e1000_driver);
}
......@@ -408,6 +416,7 @@ e1000_probe(struct pci_dev *pdev,
netdev->irq = pdev->irq;
netdev->mem_start = mmio_start;
netdev->mem_end = mmio_start + mmio_len;
netdev->base_addr = adapter->hw.io_base;
adapter->bd_number = cards_found;
......@@ -475,6 +484,8 @@ e1000_probe(struct pci_dev *pdev,
(void (*)(void *))e1000_tx_timeout_task, netdev);
register_netdev(netdev);
memcpy(adapter->ifname, netdev->name, IFNAMSIZ);
adapter->ifname[IFNAMSIZ-1] = 0;
/* we're going to reset, so assume we have no link for now */
......@@ -527,7 +538,7 @@ e1000_remove(struct pci_dev *pdev)
struct net_device *netdev = pci_get_drvdata(pdev);
struct e1000_adapter *adapter = netdev->priv;
uint32_t manc;
if(adapter->hw.mac_type >= e1000_82540) {
manc = E1000_READ_REG(&adapter->hw, MANC);
if(manc & E1000_MANC_SMBUS_EN) {
......@@ -535,7 +546,7 @@ e1000_remove(struct pci_dev *pdev)
E1000_WRITE_REG(&adapter->hw, MANC, manc);
}
}
unregister_netdev(netdev);
e1000_phy_hw_reset(&adapter->hw);
......@@ -588,9 +599,9 @@ e1000_sw_init(struct e1000_adapter *adapter)
/* flow control settings */
hw->fc_high_water = FC_DEFAULT_HI_THRESH;
hw->fc_low_water = FC_DEFAULT_LO_THRESH;
hw->fc_pause_time = FC_DEFAULT_TX_TIMER;
hw->fc_high_water = E1000_FC_HIGH_THRESH;
hw->fc_low_water = E1000_FC_LOW_THRESH;
hw->fc_pause_time = E1000_FC_PAUSE_TIME;
hw->fc_send_xon = 1;
/* Media type - copper or fiber */
......@@ -911,8 +922,9 @@ e1000_configure_rx(struct e1000_adapter *adapter)
/* set the Receive Delay Timer Register */
E1000_WRITE_REG(&adapter->hw, RDTR, adapter->rx_int_delay);
if(adapter->hw.mac_type >= e1000_82540) {
E1000_WRITE_REG(&adapter->hw, RDTR, adapter->rx_int_delay);
E1000_WRITE_REG(&adapter->hw, RADV, adapter->rx_abs_int_delay);
/* Set the interrupt throttling rate. Value is calculated
......@@ -920,9 +932,6 @@ e1000_configure_rx(struct e1000_adapter *adapter)
#define MAX_INTS_PER_SEC 8000
#define DEFAULT_ITR 1000000000/(MAX_INTS_PER_SEC * 256)
E1000_WRITE_REG(&adapter->hw, ITR, DEFAULT_ITR);
} else {
E1000_WRITE_REG(&adapter->hw, RDTR, adapter->rx_int_delay);
}
/* Setup the Base and Length of the Rx Descriptor Ring */
......@@ -1280,6 +1289,10 @@ e1000_watchdog(unsigned long data)
e1000_update_stats(adapter);
e1000_update_adaptive(&adapter->hw);
/* Cause software interrupt to ensure rx ring is cleaned */
E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
/* Early detection of hung controller */
i = txdr->next_to_clean;
if(txdr->buffer_info[i].dma &&
......@@ -1497,7 +1510,6 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
int f;
count = TXD_USE_COUNT(skb->len - skb->data_len,
adapter->max_data_per_txd);
for(f = 0; f < skb_shinfo(skb)->nr_frags; f++)
......@@ -1744,6 +1756,7 @@ e1000_update_stats(struct e1000_adapter *adapter)
adapter->stats.latecol;
adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
adapter->net_stats.tx_window_errors = adapter->stats.latecol;
adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
/* Tx Dropped needs to be maintained elsewhere */
......@@ -1756,7 +1769,8 @@ e1000_update_stats(struct e1000_adapter *adapter)
adapter->phy_stats.idle_errors += phy_tmp;
}
if(!e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
if((hw->mac_type <= e1000_82546) &&
!e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
adapter->phy_stats.receive_errors += phy_tmp;
}
}
......@@ -2164,8 +2178,7 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
while(!rx_ring->buffer_info[i].skb) {
rx_desc = E1000_RX_DESC(*rx_ring, i);
skb = alloc_skb(adapter->rx_buffer_len + reserve_len,
GFP_ATOMIC);
skb = dev_alloc_skb(adapter->rx_buffer_len + reserve_len);
if(!skb) {
/* Better luck next round */
......@@ -2396,6 +2409,29 @@ e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
return NOTIFY_DONE;
}
static int
e1000_notify_netdev(struct notifier_block *nb, unsigned long event, void *p)
{
struct e1000_adapter *adapter;
struct net_device *netdev = p;
if(netdev == NULL)
return NOTIFY_DONE;
switch(event) {
case NETDEV_CHANGENAME:
if(netdev->open == e1000_open) {
adapter = netdev->priv;
/* rename the proc nodes the easy way */
e1000_proc_dev_free(adapter);
memcpy(adapter->ifname, netdev->name, IFNAMSIZ);
adapter->ifname[IFNAMSIZ-1] = 0;
e1000_proc_dev_setup(adapter);
}
break;
}
return NOTIFY_DONE;
}
static int
e1000_suspend(struct pci_dev *pdev, uint32_t state)
{
......@@ -2412,30 +2448,40 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state)
e1000_setup_rctl(adapter);
e1000_set_multi(netdev);
/* turn on all-multi mode if wake on multicast is enabled */
if(adapter->wol & E1000_WUFC_MC) {
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl |= E1000_RCTL_MPE;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
}
if(adapter->hw.media_type == e1000_media_type_fiber) {
#define E1000_CTRL_ADVD3WUC 0x00100000
if(adapter->hw.mac_type >= e1000_82540) {
ctrl = E1000_READ_REG(&adapter->hw, CTRL);
ctrl |= E1000_CTRL_ADVD3WUC;
/* advertise wake from D3Cold */
#define E1000_CTRL_ADVD3WUC 0x00100000
/* phy power management enable */
#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
ctrl |= E1000_CTRL_ADVD3WUC |
E1000_CTRL_EN_PHY_PWR_MGMT;
E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
}
if(adapter->hw.media_type == e1000_media_type_fiber) {
/* keep the laser running in D3 */
ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
}
E1000_WRITE_REG(&adapter->hw, WUC, 0);
E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
E1000_WRITE_REG(&adapter->hw, WUFC, adapter->wol);
pci_enable_wake(pdev, 3, 1);
pci_enable_wake(pdev, 4, 1); /* 4 == D3 cold */
} else {
E1000_WRITE_REG(&adapter->hw, WUC, 0);
E1000_WRITE_REG(&adapter->hw, WUFC, 0);
pci_enable_wake(pdev, 3, 0);
pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
}
pci_save_state(pdev, adapter->pci_state);
......@@ -2445,9 +2491,12 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state)
if(manc & E1000_MANC_SMBUS_EN) {
manc |= E1000_MANC_ARP_EN;
E1000_WRITE_REG(&adapter->hw, MANC, manc);
state = 0;
}
} else
pci_set_power_state(pdev, 3);
}
state = (state > 0) ? 3 : 0;
pci_set_power_state(pdev, state);
return 0;
}
......@@ -2462,10 +2511,11 @@ e1000_resume(struct pci_dev *pdev)
pci_set_power_state(pdev, 0);
pci_restore_state(pdev, adapter->pci_state);
pci_enable_wake(pdev, 0, 0);
/* Clear the wakeup status bits */
pci_enable_wake(pdev, 3, 0);
pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
e1000_reset(adapter);
E1000_WRITE_REG(&adapter->hw, WUS, ~0);
if(netif_running(netdev))
......
......@@ -96,6 +96,6 @@ typedef enum {
readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \
readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2)))
#define E1000_WRITE_FLUSH(a) ((void)E1000_READ_REG(a, STATUS))
#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
#endif /* _E1000_OSDEP_H_ */
......@@ -197,8 +197,7 @@ E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
#define MIN_RXD 80
#define MAX_82544_RXD 4096
#define DEFAULT_RDTR 128
#define DEFAULT_RDTR_82544 0
#define DEFAULT_RDTR 0
#define MAX_RXDELAY 0xFFFF
#define MIN_RXDELAY 0
......@@ -315,7 +314,8 @@ e1000_check_options(struct e1000_adapter *adapter)
};
struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.arg.r.max = mac_type < e1000_82544 ? MAX_TXD : MAX_82544_TXD;
opt.arg.r.max = mac_type < e1000_82544 ?
MAX_TXD : MAX_82544_TXD;
tx_ring->count = TxDescriptors[bd];
e1000_validate_option(&tx_ring->count, &opt);
......@@ -398,16 +398,13 @@ e1000_check_options(struct e1000_adapter *adapter)
}
{ /* Receive Interrupt Delay */
char *rdtr = "using default of " __MODULE_STRING(DEFAULT_RDTR);
char *rdtr_82544 = "using default of "
__MODULE_STRING(DEFAULT_RDTR_82544);
struct e1000_option opt = {
.type = range_option,
.name = "Receive Interrupt Delay",
.arg = { r: { min: MIN_RXDELAY, max: MAX_RXDELAY }}
};
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.def = mac_type > e1000_82544 ? DEFAULT_RDTR : 0;
opt.err = mac_type > e1000_82544 ? rdtr : rdtr_82544;
opt.def = DEFAULT_RDTR;
opt.err = rdtr;
adapter->rx_int_delay = RxIntDelay[bd];
e1000_validate_option(&adapter->rx_int_delay, &opt);
......
......@@ -132,7 +132,7 @@ e1000_proc_single_read(char *page, char **start, off_t off,
return e1000_proc_read(page, start, off, count, eof);
}
static void __devexit
static void
e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
{
struct proc_dir_entry *intel_proc_dir, *proc_dir;
......@@ -188,7 +188,7 @@ e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
}
static int __devinit
static int
e1000_proc_singles_create(struct proc_dir_entry *parent,
struct list_head *proc_list_head)
{
......@@ -215,7 +215,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent,
return 1;
}
static void __devinit
static void
e1000_proc_dirs_create(void *data, char *name,
struct list_head *proc_list_head)
{
......@@ -255,7 +255,7 @@ e1000_proc_dirs_create(void *data, char *name,
info_entry->data = proc_list_head;
}
static void __devinit
static void
e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
void *data, size_t len,
char *(*func)(void *, size_t, char *))
......@@ -274,7 +274,7 @@ e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
list_add_tail(&new->list, proc_list_head);
}
static void __devexit
static void
e1000_proc_list_free(struct list_head *proc_list_head)
{
struct proc_list *elem;
......@@ -542,7 +542,7 @@ e1000_proc_rx_status(void *data, size_t len, char *buf)
#define LIST_ADD_H(T,D) LIST_ADD_F((T), (D), e1000_proc_hex)
#define LIST_ADD_U(T,D) LIST_ADD_F((T), (D), e1000_proc_unsigned)
static void __devinit
static void
e1000_proc_list_setup(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
......@@ -572,7 +572,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
}
LIST_ADD_U("IRQ", &adapter->pdev->irq);
LIST_ADD_S("System_Device_Name", adapter->netdev->name);
LIST_ADD_S("System_Device_Name", adapter->ifname);
LIST_ADD_F("Current_HWaddr",
adapter->netdev->dev_addr, e1000_proc_hwaddr);
LIST_ADD_F("Permanent_HWaddr",
......@@ -670,13 +670,13 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
* @adapter: board private structure
*/
void __devinit
void
e1000_proc_dev_setup(struct e1000_adapter *adapter)
{
e1000_proc_list_setup(adapter);
e1000_proc_dirs_create(adapter,
adapter->netdev->name,
adapter->ifname,
&adapter->proc_list_head);
}
......@@ -685,18 +685,18 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter)
* @adapter: board private structure
*/
void __devexit
void
e1000_proc_dev_free(struct e1000_adapter *adapter)
{
e1000_proc_dirs_free(adapter->netdev->name, &adapter->proc_list_head);
e1000_proc_dirs_free(adapter->ifname, &adapter->proc_list_head);
e1000_proc_list_free(&adapter->proc_list_head);
}
#else /* CONFIG_PROC_FS */
void __devinit e1000_proc_dev_setup(struct e1000_adapter *adapter) {}
void __devexit e1000_proc_dev_free(struct e1000_adapter *adapter) {}
void e1000_proc_dev_setup(struct e1000_adapter *adapter) {}
void e1000_proc_dev_free(struct e1000_adapter *adapter) {}
#endif /* CONFIG_PROC_FS */
......@@ -65,7 +65,6 @@ static int multicast_filter_limit = 64;
e.g. "options=16" for FD, "options=32" for 100mbps-only. */
static int full_duplex[] = {-1, -1, -1, -1, -1, -1, -1, -1};
static int options[] = {-1, -1, -1, -1, -1, -1, -1, -1};
static int debug = -1; /* The debug level */
/* A few values that may be tweaked. */
/* The ring sizes should be a power of two for efficiency. */
......@@ -119,6 +118,16 @@ static int debug = -1; /* The debug level */
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
static int debug = -1;
#define DEBUG_DEFAULT (NETIF_MSG_DRV | \
NETIF_MSG_IFDOWN | \
NETIF_MSG_IFUP | \
NETIF_MSG_RX_ERR | \
NETIF_MSG_TX_ERR)
#define DEBUG ((debug >= 0) ? (1<<debug)-1 : DEBUG_DEFAULT)
MODULE_AUTHOR("Maintainer: Andrey V. Savochkin <saw@saw.sw.com.sg>");
MODULE_DESCRIPTION("Intel i82557/i82558/i82559 PCI EtherExpressPro driver");
......@@ -167,7 +176,6 @@ static inline int null_set_power_state(struct pci_dev *dev, int state)
} while(0)
static int speedo_debug = 1;
/*
Theory of Operation
......@@ -316,23 +324,11 @@ static inline void io_outw(unsigned int val, unsigned long port)
#define outl writel
#endif
/* How to wait for the command unit to accept a command.
Typically this takes 0 ticks. */
static inline void wait_for_cmd_done(long cmd_ioaddr)
{
int wait = 1000;
do udelay(1) ;
while(inb(cmd_ioaddr) && --wait >= 0);
#ifndef final_version
if (wait < 0)
printk(KERN_ALERT "eepro100: wait_for_cmd_done timeout!\n");
#endif
}
/* Offsets to the various registers.
All accesses need not be longword aligned. */
enum speedo_offsets {
SCBStatus = 0, SCBCmd = 2, /* Rx/Command Unit command and status. */
SCBIntmask = 3,
SCBPointer = 4, /* General purpose pointer. */
SCBPort = 8, /* Misc. commands and operands. */
SCBflash = 12, SCBeeprom = 14, /* EEPROM and flash memory control. */
......@@ -488,7 +484,6 @@ struct speedo_private {
unsigned char acpi_pwr;
signed char rx_mode; /* Current PROMISC/ALLMULTI setting. */
unsigned int tx_full:1; /* The Tx queue is full. */
unsigned int full_duplex:1; /* Full-duplex operation requested. */
unsigned int flow_ctrl:1; /* Use 802.3x flow control. */
unsigned int rx_bug:1; /* Work around receiver hang errata. */
unsigned char default_port:8; /* Last dev->if_port value. */
......@@ -496,6 +491,7 @@ struct speedo_private {
unsigned short phy[2]; /* PHY media interfaces available. */
unsigned short partner; /* Link partner caps. */
struct mii_if_info mii_if; /* MII API hooks, info */
u32 msg_enable; /* debug message level */
#ifdef CONFIG_PM
u32 pm_state[16];
#endif
......@@ -559,6 +555,26 @@ static int mii_ctrl[8] = { 0x3300, 0x3100, 0x0000, 0x0100,
0x2000, 0x2100, 0x0400, 0x3100};
#endif
/* How to wait for the command unit to accept a command.
Typically this takes 0 ticks. */
static inline unsigned char wait_for_cmd_done(struct net_device *dev)
{
int wait = 1000;
long cmd_ioaddr = dev->base_addr + SCBCmd;
unsigned char r;
do {
udelay(1);
r = inb(cmd_ioaddr);
} while(r && --wait >= 0);
#ifndef final_version
if (wait < 0)
printk(KERN_ALERT "%s: wait_for_cmd_done timeout!\n", dev->name);
#endif
return r;
}
static int __devinit eepro100_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent)
{
......@@ -567,9 +583,12 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
int acpi_idle_state = 0, pm;
static int cards_found /* = 0 */;
static int did_version /* = 0 */; /* Already printed version info. */
if (speedo_debug > 0 && did_version++ == 0)
#ifndef MODULE
/* when built-in, we only print version if device is found */
static int did_version;
if (did_version++ == 0)
printk(version);
#endif
/* save power state before pci_enable_device overwrites it */
pm = pci_find_capability(pdev, PCI_CAP_ID_PM);
......@@ -598,7 +617,7 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
irq = pdev->irq;
#ifdef USE_IO
ioaddr = pci_resource_start(pdev, 1);
if (speedo_debug > 2)
if (DEBUG & NETIF_MSG_PROBE)
printk("Found Intel i82557 PCI Speedo at I/O %#lx, IRQ %d.\n",
ioaddr, irq);
#else
......@@ -609,7 +628,7 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
pci_resource_len(pdev, 0), pci_resource_start(pdev, 0));
goto err_out_free_mmio_region;
}
if (speedo_debug > 2)
if (DEBUG & NETIF_MSG_PROBE)
printk("Found Intel i82557 PCI Speedo, MMIO at %#lx, IRQ %d.\n",
pci_resource_start(pdev, 0), irq);
#endif
......@@ -815,6 +834,7 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
sp = dev->priv;
sp->pdev = pdev;
sp->msg_enable = DEBUG;
sp->acpi_pwr = acpi_idle_state;
sp->tx_ring = tx_ring_space;
sp->tx_ring_dma = tx_ring_dma;
......@@ -960,7 +980,7 @@ speedo_open(struct net_device *dev)
long ioaddr = dev->base_addr;
int retval;
if (speedo_debug > 1)
if (netif_msg_ifup(sp))
printk(KERN_DEBUG "%s: speedo_open() irq %d.\n", dev->name, dev->irq);
pci_set_power_state(sp->pdev, 0);
......@@ -1017,12 +1037,9 @@ speedo_open(struct net_device *dev)
if ((sp->phy[0] & 0x8000) == 0)
sp->mii_if.advertising = mdio_read(dev, sp->phy[0] & 0x1f, MII_ADVERTISE);
if (mdio_read(dev, sp->phy[0] & 0x1f, MII_BMSR) & BMSR_LSTATUS)
netif_carrier_on(dev);
else
netif_carrier_off(dev);
mii_check_link(&sp->mii_if);
if (speedo_debug > 2) {
if (netif_msg_ifup(sp)) {
printk(KERN_DEBUG "%s: Done speedo_open(), status %8.8x.\n",
dev->name, inw(ioaddr + SCBStatus));
}
......@@ -1054,8 +1071,7 @@ static void speedo_resume(struct net_device *dev)
sp->tx_threshold = 0x01208000;
/* Set the segment registers to '0'. */
wait_for_cmd_done(ioaddr + SCBCmd);
if (inb(ioaddr + SCBCmd)) {
if (wait_for_cmd_done(dev) != 0) {
outl(PortPartialReset, ioaddr + SCBPort);
udelay(10);
}
......@@ -1074,10 +1090,10 @@ static void speedo_resume(struct net_device *dev)
outb(CUStatsAddr, ioaddr + SCBCmd);
sp->lstats->done_marker = 0;
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
if (sp->rx_ringp[sp->cur_rx % RX_RING_SIZE] == NULL) {
if (speedo_debug > 2)
if (netif_msg_rx_err(sp))
printk(KERN_DEBUG "%s: NULL cur_rx in speedo_resume().\n",
dev->name);
} else {
......@@ -1133,8 +1149,7 @@ speedo_rx_soft_reset(struct net_device *dev)
long ioaddr;
ioaddr = dev->base_addr;
wait_for_cmd_done(ioaddr + SCBCmd);
if (inb(ioaddr + SCBCmd) != 0) {
if (wait_for_cmd_done(dev) != 0) {
printk("%s: previous command stalled\n", dev->name);
return;
}
......@@ -1147,9 +1162,7 @@ speedo_rx_soft_reset(struct net_device *dev)
rfd->rx_buf_addr = 0xffffffff;
wait_for_cmd_done(ioaddr + SCBCmd);
if (inb(ioaddr + SCBCmd) != 0) {
if (wait_for_cmd_done(dev) != 0) {
printk("%s: RxAbort command stalled\n", dev->name);
return;
}
......@@ -1172,7 +1185,7 @@ static void speedo_timer(unsigned long data)
int partner = mdio_read(dev, phy_num, MII_LPA);
if (partner != sp->partner) {
int flow_ctrl = sp->mii_if.advertising & partner & 0x0400 ? 1 : 0;
if (speedo_debug > 2) {
if (netif_msg_link(sp)) {
printk(KERN_DEBUG "%s: Link status change.\n", dev->name);
printk(KERN_DEBUG "%s: Old partner %x, new %x, adv %x.\n",
dev->name, sp->partner, partner, sp->mii_if.advertising);
......@@ -1182,16 +1195,10 @@ static void speedo_timer(unsigned long data)
sp->flow_ctrl = flow_ctrl;
sp->rx_mode = -1; /* Trigger a reload. */
}
/* Clear sticky bit. */
mdio_read(dev, phy_num, MII_BMSR);
/* If link beat has returned... */
if (mdio_read(dev, phy_num, MII_BMSR) & BMSR_LSTATUS)
netif_carrier_on(dev);
else
netif_carrier_off(dev);
}
}
if (speedo_debug > 3) {
mii_check_link(&sp->mii_if);
if (netif_msg_timer(sp)) {
printk(KERN_DEBUG "%s: Media control tick, status %4.4x.\n",
dev->name, inw(ioaddr + SCBStatus));
}
......@@ -1200,7 +1207,7 @@ static void speedo_timer(unsigned long data)
/* We haven't received a packet in a Long Time. We might have been
bitten by the receiver hang bug. This can be cleared by sending
a set multicast list command. */
if (speedo_debug > 3)
if (netif_msg_rx_err(sp))
printk(KERN_DEBUG "%s: Sending a multicast list set command"
" from a timer routine,"
" m=%d, j=%ld, l=%ld.\n",
......@@ -1218,20 +1225,17 @@ static void speedo_show_state(struct net_device *dev)
int i;
/* Print a few items for debugging. */
if (speedo_debug > 0) {
int i;
printk(KERN_DEBUG "%s: Tx ring dump, Tx queue %u / %u:\n", dev->name,
sp->cur_tx, sp->dirty_tx);
for (i = 0; i < TX_RING_SIZE; i++)
printk(KERN_DEBUG "%s: %c%c%2d %8.8x.\n", dev->name,
i == sp->dirty_tx % TX_RING_SIZE ? '*' : ' ',
i == sp->cur_tx % TX_RING_SIZE ? '=' : ' ',
i, sp->tx_ring[i].status);
}
printk(KERN_DEBUG "%s: Tx ring dump, Tx queue %u / %u:\n", dev->name,
sp->cur_tx, sp->dirty_tx);
for (i = 0; i < TX_RING_SIZE; i++)
printk(KERN_DEBUG "%s: %c%c%2d %8.8x.\n", dev->name,
i == sp->dirty_tx % TX_RING_SIZE ? '*' : ' ',
i == sp->cur_tx % TX_RING_SIZE ? '=' : ' ',
i, sp->tx_ring[i].status);
printk(KERN_DEBUG "%s: Printing Rx ring"
" (next to receive into %u, dirty index %u).\n",
dev->name, sp->cur_rx, sp->dirty_rx);
for (i = 0; i < RX_RING_SIZE; i++)
printk(KERN_DEBUG "%s: %c%c%c%2d %8.8x.\n", dev->name,
sp->rx_ringp[i] == sp->last_rxf ? 'l' : ' ',
......@@ -1324,7 +1328,7 @@ static void speedo_purge_tx(struct net_device *dev)
}
while (sp->mc_setup_head != NULL) {
struct speedo_mc_block *t;
if (speedo_debug > 1)
if (netif_msg_tx_err(sp))
printk(KERN_DEBUG "%s: freeing mc frame.\n", dev->name);
pci_unmap_single(sp->pdev, sp->mc_setup_head->frame_dma,
sp->mc_setup_head->len, PCI_DMA_TODEVICE);
......@@ -1367,13 +1371,15 @@ static void speedo_tx_timeout(struct net_device *dev)
int status = inw(ioaddr + SCBStatus);
unsigned long flags;
printk(KERN_WARNING "%s: Transmit timed out: status %4.4x "
if (netif_msg_tx_err(sp)) {
printk(KERN_WARNING "%s: Transmit timed out: status %4.4x "
" %4.4x at %d/%d command %8.8x.\n",
dev->name, status, inw(ioaddr + SCBCmd),
sp->dirty_tx, sp->cur_tx,
sp->tx_ring[sp->dirty_tx % TX_RING_SIZE].status);
speedo_show_state(dev);
speedo_show_state(dev);
}
#if 0
if ((status & 0x00C0) != 0x0080
&& (status & 0x003C) == 0x0010) {
......@@ -1462,13 +1468,13 @@ speedo_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* workaround for hardware bug on 10 mbit half duplex */
if ((sp->partner == 0) && (sp->chip_id == 1)) {
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
outb(0 , ioaddr + SCBCmd);
udelay(1);
}
/* Trigger the command unit resume. */
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
clear_suspend(sp->last_cmd);
/* We want the time window between clearing suspend flag on the previous
command and resuming CU to be as small as possible.
......@@ -1500,14 +1506,14 @@ static void speedo_tx_buffer_gc(struct net_device *dev)
int entry = dirty_tx % TX_RING_SIZE;
int status = le32_to_cpu(sp->tx_ring[entry].status);
if (speedo_debug > 5)
if (netif_msg_tx_done(sp))
printk(KERN_DEBUG " scavenge candidate %d status %4.4x.\n",
entry, status);
if ((status & StatusComplete) == 0)
break; /* It still hasn't been processed. */
if (status & TxUnderrun)
if (sp->tx_threshold < 0x01e08000) {
if (speedo_debug > 2)
if (netif_msg_tx_err(sp))
printk(KERN_DEBUG "%s: TX underrun, threshold adjusted.\n",
dev->name);
sp->tx_threshold += 0x00040000;
......@@ -1525,7 +1531,7 @@ static void speedo_tx_buffer_gc(struct net_device *dev)
dirty_tx++;
}
if (speedo_debug && (int)(sp->cur_tx - dirty_tx) > TX_RING_SIZE) {
if (netif_msg_tx_err(sp) && (int)(sp->cur_tx - dirty_tx) > TX_RING_SIZE) {
printk(KERN_ERR "out-of-sync dirty pointer, %d vs. %d,"
" full=%d.\n",
dirty_tx, sp->cur_tx, sp->tx_full);
......@@ -1535,7 +1541,7 @@ static void speedo_tx_buffer_gc(struct net_device *dev)
while (sp->mc_setup_head != NULL
&& (int)(dirty_tx - sp->mc_setup_head->tx - 1) > 0) {
struct speedo_mc_block *t;
if (speedo_debug > 1)
if (netif_msg_tx_err(sp))
printk(KERN_DEBUG "%s: freeing mc frame.\n", dev->name);
pci_unmap_single(sp->pdev, sp->mc_setup_head->frame_dma,
sp->mc_setup_head->len, PCI_DMA_TODEVICE);
......@@ -1585,7 +1591,7 @@ static void speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
FCP and ER interrupts --Dragan */
outw(status & 0xfc00, ioaddr + SCBStatus);
if (speedo_debug > 4)
if (netif_msg_intr(sp))
printk(KERN_DEBUG "%s: interrupt status=%#4.4x.\n",
dev->name, status);
......@@ -1647,7 +1653,7 @@ static void speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
}
} while (1);
if (speedo_debug > 3)
if (netif_msg_intr(sp))
printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
dev->name, inw(ioaddr + SCBStatus));
......@@ -1708,7 +1714,7 @@ static int speedo_refill_rx_buf(struct net_device *dev, int force)
if (rxf == NULL) {
unsigned int forw;
int forw_entry;
if (speedo_debug > 2 || !(sp->rx_ring_state & RrOOMReported)) {
if (netif_msg_rx_err(sp) || !(sp->rx_ring_state & RrOOMReported)) {
printk(KERN_WARNING "%s: can't fill rx buffer (force %d)!\n",
dev->name, force);
speedo_show_state(dev);
......@@ -1754,8 +1760,9 @@ speedo_rx(struct net_device *dev)
int entry = sp->cur_rx % RX_RING_SIZE;
int rx_work_limit = sp->dirty_rx + RX_RING_SIZE - sp->cur_rx;
int alloc_ok = 1;
int npkts = 0;
if (speedo_debug > 4)
if (netif_msg_intr(sp))
printk(KERN_DEBUG " In speedo_rx().\n");
/* If we own the next entry, it's a new packet. Send it up. */
while (sp->rx_ringp[entry] != NULL) {
......@@ -1778,14 +1785,14 @@ speedo_rx(struct net_device *dev)
if (sp->last_rxf == sp->rx_ringp[entry]) {
/* Postpone the packet. It'll be reaped at an interrupt when this
packet is no longer the last packet in the ring. */
if (speedo_debug > 2)
if (netif_msg_rx_err(sp))
printk(KERN_DEBUG "%s: RX packet postponed!\n",
dev->name);
sp->rx_ring_state |= RrPostponed;
break;
}
if (speedo_debug > 4)
if (netif_msg_intr(sp))
printk(KERN_DEBUG " speedo_rx() status %8.8x len %d.\n", status,
pkt_len);
if ((status & (RxErrTooBig|RxOK|0x0f90)) != RxOK) {
......@@ -1820,6 +1827,7 @@ speedo_rx(struct net_device *dev)
memcpy(skb_put(skb, pkt_len), sp->rx_skbuff[entry]->tail,
pkt_len);
#endif
npkts++;
} else {
/* Pass up the already-filled skbuff. */
skb = sp->rx_skbuff[entry];
......@@ -1830,6 +1838,7 @@ speedo_rx(struct net_device *dev)
}
sp->rx_skbuff[entry] = NULL;
skb_put(skb, pkt_len);
npkts++;
sp->rx_ringp[entry] = NULL;
pci_unmap_single(sp->pdev, sp->rx_ring_dma[entry],
PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
......@@ -1851,7 +1860,8 @@ speedo_rx(struct net_device *dev)
/* Try hard to refill the recently taken buffers. */
speedo_refill_rx_buffers(dev, 1);
sp->last_rx_time = jiffies;
if (npkts)
sp->last_rx_time = jiffies;
return 0;
}
......@@ -1866,20 +1876,27 @@ speedo_close(struct net_device *dev)
netdevice_stop(dev);
netif_stop_queue(dev);
if (speedo_debug > 1)
if (netif_msg_ifdown(sp))
printk(KERN_DEBUG "%s: Shutting down ethercard, status was %4.4x.\n",
dev->name, inw(ioaddr + SCBStatus));
/* Shut off the media monitoring timer. */
del_timer_sync(&sp->timer);
outw(SCBMaskAll, ioaddr + SCBCmd);
/* Shutting down the chip nicely fails to disable flow control. So.. */
outl(PortPartialReset, ioaddr + SCBPort);
inl(ioaddr + SCBPort); /* flush posted write */
/*
* The chip requires a 10 microsecond quiet period. Wait here!
*/
udelay(10);
free_irq(dev->irq, dev);
/* Print a few items for debugging. */
if (speedo_debug > 3)
if (netif_msg_ifdown(sp))
speedo_show_state(dev);
/* Free all the skbuffs in the Rx and Tx queues. */
......@@ -1915,7 +1932,7 @@ speedo_close(struct net_device *dev)
sp->mc_setup_head = t;
}
sp->mc_setup_tail = NULL;
if (speedo_debug > 0)
if (netif_msg_ifdown(sp))
printk(KERN_DEBUG "%s: %d multicast blocks dropped.\n", dev->name, i);
pci_set_power_state(sp->pdev, 2);
......@@ -1956,7 +1973,7 @@ speedo_get_stats(struct net_device *dev)
/* Take a spinlock to make wait_for_cmd_done and sending the
command atomic. --SAW */
spin_lock_irqsave(&sp->lock, flags);
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
outb(CUDumpStats, ioaddr + SCBCmd);
spin_unlock_irqrestore(&sp->lock, flags);
}
......@@ -2018,6 +2035,22 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
return -EFAULT;
return 0;
}
/* get message-level */
case ETHTOOL_GMSGLVL: {
struct ethtool_value edata = {ETHTOOL_GMSGLVL};
edata.data = sp->msg_enable;
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
}
/* set message-level */
case ETHTOOL_SMSGLVL: {
struct ethtool_value edata;
if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;
sp->msg_enable = edata.data;
return 0;
}
}
......@@ -2092,7 +2125,7 @@ static void set_rx_mode(struct net_device *dev)
} else
new_rx_mode = 0;
if (speedo_debug > 3)
if (netif_msg_rx_status(sp))
printk(KERN_DEBUG "%s: set_rx_mode %d -> %d\n", dev->name,
sp->rx_mode, new_rx_mode);
......@@ -2133,7 +2166,7 @@ static void set_rx_mode(struct net_device *dev)
config_cmd_data[8] = 0;
}
/* Trigger the command unit resume. */
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
clear_suspend(last_cmd);
outb(CUResume, ioaddr + SCBCmd);
if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
......@@ -2170,7 +2203,7 @@ static void set_rx_mode(struct net_device *dev)
*setup_params++ = *eaddrs++;
}
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
clear_suspend(last_cmd);
/* Immediately trigger the command unit resume. */
outb(CUResume, ioaddr + SCBCmd);
......@@ -2203,7 +2236,7 @@ static void set_rx_mode(struct net_device *dev)
mc_setup_frm = &mc_blk->frame;
/* Fill the setup frame. */
if (speedo_debug > 1)
if (netif_msg_ifup(sp))
printk(KERN_DEBUG "%s: Constructing a setup frame at %p.\n",
dev->name, mc_setup_frm);
mc_setup_frm->cmd_status =
......@@ -2246,7 +2279,7 @@ static void set_rx_mode(struct net_device *dev)
pci_dma_sync_single(sp->pdev, mc_blk->frame_dma,
mc_blk->len, PCI_DMA_TODEVICE);
wait_for_cmd_done(ioaddr + SCBCmd);
wait_for_cmd_done(dev);
clear_suspend(last_cmd);
/* Immediately trigger the command unit resume. */
outb(CUResume, ioaddr + SCBCmd);
......@@ -2257,7 +2290,7 @@ static void set_rx_mode(struct net_device *dev)
}
spin_unlock_irqrestore(&sp->lock, flags);
if (speedo_debug > 5)
if (netif_msg_rx_status(sp))
printk(" CmdMCSetup frame length %d in entry %d.\n",
dev->mc_count, entry);
}
......@@ -2400,11 +2433,9 @@ static int pci_module_init(struct pci_driver *pdev)
static int __init eepro100_init_module(void)
{
if (debug >= 0 && speedo_debug != debug)
printk(KERN_INFO "eepro100.c: Debug level is %d.\n", debug);
if (debug >= 0)
speedo_debug = debug;
#ifdef MODULE
printk(version);
#endif
return pci_module_init(&eepro100_driver);
}
......
......@@ -192,9 +192,12 @@ int mii_nway_restart (struct mii_if_info *mii)
void mii_check_link (struct mii_if_info *mii)
{
if (mii_link_ok(mii))
int cur_link = mii_link_ok(mii);
int prev_link = netif_carrier_ok(mii->dev);
if (cur_link && !prev_link)
netif_carrier_on(mii->dev);
else
else if (prev_link && !cur_link)
netif_carrier_off(mii->dev);
}
......
......@@ -184,7 +184,7 @@
NETIF_MSG_WOL | \
NETIF_MSG_RX_ERR | \
NETIF_MSG_TX_ERR)
static int debug = NATSEMI_DEF_MSG;
static int debug = -1;
/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
static int max_interrupt_work = 20;
......@@ -256,7 +256,7 @@ MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
MODULE_PARM_DESC(max_interrupt_work,
"DP8381x maximum events handled per interrupt");
MODULE_PARM_DESC(mtu, "DP8381x MTU (all boards)");
MODULE_PARM_DESC(debug, "DP8381x default debug bitmask");
MODULE_PARM_DESC(debug, "DP8381x default debug level");
MODULE_PARM_DESC(rx_copybreak,
"DP8381x copy breakpoint for copy-only-tiny-frames");
MODULE_PARM_DESC(options,
......@@ -796,7 +796,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
pci_set_drvdata(pdev, dev);
np->iosize = iosize;
spin_lock_init(&np->lock);
np->msg_enable = debug;
np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
np->hands_off = 0;
/* Reset the chip to erase previous misconfiguration. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment