Commit d25992e0 authored by Jeff Garzik's avatar Jeff Garzik

Merge mandrakesoft.com:/home/jgarzik/vanilla/linus-2.5

into mandrakesoft.com:/home/jgarzik/repo/net-drivers-2.5
parents caff8cde 96a08edb
D-Link DL2000-based Gigabit Ethernet Adapter Installation
for Linux
Jan 02, 2002
Jan 29, 2002
Contents
========
......@@ -199,8 +199,8 @@ media=media_type - Specifies the media type the NIC operates at.
6 1000Mbps full duplex.
By default, the NIC operates at autosense.
Note that only 1000mbps_fd and 1000mbps_hd
types are available for fiber adapter.
1000mbps_fd and 1000mbps_hd types are only
available for fiber adapter.
vlan=[0|1] - Specifies the VLAN ID. If vlan=0, the
Virtual Local Area Network (VLAN) function is
......
......@@ -65,7 +65,10 @@
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/sockios.h>
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
#include <linux/if_vlan.h>
#endif
#ifdef SIOCETHTOOL
#include <linux/ethtool.h>
......@@ -321,8 +324,10 @@ static inline void tasklet_init(struct tasklet_struct *tasklet,
#if (defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)) && \
defined(NETIF_F_HW_VLAN_RX)
#define ACENIC_DO_VLAN 1
#define ACE_RCB_VLAN_FLAG RCB_FLG_VLAN_ASSIST
#else
#define ACENIC_DO_VLAN 0
#define ACE_RCB_VLAN_FLAG 0
#endif
#include "acenic.h"
......@@ -563,7 +568,7 @@ static int tx_ratio[ACE_MAX_MOD_PARMS];
static int dis_pci_mem_inval[ACE_MAX_MOD_PARMS] = {1, 1, 1, 1, 1, 1, 1, 1};
static char version[] __initdata =
"acenic.c: v0.88 03/14/2002 Jes Sorensen, linux-acenic@SunSITE.dk\n"
"acenic.c: v0.89 03/15/2002 Jes Sorensen, linux-acenic@SunSITE.dk\n"
" http://home.cern.ch/~jes/gige/acenic.html\n";
static struct net_device *root_dev;
......@@ -1461,10 +1466,8 @@ static int __init ace_init(struct net_device *dev)
set_aceaddr(&info->rx_std_ctrl.rngptr, ap->rx_ring_base_dma);
info->rx_std_ctrl.max_len = ACE_STD_MTU + ETH_HLEN + 4;
info->rx_std_ctrl.flags = RCB_FLG_TCP_UDP_SUM|RCB_FLG_NO_PSEUDO_HDR;
#if ACENIC_DO_VLAN
info->rx_std_ctrl.flags |= RCB_FLG_VLAN_ASSIST;
#endif
info->rx_std_ctrl.flags =
RCB_FLG_TCP_UDP_SUM | RCB_FLG_NO_PSEUDO_HDR | ACE_RCB_VLAN_FLAG;
memset(ap->rx_std_ring, 0,
RX_STD_RING_ENTRIES * sizeof(struct rx_desc));
......@@ -1479,10 +1482,8 @@ static int __init ace_init(struct net_device *dev)
(ap->rx_ring_base_dma +
(sizeof(struct rx_desc) * RX_STD_RING_ENTRIES)));
info->rx_jumbo_ctrl.max_len = 0;
info->rx_jumbo_ctrl.flags = RCB_FLG_TCP_UDP_SUM|RCB_FLG_NO_PSEUDO_HDR;
#if ACENIC_DO_VLAN
info->rx_jumbo_ctrl.flags |= RCB_FLG_VLAN_ASSIST;
#endif
info->rx_jumbo_ctrl.flags =
RCB_FLG_TCP_UDP_SUM | RCB_FLG_NO_PSEUDO_HDR | ACE_RCB_VLAN_FLAG;
memset(ap->rx_jumbo_ring, 0,
RX_JUMBO_RING_ENTRIES * sizeof(struct rx_desc));
......@@ -1504,10 +1505,7 @@ static int __init ace_init(struct net_device *dev)
RX_JUMBO_RING_ENTRIES))));
info->rx_mini_ctrl.max_len = ACE_MINI_SIZE;
info->rx_mini_ctrl.flags =
RCB_FLG_TCP_UDP_SUM|RCB_FLG_NO_PSEUDO_HDR;
#if ACENIC_DO_VLAN
info->rx_mini_ctrl.flags |= RCB_FLG_VLAN_ASSIST;
#endif
RCB_FLG_TCP_UDP_SUM|RCB_FLG_NO_PSEUDO_HDR|ACE_RCB_VLAN_FLAG;
for (i = 0; i < RX_MINI_RING_ENTRIES; i++)
ap->rx_mini_ring[i].flags =
......@@ -1554,7 +1552,7 @@ static int __init ace_init(struct net_device *dev)
}
info->tx_ctrl.max_len = ACE_TX_RING_ENTRIES(ap);
tmp = RCB_FLG_TCP_UDP_SUM|RCB_FLG_NO_PSEUDO_HDR;
tmp = RCB_FLG_TCP_UDP_SUM | RCB_FLG_NO_PSEUDO_HDR | ACE_RCB_VLAN_FLAG;
/*
* The Tigon I does not like having the TX ring in host memory ;-(
......@@ -1563,9 +1561,6 @@ static int __init ace_init(struct net_device *dev)
tmp |= RCB_FLG_TX_HOST_RING;
#if TX_COAL_INTS_ONLY
tmp |= RCB_FLG_COAL_INT_ONLY;
#endif
#if ACENIC_DO_VLAN
tmp |= RCB_FLG_VLAN_ASSIST;
#endif
info->tx_ctrl.flags = tmp;
......@@ -1592,7 +1587,7 @@ static int __init ace_init(struct net_device *dev)
ace_set_rxtx_parms(dev, 0);
if (board_idx == BOARD_IDX_OVERFLOW) {
printk(KERN_WARNING "%s: more then %i NICs detected, "
printk(KERN_WARNING "%s: more than %i NICs detected, "
"ignoring module parameters!\n",
dev->name, ACE_MAX_MOD_PARMS);
} else if (board_idx >= 0) {
......@@ -2181,14 +2176,6 @@ static u32 ace_handle_event(struct net_device *dev, u32 evtcsm, u32 evtprd)
}
#if ACENIC_DO_VLAN
static int ace_vlan_rx(struct ace_private *ap, struct sk_buff *skb, u16 vlan_tag)
{
return vlan_hwaccel_rx(skb, ap->vlgrp, vlan_tag);
}
#endif
static void ace_rx_int(struct net_device *dev, u32 rxretprd, u32 rxretcsm)
{
struct ace_private *ap = dev->priv;
......@@ -2274,11 +2261,9 @@ static void ace_rx_int(struct net_device *dev, u32 rxretprd, u32 rxretcsm)
}
/* send it up */
#if ACENIC_DO_VLAN
if (ap->vlgrp != NULL &&
(bd_flags & BD_FLG_VLAN_TAG)) {
ace_vlan_rx(ap, skb, retdesc->vlan);
if (ap->vlgrp && (bd_flags & BD_FLG_VLAN_TAG)) {
vlan_hwaccel_rx(skb, ap->vlgrp, retdesc->vlan);
} else
#endif
netif_rx(skb);
......
......@@ -642,10 +642,6 @@ struct ace_private
struct ace_skb *skb;
dma_addr_t info_dma; /* 32/64 bit */
#if ACENIC_DO_VLAN
struct vlan_group *vlgrp;
#endif
int version, link;
int promisc, mcast_all;
......@@ -655,7 +651,6 @@ struct ace_private
struct tx_desc *tx_ring;
u32 tx_prd;
volatile u32 tx_ret_csm;
struct timer_list timer;
int tx_ring_entries;
/*
......@@ -675,6 +670,10 @@ struct ace_private
struct rx_desc *rx_mini_ring;
struct rx_desc *rx_return_ring;
#if ACENIC_DO_VLAN
struct vlan_group *vlgrp;
#endif
int tasklet_pending, jumbo;
struct tasklet_struct ace_tasklet;
......
......@@ -465,7 +465,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
#define EE_DATA_READ 0x80 /* EEPROM chip data out, in reg. 17. */
/* Delay between EEPROM clock transitions. */
#define eeprom_delay() do {} while (0);
#define eeprom_delay() do { } while (0)
/* The EEPROM commands include the alway-set leading bit. */
#define EE_WRITE_CMD (5 << 6)
......
......@@ -449,11 +449,17 @@ static int de620_open(struct net_device *dev)
return ret;
}
if (adapter_init(dev))
return -EIO;
if (adapter_init(dev)) {
ret = -EIO;
goto out_free_irq;
}
netif_start_queue(dev);
return 0;
out_free_irq:
free_irq(dev->irq, dev);
return ret;
}
/************************************************
......@@ -850,7 +856,10 @@ int __init de620_probe(struct net_device *dev)
return -EBUSY;
}
#endif
request_region(dev->base_addr, 3, "de620");
if (!request_region(dev->base_addr, 3, "de620")) {
printk(KERN_ERR "io 0x%3lX, which is busy.\n", dev->base_addr);
return -EBUSY;
}
/* else, got it! */
printk(", Ethernet Address: %2.2X",
......
/* D-Link DL2000-based Gigabit Ethernet Adapter Linux driver */
/*
Copyright (c) 2001 by D-Link Corporation
Copyright (c) 2001,2002 by D-Link Corporation
Written by Edward Peng.<edward_peng@dlink.com.tw>
Created 03-May-2001, base on Linux' sundance.c.
......@@ -27,12 +27,14 @@
Added tx_coalesce paramter.
1.07 2002/01/03 Fixed miscount of RX frame error.
1.08 2002/01/17 Fixed the multicast bug.
1.09 2002/03/07 Move rx-poll-now to re-fill loop.
Added rio_timer() to watch rx buffers.
*/
#include "dl2k.h"
static char version[] __devinitdata =
KERN_INFO "D-Link DL2000-based linux driver v1.08 2002/01/17\n";
KERN_INFO "D-Link DL2000-based linux driver v1.09 2002/03/07\n";
#define MAX_UNITS 8
static int mtu[MAX_UNITS];
......@@ -42,9 +44,10 @@ static char *media[MAX_UNITS];
static int tx_flow[MAX_UNITS];
static int rx_flow[MAX_UNITS];
static int copy_thresh;
static int rx_coalesce = DEFAULT_RXC;
static int rx_timeout = DEFAULT_RXT;
static int tx_coalesce = DEFAULT_TXC;
static int rx_coalesce; /* Rx frame count each interrupt */
static int rx_timeout; /* Rx DMA wait time in 64ns increments */
static int tx_coalesce = DEFAULT_TXC; /* HW xmit count each TxComplete [1-8] */
MODULE_AUTHOR ("Edward Peng");
MODULE_DESCRIPTION ("D-Link DL2000-based Gigabit Ethernet Adapter");
......@@ -71,6 +74,7 @@ static int max_intrloop = 50;
static int multicast_filter_limit = 0x40;
static int rio_open (struct net_device *dev);
static void rio_timer (unsigned long data);
static void tx_timeout (struct net_device *dev);
static void alloc_list (struct net_device *dev);
static int start_xmit (struct sk_buff *skb, struct net_device *dev);
......@@ -146,6 +150,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
np->chip_id = chip_idx;
np->pdev = pdev;
spin_lock_init (&np->lock);
spin_lock_init (&np->rx_lock);
/* Parse manual configuration */
np->an_enable = 1;
......@@ -260,6 +265,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
np->an_enable = 1;
mii_set_media (dev);
}
pci_read_config_byte(pdev, PCI_REVISION_ID, &np->pci_rev_id);
/* Reset all logic functions */
writew (GlobalReset | DMAReset | FIFOReset | NetworkReset | HostReset,
......@@ -421,8 +427,10 @@ rio_open (struct net_device *dev)
ioaddr + RxDMAIntCtrl);
}
/* Set RIO to poll every N*320nsec. */
writeb (0xff, ioaddr + RxDMAPollPeriod);
writeb (0x20, ioaddr + RxDMAPollPeriod);
writeb (0xff, ioaddr + TxDMAPollPeriod);
writeb (0x30, ioaddr + RxDMABurstThresh);
writeb (0x30, ioaddr + RxDMAUrgentThresh);
netif_start_queue (dev);
writel (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl);
/* VLAN supported */
......@@ -445,8 +453,58 @@ rio_open (struct net_device *dev)
/* clear statistics */
get_stats (dev);
init_timer (&np->timer);
np->timer.expires = jiffies + 1*HZ;
np->timer.data = (unsigned long) dev;
np->timer.function = &rio_timer;
add_timer (&np->timer);
return 0;
}
static void
rio_timer (unsigned long data)
{
struct net_device *dev = (struct net_device *)data;
struct netdev_private *np = dev->priv;
unsigned int entry;
int next_tick = 1*HZ;
unsigned long flags;
/* Recover rx ring exhausted error */
if (np->cur_rx - np->old_rx >= RX_RING_SIZE) {
printk(KERN_INFO "Try to recover rx ring exhausted...\n");
spin_lock_irqsave(&np->rx_lock, flags);
/* Re-allocate skbuffs to fill the descriptor ring */
for (; np->cur_rx - np->old_rx > 0; np->old_rx++) {
struct sk_buff *skb;
entry = np->old_rx % RX_RING_SIZE;
/* Dropped packets don't need to re-allocate */
if (np->rx_skbuff[entry] == NULL) {
skb = dev_alloc_skb (np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
printk (KERN_INFO
"%s: Still unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
break;
}
np->rx_skbuff[entry] = skb;
skb->dev = dev;
/* 16 byte align the IP header */
skb_reserve (skb, 2);
np->rx_ring[entry].fraginfo =
cpu_to_le64 (pci_map_single
(np->pdev, skb->tail, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
}
np->rx_ring[entry].fraginfo |=
cpu_to_le64 (np->rx_buf_sz) << 48;
np->rx_ring[entry].status = 0;
} /* end for */
spin_unlock_irqrestore (&np->rx_lock, flags);
} /* end if */
np->timer.expires = jiffies + next_tick;
add_timer(&np->timer);
}
static void
tx_timeout (struct net_device *dev)
......@@ -499,16 +557,14 @@ alloc_list (struct net_device *dev)
np->tx_ring[i].status = cpu_to_le64 (TFDDone);
np->tx_ring[i].next_desc = cpu_to_le64 (np->tx_ring_dma +
((i+1)%TX_RING_SIZE) *
sizeof (struct
netdev_desc));
sizeof (struct netdev_desc));
}
/* Initialize Rx descriptors */
for (i = 0; i < RX_RING_SIZE; i++) {
np->rx_ring[i].next_desc = cpu_to_le64 (np->rx_ring_dma +
((i + 1) % RX_RING_SIZE) *
sizeof (struct
netdev_desc));
sizeof (struct netdev_desc));
np->rx_ring[i].status = 0;
np->rx_ring[i].fraginfo = 0;
np->rx_skbuff[i] = 0;
......@@ -529,8 +585,8 @@ alloc_list (struct net_device *dev)
skb_reserve (skb, 2); /* 16 byte align the IP header. */
/* Rubicon now supports 40 bits of addressing space. */
np->rx_ring[i].fraginfo =
cpu_to_le64 (pci_map_single
(np->pdev, skb->tail, np->rx_buf_sz,
cpu_to_le64 ( pci_map_single (
np->pdev, skb->tail, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
np->rx_ring[i].fraginfo |= cpu_to_le64 (np->rx_buf_sz) << 48;
}
......@@ -773,6 +829,8 @@ receive_packet (struct net_device *dev)
int entry = np->cur_rx % RX_RING_SIZE;
int cnt = np->old_rx + RX_RING_SIZE - np->cur_rx;
int rx_shift;
spin_lock (&np->rx_lock);
if (np->old_rx > RX_RING_SIZE) {
rx_shift = RX_RING_SIZE;
np->old_rx -= rx_shift;
......@@ -830,10 +888,12 @@ receive_packet (struct net_device *dev)
skb->protocol = eth_type_trans (skb, dev);
#if 0
/* Checksum done by hw, but csum value unavailable. */
if (!(frame_status & (TCPError | UDPError | IPError))) {
if (np->pci_rev_id >= 0x0c &&
!(frame_status & (TCPError | UDPError | IPError))) {
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
#endif
netif_rx (skb);
dev->last_rx = jiffies;
}
......@@ -849,9 +909,10 @@ receive_packet (struct net_device *dev)
skb = dev_alloc_skb (np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
printk (KERN_ERR
"%s: Allocate Rx buffer error!",
dev->name);
printk (KERN_INFO
"%s: receive_packet: "
"Unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
break;
}
np->rx_skbuff[entry] = skb;
......@@ -866,13 +927,12 @@ receive_packet (struct net_device *dev)
np->rx_ring[entry].fraginfo |=
cpu_to_le64 (np->rx_buf_sz) << 48;
np->rx_ring[entry].status = 0;
}
/* RxDMAPollNow */
writel (readl (dev->base_addr + DMACtrl) | 0x00000010,
dev->base_addr + DMACtrl);
}
DEBUG_RFD_DUMP (np, 2);
spin_unlock(&np->rx_lock);
return 0;
}
......@@ -1006,7 +1066,7 @@ set_multicast (struct net_device *dev)
hash_table[0] = hash_table[1] = 0;
/* RxFlowcontrol DA: 01-80-C2-00-00-01. Hash index=0x39 */
hash_table[1] |= 0x02000000;
hash_table[1] |= cpu_to_le32(0x02000000);
if (dev->flags & IFF_PROMISC) {
/* Receive all frames promiscuously. */
rx_mode = ReceiveAllFrames;
......@@ -1021,10 +1081,15 @@ set_multicast (struct net_device *dev)
ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast;
for (i=0, mclist = dev->mc_list; mclist && i < dev->mc_count;
i++, mclist=mclist->next) {
crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr);
for (index=0, bit=0; bit<6; bit++, crc<<=1) {
if (crc & 0x80000000) index |= 1 << bit;
}
/* The inverted high significant 6 bits of CRC are
used as an index to hashtable */
for (index = 0, bit = 0; bit < 6; bit++)
if (test_bit(31 - bit, &crc))
set_bit(bit, &index);
hash_table[index / 32] |= (1 << (index % 32));
}
} else {
......@@ -1094,6 +1159,7 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
np->old_rx);
break;
case SIOCDEVPRIVATE + 8:
printk("TX ring:\n");
for (i = 0; i < TX_RING_SIZE; i++) {
desc = &np->tx_ring[i];
printk
......@@ -1629,6 +1695,7 @@ rio_close (struct net_device *dev)
writel (TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl);
synchronize_irq ();
free_irq (dev->irq, dev);
del_timer_sync (&np->timer);
/* Free all the skbuffs in the queue. */
for (i = 0; i < RX_RING_SIZE; i++) {
......@@ -1679,9 +1746,9 @@ rio_remove1 (struct pci_dev *pdev)
}
static struct pci_driver rio_driver = {
name:"dl2k",
id_table:rio_pci_tbl,
probe:rio_probe1,
name: "dl2k",
id_table: rio_pci_tbl,
probe: rio_probe1,
remove: __devexit_p(rio_remove1),
};
......
/* D-Link DL2000-based Gigabit Ethernet Adapter Linux driver */
/*
Copyright (c) 2001 by D-Link Corporation
Copyright (c) 2001, 2002 by D-Link Corporation
Written by Edward Peng.<edward_peng@dlink.com.tw>
Created 03-May-2001, base on Linux' sundance.c.
......@@ -649,6 +649,7 @@ struct netdev_private {
dma_addr_t rx_ring_dma;
struct pci_dev *pdev;
spinlock_t lock;
spinlock_t rx_lock;
struct net_device_stats stats;
unsigned int rx_buf_sz; /* Based on MTU+slack. */
unsigned int speed; /* Operating speed */
......@@ -664,9 +665,11 @@ struct netdev_private {
unsigned int tx_flow:1; /* Tx flow control enable */
unsigned int rx_flow:1; /* Rx flow control enable */
unsigned int phy_media:1; /* 1: fiber, 0: copper */
unsigned char pci_rev_id; /* PCI revision ID */
struct netdev_desc *last_tx; /* Last Tx descriptor used. */
unsigned long cur_rx, old_rx; /* Producer/consumer ring indices */
unsigned long cur_tx, old_tx;
struct timer_list timer;
int wake_polarity;
char name[256]; /* net device description */
u8 duplex_polarity;
......
......@@ -10,7 +10,7 @@
O_TARGET := e100.o
obj-y := e100_main.o e100_config.o e100_proc.o e100_phy.o \
e100_eeprom.o
e100_eeprom.o e100_test.o
obj-m := $(O_TARGET)
include $(TOPDIR)/Rules.make
......@@ -899,6 +899,15 @@ struct cfg_params {
int PollingMaxWork;
u32 b_params;
};
#ifdef ETHTOOL_TEST
struct ethtool_lpbk_data{
dma_addr_t dma_handle;
tcb_t *tcb;
rfd_t *rfd;
};
#endif
struct e100_private {
u32 flags; /* board management flags */
......@@ -988,6 +997,9 @@ struct e100_private {
u32 wolopts;
u16 ip_lbytes;
#endif
#ifdef ETHTOOL_TEST
struct ethtool_lpbk_data loopback;
#endif
#ifdef CONFIG_PM
u32 pci_state[16];
......@@ -1028,4 +1040,23 @@ extern void e100_deisolate_driver(struct e100_private *bdp,
extern unsigned char e100_hw_reset_recover(struct e100_private *bdp,
u32 reset_cmd);
#ifdef ETHTOOL_TEST
#define ROM_TEST_FAIL 0x01
#define REGISTER_TEST_FAIL 0x02
#define SELF_TEST_FAIL 0x04
#define TEST_TIMEOUT 0x08
enum test_offsets {
E100_EEPROM_TEST_FAIL = 0,
E100_CHIP_TIMEOUT,
E100_ROM_TEST_FAIL,
E100_REG_TEST_FAIL,
E100_MAC_TEST_FAIL,
E100_LPBK_MAC_FAIL,
E100_LPBK_PHY_FAIL,
E100_MAX_TEST_RES
};
#endif
#endif
......@@ -593,3 +593,102 @@ e100_config_wol(struct e100_private *bdp)
}
#endif
#ifdef ETHTOOL_TEST
/**
* e100_config_loopback_mode
* @bdp: atapter's private data struct
* @mode: loopback mode(phy/mac/none)
*
*/
unsigned char
e100_config_loopback_mode(struct e100_private *bdp, u8 mode)
{
unsigned char bc_changed = false;
u8 config_byte;
spin_lock_bh(&(bdp->config_lock));
switch (mode) {
case NO_LOOPBACK:
config_byte = CB_CFIG_LOOPBACK_NORMAL;
break;
case MAC_LOOPBACK:
config_byte = CB_CFIG_LOOPBACK_INTERNAL;
break;
case PHY_LOOPBACK:
config_byte = CB_CFIG_LOOPBACK_EXTERNAL;
break;
default:
printk(KERN_NOTICE "e100_config_loopback_mode: "
"Invalid argument 'mode': %d\n", mode);
goto exit;
}
if ((bdp->config[10] & CB_CFIG_LOOPBACK_MODE) != config_byte) {
bdp->config[10] &= (~CB_CFIG_LOOPBACK_MODE);
bdp->config[10] |= config_byte;
E100_CONFIG(bdp, 10);
bc_changed = true;
}
exit:
spin_unlock_bh(&(bdp->config_lock));
return bc_changed;
}
unsigned char
e100_config_tcb_ext_enable(struct e100_private *bdp, unsigned char enable)
{
unsigned char bc_changed = false;
spin_lock_bh(&(bdp->config_lock));
if (enable) {
if (bdp->config[6] & CB_CFIG_EXT_TCB_DIS) {
bdp->config[6] &= (~CB_CFIG_EXT_TCB_DIS);
E100_CONFIG(bdp, 6);
bc_changed = true;
}
} else {
if (!(bdp->config[6] & CB_CFIG_EXT_TCB_DIS)) {
bdp->config[6] |= CB_CFIG_EXT_TCB_DIS;
E100_CONFIG(bdp, 6);
bc_changed = true;
}
}
spin_unlock_bh(&(bdp->config_lock));
return bc_changed;
}
unsigned char
e100_config_dynamic_tbd(struct e100_private *bdp, unsigned char enable)
{
unsigned char bc_changed = false;
spin_lock_bh(&(bdp->config_lock));
if (enable) {
if (!(bdp->config[7] & CB_CFIG_DYNTBD_EN)) {
bdp->config[7] |= CB_CFIG_DYNTBD_EN;
E100_CONFIG(bdp, 7);
bc_changed = true;
}
} else {
if (bdp->config[7] & CB_CFIG_DYNTBD_EN) {
bdp->config[7] &= (~CB_CFIG_DYNTBD_EN);
E100_CONFIG(bdp, 7);
bc_changed = true;
}
}
spin_unlock_bh(&(bdp->config_lock));
return bc_changed;
}
#endif
......@@ -190,6 +190,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define CB_CFIG_LONG_RX_OK BIT_3
#define NO_LOOPBACK 0
#define MAC_LOOPBACK 0x01
#define PHY_LOOPBACK 0x02
/* function prototypes */
extern void e100_config_init(struct e100_private *bdp);
extern unsigned char e100_force_config(struct e100_private *bdp);
......@@ -201,5 +205,8 @@ extern void e100_config_mulcast_enbl(struct e100_private *bdp,
unsigned char enable);
extern void e100_config_ifs(struct e100_private *bdp);
extern void e100_config_force_dplx(struct e100_private *bdp);
extern u8 e100_config_loopback_mode(struct e100_private *bdp, u8 mode);
extern u8 e100_config_dynamic_tbd(struct e100_private *bdp, u8 enable);
extern u8 e100_config_tcb_ext_enable(struct e100_private *bdp, u8 enable);
#endif /* _E100_CONFIG_INC_ */
......@@ -146,6 +146,23 @@ static unsigned char e100_setup_filter(struct e100_private *bdp);
static void e100_do_wol(struct pci_dev *pcid, struct e100_private *bdp);
static u16 e100_get_ip_lbytes(struct net_device *dev);
extern void e100_config_wol(struct e100_private *bdp);
#endif
#ifdef ETHTOOL_TEST
extern u32 e100_run_diag(struct net_device *dev, u64 *test_info, u32 flags);
static int e100_ethtool_test(struct net_device *, struct ifreq *);
#endif
#ifdef ETHTOOL_GSTRINGS
static int e100_ethtool_gstrings(struct net_device *, struct ifreq *);
static char *test_strings[] = {
"E100_EEPROM_TEST_FAIL",
"E100_CHIP_TIMEOUT",
"E100_ROM_TEST_FAIL",
"E100_REG_TEST_FAIL",
"E100_MAC_TEST_FAIL",
"E100_LPBK_MAC_FAIL",
"E100_LPBK_PHY_FAIL"
};
#endif
#endif /*E100_ETHTOOL_IOCTL */
......@@ -165,7 +182,7 @@ static void e100_non_tx_background(unsigned long);
/* Global Data structures and variables */
char e100_copyright[] __devinitdata = "Copyright (c) 2002 Intel Corporation";
#define E100_VERSION "2.0.24-pre1"
#define E100_VERSION "2.0.25-pre1"
#define E100_FULL_DRIVER_NAME "Intel(R) PRO/100 Fast Ethernet Adapter - Loadable driver, ver "
......@@ -382,6 +399,7 @@ static void e100_set_multi_exec(struct net_device *dev);
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
MODULE_DESCRIPTION(E100_FULL_DRIVER_NAME E100_VERSION);
MODULE_LICENSE("Dual BSD/GPL");
EXPORT_NO_SYMBOLS;
E100_PARAM(TxDescriptors, "Number of transmit descriptors");
E100_PARAM(RxDescriptors, "Number of receive descriptors");
......@@ -2715,8 +2733,10 @@ e100_exec_non_cu_cmd(struct e100_private *bdp, nxmit_cb_entry_t *command)
ntcb_hdr->cb_lnk_ptr = 0;
wmb();
if (in_interrupt())
return e100_delayed_exec_non_cu_cmd(bdp, command);
if (in_interrupt() || netif_running(bdp->device))
if (netif_running(bdp->device) && (!bdp->driver_isolated))
return e100_delayed_exec_non_cu_cmd(bdp, command);
spin_lock_bh(&(bdp->bd_non_tx_lock));
......@@ -3301,6 +3321,16 @@ e100_do_ethtool_ioctl(struct net_device *dev, struct ifreq *ifr)
case ETHTOOL_SWOL:
rc = e100_ethtool_wol(dev, ifr);
break;
#endif
#ifdef ETHTOOL_TEST
case ETHTOOL_TEST:
rc = e100_ethtool_test(dev, ifr);
break;
#endif
#ifdef ETHTOOL_GSTRINGS
case ETHTOOL_GSTRINGS:
rc = e100_ethtool_gstrings(dev,ifr);
break;
#endif
default:
break;
......@@ -3464,6 +3494,36 @@ e100_ethtool_glink(struct net_device *dev, struct ifreq *ifr)
}
#endif
#ifdef ETHTOOL_TEST
static int
e100_ethtool_test(struct net_device *dev, struct ifreq *ifr)
{
struct ethtool_test *info;
int rc = -EFAULT;
info = kmalloc(sizeof(*info) + E100_MAX_TEST_RES * sizeof(u64),
GFP_ATOMIC);
if (!info)
return -EFAULT;
memset((void *) info, 0, sizeof(*info) +
E100_MAX_TEST_RES * sizeof(u64));
if (copy_from_user(info, ifr->ifr_data, sizeof(*info)))
goto exit;
info->flags = e100_run_diag(dev, info->data, info->flags);
if (!copy_to_user(ifr->ifr_data, info,
sizeof(*info) + E100_MAX_TEST_RES * sizeof(u64)))
rc = 0;
exit:
kfree(info);
return rc;
}
#endif
#ifdef ETHTOOL_NWAY_RST
static int
e100_ethtool_nway_rst(struct net_device *dev, struct ifreq *ifr)
......@@ -3505,7 +3565,9 @@ e100_ethtool_get_drvinfo(struct net_device *dev, struct ifreq *ifr)
#ifdef ETHTOOL_GEEPROM
info.eedump_len = (bdp->eeprom_size << 1);
#endif
#ifdef ETHTOOL_TEST
info.testinfo_len = E100_MAX_TEST_RES;
#endif
if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
return -EFAULT;
......@@ -3737,6 +3799,51 @@ e100_ethtool_wol(struct net_device *dev, struct ifreq *ifr)
return res;
}
#endif
#ifdef ETHTOOL_GSTRINGS
static int e100_ethtool_gstrings(struct net_device *dev, struct ifreq *ifr)
{
struct ethtool_gstrings info;
char *strings = NULL;
char *usr_strings;
int i;
memset((void *) &info, 0, sizeof(info));
usr_strings = (u8 *) (ifr->ifr_data +
offsetof(struct ethtool_gstrings, data));
if (copy_from_user(&info, ifr->ifr_data, sizeof (info)))
return -EFAULT;
switch (info.string_set) {
case ETH_SS_TEST:
if (info.len > E100_MAX_TEST_RES)
info.len = E100_MAX_TEST_RES;
strings = kmalloc(info.len * ETH_GSTRING_LEN, GFP_ATOMIC);
if (!strings)
return -EFAULT;
memset(strings, 0, info.len * ETH_GSTRING_LEN);
for (i = 0; i < info.len; i++) {
sprintf(strings + i * ETH_GSTRING_LEN, "%-31s",
test_strings[i]);
}
break;
default:
return -EOPNOTSUPP;
}
if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
return -EFAULT;
if (copy_to_user(usr_strings, strings, info.len * ETH_GSTRING_LEN))
return -EFAULT;
kfree(strings);
return 0;
}
#endif
#endif /*E100_ETHTOOL_IOCTL */
......
/*******************************************************************************
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
Intel(R) PRO/100 Family of Adapters (e100) (the "Software") being provided
by Intel Corporation. The following definitions apply to this license:
"Licensed Patents" means patent claims licensable by Intel Corporation which
are necessarily infringed by the use of sale of the Software alone or when
combined with the operating system referred to below.
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
All rights reserved.
The license is provided to Recipient and Recipient's Licensees under the
following terms.
Redistribution and use in source and binary forms of the Software, with or
without modification, are permitted provided that the following conditions
are met:
Redistributions of source code of the Software may retain the above
copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form of the Software may reproduce the above
copyright notice, this list of conditions and the following disclaimer in
the documentation and/or materials provided with the distribution.
Neither the name of Intel Corporation nor the names of its contributors
shall be used to endorse or promote products derived from this Software
without specific prior written permission.
Intel hereby grants Recipient and Licensees a non-exclusive, worldwide,
royalty-free patent license under Licensed Patents to make, use, sell, offer
to sell, import and otherwise transfer the Software, if any, in source code
and object code form. This license shall include changes to the Software
that are error corrections or other minor changes to the Software that do
not add functionality or features when the Software is incorporated in any
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR IT CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
ANY LOSS OF USE; DATA, OR PROFITS; OR BUSINESS INTERUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#include "e100.h"
#include "e100_config.h"
#ifdef ETHTOOL_TEST
extern u16 e100_eeprom_read(struct e100_private *, u16);
extern int e100_wait_exec_cmplx(struct e100_private *, u32,u8);
extern void e100_phy_reset(struct e100_private *bdp);
static u8 e100_diag_selftest(struct net_device *);
static u8 e100_diag_eeprom(struct net_device *);
static u8 e100_diag_loopback(struct net_device *);
static u8 e100_diag_one_loopback (struct net_device *, u8);
static u8 e100_diag_rcv_loopback_pkt(struct e100_private *);
static void e100_diag_config_loopback(struct e100_private *, u8, u8, u8 *,u8 *);
static u8 e100_diag_loopback_alloc(struct e100_private *);
static void e100_diag_loopback_cu_ru_exec(struct e100_private *);
static u8 e100_diag_check_pkt(u8 *);
static void e100_diag_loopback_free(struct e100_private *);
#define LB_PACKET_SIZE 1500
/**
* e100_run_diag - main test execution handler - checks mask of requests and calls the diag routines
* @dev: atapter's net device data struct
* @test_info: array with test request mask also used to store test results
*
* RETURNS: updated flags field of struct ethtool_test
*/
u32
e100_run_diag(struct net_device *dev, u64 *test_info, u32 flags)
{
struct e100_private* bdp = dev->priv;
u8 test_result = true;
e100_isolate_driver(bdp);
if (flags & ETH_TEST_FL_OFFLINE) {
u8 fail_mask;
fail_mask = e100_diag_selftest(dev);
if (fail_mask) {
test_result = false;
if (fail_mask & REGISTER_TEST_FAIL)
test_info [E100_REG_TEST_FAIL] = true;
if (fail_mask & ROM_TEST_FAIL)
test_info [E100_ROM_TEST_FAIL] = true;
if (fail_mask & SELF_TEST_FAIL)
test_info [E100_MAC_TEST_FAIL] = true;
if (fail_mask & TEST_TIMEOUT)
test_info [E100_CHIP_TIMEOUT] = true;
}
fail_mask = e100_diag_loopback(dev);
if (fail_mask) {
test_result = false;
if (fail_mask & PHY_LOOPBACK)
test_info [E100_LPBK_PHY_FAIL] = true;
if (fail_mask & MAC_LOOPBACK)
test_info [E100_LPBK_MAC_FAIL] = true;
}
}
if (!e100_diag_eeprom(dev)) {
test_result = false;
test_info [E100_EEPROM_TEST_FAIL] = true;
}
/* fully recover only if the device is open*/
if (netif_running(dev)) {
e100_deisolate_driver(bdp, true, false);
} else {
e100_deisolate_driver(bdp, false, false);
}
/*Let card recover from the test*/
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ * 2);
return flags | (test_result ? 0 : ETH_TEST_FL_FAILED);
}
/**
* e100_diag_selftest - run hardware selftest
* @dev: atapter's net device data struct
*/
static u8
e100_diag_selftest(struct net_device *dev)
{
struct e100_private *bdp = dev->priv;
u32 st_timeout, st_result;
u8 retval = 0;
if (!e100_selftest(bdp, &st_timeout, &st_result)) {
if (!st_timeout) {
if (st_result & CB_SELFTEST_REGISTER_BIT)
retval |= REGISTER_TEST_FAIL;
if (st_result & CB_SELFTEST_DIAG_BIT)
retval |= SELF_TEST_FAIL;
if (st_result & CB_SELFTEST_ROM_BIT)
retval |= ROM_TEST_FAIL;
} else {
retval = TEST_TIMEOUT;
}
}
e100_hw_reset_recover(bdp,PORT_SOFTWARE_RESET);
return retval;
}
/**
* e100_diag_eeprom - validate eeprom checksum correctness
* @dev: atapter's net device data struct
*
*/
static u8
e100_diag_eeprom (struct net_device *dev)
{
struct e100_private *bdp = dev->priv;
u16 i, eeprom_sum, eeprom_actual_csm;
for (i = 0, eeprom_sum = 0; i < (bdp->eeprom_size - 1); i++) {
eeprom_sum += e100_eeprom_read(bdp, i);
}
eeprom_actual_csm = e100_eeprom_read(bdp, bdp->eeprom_size - 1);
if (eeprom_actual_csm == (u16)(EEPROM_SUM - eeprom_sum)) {
return true;
}
return false;
}
/**
* e100_diag_loopback - performs loopback test
* @dev: atapter's net device data struct
*/
static u8
e100_diag_loopback (struct net_device *dev)
{
u8 rc = 0;
if (!e100_diag_one_loopback(dev, PHY_LOOPBACK)) {
rc |= PHY_LOOPBACK;
}
if (!e100_diag_one_loopback(dev, MAC_LOOPBACK)) {
rc |= MAC_LOOPBACK;
}
return rc;
}
/**
* e100_diag_loopback - performs loopback test
* @dev: atapter's net device data struct
* @mode: lopback test type
*/
static u8
e100_diag_one_loopback (struct net_device *dev, u8 mode)
{
struct e100_private *bdp = dev->priv;
u8 res = false;
u8 saved_dynamic_tbd = false;
u8 saved_extended_tcb = false;
if (!e100_diag_loopback_alloc(bdp))
return false;
/* change the config block to standard tcb and the correct loopback */
e100_diag_config_loopback(bdp, true, mode,
&saved_extended_tcb, &saved_dynamic_tbd);
e100_diag_loopback_cu_ru_exec(bdp);
if (e100_diag_rcv_loopback_pkt(bdp)) {
res = true;
}
e100_diag_loopback_free(bdp);
/* change the config block to previous tcb mode and the no loopback */
e100_diag_config_loopback(bdp, false, mode,
&saved_extended_tcb, &saved_dynamic_tbd);
return res;
}
/**
* e100_diag_config_loopback - setup/clear loopback before/after lpbk test
* @bdp: atapter's private data struct
* @set_loopback: true if the function is called to set lb
* @loopback_mode: the loopback mode(MAC or PHY)
* @tcb_extended: true if need to set extended tcb mode after clean loopback
* @dynamic_tbd: true if needed to set dynamic tbd mode after clean loopback
*
*/
void
e100_diag_config_loopback(struct e100_private* bdp,
u8 set_loopback,
u8 loopback_mode,
u8* tcb_extended,
u8* dynamic_tbd)
{
/* if set_loopback == true - we want to clear tcb_extended/dynamic_tbd.
* the previous values are saved in the params tcb_extended/dynamic_tbd
* if set_loopback == false - we want to restore previous value.
*/
if (set_loopback || (*tcb_extended))
*tcb_extended = e100_config_tcb_ext_enable(bdp,*tcb_extended);
if (set_loopback || (*dynamic_tbd))
*dynamic_tbd = e100_config_dynamic_tbd(bdp,*dynamic_tbd);
if (set_loopback) {
e100_config_loopback_mode(bdp,loopback_mode);
} else {
e100_config_loopback_mode(bdp,NO_LOOPBACK);
}
e100_config(bdp);
if (loopback_mode == PHY_LOOPBACK) {
unsigned long expires = jiffies + HZ * 5;
if (set_loopback)
e100_phy_reset(bdp);
/* wait up to 5 secs for PHY loopback ON/OFF to take effect */
while ((e100_get_link_state(bdp) != set_loopback) &&
time_before(jiffies, expires)) {
yield();
}
} else { /* For MAC loopback wait 500 msec to take effect */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ / 2);
}
}
/**
* e100_diag_loopback_alloc - alloc & initate tcb and rfd for the loopback
* @bdp: atapter's private data struct
*
*/
static u8
e100_diag_loopback_alloc(struct e100_private *bdp)
{
dma_addr_t dma_handle;
tcb_t *tcb;
rfd_t *rfd;
tbd_t *tbd;
tcb = pci_alloc_consistent(bdp->pdev,
(sizeof (tcb_t) + sizeof (tbd_t) +
LB_PACKET_SIZE),
&dma_handle);
if (tcb == NULL)
return false;
memset(tcb, 0x00, sizeof (tcb_t) + LB_PACKET_SIZE);
tcb->tcb_phys = dma_handle;
tcb->tcb_hdr.cb_status = 0;
tcb->tcb_hdr.cb_cmd =
cpu_to_le16(CB_EL_BIT | CB_TRANSMIT | CB_TX_SF_BIT);
tcb->tcb_hdr.cb_lnk_ptr = cpu_to_le32(tcb->tcb_phys);
tcb->tcb_tbd_ptr = cpu_to_le32(0xffffffff);
tcb->tcb_cnt = 0;
tcb->tcb_thrshld = bdp->tx_thld;
tcb->tcb_tbd_num = 1;
tcb->tcb_tbd_ptr = cpu_to_le32(tcb->tcb_phys + sizeof (tcb_t));
tbd = (tbd_t *) ((u8 *) tcb + sizeof (tcb_t));
tbd->tbd_buf_addr =
cpu_to_le32(le32_to_cpu(tcb->tcb_tbd_ptr) + sizeof (tbd_t));
tbd->tbd_buf_cnt = __constant_cpu_to_le16(1024);
memset((void *) ((u8 *) tbd + sizeof (tbd_t)), 0xFF, 1024);
memset((void *) ((u8 *) tbd + sizeof (tbd_t) + 512), 0xBA, 512);
wmb();
rfd = pci_alloc_consistent(bdp->pdev, sizeof (rfd_t), &dma_handle);
if (rfd == NULL) {
pci_free_consistent(bdp->pdev,
sizeof (tcb_t) + sizeof (tbd_t) +
LB_PACKET_SIZE, tcb, tcb->tcb_phys);
return false;
}
memset(rfd, 0x00, sizeof (rfd_t));
/* init all fields in rfd */
rfd->rfd_header.cb_status = 0;
rfd->rfd_header.cb_cmd = cpu_to_le16(RFD_EL_BIT);
rfd->rfd_act_cnt = 0;
rfd->rfd_sz = cpu_to_le16(ETH_FRAME_LEN + CHKSUM_SIZE);
bdp->loopback.dma_handle = dma_handle;
bdp->loopback.tcb = tcb;
bdp->loopback.rfd = rfd;
wmb();
return true;
}
/**
* e100_diag_loopback_cu_ru_exec - activates cu and ru to send & receive the pkt
* @bdp: atapter's private data struct
*
*/
static void
e100_diag_loopback_cu_ru_exec(struct e100_private *bdp)
{
/*load CU & RU base */
if (!e100_wait_exec_cmplx(bdp, 0, SCB_CUC_LOAD_BASE))
printk("@@@ SCB_CUC_LOAD_BASE failed\n");
if(!e100_wait_exec_cmplx(bdp, 0, SCB_RUC_LOAD_BASE))
printk("@@@ SCB_RUC_LOAD_BASE failed!\n");
if(!e100_wait_exec_cmplx(bdp, bdp->loopback.dma_handle, SCB_RUC_START))
printk("@@@ SCB_RUC_START failed!\n");
bdp->next_cu_cmd = START_WAIT;
e100_start_cu(bdp, bdp->loopback.tcb);
bdp->last_tcb = NULL;
rmb();
}
/**
* e100_diag_check_pkt - checks if a given packet is a loopback packet
* @bdp: atapter's private data struct
*
* Returns true if OK false otherwise.
*/
static u8
e100_diag_check_pkt(u8 *datap)
{
if( (*datap)==0xFF) {
if(*(datap + 600) == 0xBA) {
return true;
}
}
return false;
}
/**
* e100_diag_rcv_loopback_pkt - waits for receive and checks lpbk packet
* @bdp: atapter's private data struct
*
* Returns true if OK false otherwise.
*/
static u8
e100_diag_rcv_loopback_pkt(struct e100_private* bdp)
{
rfd_t *rfdp;
u16 rfd_status;
unsigned long expires = jiffies + HZ * 2;
rfdp =bdp->loopback.rfd;
rfd_status = le16_to_cpu(rfdp->rfd_header.cb_status);
while (!(rfd_status & RFD_STATUS_COMPLETE)) {
if (time_before(jiffies, expires)) {
yield();
rmb();
rfd_status = le16_to_cpu(rfdp->rfd_header.cb_status);
} else {
break;
}
}
if (rfd_status & RFD_STATUS_COMPLETE)
return e100_diag_check_pkt(((u8 *)rfdp+bdp->rfd_size));
else
return false;
}
/**
* e100_diag_loopback_free - free data allocated for loopback pkt send/receive
* @bdp: atapter's private data struct
*
*/
static void
e100_diag_loopback_free (struct e100_private *bdp)
{
pci_free_consistent(bdp->pdev,
sizeof(tcb_t) + sizeof(tbd_t) + LB_PACKET_SIZE,
bdp->loopback.tcb, bdp->loopback.tcb->tcb_phys);
pci_free_consistent(bdp->pdev, sizeof(rfd_t), bdp->loopback.rfd,
bdp->loopback.dma_handle);
}
#endif
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -16,7 +15,7 @@ combined with the operating system referred to below.
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -49,10 +48,10 @@ not add functionality or features when the Software is incorporated in any
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......
......@@ -9,8 +9,7 @@
O_TARGET := e1000.o
obj-y := e1000_main.o e1000_mac.o e1000_phy.o \
e1000_ethtool.o e1000_param.o e1000_proc.o
obj-y := e1000_main.o e1000_hw.o e1000_ethtool.o e1000_param.o e1000_proc.o
obj-m := $(O_TARGET)
include $(TOPDIR)/Rules.make
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......@@ -109,11 +108,14 @@
#include <net/pkt_sched.h>
#include <linux/list.h>
#include <asm/uaccess.h>
#include <linux/ethtool.h>
#ifdef NETIF_F_HW_VLAN_TX
#include <linux/if_vlan.h>
#endif
struct e1000_adapter;
#include "e1000_mac.h"
#include "e1000_phy.h"
#include "e1000_hw.h"
#define BAR_0 0
......@@ -139,6 +141,8 @@ struct e1000_adapter;
/* 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 ? */
#define E1000_RX_BUFFER_WRITE 16
#define E1000_JUMBO_PBA 0x00000028
#define E1000_DEFAULT_PBA 0x00000030
......@@ -163,10 +167,6 @@ struct e1000_desc_ring {
unsigned int size;
/* number of descriptors in the ring */
unsigned int count;
/* (atomic) number of desc with no buffer */
atomic_t unused;
/* number of desc with no buffer */
unsigned int unused_count;
/* next descriptor to associate a buffer with */
unsigned int next_to_use;
/* next descriptor to check for DD status bit */
......@@ -175,14 +175,13 @@ struct e1000_desc_ring {
struct e1000_buffer *buffer_info;
};
#define E1000_RX_DESC(ring, i) \
(&(((struct e1000_rx_desc *)((ring).desc))[i]))
#define E1000_TX_DESC(ring, i) \
(&(((struct e1000_tx_desc *)((ring).desc))[i]))
#define E1000_DESC_UNUSED(R) \
((((R)->next_to_clean + (R)->count) - ((R)->next_to_use + 1)) % ((R)->count))
#define E1000_CONTEXT_DESC(ring, i) \
(&(((struct e1000_context_desc *)((ring).desc))[i]))
#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
#define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
#define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
#define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
/* board specific private data structure */
......@@ -191,6 +190,9 @@ struct e1000_adapter {
struct timer_list phy_info_timer;
#ifdef CONFIG_PROC_FS
struct list_head proc_list_head;
#endif
#ifdef NETIF_F_HW_VLAN_TX
struct vlan_group *vlgrp;
#endif
char *id_string;
uint32_t bd_number;
......@@ -201,28 +203,29 @@ struct e1000_adapter {
uint16_t link_duplex;
spinlock_t stats_lock;
atomic_t irq_sem;
boolean_t rx_csum;
/* TX */
struct e1000_desc_ring tx_ring;
unsigned long trans_finish;
uint32_t tx_int_delay;
spinlock_t tx_lock;
uint32_t txd_cmd;
int max_data_per_txd;
/* RX */
struct e1000_desc_ring rx_ring;
uint64_t hw_csum_err;
uint64_t hw_csum_good;
uint32_t rx_int_delay;
boolean_t rx_csum;
/* OS defined structs */
struct net_device *netdev;
struct pci_dev *pdev;
struct net_device_stats net_stats;
/* structs defined in e1000_mac.h or e1000_phy.h */
struct e1000_shared_adapter shared;
struct e1000_shared_stats stats;
/* structs defined in e1000_hw.h */
struct e1000_hw hw;
struct e1000_hw_stats stats;
struct e1000_phy_info phy_info;
struct e1000_phy_stats phy_stats;
};
......
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......@@ -89,9 +88,9 @@ extern void e1000_enable_WOL(struct e1000_adapter *adapter);
static void
e1000_ethtool_gset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
if(shared->media_type == e1000_media_type_copper) {
if(hw->media_type == e1000_media_type_copper) {
ecmd->supported = (SUPPORTED_10baseT_Half |
SUPPORTED_10baseT_Full |
......@@ -103,18 +102,18 @@ e1000_ethtool_gset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
ecmd->advertising = ADVERTISED_TP;
if(shared->autoneg == 1) {
if(hw->autoneg == 1) {
ecmd->advertising |= ADVERTISED_Autoneg;
/* the e1000 autoneg seems to match ethtool nicely */
ecmd->advertising |= shared->autoneg_advertised;
ecmd->advertising |= hw->autoneg_advertised;
}
ecmd->port = PORT_TP;
ecmd->phy_address = shared->phy_addr;
ecmd->phy_address = hw->phy_addr;
if(shared->mac_type == e1000_82543)
if(hw->mac_type == e1000_82543)
ecmd->transceiver = XCVR_EXTERNAL;
else
ecmd->transceiver = XCVR_INTERNAL;
......@@ -129,13 +128,12 @@ e1000_ethtool_gset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
SUPPORTED_Autoneg);
ecmd->port = PORT_FIBRE;
ecmd->transceiver = XCVR_EXTERNAL;
}
if(netif_carrier_ok(adapter->netdev)) {
e1000_get_speed_and_duplex(shared, &adapter->link_speed,
e1000_get_speed_and_duplex(hw, &adapter->link_speed,
&adapter->link_duplex);
ecmd->speed = adapter->link_speed;
......@@ -151,37 +149,35 @@ e1000_ethtool_gset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
ecmd->duplex = -1;
}
ecmd->autoneg = (shared->autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
return;
ecmd->autoneg = (hw->autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
}
static int
e1000_ethtool_sset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
if(ecmd->autoneg == AUTONEG_ENABLE) {
shared->autoneg = 1;
shared->autoneg_advertised = (ecmd->advertising & 0x002F);
hw->autoneg = 1;
hw->autoneg_advertised = (ecmd->advertising & 0x002F);
} else {
shared->autoneg = 0;
hw->autoneg = 0;
switch(ecmd->speed + ecmd->duplex) {
case SPEED_10 + DUPLEX_HALF:
shared->forced_speed_duplex = e1000_10_half;
hw->forced_speed_duplex = e1000_10_half;
break;
case SPEED_10 + DUPLEX_FULL:
shared->forced_speed_duplex = e1000_10_full;
hw->forced_speed_duplex = e1000_10_full;
break;
case SPEED_100 + DUPLEX_HALF:
shared->forced_speed_duplex = e1000_100_half;
hw->forced_speed_duplex = e1000_100_half;
break;
case SPEED_100 + DUPLEX_FULL:
shared->forced_speed_duplex = e1000_100_full;
hw->forced_speed_duplex = e1000_100_full;
break;
case SPEED_1000 + DUPLEX_FULL:
shared->autoneg = 1;
shared->autoneg_advertised = ADVERTISE_1000_FULL;
hw->autoneg = 1;
hw->autoneg_advertised = ADVERTISE_1000_FULL;
break;
case SPEED_1000 + DUPLEX_HALF: /* not supported */
default:
......@@ -198,8 +194,12 @@ e1000_ethtool_sset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
}
static inline int
e1000_eeprom_size(struct e1000_shared_adapter *shared)
e1000_eeprom_size(struct e1000_hw *hw)
{
if((hw->mac_type > e1000_82544) &&
(E1000_READ_REG(hw, EECD) & E1000_EECD_SIZE))
return 512;
else
return 128;
}
......@@ -211,36 +211,33 @@ e1000_ethtool_gdrvinfo(struct e1000_adapter *adapter,
strncpy(drvinfo->version, e1000_driver_version, 32);
strncpy(drvinfo->fw_version, "", 32);
strncpy(drvinfo->bus_info, adapter->pdev->slot_name, 32);
drvinfo->eedump_len = e1000_eeprom_size(&adapter->shared);
return;
drvinfo->eedump_len = e1000_eeprom_size(&adapter->hw);
}
static void
e1000_ethtool_geeprom(struct e1000_adapter *adapter,
struct ethtool_eeprom *eeprom, uint16_t *eeprom_buff)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
int i, max_len;
eeprom->magic = shared->vendor_id | (shared->device_id << 16);
eeprom->magic = hw->vendor_id | (hw->device_id << 16);
max_len = e1000_eeprom_size(shared);
max_len = e1000_eeprom_size(hw);
if ((eeprom->offset + eeprom->len) > max_len)
eeprom->len = (max_len - eeprom->offset);
for(i = 0; i < max_len; i++)
eeprom_buff[i] = e1000_read_eeprom(&adapter->shared, i);
return;
e1000_read_eeprom(&adapter->hw, i, &eeprom_buff[i]);
}
static void
e1000_ethtool_gwol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
if(shared->mac_type < e1000_82544) {
if(hw->mac_type < e1000_82544) {
wol->supported = 0;
wol->wolopts = 0;
return;
......@@ -260,17 +257,15 @@ e1000_ethtool_gwol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
wol->wolopts |= WAKE_BCAST;
if(adapter->wol & E1000_WUFC_MAG)
wol->wolopts |= WAKE_MAGIC;
return;
}
static int
e1000_ethtool_swol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
if(shared->mac_type < e1000_82544)
return wol->wolopts == 0 ? 0 : -EOPNOTSUPP;
if(hw->mac_type < e1000_82544)
return wol->wolopts ? -EOPNOTSUPP : 0;
adapter->wol = 0;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......@@ -72,18 +71,18 @@
*******************************************************************************/
/* e1000_mac.h
/* e1000_hw.h
* Structures, enums, and macros for the MAC
*/
#ifndef _E1000_MAC_H_
#define _E1000_MAC_H_
#ifndef _E1000_HW_H_
#define _E1000_HW_H_
#include "e1000_osdep.h"
/* Forward declarations of structures used by the shared code */
struct e1000_shared_adapter;
struct e1000_shared_stats;
struct e1000_hw;
struct e1000_hw_stats;
/* Enumerated types specific to the e1000 hardware */
/* Media Access Controlers */
......@@ -92,6 +91,7 @@ typedef enum {
e1000_82542_rev2_1,
e1000_82543,
e1000_82544,
e1000_82540,
e1000_num_macs
} e1000_mac_type;
......@@ -142,40 +142,125 @@ typedef enum {
e1000_bus_width_64
} e1000_bus_width;
/* PHY status info structure and supporting enums */
typedef enum {
e1000_cable_length_50 = 0,
e1000_cable_length_50_80,
e1000_cable_length_80_110,
e1000_cable_length_110_140,
e1000_cable_length_140,
e1000_cable_length_undefined = 0xFF
} e1000_cable_length;
typedef enum {
e1000_10bt_ext_dist_enable_normal = 0,
e1000_10bt_ext_dist_enable_lower,
e1000_10bt_ext_dist_enable_undefined = 0xFF
} e1000_10bt_ext_dist_enable;
/* Function prototypes */
/* Setup */
void e1000_adapter_stop(struct e1000_shared_adapter *shared);
boolean_t e1000_init_hw(struct e1000_shared_adapter *shared);
void e1000_init_rx_addrs(struct e1000_shared_adapter *shared);
typedef enum {
e1000_rev_polarity_normal = 0,
e1000_rev_polarity_reversed,
e1000_rev_polarity_undefined = 0xFF
} e1000_rev_polarity;
/* Filters (multicast, vlan, receive) */
void e1000_mc_addr_list_update(struct e1000_shared_adapter *shared, uint8_t * mc_addr_list, uint32_t mc_addr_count, uint32_t pad);
uint32_t e1000_hash_mc_addr(struct e1000_shared_adapter *shared, uint8_t * mc_addr);
void e1000_mta_set(struct e1000_shared_adapter *shared, uint32_t hash_value);
void e1000_rar_set(struct e1000_shared_adapter *shared, uint8_t * mc_addr, uint32_t rar_index);
void e1000_write_vfta(struct e1000_shared_adapter *shared, uint32_t offset, uint32_t value);
void e1000_clear_vfta(struct e1000_shared_adapter *shared);
/* Link layer setup functions */
boolean_t e1000_setup_fc_and_link(struct e1000_shared_adapter *shared);
boolean_t e1000_setup_pcs_link(struct e1000_shared_adapter *shared, uint32_t dev_ctrl_reg);
void e1000_config_fc_after_link_up(struct e1000_shared_adapter *shared);
void e1000_check_for_link(struct e1000_shared_adapter *shared);
void e1000_get_speed_and_duplex(struct e1000_shared_adapter *shared, uint16_t * speed, uint16_t * duplex);
typedef enum {
e1000_polarity_reversal_enabled = 0,
e1000_polarity_reversal_disabled,
e1000_polarity_reversal_undefined = 0xFF
} e1000_polarity_reversal;
typedef enum {
e1000_auto_x_mode_manual_mdi = 0,
e1000_auto_x_mode_manual_mdix,
e1000_auto_x_mode_auto1,
e1000_auto_x_mode_auto2,
e1000_auto_x_mode_undefined = 0xFF
} e1000_auto_x_mode;
typedef enum {
e1000_1000t_rx_status_not_ok = 0,
e1000_1000t_rx_status_ok,
e1000_1000t_rx_status_undefined = 0xFF
} e1000_1000t_rx_status;
struct e1000_phy_info {
e1000_cable_length cable_length;
e1000_10bt_ext_dist_enable extended_10bt_distance;
e1000_rev_polarity cable_polarity;
e1000_polarity_reversal polarity_correction;
e1000_auto_x_mode mdix_mode;
e1000_1000t_rx_status local_rx;
e1000_1000t_rx_status remote_rx;
};
struct e1000_phy_stats {
uint32_t idle_errors;
uint32_t receive_errors;
};
/* Error Codes */
#define E1000_SUCCESS 0
#define E1000_ERR_EEPROM 1
#define E1000_ERR_PHY 2
#define E1000_ERR_CONFIG 3
#define E1000_ERR_PARAM 4
/* Function prototypes */
/* Initialization */
void e1000_reset_hw(struct e1000_hw *hw);
int32_t e1000_init_hw(struct e1000_hw *hw);
/* Link Configuration */
int32_t e1000_setup_link(struct e1000_hw *hw);
int32_t e1000_phy_setup_autoneg(struct e1000_hw *hw);
void e1000_config_collision_dist(struct e1000_hw *hw);
int32_t e1000_config_fc_after_link_up(struct e1000_hw *hw);
int32_t e1000_check_for_link(struct e1000_hw *hw);
void e1000_get_speed_and_duplex(struct e1000_hw *hw, uint16_t * speed, uint16_t * duplex);
int32_t e1000_wait_autoneg(struct e1000_hw *hw);
/* PHY */
int32_t e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
int32_t e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data);
void e1000_phy_hw_reset(struct e1000_hw *hw);
int32_t e1000_phy_reset(struct e1000_hw *hw);
int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
int32_t e1000_validate_mdi_setting(struct e1000_hw *hw);
/* EEPROM Functions */
uint16_t e1000_read_eeprom(struct e1000_shared_adapter *shared, uint16_t reg);
boolean_t e1000_validate_eeprom_checksum(struct e1000_shared_adapter *shared);
int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t *data);
int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw);
int32_t e1000_read_part_num(struct e1000_hw *hw, uint32_t * part_num);
int32_t e1000_read_mac_addr(struct e1000_hw * hw);
/* Filters (multicast, vlan, receive) */
void e1000_init_rx_addrs(struct e1000_hw *hw);
void e1000_mc_addr_list_update(struct e1000_hw *hw, uint8_t * mc_addr_list, uint32_t mc_addr_count, uint32_t pad);
uint32_t e1000_hash_mc_addr(struct e1000_hw *hw, uint8_t * mc_addr);
void e1000_mta_set(struct e1000_hw *hw, uint32_t hash_value);
void e1000_rar_set(struct e1000_hw *hw, uint8_t * mc_addr, uint32_t rar_index);
void e1000_write_vfta(struct e1000_hw *hw, uint32_t offset, uint32_t value);
void e1000_clear_vfta(struct e1000_hw *hw);
/* LED functions */
int32_t e1000_setup_led(struct e1000_hw *hw);
int32_t e1000_cleanup_led(struct e1000_hw *hw);
int32_t e1000_led_on(struct e1000_hw *hw);
int32_t e1000_led_off(struct e1000_hw *hw);
/* Adaptive IFS Functions */
/* Everything else */
void e1000_clear_hw_cntrs(struct e1000_shared_adapter *shared);
boolean_t e1000_read_part_num(struct e1000_shared_adapter *shared, uint32_t * part_num);
void e1000_read_mac_addr(struct e1000_shared_adapter * shared);
void e1000_get_bus_info(struct e1000_shared_adapter *shared);
uint32_t e1000_tbi_adjust_stats(struct e1000_shared_adapter *shared, struct e1000_shared_stats *stats, uint32_t frame_len, uint8_t * mac_addr);
void e1000_write_pci_cfg(struct e1000_shared_adapter *shared, uint32_t reg, uint16_t * value);
void e1000_clear_hw_cntrs(struct e1000_hw *hw);
void e1000_reset_adaptive(struct e1000_hw *hw);
void e1000_update_adaptive(struct e1000_hw *hw);
void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, uint32_t frame_len, uint8_t * mac_addr);
void e1000_get_bus_info(struct e1000_hw *hw);
void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
/* PCI Device IDs */
#define E1000_DEV_ID_82542 0x1000
......@@ -185,7 +270,9 @@ void e1000_write_pci_cfg(struct e1000_shared_adapter *shared, uint32_t reg, uint
#define E1000_DEV_ID_82544EI_FIBER 0x1009
#define E1000_DEV_ID_82544GC_COPPER 0x100C
#define E1000_DEV_ID_82544GC_LOM 0x100D
#define NUM_DEV_IDS 7
#define E1000_DEV_ID_82540EM 0x100E
#define E1000_DEV_ID_82540EM_LOM 0x1015
#define NUM_DEV_IDS 9
#define NODE_ADDRESS_SIZE 6
#define ETH_LENGTH_OF_ADDRESS 6
......@@ -204,9 +291,14 @@ void e1000_write_pci_cfg(struct e1000_shared_adapter *shared, uint32_t reg, uint
/* The sizes (in bytes) of a ethernet packet */
#define ENET_HEADER_SIZE 14
#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /* Without FCS */
#define MINIMUM_ETHERNET_PACKET_SIZE 60 /* Without FCS */
#define CRC_LENGTH 4
#define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* With FCS */
#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
#define ETHERNET_FCS_SIZE 4
#define MAXIMUM_ETHERNET_PACKET_SIZE \
(MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
#define MINIMUM_ETHERNET_PACKET_SIZE \
(MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
#define CRC_LENGTH ETHERNET_FCS_SIZE
#define MAX_JUMBO_FRAME_SIZE 0x3F00
......@@ -481,6 +573,7 @@ struct e1000_ffvt_entry {
#define E1000_TCTL 0x00400 /* TX Control - RW */
#define E1000_TIPG 0x00410 /* TX Inter-packet gap -RW */
#define E1000_TBT 0x00448 /* TX Burst Timer - RW */
#define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */
#define E1000_LEDCTL 0x00E00 /* LED Control - RW */
#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */
#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */
......@@ -623,6 +716,7 @@ struct e1000_ffvt_entry {
#define E1000_82542_TDT 0x00438
#define E1000_82542_TIDV 0x00440
#define E1000_82542_TBT E1000_TBT
#define E1000_82542_AIT E1000_AIT
#define E1000_82542_VFTA 0x00600
#define E1000_82542_LEDCTL E1000_LEDCTL
#define E1000_82542_PBA E1000_PBA
......@@ -706,7 +800,7 @@ struct e1000_ffvt_entry {
#define E1000_82542_FFVT E1000_FFVT
/* Statistics counters collected by the MAC */
struct e1000_shared_stats {
struct e1000_hw_stats {
uint64_t crcerrs;
uint64_t algnerrc;
uint64_t symerrs;
......@@ -767,10 +861,8 @@ struct e1000_shared_stats {
uint64_t tsctfc;
};
/* Structure containing variables used by the shared code (e1000_mac.c and
* e1000_phy.c)
*/
struct e1000_shared_adapter {
/* Structure containing variables used by the shared code (e1000_hw.c) */
struct e1000_hw {
uint8_t *hw_addr;
e1000_mac_type mac_type;
e1000_media_type media_type;
......@@ -782,29 +874,30 @@ struct e1000_shared_adapter {
uint32_t phy_id;
uint32_t phy_addr;
uint32_t original_fc;
uint32_t txcw_reg;
uint32_t txcw;
uint32_t autoneg_failed;
uint32_t max_frame_size;
uint32_t min_frame_size;
uint32_t mc_filter_type;
uint32_t num_mc_addrs;
uint32_t collision_delta;
uint32_t tx_packet_delta;
uint32_t ledctl;
uint16_t autoneg_advertised;
uint16_t pci_cmd_word;
uint16_t fc_high_water;
uint16_t fc_low_water;
uint16_t fc_pause_time;
uint16_t current_ifs_val;
uint16_t ifs_min_val;
uint16_t ifs_max_val;
uint16_t ifs_step_size;
uint16_t ifs_ratio;
uint16_t device_id;
uint16_t vendor_id;
uint16_t subsystem_id;
uint16_t subsystem_vendor_id;
uint8_t revision_id;
boolean_t disable_polarity_correction;
boolean_t get_link_status;
boolean_t tbi_compatibility_en;
boolean_t tbi_compatibility_on;
boolean_t adapter_stopped;
boolean_t fc_send_xon;
boolean_t report_tx_early;
uint8_t autoneg;
uint8_t mdix;
uint8_t forced_speed_duplex;
......@@ -812,6 +905,15 @@ struct e1000_shared_adapter {
uint8_t dma_fairness;
uint8_t mac_addr[NODE_ADDRESS_SIZE];
uint8_t perm_mac_addr[NODE_ADDRESS_SIZE];
boolean_t disable_polarity_correction;
boolean_t get_link_status;
boolean_t tbi_compatibility_en;
boolean_t tbi_compatibility_on;
boolean_t fc_send_xon;
boolean_t report_tx_early;
boolean_t adaptive_ifs;
boolean_t ifs_params_forced;
boolean_t in_ifs_mode;
};
......@@ -1254,8 +1356,9 @@ struct e1000_shared_adapter {
/* Collision related configuration parameters */
#define E1000_COLLISION_THRESHOLD 16
#define E1000_CT_SHIFT 4
#define E1000_FDX_COLLISION_DISTANCE 64
#define E1000_HDX_COLLISION_DISTANCE 64
#define E1000_COLLISION_DISTANCE 64
#define E1000_FDX_COLLISION_DISTANCE E1000_COLLISION_DISTANCE
#define E1000_HDX_COLLISION_DISTANCE E1000_COLLISION_DISTANCE
#define E1000_GB_HDX_COLLISION_DISTANCE 512
#define E1000_COLD_SHIFT 12
......@@ -1282,6 +1385,19 @@ struct e1000_shared_adapter {
#define E1000_TXDMAC_DPP 0x00000001
/* Adaptive IFS defines */
#define TX_THRESHOLD_START 8
#define TX_THRESHOLD_INCREMENT 10
#define TX_THRESHOLD_DECREMENT 1
#define TX_THRESHOLD_STOP 190
#define TX_THRESHOLD_DISABLE 0
#define TX_THRESHOLD_TIMER_MS 10000
#define MIN_NUM_XMITS 1000
#define IFS_MAX 80
#define IFS_STEP 10
#define IFS_MIN 40
#define IFS_RATIO 4
/* PBA constants */
#define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
#define E1000_PBA_24K 0x0018
......@@ -1336,18 +1452,10 @@ struct e1000_shared_adapter {
#define CARRIER_EXTENSION 0x0F
/* TBI_ACCEPT macro definition:
*
* If Tbi Compatibility mode is turned-on, then we should accept frames with
* receive errors if and only if:
* 1) errors is equal to the CRC error bit.
* 2) The last byte is a Carrier extension (0x0F).
* 3) The frame length (as reported by Hardware) is greater than 64 (60
* if a VLAN tag was stripped from the frame.
* 4) " " " " " " " <= max_frame_size+1.
*
* This macro requires:
* adapter = a pointer to struct e1000_shared_adapter
* special = the 16 bit special field of the RX descriptor with EOP set
* adapter = a pointer to struct e1000_hw
* status = the 8 bit status field of the RX descriptor with EOP set
* error = the 8 bit error field of the RX descriptor with EOP set
* length = the sum of all the length fields of the RX descriptors that
* make up the current frame
......@@ -1370,14 +1478,290 @@ struct e1000_shared_adapter {
* ...
*/
#define TBI_ACCEPT(adapter, special, errors, length, last_byte) \
#define TBI_ACCEPT(adapter, status, errors, length, last_byte) \
((adapter)->tbi_compatibility_on && \
(((errors) & E1000_RXD_ERR_FRAME_ERR_MASK) == E1000_RXD_ERR_CE) && \
((last_byte) == CARRIER_EXTENSION) && \
((length) <= ((adapter)->max_frame_size + 1)) && \
((length) > ((special == 0x0000) ? \
((adapter)->min_frame_size) : \
((adapter)->min_frame_size - VLAN_TAG_SIZE))))
(((status) & E1000_RXD_STAT_VP) ? \
(((length) > ((adapter)->min_frame_size - VLAN_TAG_SIZE)) && \
((length) <= ((adapter)->max_frame_size + 1))) : \
(((length) > (adapter)->min_frame_size) && \
((length) <= ((adapter)->max_frame_size + VLAN_TAG_SIZE + 1)))))
/* Structures, enums, and macros for the PHY */
/* Bit definitions for the Management Data IO (MDIO) and Management Data
* Clock (MDC) pins in the Device Control Register.
*/
#define E1000_CTRL_PHY_RESET_DIR E1000_CTRL_SWDPIO0
#define E1000_CTRL_PHY_RESET E1000_CTRL_SWDPIN0
#define E1000_CTRL_MDIO_DIR E1000_CTRL_SWDPIO2
#define E1000_CTRL_MDIO E1000_CTRL_SWDPIN2
#define E1000_CTRL_MDC_DIR E1000_CTRL_SWDPIO3
#define E1000_CTRL_MDC E1000_CTRL_SWDPIN3
#define E1000_CTRL_PHY_RESET_DIR4 E1000_CTRL_EXT_SDP4_DIR
#define E1000_CTRL_PHY_RESET4 E1000_CTRL_EXT_SDP4_DATA
/* PHY 1000 MII Register/Bit Definitions */
/* PHY Registers defined by IEEE */
#define PHY_CTRL 0x00 /* Control Register */
#define PHY_STATUS 0x01 /* Status Regiser */
#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */
#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */
#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */
#define PHY_LP_ABILITY 0x05 /* Link Partner Ability (Base Page) */
#define PHY_AUTONEG_EXP 0x06 /* Autoneg Expansion Reg */
#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */
#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */
#define PHY_1000T_CTRL 0x09 /* 1000Base-T Control Reg */
#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */
/* M88E1000 Specific Registers */
#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */
#define M88E1000_PHY_SPEC_STATUS 0x11 /* PHY Specific Status Register */
#define M88E1000_INT_ENABLE 0x12 /* Interrupt Enable Register */
#define M88E1000_INT_STATUS 0x13 /* Interrupt Status Register */
#define M88E1000_EXT_PHY_SPEC_CTRL 0x14 /* Extended PHY Specific Control */
#define M88E1000_RX_ERR_CNTR 0x15 /* Receive Error Counter */
#define MAX_PHY_REG_ADDRESS 0x1F /* 5 bit address bus (0-0x1F) */
/* PHY Control Register */
#define MII_CR_SPEED_SELECT_MSB 0x0040 /* bits 6,13: 10=1000, 01=100, 00=10 */
#define MII_CR_COLL_TEST_ENABLE 0x0080 /* Collision test enable */
#define MII_CR_FULL_DUPLEX 0x0100 /* FDX =1, half duplex =0 */
#define MII_CR_RESTART_AUTO_NEG 0x0200 /* Restart auto negotiation */
#define MII_CR_ISOLATE 0x0400 /* Isolate PHY from MII */
#define MII_CR_POWER_DOWN 0x0800 /* Power down */
#define MII_CR_AUTO_NEG_EN 0x1000 /* Auto Neg Enable */
#define MII_CR_SPEED_SELECT_LSB 0x2000 /* bits 6,13: 10=1000, 01=100, 00=10 */
#define MII_CR_LOOPBACK 0x4000 /* 0 = normal, 1 = loopback */
#define MII_CR_RESET 0x8000 /* 0 = normal, 1 = PHY reset */
/* PHY Status Register */
#define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabilities */
#define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */
#define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 = link */
#define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */
#define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */
#define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */
#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F */
#define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */
#define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */
#define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */
#define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */
#define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */
#define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */
#define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */
/* Autoneg Advertisement Register */
#define NWAY_AR_SELECTOR_FIELD 0x0001 /* indicates IEEE 802.3 CSMA/CD */
#define NWAY_AR_10T_HD_CAPS 0x0020 /* 10T Half Duplex Capable */
#define NWAY_AR_10T_FD_CAPS 0x0040 /* 10T Full Duplex Capable */
#define NWAY_AR_100TX_HD_CAPS 0x0080 /* 100TX Half Duplex Capable */
#define NWAY_AR_100TX_FD_CAPS 0x0100 /* 100TX Full Duplex Capable */
#define NWAY_AR_100T4_CAPS 0x0200 /* 100T4 Capable */
#define NWAY_AR_PAUSE 0x0400 /* Pause operation desired */
#define NWAY_AR_ASM_DIR 0x0800 /* Asymmetric Pause Direction bit */
#define NWAY_AR_REMOTE_FAULT 0x2000 /* Remote Fault detected */
#define NWAY_AR_NEXT_PAGE 0x8000 /* Next Page ability supported */
/* Link Partner Ability Register (Base Page) */
#define NWAY_LPAR_SELECTOR_FIELD 0x0000 /* LP protocol selector field */
#define NWAY_LPAR_10T_HD_CAPS 0x0020 /* LP is 10T Half Duplex Capable */
#define NWAY_LPAR_10T_FD_CAPS 0x0040 /* LP is 10T Full Duplex Capable */
#define NWAY_LPAR_100TX_HD_CAPS 0x0080 /* LP is 100TX Half Duplex Capable */
#define NWAY_LPAR_100TX_FD_CAPS 0x0100 /* LP is 100TX Full Duplex Capable */
#define NWAY_LPAR_100T4_CAPS 0x0200 /* LP is 100T4 Capable */
#define NWAY_LPAR_PAUSE 0x0400 /* LP Pause operation desired */
#define NWAY_LPAR_ASM_DIR 0x0800 /* LP Asymmetric Pause Direction bit */
#define NWAY_LPAR_REMOTE_FAULT 0x2000 /* LP has detected Remote Fault */
#define NWAY_LPAR_ACKNOWLEDGE 0x4000 /* LP has rx'd link code word */
#define NWAY_LPAR_NEXT_PAGE 0x8000 /* Next Page ability supported */
/* Autoneg Expansion Register */
#define NWAY_ER_LP_NWAY_CAPS 0x0001 /* LP has Auto Neg Capability */
#define NWAY_ER_PAGE_RXD 0x0002 /* LP is 10T Half Duplex Capable */
#define NWAY_ER_NEXT_PAGE_CAPS 0x0004 /* LP is 10T Full Duplex Capable */
#define NWAY_ER_LP_NEXT_PAGE_CAPS 0x0008 /* LP is 100TX Half Duplex Capable */
#define NWAY_ER_PAR_DETECT_FAULT 0x0100 /* LP is 100TX Full Duplex Capable */
/* Next Page TX Register */
#define NPTX_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
#define NPTX_TOGGLE 0x0800 /* Toggles between exchanges
* of different NP
*/
#define NPTX_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
* 0 = cannot comply with msg
*/
#define NPTX_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
#define NPTX_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
* 0 = sending last NP
*/
/* Link Partner Next Page Register */
#define LP_RNPR_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
#define LP_RNPR_TOGGLE 0x0800 /* Toggles between exchanges
* of different NP
*/
#define LP_RNPR_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
* 0 = cannot comply with msg
*/
#define LP_RNPR_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
#define LP_RNPR_ACKNOWLDGE 0x4000 /* 1 = ACK / 0 = NO ACK */
#define LP_RNPR_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
* 0 = sending last NP
*/
#endif /* _E1000_MAC_H_ */
/* 1000BASE-T Control Register */
#define CR_1000T_ASYM_PAUSE 0x0080 /* Advertise asymmetric pause bit */
#define CR_1000T_HD_CAPS 0x0100 /* Advertise 1000T HD capability */
#define CR_1000T_FD_CAPS 0x0200 /* Advertise 1000T FD capability */
#define CR_1000T_REPEATER_DTE 0x0400 /* 1=Repeater/switch device port */
/* 0=DTE device */
#define CR_1000T_MS_VALUE 0x0800 /* 1=Configure PHY as Master */
/* 0=Configure PHY as Slave */
#define CR_1000T_MS_ENABLE 0x1000 /* 1=Master/Slave manual config value */
/* 0=Automatic Master/Slave config */
#define CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
#define CR_1000T_TEST_MODE_1 0x2000 /* Transmit Waveform test */
#define CR_1000T_TEST_MODE_2 0x4000 /* Master Transmit Jitter test */
#define CR_1000T_TEST_MODE_3 0x6000 /* Slave Transmit Jitter test */
#define CR_1000T_TEST_MODE_4 0x8000 /* Transmitter Distortion test */
/* 1000BASE-T Status Register */
#define SR_1000T_IDLE_ERROR_CNT 0x00FF /* Num idle errors since last read */
#define SR_1000T_ASYM_PAUSE_DIR 0x0100 /* LP asymmetric pause direction bit */
#define SR_1000T_LP_HD_CAPS 0x0400 /* LP is 1000T HD capable */
#define SR_1000T_LP_FD_CAPS 0x0800 /* LP is 1000T FD capable */
#define SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */
#define SR_1000T_LOCAL_RX_STATUS 0x2000 /* Local receiver OK */
#define SR_1000T_MS_CONFIG_RES 0x4000 /* 1=Local TX is Master, 0=Slave */
#define SR_1000T_MS_CONFIG_FAULT 0x8000 /* Master/Slave config fault */
#define SR_1000T_REMOTE_RX_STATUS_SHIFT 12
#define SR_1000T_LOCAL_RX_STATUS_SHIFT 13
/* Extended Status Register */
#define IEEE_ESR_1000T_HD_CAPS 0x1000 /* 1000T HD capable */
#define IEEE_ESR_1000T_FD_CAPS 0x2000 /* 1000T FD capable */
#define IEEE_ESR_1000X_HD_CAPS 0x4000 /* 1000X HD capable */
#define IEEE_ESR_1000X_FD_CAPS 0x8000 /* 1000X FD capable */
#define PHY_TX_POLARITY_MASK 0x0100 /* register 10h bit 8 (polarity bit) */
#define PHY_TX_NORMAL_POLARITY 0 /* register 10h bit 8 (normal polarity) */
#define AUTO_POLARITY_DISABLE 0x0010 /* register 11h bit 4 */
/* (0=enable, 1=disable) */
/* M88E1000 PHY Specific Control Register */
#define M88E1000_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */
#define M88E1000_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
#define M88E1000_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */
#define M88E1000_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low,
* 0=CLK125 toggling
*/
#define M88E1000_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5 */
/* Manual MDI configuration */
#define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */
#define M88E1000_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover,
* 100BASE-TX/10BASE-T:
* MDI Mode
*/
#define M88E1000_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled
* all speeds.
*/
#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE 0x0080
/* 1=Enable Extended 10BASE-T distance
* (Lower 10BASE-T RX Threshold)
* 0=Normal 10BASE-T RX Threshold */
#define M88E1000_PSCR_MII_5BIT_ENABLE 0x0100
/* 1=5-Bit interface in 100BASE-TX
* 0=MII interface in 100BASE-TX */
#define M88E1000_PSCR_SCRAMBLER_DISABLE 0x0200 /* 1=Scrambler disable */
#define M88E1000_PSCR_FORCE_LINK_GOOD 0x0400 /* 1=Force link good */
#define M88E1000_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */
#define M88E1000_PSCR_POLARITY_REVERSAL_SHIFT 1
#define M88E1000_PSCR_AUTO_X_MODE_SHIFT 5
#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
/* M88E1000 PHY Specific Status Register */
#define M88E1000_PSSR_JABBER 0x0001 /* 1=Jabber */
#define M88E1000_PSSR_REV_POLARITY 0x0002 /* 1=Polarity reversed */
#define M88E1000_PSSR_MDIX 0x0040 /* 1=MDIX; 0=MDI */
#define M88E1000_PSSR_CABLE_LENGTH 0x0380 /* 0=<50M;1=50-80M;2=80-110M;
* 3=110-140M;4=>140M */
#define M88E1000_PSSR_LINK 0x0400 /* 1=Link up, 0=Link down */
#define M88E1000_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
#define M88E1000_PSSR_PAGE_RCVD 0x1000 /* 1=Page received */
#define M88E1000_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
#define M88E1000_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
#define M88E1000_PSSR_10MBS 0x0000 /* 00=10Mbs */
#define M88E1000_PSSR_100MBS 0x4000 /* 01=100Mbs */
#define M88E1000_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
#define M88E1000_PSSR_REV_POLARITY_SHIFT 1
#define M88E1000_PSSR_MDIX_SHIFT 6
#define M88E1000_PSSR_CABLE_LENGTH_SHIFT 7
/* M88E1000 Extended PHY Specific Control Register */
#define M88E1000_EPSCR_FIBER_LOOPBACK 0x4000 /* 1=Fiber loopback */
#define M88E1000_EPSCR_DOWN_NO_IDLE 0x8000 /* 1=Lost lock detect enabled.
* Will assert lost lock and bring
* link down if idle not seen
* within 1ms in 1000BASE-T
*/
/* Number of times we will attempt to autonegotiate before downshifting if we
* are the master */
#define M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK 0x0C00
#define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X 0x0000
#define M88E1000_EPSCR_MASTER_DOWNSHIFT_2X 0x0400
#define M88E1000_EPSCR_MASTER_DOWNSHIFT_3X 0x0800
#define M88E1000_EPSCR_MASTER_DOWNSHIFT_4X 0x0C00
/* Number of times we will attempt to autonegotiate before downshifting if we
* are the slave */
#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK 0x0300
#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_DIS 0x0000
#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X 0x0100
#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_2X 0x0200
#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_3X 0x0300
#define M88E1000_EPSCR_TX_CLK_2_5 0x0060 /* 2.5 MHz TX_CLK */
#define M88E1000_EPSCR_TX_CLK_25 0x0070 /* 25 MHz TX_CLK */
#define M88E1000_EPSCR_TX_CLK_0 0x0000 /* NO TX_CLK */
/* Bit definitions for valid PHY IDs. */
#define M88E1000_E_PHY_ID 0x01410C50
#define M88E1000_I_PHY_ID 0x01410C30
#define M88E1011_I_PHY_ID 0x01410C20
#define M88E1000_12_PHY_ID M88E1000_E_PHY_ID
#define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
/* Miscellaneous PHY bit definitions. */
#define PHY_PREAMBLE 0xFFFFFFFF
#define PHY_SOF 0x01
#define PHY_OP_READ 0x02
#define PHY_OP_WRITE 0x01
#define PHY_TURNAROUND 0x02
#define PHY_PREAMBLE_SIZE 32
#define MII_CR_SPEED_1000 0x0040
#define MII_CR_SPEED_100 0x2000
#define MII_CR_SPEED_10 0x0000
#define E1000_PHY_ADDRESS 0x01
#define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */
#define PHY_FORCE_TIME 20 /* 2.0 Seconds */
#define PHY_REVISION_MASK 0xFFFFFFF0
#define DEVICE_SPEED_MASK 0x00000300 /* Device Ctrl Reg Speed Mask */
#define REG4_SPEED_MASK 0x01E0
#define REG9_SPEED_MASK 0x0300
#define ADVERTISE_10_HALF 0x0001
#define ADVERTISE_10_FULL 0x0002
#define ADVERTISE_100_HALF 0x0004
#define ADVERTISE_100_FULL 0x0008
#define ADVERTISE_1000_HALF 0x0010
#define ADVERTISE_1000_FULL 0x0020
#define AUTONEG_ADVERTISE_SPEED_DEFAULT 0x002F /* Everything but 1000-Half */
#endif /* _E1000_HW_H_ */
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......@@ -76,11 +75,8 @@
#include "e1000.h"
char e1000_driver_name[] = "e1000";
char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
char e1000_driver_version[] = "4.2.4-k2";
char e1000_driver_version[] = "4.2.8";
char e1000_copyright[] = "Copyright (c) 1999-2002 Intel Corporation.";
/* e1000_pci_tbl - PCI Device ID Table
......@@ -100,6 +96,7 @@ static struct pci_device_id e1000_pci_tbl[] __devinitdata = {
{0x8086, 0x1008, 0x8086, 0x1107, 0, 0, 0},
{0x8086, 0x1009, 0x8086, 0x1109, 0, 0, 0},
{0x8086, 0x100C, 0x8086, 0x1112, 0, 0, 0},
{0x8086, 0x100E, 0x8086, 0x001E, 0, 0, 0},
/* Compaq Gigabit Ethernet Server Adapter */
{0x8086, 0x1000, 0x0E11, PCI_ANY_ID, 0, 0, 1},
{0x8086, 0x1001, 0x0E11, PCI_ANY_ID, 0, 0, 1},
......@@ -116,6 +113,7 @@ static struct pci_device_id e1000_pci_tbl[] __devinitdata = {
{0x8086, 0x1009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x100C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x100D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x100E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
/* required last entry */
{0,}
};
......@@ -132,6 +130,8 @@ static char *e1000_strings[] = {
int e1000_up(struct e1000_adapter *adapter);
void e1000_down(struct e1000_adapter *adapter);
void e1000_reset(struct e1000_adapter *adapter);
static int e1000_init_module(void);
static void e1000_exit_module(void);
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
......@@ -164,13 +164,17 @@ static void e1000_clean_tx_irq(struct e1000_adapter *adapter);
static void e1000_clean_rx_irq(struct e1000_adapter *adapter);
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter);
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
static void e1000_reset(struct e1000_adapter *adapter);
static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
static inline void e1000_rx_checksum(struct e1000_adapter *adapter,
struct e1000_rx_desc *rx_desc,
struct sk_buff *skb);
void e1000_enable_WOL(struct e1000_adapter *adapter);
#ifdef NETIF_F_HW_VLAN_TX
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
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);
#endif
/* Exported from other modules */
......@@ -192,6 +196,7 @@ static struct pci_driver e1000_driver = {
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
MODULE_LICENSE("Dual BSD/GPL");
EXPORT_NO_SYMBOLS;
/**
* e1000_init_module - Driver Registration Routine
......@@ -224,8 +229,6 @@ static void __exit
e1000_exit_module(void)
{
pci_unregister_driver(&e1000_driver);
return;
}
module_exit(e1000_exit_module);
......@@ -249,8 +252,6 @@ e1000_up(struct e1000_adapter *adapter)
e1000_configure_rx(adapter);
e1000_alloc_rx_buffers(adapter);
e1000_clear_hw_cntrs(&adapter->shared);
mod_timer(&adapter->watchdog_timer, jiffies);
e1000_irq_enable(adapter);
......@@ -260,74 +261,41 @@ e1000_up(struct e1000_adapter *adapter)
void
e1000_down(struct e1000_adapter *adapter)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct net_device *netdev = adapter->netdev;
e1000_irq_disable(adapter);
free_irq(netdev->irq, netdev);
del_timer_sync(&adapter->watchdog_timer);
del_timer_sync(&adapter->phy_info_timer);
adapter->link_speed = 0;
adapter->link_duplex = 0;
netif_carrier_off(netdev);
netif_stop_queue(netdev);
/* disable the transmit and receive units */
E1000_WRITE_REG(shared, RCTL, 0);
E1000_WRITE_REG(shared, TCTL, E1000_TCTL_PSP);
/* delay to allow PCI transactions to complete */
msec_delay(10);
e1000_reset(adapter);
e1000_clean_tx_ring(adapter);
e1000_clean_rx_ring(adapter);
e1000_reset(adapter);
}
static void
void
e1000_reset(struct e1000_adapter *adapter)
{
struct e1000_shared_adapter *shared = &adapter->shared;
uint32_t ctrl_ext;
/* Repartition Pba for greater than 9k mtu
* To take effect CTRL.RST is required.
*/
if(adapter->rx_buffer_len > E1000_RXBUFFER_8192)
E1000_WRITE_REG(shared, PBA, E1000_JUMBO_PBA);
E1000_WRITE_REG(&adapter->hw, PBA, E1000_JUMBO_PBA);
else
E1000_WRITE_REG(shared, PBA, E1000_DEFAULT_PBA);
/* 82542 2.0 needs MWI disabled while issuing a reset */
if(shared->mac_type == e1000_82542_rev2_0)
e1000_enter_82542_rst(adapter);
/* global reset */
E1000_WRITE_REG(shared, CTRL, E1000_CTRL_RST);
msec_delay(10);
/* EEPROM reload */
ctrl_ext = E1000_READ_REG(shared, CTRL_EXT);
ctrl_ext |= E1000_CTRL_EXT_EE_RST;
E1000_WRITE_REG(shared, CTRL_EXT, ctrl_ext);
msec_delay(5);
if(shared->mac_type == e1000_82542_rev2_0)
e1000_leave_82542_rst(adapter);
shared->tbi_compatibility_on = FALSE;
shared->fc = shared->original_fc;
E1000_WRITE_REG(&adapter->hw, PBA, E1000_DEFAULT_PBA);
e1000_init_hw(shared);
adapter->hw.fc = adapter->hw.original_fc;
e1000_reset_hw(&adapter->hw);
e1000_init_hw(&adapter->hw);
e1000_reset_adaptive(&adapter->hw);
e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
e1000_enable_WOL(adapter);
return;
}
/**
......@@ -382,13 +350,13 @@ e1000_probe(struct pci_dev *pdev,
adapter = netdev->priv;
adapter->netdev = netdev;
adapter->pdev = pdev;
adapter->shared.back = adapter;
adapter->hw.back = adapter;
mmio_start = pci_resource_start(pdev, BAR_0);
mmio_len = pci_resource_len(pdev, BAR_0);
adapter->shared.hw_addr = ioremap(mmio_start, mmio_len);
if(!adapter->shared.hw_addr)
adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
if(!adapter->hw.hw_addr)
goto err_ioremap;
netdev->open = &e1000_open;
......@@ -401,6 +369,11 @@ e1000_probe(struct pci_dev *pdev,
netdev->do_ioctl = &e1000_ioctl;
netdev->tx_timeout = &e1000_tx_timeout;
netdev->watchdog_timeo = HZ;
#ifdef NETIF_F_HW_VLAN_TX
netdev->vlan_rx_register = e1000_vlan_rx_register;
netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
#endif
netdev->irq = pdev->irq;
netdev->base_addr = mmio_start;
......@@ -412,8 +385,16 @@ e1000_probe(struct pci_dev *pdev,
e1000_sw_init(adapter);
if(adapter->shared.mac_type >= e1000_82543) {
if(adapter->hw.mac_type >= e1000_82543) {
#ifdef NETIF_F_HW_VLAN_TX
netdev->features = NETIF_F_SG |
NETIF_F_HW_CSUM |
NETIF_F_HW_VLAN_TX |
NETIF_F_HW_VLAN_RX |
NETIF_F_HW_VLAN_FILTER;
#else
netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
#endif
} else {
netdev->features = NETIF_F_SG;
}
......@@ -423,19 +404,28 @@ e1000_probe(struct pci_dev *pdev,
/* make sure the EEPROM is good */
if(!e1000_validate_eeprom_checksum(&adapter->shared))
if(e1000_validate_eeprom_checksum(&adapter->hw) < 0)
goto err_eeprom;
/* copy the MAC address out of the EEPROM */
e1000_read_mac_addr(&adapter->shared);
memcpy(netdev->dev_addr, adapter->shared.mac_addr, netdev->addr_len);
e1000_read_mac_addr(&adapter->hw);
memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
if(!is_valid_ether_addr(netdev->dev_addr))
goto err_eeprom;
e1000_read_part_num(&adapter->shared, &(adapter->part_num));
e1000_get_bus_info(&adapter->shared);
e1000_read_part_num(&adapter->hw, &(adapter->part_num));
e1000_get_bus_info(&adapter->hw);
if((adapter->hw.mac_type == e1000_82544) &&
(adapter->hw.bus_type == e1000_bus_type_pcix))
adapter->max_data_per_txd = 4096;
else
adapter->max_data_per_txd = MAX_JUMBO_FRAME_SIZE;
init_timer(&adapter->watchdog_timer);
adapter->watchdog_timer.function = &e1000_watchdog;
......@@ -464,7 +454,7 @@ e1000_probe(struct pci_dev *pdev,
return 0;
err_eeprom:
iounmap(adapter->shared.hw_addr);
iounmap(adapter->hw.hw_addr);
err_ioremap:
pci_release_regions(pdev);
kfree(netdev);
......@@ -480,10 +470,6 @@ e1000_probe(struct pci_dev *pdev,
* that it should release a PCI device. The could be caused by a
* Hot-Plug event, or because the driver is going to be removed from
* memory.
*
* This routine is also called to clean up from a failure in
* e1000_probe. The Adapter struct and netdev will always exist,
* all other pointers must be checked for NULL before freeing.
**/
static void __devexit
......@@ -494,15 +480,14 @@ e1000_remove(struct pci_dev *pdev)
unregister_netdev(netdev);
e1000_phy_hw_reset(&adapter->shared);
e1000_phy_hw_reset(&adapter->hw);
e1000_proc_dev_free(adapter);
iounmap(adapter->shared.hw_addr);
iounmap(adapter->hw.hw_addr);
pci_release_regions(pdev);
kfree(netdev);
return;
}
/**
......@@ -517,17 +502,17 @@ e1000_remove(struct pci_dev *pdev)
static void __devinit
e1000_sw_init(struct e1000_adapter *adapter)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev;
/* PCI config space info */
uint16_t *vendor = &shared->vendor_id;
uint16_t *device = &shared->device_id;
uint16_t *subvendor = &shared->subsystem_vendor_id;
uint16_t *subsystem = &shared->subsystem_id;
uint8_t *revision = &shared->revision_id;
uint16_t *vendor = &hw->vendor_id;
uint16_t *device = &hw->device_id;
uint16_t *subvendor = &hw->subsystem_vendor_id;
uint16_t *subsystem = &hw->subsystem_id;
uint8_t *revision = &hw->revision_id;
pci_read_config_word(pdev, PCI_VENDOR_ID, vendor);
pci_read_config_word(pdev, PCI_DEVICE_ID, device);
......@@ -535,11 +520,12 @@ e1000_sw_init(struct e1000_adapter *adapter)
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, subsystem);
pci_read_config_word(pdev, PCI_COMMAND, &shared->pci_cmd_word);
pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
adapter->rx_buffer_len = E1000_RXBUFFER_2048;
shared->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + CRC_LENGTH;
shared->min_frame_size = MINIMUM_ETHERNET_PACKET_SIZE + CRC_LENGTH;
hw->max_frame_size = netdev->mtu +
ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
/* identify the MAC */
......@@ -547,25 +533,28 @@ e1000_sw_init(struct e1000_adapter *adapter)
case E1000_DEV_ID_82542:
switch (*revision) {
case E1000_82542_2_0_REV_ID:
shared->mac_type = e1000_82542_rev2_0;
hw->mac_type = e1000_82542_rev2_0;
break;
case E1000_82542_2_1_REV_ID:
shared->mac_type = e1000_82542_rev2_1;
hw->mac_type = e1000_82542_rev2_1;
break;
default:
shared->mac_type = e1000_82542_rev2_0;
hw->mac_type = e1000_82542_rev2_0;
E1000_ERR("Could not identify 82542 revision\n");
}
break;
case E1000_DEV_ID_82543GC_FIBER:
case E1000_DEV_ID_82543GC_COPPER:
shared->mac_type = e1000_82543;
hw->mac_type = e1000_82543;
break;
case E1000_DEV_ID_82544EI_COPPER:
case E1000_DEV_ID_82544EI_FIBER:
case E1000_DEV_ID_82544GC_COPPER:
case E1000_DEV_ID_82544GC_LOM:
shared->mac_type = e1000_82544;
hw->mac_type = e1000_82544;
break;
case E1000_DEV_ID_82540EM:
hw->mac_type = e1000_82540;
break;
default:
/* should never have loaded on this device */
......@@ -574,33 +563,35 @@ e1000_sw_init(struct e1000_adapter *adapter)
/* flow control settings */
shared->fc_high_water = FC_DEFAULT_HI_THRESH;
shared->fc_low_water = FC_DEFAULT_LO_THRESH;
shared->fc_pause_time = FC_DEFAULT_TX_TIMER;
shared->fc_send_xon = 1;
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_send_xon = 1;
/* Media type - copper or fiber */
if(shared->mac_type >= e1000_82543) {
uint32_t status = E1000_READ_REG(shared, STATUS);
if(hw->mac_type >= e1000_82543) {
uint32_t status = E1000_READ_REG(hw, STATUS);
if(status & E1000_STATUS_TBIMODE)
shared->media_type = e1000_media_type_fiber;
hw->media_type = e1000_media_type_fiber;
else
shared->media_type = e1000_media_type_copper;
hw->media_type = e1000_media_type_copper;
} else {
shared->media_type = e1000_media_type_fiber;
hw->media_type = e1000_media_type_fiber;
}
if(shared->mac_type < e1000_82543)
shared->report_tx_early = 0;
if(hw->mac_type < e1000_82543)
hw->report_tx_early = 0;
else
shared->report_tx_early = 1;
hw->report_tx_early = 1;
shared->wait_autoneg_complete = FALSE;
shared->tbi_compatibility_en = TRUE;
hw->wait_autoneg_complete = FALSE;
hw->tbi_compatibility_en = TRUE;
hw->adaptive_ifs = TRUE;
atomic_set(&adapter->irq_sem, 1);
spin_lock_init(&adapter->tx_lock);
spin_lock_init(&adapter->stats_lock);
}
......@@ -677,9 +668,6 @@ e1000_close(struct net_device *netdev)
* @adapter: board private structure
*
* Return 0 on success, negative on failure
*
* e1000_setup_tx_resources allocates all software transmit resources
* and enabled the Tx unit of the MAC.
**/
static int
......@@ -708,7 +696,6 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter)
}
memset(txdr->desc, 0, txdr->size);
atomic_set(&txdr->unused, txdr->count);
txdr->next_to_use = 0;
txdr->next_to_clean = 0;
......@@ -729,19 +716,19 @@ e1000_configure_tx(struct e1000_adapter *adapter)
uint32_t tdlen = adapter->tx_ring.count * sizeof(struct e1000_tx_desc);
uint32_t tctl, tipg;
E1000_WRITE_REG(&adapter->shared, TDBAL, (tdba & 0x00000000FFFFFFFF));
E1000_WRITE_REG(&adapter->shared, TDBAH, (tdba >> 32));
E1000_WRITE_REG(&adapter->hw, TDBAL, (tdba & 0x00000000FFFFFFFF));
E1000_WRITE_REG(&adapter->hw, TDBAH, (tdba >> 32));
E1000_WRITE_REG(&adapter->shared, TDLEN, tdlen);
E1000_WRITE_REG(&adapter->hw, TDLEN, tdlen);
/* Setup the HW Tx Head and Tail descriptor pointers */
E1000_WRITE_REG(&adapter->shared, TDH, 0);
E1000_WRITE_REG(&adapter->shared, TDT, 0);
E1000_WRITE_REG(&adapter->hw, TDH, 0);
E1000_WRITE_REG(&adapter->hw, TDT, 0);
/* Set the default values for the Tx Inter Packet Gap timer */
switch (adapter->shared.mac_type) {
switch (adapter->hw.mac_type) {
case e1000_82542_rev2_0:
case e1000_82542_rev2_1:
tipg = DEFAULT_82542_TIPG_IPGT;
......@@ -749,53 +736,45 @@ e1000_configure_tx(struct e1000_adapter *adapter)
tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
break;
default:
if(adapter->shared.media_type == e1000_media_type_fiber)
if(adapter->hw.media_type == e1000_media_type_fiber)
tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
else
tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
}
E1000_WRITE_REG(&adapter->shared, TIPG, tipg);
E1000_WRITE_REG(&adapter->hw, TIPG, tipg);
/* Set the Tx Interrupt Delay register */
E1000_WRITE_REG(&adapter->shared, TIDV, adapter->tx_int_delay);
E1000_WRITE_REG(&adapter->hw, TIDV, 64);
/* Program the Transmit Control Register */
tctl = E1000_TCTL_PSP | E1000_TCTL_EN |
tctl = E1000_READ_REG(&adapter->hw, TCTL);
tctl &= ~E1000_TCTL_CT;
tctl |= E1000_TCTL_EN | E1000_TCTL_PSP |
(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
if(adapter->link_duplex == FULL_DUPLEX) {
tctl |= E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT;
} else {
tctl |= E1000_HDX_COLLISION_DISTANCE << E1000_COLD_SHIFT;
}
E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
E1000_WRITE_REG(&adapter->shared, TCTL, tctl);
e1000_config_collision_dist(&adapter->hw);
/* Setup Transmit Descriptor Settings for this adapter */
adapter->txd_cmd = E1000_TXD_CMD_IFCS;
adapter->txd_cmd = E1000_TXD_CMD_IFCS | E1000_TXD_CMD_IDE;
if(adapter->tx_int_delay > 0)
adapter->txd_cmd |= E1000_TXD_CMD_IDE;
if(adapter->shared.report_tx_early == 1)
if(adapter->hw.report_tx_early == 1)
adapter->txd_cmd |= E1000_TXD_CMD_RS;
else
adapter->txd_cmd |= E1000_TXD_CMD_RPS;
return;
}
/**
* e1000_setup_rx_resources - allocate Rx resources (Descriptors, receive SKBs)
* e1000_setup_rx_resources - allocate Rx resources (Descriptors)
* @adapter: board private structure
*
* Returns 0 on success, negative on failure
*
* e1000_setup_rx_resources allocates all software receive resources
* and network buffers, and enables the Rx unit of the MAC.
**/
static int
......@@ -826,7 +805,6 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter)
memset(rxdr->desc, 0, rxdr->size);
rxdr->next_to_clean = 0;
rxdr->unused_count = rxdr->count;
rxdr->next_to_use = 0;
return 0;
......@@ -842,18 +820,25 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
{
uint32_t rctl;
/* Setup the Receive Control Register */
rctl = E1000_RCTL_EN | E1000_RCTL_BAM |
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
(adapter->shared.mc_filter_type << E1000_RCTL_MO_SHIFT);
(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
if(adapter->shared.tbi_compatibility_on == 1)
if(adapter->hw.tbi_compatibility_on == 1)
rctl |= E1000_RCTL_SBP;
else
rctl &= ~E1000_RCTL_SBP;
rctl &= ~(E1000_RCTL_SZ_4096);
switch (adapter->rx_buffer_len) {
case E1000_RXBUFFER_2048:
default:
rctl |= E1000_RCTL_SZ_2048;
rctl &= ~(E1000_RCTL_BSEX | E1000_RCTL_LPE);
break;
case E1000_RXBUFFER_4096:
rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX | E1000_RCTL_LPE;
......@@ -866,7 +851,7 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
break;
}
E1000_WRITE_REG(&adapter->shared, RCTL, rctl);
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
}
/**
......@@ -886,38 +871,47 @@ e1000_configure_rx(struct e1000_adapter *adapter)
/* make sure receives are disabled while setting up the descriptors */
rctl = E1000_READ_REG(&adapter->shared, RCTL);
E1000_WRITE_REG(&adapter->shared, RCTL, rctl & ~E1000_RCTL_EN);
rctl = E1000_READ_REG(&adapter->hw, RCTL);
E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
/* set the Receive Delay Timer Register */
E1000_WRITE_REG(&adapter->shared, RDTR,
adapter->rx_int_delay | E1000_RDT_FPDB);
if(adapter->hw.mac_type == e1000_82540) {
E1000_WRITE_REG(&adapter->hw, RADV, adapter->rx_int_delay);
E1000_WRITE_REG(&adapter->hw, RDTR, 64);
/* Set the interrupt throttling rate. Value is calculated
* as DEFAULT_ITR = 1/(MAX_INTS_PER_SEC * 256ns) */
#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 */
E1000_WRITE_REG(&adapter->shared, RDBAL, (rdba & 0x00000000FFFFFFFF));
E1000_WRITE_REG(&adapter->shared, RDBAH, (rdba >> 32));
E1000_WRITE_REG(&adapter->hw, RDBAL, (rdba & 0x00000000FFFFFFFF));
E1000_WRITE_REG(&adapter->hw, RDBAH, (rdba >> 32));
E1000_WRITE_REG(&adapter->shared, RDLEN, rdlen);
E1000_WRITE_REG(&adapter->hw, RDLEN, rdlen);
/* Setup the HW Rx Head and Tail Descriptor Pointers */
E1000_WRITE_REG(&adapter->shared, RDH, 0);
E1000_WRITE_REG(&adapter->shared, RDT, 0);
E1000_WRITE_REG(&adapter->hw, RDH, 0);
E1000_WRITE_REG(&adapter->hw, RDT, 0);
/* Enable 82543 Receive Checksum Offload for TCP and UDP */
if((adapter->shared.mac_type >= e1000_82543) &&
if((adapter->hw.mac_type >= e1000_82543) &&
(adapter->rx_csum == TRUE)) {
rxcsum = E1000_READ_REG(&adapter->shared, RXCSUM);
rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM);
rxcsum |= E1000_RXCSUM_TUOFL;
E1000_WRITE_REG(&adapter->shared, RXCSUM, rxcsum);
E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum);
}
/* Enable Receives */
E1000_WRITE_REG(&adapter->shared, RCTL, rctl);
return;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
}
/**
......@@ -941,8 +935,6 @@ e1000_free_tx_resources(struct e1000_adapter *adapter)
adapter->tx_ring.desc, adapter->tx_ring.dma);
adapter->tx_ring.desc = NULL;
return;
}
/**
......@@ -980,14 +972,11 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter)
memset(adapter->tx_ring.desc, 0, adapter->tx_ring.size);
atomic_set(&adapter->tx_ring.unused, adapter->tx_ring.count);
adapter->tx_ring.next_to_use = 0;
adapter->tx_ring.next_to_clean = 0;
E1000_WRITE_REG(&adapter->shared, TDH, 0);
E1000_WRITE_REG(&adapter->shared, TDT, 0);
return;
E1000_WRITE_REG(&adapter->hw, TDH, 0);
E1000_WRITE_REG(&adapter->hw, TDT, 0);
}
/**
......@@ -1011,8 +1000,6 @@ e1000_free_rx_resources(struct e1000_adapter *adapter)
adapter->rx_ring.desc, adapter->rx_ring.dma);
adapter->rx_ring.desc = NULL;
return;
}
/**
......@@ -1050,14 +1037,11 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter)
memset(adapter->rx_ring.desc, 0, adapter->rx_ring.size);
adapter->rx_ring.unused_count = adapter->rx_ring.count;
adapter->rx_ring.next_to_clean = 0;
adapter->rx_ring.next_to_use = 0;
E1000_WRITE_REG(&adapter->shared, RDH, 0);
E1000_WRITE_REG(&adapter->shared, RDT, 0);
return;
E1000_WRITE_REG(&adapter->hw, RDH, 0);
E1000_WRITE_REG(&adapter->hw, RDT, 0);
}
/* The 82542 2.0 (revision 2) needs to have the receive unit in reset
......@@ -1068,7 +1052,7 @@ e1000_enter_82542_rst(struct e1000_adapter *adapter)
{
struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev;
uint16_t pci_command_word = adapter->shared.pci_cmd_word;
uint16_t pci_command_word = adapter->hw.pci_cmd_word;
uint32_t rctl;
if(pci_command_word & PCI_COMMAND_INVALIDATE) {
......@@ -1076,14 +1060,13 @@ e1000_enter_82542_rst(struct e1000_adapter *adapter)
pci_write_config_word(pdev, PCI_COMMAND, pci_command_word);
}
rctl = E1000_READ_REG(&adapter->shared, RCTL);
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl |= E1000_RCTL_RST;
E1000_WRITE_REG(&adapter->shared, RCTL, rctl);
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
msec_delay(5);
if(netif_running(netdev))
e1000_clean_rx_ring(adapter);
return;
}
static void
......@@ -1091,12 +1074,12 @@ e1000_leave_82542_rst(struct e1000_adapter *adapter)
{
struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev;
uint16_t pci_command_word = adapter->shared.pci_cmd_word;
uint16_t pci_command_word = adapter->hw.pci_cmd_word;
uint32_t rctl;
rctl = E1000_READ_REG(&adapter->shared, RCTL);
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl &= ~E1000_RCTL_RST;
E1000_WRITE_REG(&adapter->shared, RCTL, rctl);
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
msec_delay(5);
if(pci_command_word & PCI_COMMAND_INVALIDATE)
......@@ -1106,7 +1089,6 @@ e1000_leave_82542_rst(struct e1000_adapter *adapter)
e1000_configure_rx(adapter);
e1000_alloc_rx_buffers(adapter);
}
return;
}
/**
......@@ -1125,15 +1107,15 @@ e1000_set_mac(struct net_device *netdev, void *p)
/* 82542 2.0 needs to be in reset to write receive address registers */
if(adapter->shared.mac_type == e1000_82542_rev2_0)
if(adapter->hw.mac_type == e1000_82542_rev2_0)
e1000_enter_82542_rst(adapter);
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
memcpy(adapter->shared.mac_addr, addr->sa_data, netdev->addr_len);
memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
e1000_rar_set(&adapter->shared, adapter->shared.mac_addr, 0);
e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
if(adapter->shared.mac_type == e1000_82542_rev2_0)
if(adapter->hw.mac_type == e1000_82542_rev2_0)
e1000_leave_82542_rst(adapter);
return 0;
......@@ -1153,7 +1135,7 @@ static void
e1000_set_multi(struct net_device *netdev)
{
struct e1000_adapter *adapter = netdev->priv;
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
struct dev_mc_list *mc_ptr;
uint32_t rctl;
uint32_t hash_value;
......@@ -1161,7 +1143,7 @@ e1000_set_multi(struct net_device *netdev)
/* Check for Promiscuous and All Multicast modes */
rctl = E1000_READ_REG(shared, RCTL);
rctl = E1000_READ_REG(hw, RCTL);
if(netdev->flags & IFF_PROMISC) {
rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
......@@ -1172,11 +1154,11 @@ e1000_set_multi(struct net_device *netdev)
rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
}
E1000_WRITE_REG(shared, RCTL, rctl);
E1000_WRITE_REG(hw, RCTL, rctl);
/* 82542 2.0 needs to be in reset to write receive address registers */
if(shared->mac_type == e1000_82542_rev2_0)
if(hw->mac_type == e1000_82542_rev2_0)
e1000_enter_82542_rst(adapter);
/* load the first 15 multicast address into the exact filters 1-15
......@@ -1187,29 +1169,28 @@ e1000_set_multi(struct net_device *netdev)
for(i = 1; i < E1000_RAR_ENTRIES; i++) {
if(mc_ptr) {
e1000_rar_set(shared, mc_ptr->dmi_addr, i);
e1000_rar_set(hw, mc_ptr->dmi_addr, i);
mc_ptr = mc_ptr->next;
} else {
E1000_WRITE_REG_ARRAY(shared, RA, i << 1, 0);
E1000_WRITE_REG_ARRAY(shared, RA, (i << 1) + 1, 0);
E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
}
}
/* clear the old settings from the multicast hash table */
for(i = 0; i < E1000_NUM_MTA_REGISTERS; i++)
E1000_WRITE_REG_ARRAY(shared, MTA, i, 0);
E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
/* load any remaining addresses into the hash table */
for(; mc_ptr; mc_ptr = mc_ptr->next) {
hash_value = e1000_hash_mc_addr(shared, mc_ptr->dmi_addr);
e1000_mta_set(shared, hash_value);
hash_value = e1000_hash_mc_addr(hw, mc_ptr->dmi_addr);
e1000_mta_set(hw, hash_value);
}
if(shared->mac_type == e1000_82542_rev2_0)
if(hw->mac_type == e1000_82542_rev2_0)
e1000_leave_82542_rst(adapter);
return;
}
......@@ -1219,8 +1200,7 @@ static void
e1000_update_phy_info(unsigned long data)
{
struct e1000_adapter *adapter = (struct e1000_adapter *) data;
e1000_phy_get_info(&adapter->shared, &adapter->phy_info);
return;
e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
}
/**
......@@ -1234,11 +1214,11 @@ e1000_watchdog(unsigned long data)
struct e1000_adapter *adapter = (struct e1000_adapter *) data;
struct net_device *netdev = adapter->netdev;
e1000_check_for_link(&adapter->shared);
e1000_check_for_link(&adapter->hw);
if(E1000_READ_REG(&adapter->shared, STATUS) & E1000_STATUS_LU) {
if(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) {
if(!netif_carrier_ok(netdev)) {
e1000_get_speed_and_duplex(&adapter->shared,
e1000_get_speed_and_duplex(&adapter->hw,
&adapter->link_speed,
&adapter->link_duplex);
......@@ -1262,171 +1242,203 @@ e1000_watchdog(unsigned long data)
netdev->name);
netif_carrier_off(netdev);
netif_stop_queue(netdev);
mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ);
}
}
e1000_update_stats(adapter);
e1000_update_adaptive(&adapter->hw);
/* Reset the timer */
mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
return;
}
/**
* e1000_xmit_frame - Transmit entry point
* @skb: buffer with frame data to transmit
* @netdev: network interface device structure
*
* Returns 0 on success, 1 on error
*
* e1000_xmit_frame is called by the stack to initiate a transmit.
* The out of resource condition is checked after each successful Tx
* so that the stack can be notified, preventing the driver from
* ever needing to drop a frame. The atomic operations on
* tx_ring.unused are used to syncronize with the transmit
* interrupt processing code without the need for a spinlock.
**/
#define E1000_TX_FLAGS_CSUM 0x00000001
#define E1000_TX_FLAGS_VLAN 0x00000002
#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
#define E1000_TX_FLAGS_VLAN_SHIFT 16
#define TXD_USE_COUNT(x) (((x) >> 12) + ((x) & 0x0fff ? 1 : 0))
static inline boolean_t
e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
{
struct e1000_context_desc *context_desc;
int i;
uint8_t css, cso;
#define SETUP_TXD_PAGE(L, P, O) do { \
tx_ring->buffer_info[i].length = (L); \
tx_ring->buffer_info[i].dma = \
pci_map_page(pdev, (P), (O), (L), PCI_DMA_TODEVICE); \
tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma); \
tx_desc->lower.data = cpu_to_le32(txd_lower | (L)); \
tx_desc->upper.data = cpu_to_le32(txd_upper); \
} while (0)
if(skb->ip_summed == CHECKSUM_HW) {
css = skb->h.raw - skb->data;
cso = (skb->h.raw + skb->csum) - skb->data;
#define SETUP_TXD_PTR(L, P) \
SETUP_TXD_PAGE((L), virt_to_page(P), (unsigned long)(P) & ~PAGE_MASK)
i = adapter->tx_ring.next_to_use;
context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i);
#define QUEUE_TXD() do { i = (i + 1) % tx_ring->count; \
atomic_dec(&tx_ring->unused); } while (0)
context_desc->upper_setup.tcp_fields.tucss = css;
context_desc->upper_setup.tcp_fields.tucso = cso;
context_desc->upper_setup.tcp_fields.tucse = 0;
context_desc->tcp_seg_setup.data = 0;
context_desc->cmd_and_length =
cpu_to_le32(adapter->txd_cmd | E1000_TXD_CMD_DEXT);
i = (i + 1) % adapter->tx_ring.count;
adapter->tx_ring.next_to_use = i;
static int
e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
return TRUE;
}
return FALSE;
}
static inline int
e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb)
{
struct e1000_adapter *adapter = netdev->priv;
struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
struct pci_dev *pdev = adapter->pdev;
struct e1000_tx_desc *tx_desc;
int f, len, offset, txd_needed;
skb_frag_t *frag;
int len, offset, size, count, i;
int i = tx_ring->next_to_use;
uint32_t txd_upper = 0;
uint32_t txd_lower = adapter->txd_cmd;
int f;
len = skb->len - skb->data_len;
i = (tx_ring->next_to_use + tx_ring->count - 1) % tx_ring->count;
count = 0;
/* If controller appears hung, force transmit timeout */
offset = 0;
if (time_after(netdev->trans_start, adapter->trans_finish + HZ) &&
/* If transmitting XOFFs, we're not really hung */
!(E1000_READ_REG(&adapter->shared, STATUS) & E1000_STATUS_TXOFF)) {
adapter->trans_finish = jiffies;
netif_stop_queue(netdev);
return 1;
}
while(len) {
i = (i + 1) % tx_ring->count;
size = min(len, adapter->max_data_per_txd);
tx_ring->buffer_info[i].length = size;
tx_ring->buffer_info[i].dma =
pci_map_single(adapter->pdev,
skb->data + offset,
size,
PCI_DMA_TODEVICE);
txd_needed = TXD_USE_COUNT(skb->len - skb->data_len);
len -= size;
offset += size;
count++;
}
for(f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
frag = &skb_shinfo(skb)->frags[f];
txd_needed += TXD_USE_COUNT(frag->size);
}
struct skb_frag_struct *frag;
if(skb->ip_summed == CHECKSUM_HW)
txd_needed += 1;
frag = &skb_shinfo(skb)->frags[f];
len = frag->size;
offset = 0;
/* make sure there are enough Tx descriptors available in the ring */
while(len) {
i = (i + 1) % tx_ring->count;
size = min(len, adapter->max_data_per_txd);
tx_ring->buffer_info[i].length = size;
tx_ring->buffer_info[i].dma =
pci_map_page(adapter->pdev,
frag->page,
frag->page_offset + offset,
size,
PCI_DMA_TODEVICE);
if(atomic_read(&tx_ring->unused) <= (txd_needed + 1)) {
adapter->net_stats.tx_dropped++;
netif_stop_queue(netdev);
return 1;
len -= size;
offset += size;
count++;
}
}
tx_ring->buffer_info[i].skb = skb;
if(skb->ip_summed == CHECKSUM_HW) {
struct e1000_context_desc *context_desc;
uint8_t css = skb->h.raw - skb->data;
uint8_t cso = (skb->h.raw + skb->csum) - skb->data;
context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
return count;
}
context_desc->upper_setup.tcp_fields.tucss = css;
context_desc->upper_setup.tcp_fields.tucso = cso;
context_desc->upper_setup.tcp_fields.tucse = 0;
context_desc->tcp_seg_setup.data = 0;
context_desc->cmd_and_length =
cpu_to_le32(txd_lower | E1000_TXD_CMD_DEXT);
static inline void
e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags)
{
struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
struct e1000_tx_desc *tx_desc = NULL;
uint32_t txd_upper, txd_lower;
int i;
QUEUE_TXD();
txd_upper = 0;
txd_lower = adapter->txd_cmd;
txd_upper |= E1000_TXD_POPTS_TXSM << 8;
if(tx_flags & E1000_TX_FLAGS_CSUM) {
txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
txd_upper |= E1000_TXD_POPTS_TXSM << 8;
}
tx_desc = E1000_TX_DESC(*tx_ring, i);
len = skb->len - skb->data_len;
offset = 0;
if(tx_flags & E1000_TX_FLAGS_VLAN) {
txd_lower |= E1000_TXD_CMD_VLE;
txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
}
while(len > 4096) {
SETUP_TXD_PTR(4096, skb->data + offset);
QUEUE_TXD();
i = tx_ring->next_to_use;
while(count--) {
tx_desc = E1000_TX_DESC(*tx_ring, i);
len -= 4096;
offset += 4096;
tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma);
tx_desc->lower.data =
cpu_to_le32(txd_lower | tx_ring->buffer_info[i].length);
tx_desc->upper.data = cpu_to_le32(txd_upper);
i = (i + 1) % tx_ring->count;
}
SETUP_TXD_PTR(len, skb->data + offset);
tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP);
for(f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
frag = &skb_shinfo(skb)->frags[f];
tx_ring->next_to_use = i;
E1000_WRITE_REG(&adapter->hw, TDT, i);
}
QUEUE_TXD();
#define TXD_USE_COUNT(S, X) (((S) / (X)) + (((S) % (X)) ? 1 : 0))
tx_desc = E1000_TX_DESC(*tx_ring, i);
len = frag->size;
offset = 0;
static int
e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
{
struct e1000_adapter *adapter = netdev->priv;
unsigned long flags;
int tx_flags = 0, count;
while(len > 4096) {
SETUP_TXD_PAGE(4096, frag->page,
frag->page_offset + offset);
QUEUE_TXD();
int f;
tx_desc = E1000_TX_DESC(*tx_ring, i);
len -= 4096;
offset += 4096;
}
SETUP_TXD_PAGE(len, frag->page, frag->page_offset + offset);
if(time_after(netdev->trans_start, adapter->trans_finish + HZ) &&
!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_TXOFF)) {
adapter->trans_finish = jiffies;
netif_stop_queue(netdev);
return 1;
}
/* EOP and SKB pointer go with the last fragment */
count = TXD_USE_COUNT(skb->len - skb->data_len,
adapter->max_data_per_txd);
for(f = 0; f < skb_shinfo(skb)->nr_frags; f++)
count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
adapter->max_data_per_txd);
if(skb->ip_summed == CHECKSUM_HW)
count++;
tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP);
tx_ring->buffer_info[i].skb = skb;
spin_lock_irqsave(&adapter->tx_lock, flags);
e1000_clean_tx_irq(adapter);
if(E1000_DESC_UNUSED(&adapter->tx_ring) < count) {
netif_stop_queue(netdev);
spin_unlock_irqrestore(&adapter->tx_lock, flags);
return 1;
}
spin_unlock_irqrestore(&adapter->tx_lock, flags);
QUEUE_TXD();
if(e1000_tx_csum(adapter, skb))
tx_flags |= E1000_TX_FLAGS_CSUM;
tx_ring->next_to_use = i;
#ifdef NETIF_F_HW_VLAN_TX
if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
tx_flags |= E1000_TX_FLAGS_VLAN;
tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
}
#endif
/* Move the HW Tx Tail Pointer */
count = e1000_tx_map(adapter, skb);
E1000_WRITE_REG(&adapter->shared, TDT, i);
e1000_tx_queue(adapter, count, tx_flags);
netdev->trans_start = jiffies;
return 0;
}
#undef TXD_USE_COUNT
#undef SETUP_TXD
#undef QUEUE_TXD
/**
* e1000_tx_timeout - Respond to a Tx Hang
* @netdev: network interface device structure
......@@ -1470,24 +1482,21 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
{
struct e1000_adapter *adapter = netdev->priv;
int old_mtu = adapter->rx_buffer_len;
int max_frame = new_mtu + ENET_HEADER_SIZE + CRC_LENGTH;
int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
if((max_frame < MINIMUM_ETHERNET_PACKET_SIZE + CRC_LENGTH) ||
(max_frame > MAX_JUMBO_FRAME_SIZE + CRC_LENGTH)) {
if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
(max_frame > MAX_JUMBO_FRAME_SIZE)) {
E1000_ERR("Invalid MTU setting\n");
return -EINVAL;
}
if(max_frame <= MAXIMUM_ETHERNET_PACKET_SIZE + CRC_LENGTH) {
if(max_frame <= E1000_RXBUFFER_2048) {
adapter->rx_buffer_len = E1000_RXBUFFER_2048;
} else if(adapter->shared.mac_type < e1000_82543) {
} else if(adapter->hw.mac_type < e1000_82543) {
E1000_ERR("Jumbo Frames not supported on 82542\n");
return -EINVAL;
} else if(max_frame <= E1000_RXBUFFER_2048) {
adapter->rx_buffer_len = E1000_RXBUFFER_2048;
} else if(max_frame <= E1000_RXBUFFER_4096) {
adapter->rx_buffer_len = E1000_RXBUFFER_4096;
......@@ -1501,13 +1510,11 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
if(old_mtu != adapter->rx_buffer_len && netif_running(netdev)) {
e1000_down(adapter);
e1000_clean_rx_ring(adapter);
e1000_clean_tx_ring(adapter);
e1000_up(adapter);
}
netdev->mtu = new_mtu;
adapter->shared.max_frame_size = max_frame;
adapter->hw.max_frame_size = max_frame;
return 0;
}
......@@ -1520,8 +1527,9 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
static void
e1000_update_stats(struct e1000_adapter *adapter)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
unsigned long flags;
uint16_t phy_tmp;
#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
......@@ -1532,68 +1540,73 @@ e1000_update_stats(struct e1000_adapter *adapter)
* be written while holding adapter->stats_lock
*/
adapter->stats.crcerrs += E1000_READ_REG(shared, CRCERRS);
adapter->stats.gprc += E1000_READ_REG(shared, GPRC);
adapter->stats.gorcl += E1000_READ_REG(shared, GORCL);
adapter->stats.gorch += E1000_READ_REG(shared, GORCH);
adapter->stats.bprc += E1000_READ_REG(shared, BPRC);
adapter->stats.mprc += E1000_READ_REG(shared, MPRC);
adapter->stats.roc += E1000_READ_REG(shared, ROC);
adapter->stats.prc64 += E1000_READ_REG(shared, PRC64);
adapter->stats.prc127 += E1000_READ_REG(shared, PRC127);
adapter->stats.prc255 += E1000_READ_REG(shared, PRC255);
adapter->stats.prc511 += E1000_READ_REG(shared, PRC511);
adapter->stats.prc1023 += E1000_READ_REG(shared, PRC1023);
adapter->stats.prc1522 += E1000_READ_REG(shared, PRC1522);
adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
adapter->stats.roc += E1000_READ_REG(hw, ROC);
adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
spin_unlock_irqrestore(&adapter->stats_lock, flags);
/* the rest of the counters are only modified here */
adapter->stats.symerrs += E1000_READ_REG(shared, SYMERRS);
adapter->stats.mpc += E1000_READ_REG(shared, MPC);
adapter->stats.scc += E1000_READ_REG(shared, SCC);
adapter->stats.ecol += E1000_READ_REG(shared, ECOL);
adapter->stats.mcc += E1000_READ_REG(shared, MCC);
adapter->stats.latecol += E1000_READ_REG(shared, LATECOL);
adapter->stats.colc += E1000_READ_REG(shared, COLC);
adapter->stats.dc += E1000_READ_REG(shared, DC);
adapter->stats.sec += E1000_READ_REG(shared, SEC);
adapter->stats.rlec += E1000_READ_REG(shared, RLEC);
adapter->stats.xonrxc += E1000_READ_REG(shared, XONRXC);
adapter->stats.xontxc += E1000_READ_REG(shared, XONTXC);
adapter->stats.xoffrxc += E1000_READ_REG(shared, XOFFRXC);
adapter->stats.xofftxc += E1000_READ_REG(shared, XOFFTXC);
adapter->stats.fcruc += E1000_READ_REG(shared, FCRUC);
adapter->stats.gptc += E1000_READ_REG(shared, GPTC);
adapter->stats.gotcl += E1000_READ_REG(shared, GOTCL);
adapter->stats.gotch += E1000_READ_REG(shared, GOTCH);
adapter->stats.rnbc += E1000_READ_REG(shared, RNBC);
adapter->stats.ruc += E1000_READ_REG(shared, RUC);
adapter->stats.rfc += E1000_READ_REG(shared, RFC);
adapter->stats.rjc += E1000_READ_REG(shared, RJC);
adapter->stats.torl += E1000_READ_REG(shared, TORL);
adapter->stats.torh += E1000_READ_REG(shared, TORH);
adapter->stats.totl += E1000_READ_REG(shared, TOTL);
adapter->stats.toth += E1000_READ_REG(shared, TOTH);
adapter->stats.tpr += E1000_READ_REG(shared, TPR);
adapter->stats.tpt += E1000_READ_REG(shared, TPT);
adapter->stats.ptc64 += E1000_READ_REG(shared, PTC64);
adapter->stats.ptc127 += E1000_READ_REG(shared, PTC127);
adapter->stats.ptc255 += E1000_READ_REG(shared, PTC255);
adapter->stats.ptc511 += E1000_READ_REG(shared, PTC511);
adapter->stats.ptc1023 += E1000_READ_REG(shared, PTC1023);
adapter->stats.ptc1522 += E1000_READ_REG(shared, PTC1522);
adapter->stats.mptc += E1000_READ_REG(shared, MPTC);
adapter->stats.bptc += E1000_READ_REG(shared, BPTC);
if(adapter->shared.mac_type >= e1000_82543) {
adapter->stats.algnerrc += E1000_READ_REG(shared, ALGNERRC);
adapter->stats.rxerrc += E1000_READ_REG(shared, RXERRC);
adapter->stats.tncrs += E1000_READ_REG(shared, TNCRS);
adapter->stats.cexterr += E1000_READ_REG(shared, CEXTERR);
adapter->stats.tsctc += E1000_READ_REG(shared, TSCTC);
adapter->stats.tsctfc += E1000_READ_REG(shared, TSCTFC);
adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
adapter->stats.mpc += E1000_READ_REG(hw, MPC);
adapter->stats.scc += E1000_READ_REG(hw, SCC);
adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
adapter->stats.mcc += E1000_READ_REG(hw, MCC);
adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
adapter->stats.dc += E1000_READ_REG(hw, DC);
adapter->stats.sec += E1000_READ_REG(hw, SEC);
adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
adapter->stats.ruc += E1000_READ_REG(hw, RUC);
adapter->stats.rfc += E1000_READ_REG(hw, RFC);
adapter->stats.rjc += E1000_READ_REG(hw, RJC);
adapter->stats.torl += E1000_READ_REG(hw, TORL);
adapter->stats.torh += E1000_READ_REG(hw, TORH);
adapter->stats.totl += E1000_READ_REG(hw, TOTL);
adapter->stats.toth += E1000_READ_REG(hw, TOTH);
adapter->stats.tpr += E1000_READ_REG(hw, TPR);
adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
/* used for adaptive IFS */
hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
adapter->stats.tpt += hw->tx_packet_delta;
hw->collision_delta = E1000_READ_REG(hw, COLC);
adapter->stats.colc += hw->collision_delta;
if(hw->mac_type >= e1000_82543) {
adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
}
/* Fill out the OS statistics structure */
......@@ -1627,14 +1640,18 @@ e1000_update_stats(struct e1000_adapter *adapter)
/* Tx Dropped needs to be maintained elsewhere */
if(adapter->shared.media_type == e1000_media_type_copper) {
adapter->phy_stats.idle_errors +=
(e1000_read_phy_reg(shared, PHY_1000T_STATUS)
& PHY_IDLE_ERROR_COUNT_MASK);
adapter->phy_stats.receive_errors +=
e1000_read_phy_reg(shared, M88E1000_RX_ERR_CNTR);
/* Phy Stats */
if(hw->media_type == e1000_media_type_copper) {
if((adapter->link_speed == SPEED_1000) &&
(!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
adapter->phy_stats.idle_errors += phy_tmp;
}
if(!e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
adapter->phy_stats.receive_errors += phy_tmp;
}
return;
}
/**
......@@ -1646,9 +1663,8 @@ static inline void
e1000_irq_disable(struct e1000_adapter *adapter)
{
atomic_inc(&adapter->irq_sem);
E1000_WRITE_REG(&adapter->shared, IMC, ~0);
E1000_WRITE_REG(&adapter->hw, IMC, ~0);
synchronize_irq();
return;
}
/**
......@@ -1660,8 +1676,7 @@ static inline void
e1000_irq_enable(struct e1000_adapter *adapter)
{
if(atomic_dec_and_test(&adapter->irq_sem))
E1000_WRITE_REG(&adapter->shared, IMS, IMS_ENABLE_MASK);
return;
E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
}
/**
......@@ -1679,20 +1694,23 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
uint32_t icr;
int i = E1000_MAX_INTR;
while(i && (icr = E1000_READ_REG(&adapter->shared, ICR))) {
while(i && (icr = E1000_READ_REG(&adapter->hw, ICR))) {
if(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
/* run the watchdog ASAP */
adapter->shared.get_link_status = 1;
adapter->hw.get_link_status = 1;
mod_timer(&adapter->watchdog_timer, jiffies);
}
e1000_clean_rx_irq(adapter);
if((icr & E1000_ICR_TXDW) && spin_trylock(&adapter->tx_lock)) {
e1000_clean_tx_irq(adapter);
i--;
spin_unlock(&adapter->tx_lock);
}
return;
i--;
}
}
/**
......@@ -1726,7 +1744,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
if(tx_ring->buffer_info[i].skb) {
dev_kfree_skb_irq(tx_ring->buffer_info[i].skb);
dev_kfree_skb_any(tx_ring->buffer_info[i].skb);
tx_ring->buffer_info[i].skb = NULL;
}
......@@ -1734,7 +1752,6 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
memset(tx_desc, 0, sizeof(struct e1000_tx_desc));
mb();
atomic_inc(&tx_ring->unused);
i = (i + 1) % tx_ring->count;
tx_desc = E1000_TX_DESC(*tx_ring, i);
......@@ -1744,11 +1761,10 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
tx_ring->next_to_clean = i;
if(netif_queue_stopped(netdev) && netif_carrier_ok(netdev) &&
(atomic_read(&tx_ring->unused) > E1000_TX_QUEUE_WAKE)) {
(E1000_DESC_UNUSED(tx_ring) > E1000_TX_QUEUE_WAKE)) {
netif_wake_queue(netdev);
}
return;
}
/**
......@@ -1789,12 +1805,10 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
E1000_DBG("Receive packet consumed multiple buffers\n");
dev_kfree_skb_irq(skb);
memset(rx_desc, 0, 16);
memset(rx_desc, 0, sizeof(struct e1000_rx_desc));
mb();
rx_ring->buffer_info[i].skb = NULL;
rx_ring->unused_count++;
i = (i + 1) % rx_ring->count;
rx_desc = E1000_RX_DESC(*rx_ring, i);
......@@ -1805,12 +1819,12 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
last_byte = *(skb->data + length - 1);
if(TBI_ACCEPT(&adapter->shared, rx_desc->special,
if(TBI_ACCEPT(&adapter->hw, rx_desc->status,
rx_desc->errors, length, last_byte)) {
spin_lock_irqsave(&adapter->stats_lock, flags);
e1000_tbi_adjust_stats(&adapter->shared,
e1000_tbi_adjust_stats(&adapter->hw,
&adapter->stats,
length, skb->data);
......@@ -1820,11 +1834,10 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
} else {
dev_kfree_skb_irq(skb);
memset(rx_desc, 0, 16);
memset(rx_desc, 0, sizeof(struct e1000_rx_desc));
mb();
rx_ring->buffer_info[i].skb = NULL;
rx_ring->unused_count++;
i = (i + 1) % rx_ring->count;
rx_desc = E1000_RX_DESC(*rx_ring, i);
......@@ -1833,20 +1846,28 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
}
/* Good Receive */
skb_put(skb, length - CRC_LENGTH);
skb_put(skb, length - ETHERNET_FCS_SIZE);
/* Receive Checksum Offload */
e1000_rx_checksum(adapter, rx_desc, skb);
skb->protocol = eth_type_trans(skb, netdev);
#ifdef NETIF_F_HW_VLAN_TX
if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) {
vlan_hwaccel_rx(skb, adapter->vlgrp,
(rx_desc->special & E1000_RXD_SPC_VLAN_MASK));
} else {
netif_rx(skb);
}
#else
netif_rx(skb);
#endif
netdev->last_rx = jiffies;
memset(rx_desc, 0, sizeof(struct e1000_rx_desc));
mb();
rx_ring->buffer_info[i].skb = NULL;
rx_ring->unused_count++;
i = (i + 1) % rx_ring->count;
rx_desc = E1000_RX_DESC(*rx_ring, i);
......@@ -1855,8 +1876,6 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
rx_ring->next_to_clean = i;
e1000_alloc_rx_buffers(adapter);
return;
}
/**
......@@ -1911,16 +1930,13 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
rx_desc->buffer_addr = cpu_to_le64(rx_ring->buffer_info[i].dma);
/* move tail */
E1000_WRITE_REG(&adapter->shared, RDT, i);
atomic_dec(&rx_ring->unused);
if(!(i % E1000_RX_BUFFER_WRITE))
E1000_WRITE_REG(&adapter->hw, RDT, i);
i = (i + 1) % rx_ring->count;
}
rx_ring->next_to_use = i;
return;
}
/**
......@@ -1954,7 +1970,7 @@ e1000_rx_checksum(struct e1000_adapter *adapter,
struct sk_buff *skb)
{
/* 82543 or newer only */
if((adapter->shared.mac_type < e1000_82543) ||
if((adapter->hw.mac_type < e1000_82543) ||
/* Ignore Checksum bit is set */
(rx_desc->status & E1000_RXD_STAT_IXSM) ||
/* TCP Checksum has not been calculated */
......@@ -1974,10 +1990,8 @@ e1000_rx_checksum(struct e1000_adapter *adapter,
skb->ip_summed = CHECKSUM_UNNECESSARY;
adapter->hw_csum_good++;
}
return;
}
/**
* e1000_enable_WOL - Wake On Lan Support (Magic Pkt)
* @adapter: Adapter structure
......@@ -1988,29 +2002,104 @@ e1000_enable_WOL(struct e1000_adapter *adapter)
{
uint32_t wuc;
if(adapter->shared.mac_type < e1000_82544)
if(adapter->hw.mac_type < e1000_82544)
return;
if(adapter->wol) {
wuc = E1000_WUC_APME | E1000_WUC_PME_EN |
E1000_WUC_PME_STATUS | E1000_WUC_APMPME;
E1000_WRITE_REG(&adapter->shared, WUC, wuc);
E1000_WRITE_REG(&adapter->hw, WUC, wuc);
E1000_WRITE_REG(&adapter->shared, WUFC, adapter->wol);
E1000_WRITE_REG(&adapter->hw, WUFC, adapter->wol);
}
return;
}
void
e1000_write_pci_cfg(struct e1000_shared_adapter *shared,
e1000_write_pci_cfg(struct e1000_hw *hw,
uint32_t reg, uint16_t *value)
{
struct e1000_adapter *adapter = shared->back;
struct e1000_adapter *adapter = hw->back;
pci_write_config_word(adapter->pdev, reg, *value);
return;
}
#ifdef NETIF_F_HW_VLAN_TX
static void
e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
{
struct e1000_adapter *adapter = netdev->priv;
uint32_t ctrl, rctl;
e1000_irq_disable(adapter);
adapter->vlgrp = grp;
if(grp) {
/* enable VLAN tag insert/strip */
E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
ctrl = E1000_READ_REG(&adapter->hw, CTRL);
ctrl |= E1000_CTRL_VME;
E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
/* enable VLAN receive filtering */
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl |= E1000_RCTL_VFE;
rctl &= ~E1000_RCTL_CFIEN;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
} else {
/* disable VLAN tag insert/strip */
ctrl = E1000_READ_REG(&adapter->hw, CTRL);
ctrl &= ~E1000_CTRL_VME;
E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
/* disable VLAN filtering */
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl &= ~E1000_RCTL_VFE;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
}
e1000_irq_enable(adapter);
}
static void
e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
{
struct e1000_adapter *adapter = netdev->priv;
uint32_t vfta, index;
/* add VID to filter table */
index = (vid >> 5) & 0x7F;
vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
vfta |= (1 << (vid & 0x1F));
e1000_write_vfta(&adapter->hw, index, vfta);
}
static void
e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
{
struct e1000_adapter *adapter = netdev->priv;
uint32_t vfta, index;
e1000_irq_disable(adapter);
if(adapter->vlgrp)
adapter->vlgrp->vlan_devices[vid] = NULL;
e1000_irq_enable(adapter);
/* remove VID from filter table*/
index = (vid >> 5) & 0x7F;
vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
vfta &= ~(1 << (vid & 0x1F));
e1000_write_vfta(&adapter->hw, index, vfta);
}
#endif
/* e1000_main.c */
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......@@ -153,7 +152,7 @@ E1000_PARAM(Duplex, "Duplex setting");
/* Auto-negotiation Advertisement Override
*
* Valid Range: 0x00-0x0F, 0x20-0x2F
* Valid Range: 0x01-0x0F, 0x20-0x2F
*
* The AutoNeg value is a bit mask describing which speed and duplex
* combinations should be advertised during auto-negotiation.
......@@ -193,20 +192,11 @@ E1000_PARAM(FlowControl, "Flow Control setting");
E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
/* Transmit Interrupt Delay in units of 1.024 microseconds
*
* Valid Range: 0-65535
*
* Default Value: 64
*/
E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
/* Receive Interrupt Delay in units of 1.024 microseconds
*
* Valid Range: 0-65535
*
* Default Value: 64
* Default Value: 64/128
*/
E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
......@@ -252,13 +242,10 @@ E1000_PARAM(DisablePolarityCorrection,
#define MIN_RXD 80
#define MAX_82544_RXD 4096
#define DEFAULT_TIDV 64
#define MAX_TIDV 0xFFFF
#define MIN_TIDV 0
#define DEFAULT_RIDV 64
#define MAX_RIDV 0xFFFF
#define MIN_RIDV 0
#define DEFAULT_RDTR 64
#define DEFAULT_RADV 128
#define MAX_RXDELAY 0xFFFF
#define MIN_RXDELAY 0
#define DEFAULT_MDIX 0
#define MAX_MDIX 3
......@@ -332,8 +319,6 @@ e1000_validate_option(int *value, struct e1000_option *opt)
return -1;
}
#define LIST_LEN(l) (sizeof(l) / sizeof(l[0]))
static void e1000_check_fiber_options(struct e1000_adapter *adapter);
static void e1000_check_copper_options(struct e1000_adapter *adapter);
......@@ -367,7 +352,7 @@ e1000_check_options(struct e1000_adapter *adapter)
arg: { r: { min: MIN_TXD }}
};
struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
e1000_mac_type mac_type = adapter->shared.mac_type;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.arg.r.max = mac_type < e1000_82544 ? MAX_TXD : MAX_82544_TXD;
tx_ring->count = TxDescriptors[bd];
......@@ -383,7 +368,7 @@ e1000_check_options(struct e1000_adapter *adapter)
arg: { r: { min: MIN_RXD }}
};
struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
e1000_mac_type mac_type = adapter->shared.mac_type;
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.arg.r.max = mac_type < e1000_82544 ? MAX_RXD : MAX_82544_RXD;
rx_ring->count = RxDescriptors[bd];
......@@ -416,39 +401,30 @@ e1000_check_options(struct e1000_adapter *adapter)
name: "Flow Control",
err: "reading default settings from EEPROM",
def: e1000_fc_default,
arg: { l: { nr: LIST_LEN(fc_list), p: fc_list }}
arg: { l: { nr: ARRAY_SIZE(fc_list), p: fc_list }}
};
int fc = FlowControl[bd];
e1000_validate_option(&fc, &opt);
adapter->shared.fc = adapter->shared.original_fc = fc;
}
{ /* Transmit Interrupt Delay */
struct e1000_option opt = {
type: range_option,
name: "Transmit Interrupt Delay",
err: "using default of " __MODULE_STRING(DEFAULT_TIDV),
def: DEFAULT_TIDV,
arg: { r: { min: MIN_TIDV, max: MAX_TIDV }}
};
adapter->tx_int_delay = TxIntDelay[bd];
e1000_validate_option(&adapter->tx_int_delay, &opt);
adapter->hw.fc = adapter->hw.original_fc = fc;
}
{ /* Receive Interrupt Delay */
char *rdtr = "using default of " __MODULE_STRING(DEFAULT_RDTR);
char *radv = "using default of " __MODULE_STRING(DEFAULT_RADV);
struct e1000_option opt = {
type: range_option,
name: "Receive Interrupt Delay",
err: "using default of " __MODULE_STRING(DEFAULT_RIDV),
def: DEFAULT_RIDV,
arg: { r: { min: MIN_RIDV, max: MAX_RIDV }}
arg: { r: { min: MIN_RXDELAY, max: MAX_RXDELAY }}
};
e1000_mac_type mac_type = adapter->hw.mac_type;
opt.def = mac_type < e1000_82540 ? DEFAULT_RDTR : DEFAULT_RADV;
opt.err = mac_type < e1000_82540 ? rdtr : radv;
adapter->rx_int_delay = RxIntDelay[bd];
e1000_validate_option(&adapter->rx_int_delay, &opt);
}
switch(adapter->shared.media_type) {
switch(adapter->hw.media_type) {
case e1000_media_type_fiber:
e1000_check_fiber_options(adapter);
break;
......@@ -511,7 +487,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
name: "Speed",
err: "parameter ignored",
def: 0,
arg: { l: { nr: LIST_LEN(speed_list), p: speed_list }}
arg: { l: { nr: ARRAY_SIZE(speed_list), p: speed_list }}
};
speed = Speed[bd];
......@@ -526,7 +502,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
name: "Duplex",
err: "parameter ignored",
def: 0,
arg: { l: { nr: LIST_LEN(dplx_list), p: dplx_list }}
arg: { l: { nr: ARRAY_SIZE(dplx_list), p: dplx_list }}
};
dplx = Duplex[bd];
......@@ -537,10 +513,10 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
printk(KERN_INFO
"AutoNeg specified along with Speed or Duplex, "
"parameter ignored\n");
adapter->shared.autoneg_advertised = AUTONEG_ADV_DEFAULT;
adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
} else { /* Autoneg */
struct e1000_opt_list an_list[] =
#define AA "Autoneg advertising "
#define AA "AutoNeg advertising "
{{ 0x01, AA "10/HD" },
{ 0x02, AA "10/FD" },
{ 0x03, AA "10/FD, 10/HD" },
......@@ -575,20 +551,20 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
struct e1000_option opt = {
type: list_option,
name: "Autoneg",
name: "AutoNeg",
err: "parameter ignored",
def: AUTONEG_ADV_DEFAULT,
arg: { l: { nr: LIST_LEN(an_list), p: an_list }}
arg: { l: { nr: ARRAY_SIZE(an_list), p: an_list }}
};
int an = AutoNeg[bd];
e1000_validate_option(&an, &opt);
adapter->shared.autoneg_advertised = an;
adapter->hw.autoneg_advertised = an;
}
switch (speed + dplx) {
case 0:
adapter->shared.autoneg = 1;
adapter->hw.autoneg = 1;
if(Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET)
printk(KERN_INFO
"Speed and duplex autonegotiation enabled\n");
......@@ -596,75 +572,75 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
case HALF_DUPLEX:
printk(KERN_INFO "Half Duplex specified without Speed\n");
printk(KERN_INFO "Using Autonegotiation at Half Duplex only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_10_HALF |
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
ADVERTISE_100_HALF;
break;
case FULL_DUPLEX:
printk(KERN_INFO "Full Duplex specified without Speed\n");
printk(KERN_INFO "Using Autonegotiation at Full Duplex only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_10_FULL |
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
ADVERTISE_100_FULL |
ADVERTISE_1000_FULL;
break;
case SPEED_10:
printk(KERN_INFO "10 Mbps Speed specified without Duplex\n");
printk(KERN_INFO "Using Autonegotiation at 10 Mbps only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_10_HALF |
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
ADVERTISE_10_FULL;
break;
case SPEED_10 + HALF_DUPLEX:
printk(KERN_INFO "Forcing to 10 Mbps Half Duplex\n");
adapter->shared.autoneg = 0;
adapter->shared.forced_speed_duplex = e1000_10_half;
adapter->shared.autoneg_advertised = 0;
adapter->hw.autoneg = 0;
adapter->hw.forced_speed_duplex = e1000_10_half;
adapter->hw.autoneg_advertised = 0;
break;
case SPEED_10 + FULL_DUPLEX:
printk(KERN_INFO "Forcing to 10 Mbps Full Duplex\n");
adapter->shared.autoneg = 0;
adapter->shared.forced_speed_duplex = e1000_10_full;
adapter->shared.autoneg_advertised = 0;
adapter->hw.autoneg = 0;
adapter->hw.forced_speed_duplex = e1000_10_full;
adapter->hw.autoneg_advertised = 0;
break;
case SPEED_100:
printk(KERN_INFO "100 Mbps Speed specified without Duplex\n");
printk(KERN_INFO "Using Autonegotiation at 100 Mbps only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_100_HALF |
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
ADVERTISE_100_FULL;
break;
case SPEED_100 + HALF_DUPLEX:
printk(KERN_INFO "Forcing to 100 Mbps Half Duplex\n");
adapter->shared.autoneg = 0;
adapter->shared.forced_speed_duplex = e1000_100_half;
adapter->shared.autoneg_advertised = 0;
adapter->hw.autoneg = 0;
adapter->hw.forced_speed_duplex = e1000_100_half;
adapter->hw.autoneg_advertised = 0;
break;
case SPEED_100 + FULL_DUPLEX:
printk(KERN_INFO "Forcing to 100 Mbps Full Duplex\n");
adapter->shared.autoneg = 0;
adapter->shared.forced_speed_duplex = e1000_100_full;
adapter->shared.autoneg_advertised = 0;
adapter->hw.autoneg = 0;
adapter->hw.forced_speed_duplex = e1000_100_full;
adapter->hw.autoneg_advertised = 0;
break;
case SPEED_1000:
printk(KERN_INFO "1000 Mbps Speed specified without Duplex\n");
printk(KERN_INFO
"Using Autonegotiation at 1000 Mbps Full Duplex only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_1000_FULL;
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
break;
case SPEED_1000 + HALF_DUPLEX:
printk(KERN_INFO "Half Duplex is not supported at 1000 Mbps\n");
printk(KERN_INFO
"Using Autonegotiation at 1000 Mbps Full Duplex only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_1000_FULL;
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
break;
case SPEED_1000 + FULL_DUPLEX:
printk(KERN_INFO
"Using Autonegotiation at 1000 Mbps Full Duplex only\n");
adapter->shared.autoneg = 1;
adapter->shared.autoneg_advertised = ADVERTISE_1000_FULL;
adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
break;
default:
BUG();
......@@ -683,7 +659,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
int mdix = MdiX[bd];
e1000_validate_option(&mdix, &opt);
adapter->shared.mdix = mdix;
adapter->hw.mdix = mdix;
}
{ /* Automatic Correction for Reverse Cable Polarity */
/* option is actually to disable polarity correction,
......@@ -697,11 +673,11 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
int dpc = DisablePolarityCorrection[bd];
e1000_validate_option(&dpc, &opt);
adapter->shared.disable_polarity_correction = dpc;
adapter->hw.disable_polarity_correction = dpc;
}
/* Speed, AutoNeg and MDI/MDI-X must all play nice */
if (!e1000_validate_mdi_setting(&(adapter->shared))) {
if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
printk(KERN_INFO "Speed, AutoNeg and MDI-X specifications are "
"incompatible. Setting MDI-X to a compatible value.\n");
}
......
/*******************************************************************************
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
Intel(R) PRO/1000 Family of Adapters (e1000) (the "Software") being provided
by Intel Corporation. The following definitions apply to this license:
"Licensed Patents" means patent claims licensable by Intel Corporation which
are necessarily infringed by the use of sale of the Software alone or when
combined with the operating system referred to below.
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
All rights reserved.
The license is provided to Recipient and Recipient's Licensees under the
following terms.
Redistribution and use in source and binary forms of the Software, with or
without modification, are permitted provided that the following conditions
are met:
Redistributions of source code of the Software may retain the above
copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form of the Software may reproduce the above
copyright notice, this list of conditions and the following disclaimer in
the documentation and/or materials provided with the distribution.
Neither the name of Intel Corporation nor the names of its contributors
shall be used to endorse or promote products derived from this Software
without specific prior written permission.
Intel hereby grants Recipient and Licensees a non-exclusive, worldwide,
royalty-free patent license under Licensed Patents to make, use, sell, offer
to sell, import and otherwise transfer the Software, if any, in source code
and object code form. This license shall include changes to the Software
that are error corrections or other minor changes to the Software that do
not add functionality or features when the Software is incorporated in any
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR IT CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
ANY LOSS OF USE; DATA, OR PROFITS; OR BUSINESS INTERUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
/* e1000_phy.c
* Shared functions for accessing and configuring the PHY
*/
#include "e1000_mac.h"
#include "e1000_phy.h"
/******************************************************************************
* Raises the Management Data Clock
*
* shared - Struct containing variables accessed by shared code
* ctrl_reg - Device control register's current value
******************************************************************************/
static void
e1000_raise_mdc(struct e1000_shared_adapter *shared,
uint32_t *ctrl_reg)
{
/* Raise the clock input to the Management Data Clock (by setting
* the MDC bit), and then delay 2 microseconds.
*/
E1000_WRITE_REG(shared, CTRL, (*ctrl_reg | E1000_CTRL_MDC));
usec_delay(2);
return;
}
/******************************************************************************
* Lowers the Management Data Clock
*
* shared - Struct containing variables accessed by shared code
* ctrl_reg - Device control register's current value
******************************************************************************/
static void
e1000_lower_mdc(struct e1000_shared_adapter *shared,
uint32_t *ctrl_reg)
{
/* Lower the clock input to the Management Data Clock (by clearing
* the MDC bit), and then delay 2 microseconds.
*/
E1000_WRITE_REG(shared, CTRL, (*ctrl_reg & ~E1000_CTRL_MDC));
usec_delay(2);
return;
}
/******************************************************************************
* Shifts data bits out to the PHY
*
* shared - Struct containing variables accessed by shared code
* data - Data to send out to the PHY
* count - Number of bits to shift out
*
* Bits are shifted out in MSB to LSB order.
******************************************************************************/
static void
e1000_phy_shift_out(struct e1000_shared_adapter *shared,
uint32_t data,
uint16_t count)
{
uint32_t ctrl_reg;
uint32_t mask;
ASSERT(count <= 32);
/* We need to shift "count" number of bits out to the PHY. So, the
* value in the "Data" parameter will be shifted out to the PHY
* one bit at a time. In order to do this, "Data" must be broken
* down into bits, which is what the "while" logic does below.
*/
mask = 0x01;
mask <<= (count - 1);
ctrl_reg = E1000_READ_REG(shared, CTRL);
/* Set MDIO_DIR (SWDPIO1) and MDC_DIR (SWDPIO2) direction bits to
* be used as output pins.
*/
ctrl_reg |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
while(mask) {
/* A "1" is shifted out to the PHY by setting the MDIO bit to
* "1" and then raising and lowering the Management Data Clock
* (MDC). A "0" is shifted out to the PHY by setting the MDIO
* bit to "0" and then raising and lowering the clock.
*/
if(data & mask)
ctrl_reg |= E1000_CTRL_MDIO;
else
ctrl_reg &= ~E1000_CTRL_MDIO;
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
usec_delay(2);
e1000_raise_mdc(shared, &ctrl_reg);
e1000_lower_mdc(shared, &ctrl_reg);
mask = mask >> 1;
}
/* Clear the data bit just before leaving this routine. */
ctrl_reg &= ~E1000_CTRL_MDIO;
return;
}
/******************************************************************************
* Shifts data bits in from the PHY
*
* shared - Struct containing variables accessed by shared code
*
* Bits are shifted in in MSB to LSB order.
******************************************************************************/
static uint16_t
e1000_phy_shift_in(struct e1000_shared_adapter *shared)
{
uint32_t ctrl_reg;
uint16_t data = 0;
uint8_t i;
/* In order to read a register from the PHY, we need to shift in a
* total of 18 bits from the PHY. The first two bit (TurnAround)
* times are used to avoid contention on the MDIO pin when a read
* operation is performed. These two bits are ignored by us and
* thrown away. Bits are "shifted in" by raising the clock input
* to the Management Data Clock (setting the MDC bit), and then
* reading the value of the MDIO bit.
*/
ctrl_reg = E1000_READ_REG(shared, CTRL);
/* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as
* input.
*/
ctrl_reg &= ~E1000_CTRL_MDIO_DIR;
ctrl_reg &= ~E1000_CTRL_MDIO;
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
/* Raise and Lower the clock before reading in the data. This
* accounts for the TurnAround bits. The first clock occurred
* when we clocked out the last bit of the Register Address.
*/
e1000_raise_mdc(shared, &ctrl_reg);
e1000_lower_mdc(shared, &ctrl_reg);
for(data = 0, i = 0; i < 16; i++) {
data = data << 1;
e1000_raise_mdc(shared, &ctrl_reg);
ctrl_reg = E1000_READ_REG(shared, CTRL);
/* Check to see if we shifted in a "1". */
if(ctrl_reg & E1000_CTRL_MDIO)
data |= 1;
e1000_lower_mdc(shared, &ctrl_reg);
}
e1000_raise_mdc(shared, &ctrl_reg);
e1000_lower_mdc(shared, &ctrl_reg);
/* Clear the MDIO bit just before leaving this routine. */
ctrl_reg &= ~E1000_CTRL_MDIO;
return (data);
}
/******************************************************************************
* Force PHY speed and duplex settings to shared->forced_speed_duplex
*
* shared - Struct containing variables accessed by shared code
******************************************************************************/
static void
e1000_phy_force_speed_duplex(struct e1000_shared_adapter *shared)
{
uint32_t tctl_reg;
uint32_t ctrl_reg;
uint32_t shift;
uint16_t mii_ctrl_reg;
uint16_t mii_status_reg;
uint16_t phy_data;
uint16_t i;
DEBUGFUNC("e1000_phy_force_speed_duplex");
/* Turn off Flow control if we are forcing speed and duplex. */
shared->fc = e1000_fc_none;
DEBUGOUT1("shared->fc = %d\n", shared->fc);
/* Read the Device Control Register. */
ctrl_reg = E1000_READ_REG(shared, CTRL);
/* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
ctrl_reg |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
ctrl_reg &= ~(DEVICE_SPEED_MASK);
/* Clear the Auto Speed Detect Enable bit. */
ctrl_reg &= ~E1000_CTRL_ASDE;
/* Read the MII Control Register. */
mii_ctrl_reg = e1000_read_phy_reg(shared, PHY_CTRL);
/* We need to disable autoneg in order to force link and duplex. */
mii_ctrl_reg &= ~MII_CR_AUTO_NEG_EN;
/* Are we forcing Full or Half Duplex? */
if(shared->forced_speed_duplex == e1000_100_full ||
shared->forced_speed_duplex == e1000_10_full) {
/* We want to force full duplex so we SET the full duplex bits
* in the Device and MII Control Registers.
*/
ctrl_reg |= E1000_CTRL_FD;
mii_ctrl_reg |= MII_CR_FULL_DUPLEX;
DEBUGOUT("Full Duplex\n");
} else {
/* We want to force half duplex so we CLEAR the full duplex
* bits in the Device and MII Control Registers.
*/
ctrl_reg &= ~E1000_CTRL_FD;
mii_ctrl_reg &= ~MII_CR_FULL_DUPLEX; /* Do this implies HALF */
DEBUGOUT("Half Duplex\n");
}
/* Are we forcing 100Mbps??? */
if(shared->forced_speed_duplex == e1000_100_full ||
shared->forced_speed_duplex == e1000_100_half) {
/* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
ctrl_reg |= E1000_CTRL_SPD_100;
mii_ctrl_reg |= MII_CR_SPEED_100;
mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
DEBUGOUT("Forcing 100mb ");
} else { /* Force 10MB Full or Half */
/* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
ctrl_reg &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
mii_ctrl_reg |= MII_CR_SPEED_10;
mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
DEBUGOUT("Forcing 10mb ");
}
/* Now we need to configure the Collision Distance. We need to read
* the Transmit Control Register to do this.
* Note: This must be done for both Half or Full Duplex.
*/
tctl_reg = E1000_READ_REG(shared, TCTL);
DEBUGOUT1("tctl_reg = %x\n", tctl_reg);
if(!(mii_ctrl_reg & MII_CR_FULL_DUPLEX)) {
/* We are in Half Duplex mode so we need to set up our collision
* distance for 10/100.
*/
tctl_reg &= ~E1000_TCTL_COLD;
shift = E1000_HDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
} else {
/* We are in Full Duplex mode. We have the same collision
* distance regardless of speed.
*/
tctl_reg &= ~E1000_TCTL_COLD;
shift = E1000_FDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
}
/* Write the configured values back to the Transmit Control Reg. */
E1000_WRITE_REG(shared, TCTL, tctl_reg);
/* Write the configured values back to the Device Control Reg. */
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
/* Write the MII Control Register with the new PHY configuration. */
phy_data = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_CTRL);
/* Clear Auto-Crossover to force MDI manually.
* M88E1000 requires MDI forced whenever speed/duplex is forced
*/
phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
e1000_write_phy_reg(shared, M88E1000_PHY_SPEC_CTRL, phy_data);
DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data);
/* Need to reset the PHY or these bits will get ignored. */
mii_ctrl_reg |= MII_CR_RESET;
e1000_write_phy_reg(shared, PHY_CTRL, mii_ctrl_reg);
/* The wait_autoneg_complete flag may be a little misleading here.
* Since we are forcing speed and duplex, Auto-Neg is not enabled.
* But we do want to delay for a period while forcing only so we
* don't generate false No Link messages. So we will wait here
* only if the user has set wait_autoneg_complete to 1, which is
* the default.
*/
if(shared->wait_autoneg_complete) {
/* We will wait for autoneg to complete. */
DEBUGOUT("Waiting for forced speed/duplex link.\n");
mii_status_reg = 0;
/* We will wait for autoneg to complete or 4.5 seconds to expire. */
for(i = PHY_FORCE_TIME; i > 0; i--) {
/* Read the MII Status Register and wait for Auto-Neg
* Complete bit to be set.
*/
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
if(mii_status_reg & MII_SR_LINK_STATUS)
break;
msec_delay(100);
} /* end for loop */
if(i == 0) { /* We didn't get link */
/* Reset the DSP and wait again for link. */
e1000_phy_reset_dsp(shared);
}
/* This loop will early-out if the link condition has been met. */
for(i = PHY_FORCE_TIME; i > 0; i--) {
if(mii_status_reg & MII_SR_LINK_STATUS)
break;
msec_delay(100);
/* Read the MII Status Register and wait for Auto-Neg
* Complete bit to be set.
*/
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
} /* end for loop */
} /* end if wait_autoneg_complete */
/*
* Because we reset the PHY above, we need to re-force TX_CLK in the
* Extended PHY Specific Control Register to 25MHz clock. This
* value defaults back to a 2.5MHz clock when the PHY is reset.
*/
phy_data = e1000_read_phy_reg(shared, M88E1000_EXT_PHY_SPEC_CTRL);
phy_data |= M88E1000_EPSCR_TX_CLK_25;
e1000_write_phy_reg(shared, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
/* In addition, because of the s/w reset above, we need to enable
* CRS on TX. This must be set for both full and half duplex
* operation.
*/
phy_data = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_CTRL);
phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
e1000_write_phy_reg(shared, M88E1000_PHY_SPEC_CTRL, phy_data);
DEBUGOUT1("M88E1000 Phy Specific Ctrl Reg = %4x\r\n", phy_data);
return;
}
/*****************************************************************************
* Reads the value from a PHY register
*
* shared - Struct containing variables accessed by shared code
* reg_addr - address of the PHY register to read
******************************************************************************/
uint16_t
e1000_read_phy_reg(struct e1000_shared_adapter *shared,
uint32_t reg_addr)
{
uint32_t i;
uint32_t data = 0;
uint32_t command = 0;
ASSERT(reg_addr <= MAX_PHY_REG_ADDRESS);
if(shared->mac_type > e1000_82543) {
/* Set up Op-code, Phy Address, and
* register address in the MDI Control register. The MAC will
* take care of interfacing with the PHY to retrieve the
* desired data.
*/
command = ((reg_addr << E1000_MDIC_REG_SHIFT) |
(shared->phy_addr << E1000_MDIC_PHY_SHIFT) |
(E1000_MDIC_OP_READ));
E1000_WRITE_REG(shared, MDIC, command);
/* Check every 10 usec to see if the read completed. The read
* may take as long as 64 usecs (we'll wait 100 usecs max)
* from the CPU Write to the Ready bit assertion.
*/
for(i = 0; i < 64; i++) {
usec_delay(10);
data = E1000_READ_REG(shared, MDIC);
if(data & E1000_MDIC_READY)
break;
}
} else {
/* We must first send a preamble through the MDIO pin to signal the
* beginning of an MII instruction. This is done by sending 32
* consecutive "1" bits.
*/
e1000_phy_shift_out(shared, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
/* Now combine the next few fields that are required for a read
* operation. We use this method instead of calling the
* e1000_phy_shift_out routine five different times. The format of
* a MII read instruction consists of a shift out of 14 bits and is
* defined as follows:
* <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
* followed by a shift in of 18 bits. This first two bits shifted
* in are TurnAround bits used to avoid contention on the MDIO pin
* when a READ operation is performed. These two bits are thrown
* away followed by a shift in of 16 bits which contains the
* desired data.
*/
command = ((reg_addr) |
(shared->phy_addr << 5) |
(PHY_OP_READ << 10) | (PHY_SOF << 12));
e1000_phy_shift_out(shared, command, 14);
/* Now that we've shifted out the read command to the MII, we need
* to "shift in" the 16-bit value (18 total bits) of the requested
* PHY register address.
*/
data = (uint32_t) e1000_phy_shift_in(shared);
}
ASSERT(!(data & E1000_MDIC_ERROR));
return ((uint16_t) data);
}
/******************************************************************************
* Writes a value to a PHY register
*
* shared - Struct containing variables accessed by shared code
* reg_addr - address of the PHY register to write
* data - data to write to the PHY
******************************************************************************/
void
e1000_write_phy_reg(struct e1000_shared_adapter *shared,
uint32_t reg_addr,
uint16_t data)
{
uint32_t i;
uint32_t command = 0;
uint32_t mdic_reg;
ASSERT(reg_addr <= MAX_PHY_REG_ADDRESS);
if(shared->mac_type > e1000_82543) {
/* Set up Op-code, Phy Address, register
* address, and data intended for the PHY register in the MDI
* Control register. The MAC will take care of interfacing
* with the PHY to send the desired data.
*/
command = (((uint32_t) data) |
(reg_addr << E1000_MDIC_REG_SHIFT) |
(shared->phy_addr << E1000_MDIC_PHY_SHIFT) |
(E1000_MDIC_OP_WRITE));
E1000_WRITE_REG(shared, MDIC, command);
/* Check every 10 usec to see if the read completed. The read
* may take as long as 64 usecs (we'll wait 100 usecs max)
* from the CPU Write to the Ready bit assertion.
*/
for(i = 0; i < 10; i++) {
usec_delay(10);
mdic_reg = E1000_READ_REG(shared, MDIC);
if(mdic_reg & E1000_MDIC_READY)
break;
}
} else {
/* We'll need to use the SW defined pins to shift the write command
* out to the PHY. We first send a preamble to the PHY to signal the
* beginning of the MII instruction. This is done by sending 32
* consecutive "1" bits.
*/
e1000_phy_shift_out(shared, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
/* Now combine the remaining required fields that will indicate
* a write operation. We use this method instead of calling the
* e1000_phy_shift_out routine for each field in the command. The
* format of a MII write instruction is as follows:
* <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
*/
command = ((PHY_TURNAROUND) |
(reg_addr << 2) |
(shared->phy_addr << 7) |
(PHY_OP_WRITE << 12) | (PHY_SOF << 14));
command <<= 16;
command |= ((uint32_t) data);
e1000_phy_shift_out(shared, command, 32);
}
return;
}
/******************************************************************************
* Returns the PHY to the power-on reset state
*
* shared - Struct containing variables accessed by shared code
******************************************************************************/
void
e1000_phy_hw_reset(struct e1000_shared_adapter *shared)
{
uint32_t ctrl_reg;
uint32_t ctrl_ext_reg;
DEBUGFUNC("e1000_phy_hw_reset");
DEBUGOUT("Resetting Phy...\n");
if(shared->mac_type > e1000_82543) {
/* Read the device control register and assert the
* E1000_CTRL_PHY_RST bit. Hold for 20ms and then take it out
* of reset.
*/
ctrl_reg = E1000_READ_REG(shared, CTRL);
ctrl_reg |= E1000_CTRL_PHY_RST;
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
msec_delay(20);
ctrl_reg &= ~E1000_CTRL_PHY_RST;
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
msec_delay(20);
} else {
/* Read the Extended Device Control Register, assert the
* PHY_RESET_DIR bit. Then clock it out to the PHY.
*/
ctrl_ext_reg = E1000_READ_REG(shared, CTRL_EXT);
ctrl_ext_reg |= E1000_CTRL_PHY_RESET_DIR4;
E1000_WRITE_REG(shared, CTRL_EXT, ctrl_ext_reg);
msec_delay(20);
/* Set the reset bit in the device control register and clock
* it out to the PHY.
*/
ctrl_ext_reg = E1000_READ_REG(shared, CTRL_EXT);
ctrl_ext_reg &= ~E1000_CTRL_PHY_RESET4;
E1000_WRITE_REG(shared, CTRL_EXT, ctrl_ext_reg);
msec_delay(20);
ctrl_ext_reg = E1000_READ_REG(shared, CTRL_EXT);
ctrl_ext_reg |= E1000_CTRL_PHY_RESET4;
E1000_WRITE_REG(shared, CTRL_EXT, ctrl_ext_reg);
msec_delay(20);
}
return;
}
/******************************************************************************
* Resets the PHY
*
* shared - Struct containing variables accessed by shared code
*
* Sets bit 15 of the MII Control regiser
******************************************************************************/
boolean_t
e1000_phy_reset(struct e1000_shared_adapter *shared)
{
uint16_t reg_data;
uint16_t i;
DEBUGFUNC("e1000_phy_reset");
/* Read the MII control register, set the reset bit and write the
* value back by clocking it out to the PHY.
*/
reg_data = e1000_read_phy_reg(shared, PHY_CTRL);
reg_data |= MII_CR_RESET;
e1000_write_phy_reg(shared, PHY_CTRL, reg_data);
/* Wait for bit 15 of the MII Control Register to be cleared
* indicating the PHY has been reset.
*/
i = 0;
while((reg_data & MII_CR_RESET) && i++ < 500) {
reg_data = e1000_read_phy_reg(shared, PHY_CTRL);
usec_delay(1);
}
if(i >= 500) {
DEBUGOUT("Timeout waiting for PHY to reset.\n");
return FALSE;
}
return TRUE;
}
/******************************************************************************
* Detects which PHY is present and the speed and duplex
*
* shared - Struct containing variables accessed by shared code
* ctrl_reg - current value of the device control register
******************************************************************************/
boolean_t
e1000_phy_setup(struct e1000_shared_adapter *shared,
uint32_t ctrl_reg)
{
uint16_t mii_ctrl_reg;
uint16_t mii_status_reg;
uint16_t phy_specific_ctrl_reg;
uint16_t mii_autoneg_adv_reg;
uint16_t mii_1000t_ctrl_reg;
uint16_t i;
uint16_t data;
uint16_t autoneg_hw_setting;
uint16_t autoneg_fc_setting;
boolean_t restart_autoneg = FALSE;
boolean_t force_autoneg_restart = FALSE;
DEBUGFUNC("e1000_phy_setup");
/* We want to enable the Auto-Speed Detection bit in the Device
* Control Register. When set to 1, the MAC automatically detects
* the resolved speed of the link and self-configures appropriately.
* The Set Link Up bit must also be set for this behavior work
* properly.
*/
/* Nothing but 82543 and newer */
ASSERT(shared->mac_type >= e1000_82543);
/* With 82543, we need to force speed/duplex
* on the MAC equal to what the PHY speed/duplex configuration is.
* In addition, on 82543, we need to perform a hardware reset
* on the PHY to take it out of reset.
*/
if(shared->mac_type >= e1000_82544) {
ctrl_reg |= E1000_CTRL_SLU;
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
} else {
ctrl_reg |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
if(shared->mac_type == e1000_82543)
e1000_phy_hw_reset(shared);
}
if(!e1000_detect_gig_phy(shared)) {
/* No PHY detected, return FALSE */
DEBUGOUT("PhySetup failure, did not detect valid phy.\n");
return (FALSE);
}
DEBUGOUT1("Phy ID = %x \n", shared->phy_id);
/* Read the MII Control Register. */
mii_ctrl_reg = e1000_read_phy_reg(shared, PHY_CTRL);
DEBUGOUT1("MII Ctrl Reg contents = %x\n", mii_ctrl_reg);
/* Check to see if the Auto Neg Enable bit is set in the MII Control
* Register. If not, we could be in a situation where a driver was
* loaded previously and was forcing speed and duplex. Then the
* driver was unloaded but a e1000_phy_hw_reset was not performed, so
* link was still being forced and link was still achieved. Then
* the driver was reloaded with the intention to auto-negotiate, but
* since link is already established we end up not restarting
* auto-neg. So if the auto-neg bit is not enabled and the driver
* is being loaded with the desire to auto-neg, we set this flag to
* to ensure the restart of the auto-neg engine later in the logic.
*/
if(!(mii_ctrl_reg & MII_CR_AUTO_NEG_EN))
force_autoneg_restart = TRUE;
/* Clear the isolate bit for normal operation and write it back to
* the MII Control Reg. Although the spec says this doesn't need
* to be done when the PHY address is not equal to zero, we do it
* anyway just to be safe.
*/
mii_ctrl_reg &= ~(MII_CR_ISOLATE);
e1000_write_phy_reg(shared, PHY_CTRL, mii_ctrl_reg);
data = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_CTRL);
/* Enable CRS on TX. This must be set for half-duplex operation. */
data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
DEBUGOUT1("M88E1000 PSCR: %x \n", data);
e1000_write_phy_reg(shared, M88E1000_PHY_SPEC_CTRL, data);
data = e1000_read_phy_reg(shared, M88E1000_EXT_PHY_SPEC_CTRL);
/* Force TX_CLK in the Extended PHY Specific Control Register
* to 25MHz clock.
*/
data |= M88E1000_EPSCR_TX_CLK_25;
e1000_write_phy_reg(shared, M88E1000_EXT_PHY_SPEC_CTRL, data);
/* Certain PHYs will set the default of MII register 4 differently.
* We need to check this against our fc value. If it is
* different, we need to setup up register 4 correctly and restart
* autonegotiation.
*/
/* Read the MII Auto-Neg Advertisement Register (Address 4). */
mii_autoneg_adv_reg = e1000_read_phy_reg(shared, PHY_AUTONEG_ADV);
/* Shift right to put 10T-Half bit in bit 0
* Isolate the four bits for 100/10 Full/Half.
*/
autoneg_hw_setting = (mii_autoneg_adv_reg >> 5) & 0xF;
/* Get the 1000T settings. */
mii_1000t_ctrl_reg = e1000_read_phy_reg(shared, PHY_1000T_CTRL);
/* Isolate and OR in the 1000T settings. */
autoneg_hw_setting |= ((mii_1000t_ctrl_reg & 0x0300) >> 4);
/* mask all bits in the MII Auto-Neg Advertisement Register
* except for ASM_DIR and PAUSE and shift. This value
* will be used later to see if we need to restart Auto-Negotiation.
*/
autoneg_fc_setting = ((mii_autoneg_adv_reg & 0x0C00) >> 10);
/* Perform some bounds checking on the shared->autoneg_advertised
* parameter. If this variable is zero, then set it to the default.
*/
shared->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
/* If autoneg_advertised is zero, we assume it was not defaulted
* by the calling code so we set to advertise full capability.
*/
if(shared->autoneg_advertised == 0)
shared->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
/* We could be in the situation where Auto-Neg has already completed
* and the user has not indicated any overrides. In this case we
* simply need to call e1000_get_speed_and_duplex to obtain the Auto-
* Negotiated speed and duplex, then return.
*/
if(!force_autoneg_restart && shared->autoneg &&
(shared->autoneg_advertised == autoneg_hw_setting) &&
(shared->fc == autoneg_fc_setting)) {
DEBUGOUT("No overrides - Reading MII Status Reg..\n");
/* Read the MII Status Register. We read this twice because
* certain bits are "sticky" and need to be read twice.
*/
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
DEBUGOUT1("MII Status Reg contents = %x\n", mii_status_reg);
/* Do we have link now? (if so, auto-neg has completed) */
if(mii_status_reg & MII_SR_LINK_STATUS) {
data = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_STATUS);
DEBUGOUT1("M88E1000 Phy Specific Status Reg contents = %x\n", data);
/* We have link, so we need to finish the config process:
* 1) Set up the MAC to the current PHY speed/duplex
* if we are on 82543. If we
* are on newer silicon, we only need to configure
* collision distance in the Transmit Control Register.
* 2) Set up flow control on the MAC to that established
* with the link partner.
*/
if(shared->mac_type >= e1000_82544)
e1000_config_collision_dist(shared);
else
e1000_config_mac_to_phy(shared, data);
e1000_config_fc_after_link_up(shared);
return (TRUE);
}
}
/* Options:
* MDI/MDI-X = 0 (default)
* 0 - Auto for all speeds
* 1 - MDI mode
* 2 - MDI-X mode
* 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
*/
phy_specific_ctrl_reg = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_CTRL);
phy_specific_ctrl_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
switch (shared->mdix) {
case 1:
phy_specific_ctrl_reg |= M88E1000_PSCR_MDI_MANUAL_MODE;
break;
case 2:
phy_specific_ctrl_reg |= M88E1000_PSCR_MDIX_MANUAL_MODE;
break;
case 3:
phy_specific_ctrl_reg |= M88E1000_PSCR_AUTO_X_1000T;
break;
case 0:
default:
phy_specific_ctrl_reg |= M88E1000_PSCR_AUTO_X_MODE;
break;
}
e1000_write_phy_reg(shared, M88E1000_PHY_SPEC_CTRL, phy_specific_ctrl_reg);
/* Options:
* disable_polarity_correction = 0 (default)
* Automatic Correction for Reversed Cable Polarity
* 0 - Disabled
* 1 - Enabled
*/
phy_specific_ctrl_reg = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_CTRL);
phy_specific_ctrl_reg &= ~M88E1000_PSCR_POLARITY_REVERSAL;
if(shared->disable_polarity_correction == 1)
phy_specific_ctrl_reg |= M88E1000_PSCR_POLARITY_REVERSAL;
e1000_write_phy_reg(shared, M88E1000_PHY_SPEC_CTRL, phy_specific_ctrl_reg);
/* Options:
* autoneg = 1 (default)
* PHY will advertise value(s) parsed from
* autoneg_advertised and fc
* autoneg = 0
* PHY will be set to 10H, 10F, 100H, or 100F
* depending on value parsed from forced_speed_duplex.
*/
/* Is autoneg enabled? This is enabled by default or by software override.
* If so, call e1000_phy_setup_autoneg routine to parse the
* autoneg_advertised and fc options. If autoneg is NOT enabled, then the
* user should have provided a speed/duplex override. If so, then call
* e1000_phy_force_speed_duplex to parse and set this up. Otherwise,
* we are in an error situation and need to bail.
*/
if(shared->autoneg) {
DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
restart_autoneg = e1000_phy_setup_autoneg(shared);
} else {
DEBUGOUT("Forcing speed and duplex\n");
e1000_phy_force_speed_duplex(shared);
}
/* Based on information parsed above, check the flag to indicate
* whether we need to restart Auto-Neg.
*/
if(restart_autoneg) {
DEBUGOUT("Restarting Auto-Neg\n");
/* Read the MII Control Register. */
mii_ctrl_reg = e1000_read_phy_reg(shared, PHY_CTRL);
/* Restart auto-negotiation by setting the Auto Neg Enable bit and
* the Auto Neg Restart bit.
*/
mii_ctrl_reg |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
e1000_write_phy_reg(shared, PHY_CTRL, mii_ctrl_reg);
/* Does the user want to wait for Auto-Neg to complete here, or
* check at a later time (for example, callback routine).
*/
if(shared->wait_autoneg_complete)
e1000_wait_autoneg(shared);
} /* end if restart_autoneg */
/* Read the MII Status Register. */
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
DEBUGOUT1("Checking for link status - MII Status Reg contents = %x\n",
mii_status_reg);
/* Check link status. Wait up to 100 microseconds for link to
* become valid.
*/
for(i = 0; i < 10; i++) {
if(mii_status_reg & MII_SR_LINK_STATUS)
break;
usec_delay(10);
DEBUGOUT(". ");
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
}
if(mii_status_reg & MII_SR_LINK_STATUS) {
/* Yes, so configure MAC to PHY settings as well as flow control
* registers.
*/
data = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_STATUS);
DEBUGOUT1("M88E1000 Phy Specific Status Reg contents = %x\n", data);
/* We have link, so we need to finish the config process:
* 1) Set up the MAC to the current PHY speed/duplex
* if we are on 82543. If we
* are on newer silicon, we only need to configure
* collision distance in the Transmit Control Register.
* 2) Set up flow control on the MAC to that established with
* the link partner.
*/
if(shared->mac_type >= e1000_82544)
e1000_config_collision_dist(shared);
else
e1000_config_mac_to_phy(shared, data);
e1000_config_fc_after_link_up(shared);
DEBUGOUT("Valid link established!!!\n");
} else {
DEBUGOUT("Unable to establish link!!!\n");
}
return (TRUE);
}
/******************************************************************************
* Configures PHY autoneg and flow control advertisement settings
*
* shared - Struct containing variables accessed by shared code
******************************************************************************/
boolean_t
e1000_phy_setup_autoneg(struct e1000_shared_adapter *shared)
{
uint16_t mii_autoneg_adv_reg;
uint16_t mii_1000t_ctrl_reg;
DEBUGFUNC("e1000_phy_setup_autoneg");
/* Read the MII Auto-Neg Advertisement Register (Address 4). */
mii_autoneg_adv_reg = e1000_read_phy_reg(shared, PHY_AUTONEG_ADV);
/* Read the MII 1000Base-T Control Register (Address 9). */
mii_1000t_ctrl_reg = e1000_read_phy_reg(shared, PHY_1000T_CTRL);
/* Need to parse both autoneg_advertised and fc and set up
* the appropriate PHY registers. First we will parse for
* autoneg_advertised software override. Since we can advertise
* a plethora of combinations, we need to check each bit
* individually.
*/
/* First we clear all the 10/100 mb speed bits in the Auto-Neg
* Advertisement Register (Address 4) and the 1000 mb speed bits in
* the 1000Base-T Control Register (Address 9).
*/
mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
DEBUGOUT1("autoneg_advertised %x\n", shared->autoneg_advertised);
/* Do we want to advertise 10 Mb Half Duplex? */
if(shared->autoneg_advertised & ADVERTISE_10_HALF) {
DEBUGOUT("Advertise 10mb Half duplex\n");
mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
}
/* Do we want to advertise 10 Mb Full Duplex? */
if(shared->autoneg_advertised & ADVERTISE_10_FULL) {
DEBUGOUT("Advertise 10mb Full duplex\n");
mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
}
/* Do we want to advertise 100 Mb Half Duplex? */
if(shared->autoneg_advertised & ADVERTISE_100_HALF) {
DEBUGOUT("Advertise 100mb Half duplex\n");
mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
}
/* Do we want to advertise 100 Mb Full Duplex? */
if(shared->autoneg_advertised & ADVERTISE_100_FULL) {
DEBUGOUT("Advertise 100mb Full duplex\n");
mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
}
/* We do not allow the Phy to advertise 1000 Mb Half Duplex */
if(shared->autoneg_advertised & ADVERTISE_1000_HALF) {
DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
}
/* Do we want to advertise 1000 Mb Full Duplex? */
if(shared->autoneg_advertised & ADVERTISE_1000_FULL) {
DEBUGOUT("Advertise 1000mb Full duplex\n");
mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
}
/* Check for a software override of the flow control settings, and
* setup the PHY advertisement registers accordingly. If
* auto-negotiation is enabled, then software will have to set the
* "PAUSE" bits to the correct value in the Auto-Negotiation
* Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
*
* The possible values of the "fc" parameter are:
* 0: Flow control is completely disabled
* 1: Rx flow control is enabled (we can receive pause frames
* but not send pause frames).
* 2: Tx flow control is enabled (we can send pause frames
* but we do not support receiving pause frames).
* 3: Both Rx and TX flow control (symmetric) are enabled.
* other: No software override. The flow control configuration
* in the EEPROM is used.
*/
switch (shared->fc) {
case e1000_fc_none: /* 0 */
/* Flow control (RX & TX) is completely disabled by a
* software over-ride.
*/
mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
break;
case e1000_fc_rx_pause: /* 1 */
/* RX Flow control is enabled, and TX Flow control is
* disabled, by a software over-ride.
*/
/* Since there really isn't a way to advertise that we are
* capable of RX Pause ONLY, we will advertise that we
* support both symmetric and asymmetric RX PAUSE. Later
* (in e1000_config_fc_after_link_up) we will disable the
*shared's ability to send PAUSE frames.
*/
mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
break;
case e1000_fc_tx_pause: /* 2 */
/* TX Flow control is enabled, and RX Flow control is
* disabled, by a software over-ride.
*/
mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
break;
case e1000_fc_full: /* 3 */
/* Flow control (both RX and TX) is enabled by a software
* over-ride.
*/
mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
break;
default:
/* We should never get here. The value should be 0-3. */
DEBUGOUT("Flow control param set incorrectly\n");
ASSERT(0);
break;
}
/* Write the MII Auto-Neg Advertisement Register (Address 4). */
e1000_write_phy_reg(shared, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
/* Write the MII 1000Base-T Control Register (Address 9). */
e1000_write_phy_reg(shared, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
return (TRUE);
}
/******************************************************************************
* Sets MAC speed and duplex settings to reflect the those in the PHY
*
* shared - Struct containing variables accessed by shared code
* mii_reg - data to write to the MII control register
*
* The contents of the PHY register containing the needed information need to
* be passed in.
******************************************************************************/
void
e1000_config_mac_to_phy(struct e1000_shared_adapter *shared,
uint16_t mii_reg)
{
uint32_t ctrl_reg;
uint32_t tctl_reg;
uint32_t shift;
DEBUGFUNC("e1000_config_mac_to_phy");
/* We need to read the Transmit Control register to configure the
* collision distance.
* Note: This must be done for both Half or Full Duplex.
*/
tctl_reg = E1000_READ_REG(shared, TCTL);
DEBUGOUT1("tctl_reg = %x\n", tctl_reg);
/* Read the Device Control Register and set the bits to Force Speed
* and Duplex.
*/
ctrl_reg = E1000_READ_REG(shared, CTRL);
ctrl_reg |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
ctrl_reg &= ~(DEVICE_SPEED_MASK);
DEBUGOUT1("MII Register Data = %x\r\n", mii_reg);
/* Clear the ILOS bit. */
ctrl_reg &= ~E1000_CTRL_ILOS;
/* Set up duplex in the Device Control and Transmit Control
* registers depending on negotiated values.
*/
if(mii_reg & M88E1000_PSSR_DPLX) {
ctrl_reg |= E1000_CTRL_FD;
/* We are in Full Duplex mode. We have the same collision
* distance regardless of speed.
*/
tctl_reg &= ~E1000_TCTL_COLD;
shift = E1000_FDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
} else {
ctrl_reg &= ~E1000_CTRL_FD;
/* We are in Half Duplex mode. Our Half Duplex collision
* distance is different for Gigabit than for 10/100 so we will
* set accordingly.
*/
if((mii_reg & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {
/* 1000Mbs HDX */
tctl_reg &= ~E1000_TCTL_COLD;
shift = E1000_GB_HDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
tctl_reg |= E1000_TCTL_PBE; /* Enable Packet Bursting */
} else {
/* 10/100Mbs HDX */
tctl_reg &= ~E1000_TCTL_COLD;
shift = E1000_HDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
}
}
/* Set up speed in the Device Control register depending on
* negotiated values.
*/
if((mii_reg & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
ctrl_reg |= E1000_CTRL_SPD_1000;
else if((mii_reg & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
ctrl_reg |= E1000_CTRL_SPD_100;
else
ctrl_reg &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
/* Write the configured values back to the Transmit Control Reg. */
E1000_WRITE_REG(shared, TCTL, tctl_reg);
/* Write the configured values back to the Device Control Reg. */
E1000_WRITE_REG(shared, CTRL, ctrl_reg);
return;
}
/******************************************************************************
* Sets the collision distance in the Transmit Control register
*
* shared - Struct containing variables accessed by shared code
*
* Link should have been established previously. Reads the speed and duplex
* information from the Device Status register.
******************************************************************************/
void
e1000_config_collision_dist(struct e1000_shared_adapter *shared)
{
uint32_t tctl_reg;
uint16_t speed;
uint16_t duplex;
uint32_t shift;
DEBUGFUNC("e1000_config_collision_dist");
/* Get our current speed and duplex from the Device Status Register. */
e1000_get_speed_and_duplex(shared, &speed, &duplex);
/* We need to configure the Collision Distance for both Full or
* Half Duplex.
*/
tctl_reg = E1000_READ_REG(shared, TCTL);
DEBUGOUT1("tctl_reg = %x\n", tctl_reg);
/* mask the Collision Distance bits in the Transmit Control Reg. */
tctl_reg &= ~E1000_TCTL_COLD;
if(duplex == FULL_DUPLEX) {
/* We are in Full Duplex mode. Therefore, the collision distance
* is the same regardless of speed.
*/
shift = E1000_FDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
} else {
/* We are in Half Duplex mode. Half Duplex collision distance is
* different for Gigabit vs. 10/100, so we will set accordingly.
*/
if(speed == SPEED_1000) { /* 1000Mbs HDX */
shift = E1000_GB_HDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
tctl_reg |= E1000_TCTL_PBE; /* Enable Packet Bursting */
} else { /* 10/100Mbs HDX */
shift = E1000_HDX_COLLISION_DISTANCE;
shift <<= E1000_COLD_SHIFT;
tctl_reg |= shift;
}
}
/* Write the configured values back to the Transmit Control Reg. */
E1000_WRITE_REG(shared, TCTL, tctl_reg);
return;
}
/******************************************************************************
* Probes the expected PHY address for known PHY IDs
*
* shared - Struct containing variables accessed by shared code
******************************************************************************/
boolean_t
e1000_detect_gig_phy(struct e1000_shared_adapter *shared)
{
uint32_t phy_id_high;
uint16_t phy_id_low;
DEBUGFUNC("e1000_detect_gig_phy");
/* Read the PHY ID Registers to identify which PHY is onboard. */
shared->phy_addr = 1;
phy_id_high = e1000_read_phy_reg(shared, PHY_ID1);
usec_delay(2);
phy_id_low = e1000_read_phy_reg(shared, PHY_ID2);
shared->phy_id = (phy_id_low | (phy_id_high << 16)) & PHY_REVISION_MASK;
if(shared->phy_id == M88E1000_12_PHY_ID ||
shared->phy_id == M88E1000_14_PHY_ID ||
shared->phy_id == M88E1000_I_PHY_ID) {
DEBUGOUT2("phy_id 0x%x detected at address 0x%x\n",
shared->phy_id, shared->phy_addr);
return (TRUE);
} else {
DEBUGOUT("Could not auto-detect Phy!\n");
return (FALSE);
}
}
/******************************************************************************
* Resets the PHY's DSP
*
* shared - Struct containing variables accessed by shared code
******************************************************************************/
void
e1000_phy_reset_dsp(struct e1000_shared_adapter *shared)
{
e1000_write_phy_reg(shared, 29, 0x1d);
e1000_write_phy_reg(shared, 30, 0xc1);
e1000_write_phy_reg(shared, 30, 0x00);
return;
}
/******************************************************************************
* Blocks until autoneg completes or times out (~4.5 seconds)
*
* shared - Struct containing variables accessed by shared code
******************************************************************************/
boolean_t
e1000_wait_autoneg(struct e1000_shared_adapter *shared)
{
uint16_t i;
uint16_t mii_status_reg;
boolean_t autoneg_complete = FALSE;
DEBUGFUNC("e1000_wait_autoneg");
/* We will wait for autoneg to complete. */
DEBUGOUT("Waiting for Auto-Neg to complete.\n");
mii_status_reg = 0;
/* We will wait for autoneg to complete or 4.5 seconds to expire. */
for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
/* Read the MII Status Register and wait for Auto-Neg
* Complete bit to be set.
*/
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
autoneg_complete = TRUE;
break;
}
msec_delay(100);
}
return (autoneg_complete);
}
/******************************************************************************
* Get PHY information from various PHY registers
*
* shared - Struct containing variables accessed by shared code
* phy_status_info - PHY information structure
******************************************************************************/
boolean_t
e1000_phy_get_info(struct e1000_shared_adapter *shared,
struct e1000_phy_info *phy_status_info)
{
uint16_t phy_mii_status_reg;
uint16_t phy_specific_ctrl_reg;
uint16_t phy_specific_status_reg;
uint16_t phy_specific_ext_ctrl_reg;
uint16_t phy_1000t_stat_reg;
phy_status_info->cable_length = e1000_cable_length_undefined;
phy_status_info->extended_10bt_distance =
e1000_10bt_ext_dist_enable_undefined;
phy_status_info->cable_polarity = e1000_rev_polarity_undefined;
phy_status_info->polarity_correction = e1000_polarity_reversal_undefined;
phy_status_info->link_reset = e1000_down_no_idle_undefined;
phy_status_info->mdix_mode = e1000_auto_x_mode_undefined;
phy_status_info->local_rx = e1000_1000t_rx_status_undefined;
phy_status_info->remote_rx = e1000_1000t_rx_status_undefined;
/* PHY info only valid for copper media. */
if(shared == NULL || shared->media_type != e1000_media_type_copper)
return FALSE;
/* PHY info only valid for LINK UP. Read MII status reg
* back-to-back to get link status.
*/
phy_mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
phy_mii_status_reg = e1000_read_phy_reg(shared, PHY_STATUS);
if((phy_mii_status_reg & MII_SR_LINK_STATUS) != MII_SR_LINK_STATUS)
return FALSE;
/* Read various PHY registers to get the PHY info. */
phy_specific_ctrl_reg = e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_CTRL);
phy_specific_status_reg =
e1000_read_phy_reg(shared, M88E1000_PHY_SPEC_STATUS);
phy_specific_ext_ctrl_reg =
e1000_read_phy_reg(shared, M88E1000_EXT_PHY_SPEC_CTRL);
phy_1000t_stat_reg = e1000_read_phy_reg(shared, PHY_1000T_STATUS);
phy_status_info->cable_length =
((phy_specific_status_reg & M88E1000_PSSR_CABLE_LENGTH) >>
M88E1000_PSSR_CABLE_LENGTH_SHIFT);
phy_status_info->extended_10bt_distance =
(phy_specific_ctrl_reg & M88E1000_PSCR_10BT_EXT_DIST_ENABLE) >>
M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT;
phy_status_info->cable_polarity =
(phy_specific_status_reg & M88E1000_PSSR_REV_POLARITY) >>
M88E1000_PSSR_REV_POLARITY_SHIFT;
phy_status_info->polarity_correction =
(phy_specific_ctrl_reg & M88E1000_PSCR_POLARITY_REVERSAL) >>
M88E1000_PSCR_POLARITY_REVERSAL_SHIFT;
phy_status_info->link_reset =
(phy_specific_ext_ctrl_reg & M88E1000_EPSCR_DOWN_NO_IDLE) >>
M88E1000_EPSCR_DOWN_NO_IDLE_SHIFT;
phy_status_info->mdix_mode =
(phy_specific_status_reg & M88E1000_PSSR_MDIX) >>
M88E1000_PSSR_MDIX_SHIFT;
phy_status_info->local_rx =
(phy_1000t_stat_reg & SR_1000T_LOCAL_RX_STATUS) >>
SR_1000T_LOCAL_RX_STATUS_SHIFT;
phy_status_info->remote_rx =
(phy_1000t_stat_reg & SR_1000T_REMOTE_RX_STATUS) >>
SR_1000T_REMOTE_RX_STATUS_SHIFT;
return TRUE;
}
boolean_t
e1000_validate_mdi_setting(struct e1000_shared_adapter *shared)
{
if(!shared->autoneg && (shared->mdix == 0 || shared->mdix == 3)) {
shared->mdix = 1;
return FALSE;
}
return TRUE;
}
/*******************************************************************************
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
Intel(R) PRO/1000 Family of Adapters (e1000) (the "Software") being provided
by Intel Corporation. The following definitions apply to this license:
"Licensed Patents" means patent claims licensable by Intel Corporation which
are necessarily infringed by the use of sale of the Software alone or when
combined with the operating system referred to below.
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
All rights reserved.
The license is provided to Recipient and Recipient's Licensees under the
following terms.
Redistribution and use in source and binary forms of the Software, with or
without modification, are permitted provided that the following conditions
are met:
Redistributions of source code of the Software may retain the above
copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form of the Software may reproduce the above
copyright notice, this list of conditions and the following disclaimer in
the documentation and/or materials provided with the distribution.
Neither the name of Intel Corporation nor the names of its contributors
shall be used to endorse or promote products derived from this Software
without specific prior written permission.
Intel hereby grants Recipient and Licensees a non-exclusive, worldwide,
royalty-free patent license under Licensed Patents to make, use, sell, offer
to sell, import and otherwise transfer the Software, if any, in source code
and object code form. This license shall include changes to the Software
that are error corrections or other minor changes to the Software that do
not add functionality or features when the Software is incorporated in any
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR IT CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
ANY LOSS OF USE; DATA, OR PROFITS; OR BUSINESS INTERUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
/* e1000_phy.h
* Structures, enums, and macros for the PHY
*/
#ifndef _E1000_PHY_H_
#define _E1000_PHY_H_
#include "e1000_osdep.h"
/* PHY status info structure and supporting enums */
typedef enum {
e1000_cable_length_50 = 0,
e1000_cable_length_50_80,
e1000_cable_length_80_110,
e1000_cable_length_110_140,
e1000_cable_length_140,
e1000_cable_length_undefined = 0xFF
} e1000_cable_length;
typedef enum {
e1000_10bt_ext_dist_enable_normal = 0,
e1000_10bt_ext_dist_enable_lower,
e1000_10bt_ext_dist_enable_undefined = 0xFF
} e1000_10bt_ext_dist_enable;
typedef enum {
e1000_rev_polarity_normal = 0,
e1000_rev_polarity_reversed,
e1000_rev_polarity_undefined = 0xFF
} e1000_rev_polarity;
typedef enum {
e1000_polarity_reversal_enabled = 0,
e1000_polarity_reversal_disabled,
e1000_polarity_reversal_undefined = 0xFF
} e1000_polarity_reversal;
typedef enum {
e1000_down_no_idle_no_detect = 0,
e1000_down_no_idle_detect,
e1000_down_no_idle_undefined = 0xFF
} e1000_down_no_idle;
typedef enum {
e1000_auto_x_mode_manual_mdi = 0,
e1000_auto_x_mode_manual_mdix,
e1000_auto_x_mode_auto1,
e1000_auto_x_mode_auto2,
e1000_auto_x_mode_undefined = 0xFF
} e1000_auto_x_mode;
typedef enum {
e1000_1000t_rx_status_not_ok = 0,
e1000_1000t_rx_status_ok,
e1000_1000t_rx_status_undefined = 0xFF
} e1000_1000t_rx_status;
struct e1000_phy_info {
e1000_cable_length cable_length;
e1000_10bt_ext_dist_enable extended_10bt_distance;
e1000_rev_polarity cable_polarity;
e1000_polarity_reversal polarity_correction;
e1000_down_no_idle link_reset;
e1000_auto_x_mode mdix_mode;
e1000_1000t_rx_status local_rx;
e1000_1000t_rx_status remote_rx;
};
struct e1000_phy_stats {
uint32_t idle_errors;
uint32_t receive_errors;
};
/* Function Prototypes */
uint16_t e1000_read_phy_reg(struct e1000_shared_adapter *shared, uint32_t reg_addr);
void e1000_write_phy_reg(struct e1000_shared_adapter *shared, uint32_t reg_addr, uint16_t data);
void e1000_phy_hw_reset(struct e1000_shared_adapter *shared);
boolean_t e1000_phy_reset(struct e1000_shared_adapter *shared);
boolean_t e1000_phy_setup(struct e1000_shared_adapter *shared, uint32_t ctrl_reg);
boolean_t e1000_phy_setup_autoneg(struct e1000_shared_adapter *shared);
void e1000_config_mac_to_phy(struct e1000_shared_adapter *shared, uint16_t mii_reg);
void e1000_config_collision_dist(struct e1000_shared_adapter *shared);
boolean_t e1000_detect_gig_phy(struct e1000_shared_adapter *shared);
void e1000_phy_reset_dsp(struct e1000_shared_adapter *shared);
boolean_t e1000_wait_autoneg(struct e1000_shared_adapter *shared);
boolean_t e1000_phy_get_info(struct e1000_shared_adapter *shared, struct e1000_phy_info *phy_status_info);
boolean_t e1000_validate_mdi_setting(struct e1000_shared_adapter *shared);
/* Bit definitions for the Management Data IO (MDIO) and Management Data
* Clock (MDC) pins in the Device Control Register.
*/
#define E1000_CTRL_PHY_RESET_DIR E1000_CTRL_SWDPIO0
#define E1000_CTRL_PHY_RESET E1000_CTRL_SWDPIN0
#define E1000_CTRL_MDIO_DIR E1000_CTRL_SWDPIO2
#define E1000_CTRL_MDIO E1000_CTRL_SWDPIN2
#define E1000_CTRL_MDC_DIR E1000_CTRL_SWDPIO3
#define E1000_CTRL_MDC E1000_CTRL_SWDPIN3
#define E1000_CTRL_PHY_RESET_DIR4 E1000_CTRL_EXT_SDP4_DIR
#define E1000_CTRL_PHY_RESET4 E1000_CTRL_EXT_SDP4_DATA
/* PHY 1000 MII Register/Bit Definitions */
/* PHY Registers defined by IEEE */
#define PHY_CTRL 0x00 /* Control Register */
#define PHY_STATUS 0x01 /* Status Regiser */
#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */
#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */
#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */
#define PHY_LP_ABILITY 0x05 /* Link Partner Ability (Base Page) */
#define PHY_AUTONEG_EXP 0x06 /* Autoneg Expansion Reg */
#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */
#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */
#define PHY_1000T_CTRL 0x09 /* 1000Base-T Control Reg */
#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */
/* M88E1000 Specific Registers */
#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */
#define M88E1000_PHY_SPEC_STATUS 0x11 /* PHY Specific Status Register */
#define M88E1000_INT_ENABLE 0x12 /* Interrupt Enable Register */
#define M88E1000_INT_STATUS 0x13 /* Interrupt Status Register */
#define M88E1000_EXT_PHY_SPEC_CTRL 0x14 /* Extended PHY Specific Control */
#define M88E1000_RX_ERR_CNTR 0x15 /* Receive Error Counter */
#define MAX_PHY_REG_ADDRESS 0x1F /* 5 bit address bus (0-0x1F) */
/* PHY Control Register */
#define MII_CR_SPEED_SELECT_MSB 0x0040 /* bits 6,13: 10=1000, 01=100, 00=10 */
#define MII_CR_COLL_TEST_ENABLE 0x0080 /* Collision test enable */
#define MII_CR_FULL_DUPLEX 0x0100 /* FDX =1, half duplex =0 */
#define MII_CR_RESTART_AUTO_NEG 0x0200 /* Restart auto negotiation */
#define MII_CR_ISOLATE 0x0400 /* Isolate PHY from MII */
#define MII_CR_POWER_DOWN 0x0800 /* Power down */
#define MII_CR_AUTO_NEG_EN 0x1000 /* Auto Neg Enable */
#define MII_CR_SPEED_SELECT_LSB 0x2000 /* bits 6,13: 10=1000, 01=100, 00=10 */
#define MII_CR_LOOPBACK 0x4000 /* 0 = normal, 1 = loopback */
#define MII_CR_RESET 0x8000 /* 0 = normal, 1 = PHY reset */
/* PHY Status Register */
#define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabilities */
#define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */
#define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 = link */
#define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */
#define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */
#define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */
#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F */
#define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */
#define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */
#define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */
#define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */
#define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */
#define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */
#define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */
/* Autoneg Advertisement Register */
#define NWAY_AR_SELECTOR_FIELD 0x0001 /* indicates IEEE 802.3 CSMA/CD */
#define NWAY_AR_10T_HD_CAPS 0x0020 /* 10T Half Duplex Capable */
#define NWAY_AR_10T_FD_CAPS 0x0040 /* 10T Full Duplex Capable */
#define NWAY_AR_100TX_HD_CAPS 0x0080 /* 100TX Half Duplex Capable */
#define NWAY_AR_100TX_FD_CAPS 0x0100 /* 100TX Full Duplex Capable */
#define NWAY_AR_100T4_CAPS 0x0200 /* 100T4 Capable */
#define NWAY_AR_PAUSE 0x0400 /* Pause operation desired */
#define NWAY_AR_ASM_DIR 0x0800 /* Asymmetric Pause Direction bit */
#define NWAY_AR_REMOTE_FAULT 0x2000 /* Remote Fault detected */
#define NWAY_AR_NEXT_PAGE 0x8000 /* Next Page ability supported */
/* Link Partner Ability Register (Base Page) */
#define NWAY_LPAR_SELECTOR_FIELD 0x0000 /* LP protocol selector field */
#define NWAY_LPAR_10T_HD_CAPS 0x0020 /* LP is 10T Half Duplex Capable */
#define NWAY_LPAR_10T_FD_CAPS 0x0040 /* LP is 10T Full Duplex Capable */
#define NWAY_LPAR_100TX_HD_CAPS 0x0080 /* LP is 100TX Half Duplex Capable */
#define NWAY_LPAR_100TX_FD_CAPS 0x0100 /* LP is 100TX Full Duplex Capable */
#define NWAY_LPAR_100T4_CAPS 0x0200 /* LP is 100T4 Capable */
#define NWAY_LPAR_PAUSE 0x0400 /* LP Pause operation desired */
#define NWAY_LPAR_ASM_DIR 0x0800 /* LP Asymmetric Pause Direction bit */
#define NWAY_LPAR_REMOTE_FAULT 0x2000 /* LP has detected Remote Fault */
#define NWAY_LPAR_ACKNOWLEDGE 0x4000 /* LP has rx'd link code word */
#define NWAY_LPAR_NEXT_PAGE 0x8000 /* Next Page ability supported */
/* Autoneg Expansion Register */
#define NWAY_ER_LP_NWAY_CAPS 0x0001 /* LP has Auto Neg Capability */
#define NWAY_ER_PAGE_RXD 0x0002 /* LP is 10T Half Duplex Capable */
#define NWAY_ER_NEXT_PAGE_CAPS 0x0004 /* LP is 10T Full Duplex Capable */
#define NWAY_ER_LP_NEXT_PAGE_CAPS 0x0008 /* LP is 100TX Half Duplex Capable */
#define NWAY_ER_PAR_DETECT_FAULT 0x0100 /* LP is 100TX Full Duplex Capable */
/* Next Page TX Register */
#define NPTX_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
#define NPTX_TOGGLE 0x0800 /* Toggles between exchanges
* of different NP
*/
#define NPTX_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
* 0 = cannot comply with msg
*/
#define NPTX_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
#define NPTX_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
* 0 = sending last NP
*/
/* Link Partner Next Page Register */
#define LP_RNPR_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
#define LP_RNPR_TOGGLE 0x0800 /* Toggles between exchanges
* of different NP
*/
#define LP_RNPR_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
* 0 = cannot comply with msg
*/
#define LP_RNPR_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
#define LP_RNPR_ACKNOWLDGE 0x4000 /* 1 = ACK / 0 = NO ACK */
#define LP_RNPR_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
* 0 = sending last NP
*/
/* 1000BASE-T Control Register */
#define CR_1000T_ASYM_PAUSE 0x0080 /* Advertise asymmetric pause bit */
#define CR_1000T_HD_CAPS 0x0100 /* Advertise 1000T HD capability */
#define CR_1000T_FD_CAPS 0x0200 /* Advertise 1000T FD capability */
#define CR_1000T_REPEATER_DTE 0x0400 /* 1=Repeater/switch device port */
/* 0=DTE device */
#define CR_1000T_MS_VALUE 0x0800 /* 1=Configure PHY as Master */
/* 0=Configure PHY as Slave */
#define CR_1000T_MS_ENABLE 0x1000 /* 1=Master/Slave manual config value */
/* 0=Automatic Master/Slave config */
#define CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
#define CR_1000T_TEST_MODE_1 0x2000 /* Transmit Waveform test */
#define CR_1000T_TEST_MODE_2 0x4000 /* Master Transmit Jitter test */
#define CR_1000T_TEST_MODE_3 0x6000 /* Slave Transmit Jitter test */
#define CR_1000T_TEST_MODE_4 0x8000 /* Transmitter Distortion test */
/* 1000BASE-T Status Register */
#define SR_1000T_IDLE_ERROR_CNT 0x00FF /* Num idle errors since last read */
#define SR_1000T_ASYM_PAUSE_DIR 0x0100 /* LP asymmetric pause direction bit */
#define SR_1000T_LP_HD_CAPS 0x0400 /* LP is 1000T HD capable */
#define SR_1000T_LP_FD_CAPS 0x0800 /* LP is 1000T FD capable */
#define SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */
#define SR_1000T_LOCAL_RX_STATUS 0x2000 /* Local receiver OK */
#define SR_1000T_MS_CONFIG_RES 0x4000 /* 1=Local TX is Master, 0=Slave */
#define SR_1000T_MS_CONFIG_FAULT 0x8000 /* Master/Slave config fault */
#define SR_1000T_REMOTE_RX_STATUS_SHIFT 12
#define SR_1000T_LOCAL_RX_STATUS_SHIFT 13
/* Extended Status Register */
#define IEEE_ESR_1000T_HD_CAPS 0x1000 /* 1000T HD capable */
#define IEEE_ESR_1000T_FD_CAPS 0x2000 /* 1000T FD capable */
#define IEEE_ESR_1000X_HD_CAPS 0x4000 /* 1000X HD capable */
#define IEEE_ESR_1000X_FD_CAPS 0x8000 /* 1000X FD capable */
#define PHY_TX_POLARITY_MASK 0x0100 /* register 10h bit 8 (polarity bit) */
#define PHY_TX_NORMAL_POLARITY 0 /* register 10h bit 8 (normal polarity) */
#define AUTO_POLARITY_DISABLE 0x0010 /* register 11h bit 4 */
/* (0=enable, 1=disable) */
/* M88E1000 PHY Specific Control Register */
#define M88E1000_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */
#define M88E1000_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
#define M88E1000_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */
#define M88E1000_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low,
* 0=CLK125 toggling
*/
#define M88E1000_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5 */
/* Manual MDI configuration */
#define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */
#define M88E1000_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover,
* 100BASE-TX/10BASE-T:
* MDI Mode
*/
#define M88E1000_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled
* all speeds.
*/
#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE 0x0080
/* 1=Enable Extended 10BASE-T distance
* (Lower 10BASE-T RX Threshold)
* 0=Normal 10BASE-T RX Threshold */
#define M88E1000_PSCR_MII_5BIT_ENABLE 0x0100
/* 1=5-Bit interface in 100BASE-TX
* 0=MII interface in 100BASE-TX */
#define M88E1000_PSCR_SCRAMBLER_DISABLE 0x0200 /* 1=Scrambler disable */
#define M88E1000_PSCR_FORCE_LINK_GOOD 0x0400 /* 1=Force link good */
#define M88E1000_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */
#define M88E1000_PSCR_POLARITY_REVERSAL_SHIFT 1
#define M88E1000_PSCR_AUTO_X_MODE_SHIFT 5
#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
/* M88E1000 PHY Specific Status Register */
#define M88E1000_PSSR_JABBER 0x0001 /* 1=Jabber */
#define M88E1000_PSSR_REV_POLARITY 0x0002 /* 1=Polarity reversed */
#define M88E1000_PSSR_MDIX 0x0040 /* 1=MDIX; 0=MDI */
#define M88E1000_PSSR_CABLE_LENGTH 0x0380 /* 0=<50M;1=50-80M;2=80-110M;
* 3=110-140M;4=>140M */
#define M88E1000_PSSR_LINK 0x0400 /* 1=Link up, 0=Link down */
#define M88E1000_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
#define M88E1000_PSSR_PAGE_RCVD 0x1000 /* 1=Page received */
#define M88E1000_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
#define M88E1000_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
#define M88E1000_PSSR_10MBS 0x0000 /* 00=10Mbs */
#define M88E1000_PSSR_100MBS 0x4000 /* 01=100Mbs */
#define M88E1000_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
#define M88E1000_PSSR_REV_POLARITY_SHIFT 1
#define M88E1000_PSSR_MDIX_SHIFT 6
#define M88E1000_PSSR_CABLE_LENGTH_SHIFT 7
/* M88E1000 Extended PHY Specific Control Register */
#define M88E1000_EPSCR_FIBER_LOOPBACK 0x4000 /* 1=Fiber loopback */
#define M88E1000_EPSCR_DOWN_NO_IDLE 0x8000 /* 1=Lost lock detect enabled.
* Will assert lost lock and bring
* link down if idle not seen
* within 1ms in 1000BASE-T
*/
#define M88E1000_EPSCR_TX_CLK_2_5 0x0060 /* 2.5 MHz TX_CLK */
#define M88E1000_EPSCR_TX_CLK_25 0x0070 /* 25 MHz TX_CLK */
#define M88E1000_EPSCR_TX_CLK_0 0x0000 /* NO TX_CLK */
#define M88E1000_EPSCR_DOWN_NO_IDLE_SHIFT 15
/* Bit definitions for valid PHY IDs. */
#define M88E1000_12_PHY_ID 0x01410C50
#define M88E1000_14_PHY_ID 0x01410C40
#define M88E1000_I_PHY_ID 0x01410C30
/* Miscellaneous PHY bit definitions. */
#define PHY_PREAMBLE 0xFFFFFFFF
#define PHY_SOF 0x01
#define PHY_OP_READ 0x02
#define PHY_OP_WRITE 0x01
#define PHY_TURNAROUND 0x02
#define PHY_PREAMBLE_SIZE 32
#define MII_CR_SPEED_1000 0x0040
#define MII_CR_SPEED_100 0x2000
#define MII_CR_SPEED_10 0x0000
#define E1000_PHY_ADDRESS 0x01
#define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */
#define PHY_FORCE_TIME 20 /* 2.0 Seconds */
#define PHY_REVISION_MASK 0xFFFFFFF0
#define DEVICE_SPEED_MASK 0x00000300 /* Device Ctrl Reg Speed Mask */
#define REG4_SPEED_MASK 0x01E0
#define REG9_SPEED_MASK 0x0300
#define ADVERTISE_10_HALF 0x0001
#define ADVERTISE_10_FULL 0x0002
#define ADVERTISE_100_HALF 0x0004
#define ADVERTISE_100_FULL 0x0008
#define ADVERTISE_1000_HALF 0x0010
#define ADVERTISE_1000_FULL 0x0020
#define AUTONEG_ADVERTISE_SPEED_DEFAULT 0x002F /* Everything but 1000-Half */
#endif /* _E1000_PHY_H_ */
......@@ -2,9 +2,8 @@
This software program is available to you under a choice of one of two
licenses. You may choose to be licensed under either the GNU General Public
License (GPL) Version 2, June 1991, available at
http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the
text of which follows:
License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html,
or the Intel BSD + Patent License, the text of which follows:
Recipient has requested a license and Intel Corporation ("Intel") is willing
to grant a license for the software entitled Linux Base Driver for the
......@@ -18,7 +17,7 @@
"Recipient" means the party to whom Intel delivers this Software.
"Licensee" means Recipient and those third parties that receive a license to
any operating system available under the GNU Public License version 2.0 or
any operating system available under the GNU General Public License 2.0 or
later.
Copyright (c) 1999 - 2002 Intel Corporation.
......@@ -51,10 +50,10 @@
version of an operating system that has been distributed under the GNU
General Public License 2.0 or later. This patent license shall apply to the
combination of the Software and any operating system licensed under the GNU
Public License version 2.0 or later if, at the time Intel provides the
General Public License 2.0 or later if, at the time Intel provides the
Software to Recipient, such addition of the Software to the then publicly
available versions of such operating systems available under the GNU Public
License version 2.0 or later (whether in gold, beta or alpha form) causes
available versions of such operating systems available under the GNU General
Public License 2.0 or later (whether in gold, beta or alpha form) causes
such combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Software. NO
hardware per se is licensed hereunder.
......@@ -96,7 +95,9 @@
#include <linux/proc_fs.h>
#define ADAPTERS_PROC_DIR "PRO_LAN_Adapters"
#define TAG_MAX_LENGTH 36
#define TAG_MAX_LENGTH 32
#define LINE_MAX_LENGTH 80
#define FIELD_MAX_LENGTH LINE_MAX_LENGTH - TAG_MAX_LENGTH - 3
extern char e1000_driver_name[];
extern char e1000_driver_version[];
......@@ -110,7 +111,7 @@ extern char e1000_driver_version[];
struct proc_list {
struct list_head list; /* link list */
char tag[TAG_MAX_LENGTH]; /* attribute name */
char tag[TAG_MAX_LENGTH + 1]; /* attribute name */
void *data; /* attribute data */
size_t len; /* sizeof data */
char *(*func)(void *, size_t, char *); /* format data func */
......@@ -142,15 +143,20 @@ e1000_proc_info_read(char *page, char **start, off_t off,
struct list_head *proc_list_head = data, *curr;
struct proc_list *elem;
char *p = page;
char buf[64];
char buf[FIELD_MAX_LENGTH + 1];
list_for_each(curr, proc_list_head) {
elem = list_entry(curr, struct proc_list, list);
if(strlen(elem->tag) == 0)
if (p - page + LINE_MAX_LENGTH >= PAGE_SIZE)
break;
if(!strlen(elem->tag))
p += sprintf(p, "\n");
else
p += sprintf(p, "%-32s %s\n", elem->tag,
p += sprintf(p, "%-*.*s %.*s\n",
TAG_MAX_LENGTH, TAG_MAX_LENGTH,
elem->tag, FIELD_MAX_LENGTH,
elem->func(elem->data, elem->len, buf));
}
......@@ -165,7 +171,8 @@ e1000_proc_single_read(char *page, char **start, off_t off,
{
struct proc_list *elem = data;
sprintf(page, "%s", elem->func(elem->data, elem->len, page));
sprintf(page, "%.*s", FIELD_MAX_LENGTH, elem->func(elem->data,
elem->len, page));
return e1000_proc_read(page, start, off, count, eof);
}
......@@ -179,8 +186,7 @@ e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
for(intel_proc_dir = proc_net->subdir; intel_proc_dir;
intel_proc_dir = intel_proc_dir->next) {
if((intel_proc_dir->namelen == strlen(ADAPTERS_PROC_DIR)) &&
(memcmp(intel_proc_dir->name,
ADAPTERS_PROC_DIR, strlen(ADAPTERS_PROC_DIR)) == 0))
!memcmp(intel_proc_dir->name, ADAPTERS_PROC_DIR, strlen(ADAPTERS_PROC_DIR)))
break;
}
......@@ -224,8 +230,6 @@ e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
if(!proc_dir)
remove_proc_entry(ADAPTERS_PROC_DIR, proc_net);
return;
}
......@@ -241,7 +245,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent,
elem = list_entry(curr, struct proc_list, list);
if(strlen(elem->tag) == 0)
if(!strlen(elem->tag))
continue;
if(!(proc_entry =
......@@ -256,8 +260,9 @@ e1000_proc_singles_create(struct proc_dir_entry *parent,
return 1;
}
static int __devinit
e1000_proc_dirs_create(char *name, struct list_head *proc_list_head)
static void __devinit
e1000_proc_dirs_create(void *data, char *name,
struct list_head *proc_list_head)
{
struct proc_dir_entry *intel_proc_dir, *proc_dir, *info_entry;
char info_name[strlen(name) + strlen(".info")];
......@@ -265,8 +270,7 @@ e1000_proc_dirs_create(char *name, struct list_head *proc_list_head)
for(intel_proc_dir = proc_net->subdir; intel_proc_dir;
intel_proc_dir = intel_proc_dir->next) {
if((intel_proc_dir->namelen == strlen(ADAPTERS_PROC_DIR)) &&
(memcmp(intel_proc_dir->name,
ADAPTERS_PROC_DIR, strlen(ADAPTERS_PROC_DIR)) == 0))
!memcmp(intel_proc_dir->name, ADAPTERS_PROC_DIR, strlen(ADAPTERS_PROC_DIR)))
break;
}
......@@ -274,28 +278,26 @@ e1000_proc_dirs_create(char *name, struct list_head *proc_list_head)
if(!(intel_proc_dir =
create_proc_entry(ADAPTERS_PROC_DIR,
S_IFDIR, proc_net)))
return 0;
return;
if(!(proc_dir =
create_proc_entry(name, S_IFDIR, intel_proc_dir)))
return 0;
return;
SET_MODULE_OWNER(proc_dir);
if(!e1000_proc_singles_create(proc_dir, proc_list_head))
return 0;
return;
strcpy(info_name, name);
strcat(info_name, ".info");
if(!(info_entry =
create_proc_entry(info_name, S_IFREG, intel_proc_dir)))
return 0;
return;
SET_MODULE_OWNER(info_entry);
info_entry->read_proc = e1000_proc_info_read;
info_entry->data = proc_list_head;
return 1;
}
static void __devinit
......@@ -315,8 +317,6 @@ e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
new->func = func;
list_add_tail(&new->list, proc_list_head);
return;
}
static void __devexit
......@@ -329,8 +329,6 @@ e1000_proc_list_free(struct list_head *proc_list_head)
list_del(&elem->list);
kfree(elem);
}
return;
}
/*
......@@ -491,7 +489,7 @@ e1000_proc_media_type(void *data, size_t len, char *buf)
{
struct e1000_adapter *adapter = data;
sprintf(buf,
adapter->shared.media_type == e1000_media_type_copper ?
adapter->hw.media_type == e1000_media_type_copper ?
"Copper" : "Fiber");
return buf;
}
......@@ -547,18 +545,6 @@ e1000_proc_polarity_correction(void *data, size_t len, char *buf)
sprintf(buf,
correction == e1000_polarity_reversal_enabled ? "Disabled" :
correction == e1000_polarity_reversal_disabled ? "Enabled" :
"Undefined");
return buf;
}
static char *
e1000_proc_link_reset_enabled(void *data, size_t len, char *buf)
{
struct e1000_adapter *adapter = data;
e1000_down_no_idle link_reset = adapter->phy_info.link_reset;
sprintf(buf,
link_reset == e1000_down_no_idle_no_detect ? "Disabled" :
link_reset == e1000_down_no_idle_detect ? "Enabled" :
"Unknown");
return buf;
}
......@@ -568,7 +554,10 @@ e1000_proc_mdi_x_enabled(void *data, size_t len, char *buf)
{
struct e1000_adapter *adapter = data;
e1000_auto_x_mode mdix_mode = adapter->phy_info.mdix_mode;
sprintf(buf, mdix_mode == 0 ? "MDI" : "MDI-X");
sprintf(buf,
mdix_mode == e1000_auto_x_mode_manual_mdi ? "MDI" :
mdix_mode == e1000_auto_x_mode_manual_mdix ? "MDI-X" :
"Unknown");
return buf;
}
......@@ -601,7 +590,7 @@ e1000_proc_rx_status(void *data, size_t len, char *buf)
static void __devinit
e1000_proc_list_setup(struct e1000_adapter *adapter)
{
struct e1000_shared_adapter *shared = &adapter->shared;
struct e1000_hw *hw = &adapter->hw;
struct list_head *proc_list_head = &adapter->proc_list_head;
INIT_LIST_HEAD(proc_list_head);
......@@ -610,21 +599,21 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
LIST_ADD_F("Part_Number", &adapter->part_num, e1000_proc_part_number);
LIST_ADD_S("Driver_Name", e1000_driver_name);
LIST_ADD_S("Driver_Version", e1000_driver_version);
LIST_ADD_H("PCI_Vendor", &shared->vendor_id);
LIST_ADD_H("PCI_Device_ID", &shared->device_id);
LIST_ADD_H("PCI_Subsystem_Vendor", &shared->subsystem_vendor_id);
LIST_ADD_H("PCI_Subsystem_ID", &shared->subsystem_id);
LIST_ADD_H("PCI_Revision_ID", &shared->revision_id);
LIST_ADD_H("PCI_Vendor", &hw->vendor_id);
LIST_ADD_H("PCI_Device_ID", &hw->device_id);
LIST_ADD_H("PCI_Subsystem_Vendor", &hw->subsystem_vendor_id);
LIST_ADD_H("PCI_Subsystem_ID", &hw->subsystem_id);
LIST_ADD_H("PCI_Revision_ID", &hw->revision_id);
LIST_ADD_U("PCI_Bus", &adapter->pdev->bus->number);
LIST_ADD_F("PCI_Slot", adapter, e1000_proc_slot);
if(adapter->shared.mac_type >= e1000_82543) {
if(adapter->hw.mac_type >= e1000_82543) {
LIST_ADD_F("PCI_Bus_Type",
&shared->bus_type, e1000_proc_bus_type);
&hw->bus_type, e1000_proc_bus_type);
LIST_ADD_F("PCI_Bus_Speed",
&shared->bus_speed, e1000_proc_bus_speed);
&hw->bus_speed, e1000_proc_bus_speed);
LIST_ADD_F("PCI_Bus_Width",
&shared->bus_width, e1000_proc_bus_width);
&hw->bus_width, e1000_proc_bus_width);
}
LIST_ADD_U("IRQ", &adapter->pdev->irq);
......@@ -632,7 +621,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
LIST_ADD_F("Current_HWaddr",
adapter->netdev->dev_addr, e1000_proc_hwaddr);
LIST_ADD_F("Permanent_HWaddr",
adapter->shared.perm_mac_addr, e1000_proc_hwaddr);
adapter->hw.perm_mac_addr, e1000_proc_hwaddr);
LIST_ADD_BLANK();
......@@ -679,7 +668,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
LIST_ADD_U("Rx_Short_Length_Errors", &adapter->stats.ruc);
/* The 82542 does not have an alignment error count register */
if(adapter->shared.mac_type >= e1000_82543)
if(adapter->hw.mac_type >= e1000_82543)
LIST_ADD_U("Rx_Align_Errors", &adapter->stats.algnerrc);
LIST_ADD_U("Rx_Flow_Control_XON", &adapter->stats.xonrxc);
......@@ -693,7 +682,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
/* Cable diags */
LIST_ADD_F("PHY_Media_Type", adapter, e1000_proc_media_type);
if(adapter->shared.media_type == e1000_media_type_copper) {
if(adapter->hw.media_type == e1000_media_type_copper) {
LIST_ADD_F("PHY_Cable_Length",
adapter, e1000_proc_cable_length);
LIST_ADD_F("PHY_Extended_10Base_T_Distance",
......@@ -704,8 +693,6 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
adapter, e1000_proc_polarity_correction);
LIST_ADD_U("PHY_Idle_Errors",
&adapter->phy_stats.idle_errors);
LIST_ADD_F("PHY_Link_Reset_Enabled",
adapter, e1000_proc_link_reset_enabled);
LIST_ADD_U("PHY_Receive_Errors",
&adapter->phy_stats.receive_errors);
LIST_ADD_F("PHY_MDI_X_Enabled",
......@@ -718,7 +705,6 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
e1000_proc_rx_status);
}
return;
}
/*
......@@ -731,9 +717,9 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter)
{
e1000_proc_list_setup(adapter);
e1000_proc_dirs_create(adapter->netdev->name,&adapter->proc_list_head);
return;
e1000_proc_dirs_create(adapter,
adapter->netdev->name,
&adapter->proc_list_head);
}
/*
......@@ -747,8 +733,6 @@ e1000_proc_dev_free(struct e1000_adapter *adapter)
e1000_proc_dirs_free(adapter->netdev->name, &adapter->proc_list_head);
e1000_proc_list_free(&adapter->proc_list_head);
return;
}
#else /* CONFIG_PROC_FS */
......
......@@ -1795,6 +1795,7 @@ speedo_rx(struct net_device *dev)
}
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
dev->last_rx = jiffies;
sp->stats.rx_packets++;
sp->stats.rx_bytes += pkt_len;
}
......
......@@ -60,11 +60,14 @@
LK1.1.12:
* fix power-up sequence
LK1.1.13:
* revert version 1.1.12, power-up sequence "fix"
*/
#define DRV_NAME "epic100"
#define DRV_VERSION "1.11+LK1.1.12"
#define DRV_RELDATE "Jan 18, 2002"
#define DRV_VERSION "1.11+LK1.1.13"
#define DRV_RELDATE "Mar 20, 2002"
/* The user-configurable values.
......@@ -678,8 +681,9 @@ static int epic_open(struct net_device *dev)
required by the details of which bits are reset and the transceiver
wiring on the Ositech CardBus card.
*/
outl(0x12, ioaddr + MIICfg);
#if 0
outl(dev->if_port == 1 ? 0x13 : 0x12, ioaddr + MIICfg);
#endif
if (ep->chip_flags & MII_PWRDWN)
outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL);
......
......@@ -256,7 +256,7 @@ static void sp_bump(struct sixpack *sp, char cmd)
skb->mac.raw = skb->data;
skb->protocol = htons(ETH_P_AX25);
netif_rx(skb);
dev->last_rx = jiffies;
sp->dev->last_rx = jiffies;
sp->stats.rx_packets++;
}
......@@ -701,7 +701,6 @@ static struct tty_ldisc sp_ldisc = {
/* Initialize 6pack control device -- register 6pack line discipline */
static char msg_banner[] __initdata = KERN_INFO "AX.25: 6pack driver, " SIXPACK_VERSION " (dynamic channels, max=%d)\n";
static char msg_invparm[] __initdata = KERN_ERR "6pack: sixpack_maxdev parameter too large.\n";
static char msg_nomem[] __initdata = KERN_ERR "6pack: can't allocate sixpack_ctrls[] array! No 6pack available.\n";
static char msg_regfail[] __initdata = KERN_ERR "6pack: can't register line discipline (err = %d)\n";
......
......@@ -1121,6 +1121,7 @@ static void rx_bh(void *arg) {
skb->protocol = ntohs(ETH_P_AX25);
skb->mac.raw = skb->data;
netif_rx(skb);
priv->dev->last_rx = jiffies;
priv->stats.rx_packets++;
priv->stats.rx_bytes += cb;
}
......
......@@ -345,7 +345,7 @@ static void ax_bump(struct ax_disp *ax)
skb->mac.raw = skb->data;
skb->protocol = htons(ETH_P_AX25);
netif_rx(skb);
dev->last_rx = jiffies;
tmp_ax->dev->last_rx = jiffies;
tmp_ax->rx_packets++;
}
......
......@@ -1661,7 +1661,7 @@ static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
skb->pkt_type = PACKET_HOST;
netif_rx(skb);
dev->last_rx = jiffies;
scc->dev->last_rx = jiffies;
return;
}
......
......@@ -597,6 +597,7 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
sa1100_irda_rx_alloc(si);
netif_rx(skb);
dev->last_rx = jiffies;
} else {
/*
* Remap the buffer.
......
......@@ -383,7 +383,7 @@ int __init lance_probe(struct net_device *dev)
return 0;
}
}
release_resource(r);
release_region(ioaddr, LANCE_TOTAL_SIZE);
}
}
return -ENODEV;
......
......@@ -511,7 +511,6 @@ pcnet32_probe1(unsigned long ioaddr, unsigned int irq_line, int shared,
struct pci_dev *pdev)
{
struct pcnet32_private *lp;
struct resource *res;
dma_addr_t lp_dma_addr;
int i, media;
int fdx, mii, fset, dxsuflo, ltint;
......@@ -689,13 +688,12 @@ pcnet32_probe1(unsigned long ioaddr, unsigned int irq_line, int shared,
}
dev->base_addr = ioaddr;
res = request_region(ioaddr, PCNET32_TOTAL_SIZE, chipname);
if (!res)
if (request_region(ioaddr, PCNET32_TOTAL_SIZE, chipname) == NULL)
return -EBUSY;
/* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */
if ((lp = pci_alloc_consistent(pdev, sizeof(*lp), &lp_dma_addr)) == NULL) {
release_resource(res);
release_region(ioaddr, PCNET32_TOTAL_SIZE);
return -ENOMEM;
}
......@@ -727,7 +725,7 @@ pcnet32_probe1(unsigned long ioaddr, unsigned int irq_line, int shared,
if (!a) {
printk(KERN_ERR PFX "No access methods\n");
pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
release_resource(res);
release_region(ioaddr, PCNET32_TOTAL_SIZE);
return -ENODEV;
}
lp->a = *a;
......@@ -775,7 +773,7 @@ pcnet32_probe1(unsigned long ioaddr, unsigned int irq_line, int shared,
else {
printk(", failed to detect IRQ line.\n");
pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
release_resource(res);
release_region(ioaddr, PCNET32_TOTAL_SIZE);
return -ENODEV;
}
}
......
......@@ -2080,6 +2080,7 @@ static void deliver_packet(struct strip *strip_info, STRIP_Header *header, __u16
#ifdef EXT_COUNTERS
strip_info->rx_bytes += packetlen;
#endif
skb->dev->last_rx = jiffies;
netif_rx(skb);
}
}
......
......@@ -154,12 +154,10 @@ static int LOCOMX_open(struct net_device *dev)
return -ENODEV;
}
if (check_region(dev->base_addr, hw->io_extent)) {
if (!request_region(dev->base_addr, hw->io_extent, dev->name)) {
return -EAGAIN;
}
request_region(dev->base_addr, hw->io_extent, dev->name);
hw->board.chanA.ctrlio=dev->base_addr + 5;
hw->board.chanA.dataio=dev->base_addr + 7;
......
......@@ -566,8 +566,6 @@ static int MIXCOM_open(struct net_device *dev)
return 0;
err_restore_flags:
restore_flags(flags);
err_release_region:
release_region(dev->base_addr, MIXCOM_IO_EXTENT);
err_ret:
......
......@@ -517,6 +517,7 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv, int cur,
skb->len = pkt_len;
if (netif_running(dev))
skb->protocol = htons(ETH_P_HDLC);
skb->dev->last_rx = jiffies;
netif_rx(skb);
try_get_rx_skb(dpriv, cur, dev);
} else {
......
......@@ -291,6 +291,7 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u8 rxin)
#endif
port->hdlc.stats.rx_packets++;
port->hdlc.stats.rx_bytes += skb->len;
skb->dev->last_rx = jiffies;
skb->mac.raw = skb->data;
skb->dev = hdlc_to_dev(&port->hdlc);
skb->protocol = htons(ETH_P_HDLC);
......
......@@ -97,7 +97,7 @@ int __init wd_probe(struct net_device *dev)
return -EBUSY;
i = wd_probe1(dev, base_addr);
if (i != 0)
release_resource(r);
release_region(base_addr, WD_IO_EXTENT);
else
r->name = dev->name;
return i;
......@@ -114,7 +114,7 @@ int __init wd_probe(struct net_device *dev)
r->name = dev->name;
return 0;
}
release_resource(r);
release_region(ioaddr, WD_IO_EXTENT);
}
return -ENODEV;
......
......@@ -267,21 +267,28 @@ static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev)
pci_set_drvdata(pdev, NULL);
}
static struct pci_device_id orinoco_plx_pci_id_table[] __devinitdata = {
{0x1638, 0x1100, PCI_ANY_ID, PCI_ANY_ID,},
{0x1385, 0x4100, PCI_ANY_ID, PCI_ANY_ID,}, /* Netgear MA301 */
#if 0
{0x15e8, 0x0130, PCI_ANY_ID, PCI_ANY_ID,}, /* Correga */
#endif
{0x1638, 0x1100, PCI_ANY_ID, PCI_ANY_ID,}, /* SMC EZConnect SMC2602W,
Eumitcom PCI WL11000,
Addtron AWA-100*/
{0x16ab, 0x1100, PCI_ANY_ID, PCI_ANY_ID,}, /* Global Sun Tech GL24110P */
{0x16ab, 0x1101, PCI_ANY_ID, PCI_ANY_ID,}, /* Reported working, but unknown */
{0x16ab, 0x1102, PCI_ANY_ID, PCI_ANY_ID,}, /* Linksys WDT11 */
{0x16ec, 0x3685, PCI_ANY_ID, PCI_ANY_ID,}, /* USR 2415 */
{0xec80, 0xec00, PCI_ANY_ID, PCI_ANY_ID,}, /* Belkin F5D6000 */
{0,},
};
MODULE_DEVICE_TABLE(pci, orinoco_plx_pci_id_table);
static struct pci_driver orinoco_plx_driver = {
name:"orinoco_plx",
id_table:orinoco_plx_pci_id_table,
probe:orinoco_plx_init_one,
remove:__devexit_p(orinoco_plx_remove_one),
suspend:0,
resume:0
name: "orinoco_plx",
id_table: orinoco_plx_pci_id_table,
probe: orinoco_plx_init_one,
remove: __devexit_p(orinoco_plx_remove_one),
};
static int __init orinoco_plx_init(void)
......
......@@ -36,7 +36,8 @@ struct ethtool_drvinfo {
char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
/* For PCI devices, use pci_dev->slot_name. */
char reserved1[32];
char reserved2[24];
char reserved2[20];
u32 testinfo_len;
u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
};
......@@ -210,6 +211,34 @@ struct ethtool_pauseparam {
u32 tx_pause;
};
#define ETH_GSTRING_LEN 32
enum ethtool_stringset {
ETH_SS_TEST = 0,
ETH_SS_STATS,
};
/* for passing string sets for data tagging */
struct ethtool_gstrings {
u32 cmd; /* ETHTOOL_GSTRINGS */
u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
u32 len; /* number of strings in the string set */
u8 data[0];
};
enum ethtool_test_flags {
ETH_TEST_FL_OFFLINE = (1 << 0), /* online / offline */
ETH_TEST_FL_FAILED = (1 << 1), /* test passed / failed */
};
/* for requesting NIC test and getting results*/
struct ethtool_test {
u32 cmd; /* ETHTOOL_TEST */
u32 flags; /* ETH_TEST_FL_xxx */
u32 reserved;
u32 len; /* result length, in number of u64 elements */
u64 data[0];
};
/* CMDs currently supported */
#define ETHTOOL_GSET 0x00000001 /* Get settings. */
#define ETHTOOL_SSET 0x00000002 /* Set settings, privileged. */
......@@ -222,13 +251,13 @@ struct ethtool_pauseparam {
#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation, priv. */
#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */
#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data */
#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data, priv. */
#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
#define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config */
#define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config, priv. */
#define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters */
#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */
#define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters */
#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters, priv. */
#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
......@@ -236,7 +265,9 @@ struct ethtool_pauseparam {
#define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
* (ethtool_value) */
#define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
* (ethtool_value) */
* (ethtool_value), priv. */
#define ETHTOOL_TEST 0x0000001a /* execute NIC self-test, priv. */
#define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
......
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