Commit ab5ad357 authored by Scott Feldman's avatar Scott Feldman Committed by Jeff Garzik

[netdrvr e100] copyright + trailing blanks + misc

* Misc: 2004 copyright, remove trailing white space, remove some
  unused symbols.
parent 0b69e32d
/******************************************************************************* /*******************************************************************************
Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free under the terms of the GNU General Public License as published by the Free
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*******************************************************************************/ *******************************************************************************/
/* /*
* e100.c: Intel(R) PRO/100 ethernet driver * e100.c: Intel(R) PRO/100 ethernet driver
* *
* (Re)written 2003 by scott.feldman@intel.com. Based loosely on * (Re)written 2003 by scott.feldman@intel.com. Based loosely on
* original e100 driver, but better described as a munging of * original e100 driver, but better described as a munging of
...@@ -65,11 +65,11 @@ ...@@ -65,11 +65,11 @@
* through the Management Data Interface (MDI). Consequently, the * through the Management Data Interface (MDI). Consequently, the
* driver leverages the mii.c library shared with other MII-compliant * driver leverages the mii.c library shared with other MII-compliant
* devices. * devices.
* *
* Big- and Little-Endian byte order as well as 32- and 64-bit * Big- and Little-Endian byte order as well as 32- and 64-bit
* archs are supported. Weak-ordered memory and non-cache-coherent * archs are supported. Weak-ordered memory and non-cache-coherent
* archs are supported. * archs are supported.
* *
* III. Transmit * III. Transmit
* *
* A Tx skb is mapped and hangs off of a TCB. TCBs are linked * A Tx skb is mapped and hangs off of a TCB. TCBs are linked
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
* Non-Tx commands (config, multicast setup, etc) are linked * Non-Tx commands (config, multicast setup, etc) are linked
* into the CBL ring along with Tx commands. The common structure * into the CBL ring along with Tx commands. The common structure
* used for both Tx and non-Tx commands is the Command Block (CB). * used for both Tx and non-Tx commands is the Command Block (CB).
* *
* cb_to_use is the next CB to use for queuing a command; cb_to_clean * cb_to_use is the next CB to use for queuing a command; cb_to_clean
* is the next CB to check for completion; cb_to_send is the first * is the next CB to check for completion; cb_to_send is the first
* CB to start on in case of a previous failure to resume. CB clean * CB to start on in case of a previous failure to resume. CB clean
...@@ -101,14 +101,14 @@ ...@@ -101,14 +101,14 @@
* Descriptors (RFD) + data buffer, thus forming the simplified mode * Descriptors (RFD) + data buffer, thus forming the simplified mode
* memory structure. Rx skbs are allocated to contain both the RFD * memory structure. Rx skbs are allocated to contain both the RFD
* and the data buffer, but the RFD is pulled off before the skb is * and the data buffer, but the RFD is pulled off before the skb is
* indicated. The data buffer is aligned such that encapsulated * indicated. The data buffer is aligned such that encapsulated
* protocol headers are u32-aligned. Since the RFD is part of the * protocol headers are u32-aligned. Since the RFD is part of the
* mapped shared memory, and completion status is contained within * mapped shared memory, and completion status is contained within
* the RFD, the RFD must be dma_sync'ed to maintain a consistent * the RFD, the RFD must be dma_sync'ed to maintain a consistent
* view from software and hardware. * view from software and hardware.
* *
* Under typical operation, the receive unit (RU) is start once, * Under typical operation, the receive unit (RU) is start once,
* and the controller happily fills RFDs as frames arrive. If * and the controller happily fills RFDs as frames arrive. If
* replacement RFDs cannot be allocated, or the RU goes non-active, * replacement RFDs cannot be allocated, or the RU goes non-active,
* the RU must be restarted. Frame arrival generates an interrupt, * the RU must be restarted. Frame arrival generates an interrupt,
* and Rx indication and re-allocation happen in the same context, * and Rx indication and re-allocation happen in the same context,
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
* *
* MagicPacket(tm) WoL support is enabled/disabled via ethtool. * MagicPacket(tm) WoL support is enabled/disabled via ethtool.
* *
* Thanks to JC (jchapman@katalix.com) for helping with * Thanks to JC (jchapman@katalix.com) for helping with
* testing/troubleshooting the development driver. * testing/troubleshooting the development driver.
*/ */
...@@ -154,9 +154,9 @@ ...@@ -154,9 +154,9 @@
#define DRV_NAME "e100" #define DRV_NAME "e100"
#define DRV_VERSION "3.0.12_dev" #define DRV_VERSION "3.0.13_dev"
#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
#define DRV_COPYRIGHT "Copyright(c) 1999-2003 Intel Corporation" #define DRV_COPYRIGHT "Copyright(c) 1999-2004 Intel Corporation"
#define PFX DRV_NAME ": " #define PFX DRV_NAME ": "
#define E100_WATCHDOG_PERIOD 2 * HZ #define E100_WATCHDOG_PERIOD 2 * HZ
...@@ -233,9 +233,9 @@ enum mac { ...@@ -233,9 +233,9 @@ enum mac {
enum phy { enum phy {
phy_100a = 0x000003E0, phy_100a = 0x000003E0,
phy_100c = 0x035002A8, phy_100c = 0x035002A8,
phy_82555_tx = 0x015002A8, phy_82555_tx = 0x015002A8,
phy_nsc_tx = 0x5C002000, phy_nsc_tx = 0x5C002000,
phy_82562_et = 0x033002A8, phy_82562_et = 0x033002A8,
phy_82562_em = 0x032002A8, phy_82562_em = 0x032002A8,
phy_82562_eh = 0x017002A8, phy_82562_eh = 0x017002A8,
...@@ -260,15 +260,8 @@ struct csr { ...@@ -260,15 +260,8 @@ struct csr {
}; };
enum scb_status { enum scb_status {
rus_idle = 0x00,
rus_suspended = 0x04,
rus_no_resources = 0x08,
rus_ready = 0x10, rus_ready = 0x10,
rus_mask = 0x3C, rus_mask = 0x3C,
cus_idle = 0x00,
cus_suspended = 0x40,
cus_active = 0x80,
cus_mask = 0xC0,
}; };
enum scb_stat_ack { enum scb_stat_ack {
...@@ -517,7 +510,7 @@ struct nic { ...@@ -517,7 +510,7 @@ struct nic {
multicast_all = (1 << 2), multicast_all = (1 << 2),
wol_magic = (1 << 3), wol_magic = (1 << 3),
} flags ____cacheline_aligned; } flags ____cacheline_aligned;
enum mac mac; enum mac mac;
enum phy phy; enum phy phy;
struct params params; struct params params;
...@@ -544,7 +537,7 @@ struct nic { ...@@ -544,7 +537,7 @@ struct nic {
u32 rx_fc_pause; u32 rx_fc_pause;
u32 rx_fc_unsupported; u32 rx_fc_unsupported;
u32 rx_tco_frames; u32 rx_tco_frames;
u8 rev_id; u8 rev_id;
u16 leds; u16 leds;
u16 eeprom_wc; u16 eeprom_wc;
...@@ -577,14 +570,14 @@ static void e100_hw_reset(struct nic *nic) ...@@ -577,14 +570,14 @@ static void e100_hw_reset(struct nic *nic)
* device off of PCI bus */ * device off of PCI bus */
writel(selective_reset, &nic->csr->port); writel(selective_reset, &nic->csr->port);
e100_write_flush(nic); udelay(20); e100_write_flush(nic); udelay(20);
/* Now fully reset device */ /* Now fully reset device */
writel(software_reset, &nic->csr->port); writel(software_reset, &nic->csr->port);
e100_write_flush(nic); udelay(20); e100_write_flush(nic); udelay(20);
/* TCO workaround - 82559 and greater */ /* TCO workaround - 82559 and greater */
if(nic->mac >= mac_82559_D101M) { if(nic->mac >= mac_82559_D101M) {
/* Issue a redundant CU load base without setting /* Issue a redundant CU load base without setting
* general pointer, and without waiting for scb to * general pointer, and without waiting for scb to
* clear. This gets us into post-driver. Finally, * clear. This gets us into post-driver. Finally,
* wait 20 msec for reset to take effect. */ * wait 20 msec for reset to take effect. */
...@@ -712,7 +705,7 @@ static int e100_eeprom_load(struct nic *nic) ...@@ -712,7 +705,7 @@ static int e100_eeprom_load(struct nic *nic)
/* Try reading with an 8-bit addr len to discover actual addr len */ /* Try reading with an 8-bit addr len to discover actual addr len */
e100_eeprom_read(nic, &addr_len, 0); e100_eeprom_read(nic, &addr_len, 0);
nic->eeprom_wc = 1 << addr_len; nic->eeprom_wc = 1 << addr_len;
for(addr = 0; addr < nic->eeprom_wc; addr++) { for(addr = 0; addr < nic->eeprom_wc; addr++) {
nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr); nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr);
if(addr < nic->eeprom_wc - 1) if(addr < nic->eeprom_wc - 1)
...@@ -726,7 +719,7 @@ static int e100_eeprom_load(struct nic *nic) ...@@ -726,7 +719,7 @@ static int e100_eeprom_load(struct nic *nic)
DPRINTK(PROBE, ERR, "EEPROM corrupted\n"); DPRINTK(PROBE, ERR, "EEPROM corrupted\n");
return -EAGAIN; return -EAGAIN;
} }
return 0; return 0;
} }
...@@ -738,10 +731,10 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count) ...@@ -738,10 +731,10 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
/* Try reading with an 8-bit addr len to discover actual addr len */ /* Try reading with an 8-bit addr len to discover actual addr len */
e100_eeprom_read(nic, &addr_len, 0); e100_eeprom_read(nic, &addr_len, 0);
nic->eeprom_wc = 1 << addr_len; nic->eeprom_wc = 1 << addr_len;
if(start + count >= nic->eeprom_wc) if(start + count >= nic->eeprom_wc)
return -EINVAL; return -EINVAL;
for(addr = start; addr < start + count; addr++) for(addr = start; addr < start + count; addr++)
e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]); e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]);
...@@ -810,7 +803,7 @@ static inline int e100_exec_cb(struct nic *nic, struct sk_buff *skb, ...@@ -810,7 +803,7 @@ static inline int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
err = -ENOSPC; err = -ENOSPC;
cb_prepare(nic, cb, skb); cb_prepare(nic, cb, skb);
/* Order is important otherwise we'll be in a race with h/w: /* Order is important otherwise we'll be in a race with h/w:
* set S-bit in current first, then clear S-bit in previous. */ * set S-bit in current first, then clear S-bit in previous. */
cb->command |= cpu_to_le16(cb_s); cb->command |= cpu_to_le16(cb_s);
...@@ -849,7 +842,7 @@ static u16 mdio_ctrl(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data) ...@@ -849,7 +842,7 @@ static u16 mdio_ctrl(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data)
if((data_out = readl(&nic->csr->mdi_ctrl)) & mdi_ready) if((data_out = readl(&nic->csr->mdi_ctrl)) & mdi_ready)
break; break;
} }
DPRINTK(HW, DEBUG, DPRINTK(HW, DEBUG,
"%s:addr=%d, reg=%d, data_in=0x%04X, data_out=0x%04X\n", "%s:addr=%d, reg=%d, data_in=0x%04X, data_out=0x%04X\n",
dir == mdi_read ? "READ" : "WRITE", addr, reg, data, data_out); dir == mdi_read ? "READ" : "WRITE", addr, reg, data, data_out);
...@@ -877,9 +870,9 @@ static void e100_get_defaults(struct nic *nic) ...@@ -877,9 +870,9 @@ static void e100_get_defaults(struct nic *nic)
if(nic->mac == mac_unknown) if(nic->mac == mac_unknown)
nic->mac = mac_82557_D100_A; nic->mac = mac_82557_D100_A;
nic->params.rfds = rfds; nic->params.rfds = rfds;
nic->params.cbs = cbs; nic->params.cbs = cbs;
/* Quadwords to DMA into FIFO before starting frame transmit */ /* Quadwords to DMA into FIFO before starting frame transmit */
nic->tx_threshold = 0xE0; nic->tx_threshold = 0xE0;
...@@ -905,9 +898,9 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) ...@@ -905,9 +898,9 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
u8 *c = (u8 *)config; u8 *c = (u8 *)config;
cb->command = cpu_to_le16(cb_config); cb->command = cpu_to_le16(cb_config);
memset(config, 0, sizeof(struct config)); memset(config, 0, sizeof(struct config));
config->byte_count = 0x16; /* bytes in this struct */ config->byte_count = 0x16; /* bytes in this struct */
config->rx_fifo_limit = 0x8; /* bytes in FIFO before DMA */ config->rx_fifo_limit = 0x8; /* bytes in FIFO before DMA */
config->direct_rx_dma = 0x1; /* reserved */ config->direct_rx_dma = 0x1; /* reserved */
...@@ -938,7 +931,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) ...@@ -938,7 +931,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
if(nic->mii.force_media && nic->mii.full_duplex) if(nic->mii.force_media && nic->mii.full_duplex)
config->full_duplex_force = 0x1; /* 1=force, 0=auto */ config->full_duplex_force = 0x1; /* 1=force, 0=auto */
if(nic->flags & promiscuous || nic->loopback) { if(nic->flags & promiscuous || nic->loopback) {
config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */ config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */
config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */ config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */
...@@ -947,7 +940,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) ...@@ -947,7 +940,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
if(nic->flags & multicast_all) if(nic->flags & multicast_all)
config->multicast_all = 0x1; /* 1=accept, 0=no */ config->multicast_all = 0x1; /* 1=accept, 0=no */
if(!(nic->flags & wol_magic)) if(!(nic->flags & wol_magic))
config->magic_packet_disable = 0x1; /* 1=off, 0=on */ config->magic_packet_disable = 0x1; /* 1=off, 0=on */
...@@ -961,7 +954,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) ...@@ -961,7 +954,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
else else
config->standard_stat_counter = 0x0; config->standard_stat_counter = 0x0;
} }
DPRINTK(HW, DEBUG, "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", DPRINTK(HW, DEBUG, "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
DPRINTK(HW, DEBUG, "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", DPRINTK(HW, DEBUG, "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
...@@ -1007,7 +1000,7 @@ static int e100_phy_init(struct nic *nic) ...@@ -1007,7 +1000,7 @@ static int e100_phy_init(struct nic *nic)
DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id); DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id);
if(addr == 32) if(addr == 32)
return -EAGAIN; return -EAGAIN;
/* Selected the phy and isolate the rest */ /* Selected the phy and isolate the rest */
for(addr = 0; addr < 32; addr++) { for(addr = 0; addr < 32; addr++) {
if(addr != nic->mii.phy_id) { if(addr != nic->mii.phy_id) {
...@@ -1018,13 +1011,13 @@ static int e100_phy_init(struct nic *nic) ...@@ -1018,13 +1011,13 @@ static int e100_phy_init(struct nic *nic)
bmcr & ~BMCR_ISOLATE); bmcr & ~BMCR_ISOLATE);
} }
} }
/* Get phy ID */ /* Get phy ID */
id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1); id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);
id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2); id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2);
nic->phy = (u32)id_hi << 16 | (u32)id_lo; nic->phy = (u32)id_hi << 16 | (u32)id_lo;
DPRINTK(HW, DEBUG, "phy ID = 0x%08X\n", nic->phy); DPRINTK(HW, DEBUG, "phy ID = 0x%08X\n", nic->phy);
/* Handle National tx phy */ /* Handle National tx phy */
if(nic->phy == phy_nsc_tx) { if(nic->phy == phy_nsc_tx) {
/* Disable congestion control */ /* Disable congestion control */
...@@ -1033,7 +1026,7 @@ static int e100_phy_init(struct nic *nic) ...@@ -1033,7 +1026,7 @@ static int e100_phy_init(struct nic *nic)
cong &= ~NSC_CONG_ENABLE; cong &= ~NSC_CONG_ENABLE;
mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong); mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong);
} }
if(nic->mac >= mac_82550_D102) if(nic->mac >= mac_82550_D102)
/* enable/disable MDI/MDI-X auto-switching */ /* enable/disable MDI/MDI-X auto-switching */
mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG,
...@@ -1045,7 +1038,7 @@ static int e100_phy_init(struct nic *nic) ...@@ -1045,7 +1038,7 @@ static int e100_phy_init(struct nic *nic)
static int e100_hw_init(struct nic *nic) static int e100_hw_init(struct nic *nic)
{ {
int err; int err;
e100_hw_reset(nic); e100_hw_reset(nic);
DPRINTK(HW, ERR, "e100_hw_init\n"); DPRINTK(HW, ERR, "e100_hw_init\n");
...@@ -1062,7 +1055,7 @@ static int e100_hw_init(struct nic *nic) ...@@ -1062,7 +1055,7 @@ static int e100_hw_init(struct nic *nic)
return err; return err;
if((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr))) if((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr)))
return err; return err;
if((err = e100_exec_cmd(nic, cuc_dump_addr, if((err = e100_exec_cmd(nic, cuc_dump_addr,
nic->dma_addr + offsetof(struct mem, stats)))) nic->dma_addr + offsetof(struct mem, stats))))
return err; return err;
if((err = e100_exec_cmd(nic, cuc_dump_reset, 0))) if((err = e100_exec_cmd(nic, cuc_dump_reset, 0)))
...@@ -1117,7 +1110,7 @@ static void e100_update_stats(struct nic *nic) ...@@ -1117,7 +1110,7 @@ static void e100_update_stats(struct nic *nic)
&s->complete; &s->complete;
/* Device's stats reporting may take several microseconds to /* Device's stats reporting may take several microseconds to
* complete, so where always waiting for results of the * complete, so where always waiting for results of the
* previous command. */ * previous command. */
if(*complete == le32_to_cpu(0x0000A007)) { if(*complete == le32_to_cpu(0x0000A007)) {
...@@ -1203,10 +1196,10 @@ static void e100_watchdog(unsigned long data) ...@@ -1203,10 +1196,10 @@ static void e100_watchdog(unsigned long data)
} else if(!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { } else if(!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) {
DPRINTK(LINK, INFO, "link down\n"); DPRINTK(LINK, INFO, "link down\n");
} }
mii_check_link(&nic->mii); mii_check_link(&nic->mii);
/* Software generated interrupt to recover from (rare) Rx /* Software generated interrupt to recover from (rare) Rx
* allocation failure */ * allocation failure */
writeb(irq_sw_gen, &nic->csr->scb.cmd_hi); writeb(irq_sw_gen, &nic->csr->scb.cmd_hi);
e100_write_flush(nic); e100_write_flush(nic);
...@@ -1269,7 +1262,7 @@ static inline int e100_tx_clean(struct nic *nic) ...@@ -1269,7 +1262,7 @@ static inline int e100_tx_clean(struct nic *nic)
for(cb = nic->cb_to_clean; for(cb = nic->cb_to_clean;
cb->status & cpu_to_le16(cb_complete); cb->status & cpu_to_le16(cb_complete);
cb = nic->cb_to_clean = cb->next) { cb = nic->cb_to_clean = cb->next) {
if(likely(cb->skb != NULL)) { if(likely(cb->skb)) {
nic->net_stats.tx_packets++; nic->net_stats.tx_packets++;
nic->net_stats.tx_bytes += cb->skb->len; nic->net_stats.tx_bytes += cb->skb->len;
...@@ -1283,7 +1276,7 @@ static inline int e100_tx_clean(struct nic *nic) ...@@ -1283,7 +1276,7 @@ static inline int e100_tx_clean(struct nic *nic)
cb->status = 0; cb->status = 0;
nic->cbs_avail++; nic->cbs_avail++;
} }
spin_unlock(&nic->cb_lock); spin_unlock(&nic->cb_lock);
/* Recover from running out of Tx resources in xmit_frame */ /* Recover from running out of Tx resources in xmit_frame */
...@@ -1293,7 +1286,7 @@ static inline int e100_tx_clean(struct nic *nic) ...@@ -1293,7 +1286,7 @@ static inline int e100_tx_clean(struct nic *nic)
return tx_cleaned; return tx_cleaned;
} }
static void e100_clean_cbs(struct nic *nic, int free_mem) static void e100_clean_cbs(struct nic *nic)
{ {
if(nic->cbs) { if(nic->cbs) {
while(nic->cb_to_clean != nic->cb_to_use) { while(nic->cb_to_clean != nic->cb_to_use) {
...@@ -1308,13 +1301,11 @@ static void e100_clean_cbs(struct nic *nic, int free_mem) ...@@ -1308,13 +1301,11 @@ static void e100_clean_cbs(struct nic *nic, int free_mem)
nic->cb_to_clean = nic->cb_to_clean->next; nic->cb_to_clean = nic->cb_to_clean->next;
} }
nic->cbs_avail = nic->params.cbs.count; nic->cbs_avail = nic->params.cbs.count;
if(free_mem) { pci_free_consistent(nic->pdev,
pci_free_consistent(nic->pdev, sizeof(struct cb) * nic->params.cbs.count,
sizeof(struct cb) * nic->params.cbs.count, nic->cbs, nic->cbs_dma_addr);
nic->cbs, nic->cbs_dma_addr); nic->cbs = NULL;
nic->cbs = NULL; nic->cbs_avail = 0;
nic->cbs_avail = 0;
}
} }
nic->cuc_cmd = cuc_start; nic->cuc_cmd = cuc_start;
nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean =
...@@ -1325,25 +1316,25 @@ static int e100_alloc_cbs(struct nic *nic) ...@@ -1325,25 +1316,25 @@ static int e100_alloc_cbs(struct nic *nic)
{ {
struct cb *cb; struct cb *cb;
unsigned int i, count = nic->params.cbs.count; unsigned int i, count = nic->params.cbs.count;
nic->cuc_cmd = cuc_start; nic->cuc_cmd = cuc_start;
nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL; nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL;
nic->cbs_avail = 0; nic->cbs_avail = 0;
nic->cbs = pci_alloc_consistent(nic->pdev, nic->cbs = pci_alloc_consistent(nic->pdev,
sizeof(struct cb) * count, &nic->cbs_dma_addr); sizeof(struct cb) * count, &nic->cbs_dma_addr);
if(!nic->cbs) if(!nic->cbs)
return -ENOMEM; return -ENOMEM;
for(cb = nic->cbs, i = 0; i < count; cb++, i++) { for(cb = nic->cbs, i = 0; i < count; cb++, i++) {
cb->next = (i + 1 < count) ? cb + 1 : nic->cbs; cb->next = (i + 1 < count) ? cb + 1 : nic->cbs;
cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1; cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1;
cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb); cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb);
cb->link = cpu_to_le32(nic->cbs_dma_addr + cb->link = cpu_to_le32(nic->cbs_dma_addr +
((i+1) % count) * sizeof(struct cb)); ((i+1) % count) * sizeof(struct cb));
} }
nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs; nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs;
nic->cbs_avail = count; nic->cbs_avail = count;
...@@ -1617,7 +1608,7 @@ static int e100_asf(struct nic *nic) ...@@ -1617,7 +1608,7 @@ static int e100_asf(struct nic *nic)
!(nic->eeprom[eeprom_config_asf] & eeprom_gcl) && !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE)); ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE));
} }
static int e100_up(struct nic *nic) static int e100_up(struct nic *nic)
{ {
int err; int err;
...@@ -1642,7 +1633,7 @@ static int e100_up(struct nic *nic) ...@@ -1642,7 +1633,7 @@ static int e100_up(struct nic *nic)
del_timer_sync(&nic->watchdog); del_timer_sync(&nic->watchdog);
netif_stop_queue(nic->netdev); netif_stop_queue(nic->netdev);
err_clean_cbs: err_clean_cbs:
e100_clean_cbs(nic, 1); e100_clean_cbs(nic);
err_rx_clean_list: err_rx_clean_list:
e100_rx_clean_list(nic); e100_rx_clean_list(nic);
return err; return err;
...@@ -1655,7 +1646,7 @@ static void e100_down(struct nic *nic) ...@@ -1655,7 +1646,7 @@ static void e100_down(struct nic *nic)
del_timer_sync(&nic->watchdog); del_timer_sync(&nic->watchdog);
netif_carrier_off(nic->netdev); netif_carrier_off(nic->netdev);
netif_stop_queue(nic->netdev); netif_stop_queue(nic->netdev);
e100_clean_cbs(nic, 1); e100_clean_cbs(nic);
e100_rx_clean_list(nic); e100_rx_clean_list(nic);
} }
...@@ -1697,7 +1688,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) ...@@ -1697,7 +1688,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
BMCR_LOOPBACK); BMCR_LOOPBACK);
e100_start_receiver(nic); e100_start_receiver(nic);
if(!(skb = dev_alloc_skb(ETH_DATA_LEN))) { if(!(skb = dev_alloc_skb(ETH_DATA_LEN))) {
err = -ENOMEM; err = -ENOMEM;
goto err_loopback_none; goto err_loopback_none;
...@@ -1717,7 +1708,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) ...@@ -1717,7 +1708,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 0); mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 0);
nic->loopback = lb_none; nic->loopback = lb_none;
e100_hw_init(nic); e100_hw_init(nic);
e100_clean_cbs(nic, 1); e100_clean_cbs(nic);
err_clean_rx: err_clean_rx:
e100_rx_clean_list(nic); e100_rx_clean_list(nic);
return err; return err;
...@@ -1745,7 +1736,7 @@ static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) ...@@ -1745,7 +1736,7 @@ static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
return mii_ethtool_gset(&nic->mii, cmd); return mii_ethtool_gset(&nic->mii, cmd);
} }
static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd) static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
...@@ -1757,7 +1748,7 @@ static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd) ...@@ -1757,7 +1748,7 @@ static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
return err; return err;
} }
static void e100_get_drvinfo(struct net_device *netdev, static void e100_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
...@@ -1767,7 +1758,7 @@ static void e100_get_drvinfo(struct net_device *netdev, ...@@ -1767,7 +1758,7 @@ static void e100_get_drvinfo(struct net_device *netdev,
strcpy(info->fw_version, "N/A"); strcpy(info->fw_version, "N/A");
strcpy(info->bus_info, pci_name(nic->pdev)); strcpy(info->bus_info, pci_name(nic->pdev));
} }
static int e100_get_regs_len(struct net_device *netdev) static int e100_get_regs_len(struct net_device *netdev)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
...@@ -1805,11 +1796,11 @@ static void e100_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) ...@@ -1805,11 +1796,11 @@ static void e100_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
wol->supported = (nic->mac >= mac_82558_D101_A4) ? WAKE_MAGIC : 0; wol->supported = (nic->mac >= mac_82558_D101_A4) ? WAKE_MAGIC : 0;
wol->wolopts = (nic->flags & wol_magic) ? WAKE_MAGIC : 0; wol->wolopts = (nic->flags & wol_magic) ? WAKE_MAGIC : 0;
} }
static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
if(wol->wolopts != WAKE_MAGIC && wol->wolopts != 0) if(wol->wolopts != WAKE_MAGIC && wol->wolopts != 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1820,22 +1811,22 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) ...@@ -1820,22 +1811,22 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
pci_enable_wake(nic->pdev, 0, nic->flags & (wol_magic | e100_asf(nic))); pci_enable_wake(nic->pdev, 0, nic->flags & (wol_magic | e100_asf(nic)));
e100_exec_cb(nic, NULL, e100_configure); e100_exec_cb(nic, NULL, e100_configure);
return 0; return 0;
} }
static u32 e100_get_msglevel(struct net_device *netdev) static u32 e100_get_msglevel(struct net_device *netdev)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
return nic->msg_enable; return nic->msg_enable;
} }
static void e100_set_msglevel(struct net_device *netdev, u32 value) static void e100_set_msglevel(struct net_device *netdev, u32 value)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
nic->msg_enable = value; nic->msg_enable = value;
} }
static int e100_nway_reset(struct net_device *netdev) static int e100_nway_reset(struct net_device *netdev)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
...@@ -1847,7 +1838,7 @@ static u32 e100_get_link(struct net_device *netdev) ...@@ -1847,7 +1838,7 @@ static u32 e100_get_link(struct net_device *netdev)
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
return mii_link_ok(&nic->mii); return mii_link_ok(&nic->mii);
} }
static int e100_get_eeprom_len(struct net_device *netdev) static int e100_get_eeprom_len(struct net_device *netdev)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
...@@ -1859,7 +1850,7 @@ static int e100_get_eeprom(struct net_device *netdev, ...@@ -1859,7 +1850,7 @@ static int e100_get_eeprom(struct net_device *netdev,
struct ethtool_eeprom *eeprom, u8 *bytes) struct ethtool_eeprom *eeprom, u8 *bytes)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
eeprom->magic = E100_EEPROM_MAGIC; eeprom->magic = E100_EEPROM_MAGIC;
memcpy(bytes, &((u8 *)nic->eeprom)[eeprom->offset], eeprom->len); memcpy(bytes, &((u8 *)nic->eeprom)[eeprom->offset], eeprom->len);
...@@ -1870,7 +1861,7 @@ static int e100_set_eeprom(struct net_device *netdev, ...@@ -1870,7 +1861,7 @@ static int e100_set_eeprom(struct net_device *netdev,
struct ethtool_eeprom *eeprom, u8 *bytes) struct ethtool_eeprom *eeprom, u8 *bytes)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
if(eeprom->magic != E100_EEPROM_MAGIC) if(eeprom->magic != E100_EEPROM_MAGIC)
return -EINVAL; return -EINVAL;
memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len); memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len);
...@@ -1885,7 +1876,7 @@ static void e100_get_ringparam(struct net_device *netdev, ...@@ -1885,7 +1876,7 @@ static void e100_get_ringparam(struct net_device *netdev,
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
struct param_range *rfds = &nic->params.rfds; struct param_range *rfds = &nic->params.rfds;
struct param_range *cbs = &nic->params.cbs; struct param_range *cbs = &nic->params.cbs;
ring->rx_max_pending = rfds->max; ring->rx_max_pending = rfds->max;
ring->tx_max_pending = cbs->max; ring->tx_max_pending = cbs->max;
ring->rx_mini_max_pending = 0; ring->rx_mini_max_pending = 0;
...@@ -1895,14 +1886,14 @@ static void e100_get_ringparam(struct net_device *netdev, ...@@ -1895,14 +1886,14 @@ static void e100_get_ringparam(struct net_device *netdev,
ring->rx_mini_pending = 0; ring->rx_mini_pending = 0;
ring->rx_jumbo_pending = 0; ring->rx_jumbo_pending = 0;
} }
static int e100_set_ringparam(struct net_device *netdev, static int e100_set_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ring) struct ethtool_ringparam *ring)
{ {
struct nic *nic = netdev->priv; struct nic *nic = netdev->priv;
struct param_range *rfds = &nic->params.rfds; struct param_range *rfds = &nic->params.rfds;
struct param_range *cbs = &nic->params.cbs; struct param_range *cbs = &nic->params.cbs;
if(netif_running(netdev)) if(netif_running(netdev))
e100_down(nic); e100_down(nic);
rfds->count = max(ring->rx_pending, rfds->min); rfds->count = max(ring->rx_pending, rfds->min);
...@@ -1911,11 +1902,11 @@ static int e100_set_ringparam(struct net_device *netdev, ...@@ -1911,11 +1902,11 @@ static int e100_set_ringparam(struct net_device *netdev,
cbs->count = min(cbs->count, cbs->max); cbs->count = min(cbs->count, cbs->max);
if(netif_running(netdev)) if(netif_running(netdev))
e100_up(nic); e100_up(nic);
return 0; return 0;
} }
static char e100_gstrings_test[][ETH_GSTRING_LEN] = { static const char e100_gstrings_test[][ETH_GSTRING_LEN] = {
"Link test (on/offline)", "Link test (on/offline)",
"Eeprom test (on/offline)", "Eeprom test (on/offline)",
"Self test (offline)", "Self test (offline)",
...@@ -1966,7 +1957,7 @@ static int e100_phys_id(struct net_device *netdev, u32 data) ...@@ -1966,7 +1957,7 @@ static int e100_phys_id(struct net_device *netdev, u32 data)
return 0; return 0;
} }
static char e100_gstrings_stats[][ETH_GSTRING_LEN] = { static const char e100_gstrings_stats[][ETH_GSTRING_LEN] = {
"rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
"tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
"rx_length_errors", "rx_over_errors", "rx_crc_errors", "rx_length_errors", "rx_over_errors", "rx_crc_errors",
...@@ -1974,7 +1965,7 @@ static char e100_gstrings_stats[][ETH_GSTRING_LEN] = { ...@@ -1974,7 +1965,7 @@ static char e100_gstrings_stats[][ETH_GSTRING_LEN] = {
"tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors", "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors",
"tx_heartbeat_errors", "tx_window_errors", "tx_heartbeat_errors", "tx_window_errors",
/* device-specific stats */ /* device-specific stats */
"tx_deferred", "tx_single_collisions", "tx_multi_collisions", "tx_deferred", "tx_single_collisions", "tx_multi_collisions",
"tx_flow_control_pause", "rx_flow_control_pause", "tx_flow_control_pause", "rx_flow_control_pause",
"rx_flow_control_unsupported", "tx_tco_packets", "rx_tco_packets", "rx_flow_control_unsupported", "tx_tco_packets", "rx_tco_packets",
}; };
...@@ -2083,13 +2074,13 @@ static int e100_close(struct net_device *netdev) ...@@ -2083,13 +2074,13 @@ static int e100_close(struct net_device *netdev)
return 0; return 0;
} }
static int __devinit e100_probe(struct pci_dev *pdev, static int __devinit e100_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct net_device *netdev; struct net_device *netdev;
struct nic *nic; struct nic *nic;
int err; int err;
if(!(netdev = alloc_etherdev(sizeof(struct nic)))) { if(!(netdev = alloc_etherdev(sizeof(struct nic)))) {
if(((1 << debug) - 1) & NETIF_MSG_PROBE) if(((1 << debug) - 1) & NETIF_MSG_PROBE)
printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n"); printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n");
...@@ -2241,7 +2232,7 @@ static void __devexit e100_remove(struct pci_dev *pdev) ...@@ -2241,7 +2232,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
} }
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int e100_suspend(struct pci_dev *pdev, u32 state) static int e100_suspend(struct pci_dev *pdev, u32 state)
{ {
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
...@@ -2272,7 +2263,7 @@ static int e100_resume(struct pci_dev *pdev) ...@@ -2272,7 +2263,7 @@ static int e100_resume(struct pci_dev *pdev)
netif_device_attach(netdev); netif_device_attach(netdev);
if(netif_running(netdev)) if(netif_running(netdev))
e100_up(nic); e100_up(nic);
return 0; return 0;
} }
#endif #endif
...@@ -2282,7 +2273,7 @@ static struct pci_driver e100_driver = { ...@@ -2282,7 +2273,7 @@ static struct pci_driver e100_driver = {
.id_table = e100_id_table, .id_table = e100_id_table,
.probe = e100_probe, .probe = e100_probe,
.remove = __devexit_p(e100_remove), .remove = __devexit_p(e100_remove),
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = e100_suspend, .suspend = e100_suspend,
.resume = e100_resume, .resume = e100_resume,
#endif #endif
......
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