aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-05-26 01:58:01 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-26 01:58:01 -0400
commit08baf561083bc27a953aa087dd8a664bb2b88e8e (patch)
tree979d92224e21b69368a27bb684b74b3d4d744183
parent65ac8851490ec97a96759af729132c96f925a795 (diff)
net: txq_trans_update() helper
We would like to get rid of netdev->trans_start = jiffies; that about all net drivers have to use in their start_xmit() function, and use txq->trans_start instead. This can be done generically in core network, as suggested by David. Some devices, (particularly loopback) dont need trans_start update, because they dont have transmit watchdog. We could add a new device flag, or rely on fact that txq->tran_start can be updated is txq->xmit_lock_owner is different than -1. Use a helper function to hide our choice. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h6
-rw-r--r--net/core/dev.c3
-rw-r--r--net/core/netpoll.c5
-rw-r--r--net/core/pktgen.c1
-rw-r--r--net/sched/sch_teql.c1
5 files changed, 15 insertions, 1 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ae3c2099a04b..586b71f0358c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1674,6 +1674,12 @@ static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
1674 spin_unlock_bh(&txq->_xmit_lock); 1674 spin_unlock_bh(&txq->_xmit_lock);
1675} 1675}
1676 1676
1677static inline void txq_trans_update(struct netdev_queue *txq)
1678{
1679 if (txq->xmit_lock_owner != -1)
1680 txq->trans_start = jiffies;
1681}
1682
1677/** 1683/**
1678 * netif_tx_lock - grab network device transmit lock 1684 * netif_tx_lock - grab network device transmit lock
1679 * @dev: network device 1685 * @dev: network device
diff --git a/net/core/dev.c b/net/core/dev.c
index 241613f6dd2f..5eb3e48ab31d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1698,6 +1698,8 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
1698 skb->dst = NULL; 1698 skb->dst = NULL;
1699 } 1699 }
1700 rc = ops->ndo_start_xmit(skb, dev); 1700 rc = ops->ndo_start_xmit(skb, dev);
1701 if (rc == 0)
1702 txq_trans_update(txq);
1701 /* 1703 /*
1702 * TODO: if skb_orphan() was called by 1704 * TODO: if skb_orphan() was called by
1703 * dev->hard_start_xmit() (for example, the unmodified 1705 * dev->hard_start_xmit() (for example, the unmodified
@@ -1727,6 +1729,7 @@ gso:
1727 skb->next = nskb; 1729 skb->next = nskb;
1728 return rc; 1730 return rc;
1729 } 1731 }
1732 txq_trans_update(txq);
1730 if (unlikely(netif_tx_queue_stopped(txq) && skb->next)) 1733 if (unlikely(netif_tx_queue_stopped(txq) && skb->next))
1731 return NETDEV_TX_BUSY; 1734 return NETDEV_TX_BUSY;
1732 } while (skb->next); 1735 } while (skb->next);
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 67b4f3e3d4a5..7ab31a7576a1 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -302,8 +302,11 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
302 for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; 302 for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
303 tries > 0; --tries) { 303 tries > 0; --tries) {
304 if (__netif_tx_trylock(txq)) { 304 if (__netif_tx_trylock(txq)) {
305 if (!netif_tx_queue_stopped(txq)) 305 if (!netif_tx_queue_stopped(txq)) {
306 status = ops->ndo_start_xmit(skb, dev); 306 status = ops->ndo_start_xmit(skb, dev);
307 if (status == NETDEV_TX_OK)
308 txq_trans_update(txq);
309 }
307 __netif_tx_unlock(txq); 310 __netif_tx_unlock(txq);
308 311
309 if (status == NETDEV_TX_OK) 312 if (status == NETDEV_TX_OK)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 0666a827bc62..b8ccd3c88d63 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3438,6 +3438,7 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
3438 retry_now: 3438 retry_now:
3439 ret = (*xmit)(pkt_dev->skb, odev); 3439 ret = (*xmit)(pkt_dev->skb, odev);
3440 if (likely(ret == NETDEV_TX_OK)) { 3440 if (likely(ret == NETDEV_TX_OK)) {
3441 txq_trans_update(txq);
3441 pkt_dev->last_ok = 1; 3442 pkt_dev->last_ok = 1;
3442 pkt_dev->sofar++; 3443 pkt_dev->sofar++;
3443 pkt_dev->seq_num++; 3444 pkt_dev->seq_num++;
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 428a5ef5b944..a886496bdc3a 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -308,6 +308,7 @@ restart:
308 if (!netif_tx_queue_stopped(slave_txq) && 308 if (!netif_tx_queue_stopped(slave_txq) &&
309 !netif_tx_queue_frozen(slave_txq) && 309 !netif_tx_queue_frozen(slave_txq) &&
310 slave_ops->ndo_start_xmit(skb, slave) == 0) { 310 slave_ops->ndo_start_xmit(skb, slave) == 0) {
311 txq_trans_update(slave_txq);
311 __netif_tx_unlock(slave_txq); 312 __netif_tx_unlock(slave_txq);
312 master->slaves = NEXT_SLAVE(q); 313 master->slaves = NEXT_SLAVE(q);
313 netif_wake_queue(dev); 314 netif_wake_queue(dev);