Skip to content

Commit a114d0a

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
i40e: Split bytes and packets from Rx/Tx stats
This makes it so that the Tx and Rx byte and packet counts are separated from the rest of the statistics. This allows for better isolation of these stats when we move them into the 64 bit statistics. Simplify things by re-ordering how the stats display in ethtool. Instead of displaying all of the Tx queues as a block, followed by all the Rx queues, the new order is Tx[0], Rx[0], Tx[1], Rx[1], ..., Tx[n], Rx[n]. This reduces the loops and cleans up the display for testing purposes since it is very easy to verify if flow director is doing the right thing as the Tx and Rx queue pair are shown in pairs. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 7070ce0 commit a114d0a

File tree

5 files changed

+28
-26
lines changed

5 files changed

+28
-26
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
512512
vsi->rx_rings[i].ring_active);
513513
dev_info(&pf->pdev->dev,
514514
" rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n",
515-
i, vsi->rx_rings[i].rx_stats.packets,
516-
vsi->rx_rings[i].rx_stats.bytes,
515+
i, vsi->rx_rings[i].stats.packets,
516+
vsi->rx_rings[i].stats.bytes,
517517
vsi->rx_rings[i].rx_stats.non_eop_descs);
518518
dev_info(&pf->pdev->dev,
519519
" rx_rings[%i]: rx_stats: alloc_rx_page_failed = %lld, alloc_rx_buff_failed = %lld\n",
@@ -556,8 +556,8 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
556556
vsi->tx_rings[i].ring_active);
557557
dev_info(&pf->pdev->dev,
558558
" tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
559-
i, vsi->tx_rings[i].tx_stats.packets,
560-
vsi->tx_rings[i].tx_stats.bytes,
559+
i, vsi->tx_rings[i].stats.packets,
560+
vsi->tx_rings[i].stats.bytes,
561561
vsi->tx_rings[i].tx_stats.restart_queue);
562562
dev_info(&pf->pdev->dev,
563563
" tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,11 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
587587
data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
588588
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
589589
}
590-
for (j = 0; j < vsi->num_queue_pairs; j++) {
591-
data[i++] = vsi->tx_rings[j].tx_stats.packets;
592-
data[i++] = vsi->tx_rings[j].tx_stats.bytes;
593-
}
594-
for (j = 0; j < vsi->num_queue_pairs; j++) {
595-
data[i++] = vsi->rx_rings[j].rx_stats.packets;
596-
data[i++] = vsi->rx_rings[j].rx_stats.bytes;
590+
for (j = 0; j < vsi->num_queue_pairs; j++, i += 4) {
591+
data[i] = vsi->tx_rings[j].stats.packets;
592+
data[i + 1] = vsi->tx_rings[j].stats.bytes;
593+
data[i + 2] = vsi->rx_rings[j].stats.packets;
594+
data[i + 3] = vsi->rx_rings[j].stats.bytes;
597595
}
598596
if (vsi == pf->vsi[pf->lan_vsi]) {
599597
for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
@@ -641,8 +639,6 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,
641639
p += ETH_GSTRING_LEN;
642640
snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
643641
p += ETH_GSTRING_LEN;
644-
}
645-
for (i = 0; i < vsi->num_queue_pairs; i++) {
646642
snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
647643
p += ETH_GSTRING_LEN;
648644
snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,12 @@ void i40e_vsi_reset_stats(struct i40e_vsi *vsi)
376376
memset(&vsi->eth_stats_offsets, 0, sizeof(vsi->eth_stats_offsets));
377377
if (vsi->rx_rings)
378378
for (i = 0; i < vsi->num_queue_pairs; i++) {
379+
memset(&vsi->rx_rings[i].stats, 0 ,
380+
sizeof(vsi->rx_rings[i].stats));
379381
memset(&vsi->rx_rings[i].rx_stats, 0 ,
380382
sizeof(vsi->rx_rings[i].rx_stats));
383+
memset(&vsi->tx_rings[i].stats, 0 ,
384+
sizeof(vsi->tx_rings[i].stats));
381385
memset(&vsi->tx_rings[i].tx_stats, 0,
382386
sizeof(vsi->tx_rings[i].tx_stats));
383387
}
@@ -708,14 +712,14 @@ void i40e_update_stats(struct i40e_vsi *vsi)
708712
struct i40e_ring *p;
709713

710714
p = &vsi->rx_rings[q];
711-
rx_b += p->rx_stats.bytes;
712-
rx_p += p->rx_stats.packets;
715+
rx_b += p->stats.bytes;
716+
rx_p += p->stats.packets;
713717
rx_buf += p->rx_stats.alloc_rx_buff_failed;
714718
rx_page += p->rx_stats.alloc_rx_page_failed;
715719

716720
p = &vsi->tx_rings[q];
717-
tx_b += p->tx_stats.bytes;
718-
tx_p += p->tx_stats.packets;
721+
tx_b += p->stats.bytes;
722+
tx_p += p->stats.packets;
719723
tx_restart += p->tx_stats.restart_queue;
720724
tx_busy += p->tx_stats.tx_busy;
721725
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ static bool i40e_check_tx_hang(struct i40e_ring *tx_ring)
305305
* run the check_tx_hang logic with a transmit completion
306306
* pending but without time to complete it yet.
307307
*/
308-
if ((tx_ring->tx_stats.tx_done_old == tx_ring->tx_stats.packets) &&
308+
if ((tx_ring->tx_stats.tx_done_old == tx_ring->stats.packets) &&
309309
tx_pending) {
310310
/* make sure it is true for two checks in a row */
311311
ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED,
312312
&tx_ring->state);
313313
} else {
314314
/* update completed stats and disarm the hang check */
315-
tx_ring->tx_stats.tx_done_old = tx_ring->tx_stats.packets;
315+
tx_ring->tx_stats.tx_done_old = tx_ring->stats.packets;
316316
clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state);
317317
}
318318

@@ -411,8 +411,8 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
411411

412412
i += tx_ring->count;
413413
tx_ring->next_to_clean = i;
414-
tx_ring->tx_stats.bytes += total_bytes;
415-
tx_ring->tx_stats.packets += total_packets;
414+
tx_ring->stats.bytes += total_bytes;
415+
tx_ring->stats.packets += total_packets;
416416
tx_ring->q_vector->tx.total_bytes += total_bytes;
417417
tx_ring->q_vector->tx.total_packets += total_packets;
418418

@@ -1075,8 +1075,8 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
10751075
}
10761076

