Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 103318
b: refs/heads/master
c: a667601
h: refs/heads/master
v: v3
  • Loading branch information
Francois Romieu authored and David S. Miller committed Jul 8, 2008
1 parent 458f96f commit b97f454
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 81 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6a3d8aa48c1c9d3afc761b862267b9945cc6f281
refs/heads/master: a6676019a794eac967a967c1206a57824b180c9a
14 changes: 0 additions & 14 deletions trunk/drivers/net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1334,20 +1334,6 @@ config ADAPTEC_STARFIRE
To compile this driver as a module, choose M here: the module
will be called starfire. This is recommended.

config ADAPTEC_STARFIRE_NAPI
bool "Use Rx Polling (NAPI) (EXPERIMENTAL)"
depends on ADAPTEC_STARFIRE && EXPERIMENTAL
help
NAPI is a new driver API designed to reduce CPU and interrupt load
when the driver is receiving lots of packets from the card. It is
still somewhat experimental and thus not yet enabled by default.

If your estimated Rx load is 10kpps or more, or if the card will be
deployed on potentially unfriendly networks (e.g. in a firewall),
then say Y here.

If in doubt, say N.

config AC3200
tristate "Ansel Communications EISA 3200 support (EXPERIMENTAL)"
depends on NET_PCI && (ISA || EISA) && EXPERIMENTAL
Expand Down
111 changes: 45 additions & 66 deletions trunk/drivers/net/starfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/

#define DRV_NAME "starfire"
#define DRV_VERSION "2.0"
#define DRV_RELDATE "June 27, 2006"
#define DRV_VERSION "2.1"
#define DRV_RELDATE "July 6, 2008"

#include <linux/module.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -69,10 +69,6 @@
#define VLAN_SUPPORT
#endif

#ifndef CONFIG_ADAPTEC_STARFIRE_NAPI
#undef HAVE_NETDEV_POLL
#endif

/* The user-configurable values.
These may be modified when a driver module is loaded.*/

Expand Down Expand Up @@ -177,44 +173,6 @@ static int full_duplex[MAX_UNITS] = {0, };
#define skb_first_frag_len(skb) skb_headlen(skb)
#define skb_num_frags(skb) (skb_shinfo(skb)->nr_frags + 1)

#ifdef HAVE_NETDEV_POLL
#define init_poll(dev, np) \
netif_napi_add(dev, &np->napi, netdev_poll, max_interrupt_work)
#define netdev_rx(dev, np, ioaddr) \
do { \
u32 intr_enable; \
if (netif_rx_schedule_prep(dev, &np->napi)) { \
__netif_rx_schedule(dev, &np->napi); \
intr_enable = readl(ioaddr + IntrEnable); \
intr_enable &= ~(IntrRxDone | IntrRxEmpty); \
writel(intr_enable, ioaddr + IntrEnable); \
readl(ioaddr + IntrEnable); /* flush PCI posting buffers */ \
} else { \
/* Paranoia check */ \
intr_enable = readl(ioaddr + IntrEnable); \
if (intr_enable & (IntrRxDone | IntrRxEmpty)) { \
printk(KERN_INFO "%s: interrupt while in polling mode!\n", dev->name); \
intr_enable &= ~(IntrRxDone | IntrRxEmpty); \
writel(intr_enable, ioaddr + IntrEnable); \
} \
} \
} while (0)
#define netdev_receive_skb(skb) netif_receive_skb(skb)
#define vlan_netdev_receive_skb(skb, vlgrp, vlid) vlan_hwaccel_receive_skb(skb, vlgrp, vlid)
static int netdev_poll(struct napi_struct *napi, int budget);
#else /* not HAVE_NETDEV_POLL */
#define init_poll(dev, np)
#define netdev_receive_skb(skb) netif_rx(skb)
#define vlan_netdev_receive_skb(skb, vlgrp, vlid) vlan_hwaccel_rx(skb, vlgrp, vlid)
#define netdev_rx(dev, np, ioaddr) \
do { \
int quota = np->dirty_rx + RX_RING_SIZE - np->cur_rx; \
__netdev_rx(dev, &quota);\
} while (0)
#endif /* not HAVE_NETDEV_POLL */
/* end of compatibility code */


/* These identify the driver base version and may not be removed. */
static char version[] =
KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n"
Expand Down Expand Up @@ -635,6 +593,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev);
static irqreturn_t intr_handler(int irq, void *dev_instance);
static void netdev_error(struct net_device *dev, int intr_status);
static int __netdev_rx(struct net_device *dev, int *quota);
static int netdev_poll(struct napi_struct *napi, int budget);
static void refill_rx_ring(struct net_device *dev);
static void netdev_error(struct net_device *dev, int intr_status);
static void set_rx_mode(struct net_device *dev);
Expand Down Expand Up @@ -851,7 +810,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
dev->hard_start_xmit = &start_tx;
dev->tx_timeout = tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
init_poll(dev, np);
netif_napi_add(dev, &np->napi, netdev_poll, max_interrupt_work);
dev->stop = &netdev_close;
dev->get_stats = &get_stats;
dev->set_multicast_list = &set_rx_mode;
Expand Down Expand Up @@ -1054,9 +1013,8 @@ static int netdev_open(struct net_device *dev)

