[intelxl] Provide a mechanism for handling "send to VF" events
[ipxe.git] / src / drivers / net / intelxl.h
1 #ifndef _INTELX_H
2 #define _INTELX_H
3
4 /** @file
5 *
6 * Intel 40 Gigabit Ethernet network card driver
7 *
8 */
9
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12 #include <stdint.h>
13 #include <ipxe/if_ether.h>
14
15 struct intelxl_nic;
16
17 /** BAR size */
18 #define INTELXL_BAR_SIZE 0x200000
19
20 /** Alignment
21 *
22 * No data structure requires greater than 128 byte alignment.
23 */
24 #define INTELXL_ALIGN 128
25
26 /******************************************************************************
27 *
28 * Admin queue
29 *
30 ******************************************************************************
31 */
32
33 /** PF Admin Command Queue register block */
34 #define INTELXL_ADMIN_CMD 0x080000
35
36 /** PF Admin Event Queue register block */
37 #define INTELXL_ADMIN_EVT 0x080080
38
39 /** Admin Queue Base Address Low Register (offset) */
40 #define INTELXL_ADMIN_BAL 0x000
41
42 /** Admin Queue Base Address High Register (offset) */
43 #define INTELXL_ADMIN_BAH 0x100
44
45 /** Admin Queue Length Register (offset) */
46 #define INTELXL_ADMIN_LEN 0x200
47 #define INTELXL_ADMIN_LEN_LEN(x) ( (x) << 0 ) /**< Queue length */
48 #define INTELXL_ADMIN_LEN_ENABLE 0x80000000UL /**< Queue enable */
49
50 /** Admin Queue Head Register (offset) */
51 #define INTELXL_ADMIN_HEAD 0x300
52
53 /** Admin Queue Tail Register (offset) */
54 #define INTELXL_ADMIN_TAIL 0x400
55
56 /** Admin queue register offsets
57 *
58 * The physical and virtual function register maps have no discernible
59 * relationship.
60 */
61 struct intelxl_admin_offsets {
62 /** Base Address Low Register offset */
63 unsigned int bal;
64 /** Base Address High Register offset */
65 unsigned int bah;
66 /** Length Register offset */
67 unsigned int len;
68 /** Head Register offset */
69 unsigned int head;
70 /** Tail Register offset */
71 unsigned int tail;
72 };
73
74 /** Admin queue data buffer command parameters */
75 struct intelxl_admin_buffer_params {
76 /** Reserved */
77 uint8_t reserved[8];
78 /** Buffer address high */
79 uint32_t high;
80 /** Buffer address low */
81 uint32_t low;
82 } __attribute__ (( packed ));
83
84 /** Admin queue Get Version command */
85 #define INTELXL_ADMIN_VERSION 0x0001
86
87 /** Admin queue version number */
88 struct intelxl_admin_version {
89 /** Major version number */
90 uint16_t major;
91 /** Minor version number */
92 uint16_t minor;
93 } __attribute__ (( packed ));
94
95 /** Admin queue Get Version command parameters */
96 struct intelxl_admin_version_params {
97 /** ROM version */
98 uint32_t rom;
99 /** Firmware build ID */
100 uint32_t build;
101 /** Firmware version */
102 struct intelxl_admin_version firmware;
103 /** API version */
104 struct intelxl_admin_version api;
105 } __attribute__ (( packed ));
106
107 /** Admin queue Driver Version command */
108 #define INTELXL_ADMIN_DRIVER 0x0002
109
110 /** Admin queue Driver Version command parameters */
111 struct intelxl_admin_driver_params {
112 /** Driver version */
113 uint8_t major;
114 /** Minor version */
115 uint8_t minor;
116 /** Build version */
117 uint8_t build;
118 /** Sub-build version */
119 uint8_t sub;
120 /** Reserved */
121 uint8_t reserved[4];
122 /** Data buffer address */
123 uint64_t address;
124 } __attribute__ (( packed ));
125
126 /** Admin queue Driver Version data buffer */
127 struct intelxl_admin_driver_buffer {
128 /** Driver name */
129 char name[32];
130 } __attribute__ (( packed ));
131
132 /** Admin queue Shutdown command */
133 #define INTELXL_ADMIN_SHUTDOWN 0x0003
134
135 /** Admin queue Shutdown command parameters */
136 struct intelxl_admin_shutdown_params {
137 /** Driver unloading */
138 uint8_t unloading;
139 /** Reserved */
140 uint8_t reserved[15];
141 } __attribute__ (( packed ));
142
143 /** Driver is unloading */
144 #define INTELXL_ADMIN_SHUTDOWN_UNLOADING 0x01
145
146 /** Admin queue Get Switch Configuration command */
147 #define INTELXL_ADMIN_SWITCH 0x0200
148
149 /** Switching element configuration */
150 struct intelxl_admin_switch_config {
151 /** Switching element type */
152 uint8_t type;
153 /** Revision */
154 uint8_t revision;
155 /** Switching element ID */
156 uint16_t seid;
157 /** Uplink switching element ID */
158 uint16_t uplink;
159 /** Downlink switching element ID */
160 uint16_t downlink;
161 /** Reserved */
162 uint8_t reserved_b[3];
163 /** Connection type */
164 uint8_t connection;
165 /** Reserved */
166 uint8_t reserved_c[2];
167 /** Element specific information */
168 uint16_t info;
169 } __attribute__ (( packed ));
170
171 /** Virtual Station Inferface element type */
172 #define INTELXL_ADMIN_SWITCH_TYPE_VSI 19
173
174 /** Admin queue Get Switch Configuration command parameters */
175 struct intelxl_admin_switch_params {
176 /** Starting switching element identifier */
177 uint16_t next;
178 /** Reserved */
179 uint8_t reserved[6];
180 /** Data buffer address */
181 uint64_t address;
182 } __attribute__ (( packed ));
183
184 /** Admin queue Get Switch Configuration data buffer */
185 struct intelxl_admin_switch_buffer {
186 /** Number of switching elements reported */
187 uint16_t count;
188 /** Total number of switching elements */
189 uint16_t total;
190 /** Reserved */
191 uint8_t reserved_a[12];
192 /** Switch configuration */
193 struct intelxl_admin_switch_config cfg;
194 } __attribute__ (( packed ));
195
196 /** Admin queue Get VSI Parameters command */
197 #define INTELXL_ADMIN_VSI 0x0212
198
199 /** Admin queue Get VSI Parameters command parameters */
200 struct intelxl_admin_vsi_params {
201 /** VSI switching element ID */
202 uint16_t vsi;
203 /** Reserved */
204 uint8_t reserved[6];
205 /** Data buffer address */
206 uint64_t address;
207 } __attribute__ (( packed ));
208
209 /** Admin queue Get VSI Parameters data buffer */
210 struct intelxl_admin_vsi_buffer {
211 /** Reserved */
212 uint8_t reserved_a[30];
213 /** Queue numbers */
214 uint16_t queue[16];
215 /** Reserved */
216 uint8_t reserved_b[34];
217 /** Queue set handles for each traffic class */
218 uint16_t qset[8];
219 /** Reserved */
220 uint8_t reserved_c[16];
221 } __attribute__ (( packed ));
222
223 /** Admin queue Set VSI Promiscuous Modes command */
224 #define INTELXL_ADMIN_PROMISC 0x0254
225
226 /** Admin queue Set VSI Promiscuous Modes command parameters */
227 struct intelxl_admin_promisc_params {
228 /** Flags */
229 uint16_t flags;
230 /** Valid flags */
231 uint16_t valid;
232 /** VSI switching element ID */
233 uint16_t vsi;
234 /** Reserved */
235 uint8_t reserved[10];
236 } __attribute__ (( packed ));
237
238 /** Promiscuous unicast mode */
239 #define INTELXL_ADMIN_PROMISC_FL_UNICAST 0x0001
240
241 /** Promiscuous multicast mode */
242 #define INTELXL_ADMIN_PROMISC_FL_MULTICAST 0x0002
243
244 /** Promiscuous broadcast mode */
245 #define INTELXL_ADMIN_PROMISC_FL_BROADCAST 0x0004
246
247 /** Promiscuous VLAN mode */
248 #define INTELXL_ADMIN_PROMISC_FL_VLAN 0x0010
249
250 /** Admin queue Restart Autonegotiation command */
251 #define INTELXL_ADMIN_AUTONEG 0x0605
252
253 /** Admin queue Restart Autonegotiation command parameters */
254 struct intelxl_admin_autoneg_params {
255 /** Flags */
256 uint8_t flags;
257 /** Reserved */
258 uint8_t reserved[15];
259 } __attribute__ (( packed ));
260
261 /** Restart autonegotiation */
262 #define INTELXL_ADMIN_AUTONEG_FL_RESTART 0x02
263
264 /** Enable link */
265 #define INTELXL_ADMIN_AUTONEG_FL_ENABLE 0x04
266
267 /** Admin queue Get Link Status command */
268 #define INTELXL_ADMIN_LINK 0x0607
269
270 /** Admin queue Get Link Status command parameters */
271 struct intelxl_admin_link_params {
272 /** Link status notification */
273 uint8_t notify;
274 /** Reserved */
275 uint8_t reserved_a;
276 /** PHY type */
277 uint8_t phy;
278 /** Link speed */
279 uint8_t speed;
280 /** Link status */
281 uint8_t status;
282 /** Reserved */
283 uint8_t reserved_b[11];
284 } __attribute__ (( packed ));
285
286 /** Notify driver of link status changes */
287 #define INTELXL_ADMIN_LINK_NOTIFY 0x03
288
289 /** Link is up */
290 #define INTELXL_ADMIN_LINK_UP 0x01
291
292 /** Admin queue Send Message to PF command */
293 #define INTELXL_ADMIN_SEND_TO_PF 0x0801
294
295 /** Admin queue Send Message to VF command */
296 #define INTELXL_ADMIN_SEND_TO_VF 0x0802
297
298 /** Admin queue command parameters */
299 union intelxl_admin_params {
300 /** Additional data buffer command parameters */
301 struct intelxl_admin_buffer_params buffer;
302 /** Get Version command parameters */
303 struct intelxl_admin_version_params version;
304 /** Driver Version command parameters */
305 struct intelxl_admin_driver_params driver;
306 /** Shutdown command parameters */
307 struct intelxl_admin_shutdown_params shutdown;
308 /** Get Switch Configuration command parameters */
309 struct intelxl_admin_switch_params sw;
310 /** Get VSI Parameters command parameters */
311 struct intelxl_admin_vsi_params vsi;
312 /** Set VSI Promiscuous Modes command parameters */
313 struct intelxl_admin_promisc_params promisc;
314 /** Restart Autonegotiation command parameters */
315 struct intelxl_admin_autoneg_params autoneg;
316 /** Get Link Status command parameters */
317 struct intelxl_admin_link_params link;
318 } __attribute__ (( packed ));
319
320 /** Admin queue data buffer */
321 union intelxl_admin_buffer {
322 /** Driver Version data buffer */
323 struct intelxl_admin_driver_buffer driver;
324 /** Get Switch Configuration data buffer */
325 struct intelxl_admin_switch_buffer sw;
326 /** Get VSI Parameters data buffer */
327 struct intelxl_admin_vsi_buffer vsi;
328 /** Alignment padding */
329 uint8_t pad[INTELXL_ALIGN];
330 } __attribute__ (( packed ));
331
332 /** Admin queue descriptor */
333 struct intelxl_admin_descriptor {
334 /** Flags */
335 uint16_t flags;
336 /** Opcode */
337 uint16_t opcode;
338 /** Data length */
339 uint16_t len;
340 /** Return value */
341 uint16_t ret;
342 /** Opaque cookie / VF opcode */
343 union {
344 /** Cookie */
345 uint32_t cookie;
346 /** VF opcode */
347 uint32_t vopcode;
348 };
349 /** VF return value */
350 int32_t vret;
351 /** Parameters */
352 union intelxl_admin_params params;
353 } __attribute__ (( packed ));
354
355 /** Admin descriptor done */
356 #define INTELXL_ADMIN_FL_DD 0x0001
357
358 /** Admin descriptor contains a completion */
359 #define INTELXL_ADMIN_FL_CMP 0x0002
360
361 /** Admin descriptor completed in error */
362 #define INTELXL_ADMIN_FL_ERR 0x0004
363
364 /** Admin descriptor uses data buffer for command parameters */
365 #define INTELXL_ADMIN_FL_RD 0x0400
366
367 /** Admin descriptor uses data buffer */
368 #define INTELXL_ADMIN_FL_BUF 0x1000
369
370 /** Admin queue */
371 struct intelxl_admin {
372 /** Descriptors */
373 struct intelxl_admin_descriptor *desc;
374 /** Data buffers */
375 union intelxl_admin_buffer *buf;
376 /** Queue index */
377 unsigned int index;
378
379 /** Register block base */
380 unsigned int base;
381 /** Register offsets */
382 const struct intelxl_admin_offsets *regs;
383 };
384
385 /**
386 * Initialise admin queue
387 *
388 * @v admin Admin queue
389 * @v base Register block base
390 * @v regs Register offsets
391 */
392 static inline __attribute__ (( always_inline )) void
393 intelxl_init_admin ( struct intelxl_admin *admin, unsigned int base,
394 const struct intelxl_admin_offsets *regs ) {
395
396 admin->base = base;
397 admin->regs = regs;
398 }
399
400 /** Number of admin queue descriptors */
401 #define INTELXL_ADMIN_NUM_DESC 4
402
403 /** Maximum time to wait for an admin request to complete */
404 #define INTELXL_ADMIN_MAX_WAIT_MS 100
405
406 /** Admin queue API major version */
407 #define INTELXL_ADMIN_API_MAJOR 1
408
409 /******************************************************************************
410 *
411 * Transmit and receive queue context
412 *
413 ******************************************************************************
414 */
415
416 /** CMLAN Context Data Register */
417 #define INTELXL_PFCM_LANCTXDATA(x) ( 0x10c100 + ( 0x80 * (x) ) )
418
419 /** CMLAN Context Control Register */
420 #define INTELXL_PFCM_LANCTXCTL 0x10c300
421 #define INTELXL_PFCM_LANCTXCTL_QUEUE_NUM(x) \
422 ( (x) << 0 ) /**< Queue number */
423 #define INTELXL_PFCM_LANCTXCTL_SUB_LINE(x) \
424 ( (x) << 12 ) /**< Sub-line */
425 #define INTELXL_PFCM_LANCTXCTL_TYPE(x) \
426 ( (x) << 15 ) /**< Queue type */
427 #define INTELXL_PFCM_LANCTXCTL_TYPE_RX \
428 INTELXL_PFCM_LANCTXCTL_TYPE ( 0x0 ) /**< RX queue type */
429 #define INTELXL_PFCM_LANCTXCTL_TYPE_TX \
430 INTELXL_PFCM_LANCTXCTL_TYPE ( 0x1 ) /**< TX queue type */
431 #define INTELXL_PFCM_LANCTXCTL_OP_CODE(x) \
432 ( (x) << 17 ) /**< Op code */
433 #define INTELXL_PFCM_LANCTXCTL_OP_CODE_READ \
434 INTELXL_PFCM_LANCTXCTL_OP_CODE ( 0x0 ) /**< Read context */
435 #define INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE \
436 INTELXL_PFCM_LANCTXCTL_OP_CODE ( 0x1 ) /**< Write context */
437
438 /** CMLAN Context Status Register */
439 #define INTELXL_PFCM_LANCTXSTAT 0x10c380
440 #define INTELXL_PFCM_LANCTXSTAT_DONE 0x00000001UL /**< Complete */
441
442 /** Queue context line */
443 struct intelxl_context_line {
444 /** Raw data */
445 uint32_t raw[4];
446 } __attribute__ (( packed ));
447
448 /** Transmit queue context */
449 struct intelxl_context_tx {
450 /** Head pointer */
451 uint16_t head;
452 /** Flags */
453 uint16_t flags;
454 /** Base address */
455 uint64_t base;
456 /** Reserved */
457 uint8_t reserved_a[8];
458 /** Queue count */
459 uint16_t count;
460 /** Reserved */
461 uint8_t reserved_b[100];
462 /** Queue set */
463 uint16_t qset;
464 /** Reserved */
465 uint8_t reserved_c[4];
466 } __attribute__ (( packed ));
467
468 /** New transmit queue context */
469 #define INTELXL_CTX_TX_FL_NEW 0x4000
470
471 /** Transmit queue base address */
472 #define INTELXL_CTX_TX_BASE( base ) ( (base) >> 7 )
473
474 /** Transmit queue count */
475 #define INTELXL_CTX_TX_COUNT( count ) ( (count) << 1 )
476
477 /** Transmit queue set */
478 #define INTELXL_CTX_TX_QSET( qset) ( (qset) << 4 )
479
480 /** Receive queue context */
481 struct intelxl_context_rx {
482 /** Head pointer */
483 uint16_t head;
484 /** Reserved */
485 uint8_t reserved_a[2];
486 /** Base address and queue count */
487 uint64_t base_count;
488 /** Data buffer length */
489 uint16_t len;
490 /** Flags */
491 uint8_t flags;
492 /** Reserved */
493 uint8_t reserved_b[7];
494 /** Maximum frame size */
495 uint16_t mfs;
496 } __attribute__ (( packed ));
497
498 /** Receive queue base address and queue count */
499 #define INTELXL_CTX_RX_BASE_COUNT( base, count ) \
500 ( ( (base) >> 7 ) | ( ( ( uint64_t ) (count) ) << 57 ) )
501
502 /** Receive queue data buffer length */
503 #define INTELXL_CTX_RX_LEN( len ) ( (len) >> 1 )
504
505 /** Strip CRC from received packets */
506 #define INTELXL_CTX_RX_FL_CRCSTRIP 0x20
507
508 /** Receive queue maximum frame size */
509 #define INTELXL_CTX_RX_MFS( mfs ) ( (mfs) >> 2 )
510
511 /** Maximum time to wait for a context operation to complete */
512 #define INTELXL_CTX_MAX_WAIT_MS 100
513
514 /** Time to wait for a queue to become enabled */
515 #define INTELXL_QUEUE_ENABLE_DELAY_US 20
516
517 /** Time to wait for a transmit queue to become pre-disabled */
518 #define INTELXL_QUEUE_PRE_DISABLE_DELAY_US 400
519
520 /** Maximum time to wait for a queue to become disabled */
521 #define INTELXL_QUEUE_DISABLE_MAX_WAIT_MS 1000
522
523 /******************************************************************************
524 *
525 * Transmit and receive descriptors
526 *
527 ******************************************************************************
528 */
529
530 /** Global Transmit Queue Head register */
531 #define INTELXL_QTX_HEAD(x) ( 0x0e4000 + ( 0x4 * (x) ) )
532
533 /** Global Transmit Pre Queue Disable register */
534 #define INTELXL_GLLAN_TXPRE_QDIS(x) ( 0x0e6500 + ( 0x4 * ( (x) / 0x80 ) ) )
535 #define INTELXL_GLLAN_TXPRE_QDIS_QINDX(x) \
536 ( (x) << 0 ) /**< Queue index */
537 #define INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS \
538 0x40000000UL /**< Set disable */
539 #define INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS \
540 0x80000000UL /**< Clear disable */
541
542 /** Global Transmit Queue register block */
543 #define INTELXL_QTX(x) ( 0x100000 + ( 0x4 * (x) ) )
544
545 /** Global Receive Queue register block */
546 #define INTELXL_QRX(x) ( 0x120000 + ( 0x4 * (x) ) )
547
548 /** Queue Enable Register (offset) */
549 #define INTELXL_QXX_ENA 0x0000
550 #define INTELXL_QXX_ENA_REQ 0x00000001UL /**< Enable request */
551 #define INTELXL_QXX_ENA_STAT 0x00000004UL /**< Enabled status */
552
553 /** Queue Control Register (offset) */
554 #define INTELXL_QXX_CTL 0x4000
555 #define INTELXL_QXX_CTL_PFVF_Q(x) ( (x) << 0 ) /**< PF/VF queue */
556 #define INTELXL_QXX_CTL_PFVF_Q_PF \
557 INTELXL_QXX_CTL_PFVF_Q ( 0x2 ) /**< PF queue */
558 #define INTELXL_QXX_CTL_PFVF_PF_INDX(x) ( (x) << 2 ) /**< PF index */
559
560 /** Queue Tail Pointer Register (offset) */
561 #define INTELXL_QXX_TAIL 0x8000
562
563 /** Transmit data descriptor */
564 struct intelxl_tx_data_descriptor {
565 /** Buffer address */
566 uint64_t address;
567 /** Flags */
568 uint32_t flags;
569 /** Length */
570 uint32_t len;
571 } __attribute__ (( packed ));
572
573 /** Transmit data descriptor type */
574 #define INTELXL_TX_DATA_DTYP 0x0
575
576 /** Transmit data descriptor end of packet */
577 #define INTELXL_TX_DATA_EOP 0x10
578
579 /** Transmit data descriptor report status */
580 #define INTELXL_TX_DATA_RS 0x20
581
582 /** Transmit data descriptor pretty please
583 *
584 * This bit is completely missing from older versions of the XL710
585 * datasheet. Later versions describe it innocuously as "reserved,
586 * must be 1". Without this bit, everything will appear to work (up
587 * to and including the port "transmit good octets" counter), but no
588 * packet will actually be sent.
589 */
590 #define INTELXL_TX_DATA_JFDI 0x40
591
592 /** Transmit data descriptor length */
593 #define INTELXL_TX_DATA_LEN( len ) ( (len) << 2 )
594
595 /** Transmit writeback descriptor */
596 struct intelxl_tx_writeback_descriptor {
597 /** Reserved */
598 uint8_t reserved_a[8];
599 /** Flags */
600 uint8_t flags;
601 /** Reserved */
602 uint8_t reserved_b[7];
603 } __attribute__ (( packed ));
604
605 /** Transmit writeback descriptor complete */
606 #define INTELXL_TX_WB_FL_DD 0x01
607
608 /** Receive data descriptor */
609 struct intelxl_rx_data_descriptor {
610 /** Buffer address */
611 uint64_t address;
612 /** Flags */
613 uint32_t flags;
614 /** Reserved */
615 uint8_t reserved[4];
616 } __attribute__ (( packed ));
617
618 /** Receive writeback descriptor */
619 struct intelxl_rx_writeback_descriptor {
620 /** Reserved */
621 uint8_t reserved_a[2];
622 /** VLAN tag */
623 uint16_t vlan;
624 /** Reserved */
625 uint8_t reserved_b[4];
626 /** Flags */
627 uint32_t flags;
628 /** Length */
629 uint32_t len;
630 } __attribute__ (( packed ));
631
632 /** Receive writeback descriptor complete */
633 #define INTELXL_RX_WB_FL_DD 0x00000001UL
634
635 /** Receive writeback descriptor VLAN tag present */
636 #define INTELXL_RX_WB_FL_VLAN 0x00000004UL
637
638 /** Receive writeback descriptor error */
639 #define INTELXL_RX_WB_FL_RXE 0x00080000UL
640
641 /** Receive writeback descriptor length */
642 #define INTELXL_RX_WB_LEN(len) ( ( (len) >> 6 ) & 0x3fff )
643
644 /** Packet descriptor */
645 union intelxl_descriptor {
646 /** Transmit data descriptor */
647 struct intelxl_tx_data_descriptor tx;
648 /** Transmit writeback descriptor */
649 struct intelxl_tx_writeback_descriptor tx_wb;
650 /** Receive data descriptor */
651 struct intelxl_rx_data_descriptor rx;
652 /** Receive writeback descriptor */
653 struct intelxl_rx_writeback_descriptor rx_wb;
654 };
655
656 /** Descriptor ring */
657 struct intelxl_ring {
658 /** Descriptors */
659 union intelxl_descriptor *desc;
660 /** Producer index */
661 unsigned int prod;
662 /** Consumer index */
663 unsigned int cons;
664
665 /** Register block */
666 unsigned int reg;
667 /** Length (in bytes) */
668 size_t len;
669 /** Program queue context
670 *
671 * @v intelxl Intel device
672 * @v address Descriptor ring base address
673 */
674 int ( * context ) ( struct intelxl_nic *intelxl, physaddr_t address );
675 };
676
677 /**
678 * Initialise descriptor ring
679 *
680 * @v ring Descriptor ring
681 * @v count Number of descriptors
682 * @v context Method to program queue context
683 */
684 static inline __attribute__ (( always_inline)) void
685 intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count,
686 int ( * context ) ( struct intelxl_nic *intelxl,
687 physaddr_t address ) ) {
688
689 ring->len = ( count * sizeof ( ring->desc[0] ) );
690 ring->context = context;
691 }
692
693 /** Number of transmit descriptors */
694 #define INTELXL_TX_NUM_DESC 16
695
696 /** Transmit descriptor ring maximum fill level */
697 #define INTELXL_TX_FILL ( INTELXL_TX_NUM_DESC - 1 )
698
699 /** Number of receive descriptors
700 *
701 * In PXE mode (i.e. able to post single receive descriptors), 8
702 * descriptors is the only permitted value covering all possible
703 * numbers of PFs.
704 */
705 #define INTELXL_RX_NUM_DESC 8
706
707 /** Receive descriptor ring fill level */
708 #define INTELXL_RX_FILL ( INTELXL_RX_NUM_DESC - 1 )
709
710 /******************************************************************************
711 *
712 * Top level
713 *
714 ******************************************************************************
715 */
716
717 /** PF Interrupt Zero Dynamic Control Register */
718 #define INTELXL_PFINT_DYN_CTL0 0x038480
719 #define INTELXL_PFINT_DYN_CTL0_INTENA 0x00000001UL /**< Enable */
720 #define INTELXL_PFINT_DYN_CTL0_CLEARPBA 0x00000002UL /**< Acknowledge */
721 #define INTELXL_PFINT_DYN_CTL0_INTENA_MASK 0x80000000UL /**< Ignore enable */
722
723 /** PF Interrupt Zero Linked List Register */
724 #define INTELXL_PFINT_LNKLST0 0x038500
725 #define INTELXL_PFINT_LNKLST0_FIRSTQ_INDX(x) \
726 ( (x) << 0 ) /**< Queue index */
727 #define INTELXL_PFINT_LNKLST0_FIRSTQ_INDX_NONE \
728 INTELXL_PFINT_LNKLST0_FIRSTQ_INDX ( 0x7ff ) /**< End of list */
729 #define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE(x) \
730 ( (x) << 11 ) /**< Queue type */
731 #define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX \
732 INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE ( 0x0 ) /**< Receive queue */
733 #define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_TX \
734 INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE ( 0x1 ) /**< Transmit queue */
735
736 /** PF Interrupt Zero Cause Enablement Register */
737 #define INTELXL_PFINT_ICR0_ENA 0x038800
738 #define INTELXL_PFINT_ICR0_ENA_ADMINQ 0x40000000UL /**< Admin event */
739
740 /** Receive Queue Interrupt Cause Control Register */
741 #define INTELXL_QINT_RQCTL(x) ( 0x03a000 + ( 0x4 * (x) ) )
742 #define INTELXL_QINT_RQCTL_NEXTQ_INDX(x) ( (x) << 16 ) /**< Queue index */
743 #define INTELXL_QINT_RQCTL_NEXTQ_INDX_NONE \
744 INTELXL_QINT_RQCTL_NEXTQ_INDX ( 0x7ff ) /**< End of list */
745 #define INTELXL_QINT_RQCTL_NEXTQ_TYPE(x) ( (x) << 27 ) /**< Queue type */
746 #define INTELXL_QINT_RQCTL_NEXTQ_TYPE_RX \
747 INTELXL_QINT_RQCTL_NEXTQ_TYPE ( 0x0 ) /**< Receive queue */
748 #define INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX \
749 INTELXL_QINT_RQCTL_NEXTQ_TYPE ( 0x1 ) /**< Transmit queue */
750 #define INTELXL_QINT_RQCTL_CAUSE_ENA 0x40000000UL /**< Enable */
751
752 /** Transmit Queue Interrupt Cause Control Register */
753 #define INTELXL_QINT_TQCTL(x) ( 0x03c000 + ( 0x4 * (x) ) )
754 #define INTELXL_QINT_TQCTL_NEXTQ_INDX(x) ( (x) << 16 ) /**< Queue index */
755 #define INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE \
756 INTELXL_QINT_TQCTL_NEXTQ_INDX ( 0x7ff ) /**< End of list */
757 #define INTELXL_QINT_TQCTL_NEXTQ_TYPE(x) ( (x) << 27 ) /**< Queue type */
758 #define INTELXL_QINT_TQCTL_NEXTQ_TYPE_RX \
759 INTELXL_QINT_TQCTL_NEXTQ_TYPE ( 0x0 ) /**< Receive queue */
760 #define INTELXL_QINT_TQCTL_NEXTQ_TYPE_TX \
761 INTELXL_QINT_TQCTL_NEXTQ_TYPE ( 0x1 ) /**< Transmit queue */
762 #define INTELXL_QINT_TQCTL_CAUSE_ENA 0x40000000UL /**< Enable */
763
764 /** PF Control Register */
765 #define INTELXL_PFGEN_CTRL 0x092400
766 #define INTELXL_PFGEN_CTRL_PFSWR 0x00000001UL /**< Software Reset */
767
768 /** Time to delay for device reset, in milliseconds */
769 #define INTELXL_RESET_DELAY_MS 100
770
771 /** PF Queue Allocation Register */
772 #define INTELXL_PFLAN_QALLOC 0x1c0400
773 #define INTELXL_PFLAN_QALLOC_FIRSTQ(x) \
774 ( ( (x) >> 0 ) & 0x7ff ) /**< First queue */
775 #define INTELXL_PFLAN_QALLOC_LASTQ(x) \
776 ( ( (x) >> 16 ) & 0x7ff ) /**< Last queue */
777
778 /** PF LAN Port Number Register */
779 #define INTELXL_PFGEN_PORTNUM 0x1c0480
780 #define INTELXL_PFGEN_PORTNUM_PORT_NUM(x) \
781 ( ( (x) >> 0 ) & 0x3 ) /**< Port number */
782
783 /** Port MAC Address Low Register */
784 #define INTELXL_PRTGL_SAL 0x1e2120
785
786 /** Port MAC Address High Register */
787 #define INTELXL_PRTGL_SAH 0x1e2140
788 #define INTELXL_PRTGL_SAH_MFS_GET(x) ( (x) >> 16 ) /**< Max frame size */
789 #define INTELXL_PRTGL_SAH_MFS_SET(x) ( (x) << 16 ) /**< Max frame size */
790
791 /** Receive address */
792 union intelxl_receive_address {
793 struct {
794 uint32_t low;
795 uint32_t high;
796 } __attribute__ (( packed )) reg;
797 uint8_t raw[ETH_ALEN];
798 };
799
800 /** An Intel 40Gigabit network card */
801 struct intelxl_nic {
802 /** Registers */
803 void *regs;
804 /** Maximum frame size */
805 size_t mfs;
806
807 /** Physical function number */
808 unsigned int pf;
809 /** Absolute queue number base */
810 unsigned int base;
811 /** Port number */
812 unsigned int port;
813 /** Queue number */
814 unsigned int queue;
815 /** Virtual Station Interface switching element ID */
816 unsigned int vsi;
817 /** Queue set handle */
818 unsigned int qset;
819
820 /** Admin command queue */
821 struct intelxl_admin command;
822 /** Admin event queue */
823 struct intelxl_admin event;
824
825 /** Transmit descriptor ring */
826 struct intelxl_ring tx;
827 /** Receive descriptor ring */
828 struct intelxl_ring rx;
829 /** Receive I/O buffers */
830 struct io_buffer *rx_iobuf[INTELXL_RX_NUM_DESC];
831 };
832
833 extern void intelxlvf_admin_event ( struct net_device *netdev,
834 struct intelxl_admin_descriptor *evt,
835 union intelxl_admin_buffer *buf );
836
837 #endif /* _INTELXL_H */