10771077
rx_ring->next_to_clean = i;
1078-
rx_ring->rx_stats.packets += total_rx_packets;
1079-
rx_ring->rx_stats.bytes += total_rx_bytes;
1078+
rx_ring->stats.packets += total_rx_packets;
1079+
rx_ring->stats.bytes += total_rx_bytes;
10801080
rx_ring->q_vector->rx.total_packets += total_rx_packets;
10811081
rx_ring->q_vector->rx.total_bytes += total_rx_bytes;
10821082

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,18 @@ struct i40e_rx_buffer {
126126
unsigned int page_offset;
127127
};
128128

129-
struct i40e_tx_queue_stats {
129+
struct i40e_queue_stats {
130130
u64 packets;
131131
u64 bytes;
132+
};
133+
134+
struct i40e_tx_queue_stats {
132135
u64 restart_queue;
133136
u64 tx_busy;
134137
u64 tx_done_old;
135138
};
136139

137140
struct i40e_rx_queue_stats {
138-
u64 packets;
139-
u64 bytes;
140141
u64 non_eop_descs;
141142
u64 alloc_rx_page_failed;
142143
u64 alloc_rx_buff_failed;
@@ -215,6 +216,7 @@ struct i40e_ring {
215216
bool ring_active; /* is ring online or not */
216217

217218
/* stats structs */
219+
struct i40e_queue_stats stats;
218220
union {
219221
struct i40e_tx_queue_stats tx_stats;
220222
struct i40e_rx_queue_stats rx_stats;

0 commit comments

Comments
 (0)