Re: [RFC] split NAPI from network device.

2007-02-20 Thread David Miller
From: Divy Le Ray [EMAIL PROTECTED]
Date: Tue, 20 Feb 2007 23:39:55 -0800

 I applied the patch to test the chelsio drivers.
 The compilation of the forcedeth driver fails if CONFIG_FORCEDETH_NAPI 
 is not set.
 /opt/sources/linux-2.6/drivers/net/forcedeth.c: In function `nv_nic_irq':
 /opt/sources/linux-2.6/drivers/net/forcedeth.c:2866: error: structure 
 has no member named `weight'
 /opt/sources/linux-2.6/drivers/net/forcedeth.c: In function 
 `nv_nic_irq_optimized':
 /opt/sources/linux-2.6/drivers/net/forcedeth.c:2983: error: structure 
 has no member named `weight'
 /opt/sources/linux-2.6/drivers/net/forcedeth.c: In function `nv_nic_irq_rx':
 /opt/sources/linux-2.6/drivers/net/forcedeth.c:3177: error: structure 
 has no member named `weight'

Thanks for catching that, I'll fix this up.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] split NAPI from network device.

2006-12-14 Thread Benjamin Herrenschmidt
On Wed, 2006-12-13 at 15:46 -0800, Stephen Hemminger wrote:
 Split off NAPI part from network device, this patch is build tested
 only! It breaks kernel API for network devices, and only three examples
 are fixed (skge, sky2, and tg3).
 
 1. Decomposition allows different NAPI - network device
Some hardware has N devices for one IRQ, others like MSI-X
want multiple receive's for one device.
 
 2. Cleanup locking with netpoll
 
 3. Change poll callback arguements and semantics
 
 4. Make softnet_data static (only in dev.c)

Thanks !

I'll give a go at adapting emac and maybe a few more when I get 5mn to
spare...

Ben.


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC] split NAPI from network device.

2006-12-13 Thread Stephen Hemminger
Split off NAPI part from network device, this patch is build tested
only! It breaks kernel API for network devices, and only three examples
are fixed (skge, sky2, and tg3).

1. Decomposition allows different NAPI - network device
   Some hardware has N devices for one IRQ, others like MSI-X
   want multiple receive's for one device.

2. Cleanup locking with netpoll

3. Change poll callback arguements and semantics

4. Make softnet_data static (only in dev.c)

Old:
dev-poll(dev, budget)
returns 1 or 0
requeu if returns 1

New:
napi-poll(napi, quota)
returns # of elements processed
requeue based on status

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
---
 drivers/net/skge.c|   32 +++
 drivers/net/sky2.c|   40 ++--
 drivers/net/sky2.h|1 +
 drivers/net/tg3.c |   28 ++
 include/linux/netdevice.h |  167 +
 include/linux/netpoll.h   |   50 --
 net/core/dev.c|  233 ++---
 net/core/net-sysfs.c  |   12 ++-
 net/core/netpoll.c|   61 -
 net/core/rtnetlink.c  |4 +-
 10 files changed, 304 insertions(+), 324 deletions(-)

diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index b60f045..65b9b65 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2914,13 +2914,13 @@ static void skge_tx_done(struct net_device *dev)
netif_tx_unlock(dev);
 }
 
-static int skge_poll(struct net_device *dev, int *budget)
+static int skge_poll(struct napi_struct *napi, int to_do)
 {
+   struct net_device *dev = container_of(napi, struct net_device, napi);
struct skge_port *skge = netdev_priv(dev);
struct skge_hw *hw = skge-hw;
struct skge_ring *ring = skge-rx_ring;
struct skge_element *e;
-   int to_do = min(dev-quota, *budget);
int work_done = 0;
 
skge_tx_done(dev);
@@ -2950,21 +2950,17 @@ static int skge_poll(struct net_device *dev, int 
*budget)
/* restart receiver */
wmb();
skge_write8(hw, Q_ADDR(rxqaddr[skge-port], Q_CSR), CSR_START);
+   
+   if (work_done  to_do) {
+   spin_lock_irq(hw-hw_lock);
+   __netif_rx_complete(dev);
+   hw-intr_mask |= irqmask[skge-port];
+   skge_write32(hw, B0_IMSK, hw-intr_mask);
+   skge_read32(hw, B0_IMSK);
+   spin_unlock_irq(hw-hw_lock);
+   }
 
-   *budget -= work_done;
-   dev-quota -= work_done;
-
-   if (work_done =  to_do)
-   return 1; /* not done */
-
-   spin_lock_irq(hw-hw_lock);
-   __netif_rx_complete(dev);
-   hw-intr_mask |= irqmask[skge-port];
-   skge_write32(hw, B0_IMSK, hw-intr_mask);
-   skge_read32(hw, B0_IMSK);
-   spin_unlock_irq(hw-hw_lock);
-
-   return 0;
+   return work_done;
 }
 
 /* Parity errors seem to happen when Genesis is connected to a switch
@@ -3428,8 +3424,8 @@ static struct net_device *skge_devinit(struct skge_hw 
*hw, int port,
SET_ETHTOOL_OPS(dev, skge_ethtool_ops);
dev-tx_timeout = skge_tx_timeout;
dev-watchdog_timeo = TX_WATCHDOG;
-   dev-poll = skge_poll;
-   dev-weight = NAPI_WEIGHT;
+   dev-napi.poll = skge_poll;
+   dev-napi.weight = NAPI_WEIGHT;
 #ifdef CONFIG_NET_POLL_CONTROLLER
dev-poll_controller = skge_netpoll;
 #endif
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index fb1d2c3..3fd1a78 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -2305,19 +2305,16 @@ static inline void sky2_idle_start(struct sky2_hw *hw)
 static void sky2_idle(unsigned long arg)
 {
struct sky2_hw *hw = (struct sky2_hw *) arg;
-   struct net_device *dev = hw-dev[0];
-
-   if (__netif_rx_schedule_prep(dev))
-   __netif_rx_schedule(dev);
+   
+   napi_schedule(hw-napi);
 
mod_timer(hw-idle_timer, jiffies + msecs_to_jiffies(idle_timeout));
 }
 
 
-static int sky2_poll(struct net_device *dev0, int *budget)
+static int sky2_poll(struct napi_struct *napi, int work_limit)
 {
-   struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))-hw;
-   int work_limit = min(dev0-quota, *budget);
+   struct sky2_hw *hw = container_of(napi, struct sky2_hw, napi);
int work_done = 0;
u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
 
@@ -2350,21 +2347,16 @@ static int sky2_poll(struct net_device *dev0, int 
*budget)
 
work_done = sky2_status_intr(hw, work_limit);
if (work_done  work_limit) {
-   netif_rx_complete(dev0);
+   napi_complete(napi);
 
sky2_read32(hw, B0_Y2_SP_LISR);
-   return 0;
-   } else {
-   *budget -= work_done;
-   dev0-quota -= work_done;
-   return 1;
}
+   return work_done;
 }
 
 static irqreturn_t sky2_intr(int irq, void *dev_id)
 {
struct sky2_hw *hw = dev_id;
-