iPXE
thunderx.h
Go to the documentation of this file.
1#ifndef _THUNDERX_H
2#define _THUNDERX_H
3
4/** @file
5 *
6 * Cavium ThunderX Ethernet driver
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12#include <stdint.h>
13#include <ipxe/list.h>
14#include <ipxe/netdevice.h>
15
16/******************************************************************************
17 *
18 * Address space
19 *
20 ******************************************************************************
21 */
22
23/** Size of a cache line */
24#define TXNIC_LINE_SIZE 128
25
26/** Virtual function BAR size */
27#define TXNIC_VF_BAR_SIZE 0x200000UL
28
29/** Physical function BAR size */
30#define TXNIC_PF_BAR_SIZE 0x40000000UL
31
32/** BGX BAR size */
33#define TXNIC_BGX_BAR_SIZE 0x400000UL
34
35/** Maximum number of BGX Ethernet interfaces (per node) */
36#define TXNIC_NUM_BGX 2
37
38/** Maximum number of Logical MACs (per BGX) */
39#define TXNIC_NUM_LMAC 4
40
41/** Maximum number of destination MAC addresses (per BGX) */
42#define TXNIC_NUM_DMAC 32
43
44/** Maximum number of steering rules (per BGX) */
45#define TXNIC_NUM_STEERING 8
46
47/**
48 * Calculate node ID
49 *
50 * @v addr PCI BAR base address
51 * @ret node Node ID
52 */
53static inline unsigned int txnic_address_node ( uint64_t addr ) {
54
55 /* Node ID is in bits [45:44] of the hardcoded BAR address */
56 return ( ( addr >> 44 ) & 0x3 );
57}
58
59/**
60 * Calculate BGX Ethernet interface index
61 *
62 * @v addr PCI BAR base address
63 * @ret index Index
64 */
65static inline unsigned int txnic_address_bgx ( uint64_t addr ) {
66
67 /* Index is in bit 24 of the hardcoded BAR address */
68 return ( ( addr >> 24 ) & 0x1 );
69}
70
71/******************************************************************************
72 *
73 * Send queue
74 *
75 ******************************************************************************
76 */
77
78/** Send queue configuration */
79#define TXNIC_QS_SQ_CFG(q) ( ( (q) << 18 ) | 0x010800 )
80#define TXNIC_QS_SQ_CFG_ENA ( 1ULL << 19 )
81#define TXNIC_QS_SQ_CFG_RESET ( 1ULL << 17 )
82#define TXNIC_QS_SQ_CFG_QSIZE(sz) ( ( ( uint64_t ) (sz) ) << 8 )
83#define TXNIC_QS_SQ_CFG_QSIZE_1K \
84 TXNIC_QS_SQ_CFG_QSIZE ( 0 )
85
86/** Send queue base address */
87#define TXNIC_QS_SQ_BASE(q) ( ( (q) << 18 ) | 0x010820 )
88
89/** Send queue head pointer */
90#define TXNIC_QS_SQ_HEAD(q) ( ( (q) << 18 ) | 0x010828 )
91
92/** Send queue tail pointer */
93#define TXNIC_QS_SQ_TAIL(q) ( ( (q) << 18 ) | 0x010830 )
94
95/** Send queue doorbell */
96#define TXNIC_QS_SQ_DOOR(q) ( ( (q) << 18 ) | 0x010838 )
97
98/** Send queue status */
99#define TXNIC_QS_SQ_STATUS(q) ( ( (q) << 18 ) | 0x010840 )
100#define TXNIC_QS_SQ_STATUS_STOPPED ( 1ULL << 21 )
101
102/** Maximum time to wait for a send queue to stop
103 *
104 * This is a policy decision.
105 */
106#define TXNIC_SQ_STOP_MAX_WAIT_MS 100
107
108/** A send header subdescriptor */
110 /** Total length */
112 /** Unused */
114 /** Subdescriptor count */
116 /** Flags */
118 /** Unused */
120} __attribute__ (( packed ));
121
122/** Flags for send header subdescriptor
123 *
124 * These comprise SUBDC=0x1 and PNC=0x1.
125 */
126#define TXNIC_SEND_HDR_FLAGS 0x14
127
128/** A send gather subdescriptor */
130 /** Size */
132 /** Unused */
134 /** Flags */
136 /** Address */
138} __attribute__ (( packed ));
139
140/** Flags for send gather subdescriptor
141 *
142 * These comprise SUBDC=0x4 and LD_TYPE=0x0.
143 */
144#define TXNIC_SEND_GATHER_FLAGS 0x40
145
146/** A send queue entry
147 *
148 * Each send queue entry comprises a single send header subdescriptor
149 * and a single send gather subdescriptor.
150 */
151struct txnic_sqe {
152 /** Send header descriptor */
154 /** Send gather descriptor */
156} __attribute__ (( packed ));
157
158/** Number of subdescriptors per send queue entry */
159#define TXNIC_SQE_SUBDESCS ( sizeof ( struct txnic_sqe ) / \
160 sizeof ( struct txnic_send_header ) )
161
162/** Number of send queue entries
163 *
164 * The minimum send queue size is 1024 entries.
165 */
166#define TXNIC_SQES ( 1024 / TXNIC_SQE_SUBDESCS )
167
168/** Send queue maximum fill level
169 *
170 * This is a policy decision.
171 */
172#define TXNIC_SQ_FILL 32
173
174/** Send queue alignment */
175#define TXNIC_SQ_ALIGN TXNIC_LINE_SIZE
176
177/** Send queue stride */
178#define TXNIC_SQ_STRIDE sizeof ( struct txnic_sqe )
179
180/** Send queue size */
181#define TXNIC_SQ_SIZE ( TXNIC_SQES * TXNIC_SQ_STRIDE )
182
183/** A send queue */
184struct txnic_sq {
185 /** Producer counter */
186 unsigned int prod;
187 /** Consumer counter */
188 unsigned int cons;
189 /** Send queue entries */
190 struct txnic_sqe *sqe;
191};
192
193/******************************************************************************
194 *
195 * Receive queue
196 *
197 ******************************************************************************
198 */
199
200/** Receive queue configuration */
201#define TXNIC_QS_RQ_CFG(q) ( ( (q) << 18 ) | 0x010600 )
202#define TXNIC_QS_RQ_CFG_ENA ( 1ULL << 1 )
203
204/** Maximum time to wait for a receive queue to disable
205 *
206 * This is a policy decision.
207 */
208#define TXNIC_RQ_DISABLE_MAX_WAIT_MS 100
209
210/** Receive buffer descriptor ring configuration */
211#define TXNIC_QS_RBDR_CFG(q) ( ( (q) << 18 ) | 0x010c00 )
212#define TXNIC_QS_RBDR_CFG_ENA ( 1ULL << 44 )
213#define TXNIC_QS_RBDR_CFG_RESET ( 1ULL << 43 )
214#define TXNIC_QS_RBDR_CFG_QSIZE(sz) ( ( ( uint64_t ) (sz) ) << 32 )
215#define TXNIC_QS_RBDR_CFG_QSIZE_8K \
216 TXNIC_QS_RBDR_CFG_QSIZE ( 0 )
217#define TXNIC_QS_RBDR_CFG_LINES(sz) ( ( ( uint64_t ) (sz) ) << 0 )
218
219/** Receive buffer descriptor ring base address */
220#define TXNIC_QS_RBDR_BASE(q) ( ( (q) << 18 ) | 0x010c20 )
221
222/** Receive buffer descriptor ring head pointer */
223#define TXNIC_QS_RBDR_HEAD(q) ( ( (q) << 18 ) | 0x010c28 )
224
225/** Receive buffer descriptor ring tail pointer */
226#define TXNIC_QS_RBDR_TAIL(q) ( ( (q) << 18 ) | 0x010c30 )
227
228/** Receive buffer descriptor ring doorbell */
229#define TXNIC_QS_RBDR_DOOR(q) ( ( (q) << 18 ) | 0x010c38 )
230
231/** Receive buffer descriptor ring status 0 */
232#define TXNIC_QS_RBDR_STATUS0(q) ( ( (q) << 18 ) | 0x010c40 )
233
234/** A receive buffer descriptor ring entry */
236 /** Address */
238} __attribute__ (( packed ));
239
240/** A receive queue entry */
241struct txnic_rqe {
242 /** Receive buffer descriptor ring entry */
244} __attribute__ (( packed ));
245
246/** Number of receive queue entries
247 *
248 * The minimum receive queue size is 8192 entries.
249 */
250#define TXNIC_RQES 8192
251
252/** Receive queue maximum fill level
253 *
254 * This is a policy decision. Must not exceed TXNIC_RQES.
255 */
256#define TXNIC_RQ_FILL 32
257
258/** Receive queue entry size
259 *
260 * This is a policy decision.
261 */
262#define TXNIC_RQE_SIZE ( ( ETH_DATA_ALIGN + ETH_FRAME_LEN + \
263 4 /* VLAN */ + TXNIC_LINE_SIZE - 1 ) \
264 & ~( TXNIC_LINE_SIZE - 1 ) )
265
266/** Receive queue alignment */
267#define TXNIC_RQ_ALIGN TXNIC_LINE_SIZE
268
269/** Receive queue stride */
270#define TXNIC_RQ_STRIDE sizeof ( struct txnic_rqe )
271
272/** Receive queue size */
273#define TXNIC_RQ_SIZE ( TXNIC_RQES * TXNIC_RQ_STRIDE )
274
275/** A receive queue */
276struct txnic_rq {
277 /** Producer counter */
278 unsigned int prod;
279 /** Consumer counter */
280 unsigned int cons;
281 /** Receive queue entries */
282 struct txnic_rqe *rqe;
283 /** I/O buffers */
285};
286
287/******************************************************************************
288 *
289 * Completion queue
290 *
291 ******************************************************************************
292 */
293
294/** Completion queue configuration */
295#define TXNIC_QS_CQ_CFG(q) ( ( (q) << 18 ) | 0x010400 )
296#define TXNIC_QS_CQ_CFG_ENA ( 1ULL << 42 )
297#define TXNIC_QS_CQ_CFG_RESET ( 1ULL << 41 )
298#define TXNIC_QS_CQ_CFG_QSIZE(sz) ( ( ( uint64_t ) (sz) ) << 32 )
299#define TXNIC_QS_CQ_CFG_QSIZE_256 \
300 TXNIC_QS_CQ_CFG_QSIZE ( 7 )
301
302/** Maximum time to wait for a completion queue to disable
303 *
304 * This is a policy decision.
305 */
306#define TXNIC_CQ_DISABLE_MAX_WAIT_MS 100
307
308/** Completion queue base address */
309#define TXNIC_QS_CQ_BASE(q) ( ( (q) << 18 ) | 0x010420 )
310
311/** Completion queue head pointer */
312#define TXNIC_QS_CQ_HEAD(q) ( ( (q) << 18 ) | 0x010428 )
313
314/** Completion queue tail pointer */
315#define TXNIC_QS_CQ_TAIL(q) ( ( (q) << 18 ) | 0x010430 )
316
317/** Completion queue doorbell */
318#define TXNIC_QS_CQ_DOOR(q) ( ( (q) << 18 ) | 0x010438 )
319
320/** Completion queue status */
321#define TXNIC_QS_CQ_STATUS(q) ( ( (q) << 18 ) | 0x010440 )
322#define TXNIC_QS_CQ_STATUS_QCOUNT(status) \
323 ( ( (status) >> 0 ) & 0xffff )
324
325/** Completion queue status 2 */
326#define TXNIC_QS_CQ_STATUS2(q) ( ( (q) << 18 ) | 0x010448 )
327
328/** A send completion queue entry */
330 /** Status */
332 /** Unused */
334 /** Send queue entry pointer */
336 /** Type */
338} __attribute__ (( packed ));
339
340/** Send completion queue entry type */
341#define TXNIC_CQE_TYPE_SEND 0x80
342
343/** A receive completion queue entry */
345 /** Error opcode */
347 /** Unused */
349 /** Type */
351 /** Unused */
353 /** Padding */
355 /** Unused */
357 /** Length */
359} __attribute__ (( packed ));
360
361/** Receive completion queue entry type */
362#define TXNIC_CQE_TYPE_RX 0x20
363
364/** Applied padding */
365#define TXNIC_CQE_RX_APAD_LEN( apad ) ( (apad) >> 5 )
366
367/** Completion queue entry common fields */
369 /** Unused */
371 /** Type */
373} __attribute__ (( packed ));
374
375/** A completion queue entry */
377 /** Common fields */
379 /** Send completion */
381 /** Receive completion */
383 /** Padding */
385};
386
387/** Number of completion queue entries
388 *
389 * The minimum completion queue size is 256 entries.
390 */
391#define TXNIC_CQES 256
392
393/** Completion queue alignment */
394#define TXNIC_CQ_ALIGN 512
395
396/** Completion queue stride */
397#define TXNIC_CQ_STRIDE sizeof ( union txnic_cqe )
398
399/** Completion queue size */
400#define TXNIC_CQ_SIZE ( TXNIC_CQES * TXNIC_CQ_STRIDE )
401
402/** A completion queue */
403struct txnic_cq {
404 /** Consumer counter */
405 unsigned int cons;
406 /** Completion queue entries */
408};
409
410/******************************************************************************
411 *
412 * Virtual NIC
413 *
414 ******************************************************************************
415 */
416
417/** A virtual NIC */
418struct txnic {
419 /** Registers */
420 void *regs;
421 /** Device name (for debugging) */
422 const char *name;
423 /** Network device */
425
426 /** Send queue */
427 struct txnic_sq sq;
428 /** Receive queue */
429 struct txnic_rq rq;
430 /** Completion queue */
431 struct txnic_cq cq;
432};
433
434/******************************************************************************
435 *
436 * Physical function
437 *
438 ******************************************************************************
439 */
440
441/** Physical function configuration */
442#define TXNIC_PF_CFG 0x000000
443#define TXNIC_PF_CFG_ENA ( 1ULL << 0 )
444
445/** Backpressure configuration */
446#define TXNIC_PF_BP_CFG 0x000080
447#define TXNIC_PF_BP_CFG_BP_POLL_ENA ( 1ULL << 6 )
448#define TXNIC_PF_BP_CFG_BP_POLL_DLY(dl) ( ( ( uint64_t ) (dl) ) << 0 )
449#define TXNIC_PF_BP_CFG_BP_POLL_DLY_DEFAULT \
450 TXNIC_PF_BP_CFG_BP_POLL_DLY ( 3 )
451
452/** Interface send configuration */
453#define TXNIC_PF_INTF_SEND_CFG(in) ( ( (in) << 8 ) | 0x000200 )
454#define TXNIC_PF_INTF_SEND_CFG_BLOCK_BGX ( 1ULL << 3 )
455#define TXNIC_PF_INTF_SEND_CFG_BLOCK(bl) ( ( ( uint64_t ) (bl) ) << 0 )
456
457/** Interface backpressure configuration */
458#define TXNIC_PF_INTF_BP_CFG(in) ( ( (in) << 8 ) | 0x000208 )
459#define TXNIC_PF_INTF_BP_CFG_BP_ENA ( 1ULL << 63 )
460#define TXNIC_PF_INTF_BP_CFG_BP_ID_BGX ( 1ULL << 3 )
461#define TXNIC_PF_INTF_BP_CFG_BP_ID(bp) ( ( ( uint64_t ) (bp) ) << 0 )
462
463/** Port kind configuration */
464#define TXNIC_PF_PKIND_CFG(pk) ( ( (pk) << 3 ) | 0x000600 )
465#define TXNIC_PF_PKIND_CFG_LENERR_EN ( 1ULL << 33 )
466#define TXNIC_PF_PKIND_CFG_MAXLEN(ct) ( ( ( uint64_t ) (ct) ) << 16 )
467#define TXNIC_PF_PKIND_CFG_MAXLEN_DISABLE \
468 TXNIC_PF_PKIND_CFG_MAXLEN ( 0xffff )
469#define TXNIC_PF_PKIND_CFG_MINLEN(ct) ( ( ( uint64_t ) (ct) ) << 0 )
470#define TXNIC_PF_PKIND_CFG_MINLEN_DISABLE \
471 TXNIC_PF_PKIND_CFG_MINLEN ( 0x0000 )
472
473/** Match parse index configuration */
474#define TXNIC_PF_MPI_CFG(ix) ( ( (ix) << 3 ) | 0x210000 )
475#define TXNIC_PF_MPI_CFG_VNIC(vn) ( ( ( uint64_t ) (vn) ) << 24 )
476#define TXNIC_PF_MPI_CFG_RSSI_BASE(ix) ( ( ( uint64_t ) (ix) ) << 0 )
477
478/** RSS indirection receive queue */
479#define TXNIC_PF_RSSI_RQ(ix) ( ( (ix) << 3 ) | 0x220000 )
480#define TXNIC_PF_RSSI_RQ_RQ_QS(qs) ( ( ( uint64_t ) (qs) ) << 3 )
481
482/** LMAC registers */
483#define TXNIC_PF_LMAC(lm) ( ( (lm) << 3 ) | 0x240000 )
484
485/** LMAC configuration */
486#define TXNIC_PF_LMAC_CFG 0x000000
487#define TXNIC_PF_LMAC_CFG_ADJUST(ad) ( ( ( uint64_t ) (ad) ) << 8 )
488#define TXNIC_PF_LMAC_CFG_ADJUST_DEFAULT \
489 TXNIC_PF_LMAC_CFG_ADJUST ( 6 )
490#define TXNIC_PF_LMAC_CFG_MIN_PKT_SIZE(sz) ( ( ( uint64_t ) (sz) ) << 0 )
491
492/** LMAC configuration 2 */
493#define TXNIC_PF_LMAC_CFG2 0x000100
494#define TXNIC_PF_LMAC_CFG2_MAX_PKT_SIZE(sz) ( ( ( uint64_t ) (sz) ) << 0 )
495
496/** LMAC credit */
497#define TXNIC_PF_LMAC_CREDIT 0x004000
498#define TXNIC_PF_LMAC_CREDIT_CC_UNIT_CNT(ct) ( ( ( uint64_t ) (ct) ) << 12 )
499#define TXNIC_PF_LMAC_CREDIT_CC_UNIT_CNT_DEFAULT \
500 TXNIC_PF_LMAC_CREDIT_CC_UNIT_CNT ( 192 )
501#define TXNIC_PF_LMAC_CREDIT_CC_PACKET_CNT(ct) ( ( ( uint64_t ) (ct) ) << 2 )
502#define TXNIC_PF_LMAC_CREDIT_CC_PACKET_CNT_DEFAULT \
503 TXNIC_PF_LMAC_CREDIT_CC_PACKET_CNT ( 511 )
504#define TXNIC_PF_LMAC_CREDIT_CC_ENABLE ( 1ULL << 1 )
505
506/** Channel registers */
507#define TXNIC_PF_CHAN(ch) ( ( (ch) << 3 ) | 0x400000 )
508
509/** Channel transmit configuration */
510#define TXNIC_PF_CHAN_TX_CFG 0x000000
511#define TXNIC_PF_CHAN_TX_CFG_BP_ENA ( 1ULL << 0 )
512
513/** Channel receive configuration */
514#define TXNIC_PF_CHAN_RX_CFG 0x020000
515#define TXNIC_PF_CHAN_RX_CFG_CPI_BASE(ix) ( ( ( uint64_t ) (ix) ) << 48 )
516
517/** Channel receive backpressure configuration */
518#define TXNIC_PF_CHAN_RX_BP_CFG 0x080000
519#define TXNIC_PF_CHAN_RX_BP_CFG_ENA ( 1ULL << 63 )
520#define TXNIC_PF_CHAN_RX_BP_CFG_BPID(bp) ( ( ( uint64_t ) (bp) ) << 0 )
521
522/** Traffic limiter 2 configuration */
523#define TXNIC_PF_TL2_CFG(tl) ( ( (tl) << 3 ) | 0x500000 )
524#define TXNIC_PF_TL2_CFG_RR_QUANTUM(rr) ( ( ( uint64_t ) (rr) ) << 0 )
525#define TXNIC_PF_TL2_CFG_RR_QUANTUM_DEFAULT \
526 TXNIC_PF_TL2_CFG_RR_QUANTUM ( 0x905 )
527
528/** Traffic limiter 3 configuration */
529#define TXNIC_PF_TL3_CFG(tl) ( ( (tl) << 3 ) | 0x600000 )
530#define TXNIC_PF_TL3_CFG_RR_QUANTUM(rr) ( ( ( uint64_t ) (rr) ) << 0 )
531#define TXNIC_PF_TL3_CFG_RR_QUANTUM_DEFAULT \
532 TXNIC_PF_TL3_CFG_RR_QUANTUM ( 0x905 )
533
534/** Traffic limiter 3 channel mapping */
535#define TXNIC_PF_TL3_CHAN(tl) ( ( (tl) << 3 ) | 0x620000 )
536#define TXNIC_PF_TL3_CHAN_CHAN(ch) ( ( (ch) & 0x7f ) << 0 )
537
538/** Traffic limiter 4 configuration */
539#define TXNIC_PF_TL4_CFG(tl) ( ( (tl) << 3 ) | 0x800000 )
540#define TXNIC_PF_TL4_CFG_SQ_QS(qs) ( ( ( uint64_t ) (qs) ) << 27 )
541#define TXNIC_PF_TL4_CFG_RR_QUANTUM(rr) ( ( ( uint64_t ) (rr) ) << 0 )
542#define TXNIC_PF_TL4_CFG_RR_QUANTUM_DEFAULT \
543 TXNIC_PF_TL4_CFG_RR_QUANTUM ( 0x905 )
544
545/** Queue set registers */
546#define TXNIC_PF_QS(qs) ( ( (qs) << 21 ) | 0x20000000UL )
547
548/** Queue set configuration */
549#define TXNIC_PF_QS_CFG 0x010000
550#define TXNIC_PF_QS_CFG_ENA ( 1ULL << 31 )
551#define TXNIC_PF_QS_CFG_VNIC(vn) ( ( ( uint64_t ) (vn) ) << 0 )
552
553/** Receive queue configuration */
554#define TXNIC_PF_QS_RQ_CFG(q) ( ( (q) << 18 ) | 0x010400 )
555#define TXNIC_PF_QS_RQ_CFG_CACHING(cx) ( ( ( uint64_t ) (cx) ) << 26 )
556#define TXNIC_PF_QS_RQ_CFG_CACHING_ALL \
557 TXNIC_PF_QS_RQ_CFG_CACHING ( 1 )
558#define TXNIC_PF_QS_RQ_CFG_CQ_QS(qs) ( ( ( uint64_t ) (qs) ) << 19 )
559#define TXNIC_PF_QS_RQ_CFG_RBDR_CONT_QS(qs) ( ( ( uint64_t ) (qs) ) << 9 )
560#define TXNIC_PF_QS_RQ_CFG_RBDR_STRT_QS(qs) ( ( ( uint64_t ) (qs) ) << 1 )
561
562/** Receive queue drop configuration */
563#define TXNIC_PF_QS_RQ_DROP_CFG(q) ( ( (q) << 18 ) | 0x010420 )
564
565/** Receive queue backpressure configuration */
566#define TXNIC_PF_QS_RQ_BP_CFG(q) ( ( (q) << 18 ) | 0x010500 )
567#define TXNIC_PF_QS_RQ_BP_CFG_RBDR_BP_ENA ( 1ULL << 63 )
568#define TXNIC_PF_QS_RQ_BP_CFG_CQ_BP_ENA ( 1ULL << 62 )
569#define TXNIC_PF_QS_RQ_BP_CFG_BPID(bp) ( ( ( uint64_t ) (bp) ) << 0 )
570
571/** Send queue configuration */
572#define TXNIC_PF_QS_SQ_CFG(q) ( ( (q) << 18 ) | 0x010c00 )
573#define TXNIC_PF_QS_SQ_CFG_CQ_QS(qs) ( ( ( uint64_t ) (qs) ) << 3 )
574
575/** Send queue configuration 2 */
576#define TXNIC_PF_QS_SQ_CFG2(q) ( ( (q) << 18 ) | 0x010c08 )
577#define TXNIC_PF_QS_SQ_CFG2_TL4(tl) ( ( ( uint64_t ) (tl) ) << 0 )
578
579/** A physical function */
580struct txnic_pf {
581 /** Registers */
582 void *regs;
583 /** PCI device */
585 /** Node ID */
586 unsigned int node;
587
588 /** Virtual function BAR base */
589 unsigned long vf_membase;
590 /** Virtual function BAR stride */
591 unsigned long vf_stride;
592
593 /** List of physical functions */
595 /** BGX Ethernet interfaces (if known) */
597};
598
599/**
600 * Calculate virtual NIC index
601 *
602 * @v bgx_idx BGX Ethernet interface index
603 * @v lmac_idx Logical MAC index
604 * @ret vnic_idx Virtual NIC index
605 */
606#define TXNIC_VNIC_IDX( bgx_idx, lmac_idx ) \
607 ( ( (bgx_idx) * TXNIC_NUM_LMAC ) + (lmac_idx) )
608
609/**
610 * Calculate BGX Ethernet interface index
611 *
612 * @v vnic_idx Virtual NIC index
613 * @ret bgx_idx BGX Ethernet interface index
614 */
615#define TXNIC_BGX_IDX( vnic_idx ) ( (vnic_idx) / TXNIC_NUM_LMAC )
616
617/**
618 * Calculate logical MAC index
619 *
620 * @v vnic_idx Virtual NIC index
621 * @ret lmac_idx Logical MAC index
622 */
623#define TXNIC_LMAC_IDX( vnic_idx ) ( (vnic_idx) % TXNIC_NUM_LMAC )
624
625/**
626 * Calculate traffic limiter 2 index
627 *
628 * @v vnic_idx Virtual NIC index
629 * @v tl2_idx Traffic limiter 2 index
630 */
631#define TXNIC_TL2_IDX( vnic_idx ) ( (vnic_idx) << 3 )
632
633/**
634 * Calculate traffic limiter 3 index
635 *
636 * @v vnic_idx Virtual NIC index
637 * @v tl3_idx Traffic limiter 3 index
638 */
639#define TXNIC_TL3_IDX( vnic_idx ) ( (vnic_idx) << 5 )
640
641/**
642 * Calculate traffic limiter 4 index
643 *
644 * @v vnic_idx Virtual NIC index
645 * @v tl4_idx Traffic limiter 4 index
646 */
647#define TXNIC_TL4_IDX( vnic_idx ) ( (vnic_idx) << 7 )
648
649/**
650 * Calculate channel index
651 *
652 * @v vnic_idx Virtual NIC index
653 * @v chan_idx Channel index
654 */
655#define TXNIC_CHAN_IDX( vnic_idx ) ( ( TXNIC_BGX_IDX (vnic_idx) << 7 ) | \
656 ( TXNIC_LMAC_IDX (vnic_idx) << 4 ) )
657
658/******************************************************************************
659 *
660 * BGX Ethernet interface
661 *
662 ******************************************************************************
663 */
664
665/** Per-LMAC registers */
666#define BGX_LMAC(lm) ( ( (lm) << 20 ) | 0x00000000UL )
667
668/** CMR configuration */
669#define BGX_CMR_CONFIG 0x000000
670#define BGX_CMR_CONFIG_ENABLE ( 1ULL << 15 )
671#define BGX_CMR_CONFIG_DATA_PKT_RX_EN ( 1ULL << 14 )
672#define BGX_CMR_CONFIG_DATA_PKT_TX_EN ( 1ULL << 13 )
673#define BGX_CMR_CONFIG_LMAC_TYPE_GET(config) \
674 ( ( (config) >> 8 ) & 0x7 )
675#define BGX_CMR_CONFIG_LMAC_TYPE_SET(ty) ( ( ( uint64_t ) (ty) ) << 8 )
676#define BGX_CMR_CONFIG_LANE_TO_SDS(ls) ( ( ( uint64_t ) (ls) ) << 0 )
677
678/** CMR global configuration */
679#define BGX_CMR_GLOBAL_CONFIG 0x000008
680#define BGX_CMR_GLOBAL_CONFIG_FCS_STRIP ( 1ULL << 6 )
681
682/** CMR receive statistics 0 */
683#define BGX_CMR_RX_STAT0 0x000070
684
685/** CMR receive statistics 1 */
686#define BGX_CMR_RX_STAT1 0x000078
687
688/** CMR receive statistics 2 */
689#define BGX_CMR_RX_STAT2 0x000080
690
691/** CMR receive statistics 3 */
692#define BGX_CMR_RX_STAT3 0x000088
693
694/** CMR receive statistics 4 */
695#define BGX_CMR_RX_STAT4 0x000090
696
697/** CMR receive statistics 5 */
698#define BGX_CMR_RX_STAT5 0x000098
699
700/** CMR receive statistics 6 */
701#define BGX_CMR_RX_STAT6 0x0000a0
702
703/** CMR receive statistics 7 */
704#define BGX_CMR_RX_STAT7 0x0000a8
705
706/** CMR receive statistics 8 */
707#define BGX_CMR_RX_STAT8 0x0000b0
708
709/** CMR receive statistics 9 */
710#define BGX_CMR_RX_STAT9 0x0000b8
711
712/** CMR receive statistics 10 */
713#define BGX_CMR_RX_STAT10 0x0000c0
714
715/** CMR destination MAC control */
716#define BGX_CMR_RX_DMAC_CTL 0x0000e8
717#define BGX_CMR_RX_DMAC_CTL_MCST_MODE(md) ( ( ( uint64_t ) (md) ) << 1 )
718#define BGX_CMR_RX_DMAC_CTL_MCST_MODE_ACCEPT \
719 BGX_CMR_RX_DMAC_CTL_MCST_MODE ( 1 )
720#define BGX_CMR_RX_DMAC_CTL_BCST_ACCEPT ( 1ULL << 0 )
721
722/** CMR destination MAC CAM */
723#define BGX_CMR_RX_DMAC_CAM(i) ( ( (i) << 3 ) | 0x000200 )
724
725/** CMR receive steering */
726#define BGX_CMR_RX_STEERING(i) ( ( (i) << 3 ) | 0x000300 )
727
728/** CMR backpressure channel mask AND */
729#define BGX_CMR_CHAN_MSK_AND 0x000450
730#define BGX_CMR_CHAN_MSK_AND_ALL(count) \
731 ( 0xffffffffffffffffULL >> ( 16 * ( 4 - (count) ) ) )
732
733/** CMR transmit statistics 0 */
734#define BGX_CMR_TX_STAT0 0x000600
735
736/** CMR transmit statistics 1 */
737#define BGX_CMR_TX_STAT1 0x000608
738
739/** CMR transmit statistics 2 */
740#define BGX_CMR_TX_STAT2 0x000610
741
742/** CMR transmit statistics 3 */
743#define BGX_CMR_TX_STAT3 0x000618
744
745/** CMR transmit statistics 4 */
746#define BGX_CMR_TX_STAT4 0x000620
747
748/** CMR transmit statistics 5 */
749#define BGX_CMR_TX_STAT5 0x000628
750
751/** CMR transmit statistics 6 */
752#define BGX_CMR_TX_STAT6 0x000630
753
754/** CMR transmit statistics 7 */
755#define BGX_CMR_TX_STAT7 0x000638
756
757/** CMR transmit statistics 8 */
758#define BGX_CMR_TX_STAT8 0x000640
759
760/** CMR transmit statistics 9 */
761#define BGX_CMR_TX_STAT9 0x000648
762
763/** CMR transmit statistics 10 */
764#define BGX_CMR_TX_STAT10 0x000650
765
766/** CMR transmit statistics 11 */
767#define BGX_CMR_TX_STAT11 0x000658
768
769/** CMR transmit statistics 12 */
770#define BGX_CMR_TX_STAT12 0x000660
771
772/** CMR transmit statistics 13 */
773#define BGX_CMR_TX_STAT13 0x000668
774
775/** CMR transmit statistics 14 */
776#define BGX_CMR_TX_STAT14 0x000670
777
778/** CMR transmit statistics 15 */
779#define BGX_CMR_TX_STAT15 0x000678
780
781/** CMR transmit statistics 16 */
782#define BGX_CMR_TX_STAT16 0x000680
783
784/** CMR transmit statistics 17 */
785#define BGX_CMR_TX_STAT17 0x000688
786
787/** CMR receive logical MACs */
788#define BGX_CMR_RX_LMACS 0x000468
789#define BGX_CMR_RX_LMACS_LMACS_GET(lmacs) \
790 ( ( (lmacs) >> 0 ) & 0x7 )
791#define BGX_CMR_RX_LMACS_LMACS_SET(ct) ( ( ( uint64_t ) (ct) ) << 0 )
792
793/** CMR transmit logical MACs */
794#define BGX_CMR_TX_LMACS 0x001000
795#define BGX_CMR_TX_LMACS_LMACS_GET(lmacs) \
796 ( ( (lmacs) >> 0 ) & 0x7 )
797#define BGX_CMR_TX_LMACS_LMACS_SET(ct) ( ( ( uint64_t ) (ct) ) << 0 )
798
799/** SPU control 1 */
800#define BGX_SPU_CONTROL1 0x010000
801#define BGX_SPU_CONTROL1_RESET ( 1ULL << 15 )
802#define BGX_SPU_CONTROL1_LO_PWR ( 1ULL << 11 )
803
804/** SPU reset delay */
805#define BGX_SPU_RESET_DELAY_MS 10
806
807/** SPU status 1 */
808#define BGX_SPU_STATUS1 0x010008
809#define BGX_SPU_STATUS1_FLT ( 1ULL << 7 )
810#define BGX_SPU_STATUS1_RCV_LNK ( 1ULL << 2 )
811
812/** SPU status 2 */
813#define BGX_SPU_STATUS2 0x010020
814#define BGX_SPU_STATUS2_RCVFLT ( 1ULL << 10 )
815
816/** SPU BASE-R status 1 */
817#define BGX_SPU_BR_STATUS1 0x010030
818#define BGX_SPU_BR_STATUS1_RCV_LNK ( 1ULL << 12 )
819#define BGX_SPU_BR_STATUS1_HI_BER ( 1ULL << 1 )
820#define BGX_SPU_BR_STATUS1_BLK_LOCK ( 1ULL << 0 )
821
822/** SPU BASE-R status 2 */
823#define BGX_SPU_BR_STATUS2 0x010038
824#define BGX_SPU_BR_STATUS2_LATCHED_LOCK ( 1ULL << 15 )
825#define BGX_SPU_BR_STATUS2_LATCHED_BER ( 1ULL << 14 )
826
827/** SPU BASE-R alignment status */
828#define BGX_SPU_BR_ALGN_STATUS 0x010050
829#define BGX_SPU_BR_ALGN_STATUS_ALIGND ( 1ULL << 12 )
830
831/** SPU BASE-R link training control */
832#define BGX_SPU_BR_PMD_CONTROL 0x010068
833#define BGX_SPU_BR_PMD_CONTROL_TRAIN_EN ( 1ULL << 1 )
834
835/** SPU BASE-R link training status */
836#define BGX_SPU_BR_PMD_STATUS 0x010070
837
838/** SPU link partner coefficient update */
839#define BGX_SPU_BR_PMD_LP_CUP 0x010078
840
841/** SPU local device coefficient update */
842#define BGX_SPU_BR_PMD_LD_CUP 0x010088
843
844/** SPU local device status report */
845#define BGX_SPU_BR_PMD_LD_REP 0x010090
846
847/** SPU forward error correction control */
848#define BGX_SPU_FEC_CONTROL 0x0100a0
849
850/** SPU autonegotation control */
851#define BGX_SPU_AN_CONTROL 0x0100c8
852
853/** SPU autonegotiation status */
854#define BGX_SPU_AN_STATUS 0x0100d0
855#define BGX_SPU_AN_STATUS_XNP_STAT ( 1ULL << 7 )
856#define BGX_SPU_AN_STATUS_PAGE_RX ( 1ULL << 6 )
857#define BGX_SPU_AN_STATUS_AN_COMPLETE ( 1ULL << 5 )
858#define BGX_SPU_AN_STATUS_LINK_STATUS ( 1ULL << 2 )
859#define BGX_SPU_AN_STATUS_LP_AN_ABLE ( 1ULL << 0 )
860
861/** SPU interrupt */
862#define BGX_SPU_INT 0x010220
863#define BGX_SPU_INT_TRAINING_FAIL ( 1ULL << 14 )
864#define BGX_SPU_INT_TRAINING_DONE ( 1ULL << 13 )
865#define BGX_SPU_INT_AN_COMPLETE ( 1ULL << 12 )
866#define BGX_SPU_INT_AN_LINK_GOOD ( 1ULL << 11 )
867#define BGX_SPU_INT_AN_PAGE_RX ( 1ULL << 10 )
868#define BGX_SPU_INT_FEC_UNCORR ( 1ULL << 9 )
869#define BGX_SPU_INT_FEC_CORR ( 1ULL << 8 )
870#define BGX_SPU_INT_BIP_ERR ( 1ULL << 7 )
871#define BGX_SPU_INT_DBG_SYNC ( 1ULL << 6 )
872#define BGX_SPU_INT_ALGNLOS ( 1ULL << 5 )
873#define BGX_SPU_INT_SYNLOS ( 1ULL << 4 )
874#define BGX_SPU_INT_BITLCKLS ( 1ULL << 3 )
875#define BGX_SPU_INT_ERR_BLK ( 1ULL << 2 )
876#define BGX_SPU_INT_RX_LINK_DOWN ( 1ULL << 1 )
877#define BGX_SPU_INT_RX_LINK_UP ( 1ULL << 0 )
878
879/** LMAC types */
881 TXNIC_LMAC_SGMII = 0x0, /**< SGMII/1000BASE-X */
882 TXNIC_LMAC_XAUI = 0x1, /**< 10GBASE-X/XAUI or DXAUI */
883 TXNIC_LMAC_RXAUI = 0x2, /**< Reduced XAUI */
884 TXNIC_LMAC_10G_R = 0x3, /**< 10GBASE-R */
885 TXNIC_LMAC_40G_R = 0x4, /**< 40GBASE-R */
886};
887
888/** An LMAC type */
890 /** Name */
891 const char *name;
892 /** Number of LMACs */
894 /** Lane-to-SDS mapping */
896};
897
898/** An LMAC address */
900 struct {
903 } __attribute__ (( packed ));
905};
906
907/** A Logical MAC (LMAC) */
909 /** Registers */
910 void *regs;
911 /** Containing BGX Ethernet interface */
912 struct txnic_bgx *bgx;
913 /** Virtual NIC index */
914 unsigned int idx;
915
916 /** MAC address */
918
919 /** Virtual NIC (if applicable) */
920 struct txnic *vnic;
921};
922
923/** A BGX Ethernet interface */
924struct txnic_bgx {
925 /** Registers */
926 void *regs;
927 /** PCI device */
929 /** Node ID */
930 unsigned int node;
931 /** BGX index */
932 unsigned int idx;
933
934 /** LMAC type */
936 /** Number of LMACs */
937 unsigned int count;
938 /** Link training is in use */
940
941 /** List of BGX Ethernet interfaces */
943 /** Physical function (if known) */
944 struct txnic_pf *pf;
945
946 /** Logical MACs */
948};
949
950#endif /* _THUNDERX_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
uint32_t addr
Buffer address.
Definition dwmac.h:9
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define ETH_ALEN
Definition if_ether.h:9
#define __attribute__(x)
Definition compiler.h:10
Linked lists.
Network device management.
A persistent I/O buffer.
Definition iobuf.h:38
A doubly-linked list entry (or list head)
Definition list.h:19
A network device.
Definition netdevice.h:353
A PCI device.
Definition pci.h:211
A BGX Ethernet interface.
Definition thunderx.h:924
void * regs
Registers.
Definition thunderx.h:926
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition thunderx.h:947
struct list_head list
List of BGX Ethernet interfaces.
Definition thunderx.h:942
struct txnic_lmac_type * type
LMAC type.
Definition thunderx.h:935
unsigned int idx
BGX index.
Definition thunderx.h:932
unsigned int count
Number of LMACs.
Definition thunderx.h:937
unsigned int node
Node ID.
Definition thunderx.h:930
struct txnic_pf * pf
Physical function (if known)
Definition thunderx.h:944
struct pci_device * pci
PCI device.
Definition thunderx.h:928
int training
Link training is in use.
Definition thunderx.h:939
A completion queue.
Definition thunderx.h:403
union txnic_cqe * cqe
Completion queue entries.
Definition thunderx.h:407
unsigned int cons
Consumer counter.
Definition thunderx.h:405
Completion queue entry common fields.
Definition thunderx.h:368
uint8_t cqe_type
Type.
Definition thunderx.h:372
uint8_t unused_a[7]
Unused.
Definition thunderx.h:370
A receive completion queue entry.
Definition thunderx.h:344
uint8_t errop
Error opcode.
Definition thunderx.h:346
uint16_t len
Length.
Definition thunderx.h:358
uint8_t unused_b[1]
Unused.
Definition thunderx.h:352
uint8_t cqe_type
Type.
Definition thunderx.h:350
uint8_t apad
Padding.
Definition thunderx.h:354
uint8_t unused_c[4]
Unused.
Definition thunderx.h:356
uint8_t unused_a[6]
Unused.
Definition thunderx.h:348
A send completion queue entry.
Definition thunderx.h:329
uint16_t sqe_ptr
Send queue entry pointer.
Definition thunderx.h:335
uint8_t cqe_type
Type.
Definition thunderx.h:337
uint8_t unused[4]
Unused.
Definition thunderx.h:333
uint8_t send_status
Status.
Definition thunderx.h:331
An LMAC type.
Definition thunderx.h:889
uint32_t lane_to_sds
Lane-to-SDS mapping.
Definition thunderx.h:895
const char * name
Name.
Definition thunderx.h:891
uint8_t count
Number of LMACs.
Definition thunderx.h:893
A Logical MAC (LMAC)
Definition thunderx.h:908
union txnic_lmac_address mac
MAC address.
Definition thunderx.h:917
struct txnic * vnic
Virtual NIC (if applicable)
Definition thunderx.h:920
unsigned int idx
Virtual NIC index.
Definition thunderx.h:914
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition thunderx.h:912
void * regs
Registers.
Definition thunderx.h:910
A physical function.
Definition thunderx.h:580
struct pci_device * pci
PCI device.
Definition thunderx.h:584
void * regs
Registers.
Definition thunderx.h:582
struct list_head list
List of physical functions.
Definition thunderx.h:594
unsigned long vf_stride
Virtual function BAR stride.
Definition thunderx.h:591
unsigned int node
Node ID.
Definition thunderx.h:586
unsigned long vf_membase
Virtual function BAR base.
Definition thunderx.h:589
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition thunderx.h:596
A receive buffer descriptor ring entry.
Definition thunderx.h:235
uint64_t addr
Address.
Definition thunderx.h:237
A receive queue.
Definition thunderx.h:276
unsigned int cons
Consumer counter.
Definition thunderx.h:280
struct txnic_rqe * rqe
Receive queue entries.
Definition thunderx.h:282
unsigned int prod
Producer counter.
Definition thunderx.h:278
struct io_buffer * iobuf[TXNIC_RQ_FILL]
I/O buffers.
Definition thunderx.h:284
A receive queue entry.
Definition thunderx.h:241
struct txnic_rbdr_entry rbdre
Receive buffer descriptor ring entry.
Definition thunderx.h:243
A send gather subdescriptor.
Definition thunderx.h:129
uint8_t unused[5]
Unused.
Definition thunderx.h:133
uint64_t addr
Address.
Definition thunderx.h:137
uint16_t size
Size.
Definition thunderx.h:131
uint8_t flags
Flags.
Definition thunderx.h:135
A send header subdescriptor.
Definition thunderx.h:109
uint8_t unused_a[2]
Unused.
Definition thunderx.h:113
uint32_t total
Total length.
Definition thunderx.h:111
uint8_t unused_b[8]
Unused.
Definition thunderx.h:119
uint8_t flags
Flags.
Definition thunderx.h:117
uint8_t subdcnt
Subdescriptor count.
Definition thunderx.h:115
A send queue.
Definition thunderx.h:184
unsigned int prod
Producer counter.
Definition thunderx.h:186
struct txnic_sqe * sqe
Send queue entries.
Definition thunderx.h:190
unsigned int cons
Consumer counter.
Definition thunderx.h:188
A send queue entry.
Definition thunderx.h:151
struct txnic_send_gather gather
Send gather descriptor.
Definition thunderx.h:155
struct txnic_send_header hdr
Send header descriptor.
Definition thunderx.h:153
A virtual NIC.
Definition thunderx.h:418
struct txnic_cq cq
Completion queue.
Definition thunderx.h:431
struct net_device * netdev
Network device.
Definition thunderx.h:424
void * regs
Registers.
Definition thunderx.h:420
const char * name
Device name (for debugging)
Definition thunderx.h:422
struct txnic_rq rq
Receive queue.
Definition thunderx.h:429
struct txnic_sq sq
Send queue.
Definition thunderx.h:427
static unsigned int txnic_address_node(uint64_t addr)
Calculate node ID.
Definition thunderx.h:53
#define TXNIC_NUM_LMAC
Maximum number of Logical MACs (per BGX)
Definition thunderx.h:39
#define TXNIC_NUM_BGX
Maximum number of BGX Ethernet interfaces (per node)
Definition thunderx.h:36
txnic_lmac_types
LMAC types.
Definition thunderx.h:880
@ TXNIC_LMAC_XAUI
10GBASE-X/XAUI or DXAUI
Definition thunderx.h:882
@ TXNIC_LMAC_40G_R
40GBASE-R
Definition thunderx.h:885
@ TXNIC_LMAC_RXAUI
Reduced XAUI.
Definition thunderx.h:883
@ TXNIC_LMAC_10G_R
10GBASE-R
Definition thunderx.h:884
@ TXNIC_LMAC_SGMII
SGMII/1000BASE-X.
Definition thunderx.h:881
static unsigned int txnic_address_bgx(uint64_t addr)
Calculate BGX Ethernet interface index.
Definition thunderx.h:65
#define TXNIC_RQ_FILL
Receive queue maximum fill level.
Definition thunderx.h:256
A completion queue entry.
Definition thunderx.h:376
struct txnic_cqe_rx rx
Receive completion.
Definition thunderx.h:382
uint8_t pad[512]
Padding.
Definition thunderx.h:384
struct txnic_cqe_common common
Common fields.
Definition thunderx.h:378
struct txnic_cqe_send send
Send completion.
Definition thunderx.h:380
An LMAC address.
Definition thunderx.h:899
uint8_t pad[2]
Definition thunderx.h:901
uint8_t raw[ETH_ALEN]
Definition thunderx.h:902