MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver");
-static int num_params;
-module_param_array(link, int, num_params, 0);
-module_param_array(trace, int, num_params, 0);
-module_param_array(tx_coal_tick, int, num_params, 0);
-module_param_array(max_tx_desc, int, num_params, 0);
-module_param_array(rx_coal_tick, int, num_params, 0);
-module_param_array(max_rx_desc, int, num_params, 0);
-module_param_array(tx_ratio, int, num_params, 0);
+module_param_array(link, int, NULL, 0);
+module_param_array(trace, int, NULL, 0);
+module_param_array(tx_coal_tick, int, NULL, 0);
+module_param_array(max_tx_desc, int, NULL, 0);
+module_param_array(rx_coal_tick, int, NULL, 0);
+module_param_array(max_rx_desc, int, NULL, 0);
+module_param_array(tx_ratio, int, NULL, 0);
MODULE_PARM_DESC(link, "AceNIC/3C985/NetGear link state");
MODULE_PARM_DESC(trace, "AceNIC/3C985/NetGear firmware trace level");
MODULE_PARM_DESC(tx_coal_tick, "AceNIC/3C985/GA620 max clock ticks to wait from first tx descriptor arrives");
MODULE_PARM_DESC(tx_ratio, "AceNIC/3C985/GA620 ratio of NIC memory used for TX/RX descriptors (range 0-63)");
-static char version[] __initdata =
+static char version[] __devinitdata =
"acenic.c: v0.92 08/05/2002 Jes Sorensen, linux-acenic@SunSITE.dk\n"
" http://home.cern.ch/~jes/gige/acenic.html\n";
.get_drvinfo = ace_get_drvinfo,
};
+static void ace_watchdog(struct net_device *dev);
+
static int __devinit acenic_probe_one(struct pci_dev *pdev,
const struct pci_device_id *id)
{
dev->vlan_rx_kill_vid = ace_vlan_rx_kill_vid;
#endif
if (1) {
- static void ace_watchdog(struct net_device *dev);
dev->tx_timeout = &ace_watchdog;
dev->watchdog_timeo = 5*HZ;
}
* addresses but who gives a damn.
*/
dev->base_addr = pci_resource_start(pdev, 0);
- ap->regs = (struct ace_regs *)ioremap(dev->base_addr, 0x4000);
+ ap->regs = ioremap(dev->base_addr, 0x4000);
if (!ap->regs) {
printk(KERN_ERR "%s: Unable to map I/O register, "
"AceNIC %i will be disabled.\n",
{
struct net_device *dev = pci_get_drvdata(pdev);
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
short i;
unregister_netdev(dev);
/*
* Commands are considered to be slow.
*/
-static inline void ace_issue_cmd(struct ace_regs *regs, struct cmd *cmd)
+static inline void ace_issue_cmd(struct ace_regs __iomem *regs, struct cmd *cmd)
{
u32 idx;
}
-static int __init ace_init(struct net_device *dev)
+static int __devinit ace_init(struct net_device *dev)
{
struct ace_private *ap;
- struct ace_regs *regs;
+ struct ace_regs __iomem *regs;
struct ace_info *info = NULL;
struct pci_dev *pdev;
unsigned long myjif;
writel(TX_RING_BASE, ®s->WinBase);
if (ACE_IS_TIGON_I(ap)) {
- ap->tx_ring = (struct tx_desc *)regs->Window;
- for (i = 0; i < (TIGON_I_TX_RING_ENTRIES *
- sizeof(struct tx_desc) / 4); i++) {
- writel(0, (unsigned long)ap->tx_ring + i * 4);
- }
+ ap->tx_ring = (struct tx_desc *) regs->Window;
+ for (i = 0; i < (TIGON_I_TX_RING_ENTRIES
+ * sizeof(struct tx_desc)) / sizeof(u32); i++)
+ writel(0, (void __iomem *)ap->tx_ring + i * 4);
set_aceaddr(&info->tx_ctrl.rngptr, TX_RING_BASE);
} else {
static void ace_set_rxtx_parms(struct net_device *dev, int jumbo)
{
- struct ace_private *ap;
- struct ace_regs *regs;
- int board_idx;
-
- ap = netdev_priv(dev);
- regs = ap->regs;
-
- board_idx = ap->board_idx;
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
+ int board_idx = ap->board_idx;
if (board_idx >= 0) {
if (!jumbo) {
{
struct net_device *dev = data;
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
/*
* We haven't received a stats update event for more than 2.5
static void ace_tasklet(unsigned long dev)
{
- struct ace_private *ap = ((struct net_device *)dev)->priv;
+ struct ace_private *ap = netdev_priv((struct net_device *)dev);
int cur_size;
cur_size = atomic_read(&ap->cur_rx_bufs);
*/
static void ace_load_std_rx_ring(struct ace_private *ap, int nr_bufs)
{
- struct ace_regs *regs;
+ struct ace_regs __iomem *regs = ap->regs;
short i, idx;
-
- regs = ap->regs;
+
prefetchw(&ap->cur_rx_bufs);
static void ace_load_mini_rx_ring(struct ace_private *ap, int nr_bufs)
{
- struct ace_regs *regs;
+ struct ace_regs __iomem *regs = ap->regs;
short i, idx;
- regs = ap->regs;
-
prefetchw(&ap->cur_mini_bufs);
idx = ap->rx_mini_skbprd;
*/
static void ace_load_jumbo_rx_ring(struct ace_private *ap, int nr_bufs)
{
- struct ace_regs *regs;
+ struct ace_regs __iomem *regs = ap->regs;
short i, idx;
- regs = ap->regs;
-
idx = ap->rx_jumbo_skbprd;
for (i = 0; i < nr_bufs; i++) {
* the 12.3.x Firmware - my Tigon I NICs seem to disagree!
*/
if (ACE_IS_TIGON_I(ap)) {
- struct ace_regs *regs = ap->regs;
- writel(idx, ®s->RxRetCsm);
+ writel(idx, &ap->regs->RxRetCsm);
}
ap->cur_rx = idx;
static irqreturn_t ace_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
{
- struct ace_private *ap;
- struct ace_regs *regs;
struct net_device *dev = (struct net_device *)dev_id;
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
u32 idx;
u32 txcsm, rxretcsm, rxretprd;
u32 evtcsm, evtprd;
- ap = netdev_priv(dev);
- regs = ap->regs;
-
/*
* In case of PCI shared interrupts or spurious interrupts,
* we want to make sure it is actually our interrupt before
static int ace_open(struct net_device *dev)
{
- struct ace_private *ap;
- struct ace_regs *regs;
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
struct cmd cmd;
- ap = netdev_priv(dev);
- regs = ap->regs;
-
if (!(ap->fw_running)) {
printk(KERN_WARNING "%s: Firmware not running!\n", dev->name);
return -EBUSY;
static int ace_close(struct net_device *dev)
{
- struct ace_private *ap;
- struct ace_regs *regs;
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
struct cmd cmd;
unsigned long flags;
short i;
*/
netif_stop_queue(dev);
- ap = netdev_priv(dev);
- regs = ap->regs;
-
+
if (ap->promisc) {
cmd.evt = C_SET_PROMISC_MODE;
cmd.code = C_C_PROMISC_DISABLE;
if (mapping) {
if (ACE_IS_TIGON_I(ap)) {
- writel(0, &ap->tx_ring[i].addr.addrhi);
- writel(0, &ap->tx_ring[i].addr.addrlo);
- writel(0, &ap->tx_ring[i].flagsize);
+ struct tx_desc __iomem *tx
+ = (struct tx_desc __iomem *) &ap->tx_ring[i];
+ writel(0, &tx->addr.addrhi);
+ writel(0, &tx->addr.addrlo);
+ writel(0, &tx->flagsize);
} else
memset(ap->tx_ring + i, 0,
sizeof(struct tx_desc));
#endif
if (ACE_IS_TIGON_I(ap)) {
- writel(addr >> 32, &desc->addr.addrhi);
- writel(addr & 0xffffffff, &desc->addr.addrlo);
- writel(flagsize, &desc->flagsize);
+ struct tx_desc __iomem *io = (struct tx_desc __iomem *) desc;
+ writel(addr >> 32, &io->addr.addrhi);
+ writel(addr & 0xffffffff, &io->addr.addrlo);
+ writel(flagsize, &io->flagsize);
#if ACENIC_DO_VLAN
- writel(vlan_tag, &desc->vlanres);
+ writel(vlan_tag, &io->vlanres);
#endif
} else {
desc->addr.addrhi = addr >> 32;
static int ace_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
struct tx_desc *desc;
u32 idx, flagsize;
+ unsigned long maxjiff = jiffies + 3*HZ;
restart:
idx = ap->tx_prd;
if (tx_ring_full(ap, ap->tx_ret_csm, idx))
goto overflow;
-#if MAX_SKB_FRAGS
- if (!skb_shinfo(skb)->nr_frags)
-#endif
- {
+ if (!skb_shinfo(skb)->nr_frags) {
dma_addr_t mapping;
u32 vlan_tag = 0;
flagsize |= BD_FLG_COAL_NOW;
ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
- }
-#if MAX_SKB_FRAGS
- else {
+ } else {
dma_addr_t mapping;
u32 vlan_tag = 0;
int i, len = 0;
ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
}
}
-#endif
wmb();
ap->tx_prd = idx;
}
dev->trans_start = jiffies;
- return 0;
+ return NETDEV_TX_OK;
overflow:
/*
* Alternative is to return with 1 not throttling queue. In this
* case loop becomes longer, no more useful effects.
*/
- barrier();
- goto restart;
+ if (time_before(jiffies, maxjiff)) {
+ barrier();
+ cpu_relax();
+ goto restart;
+ }
+
+ /* The ring is stuck full. */
+ printk(KERN_WARNING "%s: Transmit ring stuck full\n", dev->name);
+ return NETDEV_TX_BUSY;
}
static int ace_change_mtu(struct net_device *dev, int new_mtu)
{
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
if (new_mtu > ACE_JUMBO_MTU)
return -EINVAL;
static int ace_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
{
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
u32 link;
memset(ecmd, 0, sizeof(struct ethtool_cmd));
static int ace_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
{
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
u32 link, speed;
link = readl(®s->GigLnkState);
*/
static int ace_set_mac_addr(struct net_device *dev, void *p)
{
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
struct sockaddr *addr=p;
- struct ace_regs *regs;
u8 *da;
struct cmd cmd;
da = (u8 *)dev->dev_addr;
- regs = ((struct ace_private *)netdev_priv(dev))->regs;
writel(da[0] << 8 | da[1], ®s->MacAddrHi);
writel((da[2] << 24) | (da[3] << 16) | (da[4] << 8) | da[5],
®s->MacAddrLo);
static void ace_set_multicast_list(struct net_device *dev)
{
struct ace_private *ap = netdev_priv(dev);
- struct ace_regs *regs = ap->regs;
+ struct ace_regs __iomem *regs = ap->regs;
struct cmd cmd;
if ((dev->flags & IFF_ALLMULTI) && !(ap->mcast_all)) {
static struct net_device_stats *ace_get_stats(struct net_device *dev)
{
struct ace_private *ap = netdev_priv(dev);
- struct ace_mac_stats *mac_stats =
- (struct ace_mac_stats *)ap->regs->Stats;
+ struct ace_mac_stats __iomem *mac_stats =
+ (struct ace_mac_stats __iomem *)ap->regs->Stats;
ap->stats.rx_missed_errors = readl(&mac_stats->drop_space);
ap->stats.multicast = readl(&mac_stats->kept_mc);
}
-static void __init ace_copy(struct ace_regs *regs, void *src,
+static void __devinit ace_copy(struct ace_regs __iomem *regs, void *src,
u32 dest, int size)
{
- unsigned long tdest;
+ void __iomem *tdest;
u32 *wsrc;
short tsize, i;
while (size > 0) {
tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
min_t(u32, size, ACE_WINDOW_SIZE));
- tdest = (unsigned long)®s->Window +
+ tdest = (void __iomem *) ®s->Window +
(dest & (ACE_WINDOW_SIZE - 1));
writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase);
/*
}
-static void __init ace_clear(struct ace_regs *regs, u32 dest, int size)
+static void __devinit ace_clear(struct ace_regs __iomem *regs, u32 dest, int size)
{
- unsigned long tdest;
+ void __iomem *tdest;
short tsize = 0, i;
if (size <= 0)
while (size > 0) {
tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
min_t(u32, size, ACE_WINDOW_SIZE));
- tdest = (unsigned long)®s->Window +
+ tdest = (void __iomem *) ®s->Window +
(dest & (ACE_WINDOW_SIZE - 1));
writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase);
* This operation requires the NIC to be halted and is performed with
* interrupts disabled and with the spinlock hold.
*/
-int __init ace_load_firmware(struct net_device *dev)
+int __devinit ace_load_firmware(struct net_device *dev)
{
- struct ace_private *ap;
- struct ace_regs *regs;
-
- ap = netdev_priv(dev);
- regs = ap->regs;
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
if (!(readl(®s->CpuCtrl) & CPU_HALTED)) {
printk(KERN_ERR "%s: trying to download firmware while the "
* Thanks to Stevarino Webinski for helping tracking down the bugs in the
* code i2c readout code by beta testing all my hacks.
*/
-static void __init eeprom_start(struct ace_regs *regs)
+static void __devinit eeprom_start(struct ace_regs __iomem *regs)
{
u32 local;
}
-static void __init eeprom_prep(struct ace_regs *regs, u8 magic)
+static void __devinit eeprom_prep(struct ace_regs __iomem *regs, u8 magic)
{
short i;
u32 local;
}
-static int __init eeprom_check_ack(struct ace_regs *regs)
+static int __devinit eeprom_check_ack(struct ace_regs __iomem *regs)
{
int state;
u32 local;
}
-static void __init eeprom_stop(struct ace_regs *regs)
+static void __devinit eeprom_stop(struct ace_regs __iomem *regs)
{
u32 local;
/*
* Read a whole byte from the EEPROM.
*/
-static int __init read_eeprom_byte(struct net_device *dev,
+static int __devinit read_eeprom_byte(struct net_device *dev,
unsigned long offset)
{
- struct ace_private *ap;
- struct ace_regs *regs;
+ struct ace_private *ap = netdev_priv(dev);
+ struct ace_regs __iomem *regs = ap->regs;
unsigned long flags;
u32 local;
int result = 0;
goto out;
}
- ap = netdev_priv(dev);
- regs = ap->regs;
-
/*
* Don't take interrupts on this CPU will bit banging
* the %#%#@$ I2C device