#define DRV_NAME "e100"
-#define DRV_VERSION "3.0.17"
+#define DRV_VERSION "3.0.18"
#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
#define DRV_COPYRIGHT "Copyright(c) 1999-2004 Intel Corporation"
#define PFX DRV_NAME ": "
/* Three cmds: write/erase enable, write data, write/erase disable */
cmd_addr_data[0] = op_ewen << (addr_len - 2);
- cmd_addr_data[1] = (((op_write << addr_len) | addr) << 16) | data;
+ cmd_addr_data[1] = (((op_write << addr_len) | addr) << 16) |
+ cpu_to_le16(data);
cmd_addr_data[2] = op_ewds << (addr_len - 2);
/* Bit-bang cmds to write word to eeprom */
writeb(0, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
}
-
};
/* General technique stolen from the eepro100 driver - very clever */
writeb(0, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
- return data;
+ return le16_to_cpu(data);
};
/* Load entire EEPROM image into driver cache and validate checksum */
for(addr = 0; addr < nic->eeprom_wc; addr++) {
nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr);
if(addr < nic->eeprom_wc - 1)
- checksum += nic->eeprom[addr];
+ checksum += cpu_to_le16(nic->eeprom[addr]);
}
/* The checksum, stored in the last word, is calculated such that
* the sum of words should be 0xBABA */
- checksum = 0xBABA - checksum;
+ checksum = le16_to_cpu(0xBABA - checksum);
if(checksum != nic->eeprom[nic->eeprom_wc - 1]) {
DPRINTK(PROBE, ERR, "EEPROM corrupted\n");
return -EAGAIN;
/* The checksum, stored in the last word, is calculated such that
* the sum of words should be 0xBABA */
for(addr = 0; addr < nic->eeprom_wc - 1; addr++)
- checksum += nic->eeprom[addr];
- nic->eeprom[nic->eeprom_wc - 1] = 0xBABA - checksum;
- e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, 0xBABA - checksum);
+ checksum += cpu_to_le16(nic->eeprom[addr]);
+ nic->eeprom[nic->eeprom_wc - 1] = le16_to_cpu(0xBABA - checksum);
+ e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1,
+ nic->eeprom[nic->eeprom_wc - 1]);
return 0;
}
cb->prev->command &= cpu_to_le16(~cb_s);
while(nic->cb_to_send != nic->cb_to_use) {
- if(unlikely((err = e100_exec_cmd(nic, nic->cuc_cmd,
- nic->cb_to_send->dma_addr)))) {
+ if(unlikely(e100_exec_cmd(nic, nic->cuc_cmd,
+ nic->cb_to_send->dma_addr))) {
/* Ok, here's where things get sticky. It's
* possible that we can't schedule the command
* because the controller is too busy, so
static int mdio_read(struct net_device *netdev, int addr, int reg)
{
- return mdio_ctrl(netdev->priv, addr, mdi_read, reg, 0);
+ return mdio_ctrl(netdev_priv(netdev), addr, mdi_read, reg, 0);
}
static void mdio_write(struct net_device *netdev, int addr, int reg, int data)
{
- mdio_ctrl(netdev->priv, addr, mdi_write, reg, data);
+ mdio_ctrl(netdev_priv(netdev), addr, mdi_write, reg, data);
}
static void e100_get_defaults(struct nic *nic)
static void e100_set_multicast_list(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n",
netdev->mc_count, netdev->flags);
static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
int err;
if(nic->flags & ich_10h_workaround) {
static void e100_clean_cbs(struct nic *nic)
{
if(nic->cbs) {
- while(nic->cb_to_clean != nic->cb_to_use) {
+ while(nic->cbs_avail != nic->params.cbs.count) {
struct cb *cb = nic->cb_to_clean;
if(cb->skb) {
pci_unmap_single(nic->pdev,
dev_kfree_skb(cb->skb);
}
nic->cb_to_clean = nic->cb_to_clean->next;
+ nic->cbs_avail++;
}
- nic->cbs_avail = nic->params.cbs.count;
pci_free_consistent(nic->pdev,
sizeof(struct cb) * nic->params.cbs.count,
nic->cbs, nic->cbs_dma_addr);
if(!(rx->skb = dev_alloc_skb(RFD_BUF_LEN + rx_offset)))
return -ENOMEM;
- /* Align, init, and map the RFA. */
+ /* Align, init, and map the RFD. */
rx->skb->dev = nic->netdev;
skb_reserve(rx->skb, rx_offset);
memcpy(rx->skb->data, &nic->blank_rfd, sizeof(struct rfd));
rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
- RFD_BUF_LEN, PCI_DMA_FROMDEVICE);
+ RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
/* Link the RFD to end of RFA by linking previous RFD to
* this one, and clearing EL bit of previous. */
wmb();
prev_rfd->command &= ~cpu_to_le16(cb_el);
pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr,
- sizeof(struct rfd), PCI_DMA_TODEVICE);
+ sizeof(struct rfd), PCI_DMA_TODEVICE);
}
return 0;
/* Need to sync before taking a peek at cb_complete bit */
pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr,
- sizeof(struct rfd), PCI_DMA_FROMDEVICE);
+ sizeof(struct rfd), PCI_DMA_FROMDEVICE);
rfd_status = le16_to_cpu(rfd->status);
DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status);
/* Get data */
pci_unmap_single(nic->pdev, rx->dma_addr,
- RFD_BUF_LEN, PCI_DMA_FROMDEVICE);
+ RFD_BUF_LEN, PCI_DMA_FROMDEVICE);
/* Pull off the RFD and put the actual data (minus eth hdr) */
skb_reserve(skb, sizeof(struct rfd));
static irqreturn_t e100_intr(int irq, void *dev_id, struct pt_regs *regs)
{
struct net_device *netdev = dev_id;
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
u8 stat_ack = readb(&nic->csr->scb.stat_ack);
DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack);
#ifdef CONFIG_E100_NAPI
static int e100_poll(struct net_device *netdev, int *budget)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
unsigned int work_to_do = min(netdev->quota, *budget);
unsigned int work_done = 0;
int tx_cleaned;
#ifdef CONFIG_NET_POLL_CONTROLLER
static void e100_netpoll(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
e100_disable_irq(nic);
e100_intr(nic->pdev->irq, netdev, NULL);
e100_enable_irq(nic);
static struct net_device_stats *e100_get_stats(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
return &nic->net_stats;
}
static int e100_set_mac_address(struct net_device *netdev, void *p)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
struct sockaddr *addr = p;
if (!is_valid_ether_addr(addr->sa_data))
goto err_clean_cbs;
e100_set_multicast_list(nic->netdev);
e100_start_receiver(nic);
- netif_start_queue(nic->netdev);
mod_timer(&nic->watchdog, jiffies);
if((err = request_irq(nic->pdev->irq, e100_intr, SA_SHIRQ,
nic->netdev->name, nic->netdev)))
goto err_no_irq;
e100_enable_irq(nic);
+ netif_wake_queue(nic->netdev);
return 0;
err_no_irq:
del_timer_sync(&nic->watchdog);
- netif_stop_queue(nic->netdev);
err_clean_cbs:
e100_clean_cbs(nic);
err_rx_clean_list:
static void e100_tx_timeout(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
readb(&nic->csr->scb.status));
- e100_down(netdev->priv);
- e100_up(netdev->priv);
+ e100_down(netdev_priv(netdev));
+ e100_up(netdev_priv(netdev));
}
static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
return mii_ethtool_gset(&nic->mii, cmd);
}
static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
int err;
mdio_write(netdev, nic->mii.phy_id, MII_BMCR, BMCR_RESET);
static void e100_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
strcpy(info->fw_version, "N/A");
static int e100_get_regs_len(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
#define E100_PHY_REGS 0x1C
#define E100_REGS_LEN 1 + E100_PHY_REGS + \
sizeof(nic->mem->dump_buf) / sizeof(u32)
static void e100_get_regs(struct net_device *netdev,
struct ethtool_regs *regs, void *p)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
u32 *buff = p;
int i;
static void e100_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
wol->supported = (nic->mac >= mac_82558_D101_A4) ? 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)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
if(wol->wolopts != WAKE_MAGIC && wol->wolopts != 0)
return -EOPNOTSUPP;
static u32 e100_get_msglevel(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
return nic->msg_enable;
}
static void e100_set_msglevel(struct net_device *netdev, u32 value)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
nic->msg_enable = value;
}
static int e100_nway_reset(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
return mii_nway_restart(&nic->mii);
}
static u32 e100_get_link(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
return mii_link_ok(&nic->mii);
}
static int e100_get_eeprom_len(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
return nic->eeprom_wc << 1;
}
static int e100_get_eeprom(struct net_device *netdev,
struct ethtool_eeprom *eeprom, u8 *bytes)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
eeprom->magic = E100_EEPROM_MAGIC;
memcpy(bytes, &((u8 *)nic->eeprom)[eeprom->offset], eeprom->len);
static int e100_set_eeprom(struct net_device *netdev,
struct ethtool_eeprom *eeprom, u8 *bytes)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
if(eeprom->magic != E100_EEPROM_MAGIC)
return -EINVAL;
+
memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len);
return e100_eeprom_save(nic, eeprom->offset >> 1,
static void e100_get_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ring)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
struct param_range *rfds = &nic->params.rfds;
struct param_range *cbs = &nic->params.cbs;
static int e100_set_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ring)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
struct param_range *rfds = &nic->params.rfds;
struct param_range *cbs = &nic->params.cbs;
static void e100_diag_test(struct net_device *netdev,
struct ethtool_test *test, u64 *data)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
int i;
memset(data, 0, E100_TEST_LEN * sizeof(u64));
static int e100_phys_id(struct net_device *netdev, u32 data)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
static void e100_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
int i;
for(i = 0; i < E100_NET_STATS_LEN; i++)
static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
{
- struct nic *nic = netdev->priv;
- struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&ifr->ifr_data;
+ struct nic *nic = netdev_priv(netdev);
- return generic_mii_ioctl(&nic->mii, mii, cmd, NULL);
+ return generic_mii_ioctl(&nic->mii, if_mii(ifr), cmd, NULL);
}
static int e100_alloc(struct nic *nic)
static int e100_open(struct net_device *netdev)
{
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
int err = 0;
netif_carrier_off(netdev);
static int e100_close(struct net_device *netdev)
{
- e100_down(netdev->priv);
+ e100_down(netdev_priv(netdev));
return 0;
}
netdev->poll_controller = e100_netpoll;
#endif
- nic = netdev->priv;
+ nic = netdev_priv(netdev);
nic->netdev = netdev;
nic->pdev = pdev;
nic->msg_enable = (1 << debug) - 1;
if((err = e100_eeprom_load(nic)))
goto err_out_free;
- ((u16 *)netdev->dev_addr)[0] = le16_to_cpu(nic->eeprom[0]);
- ((u16 *)netdev->dev_addr)[1] = le16_to_cpu(nic->eeprom[1]);
- ((u16 *)netdev->dev_addr)[2] = le16_to_cpu(nic->eeprom[2]);
+
+ memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN);
if(!is_valid_ether_addr(netdev->dev_addr)) {
DPRINTK(PROBE, ERR, "Invalid MAC address from "
"EEPROM, aborting.\n");
struct net_device *netdev = pci_get_drvdata(pdev);
if(netdev) {
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
unregister_netdev(netdev);
e100_free(nic);
iounmap(nic->csr);
static int e100_suspend(struct pci_dev *pdev, u32 state)
{
struct net_device *netdev = pci_get_drvdata(pdev);
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
if(netif_running(netdev))
e100_down(nic);
static int e100_resume(struct pci_dev *pdev)
{
struct net_device *netdev = pci_get_drvdata(pdev);
- struct nic *nic = netdev->priv;
+ struct nic *nic = netdev_priv(netdev);
pci_set_power_state(pdev, 0);
pci_restore_state(pdev, nic->pm_state);