Skip to content

Commit 82fd151

Browse files
shailend-gdavem330
authored andcommitted
gve: Reduce alloc and copy costs in the GQ rx path
Previously, even if just one of the many fragments of a 9k packet required a copy, we'd copy the whole packet into a freshly-allocated 9k-sized linear SKB, and this led to performance issues. By having a pool of pages to copy into, each fragment can be independently handled, leading to a reduced incidence of allocation and copy. Signed-off-by: Shailend Chand <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d08b0f8 commit 82fd151

File tree

6 files changed

+338
-266
lines changed

6 files changed

+338
-266
lines changed

drivers/net/ethernet/google/gve/gve.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ struct gve_rx_slot_page_info {
6060
void *page_address;
6161
u32 page_offset; /* offset to write to in page */
6262
int pagecnt_bias; /* expected pagecnt if only the driver has a ref */
63-
u8 can_flip;
63+
u16 pad; /* adjustment for rx padding */
64+
u8 can_flip; /* tracks if the networking stack is using the page */
6465
};
6566

6667
/* A list of pages registered with the device during setup and used by a queue
@@ -149,10 +150,17 @@ struct gve_rx_ctx {
149150
/* head and tail of skb chain for the current packet or NULL if none */
150151
struct sk_buff *skb_head;
151152
struct sk_buff *skb_tail;
152-
u16 total_expected_size;
153-
u8 expected_frag_cnt;
154-
u8 curr_frag_cnt;
155-
u8 reuse_frags;
153+
u32 total_size;
154+
u8 frag_cnt;
155+
bool drop_pkt;
156+
};
157+
158+
struct gve_rx_cnts {
159+
u32 ok_pkt_bytes;
160+
u16 ok_pkt_cnt;
161+
u16 total_pkt_cnt;
162+
u16 cont_pkt_cnt;
163+
u16 desc_err_pkt_cnt;
156164
};
157165

158166
/* Contains datapath state used to represent an RX queue. */
@@ -167,6 +175,10 @@ struct gve_rx_ring {
167175
/* threshold for posting new buffs and descs */
168176
u32 db_threshold;
169177
u16 packet_buffer_size;
178+
179+
u32 qpl_copy_pool_mask;
180+
u32 qpl_copy_pool_head;
181+
struct gve_rx_slot_page_info *qpl_copy_pool;
170182
};
171183

172184
/* DQO fields. */
@@ -216,7 +228,9 @@ struct gve_rx_ring {
216228
u64 rx_desc_err_dropped_pkt; /* free-running count of packets dropped by descriptor error */
217229
u64 rx_cont_packet_cnt; /* free-running multi-fragment packets received */
218230
u64 rx_frag_flip_cnt; /* free-running count of rx segments where page_flip was used */
219-
u64 rx_frag_copy_cnt; /* free-running count of rx segments copied into skb linear portion */
231+
u64 rx_frag_copy_cnt; /* free-running count of rx segments copied */
232+
u64 rx_frag_alloc_cnt; /* free-running count of rx page allocations */
233+
220234
u32 q_num; /* queue index */
221235
u32 ntfy_id; /* notification block index */
222236
struct gve_queue_resources *q_resources; /* head and tail pointer idx */

drivers/net/ethernet/google/gve/gve_ethtool.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static const char gve_gstrings_main_stats[][ETH_GSTRING_LEN] = {
4545
static const char gve_gstrings_rx_stats[][ETH_GSTRING_LEN] = {
4646
"rx_posted_desc[%u]", "rx_completed_desc[%u]", "rx_consumed_desc[%u]", "rx_bytes[%u]",
4747
"rx_cont_packet_cnt[%u]", "rx_frag_flip_cnt[%u]", "rx_frag_copy_cnt[%u]",
48+
"rx_frag_alloc_cnt[%u]",
4849
"rx_dropped_pkt[%u]", "rx_copybreak_pkt[%u]", "rx_copied_pkt[%u]",
4950
"rx_queue_drop_cnt[%u]", "rx_no_buffers_posted[%u]",
5051
"rx_drops_packet_over_mru[%u]", "rx_drops_invalid_checksum[%u]",
@@ -271,6 +272,7 @@ gve_get_ethtool_stats(struct net_device *netdev,
271272
data[i++] = rx->rx_cont_packet_cnt;
272273
data[i++] = rx->rx_frag_flip_cnt;
273274
data[i++] = rx->rx_frag_copy_cnt;
275+
data[i++] = rx->rx_frag_alloc_cnt;
274276
/* rx dropped packets */
275277
data[i++] = tmp_rx_skb_alloc_fail +
276278
tmp_rx_buf_alloc_fail +

0 commit comments

Comments
 (0)