net: expand time stamping, batch #2
Subsystems (3)
v2 cover net: expand time stamping, batch #2
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 | 3 +++ drivers/net/smsc911x.c | 1 + drivers/net/ucc_geth.c | 2 ++ drivers/net/xilinx_emaclite.c | 9 +++++++-- net/core/timestamping.c | 1 + 11 files changed, 30 insertions(+), 6 deletions(-)
PATCH v2 1/11 net: export the receive time stamping hook for non-NAPI drivers
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.
--- net/core/timestamping.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/timestamping.c +1 -0
@@ -122,6 +122,7 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb)return false; } +EXPORT_SYMBOL_GPL (skb_defer_rx_timestamp);void __init skb_timestamping_init (void ) {
Signature · 1 line
1.7.0.4
PATCH v2 2/11 lib8390: enable transmit and receive time stamping.
In reply to Richard CochranThis 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.
--- drivers/net/lib8390.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/lib8390.c +3 -2
@@ -410,7 +410,7 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb,spin_unlock (&ei_local->page_lock);enable_irq_lockdep_irqrestore (dev->irq, &flags); - +skb_tx_timestamp (skb);dev_kfree_skb (skb); dev->stats.tx_bytes += send_length;
@@ -758,7 +758,8 @@ static void ei_receive(struct net_device *dev)skb_put (skb, pkt_len);/* Make room */ ei_block_input (dev, pkt_len, skb, current_offset +sizeof (rx_frame)); skb->protocol=eth_type_trans (skb,dev); -netif_rx (skb); +if (!skb_defer_rx_timestamp (skb)) +netif_rx (skb); dev->stats.rx_packets++; dev->stats.rx_bytes += pkt_len;if (pkt_stat &ENRSR_PHY )
Signature · 1 line
1.7.0.4
PATCH v2 4/11 ll_temac: enable transmit and receive time stamping.
In reply to Richard CochranThis 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.
--- drivers/net/ll_temac_main.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/ll_temac_main.c +4 -1
@@ -727,6 +727,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)if (lp->tx_bd_tail >=TX_BD_NUM ) lp->tx_bd_tail =0 ; +skb_tx_timestamp (skb); +/* Kick off the transfer */ lp->dma_out (lp,TX_TAILDESC_PTR , tail_p);/* DMA start */
@@ -772,7 +774,8 @@ static void ll_temac_recv(struct net_device *ndev) skb->ip_summed =CHECKSUM_COMPLETE ; } -netif_rx (skb); +if (!skb_defer_rx_timestamp (skb)) +netif_rx (skb); ndev->stats.rx_packets++; ndev->stats.rx_bytes += length;
Signature · 1 line
1.7.0.4
PATCH v2 5/11 fec_mpc52xx: enable transmit and receive time stamping.
In reply to Richard CochranThis 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.
--- drivers/net/fec_mpc52xx.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/fec_mpc52xx.c +3 -1
@@ -335,6 +335,7 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev) bd->skb_pa =dma_map_single (dev->dev.parent, skb->data, skb->len,DMA_TO_DEVICE ); +skb_tx_timestamp (skb);bcom_submit_next_buffer (priv->tx_dmatsk, skb);spin_unlock_irqrestore (&priv->lock, flags);
@@ -434,7 +435,8 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id) length = status &BCOM_FEC_RX_BD_LEN_MASK ;skb_put (rskb, length -4 );/* length without CRC32 */ rskb->protocol =eth_type_trans (rskb, dev); -netif_rx (rskb); +if (!skb_defer_rx_timestamp (skb)) +netif_rx (rskb);spin_lock (&priv->lock); }
Signature · 1 line
1.7.0.4
PATCH v2 6/11 macb: enable transmit time stamping.
In reply to Richard CochranThis patch enables software (and phy device) transmit time stamping Compile tested only.
--- drivers/net/macb.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/macb.c +2 -0
@@ -669,6 +669,8 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) entry =NEXT_TX (entry); bp->tx_head = entry; +skb_tx_timestamp (skb); +macb_writel (bp,NCR ,macb_readl (bp,NCR ) |MACB_BIT (TSTART ));if (TX_BUFFS_AVAIL (bp) <1 )
Signature · 1 line
1.7.0.4
PATCH v2 7/11 fs_enet: enable transmit time stamping.
In reply to Richard CochranThis patch enables software (and phy device) transmit time stamping. Compile tested only.
--- drivers/net/fs_enet/fs_enet-main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/fs_enet/fs_enet-main.c +2 -0
@@ -697,6 +697,8 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) sc |=BD_ENET_TX_PAD ;CBDS_SC (bdp, sc); +skb_tx_timestamp (skb); + (*fep->ops->tx_kickstart)(dev);spin_unlock_irqrestore (&fep->tx_lock, flags);
Signature · 1 line
1.7.0.4
PATCH v2 8/11 smsc911x: enable transmit time stamping.
In reply to Richard CochranThis patch enables software (and phy device) transmit time stamping. Compile tested only.
--- drivers/net/smsc911x.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/smsc911x.c +1 -0
@@ -1473,6 +1473,7 @@ static int smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) pdata->ops->tx_writefifo (pdata, (unsigned int *)bufp, wrsz); freespace -= (skb->len +32 ); +skb_tx_timestamp (skb);dev_kfree_skb (skb);if (unlikely (smsc911x_tx_get_txstatcount (pdata) >=30 ))
Signature · 1 line
1.7.0.4
PATCH v2 9/11 pxa168_eth: enable transmit time stamping.
In reply to Richard CochranThis patch enables software (and phy device) transmit time stamping Compile tested only.
--- drivers/net/pxa168_eth.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/pxa168_eth.c +3 -0
@@ -1267,6 +1267,9 @@ static int pxa168_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) pep->tx_skb[tx_index] = skb; desc->byte_cnt = length; desc->buf_ptr =dma_map_single (NULL , skb->data, length,DMA_TO_DEVICE ); + +skb_tx_timestamp (skb); +wmb (); desc->cmd_sts =BUF_OWNED_BY_DMA |TX_GEN_CRC |TX_FIRST_DESC |TX_ZERO_PADDING |TX_LAST_DESC |TX_EN_INT ;
Signature · 1 line
1.7.0.4
PATCH v2 10/11 mv643xx_eth: enable transmit time stamping.
In reply to Richard CochranThis patch enables software (and phy device) transmit time stamping. Compile tested only.
--- drivers/net/mv643xx_eth.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/mv643xx_eth.c +2 -0
@@ -847,6 +847,8 @@ no_csum:/* clear TX_END status */ mp->work_tx_end &= ~(1 << txq->index); +skb_tx_timestamp (skb); +/* ensure all descriptors are written before poking hardware */ wmb ();txq_enable (txq);
Signature · 1 line
1.7.0.4
PATCH v2 11/11 ucc_geth: enable transmit time stamping.
In reply to Richard CochranThis patch enables software (and phy device) transmit time stamping. Compile tested only.
--- drivers/net/ucc_geth.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/ucc_geth.c +2 -0
@@ -3165,6 +3165,8 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev) ugeth->txBd[txQ] = bd; +skb_tx_timestamp (skb); +if (ugeth->p_scheduler) { ugeth->cpucount[txQ]++;/* Indicate to QE that there are more Tx bds ready for
Signature · 1 line
1.7.0.4
PATCH v2 3/11 emaclite: enable transmit and receive time stamping.
In reply to Richard CochranThis 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.
--- drivers/net/xilinx_emaclite.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/xilinx_emaclite.c +7 -2
@@ -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 -* defer the skb for transmission at a later point when the +* defer the skb for transmission during the ISR, after the * current transmission is complete */ netif_stop_queue (dev); lp->deferred_skb = new_skb; +/* Take the time stamp now, since we can't do this in an ISR. */ +skb_tx_timestamp (new_skb);spin_unlock_irqrestore (&lp->reset_lock, flags);return 0 ; }spin_unlock_irqrestore (&lp->reset_lock, flags); +skb_tx_timestamp (new_skb); + dev->stats.tx_bytes += len;dev_kfree_skb (new_skb);
Signature · 1 line
1.7.0.4