aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qla3xxx.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-10-03 19:41:36 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:47:45 -0400
commitbea3348eef27e6044b6161fd04c3152215f96411 (patch)
treef0990b263e5ce42505d290a4c346fe990bcd4c33 /drivers/net/qla3xxx.c
parentdde4e47e8fe333a5649a3fa0e7db1fa7c08d6158 (diff)
[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>
Diffstat (limited to 'drivers/net/qla3xxx.c')
-rwxr-xr-xdrivers/net/qla3xxx.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index ea151315050c..bf9f8f64ba67 100755
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2310,10 +2310,10 @@ static int ql_tx_rx_clean(struct ql3_adapter *qdev,
2310 return work_done; 2310 return work_done;
2311} 2311}
2312 2312
2313static int ql_poll(struct net_device *ndev, int *budget) 2313static int ql_poll(struct napi_struct *napi, int budget)
2314{ 2314{
2315 struct ql3_adapter *qdev = netdev_priv(ndev); 2315 struct ql3_adapter *qdev = container_of(napi, struct ql3_adapter, napi);
2316 int work_to_do = min(*budget, ndev->quota); 2316 struct net_device *ndev = qdev->ndev;
2317 int rx_cleaned = 0, tx_cleaned = 0; 2317 int rx_cleaned = 0, tx_cleaned = 0;
2318 unsigned long hw_flags; 2318 unsigned long hw_flags;
2319 struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers; 2319 struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
@@ -2321,16 +2321,13 @@ static int ql_poll(struct net_device *ndev, int *budget)
2321 if (!netif_carrier_ok(ndev)) 2321 if (!netif_carrier_ok(ndev))
2322 goto quit_polling; 2322 goto quit_polling;
2323 2323
2324 ql_tx_rx_clean(qdev, &tx_cleaned, &rx_cleaned, work_to_do); 2324 ql_tx_rx_clean(qdev, &tx_cleaned, &rx_cleaned, budget);
2325 *budget -= rx_cleaned;
2326 ndev->quota -= rx_cleaned;
2327 2325
2328 if( tx_cleaned + rx_cleaned != work_to_do || 2326 if (tx_cleaned + rx_cleaned != budget ||
2329 !netif_running(ndev)) { 2327 !netif_running(ndev)) {
2330quit_polling: 2328quit_polling:
2331 netif_rx_complete(ndev);
2332
2333 spin_lock_irqsave(&qdev->hw_lock, hw_flags); 2329 spin_lock_irqsave(&qdev->hw_lock, hw_flags);
2330 __netif_rx_complete(ndev, napi);
2334 ql_update_small_bufq_prod_index(qdev); 2331 ql_update_small_bufq_prod_index(qdev);
2335 ql_update_lrg_bufq_prod_index(qdev); 2332 ql_update_lrg_bufq_prod_index(qdev);
2336 writel(qdev->rsp_consumer_index, 2333 writel(qdev->rsp_consumer_index,
@@ -2338,9 +2335,8 @@ quit_polling:
2338 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); 2335 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
2339 2336
2340 ql_enable_interrupts(qdev); 2337 ql_enable_interrupts(qdev);
2341 return 0;
2342 } 2338 }
2343 return 1; 2339 return tx_cleaned + rx_cleaned;
2344} 2340}
2345 2341
2346static irqreturn_t ql3xxx_isr(int irq, void *dev_id) 2342static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
@@ -2390,8 +2386,8 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
2390 spin_unlock(&qdev->adapter_lock); 2386 spin_unlock(&qdev->adapter_lock);
2391 } else if (value & ISP_IMR_DISABLE_CMPL_INT) { 2387 } else if (value & ISP_IMR_DISABLE_CMPL_INT) {
2392 ql_disable_interrupts(qdev); 2388 ql_disable_interrupts(qdev);
2393 if (likely(netif_rx_schedule_prep(ndev))) { 2389 if (likely(netif_rx_schedule_prep(ndev, &qdev->napi))) {
2394 __netif_rx_schedule(ndev); 2390 __netif_rx_schedule(ndev, &qdev->napi);
2395 } 2391 }
2396 } else { 2392 } else {
2397 return IRQ_NONE; 2393 return IRQ_NONE;
@@ -3617,7 +3613,7 @@ static int ql_adapter_down(struct ql3_adapter *qdev, int do_reset)
3617 3613
3618 del_timer_sync(&qdev->adapter_timer); 3614 del_timer_sync(&qdev->adapter_timer);
3619 3615
3620 netif_poll_disable(ndev); 3616 napi_disable(&qdev->napi);
3621 3617
3622 if (do_reset) { 3618 if (do_reset) {
3623 int soft_reset; 3619 int soft_reset;
@@ -3705,7 +3701,7 @@ static int ql_adapter_up(struct ql3_adapter *qdev)
3705 3701
3706 mod_timer(&qdev->adapter_timer, jiffies + HZ * 1); 3702 mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
3707 3703
3708 netif_poll_enable(ndev); 3704 napi_enable(&qdev->napi);
3709 ql_enable_interrupts(qdev); 3705 ql_enable_interrupts(qdev);
3710 return 0; 3706 return 0;
3711 3707
@@ -4061,8 +4057,7 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
4061 ndev->tx_timeout = ql3xxx_tx_timeout; 4057 ndev->tx_timeout = ql3xxx_tx_timeout;
4062 ndev->watchdog_timeo = 5 * HZ; 4058 ndev->watchdog_timeo = 5 * HZ;
4063 4059
4064 ndev->poll = &ql_poll; 4060 netif_napi_add(ndev, &qdev->napi, ql_poll, 64);
4065 ndev->weight = 64;
4066 4061
4067 ndev->irq = pdev->irq; 4062 ndev->irq = pdev->irq;
4068 4063