Skip to content

Commit 37149e9

Browse files
DavMiladavem330
authored andcommitted
gve: Implement packet continuation for RX.
This enables the driver to receive RX packets spread across multiple buffers: For a given multi-fragment packet the "packet continuation" bit is set on all descriptors except the last one. These descriptors' payloads are combined into a single SKB before the SKB is handed to the networking stack. This change adds a "packet buffer size" notion for RX queues. The CreateRxQueue AdminQueue command sent to the device now includes the packet_buffer_size. We opt for a packet_buffer_size of PAGE_SIZE / 2 to give the driver the opportunity to flip pages where we can instead of copying. Signed-off-by: David Awogbemila <[email protected]> Signed-off-by: Jeroen de Borst <[email protected]> Reviewed-by: Catherine Sullivan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1344e75 commit 37149e9

File tree

9 files changed

+292
-126
lines changed

9 files changed

+292
-126
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ struct gve_rx_ctx {
149149
/* head and tail of skb chain for the current packet or NULL if none */
150150
struct sk_buff *skb_head;
151151
struct sk_buff *skb_tail;
152+
u16 total_expected_size;
153+
u8 expected_frag_cnt;
154+
u8 curr_frag_cnt;
155+
u8 reuse_frags;
152156
};
153157

154158
/* Contains datapath state used to represent an RX queue. */
@@ -162,6 +166,7 @@ struct gve_rx_ring {
162166

163167
/* threshold for posting new buffs and descs */
164168
u32 db_threshold;
169+
u16 packet_buffer_size;
165170
};
166171

167172
/* DQO fields. */
@@ -209,6 +214,9 @@ struct gve_rx_ring {
209214
u64 rx_skb_alloc_fail; /* free-running count of skb alloc fails */
210215
u64 rx_buf_alloc_fail; /* free-running count of buffer alloc fails */
211216
u64 rx_desc_err_dropped_pkt; /* free-running count of packets dropped by descriptor error */
217+
u64 rx_cont_packet_cnt; /* free-running multi-fragment packets received */
218+
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 */
212220
u32 q_num; /* queue index */
213221
u32 ntfy_id; /* notification block index */
214222
struct gve_queue_resources *q_resources; /* head and tail pointer idx */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
530530
cpu_to_be64(rx->data.data_bus),
531531
cmd.create_rx_queue.index = cpu_to_be32(queue_index);
532532
cmd.create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
533+
cmd.create_rx_queue.packet_buffer_size = cpu_to_be16(rx->packet_buffer_size);
533534
} else {
534535
cmd.create_rx_queue.rx_ring_size =
535536
cpu_to_be16(priv->rx_desc_cnt);

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ union gve_rx_data_slot {
9090

9191
/* GVE Recive Packet Descriptor Flags */
9292
#define GVE_RXFLG(x) cpu_to_be16(1 << (3 + (x)))
93-
#define GVE_RXF_FRAG GVE_RXFLG(3) /* IP Fragment */
94-
#define GVE_RXF_IPV4 GVE_RXFLG(4) /* IPv4 */
95-
#define GVE_RXF_IPV6 GVE_RXFLG(5) /* IPv6 */
96-
#define GVE_RXF_TCP GVE_RXFLG(6) /* TCP Packet */
97-
#define GVE_RXF_UDP GVE_RXFLG(7) /* UDP Packet */
98-
#define GVE_RXF_ERR GVE_RXFLG(8) /* Packet Error Detected */
93+
#define GVE_RXF_FRAG GVE_RXFLG(3) /* IP Fragment */
94+
#define GVE_RXF_IPV4 GVE_RXFLG(4) /* IPv4 */
95+
#define GVE_RXF_IPV6 GVE_RXFLG(5) /* IPv6 */
96+
#define GVE_RXF_TCP GVE_RXFLG(6) /* TCP Packet */
97+
#define GVE_RXF_UDP GVE_RXFLG(7) /* UDP Packet */
98+
#define GVE_RXF_ERR GVE_RXFLG(8) /* Packet Error Detected */
99+
#define GVE_RXF_PKT_CONT GVE_RXFLG(10) /* Multi Fragment RX packet */
99100

100101
/* GVE IRQ */
101102
#define GVE_IRQ_ACK BIT(31)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static const char gve_gstrings_main_stats[][ETH_GSTRING_LEN] = {
4343

4444
static const char gve_gstrings_rx_stats[][ETH_GSTRING_LEN] = {
4545
"rx_posted_desc[%u]", "rx_completed_desc[%u]", "rx_bytes[%u]",
46+
"rx_cont_packet_cnt[%u]", "rx_frag_flip_cnt[%u]", "rx_frag_copy_cnt[%u]",
4647
"rx_dropped_pkt[%u]", "rx_copybreak_pkt[%u]", "rx_copied_pkt[%u]",
4748
"rx_queue_drop_cnt[%u]", "rx_no_buffers_posted[%u]",
4849
"rx_drops_packet_over_mru[%u]", "rx_drops_invalid_checksum[%u]",
@@ -265,6 +266,9 @@ gve_get_ethtool_stats(struct net_device *netdev,
265266
} while (u64_stats_fetch_retry(&priv->rx[ring].statss,
266267
start));
267268
data[i++] = tmp_rx_bytes;
269+
data[i++] = rx->rx_cont_packet_cnt;
270+
data[i++] = rx->rx_frag_flip_cnt;
271+
data[i++] = rx->rx_frag_copy_cnt;
268272
/* rx dropped packets */
269273
data[i++] = tmp_rx_skb_alloc_fail +
270274
tmp_rx_buf_alloc_fail +

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,14 +1371,6 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
13711371
"Could not get device information: err=%d\n", err);
13721372
goto err;
13731373
}
1374-
if (gve_is_gqi(priv) && priv->dev->max_mtu > PAGE_SIZE) {
1375-
priv->dev->max_mtu = PAGE_SIZE;
1376-
err = gve_adminq_set_mtu(priv, priv->dev->mtu);
1377-
if (err) {
1378-
dev_err(&priv->pdev->dev, "Could not set mtu");
1379-
goto err;
1380-
}
1381-
}
13821374
priv->dev->mtu = priv->dev->max_mtu;
13831375
num_ntfy = pci_msix_vec_count(priv->pdev);
13841376
if (num_ntfy <= 0) {

0 commit comments

Comments
 (0)