Skip to content

Commit e486bdf

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
i40e/i40evf: Add txring_txq function to match fm10k and ixgbe
This patch adds a txring_txq function which allows us to convert a i40e_ring/i40evf_ring to a netdev_tx_queue structure. This way we can avoid having to make a multi-line function call for all the spots that need access to this. Change-ID: Ic063b71d8b92ea406d2c32e798c8e2b02809d65b Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 64bfd68 commit e486bdf

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,7 @@ void i40e_clean_tx_ring(struct i40e_ring *tx_ring)
584584
return;
585585

586586
/* cleanup Tx queue statistics */
587-
netdev_tx_reset_queue(netdev_get_tx_queue(tx_ring->netdev,
588-
tx_ring->queue_index));
587+
netdev_tx_reset_queue(txring_txq(tx_ring));
589588
}
590589

591590
/**
@@ -754,8 +753,8 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
754753
tx_ring->arm_wb = true;
755754
}
756755

757-
netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev,
758-
tx_ring->queue_index),
756+
/* notify netdev of completed buffers */
757+
netdev_tx_completed_queue(txring_txq(tx_ring),
759758
total_packets, total_bytes);
760759

761760
#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2)
@@ -2784,9 +2783,7 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
27842783

27852784
tx_ring->next_to_use = i;
27862785

2787-
netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev,
2788-
tx_ring->queue_index),
2789-
first->bytecount);
2786+
netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount);
27902787
i40e_maybe_stop_tx(tx_ring, DESC_NEEDED);
27912788

27922789
/* Algorithm to optimize tail and RS bit setting:
@@ -2811,13 +2808,11 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
28112808
* trigger a force WB.
28122809
*/
28132810
if (skb->xmit_more &&
2814-
!netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2815-
tx_ring->queue_index))) {
2811+
!netif_xmit_stopped(txring_txq(tx_ring))) {
28162812
tx_ring->flags |= I40E_TXR_FLAGS_LAST_XMIT_MORE_SET;
28172813
tail_bump = false;
28182814
} else if (!skb->xmit_more &&
2819-
!netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2820-
tx_ring->queue_index)) &&
2815+
!netif_xmit_stopped(txring_txq(tx_ring)) &&
28212816
(!(tx_ring->flags & I40E_TXR_FLAGS_LAST_XMIT_MORE_SET)) &&
28222817
(tx_ring->packet_stride < WB_STRIDE) &&
28232818
(desc_count < WB_STRIDE)) {

drivers/net/ethernet/intel/i40e/i40e_txrx.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,13 @@ static inline bool i40e_rx_is_fcoe(u16 ptype)
463463
return (ptype >= I40E_RX_PTYPE_L2_FCOE_PAY3) &&
464464
(ptype <= I40E_RX_PTYPE_L2_FCOE_VFT_FCOTHER);
465465
}
466+
467+
/**
468+
* txring_txq - Find the netdev Tx ring based on the i40e Tx ring
469+
* @ring: Tx ring to find the netdev equivalent of
470+
**/
471+
static inline struct netdev_queue *txring_txq(const struct i40e_ring *ring)
472+
{
473+
return netdev_get_tx_queue(ring->netdev, ring->queue_index);
474+
}
466475
#endif /* _I40E_TXRX_H_ */

drivers/net/ethernet/intel/i40evf/i40e_txrx.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ void i40evf_clean_tx_ring(struct i40e_ring *tx_ring)
103103
return;
104104

105105
/* cleanup Tx queue statistics */
106-
netdev_tx_reset_queue(netdev_get_tx_queue(tx_ring->netdev,
107-
tx_ring->queue_index));
106+
netdev_tx_reset_queue(txring_txq(tx_ring));
108107
}
109108

110109
/**
@@ -273,8 +272,8 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
273272
tx_ring->arm_wb = true;
274273
}
275274

276-
netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev,
277-
tx_ring->queue_index),
275+
/* notify netdev of completed buffers */
276+
netdev_tx_completed_queue(txring_txq(tx_ring),
278277
total_packets, total_bytes);
279278

280279
#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2)
@@ -2012,9 +2011,7 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
20122011

20132012
tx_ring->next_to_use = i;
20142013

2015-
netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev,
2016-
tx_ring->queue_index),
2017-
first->bytecount);
2014+
netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount);
20182015
i40e_maybe_stop_tx(tx_ring, DESC_NEEDED);
20192016

20202017
/* Algorithm to optimize tail and RS bit setting:
@@ -2039,13 +2036,11 @@ static inline void i40evf_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
20392036
* trigger a force WB.
20402037
*/
20412038
if (skb->xmit_more &&
2042-
!netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2043-
tx_ring->queue_index))) {
2039+
!netif_xmit_stopped(txring_txq(tx_ring))) {
20442040
tx_ring->flags |= I40E_TXR_FLAGS_LAST_XMIT_MORE_SET;
20452041
tail_bump = false;
20462042
} else if (!skb->xmit_more &&
2047-
!netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2048-
tx_ring->queue_index)) &&
2043+
!netif_xmit_stopped(txring_txq(tx_ring)) &&
20492044
(!(tx_ring->flags & I40E_TXR_FLAGS_LAST_XMIT_MORE_SET)) &&
20502045
(tx_ring->packet_stride < WB_STRIDE) &&
20512046
(desc_count < WB_STRIDE)) {

drivers/net/ethernet/intel/i40evf/i40e_txrx.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,13 @@ static inline bool i40e_rx_is_fcoe(u16 ptype)
445445
return (ptype >= I40E_RX_PTYPE_L2_FCOE_PAY3) &&
446446
(ptype <= I40E_RX_PTYPE_L2_FCOE_VFT_FCOTHER);
447447
}
448+
449+
/**
450+
* txring_txq - Find the netdev Tx ring based on the i40e Tx ring
451+
* @ring: Tx ring to find the netdev equivalent of
452+
**/
453+
static inline struct netdev_queue *txring_txq(const struct i40e_ring *ring)
454+
{
455+
return netdev_get_tx_queue(ring->netdev, ring->queue_index);
456+
}
448457
#endif /* _I40E_TXRX_H_ */

0 commit comments

Comments
 (0)