1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _VIRTCHNL_H_
14#define _VIRTCHNL_H_
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49enum virtchnl_status_code {
50 VIRTCHNL_STATUS_SUCCESS = 0,
51 VIRTCHNL_STATUS_ERR_PARAM = -5,
52 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
53 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
54 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
55 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
56 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
57 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
58};
59
60
61#define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
62#define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
63
64#define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0
65#define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
66#define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
67#define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
68#define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
69#define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
70#define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
71#define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7
72
73enum virtchnl_link_speed {
74 VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
75 VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT),
76 VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT),
77 VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT),
78 VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
79 VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
80 VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
81 VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT),
82 VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT),
83};
84
85
86
87enum virtchnl_rx_hsplit {
88 VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0,
89 VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1,
90 VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2,
91 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4,
92 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8,
93};
94
95
96
97
98
99
100enum virtchnl_ops {
101
102
103
104
105
106
107 VIRTCHNL_OP_UNKNOWN = 0,
108 VIRTCHNL_OP_VERSION = 1,
109 VIRTCHNL_OP_RESET_VF = 2,
110 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
111 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
112 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
113 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
114 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
115 VIRTCHNL_OP_ENABLE_QUEUES = 8,
116 VIRTCHNL_OP_DISABLE_QUEUES = 9,
117 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
118 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
119 VIRTCHNL_OP_ADD_VLAN = 12,
120 VIRTCHNL_OP_DEL_VLAN = 13,
121 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
122 VIRTCHNL_OP_GET_STATS = 15,
123 VIRTCHNL_OP_RSVD = 16,
124 VIRTCHNL_OP_EVENT = 17,
125 VIRTCHNL_OP_IWARP = 20,
126 VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21,
127 VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22,
128 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
129 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
130 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
131 VIRTCHNL_OP_SET_RSS_HENA = 26,
132 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
133 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
134 VIRTCHNL_OP_REQUEST_QUEUES = 29,
135 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
136 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
137 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
138 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
139
140 VIRTCHNL_OP_ADD_RSS_CFG = 45,
141 VIRTCHNL_OP_DEL_RSS_CFG = 46,
142 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
143 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
144 VIRTCHNL_OP_MAX,
145};
146
147
148
149
150
151
152#define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
153 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
154#define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
155 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
156
157
158
159
160
161struct virtchnl_msg {
162 u8 pad[8];
163 enum virtchnl_ops v_opcode;
164 enum virtchnl_status_code v_retval;
165 u32 vfid;
166};
167
168VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184#define VIRTCHNL_VERSION_MAJOR 1
185#define VIRTCHNL_VERSION_MINOR 1
186#define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
187
188struct virtchnl_version_info {
189 u32 major;
190 u32 minor;
191};
192
193VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
194
195#define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
196#define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214enum virtchnl_vsi_type {
215 VIRTCHNL_VSI_TYPE_INVALID = 0,
216 VIRTCHNL_VSI_SRIOV = 6,
217};
218
219
220
221
222
223
224
225
226
227struct virtchnl_vsi_resource {
228 u16 vsi_id;
229 u16 num_queue_pairs;
230 enum virtchnl_vsi_type vsi_type;
231 u16 qset_handle;
232 u8 default_mac_addr[ETH_ALEN];
233};
234
235VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
236
237
238
239
240
241#define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
242#define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
243#define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
244#define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
245#define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
246#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
247
248#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
249#define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
250#define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
251#define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
252#define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
253#define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
254#define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
255#define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
256#define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
257#define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
258#define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
259#define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
260
261#define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
262 VIRTCHNL_VF_OFFLOAD_VLAN | \
263 VIRTCHNL_VF_OFFLOAD_RSS_PF)
264
265struct virtchnl_vf_resource {
266 u16 num_vsis;
267 u16 num_queue_pairs;
268 u16 max_vectors;
269 u16 max_mtu;
270
271 u32 vf_cap_flags;
272 u32 rss_key_size;
273 u32 rss_lut_size;
274
275 struct virtchnl_vsi_resource vsi_res[1];
276};
277
278VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
279
280
281
282
283
284
285
286
287struct virtchnl_txq_info {
288 u16 vsi_id;
289 u16 queue_id;
290 u16 ring_len;
291 u16 headwb_enabled;
292 u64 dma_ring_addr;
293 u64 dma_headwb_addr;
294};
295
296VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
297
298
299
300
301
302
303
304
305struct virtchnl_rxq_info {
306 u16 vsi_id;
307 u16 queue_id;
308 u32 ring_len;
309 u16 hdr_size;
310 u16 splithdr_enabled;
311 u32 databuffer_size;
312 u32 max_pkt_size;
313 u32 pad1;
314 u64 dma_ring_addr;
315 enum virtchnl_rx_hsplit rx_split_pos;
316 u32 pad2;
317};
318
319VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
320
321
322
323
324
325
326
327
328struct virtchnl_queue_pair_info {
329
330 struct virtchnl_txq_info txq;
331 struct virtchnl_rxq_info rxq;
332};
333
334VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
335
336struct virtchnl_vsi_queue_config_info {
337 u16 vsi_id;
338 u16 num_queue_pairs;
339 u32 pad;
340 struct virtchnl_queue_pair_info qpair[1];
341};
342
343VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
344
345
346
347
348
349
350
351
352
353
354
355
356struct virtchnl_vf_res_request {
357 u16 num_queue_pairs;
358};
359
360
361
362
363
364
365
366
367struct virtchnl_vector_map {
368 u16 vsi_id;
369 u16 vector_id;
370 u16 rxq_map;
371 u16 txq_map;
372 u16 rxitr_idx;
373 u16 txitr_idx;
374};
375
376VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
377
378struct virtchnl_irq_map_info {
379 u16 num_vectors;
380 struct virtchnl_vector_map vecmap[1];
381};
382
383VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
384
385
386
387
388
389
390
391
392
393struct virtchnl_queue_select {
394 u16 vsi_id;
395 u16 pad;
396 u32 rx_queues;
397 u32 tx_queues;
398};
399
400VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436struct virtchnl_ether_addr {
437 u8 addr[ETH_ALEN];
438 u8 type;
439#define VIRTCHNL_ETHER_ADDR_LEGACY 0
440#define VIRTCHNL_ETHER_ADDR_PRIMARY 1
441#define VIRTCHNL_ETHER_ADDR_EXTRA 2
442#define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3
443 u8 pad;
444};
445
446VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
447
448struct virtchnl_ether_addr_list {
449 u16 vsi_id;
450 u16 num_elements;
451 struct virtchnl_ether_addr list[1];
452};
453
454VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470struct virtchnl_vlan_filter_list {
471 u16 vsi_id;
472 u16 num_elements;
473 u16 vlan_id[1];
474};
475
476VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
477
478
479
480
481
482
483struct virtchnl_promisc_info {
484 u16 vsi_id;
485 u16 flags;
486};
487
488VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
489
490#define FLAG_VF_UNICAST_PROMISC 0x00000001
491#define FLAG_VF_MULTICAST_PROMISC 0x00000002
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510struct virtchnl_rss_key {
511 u16 vsi_id;
512 u16 key_len;
513 u8 key[1];
514};
515
516VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
517
518struct virtchnl_rss_lut {
519 u16 vsi_id;
520 u16 lut_entries;
521 u8 lut[1];
522};
523
524VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
525
526
527
528
529
530
531
532
533struct virtchnl_rss_hena {
534 u64 hena;
535};
536
537VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
538
539
540
541
542
543
544
545
546struct virtchnl_channel_info {
547 u16 count;
548 u16 offset;
549 u32 pad;
550 u64 max_tx_rate;
551};
552
553VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
554
555struct virtchnl_tc_info {
556 u32 num_tc;
557 u32 pad;
558 struct virtchnl_channel_info list[1];
559};
560
561VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
562
563
564
565
566
567
568
569
570
571struct virtchnl_l4_spec {
572 u8 src_mac[ETH_ALEN];
573 u8 dst_mac[ETH_ALEN];
574 __be16 vlan_id;
575 __be16 pad;
576 __be32 src_ip[4];
577 __be32 dst_ip[4];
578 __be16 src_port;
579 __be16 dst_port;
580};
581
582VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
583
584union virtchnl_flow_spec {
585 struct virtchnl_l4_spec tcp_spec;
586 u8 buffer[128];
587};
588
589VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
590
591enum virtchnl_action {
592
593 VIRTCHNL_ACTION_DROP = 0,
594 VIRTCHNL_ACTION_TC_REDIRECT,
595 VIRTCHNL_ACTION_PASSTHRU,
596 VIRTCHNL_ACTION_QUEUE,
597 VIRTCHNL_ACTION_Q_REGION,
598 VIRTCHNL_ACTION_MARK,
599 VIRTCHNL_ACTION_COUNT,
600};
601
602enum virtchnl_flow_type {
603
604 VIRTCHNL_TCP_V4_FLOW = 0,
605 VIRTCHNL_TCP_V6_FLOW,
606};
607
608struct virtchnl_filter {
609 union virtchnl_flow_spec data;
610 union virtchnl_flow_spec mask;
611 enum virtchnl_flow_type flow_type;
612 enum virtchnl_action action;
613 u32 action_meta;
614 u8 field_flags;
615 u8 pad[3];
616};
617
618VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
619
620
621
622
623
624
625enum virtchnl_event_codes {
626 VIRTCHNL_EVENT_UNKNOWN = 0,
627 VIRTCHNL_EVENT_LINK_CHANGE,
628 VIRTCHNL_EVENT_RESET_IMPENDING,
629 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
630};
631
632#define PF_EVENT_SEVERITY_INFO 0
633#define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
634
635struct virtchnl_pf_event {
636 enum virtchnl_event_codes event;
637 union {
638
639
640
641
642
643
644
645
646 struct {
647 enum virtchnl_link_speed link_speed;
648 bool link_status;
649 } link_event;
650 struct {
651
652 u32 link_speed;
653 u8 link_status;
654 u8 pad[3];
655 } link_event_adv;
656 } event_data;
657
658 int severity;
659};
660
661VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
662
663
664
665
666
667
668
669
670
671
672
673
674
675struct virtchnl_iwarp_qv_info {
676 u32 v_idx;
677 u16 ceq_idx;
678 u16 aeq_idx;
679 u8 itr_idx;
680 u8 pad[3];
681};
682
683VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_iwarp_qv_info);
684
685struct virtchnl_iwarp_qvlist_info {
686 u32 num_vectors;
687 struct virtchnl_iwarp_qv_info qv_info[1];
688};
689
690VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_iwarp_qvlist_info);
691
692
693
694
695
696
697
698
699
700
701
702
703enum virtchnl_vfr_states {
704 VIRTCHNL_VFR_INPROGRESS = 0,
705 VIRTCHNL_VFR_COMPLETED,
706 VIRTCHNL_VFR_VFACTIVE,
707};
708
709
710enum virtchnl_rss_algorithm {
711 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
712 VIRTCHNL_RSS_ALG_R_ASYMMETRIC = 1,
713 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
714 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
715};
716
717#define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
718#define PROTO_HDR_SHIFT 5
719#define PROTO_HDR_FIELD_START(proto_hdr_type) ((proto_hdr_type) << PROTO_HDR_SHIFT)
720#define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
721
722
723
724
725
726
727
728
729#define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
730 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
731#define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
732 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
733#define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
734 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
735#define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
736
737#define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
738 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
739 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
740#define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
741 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
742 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
743
744#define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
745 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
746#define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
747 (((hdr)->type) >> PROTO_HDR_SHIFT)
748#define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
749 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
750#define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
751 (VIRTCHNL_TEST_PROTO_HDR_TYPE((hdr), (val)) && \
752 VIRTCHNL_TEST_PROTO_HDR_FIELD((hdr), (val)))
753
754
755
756
757
758
759enum virtchnl_proto_hdr_type {
760 VIRTCHNL_PROTO_HDR_NONE,
761 VIRTCHNL_PROTO_HDR_ETH,
762 VIRTCHNL_PROTO_HDR_S_VLAN,
763 VIRTCHNL_PROTO_HDR_C_VLAN,
764 VIRTCHNL_PROTO_HDR_IPV4,
765 VIRTCHNL_PROTO_HDR_IPV6,
766 VIRTCHNL_PROTO_HDR_TCP,
767 VIRTCHNL_PROTO_HDR_UDP,
768 VIRTCHNL_PROTO_HDR_SCTP,
769 VIRTCHNL_PROTO_HDR_GTPU_IP,
770 VIRTCHNL_PROTO_HDR_GTPU_EH,
771 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
772 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
773 VIRTCHNL_PROTO_HDR_PPPOE,
774 VIRTCHNL_PROTO_HDR_L2TPV3,
775 VIRTCHNL_PROTO_HDR_ESP,
776 VIRTCHNL_PROTO_HDR_AH,
777 VIRTCHNL_PROTO_HDR_PFCP,
778};
779
780
781enum virtchnl_proto_hdr_field {
782
783 VIRTCHNL_PROTO_HDR_ETH_SRC =
784 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
785 VIRTCHNL_PROTO_HDR_ETH_DST,
786 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
787
788 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
789 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
790
791 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
792 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
793
794 VIRTCHNL_PROTO_HDR_IPV4_SRC =
795 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
796 VIRTCHNL_PROTO_HDR_IPV4_DST,
797 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
798 VIRTCHNL_PROTO_HDR_IPV4_TTL,
799 VIRTCHNL_PROTO_HDR_IPV4_PROT,
800
801 VIRTCHNL_PROTO_HDR_IPV6_SRC =
802 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
803 VIRTCHNL_PROTO_HDR_IPV6_DST,
804 VIRTCHNL_PROTO_HDR_IPV6_TC,
805 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
806 VIRTCHNL_PROTO_HDR_IPV6_PROT,
807
808 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
809 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
810 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
811
812 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
813 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
814 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
815
816 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
817 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
818 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
819
820 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
821 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
822
823 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
824 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
825 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
826
827 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
828 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
829
830 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
831 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
832
833 VIRTCHNL_PROTO_HDR_ESP_SPI =
834 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
835
836 VIRTCHNL_PROTO_HDR_AH_SPI =
837 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
838
839 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
840 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
841 VIRTCHNL_PROTO_HDR_PFCP_SEID,
842};
843
844struct virtchnl_proto_hdr {
845 enum virtchnl_proto_hdr_type type;
846 u32 field_selector;
847 u8 buffer[64];
848
849
850
851
852
853};
854
855VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
856
857struct virtchnl_proto_hdrs {
858 u8 tunnel_level;
859 u8 pad[3];
860
861
862
863
864
865
866
867 int count;
868 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
869};
870
871VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
872
873struct virtchnl_rss_cfg {
874 struct virtchnl_proto_hdrs proto_hdrs;
875 enum virtchnl_rss_algorithm rss_algorithm;
876 u8 reserved[128];
877};
878
879VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
880
881
882struct virtchnl_filter_action {
883 enum virtchnl_action type;
884 union {
885
886 struct {
887 u16 index;
888 u8 region;
889 } queue;
890
891 struct {
892
893 u8 shared;
894 u32 id;
895 } count;
896
897 u32 mark_id;
898 u8 reserve[32];
899 } act_conf;
900};
901
902VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
903
904#define VIRTCHNL_MAX_NUM_ACTIONS 8
905
906struct virtchnl_filter_action_set {
907
908 int count;
909 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
910};
911
912VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
913
914
915struct virtchnl_fdir_rule {
916 struct virtchnl_proto_hdrs proto_hdrs;
917 struct virtchnl_filter_action_set action_set;
918};
919
920VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947enum virtchnl_fdir_prgm_status {
948 VIRTCHNL_FDIR_SUCCESS = 0,
949 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
950 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
951 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
952 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
953 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
954 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
955};
956
957
958
959
960
961
962struct virtchnl_fdir_add {
963 u16 vsi_id;
964
965
966
967
968 u16 validate_only;
969 u32 flow_id;
970 struct virtchnl_fdir_rule rule_cfg;
971 enum virtchnl_fdir_prgm_status status;
972};
973
974VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
975
976
977
978
979
980struct virtchnl_fdir_del {
981 u16 vsi_id;
982 u16 pad;
983 u32 flow_id;
984 enum virtchnl_fdir_prgm_status status;
985};
986
987VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
988
989
990
991
992
993
994
995
996
997
998static inline int
999virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1000 u8 *msg, u16 msglen)
1001{
1002 bool err_msg_format = false;
1003 int valid_len = 0;
1004
1005
1006 switch (v_opcode) {
1007 case VIRTCHNL_OP_VERSION:
1008 valid_len = sizeof(struct virtchnl_version_info);
1009 break;
1010 case VIRTCHNL_OP_RESET_VF:
1011 break;
1012 case VIRTCHNL_OP_GET_VF_RESOURCES:
1013 if (VF_IS_V11(ver))
1014 valid_len = sizeof(u32);
1015 break;
1016 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
1017 valid_len = sizeof(struct virtchnl_txq_info);
1018 break;
1019 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
1020 valid_len = sizeof(struct virtchnl_rxq_info);
1021 break;
1022 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
1023 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
1024 if (msglen >= valid_len) {
1025 struct virtchnl_vsi_queue_config_info *vqc =
1026 (struct virtchnl_vsi_queue_config_info *)msg;
1027 valid_len += (vqc->num_queue_pairs *
1028 sizeof(struct
1029 virtchnl_queue_pair_info));
1030 if (vqc->num_queue_pairs == 0)
1031 err_msg_format = true;
1032 }
1033 break;
1034 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1035 valid_len = sizeof(struct virtchnl_irq_map_info);
1036 if (msglen >= valid_len) {
1037 struct virtchnl_irq_map_info *vimi =
1038 (struct virtchnl_irq_map_info *)msg;
1039 valid_len += (vimi->num_vectors *
1040 sizeof(struct virtchnl_vector_map));
1041 if (vimi->num_vectors == 0)
1042 err_msg_format = true;
1043 }
1044 break;
1045 case VIRTCHNL_OP_ENABLE_QUEUES:
1046 case VIRTCHNL_OP_DISABLE_QUEUES:
1047 valid_len = sizeof(struct virtchnl_queue_select);
1048 break;
1049 case VIRTCHNL_OP_ADD_ETH_ADDR:
1050 case VIRTCHNL_OP_DEL_ETH_ADDR:
1051 valid_len = sizeof(struct virtchnl_ether_addr_list);
1052 if (msglen >= valid_len) {
1053 struct virtchnl_ether_addr_list *veal =
1054 (struct virtchnl_ether_addr_list *)msg;
1055 valid_len += veal->num_elements *
1056 sizeof(struct virtchnl_ether_addr);
1057 if (veal->num_elements == 0)
1058 err_msg_format = true;
1059 }
1060 break;
1061 case VIRTCHNL_OP_ADD_VLAN:
1062 case VIRTCHNL_OP_DEL_VLAN:
1063 valid_len = sizeof(struct virtchnl_vlan_filter_list);
1064 if (msglen >= valid_len) {
1065 struct virtchnl_vlan_filter_list *vfl =
1066 (struct virtchnl_vlan_filter_list *)msg;
1067 valid_len += vfl->num_elements * sizeof(u16);
1068 if (vfl->num_elements == 0)
1069 err_msg_format = true;
1070 }
1071 break;
1072 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
1073 valid_len = sizeof(struct virtchnl_promisc_info);
1074 break;
1075 case VIRTCHNL_OP_GET_STATS:
1076 valid_len = sizeof(struct virtchnl_queue_select);
1077 break;
1078 case VIRTCHNL_OP_IWARP:
1079
1080
1081
1082
1083 if (msglen)
1084 valid_len = msglen;
1085 else
1086 err_msg_format = true;
1087 break;
1088 case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP:
1089 break;
1090 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
1091 valid_len = sizeof(struct virtchnl_iwarp_qvlist_info);
1092 if (msglen >= valid_len) {
1093 struct virtchnl_iwarp_qvlist_info *qv =
1094 (struct virtchnl_iwarp_qvlist_info *)msg;
1095 if (qv->num_vectors == 0) {
1096 err_msg_format = true;
1097 break;
1098 }
1099 valid_len += ((qv->num_vectors - 1) *
1100 sizeof(struct virtchnl_iwarp_qv_info));
1101 }
1102 break;
1103 case VIRTCHNL_OP_CONFIG_RSS_KEY:
1104 valid_len = sizeof(struct virtchnl_rss_key);
1105 if (msglen >= valid_len) {
1106 struct virtchnl_rss_key *vrk =
1107 (struct virtchnl_rss_key *)msg;
1108 valid_len += vrk->key_len - 1;
1109 }
1110 break;
1111 case VIRTCHNL_OP_CONFIG_RSS_LUT:
1112 valid_len = sizeof(struct virtchnl_rss_lut);
1113 if (msglen >= valid_len) {
1114 struct virtchnl_rss_lut *vrl =
1115 (struct virtchnl_rss_lut *)msg;
1116 valid_len += vrl->lut_entries - 1;
1117 }
1118 break;
1119 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
1120 break;
1121 case VIRTCHNL_OP_SET_RSS_HENA:
1122 valid_len = sizeof(struct virtchnl_rss_hena);
1123 break;
1124 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
1125 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
1126 break;
1127 case VIRTCHNL_OP_REQUEST_QUEUES:
1128 valid_len = sizeof(struct virtchnl_vf_res_request);
1129 break;
1130 case VIRTCHNL_OP_ENABLE_CHANNELS:
1131 valid_len = sizeof(struct virtchnl_tc_info);
1132 if (msglen >= valid_len) {
1133 struct virtchnl_tc_info *vti =
1134 (struct virtchnl_tc_info *)msg;
1135 valid_len += (vti->num_tc - 1) *
1136 sizeof(struct virtchnl_channel_info);
1137 if (vti->num_tc == 0)
1138 err_msg_format = true;
1139 }
1140 break;
1141 case VIRTCHNL_OP_DISABLE_CHANNELS:
1142 break;
1143 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
1144 valid_len = sizeof(struct virtchnl_filter);
1145 break;
1146 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
1147 valid_len = sizeof(struct virtchnl_filter);
1148 break;
1149 case VIRTCHNL_OP_ADD_RSS_CFG:
1150 case VIRTCHNL_OP_DEL_RSS_CFG:
1151 valid_len = sizeof(struct virtchnl_rss_cfg);
1152 break;
1153 case VIRTCHNL_OP_ADD_FDIR_FILTER:
1154 valid_len = sizeof(struct virtchnl_fdir_add);
1155 break;
1156 case VIRTCHNL_OP_DEL_FDIR_FILTER:
1157 valid_len = sizeof(struct virtchnl_fdir_del);
1158 break;
1159
1160 case VIRTCHNL_OP_EVENT:
1161 case VIRTCHNL_OP_UNKNOWN:
1162 default:
1163 return VIRTCHNL_STATUS_ERR_PARAM;
1164 }
1165
1166 if (err_msg_format || valid_len != msglen)
1167 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
1168
1169 return 0;
1170}
1171#endif
1172