Skip to content

Commit 0cb4c0a

Browse files
ahduyckkuba-moo
authored andcommitted
eth: fbnic: Implement Rx queue alloc/start/stop/free
Implement control path parts of Rx queue handling. The NIC consumes memory in pages. It takes a full page and places packets into it in a configurable manner (with the ability to define headroom / tailroom as well as head alignment requirements). As mentioned in prior patches there are two page submissions queues one for packet headers and second (optional) for packet payloads. For now feed both queues from a single page pool. Use the page pool "fragment" API, as we can't predict upfront how the page will be sliced. Signed-off-by: Alexander Duyck <[email protected]> Link: https://patch.msgid.link/172079939092.1778861.3780136633831329550.stgit@ahduyck-xeon-server.home.arpa Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 40bf06a commit 0cb4c0a

File tree

6 files changed

+638
-9
lines changed

6 files changed

+638
-9
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_csr.h

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,37 @@
1616

1717
#define FBNIC_CLOCK_FREQ (600 * (1000 * 1000))
1818

19+
/* Rx Buffer Descriptor Format
20+
*
21+
* The layout of this can vary depending on the page size of the system.
22+
*
23+
* If the page size is 4K then the layout will simply consist of ID for
24+
* the 16 most significant bits, and the lower 46 are essentially the page
25+
* address with the lowest 12 bits being reserved 0 due to the fact that
26+
* a page will be aligned.
27+
*
28+
* If the page size is larger than 4K then the lower n bits of the ID and
29+
* page address will be reserved for the fragment ID. This fragment will
30+
* be 4K in size and will be used to index both the DMA address and the ID
31+
* by the same amount.
32+
*/
33+
#define FBNIC_BD_DESC_ADDR_MASK DESC_GENMASK(45, 12)
34+
#define FBNIC_BD_DESC_ID_MASK DESC_GENMASK(63, 48)
35+
#define FBNIC_BD_FRAG_SIZE \
36+
(FBNIC_BD_DESC_ADDR_MASK & ~(FBNIC_BD_DESC_ADDR_MASK - 1))
37+
#define FBNIC_BD_FRAG_COUNT \
38+
(PAGE_SIZE / FBNIC_BD_FRAG_SIZE)
39+
#define FBNIC_BD_FRAG_ADDR_MASK \
40+
(FBNIC_BD_DESC_ADDR_MASK & \
41+
~(FBNIC_BD_DESC_ADDR_MASK * FBNIC_BD_FRAG_COUNT))
42+
#define FBNIC_BD_FRAG_ID_MASK \
43+
(FBNIC_BD_DESC_ID_MASK & \
44+
~(FBNIC_BD_DESC_ID_MASK * FBNIC_BD_FRAG_COUNT))
45+
#define FBNIC_BD_PAGE_ADDR_MASK \
46+
(FBNIC_BD_DESC_ADDR_MASK & ~FBNIC_BD_FRAG_ADDR_MASK)
47+
#define FBNIC_BD_PAGE_ID_MASK \
48+
(FBNIC_BD_DESC_ID_MASK & ~FBNIC_BD_FRAG_ID_MASK)
49+
1950
/* Register Definitions
2051
*
2152
* The registers are laid as indexes into an le32 array. As such the actual
@@ -124,14 +155,14 @@ enum {
124155

125156
/* Global QM Rx registers */
126157
#define FBNIC_CSR_START_QM_RX 0x00c00 /* CSR section delimiter */
127-
#define FBNIC_QM_RCQ_IDLE(n) (0x00c00 + (n)) /* 0x03000 + 0x4*n */
158+
#define FBNIC_QM_RCQ_IDLE(n) (0x00c00 + (n)) /* 0x03000 + 4*n */
128159
#define FBNIC_QM_RCQ_IDLE_CNT 4
129160
#define FBNIC_QM_RCQ_CTL0 0x00c0c /* 0x03030 */
130161
#define FBNIC_QM_RCQ_CTL0_COAL_WAIT CSR_GENMASK(15, 0)
131162
#define FBNIC_QM_RCQ_CTL0_TICK_CYCLES CSR_GENMASK(26, 16)
132-
#define FBNIC_QM_HPQ_IDLE(n) (0x00c0f + (n)) /* 0x0303c + 0x4*n */
163+
#define FBNIC_QM_HPQ_IDLE(n) (0x00c0f + (n)) /* 0x0303c + 4*n */
133164
#define FBNIC_QM_HPQ_IDLE_CNT 4
134-
#define FBNIC_QM_PPQ_IDLE(n) (0x00c13 + (n)) /* 0x0304c + 0x4*n */
165+
#define FBNIC_QM_PPQ_IDLE(n) (0x00c13 + (n)) /* 0x0304c + 4*n */
135166
#define FBNIC_QM_PPQ_IDLE_CNT 4
136167
#define FBNIC_QM_RNI_RBP_CTL 0x00c2d /* 0x030b4 */
137168
#define FBNIC_QM_RNI_RBP_CTL_MRRS CSR_GENMASK(1, 0)
@@ -451,12 +482,78 @@ enum {
451482
#define FBNIC_QUEUE_TIM_COUNTS_CNT0_MASK CSR_GENMASK(14, 0)
452483

453484
/* Rx Completion Queue Registers */
485+
#define FBNIC_QUEUE_RCQ_CTL 0x200 /* 0x800 */
486+
#define FBNIC_QUEUE_RCQ_CTL_RESET CSR_BIT(0)
487+
#define FBNIC_QUEUE_RCQ_CTL_ENABLE CSR_BIT(1)
488+
454489
#define FBNIC_QUEUE_RCQ_HEAD 0x201 /* 0x804 */
455490

491+
#define FBNIC_QUEUE_RCQ_SIZE 0x204 /* 0x810 */
492+
#define FBNIC_QUEUE_RCQ_SIZE_MASK CSR_GENMASK(3, 0)
493+
494+
#define FBNIC_QUEUE_RCQ_BAL 0x220 /* 0x880 */
495+
#define FBNIC_QUEUE_RCQ_BAH 0x221 /* 0x884 */
496+
456497
/* Rx Buffer Descriptor Queue Registers */
498+
#define FBNIC_QUEUE_BDQ_CTL 0x240 /* 0x900 */
499+
#define FBNIC_QUEUE_BDQ_CTL_RESET CSR_BIT(0)
500+
#define FBNIC_QUEUE_BDQ_CTL_ENABLE CSR_BIT(1)
501+
#define FBNIC_QUEUE_BDQ_CTL_PPQ_ENABLE CSR_BIT(30)
502+
457503
#define FBNIC_QUEUE_BDQ_HPQ_TAIL 0x241 /* 0x904 */
458504
#define FBNIC_QUEUE_BDQ_PPQ_TAIL 0x242 /* 0x908 */
459505

506+
#define FBNIC_QUEUE_BDQ_HPQ_SIZE 0x247 /* 0x91c */
507+
#define FBNIC_QUEUE_BDQ_PPQ_SIZE 0x248 /* 0x920 */
508+
#define FBNIC_QUEUE_BDQ_SIZE_MASK CSR_GENMASK(3, 0)
509+
510+
#define FBNIC_QUEUE_BDQ_HPQ_BAL 0x260 /* 0x980 */
511+
#define FBNIC_QUEUE_BDQ_HPQ_BAH 0x261 /* 0x984 */
512+
#define FBNIC_QUEUE_BDQ_PPQ_BAL 0x262 /* 0x988 */
513+
#define FBNIC_QUEUE_BDQ_PPQ_BAH 0x263 /* 0x98c */
514+
515+
/* Rx DMA Engine Configuration */
516+
#define FBNIC_QUEUE_RDE_CTL0 0x2a0 /* 0xa80 */
517+
#define FBNIC_QUEUE_RDE_CTL0_EN_HDR_SPLIT CSR_BIT(31)
518+
#define FBNIC_QUEUE_RDE_CTL0_DROP_MODE_MASK CSR_GENMASK(30, 29)
519+
enum {
520+
FBNIC_QUEUE_RDE_CTL0_DROP_IMMEDIATE = 0,
521+
FBNIC_QUEUE_RDE_CTL0_DROP_WAIT = 1,
522+
FBNIC_QUEUE_RDE_CTL0_DROP_NEVER = 2,
523+
};
524+
525+
#define FBNIC_QUEUE_RDE_CTL0_MIN_HROOM_MASK CSR_GENMASK(28, 20)
526+
#define FBNIC_QUEUE_RDE_CTL0_MIN_TROOM_MASK CSR_GENMASK(19, 11)
527+
528+
#define FBNIC_QUEUE_RDE_CTL1 0x2a1 /* 0xa84 */
529+
#define FBNIC_QUEUE_RDE_CTL1_MAX_HDR_MASK CSR_GENMASK(24, 12)
530+
#define FBNIC_QUEUE_RDE_CTL1_PAYLD_OFF_MASK CSR_GENMASK(11, 9)
531+
#define FBNIC_QUEUE_RDE_CTL1_PAYLD_PG_CL_MASK CSR_GENMASK(8, 6)
532+
#define FBNIC_QUEUE_RDE_CTL1_PADLEN_MASK CSR_GENMASK(5, 2)
533+
#define FBNIC_QUEUE_RDE_CTL1_PAYLD_PACK_MASK CSR_GENMASK(1, 0)
534+
enum {
535+
FBNIC_QUEUE_RDE_CTL1_PAYLD_PACK_NONE = 0,
536+
FBNIC_QUEUE_RDE_CTL1_PAYLD_PACK_ALL = 1,
537+
FBNIC_QUEUE_RDE_CTL1_PAYLD_PACK_RSS = 2,
538+
};
539+
540+
/* Rx Interrupt Manager Registers */
541+
#define FBNIC_QUEUE_RIM_CTL 0x2c0 /* 0xb00 */
542+
#define FBNIC_QUEUE_RIM_CTL_MSIX_MASK CSR_GENMASK(7, 0)
543+
544+
#define FBNIC_QUEUE_RIM_THRESHOLD 0x2c1 /* 0xb04 */
545+
#define FBNIC_QUEUE_RIM_THRESHOLD_RCD_MASK CSR_GENMASK(14, 0)
546+
547+
#define FBNIC_QUEUE_RIM_CLEAR 0x2c2 /* 0xb08 */
548+
#define FBNIC_QUEUE_RIM_CLEAR_MASK CSR_BIT(0)
549+
#define FBNIC_QUEUE_RIM_SET 0x2c3 /* 0xb0c */
550+
#define FBNIC_QUEUE_RIM_SET_MASK CSR_BIT(0)
551+
#define FBNIC_QUEUE_RIM_MASK 0x2c4 /* 0xb10 */
552+
#define FBNIC_QUEUE_RIM_MASK_MASK CSR_BIT(0)
553+
554+
#define FBNIC_QUEUE_RIM_COAL_STATUS 0x2c5 /* 0xb14 */
555+
#define FBNIC_QUEUE_RIM_RCD_COUNT_MASK CSR_GENMASK(30, 16)
556+
#define FBNIC_QUEUE_RIM_TIMER_MASK CSR_GENMASK(13, 0)
460557
#define FBNIC_MAX_QUEUES 128
461558
#define FBNIC_CSR_END_QUEUE (0x40000 + 0x400 * FBNIC_MAX_QUEUES - 1)
462559

drivers/net/ethernet/meta/fbnic/fbnic_netdev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
131131
INIT_LIST_HEAD(&fbn->napis);
132132

133133
fbn->txq_size = FBNIC_TXQ_SIZE_DEFAULT;
134+
fbn->hpq_size = FBNIC_HPQ_SIZE_DEFAULT;
135+
fbn->ppq_size = FBNIC_PPQ_SIZE_DEFAULT;
136+
fbn->rcq_size = FBNIC_RCQ_SIZE_DEFAULT;
134137

135138
default_queues = netif_get_num_default_rss_queues();
136139
if (default_queues > fbd->max_num_queues)

drivers/net/ethernet/meta/fbnic/fbnic_netdev.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ struct fbnic_net {
1616
struct fbnic_dev *fbd;
1717

1818
u32 txq_size;
19+
u32 hpq_size;
20+
u32 ppq_size;
21+
u32 rcq_size;
1922

2023
u16 num_napi;
2124

drivers/net/ethernet/meta/fbnic/fbnic_pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void fbnic_up(struct fbnic_net *fbn)
129129
{
130130
fbnic_enable(fbn);
131131

132+
fbnic_fill(fbn);
133+
132134
/* Enable Tx/Rx processing */
133135
fbnic_napi_enable(fbn);
134136
netif_tx_start_all_queues(fbn->netdev);

0 commit comments

Comments
 (0)