1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef _VNIC_DEVCMD_H_
21 #define _VNIC_DEVCMD_H_
22
23 #define _CMD_NBITS 14
24 #define _CMD_VTYPEBITS 10
25 #define _CMD_FLAGSBITS 6
26 #define _CMD_DIRBITS 2
27
28 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
29 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
30 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
31 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
32
33 #define _CMD_NSHIFT 0
34 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
35 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
36 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
37
38
39
40
41 #define _CMD_DIR_NONE 0U
42 #define _CMD_DIR_WRITE 1U
43 #define _CMD_DIR_READ 2U
44 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
45
46
47
48
49 #define _CMD_FLAGS_NONE 0U
50 #define _CMD_FLAGS_NOWAIT 1U
51
52
53
54
55 #define _CMD_VTYPE_NONE 0U
56 #define _CMD_VTYPE_ENET 1U
57 #define _CMD_VTYPE_FC 2U
58 #define _CMD_VTYPE_SCSI 4U
59 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
60
61
62
63
64 #define _CMDCF(dir, flags, vtype, nr) \
65 (((dir) << _CMD_DIRSHIFT) | \
66 ((flags) << _CMD_FLAGSSHIFT) | \
67 ((vtype) << _CMD_VTYPESHIFT) | \
68 ((nr) << _CMD_NSHIFT))
69 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
70 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
71
72
73
74
75 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
76 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
77 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
78 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
79
80 enum vnic_devcmd_cmd {
81 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
82
83
84
85
86
87
88
89
90
91
92 CMD_MCPU_FW_INFO_OLD = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
111
112
113
114
115 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
116
117
118 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
119
120
121
122 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
123
124
125 CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
126
127
128 CMD_PACKET_FILTER_ALL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7),
129
130
131 CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
132
133
134 CMD_GET_MAC_ADDR = _CMDC(_CMD_DIR_READ,
135 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9),
136
137
138 CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
139 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
140
141
142 CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
143 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
144
145
146 CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
147
148
149 CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
150
151
152
153
154
155
156
157
158
159
160 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
161
162
163
164
165
166
167
168
169
170 CMD_NIC_CFG_CHK = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
171
172
173 CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17),
174
175
176 CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18),
177
178
179 CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
180
181
182
183 CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
184
185
186
187
188
189
190
191
192
193 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
194
195
196
197 CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
198
199
200 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
201
202
203
204 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
205
206
207 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
208
209
210
211 CMD_INIT_v1 = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
212
213
214
215
216 CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
217
218
219 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
220
221
222 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
223
224
225 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
226
227
228
229
230 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
231
232
233
234
235 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
236
237
238
239 CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
240
241
242 CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
243
244
245 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
246
247
248 CMD_INIT = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
249
250
251
252
253 CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
254
255
256
257
258 CMD_PERBI = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37),
259
260
261
262
263 CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
264
265
266 CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
267
268
269
270 CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
271
272
273
274
275
276 CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41),
277
278
279
280
281
282
283
284 CMD_PROXY_BY_BDF = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42),
285
286
287
288
289
290 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
291
292
293
294
295
296
297
298
299
300 CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
301
302
303
304
305 CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
306
307
308
309
310
311
312
313 CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
314
315
316
317
318
319
320
321 CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
322
323
324
325
326
327 CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352 CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371 CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
372
373
374
375
376
377
378 CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
379
380
381
382
383
384 CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
385
386
387
388
389
390 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
391
392
393
394
395
396
397 CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
398
399
400
401
402 CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
403
404
405
406
407
408 CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
409
410
411
412
413
414 CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
415
416
417
418
419
420
421 CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
422
423
424
425
426 CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
427
428
429
430
431
432
433
434 CMD_GET_SUPP_FEATURE_VER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 69),
435
436
437
438
439
440
441
442
443 CMD_OVERLAY_OFFLOAD_CTRL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 72),
444
445
446
447
448
449
450
451 CMD_OVERLAY_OFFLOAD_CFG = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 73),
452 };
453
454
455 #define CMD_ENABLE2_STANDBY 0x0
456 #define CMD_ENABLE2_ACTIVE 0x1
457
458
459 #define CMD_OPENF_OPROM 0x1
460 #define CMD_OPENF_IG_DESCCACHE 0x2
461
462
463 #define CMD_INITF_DEFAULT_MAC 0x1
464
465
466 #define CMD_PFILTER_DIRECTED 0x01
467 #define CMD_PFILTER_MULTICAST 0x02
468 #define CMD_PFILTER_BROADCAST 0x04
469 #define CMD_PFILTER_PROMISCUOUS 0x08
470 #define CMD_PFILTER_ALL_MULTICAST 0x10
471
472
473 #define CMD_QP_RQWQ 0x0
474
475
476 #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK 0
477 #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN 1
478 #define IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN 2
479 #define IG_VLAN_REWRITE_MODE_PASS_THRU 3
480
481 enum vnic_devcmd_status {
482 STAT_NONE = 0,
483 STAT_BUSY = 1 << 0,
484 STAT_ERROR = 1 << 1,
485 };
486
487 enum vnic_devcmd_error {
488 ERR_SUCCESS = 0,
489 ERR_EINVAL = 1,
490 ERR_EFAULT = 2,
491 ERR_EPERM = 3,
492 ERR_EBUSY = 4,
493 ERR_ECMDUNKNOWN = 5,
494 ERR_EBADSTATE = 6,
495 ERR_ENOMEM = 7,
496 ERR_ETIMEDOUT = 8,
497 ERR_ELINKDOWN = 9,
498 ERR_EMAXRES = 10,
499 ERR_ENOTSUPPORTED = 11,
500 ERR_EINPROGRESS = 12,
501 ERR_MAX
502 };
503
504
505
506
507
508
509
510 struct vnic_devcmd_fw_info {
511 char fw_version[32];
512 char fw_build[32];
513 char hw_version[32];
514 char hw_serial_number[32];
515 u16 asic_type;
516 u16 asic_rev;
517 };
518
519 struct vnic_devcmd_notify {
520 u32 csum;
521
522 u32 link_state;
523 u32 port_speed;
524 u32 mtu;
525 u32 msglvl;
526 u32 uif;
527 u32 status;
528 u32 error;
529 u32 link_down_cnt;
530 u32 perbi_rebuild_cnt;
531 };
532 #define VNIC_STF_FATAL_ERR 0x0001
533 #define VNIC_STF_STD_PAUSE 0x0002
534 #define VNIC_STF_PFC_PAUSE 0x0004
535
536 #define VNIC_STF_ALL (VNIC_STF_FATAL_ERR |\
537 VNIC_STF_STD_PAUSE |\
538 VNIC_STF_PFC_PAUSE |\
539 0)
540
541 struct vnic_devcmd_provinfo {
542 u8 oui[3];
543 u8 type;
544 u8 data[0];
545 };
546
547
548
549
550 #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
551
552 #define FILTER_FIELDS_USNIC ( \
553 FILTER_FIELD_VALID(1) | \
554 FILTER_FIELD_VALID(2) | \
555 FILTER_FIELD_VALID(3) | \
556 FILTER_FIELD_VALID(4))
557
558 #define FILTER_FIELDS_IPV4_5TUPLE ( \
559 FILTER_FIELD_VALID(1) | \
560 FILTER_FIELD_VALID(2) | \
561 FILTER_FIELD_VALID(3) | \
562 FILTER_FIELD_VALID(4) | \
563 FILTER_FIELD_VALID(5))
564
565 #define FILTER_FIELDS_MAC_VLAN ( \
566 FILTER_FIELD_VALID(1) | \
567 FILTER_FIELD_VALID(2))
568
569 #define FILTER_FIELD_USNIC_VLAN FILTER_FIELD_VALID(1)
570 #define FILTER_FIELD_USNIC_ETHTYPE FILTER_FIELD_VALID(2)
571 #define FILTER_FIELD_USNIC_PROTO FILTER_FIELD_VALID(3)
572 #define FILTER_FIELD_USNIC_ID FILTER_FIELD_VALID(4)
573
574 struct filter_usnic_id {
575 u32 flags;
576 u16 vlan;
577 u16 ethtype;
578 u8 proto_version;
579 u32 usnic_id;
580 } __packed;
581
582 #define FILTER_FIELD_5TUP_PROTO FILTER_FIELD_VALID(1)
583 #define FILTER_FIELD_5TUP_SRC_AD FILTER_FIELD_VALID(2)
584 #define FILTER_FIELD_5TUP_DST_AD FILTER_FIELD_VALID(3)
585 #define FILTER_FIELD_5TUP_SRC_PT FILTER_FIELD_VALID(4)
586 #define FILTER_FIELD_5TUP_DST_PT FILTER_FIELD_VALID(5)
587
588
589 enum protocol_e {
590 PROTO_UDP = 0,
591 PROTO_TCP = 1,
592 };
593
594 struct filter_ipv4_5tuple {
595 u32 flags;
596 u32 protocol;
597 u32 src_addr;
598 u32 dst_addr;
599 u16 src_port;
600 u16 dst_port;
601 } __packed;
602
603 #define FILTER_FIELD_VMQ_VLAN FILTER_FIELD_VALID(1)
604 #define FILTER_FIELD_VMQ_MAC FILTER_FIELD_VALID(2)
605
606 struct filter_mac_vlan {
607 u32 flags;
608 u16 vlan;
609 u8 mac_addr[6];
610 } __packed;
611
612
613 enum {
614 FILTER_ACTION_RQ_STEERING = 0,
615 FILTER_ACTION_MAX
616 };
617
618 struct filter_action {
619 u32 type;
620 union {
621 u32 rq_idx;
622 } u;
623 } __packed;
624
625
626 enum filter_type {
627 FILTER_USNIC_ID = 0,
628 FILTER_IPV4_5TUPLE = 1,
629 FILTER_MAC_VLAN = 2,
630 FILTER_MAX
631 };
632
633 struct filter {
634 u32 type;
635 union {
636 struct filter_usnic_id usnic;
637 struct filter_ipv4_5tuple ipv4;
638 struct filter_mac_vlan mac_vlan;
639 } u;
640 } __packed;
641
642 enum {
643 CLSF_TLV_FILTER = 0,
644 CLSF_TLV_ACTION = 1,
645 };
646
647
648 #define FILTER_MAX_BUF_SIZE 100
649
650 struct filter_tlv {
651 u_int32_t type;
652 u_int32_t length;
653 u_int32_t val[0];
654 };
655
656 enum {
657 CLSF_ADD = 0,
658 CLSF_DEL = 1,
659 };
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675 #define VNIC_DEVCMD_NARGS 15
676 struct vnic_devcmd {
677 u32 status;
678 u32 cmd;
679 u64 args[VNIC_DEVCMD_NARGS];
680 };
681
682 #define DEVCMD2_FNORESULT 0x1
683
684 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
685 struct vnic_devcmd2 {
686 u16 pad;
687 u16 flags;
688 u32 cmd;
689 u64 args[VNIC_DEVCMD2_NARGS];
690 };
691
692 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
693 struct devcmd2_result {
694 u64 results[VNIC_DEVCMD2_NRESULTS];
695 u32 pad;
696 u16 completed_index;
697 u8 error;
698 u8 color;
699 };
700
701 #define DEVCMD2_RING_SIZE 32
702 #define DEVCMD2_DESC_SIZE 128
703
704 enum overlay_feature_t {
705 OVERLAY_FEATURE_NVGRE = 1,
706 OVERLAY_FEATURE_VXLAN,
707 OVERLAY_FEATURE_MAX,
708 };
709
710 enum overlay_ofld_cmd {
711 OVERLAY_OFFLOAD_ENABLE,
712 OVERLAY_OFFLOAD_DISABLE,
713 OVERLAY_OFFLOAD_ENABLE_P2,
714 OVERLAY_OFFLOAD_MAX,
715 };
716
717 #define OVERLAY_CFG_VXLAN_PORT_UPDATE 0
718
719 #define ENIC_VXLAN_INNER_IPV6 BIT(0)
720 #define ENIC_VXLAN_OUTER_IPV6 BIT(1)
721 #define ENIC_VXLAN_MULTI_WQ BIT(2)
722
723
724
725
726
727 enum vic_feature_t {
728 VIC_FEATURE_VXLAN,
729 VIC_FEATURE_RDMA,
730 VIC_FEATURE_VXLAN_PATCH,
731 VIC_FEATURE_MAX,
732 };
733
734 #endif