Skip to content

Commit a27e6e7

Browse files
Andre Guedesanguy11
authored andcommitted
igc: Introduce TX/RX stats helpers
In preparation for AF_XDP zero-copy support, encapsulate the code that updates the driver RX stats in its own local helper so it can be reused in the zero-copy path. Likewise, encapsulate TX stats code as well. Signed-off-by: Andre Guedes <[email protected]> Signed-off-by: Vedang Patel <[email protected]> Signed-off-by: Jithu Joseph <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Tested-by: Dvora Fuxbrumer <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 4609ffb commit a27e6e7

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,20 @@ static void igc_finalize_xdp(struct igc_adapter *adapter, int status)
21112111
xdp_do_flush();
21122112
}
21132113

2114+
static void igc_update_rx_stats(struct igc_q_vector *q_vector,
2115+
unsigned int packets, unsigned int bytes)
2116+
{
2117+
struct igc_ring *ring = q_vector->rx.ring;
2118+
2119+
u64_stats_update_begin(&ring->rx_syncp);
2120+
ring->rx_stats.packets += packets;
2121+
ring->rx_stats.bytes += bytes;
2122+
u64_stats_update_end(&ring->rx_syncp);
2123+
2124+
q_vector->rx.total_packets += packets;
2125+
q_vector->rx.total_bytes += bytes;
2126+
}
2127+
21142128
static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
21152129
{
21162130
unsigned int total_bytes = 0, total_packets = 0;
@@ -2231,19 +2245,28 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
22312245
/* place incomplete frames back on ring for completion */
22322246
rx_ring->skb = skb;
22332247

2234-
u64_stats_update_begin(&rx_ring->rx_syncp);
2235-
rx_ring->rx_stats.packets += total_packets;
2236-
rx_ring->rx_stats.bytes += total_bytes;
2237-
u64_stats_update_end(&rx_ring->rx_syncp);
2238-
q_vector->rx.total_packets += total_packets;
2239-
q_vector->rx.total_bytes += total_bytes;
2248+
igc_update_rx_stats(q_vector, total_packets, total_bytes);
22402249

22412250
if (cleaned_count)
22422251
igc_alloc_rx_buffers(rx_ring, cleaned_count);
22432252

22442253
return total_packets;
22452254
}
22462255

2256+
static void igc_update_tx_stats(struct igc_q_vector *q_vector,
2257+
unsigned int packets, unsigned int bytes)
2258+
{
2259+
struct igc_ring *ring = q_vector->tx.ring;
2260+
2261+
u64_stats_update_begin(&ring->tx_syncp);
2262+
ring->tx_stats.bytes += bytes;
2263+
ring->tx_stats.packets += packets;
2264+
u64_stats_update_end(&ring->tx_syncp);
2265+
2266+
q_vector->tx.total_bytes += bytes;
2267+
q_vector->tx.total_packets += packets;
2268+
}
2269+
22472270
/**
22482271
* igc_clean_tx_irq - Reclaim resources after transmit completes
22492272
* @q_vector: pointer to q_vector containing needed info
@@ -2346,12 +2369,8 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)
23462369

23472370
i += tx_ring->count;
23482371
tx_ring->next_to_clean = i;
2349-
u64_stats_update_begin(&tx_ring->tx_syncp);
2350-
tx_ring->tx_stats.bytes += total_bytes;
2351-
tx_ring->tx_stats.packets += total_packets;
2352-
u64_stats_update_end(&tx_ring->tx_syncp);
2353-
q_vector->tx.total_bytes += total_bytes;
2354-
q_vector->tx.total_packets += total_packets;
2372+
2373+
igc_update_tx_stats(q_vector, total_packets, total_bytes);
23552374

23562375
if (test_bit(IGC_RING_FLAG_TX_DETECT_HANG, &tx_ring->flags)) {
23572376
struct igc_hw *hw = &adapter->hw;

0 commit comments

Comments
 (0)