diff options
author | Eric Dumazet <edumazet@google.com> | 2014-10-08 11:19:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-08 16:08:04 -0400 |
commit | 535114539bb2c081b6680cb5a34be17e7b45df37 (patch) | |
tree | f23c322826074ddd2eb0cbb84104210996746570 | |
parent | 709c48b39ecf11a81f3820c13a828c330fd832b9 (diff) |
net: add netdev_txq_bql_{enqueue, complete}_prefetchw() helpers
Add two helpers so that drivers do not have to care of BQL being
available or not.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Jim Davis <jim.epost@gmail.com>
Fixes: 29d40c903247 ("net/mlx4_en: Use prefetch in tx path")
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_tx.c | 5 | ||||
-rw-r--r-- | include/linux/netdevice.h | 29 |
2 files changed, 32 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 8726a4aee5a7..34c137878545 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
@@ -392,7 +392,8 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev, | |||
392 | if (!priv->port_up) | 392 | if (!priv->port_up) |
393 | return true; | 393 | return true; |
394 | 394 | ||
395 | prefetchw(&ring->tx_queue->dql.limit); | 395 | netdev_txq_bql_complete_prefetchw(ring->tx_queue); |
396 | |||
396 | index = cons_index & size_mask; | 397 | index = cons_index & size_mask; |
397 | cqe = mlx4_en_get_cqe(buf, index, priv->cqe_size) + factor; | 398 | cqe = mlx4_en_get_cqe(buf, index, priv->cqe_size) + factor; |
398 | last_nr_txbb = ACCESS_ONCE(ring->last_nr_txbb); | 399 | last_nr_txbb = ACCESS_ONCE(ring->last_nr_txbb); |
@@ -737,7 +738,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
737 | vlan_tag = vlan_tx_tag_get(skb); | 738 | vlan_tag = vlan_tx_tag_get(skb); |
738 | 739 | ||
739 | 740 | ||
740 | prefetchw(&ring->tx_queue->dql); | 741 | netdev_txq_bql_enqueue_prefetchw(ring->tx_queue); |
741 | 742 | ||
742 | /* Track current inflight packets for performance analysis */ | 743 | /* Track current inflight packets for performance analysis */ |
743 | AVG_PERF_COUNTER(priv->pstats.inflight_avg, | 744 | AVG_PERF_COUNTER(priv->pstats.inflight_avg, |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3a4315b39d20..838407aea705 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/bug.h> | 30 | #include <linux/bug.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/atomic.h> | 32 | #include <linux/atomic.h> |
33 | #include <linux/prefetch.h> | ||
33 | #include <asm/cache.h> | 34 | #include <asm/cache.h> |
34 | #include <asm/byteorder.h> | 35 | #include <asm/byteorder.h> |
35 | 36 | ||
@@ -2480,6 +2481,34 @@ netif_xmit_frozen_or_drv_stopped(const struct netdev_queue *dev_queue) | |||
2480 | return dev_queue->state & QUEUE_STATE_DRV_XOFF_OR_FROZEN; | 2481 | return dev_queue->state & QUEUE_STATE_DRV_XOFF_OR_FROZEN; |
2481 | } | 2482 | } |
2482 | 2483 | ||
2484 | /** | ||
2485 | * netdev_txq_bql_enqueue_prefetchw - prefetch bql data for write | ||
2486 | * @dev_queue: pointer to transmit queue | ||
2487 | * | ||
2488 | * BQL enabled drivers might use this helper in their ndo_start_xmit(), | ||
2489 | * to give appropriate hint to the cpu. | ||
2490 | */ | ||
2491 | static inline void netdev_txq_bql_enqueue_prefetchw(struct netdev_queue *dev_queue) | ||
2492 | { | ||
2493 | #ifdef CONFIG_BQL | ||
2494 | prefetchw(&dev_queue->dql.num_queued); | ||
2495 | #endif | ||
2496 | } | ||
2497 | |||
2498 | /** | ||
2499 | * netdev_txq_bql_complete_prefetchw - prefetch bql data for write | ||
2500 | * @dev_queue: pointer to transmit queue | ||
2501 | * | ||
2502 | * BQL enabled drivers might use this helper in their TX completion path, | ||
2503 | * to give appropriate hint to the cpu. | ||
2504 | */ | ||
2505 | static inline void netdev_txq_bql_complete_prefetchw(struct netdev_queue *dev_queue) | ||
2506 | { | ||
2507 | #ifdef CONFIG_BQL | ||
2508 | prefetchw(&dev_queue->dql.limit); | ||
2509 | #endif | ||
2510 | } | ||
2511 | |||
2483 | static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue, | 2512 | static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue, |
2484 | unsigned int bytes) | 2513 | unsigned int bytes) |
2485 | { | 2514 | { |