writel(np->intr_timer_ctrl, ioaddr + IntrTimerCtrl);

#ifdef HAVE_NETDEV_POLL
napi_enable(&np->napi);
#endif

netif_start_queue(dev);

if (debug > 1)
Expand Down Expand Up @@ -1330,8 +1288,28 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)

handled = 1;

if (intr_status & (IntrRxDone | IntrRxEmpty))
netdev_rx(dev, np, ioaddr);
if (intr_status & (IntrRxDone | IntrRxEmpty)) {
u32 enable;

if (likely(netif_rx_schedule_prep(dev, &np->napi))) {
__netif_rx_schedule(dev, &np->napi);
enable = readl(ioaddr + IntrEnable);
enable &= ~(IntrRxDone | IntrRxEmpty);
writel(enable, ioaddr + IntrEnable);
/* flush PCI posting buffers */
readl(ioaddr + IntrEnable);
} else {
/* Paranoia check */
enable = readl(ioaddr + IntrEnable);
if (enable & (IntrRxDone | IntrRxEmpty)) {
printk(KERN_INFO
"%s: interrupt while in poll!\n",
dev->name);
enable &= ~(IntrRxDone | IntrRxEmpty);
writel(enable, ioaddr + IntrEnable);
}
}
}

/* Scavenge the skbuff list based on the Tx-done queue.
There are redundant checks here that may be cleaned up
Expand Down Expand Up @@ -1411,8 +1389,10 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
}


/* This routine is logically part of the interrupt/poll handler, but separated
for clarity, code sharing between NAPI/non-NAPI, and better register allocation. */
/*
* This routine is logically part of the interrupt/poll handler, but separated
* for clarity and better register allocation.
*/
static int __netdev_rx(struct net_device *dev, int *quota)
{
struct netdev_private *np = netdev_priv(dev);
Expand Down Expand Up @@ -1507,13 +1487,20 @@ static int __netdev_rx(struct net_device *dev, int *quota)
}
#ifdef VLAN_SUPPORT
if (np->vlgrp && le16_to_cpu(desc->status2) & 0x0200) {
if (debug > 4)
printk(KERN_DEBUG " netdev_rx() vlanid = %d\n", le16_to_cpu(desc->vlanid));
/* vlan_netdev_receive_skb() expects a packet with the VLAN tag stripped out */
vlan_netdev_receive_skb(skb, np->vlgrp, le16_to_cpu(desc->vlanid));
u16 vlid = le16_to_cpu(desc->vlanid);

if (debug > 4) {
printk(KERN_DEBUG " netdev_rx() vlanid = %d\n",
vlid);
}
/*
* vlan_hwaccel_rx expects a packet with the VLAN tag
* stripped out.
*/
vlan_hwaccel_rx(skb, np->vlgrp, vlid);
} else
#endif /* VLAN_SUPPORT */
netdev_receive_skb(skb);
netif_receive_skb(skb);
dev->last_rx = jiffies;
np->stats.rx_packets++;

Expand All @@ -1532,8 +1519,6 @@ static int __netdev_rx(struct net_device *dev, int *quota)
return retcode;
}


#ifdef HAVE_NETDEV_POLL
static int netdev_poll(struct napi_struct *napi, int budget)
{
struct netdev_private *np = container_of(napi, struct netdev_private, napi);
Expand Down Expand Up @@ -1564,8 +1549,6 @@ static int netdev_poll(struct napi_struct *napi, int budget)
/* Restart Rx engine if stopped. */
return budget - quota;
}
#endif /* HAVE_NETDEV_POLL */


static void refill_rx_ring(struct net_device *dev)
{
Expand Down Expand Up @@ -1906,9 +1889,8 @@ static int netdev_close(struct net_device *dev)
int i;

netif_stop_queue(dev);
#ifdef HAVE_NETDEV_POLL

napi_disable(&np->napi);
#endif

if (debug > 1) {
printk(KERN_DEBUG "%s: Shutting down ethercard, Intr status %#8.8x.\n",
Expand Down Expand Up @@ -2044,11 +2026,8 @@ static int __init starfire_init (void)
/* when a module, this is printed whether or not devices are found in probe */
#ifdef MODULE
printk(version);
#ifdef HAVE_NETDEV_POLL

printk(KERN_INFO DRV_NAME ": polling (NAPI) enabled\n");
#else
printk(KERN_INFO DRV_NAME ": polling (NAPI) disabled\n");
#endif
#endif

/* we can do this test only at run-time... sigh */
Expand Down

0 comments on commit b97f454

Please sign in to comment.