Skip to content

Commit aa4725c

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next
-queue Tony Nguyen says: ==================== 40GbE Intel Wired LAN Driver Updates 2022-02-08 Joe Damato says: This patch set makes several updates to the i40e driver stats collection and reporting code to help users of i40e get a better sense of how the driver is performing and interacting with the rest of the kernel. These patches include some new stats (like waived and busy) which were inspired by other drivers that track stats using the same nomenclature. The new stats and an existing stat, rx_reuse, are now accessible with ethtool to make harvesting this data more convenient for users. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 3a5f238 + b76bc12 commit aa4725c

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@ struct i40e_vsi {
854854
u64 tx_force_wb;
855855
u64 rx_buf_failed;
856856
u64 rx_page_failed;
857+
u64 rx_page_reuse;
858+
u64 rx_page_alloc;
859+
u64 rx_page_waive;
860+
u64 rx_page_busy;
857861

858862
/* These are containers of ring pointers, allocated at run-time */
859863
struct i40e_ring **rx_rings;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ static const struct i40e_stats i40e_gstrings_misc_stats[] = {
295295
I40E_VSI_STAT("tx_busy", tx_busy),
296296
I40E_VSI_STAT("rx_alloc_fail", rx_buf_failed),
297297
I40E_VSI_STAT("rx_pg_alloc_fail", rx_page_failed),
298+
I40E_VSI_STAT("rx_cache_reuse", rx_page_reuse),
299+
I40E_VSI_STAT("rx_cache_alloc", rx_page_alloc),
300+
I40E_VSI_STAT("rx_cache_waive", rx_page_waive),
301+
I40E_VSI_STAT("rx_cache_busy", rx_page_busy),
298302
};
299303

300304
/* These PF_STATs might look like duplicates of some NETDEV_STATs,

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,14 @@ void i40e_update_veb_stats(struct i40e_veb *veb)
773773
**/
774774
static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
775775
{
776+
u64 rx_page, rx_buf, rx_reuse, rx_alloc, rx_waive, rx_busy;
776777
struct i40e_pf *pf = vsi->back;
777778
struct rtnl_link_stats64 *ons;
778779
struct rtnl_link_stats64 *ns; /* netdev stats */
779780
struct i40e_eth_stats *oes;
780781
struct i40e_eth_stats *es; /* device's eth stats */
781782
u64 tx_restart, tx_busy;
782783
struct i40e_ring *p;
783-
u64 rx_page, rx_buf;
784784
u64 bytes, packets;
785785
unsigned int start;
786786
u64 tx_linearize;
@@ -806,6 +806,10 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
806806
tx_restart = tx_busy = tx_linearize = tx_force_wb = 0;
807807
rx_page = 0;
808808
rx_buf = 0;
809+
rx_reuse = 0;
810+
rx_alloc = 0;
811+
rx_waive = 0;
812+
rx_busy = 0;
809813
rcu_read_lock();
810814
for (q = 0; q < vsi->num_queue_pairs; q++) {
811815
/* locate Tx ring */
@@ -839,6 +843,10 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
839843
rx_p += packets;
840844
rx_buf += p->rx_stats.alloc_buff_failed;
841845
rx_page += p->rx_stats.alloc_page_failed;
846+
rx_reuse += p->rx_stats.page_reuse_count;
847+
rx_alloc += p->rx_stats.page_alloc_count;
848+
rx_waive += p->rx_stats.page_waive_count;
849+
rx_busy += p->rx_stats.page_busy_count;
842850

843851
if (i40e_enabled_xdp_vsi(vsi)) {
844852
/* locate XDP ring */
@@ -866,6 +874,10 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
866874
vsi->tx_force_wb = tx_force_wb;
867875
vsi->rx_page_failed = rx_page;
868876
vsi->rx_buf_failed = rx_buf;
877+
vsi->rx_page_reuse = rx_reuse;
878+
vsi->rx_page_alloc = rx_alloc;
879+
vsi->rx_page_waive = rx_waive;
880+
vsi->rx_page_busy = rx_busy;
869881

870882
ns->rx_packets = rx_p;
871883
ns->rx_bytes = rx_b;

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,6 @@ static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
13821382
new_buff->page_offset = old_buff->page_offset;
13831383
new_buff->pagecnt_bias = old_buff->pagecnt_bias;
13841384

1385-
rx_ring->rx_stats.page_reuse_count++;
1386-
13871385
/* clear contents of buffer_info */
13881386
old_buff->page = NULL;
13891387
}
@@ -1675,6 +1673,8 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,
16751673
return false;
16761674
}
16771675

1676+
rx_ring->rx_stats.page_alloc_count++;
1677+
16781678
/* map page for use */
16791679
dma = dma_map_page_attrs(rx_ring->dev, page, 0,
16801680
i40e_rx_pg_size(rx_ring),
@@ -1982,32 +1982,43 @@ static bool i40e_cleanup_headers(struct i40e_ring *rx_ring, struct sk_buff *skb,
19821982
/**
19831983
* i40e_can_reuse_rx_page - Determine if page can be reused for another Rx
19841984
* @rx_buffer: buffer containing the page
1985+
* @rx_stats: rx stats structure for the rx ring
19851986
* @rx_buffer_pgcnt: buffer page refcount pre xdp_do_redirect() call
19861987
*
19871988
* If page is reusable, we have a green light for calling i40e_reuse_rx_page,
19881989
* which will assign the current buffer to the buffer that next_to_alloc is
19891990
* pointing to; otherwise, the DMA mapping needs to be destroyed and
1990-
* page freed
1991+
* page freed.
1992+
*
1993+
* rx_stats will be updated to indicate whether the page was waived
1994+
* or busy if it could not be reused.
19911995
*/
19921996
static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,
1997+
struct i40e_rx_queue_stats *rx_stats,
19931998
int rx_buffer_pgcnt)
19941999
{
19952000
unsigned int pagecnt_bias = rx_buffer->pagecnt_bias;
19962001
struct page *page = rx_buffer->page;
19972002

19982003
/* Is any reuse possible? */
1999-
if (!dev_page_is_reusable(page))
2004+
if (!dev_page_is_reusable(page)) {
2005+
rx_stats->page_waive_count++;
20002006
return false;
2007+
}
20012008

20022009
#if (PAGE_SIZE < 8192)
20032010
/* if we are only owner of page we can reuse it */
2004-
if (unlikely((rx_buffer_pgcnt - pagecnt_bias) > 1))
2011+
if (unlikely((rx_buffer_pgcnt - pagecnt_bias) > 1)) {
2012+
rx_stats->page_busy_count++;
20052013
return false;
2014+
}
20062015
#else
20072016
#define I40E_LAST_OFFSET \
20082017
(SKB_WITH_OVERHEAD(PAGE_SIZE) - I40E_RXBUFFER_2048)
2009-
if (rx_buffer->page_offset > I40E_LAST_OFFSET)
2018+
if (rx_buffer->page_offset > I40E_LAST_OFFSET) {
2019+
rx_stats->page_busy_count++;
20102020
return false;
2021+
}
20112022
#endif
20122023

20132024
/* If we have drained the page fragment pool we need to update
@@ -2237,7 +2248,7 @@ static void i40e_put_rx_buffer(struct i40e_ring *rx_ring,
22372248
struct i40e_rx_buffer *rx_buffer,
22382249
int rx_buffer_pgcnt)
22392250
{
2240-
if (i40e_can_reuse_rx_page(rx_buffer, rx_buffer_pgcnt)) {
2251+
if (i40e_can_reuse_rx_page(rx_buffer, &rx_ring->rx_stats, rx_buffer_pgcnt)) {
22412252
/* hand second half of page back to the ring */
22422253
i40e_reuse_rx_page(rx_ring, rx_buffer);
22432254
} else {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ struct i40e_rx_queue_stats {
298298
u64 alloc_page_failed;
299299
u64 alloc_buff_failed;
300300
u64 page_reuse_count;
301+
u64 page_alloc_count;
302+
u64 page_waive_count;
303+
u64 page_busy_count;
301304
};
302305

303306
enum i40e_ring_state_t {

0 commit comments

Comments
 (0)