2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
drivers/net/tulip/interrupt.c
|
|
|
|
|
2006-09-08 20:15:34 +02:00
|
|
|
Maintained by Valerie Henson <val_henson@linux.intel.com>
|
2005-04-17 00:20:36 +02:00
|
|
|
Copyright 2000,2001 The Linux Kernel Team
|
|
|
|
Written/copyright 1994-2001 by Donald Becker.
|
|
|
|
|
|
|
|
This software may be used and distributed according to the terms
|
|
|
|
of the GNU General Public License, incorporated herein by reference.
|
|
|
|
|
|
|
|
Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
|
|
|
|
for more information on this driver, or visit the project
|
|
|
|
Web page at http://sourceforge.net/projects/tulip/
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include "tulip.h"
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
|
|
|
|
int tulip_rx_copybreak;
|
|
|
|
unsigned int tulip_max_interrupt_work;
|
|
|
|
|
|
|
|
#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
|
|
|
|
#define MIT_SIZE 15
|
|
|
|
#define MIT_TABLE 15 /* We use 0 or max */
|
|
|
|
|
|
|
|
static unsigned int mit_table[MIT_SIZE+1] =
|
|
|
|
{
|
|
|
|
/* CRS11 21143 hardware Mitigation Control Interrupt
|
|
|
|
We use only RX mitigation we other techniques for
|
|
|
|
TX intr. mitigation.
|
|
|
|
|
|
|
|
31 Cycle Size (timer control)
|
|
|
|
30:27 TX timer in 16 * Cycle size
|
|
|
|
26:24 TX No pkts before Int.
|
|
|
|
23:20 RX timer in Cycle size
|
|
|
|
19:17 RX No pkts before Int.
|
|
|
|
16 Continues Mode (CM)
|
|
|
|
*/
|
|
|
|
|
|
|
|
0x0, /* IM disabled */
|
|
|
|
0x80150000, /* RX time = 1, RX pkts = 2, CM = 1 */
|
|
|
|
0x80150000,
|
|
|
|
0x80270000,
|
|
|
|
0x80370000,
|
|
|
|
0x80490000,
|
|
|
|
0x80590000,
|
|
|
|
0x80690000,
|
|
|
|
0x807B0000,
|
|
|
|
0x808B0000,
|
|
|
|
0x809D0000,
|
|
|
|
0x80AD0000,
|
|
|
|
0x80BD0000,
|
|
|
|
0x80CF0000,
|
|
|
|
0x80DF0000,
|
|
|
|
// 0x80FF0000 /* RX time = 16, RX pkts = 7, CM = 1 */
|
|
|
|
0x80F10000 /* RX time = 16, RX pkts = 0, CM = 1 */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int tulip_refill_rx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct tulip_private *tp = netdev_priv(dev);
|
|
|
|
int entry;
|
|
|
|
int refilled = 0;
|
|
|
|
|
|
|
|
/* Refill the Rx ring buffers. */
|
|
|
|
for (; tp->cur_rx - tp->dirty_rx > 0; tp->dirty_rx++) {
|
|
|
|
entry = tp->dirty_rx % RX_RING_SIZE;
|
|
|
|
if (tp->rx_buffers[entry].skb == NULL) {
|
|
|
|
struct sk_buff *skb;
|
|
|
|
dma_addr_t mapping;
|
|
|
|
|
|
|
|
skb = tp->rx_buffers[entry].skb = dev_alloc_skb(PKT_BUF_SZ);
|
|
|
|
if (skb == NULL)
|
|
|
|
break;
|
|
|
|
|
2005-06-29 00:25:31 +02:00
|
|
|
mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
|
2005-04-17 00:20:36 +02:00
|
|
|
PCI_DMA_FROMDEVICE);
|
|
|
|
tp->rx_buffers[entry].mapping = mapping;
|
|
|
|
|
|
|
|
skb->dev = dev; /* Mark as being used by this device. */
|
|
|
|
tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping);
|
|
|
|
refilled++;
|
|
|
|
}
|
|
|
|
tp->rx_ring[entry].status = cpu_to_le32(DescOwned);
|
|
|
|
}
|
|
|
|
if(tp->chip_id == LC82C168) {
|
|
|
|
if(((ioread32(tp->base_addr + CSR5)>>17)&0x07) == 4) {
|
|
|
|
/* Rx stopped due to out of buffers,
|
|
|
|
* restart it
|
|
|
|
*/
|
|
|
|
iowrite32(0x01, tp->base_addr + CSR2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return refilled;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TULIP_NAPI
|
|
|
|
|
|
|
|
void oom_timer(unsigned long data)
|
|
|
|
{
|
|
|
|
struct net_device *dev = (struct net_device *)data;
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
struct tulip_private *tp = netdev_priv(dev);
|
|
|
|
netif_rx_schedule(dev, &tp->napi);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
int tulip_poll(struct napi_struct *napi, int budget)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
struct tulip_private *tp = container_of(napi, struct tulip_private, napi);
|
|
|
|
struct net_device *dev = tp->dev;
|
2005-04-17 00:20:36 +02:00
|
|
|
int entry = tp->cur_rx % RX_RING_SIZE;
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
int work_done = 0;
|
|
|
|
#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
|
2005-04-17 00:20:36 +02:00
|
|
|
int received = 0;
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
|
|
|
|
|
|
|
|
/* that one buffer is needed for mit activation; or might be a
|
|
|
|
bug in the ring buffer code; check later -- JHS*/
|
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
if (budget >=RX_RING_SIZE) budget--;
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (tulip_debug > 4)
|
|
|
|
printk(KERN_DEBUG " In tulip_rx(), entry %d %8.8x.\n", entry,
|
|
|
|
tp->rx_ring[entry].status);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (ioread32(tp->base_addr + CSR5) == 0xffffffff) {
|
|
|
|
printk(KERN_DEBUG " In tulip_poll(), hardware disappeared.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Acknowledge current RX interrupt sources. */
|
|
|
|
iowrite32((RxIntr | RxNoBuf), tp->base_addr + CSR5);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* If we own the next entry, it is a new packet. Send it up. */
|
|
|
|
while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) {
|
|
|
|
s32 status = le32_to_cpu(tp->rx_ring[entry].status);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (tp->dirty_rx + RX_RING_SIZE == tp->cur_rx)
|
|
|
|
break;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (tulip_debug > 5)
|
|
|
|
printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n",
|
|
|
|
dev->name, entry, status);
|
2008-01-07 09:23:04 +01:00
|
|
|
|
|
|
|
if (++work_done >= budget)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto not_done;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((status & 0x38008300) != 0x0300) {
|
|
|
|
if ((status & 0x38000300) != 0x0300) {
|
|
|
|
/* Ingore earlier buffers. */
|
|
|
|
if ((status & 0xffff) != 0x7fff) {
|
|
|
|
if (tulip_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: Oversized Ethernet frame "
|
|
|
|
"spanned multiple buffers, status %8.8x!\n",
|
|
|
|
dev->name, status);
|
|
|
|
tp->stats.rx_length_errors++;
|
|
|
|
}
|
|
|
|
} else if (status & RxDescFatalErr) {
|
|
|
|
/* There was a fatal error. */
|
|
|
|
if (tulip_debug > 2)
|
|
|
|
printk(KERN_DEBUG "%s: Receive error, Rx status %8.8x.\n",
|
|
|
|
dev->name, status);
|
|
|
|
tp->stats.rx_errors++; /* end of a packet.*/
|
|
|
|
if (status & 0x0890) tp->stats.rx_length_errors++;
|
|
|
|
if (status & 0x0004) tp->stats.rx_frame_errors++;
|
|
|
|
if (status & 0x0002) tp->stats.rx_crc_errors++;
|
|
|
|
if (status & 0x0001) tp->stats.rx_fifo_errors++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Omit the four octet CRC from the length. */
|
|
|
|
short pkt_len = ((status >> 16) & 0x7ff) - 4;
|
|
|
|
struct sk_buff *skb;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifndef final_version
|
|
|
|
if (pkt_len > 1518) {
|
|
|
|
printk(KERN_WARNING "%s: Bogus packet size of %d (%#x).\n",
|
|
|
|
dev->name, pkt_len, pkt_len);
|
|
|
|
pkt_len = 1518;
|
|
|
|
tp->stats.rx_length_errors++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* Check if the packet is long enough to accept without copying
|
|
|
|
to a minimally-sized skbuff. */
|
|
|
|
if (pkt_len < tulip_rx_copybreak
|
|
|
|
&& (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
|
|
|
|
skb_reserve(skb, 2); /* 16 byte align the IP header */
|
|
|
|
pci_dma_sync_single_for_cpu(tp->pdev,
|
|
|
|
tp->rx_buffers[entry].mapping,
|
|
|
|
pkt_len, PCI_DMA_FROMDEVICE);
|
|
|
|
#if ! defined(__alpha__)
|
2007-07-11 07:08:12 +02:00
|
|
|
skb_copy_to_linear_data(skb, tp->rx_buffers[entry].skb->data,
|
|
|
|
pkt_len);
|
2005-04-17 00:20:36 +02:00
|
|
|
skb_put(skb, pkt_len);
|
|
|
|
#else
|
|
|
|
memcpy(skb_put(skb, pkt_len),
|
2005-06-29 00:25:31 +02:00
|
|
|
tp->rx_buffers[entry].skb->data,
|
2005-04-17 00:20:36 +02:00
|
|
|
pkt_len);
|
|
|
|
#endif
|
|
|
|
pci_dma_sync_single_for_device(tp->pdev,
|
|
|
|
tp->rx_buffers[entry].mapping,
|
|
|
|
pkt_len, PCI_DMA_FROMDEVICE);
|
|
|
|
} else { /* Pass up the skb already on the Rx ring. */
|
|
|
|
char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
|
|
|
|
pkt_len);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifndef final_version
|
|
|
|
if (tp->rx_buffers[entry].mapping !=
|
|
|
|
le32_to_cpu(tp->rx_ring[entry].buffer1)) {
|
|
|
|
printk(KERN_ERR "%s: Internal fault: The skbuff addresses "
|
|
|
|
"do not match in tulip_rx: %08x vs. %08llx %p / %p.\n",
|
|
|
|
dev->name,
|
|
|
|
le32_to_cpu(tp->rx_ring[entry].buffer1),
|
|
|
|
(unsigned long long)tp->rx_buffers[entry].mapping,
|
|
|
|
skb->head, temp);
|
|
|
|
}
|
|
|
|
#endif
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
|
|
|
|
PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
tp->rx_buffers[entry].skb = NULL;
|
|
|
|
tp->rx_buffers[entry].mapping = 0;
|
|
|
|
}
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
netif_receive_skb(skb);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
dev->last_rx = jiffies;
|
|
|
|
tp->stats.rx_packets++;
|
|
|
|
tp->stats.rx_bytes += pkt_len;
|
|
|
|
}
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
|
|
|
|
received++;
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
entry = (++tp->cur_rx) % RX_RING_SIZE;
|
|
|
|
if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/4)
|
|
|
|
tulip_refill_rx(dev);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* New ack strategy... irq does not ack Rx any longer
|
|
|
|
hopefully this helps */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Really bad things can happen here... If new packet arrives
|
|
|
|
* and an irq arrives (tx or just due to occasionally unset
|
|
|
|
* mask), it will be acked by irq handler, but new thread
|
|
|
|
* is not scheduled. It is major hole in design.
|
|
|
|
* No idea how to fix this if "playing with fire" will fail
|
|
|
|
* tomorrow (night 011029). If it will not fail, we won
|
|
|
|
* finally: amount of IO did not increase at all. */
|
|
|
|
} while ((ioread32(tp->base_addr + CSR5) & RxIntr));
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* We use this simplistic scheme for IM. It's proven by
|
|
|
|
real life installations. We can have IM enabled
|
2006-05-27 03:39:03 +02:00
|
|
|
continuesly but this would cause unnecessary latency.
|
|
|
|
Unfortunely we can't use all the NET_RX_* feedback here.
|
|
|
|
This would turn on IM for devices that is not contributing
|
|
|
|
to backlog congestion with unnecessary latency.
|
|
|
|
|
2007-05-09 08:57:56 +02:00
|
|
|
We monitor the device RX-ring and have:
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
HW Interrupt Mitigation either ON or OFF.
|
2006-05-27 03:39:03 +02:00
|
|
|
|
|
|
|
ON: More then 1 pkt received (per intr.) OR we are dropping
|
2005-04-17 00:20:36 +02:00
|
|
|
OFF: Only 1 pkt received
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
Note. We only use min and max (0, 15) settings from mit_table */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if( tp->flags & HAS_INTR_MITIGATION) {
|
|
|
|
if( received > 1 ) {
|
|
|
|
if( ! tp->mit_on ) {
|
|
|
|
tp->mit_on = 1;
|
|
|
|
iowrite32(mit_table[MIT_TABLE], tp->base_addr + CSR11);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if( tp->mit_on ) {
|
|
|
|
tp->mit_on = 0;
|
|
|
|
iowrite32(0, tp->base_addr + CSR11);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_TULIP_NAPI_HW_MITIGATION */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
tulip_refill_rx(dev);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* If RX ring is not full we are out of memory. */
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
|
|
|
goto oom;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Remove us from polling list and enable RX intr. */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
netif_rx_complete(dev, napi);
|
2005-04-17 00:20:36 +02:00
|
|
|
iowrite32(tulip_tbl[tp->chip_id].valid_intrs, tp->base_addr+CSR7);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* The last op happens after poll completion. Which means the following:
|
|
|
|
* 1. it can race with disabling irqs in irq handler
|
|
|
|
* 2. it can race with dise/enabling irqs in other poll threads
|
|
|
|
* 3. if an irq raised after beginning loop, it will be immediately
|
|
|
|
* triggered here.
|
|
|
|
*
|
|
|
|
* Summarizing: the logic results in some redundant irqs both
|
|
|
|
* due to races in masking and due to too late acking of already
|
|
|
|
* processed irqs. But it must not result in losing events.
|
|
|
|
*/
|
2006-05-27 03:39:03 +02:00
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
return work_done;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
not_done:
|
|
|
|
if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 ||
|
|
|
|
tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
|
|
|
tulip_refill_rx(dev);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
|
|
|
|
goto oom;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
return work_done;
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
oom: /* Executed with RX ints disabled */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Start timer, stop polling, but do not enable rx interrupts. */
|
|
|
|
mod_timer(&tp->oom_timer, jiffies+1);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Think: timer_pending() was an explicit signature of bug.
|
|
|
|
* Timer can be pending now but fired and completed
|
|
|
|
* before we did netif_rx_complete(). See? We would lose it. */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* remove ourselves from the polling list */
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
netif_rx_complete(dev, napi);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
return work_done;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#else /* CONFIG_TULIP_NAPI */
|
|
|
|
|
|
|
|
static int tulip_rx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct tulip_private *tp = netdev_priv(dev);
|
|
|
|
int entry = tp->cur_rx % RX_RING_SIZE;
|
|
|
|
int rx_work_limit = tp->dirty_rx + RX_RING_SIZE - tp->cur_rx;
|
|
|
|
int received = 0;
|
|
|
|
|
|
|
|
if (tulip_debug > 4)
|
|
|
|
printk(KERN_DEBUG " In tulip_rx(), entry %d %8.8x.\n", entry,
|
|
|
|
tp->rx_ring[entry].status);
|
|
|
|
/* If we own the next entry, it is a new packet. Send it up. */
|
|
|
|
while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) {
|
|
|
|
s32 status = le32_to_cpu(tp->rx_ring[entry].status);
|
|
|
|
|
|
|
|
if (tulip_debug > 5)
|
|
|
|
printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n",
|
|
|
|
dev->name, entry, status);
|
|
|
|
if (--rx_work_limit < 0)
|
|
|
|
break;
|
|
|
|
if ((status & 0x38008300) != 0x0300) {
|
|
|
|
if ((status & 0x38000300) != 0x0300) {
|
|
|
|
/* Ingore earlier buffers. */
|
|
|
|
if ((status & 0xffff) != 0x7fff) {
|
|
|
|
if (tulip_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: Oversized Ethernet frame "
|
|
|
|
"spanned multiple buffers, status %8.8x!\n",
|
|
|
|
dev->name, status);
|
|
|
|
tp->stats.rx_length_errors++;
|
|
|
|
}
|
|
|
|
} else if (status & RxDescFatalErr) {
|
|
|
|
/* There was a fatal error. */
|
|
|
|
if (tulip_debug > 2)
|
|
|
|
printk(KERN_DEBUG "%s: Receive error, Rx status %8.8x.\n",
|
|
|
|
dev->name, status);
|
|
|
|
tp->stats.rx_errors++; /* end of a packet.*/
|
|
|
|
if (status & 0x0890) tp->stats.rx_length_errors++;
|
|
|
|
if (status & 0x0004) tp->stats.rx_frame_errors++;
|
|
|
|
if (status & 0x0002) tp->stats.rx_crc_errors++;
|
|
|
|
if (status & 0x0001) tp->stats.rx_fifo_errors++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Omit the four octet CRC from the length. */
|
|
|
|
short pkt_len = ((status >> 16) & 0x7ff) - 4;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
#ifndef final_version
|
|
|
|
if (pkt_len > 1518) {
|
|
|
|
printk(KERN_WARNING "%s: Bogus packet size of %d (%#x).\n",
|
|
|
|
dev->name, pkt_len, pkt_len);
|
|
|
|
pkt_len = 1518;
|
|
|
|
tp->stats.rx_length_errors++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check if the packet is long enough to accept without copying
|
|
|
|
to a minimally-sized skbuff. */
|
|
|
|
if (pkt_len < tulip_rx_copybreak
|
|
|
|
&& (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
|
|
|
|
skb_reserve(skb, 2); /* 16 byte align the IP header */
|
|
|
|
pci_dma_sync_single_for_cpu(tp->pdev,
|
|
|
|
tp->rx_buffers[entry].mapping,
|
|
|
|
pkt_len, PCI_DMA_FROMDEVICE);
|
|
|
|
#if ! defined(__alpha__)
|
2007-07-11 07:08:12 +02:00
|
|
|
skb_copy_to_linear_data(skb, tp->rx_buffers[entry].skb->data,
|
|
|
|
pkt_len);
|
2005-04-17 00:20:36 +02:00
|
|
|
skb_put(skb, pkt_len);
|
|
|
|
#else
|
|
|
|
memcpy(skb_put(skb, pkt_len),
|
2005-06-29 00:25:31 +02:00
|
|
|
tp->rx_buffers[entry].skb->data,
|
2005-04-17 00:20:36 +02:00
|
|
|
pkt_len);
|
|
|
|
#endif
|
|
|
|
pci_dma_sync_single_for_device(tp->pdev,
|
|
|
|
tp->rx_buffers[entry].mapping,
|
|
|
|
pkt_len, PCI_DMA_FROMDEVICE);
|
|
|
|
} else { /* Pass up the skb already on the Rx ring. */
|
|
|
|
char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
|
|
|
|
pkt_len);
|
|
|
|
|
|
|
|
#ifndef final_version
|
|
|
|
if (tp->rx_buffers[entry].mapping !=
|
|
|
|
le32_to_cpu(tp->rx_ring[entry].buffer1)) {
|
|
|
|
printk(KERN_ERR "%s: Internal fault: The skbuff addresses "
|
|
|
|
"do not match in tulip_rx: %08x vs. %Lx %p / %p.\n",
|
|
|
|
dev->name,
|
|
|
|
le32_to_cpu(tp->rx_ring[entry].buffer1),
|
|
|
|
(long long)tp->rx_buffers[entry].mapping,
|
|
|
|
skb->head, temp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
|
|
|
|
PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
|
|
|
|
|
|
|
|
tp->rx_buffers[entry].skb = NULL;
|
|
|
|
tp->rx_buffers[entry].mapping = 0;
|
|
|
|
}
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
|
|
|
|
|
|
netif_rx(skb);
|
|
|
|
|
|
|
|
dev->last_rx = jiffies;
|
|
|
|
tp->stats.rx_packets++;
|
|
|
|
tp->stats.rx_bytes += pkt_len;
|
|
|
|
}
|
|
|
|
received++;
|
|
|
|
entry = (++tp->cur_rx) % RX_RING_SIZE;
|
|
|
|
}
|
|
|
|
return received;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_TULIP_NAPI */
|
|
|
|
|
|
|
|
static inline unsigned int phy_interrupt (struct net_device *dev)
|
|
|
|
{
|
|
|
|
#ifdef __hppa__
|
|
|
|
struct tulip_private *tp = netdev_priv(dev);
|
|
|
|
int csr12 = ioread32(tp->base_addr + CSR12) & 0xff;
|
|
|
|
|
|
|
|
if (csr12 != tp->csr12_shadow) {
|
|
|
|
/* ack interrupt */
|
|
|
|
iowrite32(csr12 | 0x02, tp->base_addr + CSR12);
|
|
|
|
tp->csr12_shadow = csr12;
|
|
|
|
/* do link change stuff */
|
|
|
|
spin_lock(&tp->lock);
|
|
|
|
tulip_check_duplex(dev);
|
|
|
|
spin_unlock(&tp->lock);
|
|
|
|
/* clear irq ack bit */
|
|
|
|
iowrite32(csr12 & ~0x02, tp->base_addr + CSR12);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The interrupt handler does all of the Rx thread work and cleans up
|
|
|
|
after the Tx thread. */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 15:55:46 +02:00
|
|
|
irqreturn_t tulip_interrupt(int irq, void *dev_instance)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct net_device *dev = (struct net_device *)dev_instance;
|
|
|
|
struct tulip_private *tp = netdev_priv(dev);
|
|
|
|
void __iomem *ioaddr = tp->base_addr;
|
|
|
|
int csr5;
|
|
|
|
int missed;
|
|
|
|
int rx = 0;
|
|
|
|
int tx = 0;
|
|
|
|
int oi = 0;
|
|
|
|
int maxrx = RX_RING_SIZE;
|
|
|
|
int maxtx = TX_RING_SIZE;
|
|
|
|
int maxoi = TX_RING_SIZE;
|
|
|
|
#ifdef CONFIG_TULIP_NAPI
|
|
|
|
int rxd = 0;
|
|
|
|
#else
|
|
|
|
int entry;
|
|
|
|
#endif
|
|
|
|
unsigned int work_count = tulip_max_interrupt_work;
|
|
|
|
unsigned int handled = 0;
|
|
|
|
|
|
|
|
/* Let's see whether the interrupt really is for us */
|
|
|
|
csr5 = ioread32(ioaddr + CSR5);
|
|
|
|
|
2006-05-27 03:39:03 +02:00
|
|
|
if (tp->flags & HAS_PHY_IRQ)
|
2005-04-17 00:20:36 +02:00
|
|
|
handled = phy_interrupt (dev);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((csr5 & (NormalIntr|AbnormalIntr)) == 0)
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
|
|
|
|
tp->nir++;
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
#ifdef CONFIG_TULIP_NAPI
|
|
|
|
|
|
|
|
if (!rxd && (csr5 & (RxIntr | RxNoBuf))) {
|
|
|
|
rxd++;
|
|
|
|
/* Mask RX intrs and add the device to poll list. */
|
|
|
|
iowrite32(tulip_tbl[tp->chip_id].valid_intrs&~RxPollInt, ioaddr + CSR7);
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 01:41:36 +02:00
|
|
|
netif_rx_schedule(dev, &tp->napi);
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!(csr5&~(AbnormalIntr|NormalIntr|RxPollInt|TPLnkPass)))
|
|
|
|
break;
|
|
|
|
}
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Acknowledge the interrupt sources we handle here ASAP
|
|
|
|
the poll function does Rx and RxNoBuf acking */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
iowrite32(csr5 & 0x0001ff3f, ioaddr + CSR5);
|
|
|
|
|
2006-05-27 03:39:03 +02:00
|
|
|
#else
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Acknowledge all of the current interrupt sources ASAP. */
|
|
|
|
iowrite32(csr5 & 0x0001ffff, ioaddr + CSR5);
|
|
|
|
|
|
|
|
|
|
|
|
if (csr5 & (RxIntr | RxNoBuf)) {
|
|
|
|
rx += tulip_rx(dev);
|
|
|
|
tulip_refill_rx(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_TULIP_NAPI */
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (tulip_debug > 4)
|
|
|
|
printk(KERN_DEBUG "%s: interrupt csr5=%#8.8x new csr5=%#8.8x.\n",
|
|
|
|
dev->name, csr5, ioread32(ioaddr + CSR5));
|
2006-05-27 03:39:03 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (csr5 & (TxNoBuf | TxDied | TxIntr | TimerInt)) {
|
|
|
|
unsigned int dirty_tx;
|
|
|
|
|
|
|
|
spin_lock(&tp->lock);
|
|
|
|
|
|
|
|
for (dirty_tx = tp->dirty_tx; tp->cur_tx - dirty_tx > 0;
|
|
|
|
dirty_tx++) {
|
|
|
|
int entry = dirty_tx % TX_RING_SIZE;
|
|
|
|
int status = le32_to_cpu(tp->tx_ring[entry].status);
|
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
break; /* It still has not been Txed */
|
|
|
|
|
|
|
|
/* Check for Rx filter setup frames. */
|
|
|
|
if (tp->tx_buffers[entry].skb == NULL) {
|
|
|
|
/* test because dummy frames not mapped */
|
|
|
|
if (tp->tx_buffers[entry].mapping)
|
|
|
|
pci_unmap_single(tp->pdev,
|
|
|
|
tp->tx_buffers[entry].mapping,
|
|
|
|
sizeof(tp->setup_frame),
|
|
|
|
PCI_DMA_TODEVICE);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & 0x8000) {
|
|
|
|
/* There was an major error, log it. */
|
|
|
|
#ifndef final_version
|
|
|
|
if (tulip_debug > 1)
|
|
|
|
printk(KERN_DEBUG "%s: Transmit error, Tx status %8.8x.\n",
|
|
|
|
dev->name, status);
|
|
|
|
#endif
|
|
|
|
tp->stats.tx_errors++;
|
|
|
|
if (status & 0x4104) tp->stats.tx_aborted_errors++;
|
|
|
|
if (status & 0x0C00) tp->stats.tx_carrier_errors++;
|
|
|
|
if (status & 0x0200) tp->stats.tx_window_errors++;
|
|
|
|
if (status & 0x0002) tp->stats.tx_fifo_errors++;
|
|
|
|
if ((status & 0x0080) && tp->full_duplex == 0)
|
|
|
|
tp->stats.tx_heartbeat_errors++;
|
|
|
|
} else {
|
|
|
|
tp->stats.tx_bytes +=
|
|
|
|
tp->tx_buffers[entry].skb->len;
|
|
|
|
tp->stats.collisions += (status >> 3) & 15;
|
|
|
|
tp->stats.tx_packets++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
|
|
|
|
tp->tx_buffers[entry].skb->len,
|
|
|
|
PCI_DMA_TODEVICE);
|
|
|
|
|
|
|
|
/* Free the original skb. */
|
|
|
|
dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
|
|
|
|
tp->tx_buffers[entry].skb = NULL;
|
|
|
|
tp->tx_buffers[entry].mapping = 0;
|
|
|
|
tx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef final_version
|
|
|
|
if (tp->cur_tx - dirty_tx > TX_RING_SIZE) {
|
|
|
|
printk(KERN_ERR "%s: Out-of-sync dirty pointer, %d vs. %d.\n",
|
|
|
|
dev->name, dirty_tx, tp->cur_tx);
|
|
|
|
dirty_tx += TX_RING_SIZE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (tp->cur_tx - dirty_tx < TX_RING_SIZE - 2)
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
|
|
|
|
tp->dirty_tx = dirty_tx;
|
|
|
|
if (csr5 & TxDied) {
|
|
|
|
if (tulip_debug > 2)
|
|
|
|
printk(KERN_WARNING "%s: The transmitter stopped."
|
|
|
|
" CSR5 is %x, CSR6 %x, new CSR6 %x.\n",
|
|
|
|
dev->name, csr5, ioread32(ioaddr + CSR6), tp->csr6);
|
|
|
|
tulip_restart_rxtx(tp);
|
|
|
|
}
|
|
|
|
spin_unlock(&tp->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Log errors. */
|
|
|
|
if (csr5 & AbnormalIntr) { /* Abnormal error summary bit. */
|
|
|
|
if (csr5 == 0xffffffff)
|
|
|
|
break;
|
|
|
|
if (csr5 & TxJabber) tp->stats.tx_errors++;
|
|
|
|
if (csr5 & TxFIFOUnderflow) {
|
|
|
|
if ((tp->csr6 & 0xC000) != 0xC000)
|
|
|
|
tp->csr6 += 0x4000; /* Bump up the Tx threshold */
|
|
|
|
else
|
|
|
|
tp->csr6 |= 0x00200000; /* Store-n-forward. */
|
|
|
|
/* Restart the transmit process. */
|
|
|
|
tulip_restart_rxtx(tp);
|
|
|
|
iowrite32(0, ioaddr + CSR1);
|
|
|
|
}
|
|
|
|
if (csr5 & (RxDied | RxNoBuf)) {
|
|
|
|
if (tp->flags & COMET_MAC_ADDR) {
|
|
|
|
iowrite32(tp->mc_filter[0], ioaddr + 0xAC);
|
|
|
|
iowrite32(tp->mc_filter[1], ioaddr + 0xB0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (csr5 & RxDied) { /* Missed a Rx frame. */
|
|
|
|
tp->stats.rx_missed_errors += ioread32(ioaddr + CSR8) & 0xffff;
|
|
|
|
tp->stats.rx_errors++;
|
|
|
|
tulip_start_rxtx(tp);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* NB: t21142_lnk_change() does a del_timer_sync(), so be careful if this
|
|
|
|
* call is ever done under the spinlock
|
|
|
|
*/
|
|
|
|
if (csr5 & (TPLnkPass | TPLnkFail | 0x08000000)) {
|
|
|
|
if (tp->link_change)
|
|
|
|
(tp->link_change)(dev, csr5);
|
|
|
|
}
|
2007-03-12 10:31:33 +01:00
|
|
|
if (csr5 & SystemError) {
|
2005-04-17 00:20:36 +02:00
|
|
|
int error = (csr5 >> 23) & 7;
|
|
|
|
/* oops, we hit a PCI error. The code produced corresponds
|
|
|
|
* to the reason:
|
|
|
|
* 0 - parity error
|
|
|
|
* 1 - master abort
|
|
|
|
* 2 - target abort
|
|
|
|
* Note that on parity error, we should do a software reset
|
|
|
|
* of the chip to get it back into a sane state (according
|
|
|
|
* to the 21142/3 docs that is).
|
|
|
|
* -- rmk
|
|
|
|
*/
|
|
|
|
printk(KERN_ERR "%s: (%lu) System Error occurred (%d)\n",
|
|
|
|
dev->name, tp->nir, error);
|
|
|
|
}
|
|
|
|
/* Clear all error sources, included undocumented ones! */
|
|
|
|
iowrite32(0x0800f7ba, ioaddr + CSR5);
|
|
|
|
oi++;
|
|
|
|
}
|
|
|
|
if (csr5 & TimerInt) {
|
|
|
|
|
|
|
|
if (tulip_debug > 2)
|
|
|
|
printk(KERN_ERR "%s: Re-enabling interrupts, %8.8x.\n",
|
|
|
|
dev->name, csr5);
|
|
|
|
iowrite32(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
|
|
|
|
tp->ttimer = 0;
|
|
|
|
oi++;
|
|
|
|
}
|
|
|
|
if (tx > maxtx || rx > maxrx || oi > maxoi) {
|
|
|
|
if (tulip_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: Too much work during an interrupt, "
|
|
|
|
"csr5=0x%8.8x. (%lu) (%d,%d,%d)\n", dev->name, csr5, tp->nir, tx, rx, oi);
|
|
|
|
|
|
|
|
/* Acknowledge all interrupt sources. */
|
|
|
|
iowrite32(0x8001ffff, ioaddr + CSR5);
|
|
|
|
if (tp->flags & HAS_INTR_MITIGATION) {
|
|
|
|
/* Josip Loncaric at ICASE did extensive experimentation
|
|
|
|
to develop a good interrupt mitigation setting.*/
|
|
|
|
iowrite32(0x8b240000, ioaddr + CSR11);
|
|
|
|
} else if (tp->chip_id == LC82C168) {
|
|
|
|
/* the LC82C168 doesn't have a hw timer.*/
|
|
|
|
iowrite32(0x00, ioaddr + CSR7);
|
|
|
|
mod_timer(&tp->timer, RUN_AT(HZ/50));
|
|
|
|
} else {
|
|
|
|
/* Mask all interrupting sources, set timer to
|
|
|
|
re-enable. */
|
|
|
|
iowrite32(((~csr5) & 0x0001ebef) | AbnormalIntr | TimerInt, ioaddr + CSR7);
|
|
|
|
iowrite32(0x0012, ioaddr + CSR11);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
work_count--;
|
|
|
|
if (work_count == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
csr5 = ioread32(ioaddr + CSR5);
|
|
|
|
|
|
|
|
#ifdef CONFIG_TULIP_NAPI
|
|
|
|
if (rxd)
|
|
|
|
csr5 &= ~RxPollInt;
|
2006-05-27 03:39:03 +02:00
|
|
|
} while ((csr5 & (TxNoBuf |
|
|
|
|
TxDied |
|
|
|
|
TxIntr |
|
2005-04-17 00:20:36 +02:00
|
|
|
TimerInt |
|
|
|
|
/* Abnormal intr. */
|
2006-05-27 03:39:03 +02:00
|
|
|
RxDied |
|
|
|
|
TxFIFOUnderflow |
|
|
|
|
TxJabber |
|
|
|
|
TPLnkFail |
|
2007-03-12 10:31:33 +01:00
|
|
|
SystemError )) != 0);
|
2006-05-27 03:39:03 +02:00
|
|
|
#else
|
2005-04-17 00:20:36 +02:00
|
|
|
} while ((csr5 & (NormalIntr|AbnormalIntr)) != 0);
|
|
|
|
|
|
|
|
tulip_refill_rx(dev);
|
|
|
|
|
|
|
|
/* check if the card is in suspend mode */
|
|
|
|
entry = tp->dirty_rx % RX_RING_SIZE;
|
|
|
|
if (tp->rx_buffers[entry].skb == NULL) {
|
|
|
|
if (tulip_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: in rx suspend mode: (%lu) (tp->cur_rx = %u, ttimer = %d, rx = %d) go/stay in suspend mode\n", dev->name, tp->nir, tp->cur_rx, tp->ttimer, rx);
|
|
|
|
if (tp->chip_id == LC82C168) {
|
|
|
|
iowrite32(0x00, ioaddr + CSR7);
|
|
|
|
mod_timer(&tp->timer, RUN_AT(HZ/50));
|
|
|
|
} else {
|
|
|
|
if (tp->ttimer == 0 || (ioread32(ioaddr + CSR11) & 0xffff) == 0) {
|
|
|
|
if (tulip_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: in rx suspend mode: (%lu) set timer\n", dev->name, tp->nir);
|
|
|
|
iowrite32(tulip_tbl[tp->chip_id].valid_intrs | TimerInt,
|
|
|
|
ioaddr + CSR7);
|
|
|
|
iowrite32(TimerInt, ioaddr + CSR5);
|
|
|
|
iowrite32(12, ioaddr + CSR11);
|
|
|
|
tp->ttimer = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_TULIP_NAPI */
|
|
|
|
|
|
|
|
if ((missed = ioread32(ioaddr + CSR8) & 0x1ffff)) {
|
|
|
|
tp->stats.rx_dropped += missed & 0x10000 ? 0x10000 : missed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tulip_debug > 4)
|
|
|
|
printk(KERN_DEBUG "%s: exiting interrupt, csr5=%#4.4x.\n",
|
|
|
|
dev->name, ioread32(ioaddr + CSR5));
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|