* [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git
@ 2007-09-08 0:27 Auke Kok
2007-09-08 0:30 ` Kok, Auke
0 siblings, 1 reply; 6+ messages in thread
From: Auke Kok @ 2007-09-08 0:27 UTC (permalink / raw)
To: akpm, davem; +Cc: jeff, netdev, auke-jan.h.kok
This incorporates the new napi_struct changes into e1000e. Included
bugfix for ifdown hang from Krishna Kumar for e1000.
Disabling polling is no longer needed at init time, so remove
napi_disable() call from _probe().
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---
drivers/net/e1000e/e1000.h | 2 ++
drivers/net/e1000e/netdev.c | 39 ++++++++++++++++-----------------------
2 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index c57e35a..d2499bb 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -187,6 +187,8 @@ struct e1000_adapter {
struct e1000_ring *tx_ring /* One per active queue */
____cacheline_aligned_in_smp;
+ struct napi_struct napi;
+
unsigned long tx_queue_len;
unsigned int restart_queue;
u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 372da46..f8ec537 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
- if (netif_rx_schedule_prep(netdev)) {
+ if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
- __netif_rx_schedule(netdev);
+ __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
- if (netif_rx_schedule_prep(netdev)) {
+ if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
- __netif_rx_schedule(netdev);
+ __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1662,10 +1662,10 @@ set_itr_now:
* e1000_clean - NAPI Rx polling callback
* @adapter: board private structure
**/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
{
- struct e1000_adapter *adapter;
- int work_to_do = min(*budget, poll_dev->quota);
+ struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
+ struct net_device *poll_dev = adapter->netdev;
int tx_cleaned = 0, work_done = 0;
/* Must NOT use netdev_priv macro here. */
@@ -1684,25 +1684,20 @@ static int e1000_clean(struct net_device *poll_dev, int *budget)
spin_unlock(&adapter->tx_queue_lock);
}
- adapter->clean_rx(adapter, &work_done, work_to_do);
- *budget -= work_done;
- poll_dev->quota -= work_done;
+ adapter->clean_rx(adapter, &work_done, budget);
/* If no Tx and not enough Rx work done, exit the polling mode */
- if ((!tx_cleaned && (work_done == 0)) ||
+ if ((tx_cleaned && (work_done < budget)) ||
!netif_running(poll_dev)) {
quit_polling:
if (adapter->itr_setting & 3)
e1000_set_itr(adapter);
- netif_rx_complete(poll_dev);
- if (test_bit(__E1000_DOWN, &adapter->state))
- atomic_dec(&adapter->irq_sem);
- else
- e1000_irq_enable(adapter);
+ netif_rx_complete(poll_dev, napi);
+ e1000_irq_enable(adapter);
return 0;
}
- return 1;
+ return work_done;
}
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2439,7 +2434,7 @@ int e1000e_up(struct e1000_adapter *adapter)
clear_bit(__E1000_DOWN, &adapter->state);
- netif_poll_enable(adapter->netdev);
+ napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
/* fire a link change interrupt to start the watchdog */
@@ -2472,7 +2467,7 @@ void e1000e_down(struct e1000_adapter *adapter)
e1e_flush();
msleep(10);
- netif_poll_disable(netdev);
+ napi_disable(&adapter->napi);
e1000_irq_disable(adapter);
del_timer_sync(&adapter->watchdog_timer);
@@ -2605,7 +2600,7 @@ static int e1000_open(struct net_device *netdev)
/* From here on the code is the same as e1000e_up() */
clear_bit(__E1000_DOWN, &adapter->state);
- netif_poll_enable(netdev);
+ napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
@@ -4090,8 +4085,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
e1000e_set_ethtool_ops(netdev);
netdev->tx_timeout = &e1000_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
- netdev->poll = &e1000_clean;
- netdev->weight = 64;
+ netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
netdev->vlan_rx_register = e1000_vlan_rx_register;
netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
@@ -4260,7 +4254,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
/* tell the stack to leave us alone until e1000_open() is called */
netif_carrier_off(netdev);
netif_stop_queue(netdev);
- netif_poll_disable(netdev);
strcpy(netdev->name, "eth%d");
err = register_netdev(netdev);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git
2007-09-08 0:27 [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git Auke Kok
@ 2007-09-08 0:30 ` Kok, Auke
2007-09-08 7:53 ` Robert Olsson
0 siblings, 1 reply; 6+ messages in thread
From: Kok, Auke @ 2007-09-08 0:30 UTC (permalink / raw)
To: davem; +Cc: akpm, jeff, netdev
Auke Kok wrote:
> This incorporates the new napi_struct changes into e1000e. Included
> bugfix for ifdown hang from Krishna Kumar for e1000.
>
> Disabling polling is no longer needed at init time, so remove
> napi_disable() call from _probe().
david,
while testing this patch I noticed that the poll routine is now called 100% of
the time, and since I'm not doing much different than before, I suspec that
something in the new napi code is staying in polling mode forever? Since e1000e
is pretty much the same code as e1000, I doubt the problem is there, but you can
probably tell better. ideas?
Auke
>
> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
> ---
>
> drivers/net/e1000e/e1000.h | 2 ++
> drivers/net/e1000e/netdev.c | 39 ++++++++++++++++-----------------------
> 2 files changed, 18 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> index c57e35a..d2499bb 100644
> --- a/drivers/net/e1000e/e1000.h
> +++ b/drivers/net/e1000e/e1000.h
> @@ -187,6 +187,8 @@ struct e1000_adapter {
> struct e1000_ring *tx_ring /* One per active queue */
> ____cacheline_aligned_in_smp;
>
> + struct napi_struct napi;
> +
> unsigned long tx_queue_len;
> unsigned int restart_queue;
> u32 txd_cmd;
> diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
> index 372da46..f8ec537 100644
> --- a/drivers/net/e1000e/netdev.c
> +++ b/drivers/net/e1000e/netdev.c
> @@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
> mod_timer(&adapter->watchdog_timer, jiffies + 1);
> }
>
> - if (netif_rx_schedule_prep(netdev)) {
> + if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
> adapter->total_tx_bytes = 0;
> adapter->total_tx_packets = 0;
> adapter->total_rx_bytes = 0;
> adapter->total_rx_packets = 0;
> - __netif_rx_schedule(netdev);
> + __netif_rx_schedule(netdev, &adapter->napi);
> } else {
> atomic_dec(&adapter->irq_sem);
> }
> @@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
> mod_timer(&adapter->watchdog_timer, jiffies + 1);
> }
>
> - if (netif_rx_schedule_prep(netdev)) {
> + if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
> adapter->total_tx_bytes = 0;
> adapter->total_tx_packets = 0;
> adapter->total_rx_bytes = 0;
> adapter->total_rx_packets = 0;
> - __netif_rx_schedule(netdev);
> + __netif_rx_schedule(netdev, &adapter->napi);
> } else {
> atomic_dec(&adapter->irq_sem);
> }
> @@ -1662,10 +1662,10 @@ set_itr_now:
> * e1000_clean - NAPI Rx polling callback
> * @adapter: board private structure
> **/
> -static int e1000_clean(struct net_device *poll_dev, int *budget)
> +static int e1000_clean(struct napi_struct *napi, int budget)
> {
> - struct e1000_adapter *adapter;
> - int work_to_do = min(*budget, poll_dev->quota);
> + struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
> + struct net_device *poll_dev = adapter->netdev;
> int tx_cleaned = 0, work_done = 0;
>
> /* Must NOT use netdev_priv macro here. */
> @@ -1684,25 +1684,20 @@ static int e1000_clean(struct net_device *poll_dev, int *budget)
> spin_unlock(&adapter->tx_queue_lock);
> }
>
> - adapter->clean_rx(adapter, &work_done, work_to_do);
> - *budget -= work_done;
> - poll_dev->quota -= work_done;
> + adapter->clean_rx(adapter, &work_done, budget);
>
> /* If no Tx and not enough Rx work done, exit the polling mode */
> - if ((!tx_cleaned && (work_done == 0)) ||
> + if ((tx_cleaned && (work_done < budget)) ||
> !netif_running(poll_dev)) {
> quit_polling:
> if (adapter->itr_setting & 3)
> e1000_set_itr(adapter);
> - netif_rx_complete(poll_dev);
> - if (test_bit(__E1000_DOWN, &adapter->state))
> - atomic_dec(&adapter->irq_sem);
> - else
> - e1000_irq_enable(adapter);
> + netif_rx_complete(poll_dev, napi);
> + e1000_irq_enable(adapter);
> return 0;
> }
>
> - return 1;
> + return work_done;
> }
>
> static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
> @@ -2439,7 +2434,7 @@ int e1000e_up(struct e1000_adapter *adapter)
>
> clear_bit(__E1000_DOWN, &adapter->state);
>
> - netif_poll_enable(adapter->netdev);
> + napi_enable(&adapter->napi);
> e1000_irq_enable(adapter);
>
> /* fire a link change interrupt to start the watchdog */
> @@ -2472,7 +2467,7 @@ void e1000e_down(struct e1000_adapter *adapter)
> e1e_flush();
> msleep(10);
>
> - netif_poll_disable(netdev);
> + napi_disable(&adapter->napi);
> e1000_irq_disable(adapter);
>
> del_timer_sync(&adapter->watchdog_timer);
> @@ -2605,7 +2600,7 @@ static int e1000_open(struct net_device *netdev)
> /* From here on the code is the same as e1000e_up() */
> clear_bit(__E1000_DOWN, &adapter->state);
>
> - netif_poll_enable(netdev);
> + napi_enable(&adapter->napi);
>
> e1000_irq_enable(adapter);
>
> @@ -4090,8 +4085,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
> e1000e_set_ethtool_ops(netdev);
> netdev->tx_timeout = &e1000_tx_timeout;
> netdev->watchdog_timeo = 5 * HZ;
> - netdev->poll = &e1000_clean;
> - netdev->weight = 64;
> + netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
> netdev->vlan_rx_register = e1000_vlan_rx_register;
> netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
> netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
> @@ -4260,7 +4254,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
> /* tell the stack to leave us alone until e1000_open() is called */
> netif_carrier_off(netdev);
> netif_stop_queue(netdev);
> - netif_poll_disable(netdev);
>
> strcpy(netdev->name, "eth%d");
> err = register_netdev(netdev);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git
2007-09-08 0:30 ` Kok, Auke
@ 2007-09-08 7:53 ` Robert Olsson
2007-09-12 14:53 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Robert Olsson @ 2007-09-08 7:53 UTC (permalink / raw)
To: Kok, Auke; +Cc: davem, akpm, jeff, netdev
Kok, Auke writes:
> david,
>
> while testing this patch I noticed that the poll routine is now called
> 100% of the time, and since I'm not doing much different than before, I
> suspec that something in the new napi code is staying in polling mode
> forever? Since e1000e is pretty much the same code as e1000, I doubt the
> problem is there, but you can probably tell better. ideas?
Hello,
Yes a correct observation. I've spotted this bug too and it caused by the
policy change in the NAPI scheduling. Look at tx_cleaned.
I suggest we revert this change for now.
Cheers
--ro
Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7b0bcdb..5cb883a 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3944,7 +3944,7 @@ e1000_clean(struct napi_struct *napi, int budget)
&work_done, budget);
/* If no Tx and not enough Rx work done, exit the polling mode */
- if ((tx_cleaned && (work_done < budget)) ||
+ if ((!tx_cleaned && (work_done == 0)) ||
!netif_running(poll_dev)) {
quit_polling:
if (likely(adapter->itr_setting & 3))
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git
2007-09-08 7:53 ` Robert Olsson
@ 2007-09-12 14:53 ` David Miller
2007-09-12 16:42 ` Kok, Auke
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2007-09-12 14:53 UTC (permalink / raw)
To: Robert.Olsson; +Cc: auke-jan.h.kok, akpm, jeff, netdev
From: Robert Olsson <Robert.Olsson@data.slu.se>
Date: Sat, 8 Sep 2007 09:53:49 +0200
> Yes a correct observation. I've spotted this bug too and it caused by the
> policy change in the NAPI scheduling. Look at tx_cleaned.
>
> I suggest we revert this change for now.
The tx_cleaned logic change was not intentional, and
that's the bug that makes e1000 spin endlessly in NAPI.
The other part, the work_done < budget part, was intentional
so I'm going to keep it in there for now. I've checked
in the patch below to deal with this.
I suspect the check "work_done == 0" is some shamans dance
to get slightly better performance, but it's 1) wrong and
2) at best needs to be explained in a comment and fully
quantified.
>From e8cbb449155000eecc6e855ea71510fecfc7d5ee Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@kimchee.(none)>
Date: Wed, 12 Sep 2007 16:50:32 +0200
Subject: [PATCH] [E1000]: Fix unintended NAPI breakout logic change.
The inversion of the !tx_cleaned test in e1000_clean()
was not intentional, we just wanted to change the
"work_done == 0" to "work_done < budget"
Noticed by Robert Olsson.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/e1000/e1000_main.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7b0bcdb..58bb758 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3944,7 +3944,7 @@ e1000_clean(struct napi_struct *napi, int budget)
&work_done, budget);
/* If no Tx and not enough Rx work done, exit the polling mode */
- if ((tx_cleaned && (work_done < budget)) ||
+ if ((!tx_cleaned && (work_done < budget)) ||
!netif_running(poll_dev)) {
quit_polling:
if (likely(adapter->itr_setting & 3))
--
1.5.2.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git
2007-09-12 14:53 ` David Miller
@ 2007-09-12 16:42 ` Kok, Auke
2007-09-13 6:55 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Kok, Auke @ 2007-09-12 16:42 UTC (permalink / raw)
To: David Miller; +Cc: Robert.Olsson, akpm, jeff, netdev
David Miller wrote:
> From: Robert Olsson <Robert.Olsson@data.slu.se>
> Date: Sat, 8 Sep 2007 09:53:49 +0200
>
>> Yes a correct observation. I've spotted this bug too and it caused by the
>> policy change in the NAPI scheduling. Look at tx_cleaned.
>>
>> I suggest we revert this change for now.
>
> The tx_cleaned logic change was not intentional, and
> that's the bug that makes e1000 spin endlessly in NAPI.
>
> The other part, the work_done < budget part, was intentional
> so I'm going to keep it in there for now. I've checked
> in the patch below to deal with this.
>
> I suspect the check "work_done == 0" is some shamans dance
> to get slightly better performance, but it's 1) wrong and
> 2) at best needs to be explained in a comment and fully
> quantified.
it probably gives us one more poll, so it might help, this isn't crucial and I
agree that it might offset the budgetting.
> From e8cbb449155000eecc6e855ea71510fecfc7d5ee Mon Sep 17 00:00:00 2001
> From: David S. Miller <davem@kimchee.(none)>
> Date: Wed, 12 Sep 2007 16:50:32 +0200
> Subject: [PATCH] [E1000]: Fix unintended NAPI breakout logic change.
>
> The inversion of the !tx_cleaned test in e1000_clean()
> was not intentional, we just wanted to change the
> "work_done == 0" to "work_done < budget"
>
> Noticed by Robert Olsson.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
> drivers/net/e1000/e1000_main.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
> index 7b0bcdb..58bb758 100644
> --- a/drivers/net/e1000/e1000_main.c
> +++ b/drivers/net/e1000/e1000_main.c
> @@ -3944,7 +3944,7 @@ e1000_clean(struct napi_struct *napi, int budget)
> &work_done, budget);
>
> /* If no Tx and not enough Rx work done, exit the polling mode */
> - if ((tx_cleaned && (work_done < budget)) ||
> + if ((!tx_cleaned && (work_done < budget)) ||
> !netif_running(poll_dev)) {
> quit_polling:
> if (likely(adapter->itr_setting & 3))
Ack, this is exactly what I did to fix e1000e as well.
Auke
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git
2007-09-12 16:42 ` Kok, Auke
@ 2007-09-13 6:55 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2007-09-13 6:55 UTC (permalink / raw)
To: auke-jan.h.kok; +Cc: Robert.Olsson, akpm, jeff, netdev
From: "Kok, Auke" <auke-jan.h.kok@intel.com>
Date: Wed, 12 Sep 2007 09:42:29 -0700
> David Miller wrote:
> >
> > diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
> > index 7b0bcdb..58bb758 100644
> > --- a/drivers/net/e1000/e1000_main.c
> > +++ b/drivers/net/e1000/e1000_main.c
> > @@ -3944,7 +3944,7 @@ e1000_clean(struct napi_struct *napi, int budget)
> > &work_done, budget);
> >
> > /* If no Tx and not enough Rx work done, exit the polling mode */
> > - if ((tx_cleaned && (work_done < budget)) ||
> > + if ((!tx_cleaned && (work_done < budget)) ||
> > !netif_running(poll_dev)) {
> > quit_polling:
> > if (likely(adapter->itr_setting & 3))
>
>
> Ack, this is exactly what I did to fix e1000e as well.
Thanks for reviewing.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-09-13 6:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-08 0:27 [PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git Auke Kok
2007-09-08 0:30 ` Kok, Auke
2007-09-08 7:53 ` Robert Olsson
2007-09-12 14:53 ` David Miller
2007-09-12 16:42 ` Kok, Auke
2007-09-13 6:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).