From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 11:20:03
This patch series represents a continuation of the effort to get
better coverage of the SO_TIMESTAMPING socket API in the Ethernet
drivers. Adding time stamping support to a given driver solves two
separate issues, namely software transmit time stamping and hardware
time stamping in PHY devices.
This second batch adds the hooks into all remaining (?) arm and
powerpc MAC drivers using phylib. The first patch exports the receive
hook for use by non-NAPI drivers when compiled as modules. Patch #5
has been tested on real hardware, but the rest have only been compile
tested.
Richard Cochran (11):
net: export the receive time stamping hook for non-NAPI drivers
lib8390: enable transmit and receive time stamping.
emaclite: enable transmit and receive time stamping.
ll_temac: enable transmit and receive time stamping.
fec_mpc52xx: enable transmit and receive time stamping.
macb: enable transmit time stamping.
fs_enet: enable transmit time stamping.
smsc911x: enable transmit time stamping.
pxa168_eth: enable transmit time stamping.
mv643xx_eth: enable transmit time stamping.
ucc_geth: enable transmit time stamping.
drivers/net/fec_mpc52xx.c | 4 +++-
drivers/net/fs_enet/fs_enet-main.c | 2 ++
drivers/net/lib8390.c | 5 +++--
drivers/net/ll_temac_main.c | 5 ++++-
drivers/net/macb.c | 2 ++
drivers/net/mv643xx_eth.c | 2 ++
drivers/net/pxa168_eth.c | 1 +
drivers/net/smsc911x.c | 1 +
drivers/net/ucc_geth.c | 1 +
drivers/net/xilinx_emaclite.c | 9 +++++++--
net/core/timestamping.c | 1 +
11 files changed, 27 insertions(+), 6 deletions(-)
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 11:20:04
Ethernet MAC drivers based on phylib (but not using NAPI) can
enable hardware time stamping in phy devices by calling netif_rx()
conditionally based on a call to skb_defer_rx_timestamp().
This commit exports that function so that drivers calling it may
be compiled as modules.
Signed-off-by: Richard Cochran <redacted>
---
net/core/timestamping.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 11:20:07
This patch enables software (and phy device) time stamping. This file is
included by drivers/net/ax88796.c, which is based on phylib. So, this
patch makes hardware time stamping in the PHY possible.
Compile tested only.
Signed-off-by: Richard Cochran <redacted>
---
drivers/net/lib8390.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 11:20:10
This patch enables software (and phy device) time stamping. Since this
MAC uses phylib, adding the hooks make hardware time stamping in the phy
possible.
Compile tested only.
Cc: John Linn <redacted>
Signed-off-by: Richard Cochran <redacted>
---
drivers/net/xilinx_emaclite.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
@@ -647,7 +647,8 @@ static void xemaclite_rx_handler(struct net_device *dev)dev->stats.rx_packets++;dev->stats.rx_bytes+=len;-netif_rx(skb);/* Send the packet upstream */+if(!skb_defer_rx_timestamp(skb))+netif_rx(skb);/* Send the packet upstream */}/**
@@ -1029,15 +1030,19 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev)spin_lock_irqsave(&lp->reset_lock,flags);if(xemaclite_send_data(lp,(u8*)new_skb->data,len)!=0){/* If the Emaclite Tx buffer is busy, stop the Tx queue and-*defertheskbfortransmissionatalaterpointwhenthe+*defertheskbfortransmissionduringtheISR,afterthe*currenttransmissioniscomplete*/netif_stop_queue(dev);lp->deferred_skb=new_skb;spin_unlock_irqrestore(&lp->reset_lock,flags);+/* Take the time stamp now, since we can't do this in an ISR. */+skb_tx_timestamp(new_skb);return0;}spin_unlock_irqrestore(&lp->reset_lock,flags);+skb_tx_timestamp(new_skb);+dev->stats.tx_bytes+=len;dev_kfree_skb(new_skb);
From: Eric Dumazet <hidden> Date: 2011-06-19 11:53:51
Le dimanche 19 juin 2011 à 13:19 +0200, Richard Cochran a écrit :
quoted hunk
This patch enables software (and phy device) time stamping. Since this
MAC uses phylib, adding the hooks make hardware time stamping in the phy
possible.
Compile tested only.
Cc: John Linn <redacted>
Signed-off-by: Richard Cochran <redacted>
---
drivers/net/xilinx_emaclite.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
@@ -647,7 +647,8 @@ static void xemaclite_rx_handler(struct net_device *dev)dev->stats.rx_packets++;dev->stats.rx_bytes+=len;-netif_rx(skb);/* Send the packet upstream */+if(!skb_defer_rx_timestamp(skb))+netif_rx(skb);/* Send the packet upstream */}/**
@@ -1029,15 +1030,19 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev)spin_lock_irqsave(&lp->reset_lock,flags);if(xemaclite_send_data(lp,(u8*)new_skb->data,len)!=0){/* If the Emaclite Tx buffer is busy, stop the Tx queue and-*defertheskbfortransmissionatalaterpointwhenthe+*defertheskbfortransmissionduringtheISR,afterthe*currenttransmissioniscomplete*/netif_stop_queue(dev);lp->deferred_skb=new_skb;spin_unlock_irqrestore(&lp->reset_lock,flags);
Since you unlock reset_lock right here, there is no guarantee something
wont eat 'deferred_skb', so you might manipulate a freed skb after this
point.
+ /* Take the time stamp now, since we can't do this in an ISR. */
+ skb_tx_timestamp(new_skb);
return 0;
}
spin_unlock_irqrestore(&lp->reset_lock, flags);
+ skb_tx_timestamp(new_skb);
+
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 11:20:13
This patch enables software (and phy device) time stamping. Since this MAC
is based on phylib, adding the hooks makes hardware time stamping in the
phy possible.
Compile tested only.
Cc: Grant Likely <redacted>
Signed-off-by: Richard Cochran <redacted>
---
drivers/net/ll_temac_main.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
@@ -730,6 +730,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)/* Kick off the transfer */lp->dma_out(lp,TX_TAILDESC_PTR,tail_p);/* DMA start */+skb_tx_timestamp(skb);+returnNETDEV_TX_OK;}
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 11:20:15
This patch enables software (and phy device) time stamping. Software
time stamping using the SO_TIMESTAMPING API was tested and found to be
working on the LITE5200B board.
Cc: Grant Likely <redacted>
Signed-off-by: Richard Cochran <redacted>
---
drivers/net/fec_mpc52xx.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
From: Eric Dumazet <hidden> Date: 2011-06-19 11:56:20
Le dimanche 19 juin 2011 à 13:20 +0200, Richard Cochran a écrit :
quoted hunk
This patch enables software (and phy device) time stamping. Software
time stamping using the SO_TIMESTAMPING API was tested and found to be
working on the LITE5200B board.
Cc: Grant Likely <redacted>
Signed-off-by: Richard Cochran <redacted>
---
drivers/net/fec_mpc52xx.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-19 18:12:12
On Sun, Jun 19, 2011 at 01:58:04PM +0200, Eric Dumazet wrote:
Well, I'll stop my review here, there is the same problem I guess in all
your patches.
Thanks for your review. I have posted a fix for the first batch (since
they are already in next) and reposted this series.
But, considering your point, it looks like pxa168_eth and mv643xx_eth
(see patches 9 and 10 of this series) already access skb->len unsafely.
Would you care to comment on those spots, too?
Thanks,
Richard
From: Eric Dumazet <hidden> Date: 2011-06-19 18:30:58
Le dimanche 19 juin 2011 à 20:12 +0200, Richard Cochran a écrit :
Thanks for your review. I have posted a fix for the first batch (since
they are already in next) and reposted this series.
But, considering your point, it looks like pxa168_eth and mv643xx_eth
(see patches 9 and 10 of this series) already access skb->len unsafely.
Would you care to comment on those spots, too?
They certainly are buggy, at a first glance.
Not only skb->len is unsafe, but netif_tx_stop_queue() calls are unsafe
too.
Not sure anyone still use these drivers...
From: Richard Cochran <richardcochran@gmail.com> Date: 2011-06-20 06:58:28
On Sun, Jun 19, 2011 at 08:30:49PM +0200, Eric Dumazet wrote:
Le dimanche 19 juin 2011 à 20:12 +0200, Richard Cochran a écrit :
quoted
Thanks for your review. I have posted a fix for the first batch (since
they are already in next) and reposted this series.
But, considering your point, it looks like pxa168_eth and mv643xx_eth
(see patches 9 and 10 of this series) already access skb->len unsafely.
Would you care to comment on those spots, too?
They certainly are buggy, at a first glance.
Not only skb->len is unsafe, but netif_tx_stop_queue() calls are unsafe
too.
Out of the MAC drivers in my two batches, only drivers/net/tg3.c calls
netif_tx_stop_queue(txq);
However, I don't know how to fix that. Anyone else care to take a look?
Thanks,
Richard
From: Matt Carlson <hidden> Date: 2011-06-22 23:53:06
On Sun, Jun 19, 2011 at 11:58:31PM -0700, Richard Cochran wrote:
On Sun, Jun 19, 2011 at 08:30:49PM +0200, Eric Dumazet wrote:
quoted
Le dimanche 19 juin 2011 ? 20:12 +0200, Richard Cochran a ?crit :
quoted
Thanks for your review. I have posted a fix for the first batch (since
they are already in next) and reposted this series.
But, considering your point, it looks like pxa168_eth and mv643xx_eth
(see patches 9 and 10 of this series) already access skb->len unsafely.
Would you care to comment on those spots, too?
They certainly are buggy, at a first glance.
Not only skb->len is unsafe, but netif_tx_stop_queue() calls are unsafe
too.
Out of the MAC drivers in my two batches, only drivers/net/tg3.c calls
netif_tx_stop_queue(txq);
However, I don't know how to fix that. Anyone else care to take a look?
From: Eric Dumazet <hidden> Date: 2011-06-19 22:43:41
As soon as skb is given to hardware and spinlock released, TX completion
can free skb under us. Therefore, we should update netdev stats before
spinlock release.
Signed-off-by: Eric Dumazet <redacted>
---
drivers/net/hp100.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: David Miller <davem@davemloft.net> Date: 2011-06-19 23:34:12
From: Eric Dumazet <redacted>
Date: Mon, 20 Jun 2011 00:43:33 +0200
As soon as skb is given to hardware and spinlock released, TX completion
can free skb under us. Therefore, we should update netdev stats before
spinlock release.
Signed-off-by: Eric Dumazet <redacted>