Skip to content

Commit 08baf56

Browse files
Eric Dumazetdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 65ac885 commit 08baf56

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

include/linux/netdevice.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,12 @@ static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
16741674
spin_unlock_bh(&txq->_xmit_lock);
16751675
}
16761676

1677+
static inline void txq_trans_update(struct netdev_queue *txq)
1678+
{
1679+
if (txq->xmit_lock_owner != -1)
1680+
txq->trans_start = jiffies;
1681+
}
1682+
16771683
/**
16781684
* netif_tx_lock - grab network device transmit lock
16791685
* @dev: network device

net/core/dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,8 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
16981698
skb->dst = NULL;
16991699
}
17001700
rc = ops->ndo_start_xmit(skb, dev);
1701+
if (rc == 0)
1702+
txq_trans_update(txq);
17011703
/*
17021704
* TODO: if skb_orphan() was called by
17031705
* dev->hard_start_xmit() (for example, the unmodified
@@ -1727,6 +1729,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
17271729
skb->next = nskb;
17281730
return rc;
17291731
}
1732+
txq_trans_update(txq);
17301733
if (unlikely(netif_tx_queue_stopped(txq) && skb->next))
17311734
return NETDEV_TX_BUSY;
17321735
} while (skb->next);

net/core/netpoll.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,11 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
302302
for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
303303
tries > 0; --tries) {
304304
if (__netif_tx_trylock(txq)) {
305-
if (!netif_tx_queue_stopped(txq))
305+
if (!netif_tx_queue_stopped(txq)) {
306306
status = ops->ndo_start_xmit(skb, dev);
307+
if (status == NETDEV_TX_OK)
308+
txq_trans_update(txq);
309+
}
307310
__netif_tx_unlock(txq);
308311

309312
if (status == NETDEV_TX_OK)

net/core/pktgen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,6 +3438,7 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
34383438
retry_now:
34393439
ret = (*xmit)(pkt_dev->skb, odev);
34403440
if (likely(ret == NETDEV_TX_OK)) {
3441+
txq_trans_update(txq);
34413442
pkt_dev->last_ok = 1;
34423443
pkt_dev->sofar++;
34433444
pkt_dev->seq_num++;

net/sched/sch_teql.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ static int teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
308308
if (!netif_tx_queue_stopped(slave_txq) &&
309309
!netif_tx_queue_frozen(slave_txq) &&
310310
slave_ops->ndo_start_xmit(skb, slave) == 0) {
311+
txq_trans_update(slave_txq);
311312
__netif_tx_unlock(slave_txq);
312313
master->slaves = NEXT_SLAVE(q);
313314
netif_wake_queue(dev);

0 commit comments

Comments
 (0)