1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#ifndef _VMXNET3_DEFS_H_
28#define _VMXNET3_DEFS_H_
29
30#include "upt1_defs.h"
31
32
33
34enum {
35 VMXNET3_REG_VRRS = 0x0,
36 VMXNET3_REG_UVRS = 0x8,
37 VMXNET3_REG_DSAL = 0x10,
38 VMXNET3_REG_DSAH = 0x18,
39 VMXNET3_REG_CMD = 0x20,
40 VMXNET3_REG_MACL = 0x28,
41 VMXNET3_REG_MACH = 0x30,
42 VMXNET3_REG_ICR = 0x38,
43 VMXNET3_REG_ECR = 0x40
44};
45
46
47enum {
48 VMXNET3_REG_IMR = 0x0,
49 VMXNET3_REG_TXPROD = 0x600,
50 VMXNET3_REG_RXPROD = 0x800,
51 VMXNET3_REG_RXPROD2 = 0xA00
52};
53
54#define VMXNET3_PT_REG_SIZE 4096
55#define VMXNET3_VD_REG_SIZE 4096
56
57#define VMXNET3_REG_ALIGN 8
58#define VMXNET3_REG_ALIGN_MASK 0x7
59
60
61#define VMXNET3_IO_TYPE_PT 0
62#define VMXNET3_IO_TYPE_VD 1
63#define VMXNET3_IO_ADDR(type, reg) (((type) << 24) | ((reg) & 0xFFFFFF))
64#define VMXNET3_IO_TYPE(addr) ((addr) >> 24)
65#define VMXNET3_IO_REG(addr) ((addr) & 0xFFFFFF)
66
67enum {
68 VMXNET3_CMD_FIRST_SET = 0xCAFE0000,
69 VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET,
70 VMXNET3_CMD_QUIESCE_DEV,
71 VMXNET3_CMD_RESET_DEV,
72 VMXNET3_CMD_UPDATE_RX_MODE,
73 VMXNET3_CMD_UPDATE_MAC_FILTERS,
74 VMXNET3_CMD_UPDATE_VLAN_FILTERS,
75 VMXNET3_CMD_UPDATE_RSSIDT,
76 VMXNET3_CMD_UPDATE_IML,
77 VMXNET3_CMD_UPDATE_PMCFG,
78 VMXNET3_CMD_UPDATE_FEATURE,
79 VMXNET3_CMD_RESERVED1,
80 VMXNET3_CMD_LOAD_PLUGIN,
81 VMXNET3_CMD_RESERVED2,
82 VMXNET3_CMD_RESERVED3,
83 VMXNET3_CMD_SET_COALESCE,
84 VMXNET3_CMD_REGISTER_MEMREGS,
85
86 VMXNET3_CMD_FIRST_GET = 0xF00D0000,
87 VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
88 VMXNET3_CMD_GET_STATS,
89 VMXNET3_CMD_GET_LINK,
90 VMXNET3_CMD_GET_PERM_MAC_LO,
91 VMXNET3_CMD_GET_PERM_MAC_HI,
92 VMXNET3_CMD_GET_DID_LO,
93 VMXNET3_CMD_GET_DID_HI,
94 VMXNET3_CMD_GET_DEV_EXTRA_INFO,
95 VMXNET3_CMD_GET_CONF_INTR,
96 VMXNET3_CMD_GET_RESERVED1,
97 VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
98 VMXNET3_CMD_GET_COALESCE,
99};
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119struct Vmxnet3_TxDesc {
120 __le64 addr;
121
122#ifdef __BIG_ENDIAN_BITFIELD
123 u32 msscof:14;
124 u32 ext1:1;
125 u32 dtype:1;
126 u32 rsvd:1;
127 u32 gen:1;
128 u32 len:14;
129#else
130 u32 len:14;
131 u32 gen:1;
132 u32 rsvd:1;
133 u32 dtype:1;
134 u32 ext1:1;
135 u32 msscof:14;
136#endif
137
138#ifdef __BIG_ENDIAN_BITFIELD
139 u32 tci:16;
140 u32 ti:1;
141 u32 ext2:1;
142 u32 cq:1;
143 u32 eop:1;
144 u32 om:2;
145 u32 hlen:10;
146#else
147 u32 hlen:10;
148 u32 om:2;
149 u32 eop:1;
150 u32 cq:1;
151 u32 ext2:1;
152 u32 ti:1;
153 u32 tci:16;
154#endif
155};
156
157
158#define VMXNET3_OM_NONE 0
159#define VMXNET3_OM_CSUM 2
160#define VMXNET3_OM_TSO 3
161
162
163#define VMXNET3_TXD_EOP_SHIFT 12
164#define VMXNET3_TXD_CQ_SHIFT 13
165#define VMXNET3_TXD_GEN_SHIFT 14
166#define VMXNET3_TXD_EOP_DWORD_SHIFT 3
167#define VMXNET3_TXD_GEN_DWORD_SHIFT 2
168
169#define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT)
170#define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT)
171#define VMXNET3_TXD_GEN (1 << VMXNET3_TXD_GEN_SHIFT)
172
173#define VMXNET3_HDR_COPY_SIZE 128
174
175
176struct Vmxnet3_TxDataDesc {
177 u8 data[VMXNET3_HDR_COPY_SIZE];
178};
179
180typedef u8 Vmxnet3_RxDataDesc;
181
182#define VMXNET3_TCD_GEN_SHIFT 31
183#define VMXNET3_TCD_GEN_SIZE 1
184#define VMXNET3_TCD_TXIDX_SHIFT 0
185#define VMXNET3_TCD_TXIDX_SIZE 12
186#define VMXNET3_TCD_GEN_DWORD_SHIFT 3
187
188struct Vmxnet3_TxCompDesc {
189 u32 txdIdx:12;
190 u32 ext1:20;
191
192 __le32 ext2;
193 __le32 ext3;
194
195 u32 rsvd:24;
196 u32 type:7;
197 u32 gen:1;
198};
199
200struct Vmxnet3_RxDesc {
201 __le64 addr;
202
203#ifdef __BIG_ENDIAN_BITFIELD
204 u32 gen:1;
205 u32 rsvd:15;
206 u32 dtype:1;
207 u32 btype:1;
208 u32 len:14;
209#else
210 u32 len:14;
211 u32 btype:1;
212 u32 dtype:1;
213 u32 rsvd:15;
214 u32 gen:1;
215#endif
216 u32 ext1;
217};
218
219
220#define VMXNET3_RXD_BTYPE_HEAD 0
221#define VMXNET3_RXD_BTYPE_BODY 1
222
223
224#define VMXNET3_RXD_BTYPE_SHIFT 14
225#define VMXNET3_RXD_GEN_SHIFT 31
226
227struct Vmxnet3_RxCompDesc {
228#ifdef __BIG_ENDIAN_BITFIELD
229 u32 ext2:1;
230 u32 cnc:1;
231 u32 rssType:4;
232 u32 rqID:10;
233 u32 sop:1;
234 u32 eop:1;
235 u32 ext1:2;
236 u32 rxdIdx:12;
237#else
238 u32 rxdIdx:12;
239 u32 ext1:2;
240 u32 eop:1;
241 u32 sop:1;
242 u32 rqID:10;
243 u32 rssType:4;
244 u32 cnc:1;
245 u32 ext2:1;
246#endif
247
248 __le32 rssHash;
249
250#ifdef __BIG_ENDIAN_BITFIELD
251 u32 tci:16;
252 u32 ts:1;
253 u32 err:1;
254 u32 len:14;
255#else
256 u32 len:14;
257 u32 err:1;
258 u32 ts:1;
259 u32 tci:16;
260#endif
261
262
263#ifdef __BIG_ENDIAN_BITFIELD
264 u32 gen:1;
265 u32 type:7;
266 u32 fcs:1;
267 u32 frg:1;
268 u32 v4:1;
269 u32 v6:1;
270 u32 ipc:1;
271 u32 tcp:1;
272 u32 udp:1;
273 u32 tuc:1;
274 u32 csum:16;
275#else
276 u32 csum:16;
277 u32 tuc:1;
278 u32 udp:1;
279 u32 tcp:1;
280 u32 ipc:1;
281 u32 v6:1;
282 u32 v4:1;
283 u32 frg:1;
284 u32 fcs:1;
285 u32 type:7;
286 u32 gen:1;
287#endif
288};
289
290struct Vmxnet3_RxCompDescExt {
291 __le32 dword1;
292 u8 segCnt;
293 u8 dupAckCnt;
294 __le16 tsDelta;
295 __le32 dword2;
296#ifdef __BIG_ENDIAN_BITFIELD
297 u32 gen:1;
298 u32 type:7;
299 u32 fcs:1;
300 u32 frg:1;
301 u32 v4:1;
302 u32 v6:1;
303 u32 ipc:1;
304 u32 tcp:1;
305 u32 udp:1;
306 u32 tuc:1;
307 u32 mss:16;
308#else
309 u32 mss:16;
310 u32 tuc:1;
311 u32 udp:1;
312 u32 tcp:1;
313 u32 ipc:1;
314 u32 v6:1;
315 u32 v4:1;
316 u32 frg:1;
317 u32 fcs:1;
318 u32 type:7;
319 u32 gen:1;
320#endif
321};
322
323
324
325#define VMXNET3_RCD_TUC_SHIFT 16
326#define VMXNET3_RCD_IPC_SHIFT 19
327
328
329#define VMXNET3_RCD_TYPE_SHIFT 56
330#define VMXNET3_RCD_GEN_SHIFT 63
331
332
333#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
334 1 << VMXNET3_RCD_IPC_SHIFT)
335#define VMXNET3_TXD_GEN_SIZE 1
336#define VMXNET3_TXD_EOP_SIZE 1
337
338
339enum {
340 VMXNET3_RCD_RSS_TYPE_NONE = 0,
341 VMXNET3_RCD_RSS_TYPE_IPV4 = 1,
342 VMXNET3_RCD_RSS_TYPE_TCPIPV4 = 2,
343 VMXNET3_RCD_RSS_TYPE_IPV6 = 3,
344 VMXNET3_RCD_RSS_TYPE_TCPIPV6 = 4,
345};
346
347
348
349union Vmxnet3_GenericDesc {
350 __le64 qword[2];
351 __le32 dword[4];
352 __le16 word[8];
353 struct Vmxnet3_TxDesc txd;
354 struct Vmxnet3_RxDesc rxd;
355 struct Vmxnet3_TxCompDesc tcd;
356 struct Vmxnet3_RxCompDesc rcd;
357 struct Vmxnet3_RxCompDescExt rcdExt;
358};
359
360#define VMXNET3_INIT_GEN 1
361
362
363#define VMXNET3_MAX_TX_BUF_SIZE (1 << 14)
364
365
366#define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \
367 VMXNET3_MAX_TX_BUF_SIZE)
368
369
370#define VMXNET3_MAX_TXD_PER_PKT 16
371
372
373#define VMXNET3_MAX_RX_BUF_SIZE ((1 << 14) - 1)
374
375#define VMXNET3_MIN_T0_BUF_SIZE 128
376#define VMXNET3_MAX_CSUM_OFFSET 1024
377
378
379#define VMXNET3_RING_BA_ALIGN 512
380#define VMXNET3_RING_BA_MASK (VMXNET3_RING_BA_ALIGN - 1)
381
382
383#define VMXNET3_RING_SIZE_ALIGN 32
384#define VMXNET3_RING_SIZE_MASK (VMXNET3_RING_SIZE_ALIGN - 1)
385
386
387#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
388#define VMXNET3_TXDATA_DESC_SIZE_MASK (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
389
390
391#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
392#define VMXNET3_RXDATA_DESC_SIZE_MASK (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
393
394
395#define VMXNET3_TX_RING_MAX_SIZE 4096
396#define VMXNET3_TC_RING_MAX_SIZE 4096
397#define VMXNET3_RX_RING_MAX_SIZE 4096
398#define VMXNET3_RX_RING2_MAX_SIZE 4096
399#define VMXNET3_RC_RING_MAX_SIZE 8192
400
401#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
402#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
403
404#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
405
406
407
408enum {
409 VMXNET3_ERR_NOEOP = 0x80000000,
410 VMXNET3_ERR_TXD_REUSE = 0x80000001,
411 VMXNET3_ERR_BIG_PKT = 0x80000002,
412 VMXNET3_ERR_DESC_NOT_SPT = 0x80000003,
413 VMXNET3_ERR_SMALL_BUF = 0x80000004,
414 VMXNET3_ERR_STRESS = 0x80000005,
415 VMXNET3_ERR_SWITCH = 0x80000006,
416 VMXNET3_ERR_TXD_INVALID = 0x80000007,
417};
418
419
420#define VMXNET3_CDTYPE_TXCOMP 0
421#define VMXNET3_CDTYPE_RXCOMP 3
422#define VMXNET3_CDTYPE_RXCOMP_LRO 4
423
424enum {
425 VMXNET3_GOS_BITS_UNK = 0,
426 VMXNET3_GOS_BITS_32 = 1,
427 VMXNET3_GOS_BITS_64 = 2,
428};
429
430#define VMXNET3_GOS_TYPE_LINUX 1
431
432
433struct Vmxnet3_GOSInfo {
434#ifdef __BIG_ENDIAN_BITFIELD
435 u32 gosMisc:10;
436 u32 gosVer:16;
437 u32 gosType:4;
438 u32 gosBits:2;
439#else
440 u32 gosBits:2;
441 u32 gosType:4;
442 u32 gosVer:16;
443 u32 gosMisc:10;
444#endif
445};
446
447struct Vmxnet3_DriverInfo {
448 __le32 version;
449 struct Vmxnet3_GOSInfo gos;
450 __le32 vmxnet3RevSpt;
451 __le32 uptVerSpt;
452};
453
454
455#define VMXNET3_REV1_MAGIC 3133079265u
456
457
458
459
460
461
462
463#define VMXNET3_QUEUE_DESC_ALIGN 128
464
465
466struct Vmxnet3_MiscConf {
467 struct Vmxnet3_DriverInfo driverInfo;
468 __le64 uptFeatures;
469 __le64 ddPA;
470 __le64 queueDescPA;
471 __le32 ddLen;
472 __le32 queueDescLen;
473 __le32 mtu;
474 __le16 maxNumRxSG;
475 u8 numTxQueues;
476 u8 numRxQueues;
477 __le32 reserved[4];
478};
479
480
481struct Vmxnet3_TxQueueConf {
482 __le64 txRingBasePA;
483 __le64 dataRingBasePA;
484 __le64 compRingBasePA;
485 __le64 ddPA;
486 __le64 reserved;
487 __le32 txRingSize;
488 __le32 dataRingSize;
489 __le32 compRingSize;
490 __le32 ddLen;
491 u8 intrIdx;
492 u8 _pad1[1];
493 __le16 txDataRingDescSize;
494 u8 _pad2[4];
495};
496
497
498struct Vmxnet3_RxQueueConf {
499 __le64 rxRingBasePA[2];
500 __le64 compRingBasePA;
501 __le64 ddPA;
502 __le64 rxDataRingBasePA;
503 __le32 rxRingSize[2];
504 __le32 compRingSize;
505 __le32 ddLen;
506 u8 intrIdx;
507 u8 _pad1[1];
508 __le16 rxDataRingDescSize;
509 u8 _pad2[4];
510};
511
512
513enum vmxnet3_intr_mask_mode {
514 VMXNET3_IMM_AUTO = 0,
515 VMXNET3_IMM_ACTIVE = 1,
516 VMXNET3_IMM_LAZY = 2
517};
518
519enum vmxnet3_intr_type {
520 VMXNET3_IT_AUTO = 0,
521 VMXNET3_IT_INTX = 1,
522 VMXNET3_IT_MSI = 2,
523 VMXNET3_IT_MSIX = 3
524};
525
526#define VMXNET3_MAX_TX_QUEUES 8
527#define VMXNET3_MAX_RX_QUEUES 16
528
529#define VMXNET3_MAX_INTRS 25
530
531
532#define VMXNET3_IC_DISABLE_ALL 0x1
533
534
535struct Vmxnet3_IntrConf {
536 bool autoMask;
537 u8 numIntrs;
538 u8 eventIntrIdx;
539 u8 modLevels[VMXNET3_MAX_INTRS];
540
541 __le32 intrCtrl;
542 __le32 reserved[2];
543};
544
545
546#define VMXNET3_VFT_SIZE (4096 / (sizeof(u32) * 8))
547
548
549struct Vmxnet3_QueueStatus {
550 bool stopped;
551 u8 _pad[3];
552 __le32 error;
553};
554
555
556struct Vmxnet3_TxQueueCtrl {
557 __le32 txNumDeferred;
558 __le32 txThreshold;
559 __le64 reserved;
560};
561
562
563struct Vmxnet3_RxQueueCtrl {
564 bool updateRxProd;
565 u8 _pad[7];
566 __le64 reserved;
567};
568
569enum {
570 VMXNET3_RXM_UCAST = 0x01,
571 VMXNET3_RXM_MCAST = 0x02,
572 VMXNET3_RXM_BCAST = 0x04,
573 VMXNET3_RXM_ALL_MULTI = 0x08,
574 VMXNET3_RXM_PROMISC = 0x10
575};
576
577struct Vmxnet3_RxFilterConf {
578 __le32 rxMode;
579 __le16 mfTableLen;
580 __le16 _pad1;
581 __le64 mfTablePA;
582 __le32 vfTable[VMXNET3_VFT_SIZE];
583};
584
585
586#define VMXNET3_PM_MAX_FILTERS 6
587#define VMXNET3_PM_MAX_PATTERN_SIZE 128
588#define VMXNET3_PM_MAX_MASK_SIZE (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
589
590#define VMXNET3_PM_WAKEUP_MAGIC cpu_to_le16(0x01)
591#define VMXNET3_PM_WAKEUP_FILTER cpu_to_le16(0x02)
592
593
594
595struct Vmxnet3_PM_PktFilter {
596 u8 maskSize;
597 u8 patternSize;
598 u8 mask[VMXNET3_PM_MAX_MASK_SIZE];
599 u8 pattern[VMXNET3_PM_MAX_PATTERN_SIZE];
600 u8 pad[6];
601};
602
603
604struct Vmxnet3_PMConf {
605 __le16 wakeUpEvents;
606 u8 numFilters;
607 u8 pad[5];
608 struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
609};
610
611
612struct Vmxnet3_VariableLenConfDesc {
613 __le32 confVer;
614 __le32 confLen;
615 __le64 confPA;
616};
617
618
619struct Vmxnet3_TxQueueDesc {
620 struct Vmxnet3_TxQueueCtrl ctrl;
621 struct Vmxnet3_TxQueueConf conf;
622
623
624 struct Vmxnet3_QueueStatus status;
625 struct UPT1_TxStats stats;
626 u8 _pad[88];
627};
628
629
630struct Vmxnet3_RxQueueDesc {
631 struct Vmxnet3_RxQueueCtrl ctrl;
632 struct Vmxnet3_RxQueueConf conf;
633
634 struct Vmxnet3_QueueStatus status;
635 struct UPT1_RxStats stats;
636 u8 __pad[88];
637};
638
639struct Vmxnet3_SetPolling {
640 u8 enablePolling;
641};
642
643#define VMXNET3_COAL_STATIC_MAX_DEPTH 128
644#define VMXNET3_COAL_RBC_MIN_RATE 100
645#define VMXNET3_COAL_RBC_MAX_RATE 100000
646
647enum Vmxnet3_CoalesceMode {
648 VMXNET3_COALESCE_DISABLED = 0,
649 VMXNET3_COALESCE_ADAPT = 1,
650 VMXNET3_COALESCE_STATIC = 2,
651 VMXNET3_COALESCE_RBC = 3
652};
653
654struct Vmxnet3_CoalesceRbc {
655 u32 rbc_rate;
656};
657
658struct Vmxnet3_CoalesceStatic {
659 u32 tx_depth;
660 u32 tx_comp_depth;
661 u32 rx_depth;
662};
663
664struct Vmxnet3_CoalesceScheme {
665 enum Vmxnet3_CoalesceMode coalMode;
666 union {
667 struct Vmxnet3_CoalesceRbc coalRbc;
668 struct Vmxnet3_CoalesceStatic coalStatic;
669 } coalPara;
670};
671
672struct Vmxnet3_MemoryRegion {
673 __le64 startPA;
674 __le32 length;
675 __le16 txQueueBits;
676 __le16 rxQueueBits;
677};
678
679#define MAX_MEMORY_REGION_PER_QUEUE 16
680#define MAX_MEMORY_REGION_PER_DEVICE 256
681
682struct Vmxnet3_MemRegs {
683 __le16 numRegs;
684 __le16 pad[3];
685 struct Vmxnet3_MemoryRegion memRegs[1];
686};
687
688
689
690
691union Vmxnet3_CmdInfo {
692 struct Vmxnet3_VariableLenConfDesc varConf;
693 struct Vmxnet3_SetPolling setPolling;
694 __le64 data[2];
695};
696
697struct Vmxnet3_DSDevRead {
698
699 struct Vmxnet3_MiscConf misc;
700 struct Vmxnet3_IntrConf intrConf;
701 struct Vmxnet3_RxFilterConf rxFilterConf;
702 struct Vmxnet3_VariableLenConfDesc rssConfDesc;
703 struct Vmxnet3_VariableLenConfDesc pmConfDesc;
704 struct Vmxnet3_VariableLenConfDesc pluginConfDesc;
705};
706
707
708struct Vmxnet3_DriverShared {
709 __le32 magic;
710
711 __le32 pad;
712 struct Vmxnet3_DSDevRead devRead;
713 __le32 ecr;
714 __le32 reserved;
715 union {
716 __le32 reserved1[4];
717 union Vmxnet3_CmdInfo cmdInfo;
718
719
720
721 } cu;
722};
723
724
725#define VMXNET3_ECR_RQERR (1 << 0)
726#define VMXNET3_ECR_TQERR (1 << 1)
727#define VMXNET3_ECR_LINK (1 << 2)
728#define VMXNET3_ECR_DIC (1 << 3)
729#define VMXNET3_ECR_DEBUG (1 << 4)
730
731
732#define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1)
733
734
735#define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \
736 do {\
737 (idx)++;\
738 if (unlikely((idx) == (ring_size))) {\
739 (idx) = 0;\
740 } \
741 } while (0)
742
743#define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \
744 (vfTable[vid >> 5] |= (1 << (vid & 31)))
745#define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \
746 (vfTable[vid >> 5] &= ~(1 << (vid & 31)))
747
748#define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \
749 ((vfTable[vid >> 5] & (1 << (vid & 31))) != 0)
750
751#define VMXNET3_MAX_MTU 9000
752#define VMXNET3_MIN_MTU 60
753
754#define VMXNET3_LINK_UP (10000 << 16 | 1)
755#define VMXNET3_LINK_DOWN 0
756
757#endif
758