Skip to content

Commit cccfc84

Browse files
rushil-googlevijay-suman
authored andcommitted
gve: Tx path for DQO-QPL
Each QPL page is divided into GVE_TX_BUFS_PER_PAGE_DQO buffers. When a packet needs to be transmitted, we break the packet into max GVE_TX_BUF_SIZE_DQO sized chunks and transmit each chunk using a TX descriptor. We allocate the TX buffers from the free list in dqo_tx. We store these TX buffer indices in an array in the pending_packet structure. The TX buffers are returned to the free list in dqo_compl after receiving packet completion or when removing packets from miss completions list. Signed-off-by: Rushil Gupta <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Praveen Kaligineedi <[email protected]> Signed-off-by: Bailey Forrest <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit a6fb8d5) Orabug: 37356729 Signed-off-by: Yifei Liu <[email protected]> Reviewed-by: Saeed Mirzamohammadi <[email protected]> Conflicts: drivers/net/ethernet/google/gve/gve_tx_dqo.c Difference in the deleted parts in gve_tx_add_skb_no_copy_dqo. Some code base difference different due to missing content between v5.15 and v6.5, solve them by reference from the google cos 5.15 branch. Signed-off-by: Saeed Mirzamohammadi <[email protected]> Signed-off-by: Vijayendra Suman <[email protected]>
1 parent a275c58 commit cccfc84

File tree

2 files changed

+393
-84
lines changed

2 files changed

+393
-84
lines changed

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

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@
5555
/* Maximum TSO size supported on DQO */
5656
#define GVE_DQO_TX_MAX 0x3FFFF
5757

58+
#define GVE_TX_BUF_SHIFT_DQO 11
59+
60+
/* 2K buffers for DQO-QPL */
61+
#define GVE_TX_BUF_SIZE_DQO BIT(GVE_TX_BUF_SHIFT_DQO)
62+
#define GVE_TX_BUFS_PER_PAGE_DQO (PAGE_SIZE >> GVE_TX_BUF_SHIFT_DQO)
63+
#define GVE_MAX_TX_BUFS_PER_PKT (DIV_ROUND_UP(GVE_DQO_TX_MAX, GVE_TX_BUF_SIZE_DQO))
64+
65+
/* If number of free/recyclable buffers are less than this threshold; driver
66+
* allocs and uses a non-qpl page on the receive path of DQO QPL to free
67+
* up buffers.
68+
* Value is set big enough to post at least 3 64K LRO packet via 2K buffer to NIC.
69+
*/
70+
#define GVE_DQO_QPL_ONDEMAND_ALLOC_THRESHOLD 96
71+
5872
/* Each slot in the desc ring has a 1:1 mapping to a slot in the data ring */
5973
struct gve_rx_desc_queue {
6074
struct gve_rx_desc *desc_ring; /* the descriptor ring */
@@ -319,8 +333,14 @@ struct gve_tx_pending_packet_dqo {
319333
* All others correspond to `skb`'s frags and should be unmapped with
320334
* `dma_unmap_page`.
321335
*/
322-
DEFINE_DMA_UNMAP_ADDR(dma[MAX_SKB_FRAGS + 1]);
323-
DEFINE_DMA_UNMAP_LEN(len[MAX_SKB_FRAGS + 1]);
336+
union {
337+
struct {
338+
DEFINE_DMA_UNMAP_ADDR(dma[MAX_SKB_FRAGS + 1]);
339+
DEFINE_DMA_UNMAP_LEN(len[MAX_SKB_FRAGS + 1]);
340+
};
341+
s16 tx_qpl_buf_ids[GVE_MAX_TX_BUFS_PER_PKT];
342+
};
343+
324344
u16 num_bufs;
325345

326346
/* Linked list index to next element in the list, or -1 if none */
@@ -375,6 +395,32 @@ struct gve_tx_ring {
375395
* set.
376396
*/
377397
u32 last_re_idx;
398+
399+
/* free running number of packet buf descriptors posted */
400+
u16 posted_packet_desc_cnt;
401+
/* free running number of packet buf descriptors completed */
402+
u16 completed_packet_desc_cnt;
403+
404+
/* QPL fields */
405+
struct {
406+
/* Linked list of gve_tx_buf_dqo. Index into
407+
* tx_qpl_buf_next, or -1 if empty.
408+
*
409+
* This is a consumer list owned by the TX path. When it
410+
* runs out, the producer list is stolen from the
411+
* completion handling path
412+
* (dqo_compl.free_tx_qpl_buf_head).
413+
*/
414+
s16 free_tx_qpl_buf_head;
415+
416+
/* Free running count of the number of QPL tx buffers
417+
* allocated
418+
*/
419+
u32 alloc_tx_qpl_buf_cnt;
420+
421+
/* Cached value of `dqo_compl.free_tx_qpl_buf_cnt` */
422+
u32 free_tx_qpl_buf_cnt;
423+
};
378424
} dqo_tx;
379425
};
380426

@@ -416,6 +462,24 @@ struct gve_tx_ring {
416462
* reached a specified timeout.
417463
*/
418464
struct gve_index_list timed_out_completions;
465+
466+
/* QPL fields */
467+
struct {
468+
/* Linked list of gve_tx_buf_dqo. Index into
469+
* tx_qpl_buf_next, or -1 if empty.
470+
*
471+
* This is the producer list, owned by the completion
472+
* handling path. When the consumer list
473+
* (dqo_tx.free_tx_qpl_buf_head) is runs out, this list
474+
* will be stolen.
475+
*/
476+
atomic_t free_tx_qpl_buf_head;
477+
478+
/* Free running count of the number of tx buffers
479+
* freed
480+
*/
481+
atomic_t free_tx_qpl_buf_cnt;
482+
};
419483
} dqo_compl;
420484
} ____cacheline_aligned;
421485
u64 pkt_done; /* free-running - total packets completed */
@@ -447,6 +511,15 @@ struct gve_tx_ring {
447511
struct {
448512
/* qpl assigned to this queue */
449513
struct gve_queue_page_list *qpl;
514+
515+
/* Each QPL page is divided into TX bounce buffers
516+
* of size GVE_TX_BUF_SIZE_DQO. tx_qpl_buf_next is
517+
* an array to manage linked lists of TX buffers.
518+
* An entry j at index i implies that j'th buffer
519+
* is next on the list after i
520+
*/
521+
s16 *tx_qpl_buf_next;
522+
u32 num_tx_qpl_bufs;
450523
};
451524
} dqo;
452525
} ____cacheline_aligned;

0 commit comments

Comments
 (0)