Imported Upstream version 16.04
[deb_dpdk.git] / drivers / net / ena / base / ena_defs / ena_admin_defs.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright (c) 2015-2016 Amazon.com, Inc. or its affiliates.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef _ENA_ADMIN_H_
35 #define _ENA_ADMIN_H_
36
37 /* admin commands opcodes */
38 enum ena_admin_aq_opcode {
39         /* create submission queue */
40         ENA_ADMIN_CREATE_SQ = 1,
41
42         /* destroy submission queue */
43         ENA_ADMIN_DESTROY_SQ = 2,
44
45         /* create completion queue */
46         ENA_ADMIN_CREATE_CQ = 3,
47
48         /* destroy completion queue */
49         ENA_ADMIN_DESTROY_CQ = 4,
50
51         /* get capabilities of particular feature */
52         ENA_ADMIN_GET_FEATURE = 8,
53
54         /* get capabilities of particular feature */
55         ENA_ADMIN_SET_FEATURE = 9,
56
57         /* get statistics */
58         ENA_ADMIN_GET_STATS = 11,
59 };
60
61 /* privileged amdin commands opcodes */
62 enum ena_admin_aq_opcode_privileged {
63         /* get device capabilities */
64         ENA_ADMIN_IDENTIFY = 48,
65
66         /* configure device */
67         ENA_ADMIN_CONFIGURE_PF_DEVICE = 49,
68
69         /* setup SRIOV PCIe Virtual Function capabilities */
70         ENA_ADMIN_SETUP_VF = 50,
71
72         /* load firmware to the controller */
73         ENA_ADMIN_LOAD_FIRMWARE = 52,
74
75         /* commit previously loaded firmare */
76         ENA_ADMIN_COMMIT_FIRMWARE = 53,
77
78         /* quiesce virtual function */
79         ENA_ADMIN_QUIESCE_VF = 54,
80
81         /* load virtual function from migrates context */
82         ENA_ADMIN_MIGRATE_VF = 55,
83 };
84
85 /* admin command completion status codes */
86 enum ena_admin_aq_completion_status {
87         /* Request completed successfully */
88         ENA_ADMIN_SUCCESS = 0,
89
90         /* no resources to satisfy request */
91         ENA_ADMIN_RESOURCE_ALLOCATION_FAILURE = 1,
92
93         /* Bad opcode in request descriptor */
94         ENA_ADMIN_BAD_OPCODE = 2,
95
96         /* Unsupported opcode in request descriptor */
97         ENA_ADMIN_UNSUPPORTED_OPCODE = 3,
98
99         /* Wrong request format */
100         ENA_ADMIN_MALFORMED_REQUEST = 4,
101
102         /* One of parameters is not valid. Provided in ACQ entry
103          * extended_status
104          */
105         ENA_ADMIN_ILLEGAL_PARAMETER = 5,
106
107         /* unexpected error */
108         ENA_ADMIN_UNKNOWN_ERROR = 6,
109 };
110
111 /* get/set feature subcommands opcodes */
112 enum ena_admin_aq_feature_id {
113         /* list of all supported attributes/capabilities in the ENA */
114         ENA_ADMIN_DEVICE_ATTRIBUTES = 1,
115
116         /* max number of supported queues per for every queues type */
117         ENA_ADMIN_MAX_QUEUES_NUM = 2,
118
119         /* low latency queues capabilities (max entry size, depth) */
120         ENA_ADMIN_LLQ_CONFIG = 3,
121
122         /* power management capabilities */
123         ENA_ADMIN_POWER_MANAGEMENT_CONFIG = 4,
124
125         /* MAC address filters support, multicast, broadcast, and
126          * promiscuous
127          */
128         ENA_ADMIN_MAC_FILTERS_CONFIG = 5,
129
130         /* VLAN membership, frame format, etc.  */
131         ENA_ADMIN_VLAN_CONFIG = 6,
132
133         /* Available size for various on-chip memory resources, accessible
134          * by the driver
135          */
136         ENA_ADMIN_ON_DEVICE_MEMORY_CONFIG = 7,
137
138         /* Receive Side Scaling (RSS) function */
139         ENA_ADMIN_RSS_HASH_FUNCTION = 10,
140
141         /* stateless TCP/UDP/IP offload capabilities. */
142         ENA_ADMIN_STATELESS_OFFLOAD_CONFIG = 11,
143
144         /* Multiple tuples flow table configuration */
145         ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG = 12,
146
147         /* max MTU, current MTU */
148         ENA_ADMIN_MTU = 14,
149
150         /* Receive Side Scaling (RSS) hash input */
151         ENA_ADMIN_RSS_HASH_INPUT = 18,
152
153         /* overlay tunnels configuration */
154         ENA_ADMIN_TUNNEL_CONFIG = 19,
155
156         /* interrupt moderation parameters */
157         ENA_ADMIN_INTERRUPT_MODERATION = 20,
158
159         /* 1588v2 and Timing configuration */
160         ENA_ADMIN_1588_CONFIG = 21,
161
162         /* Packet Header format templates configuration for input and
163          * output parsers
164          */
165         ENA_ADMIN_PKT_HEADER_TEMPLATES_CONFIG = 23,
166
167         /* AENQ configuration */
168         ENA_ADMIN_AENQ_CONFIG = 26,
169
170         /* Link configuration */
171         ENA_ADMIN_LINK_CONFIG = 27,
172
173         /* Host attributes configuration */
174         ENA_ADMIN_HOST_ATTR_CONFIG = 28,
175
176         /* Number of valid opcodes */
177         ENA_ADMIN_FEATURES_OPCODE_NUM = 32,
178 };
179
180 /* descriptors and headers placement */
181 enum ena_admin_placement_policy_type {
182         /* descriptors and headers are in OS memory */
183         ENA_ADMIN_PLACEMENT_POLICY_HOST = 1,
184
185         /* descriptors and headers in device memory (a.k.a Low Latency
186          * Queue)
187          */
188         ENA_ADMIN_PLACEMENT_POLICY_DEV = 3,
189 };
190
191 /* link speeds */
192 enum ena_admin_link_types {
193         ENA_ADMIN_LINK_SPEED_1G = 0x1,
194
195         ENA_ADMIN_LINK_SPEED_2_HALF_G = 0x2,
196
197         ENA_ADMIN_LINK_SPEED_5G = 0x4,
198
199         ENA_ADMIN_LINK_SPEED_10G = 0x8,
200
201         ENA_ADMIN_LINK_SPEED_25G = 0x10,
202
203         ENA_ADMIN_LINK_SPEED_40G = 0x20,
204
205         ENA_ADMIN_LINK_SPEED_50G = 0x40,
206
207         ENA_ADMIN_LINK_SPEED_100G = 0x80,
208
209         ENA_ADMIN_LINK_SPEED_200G = 0x100,
210
211         ENA_ADMIN_LINK_SPEED_400G = 0x200,
212 };
213
214 /* completion queue update policy */
215 enum ena_admin_completion_policy_type {
216         /* cqe for each sq descriptor */
217         ENA_ADMIN_COMPLETION_POLICY_DESC = 0,
218
219         /* cqe upon request in sq descriptor */
220         ENA_ADMIN_COMPLETION_POLICY_DESC_ON_DEMAND = 1,
221
222         /* current queue head pointer is updated in OS memory upon sq
223          * descriptor request
224          */
225         ENA_ADMIN_COMPLETION_POLICY_HEAD_ON_DEMAND = 2,
226
227         /* current queue head pointer is updated in OS memory for each sq
228          * descriptor
229          */
230         ENA_ADMIN_COMPLETION_POLICY_HEAD = 3,
231 };
232
233 /* type of get statistics command */
234 enum ena_admin_get_stats_type {
235         /* Basic statistics */
236         ENA_ADMIN_GET_STATS_TYPE_BASIC = 0,
237
238         /* Extended statistics */
239         ENA_ADMIN_GET_STATS_TYPE_EXTENDED = 1,
240 };
241
242 /* scope of get statistics command */
243 enum ena_admin_get_stats_scope {
244         ENA_ADMIN_SPECIFIC_QUEUE = 0,
245
246         ENA_ADMIN_ETH_TRAFFIC = 1,
247 };
248
249 /* ENA Admin Queue (AQ) common descriptor */
250 struct ena_admin_aq_common_desc {
251         /* word 0 : */
252         /* command identificator to associate it with the completion
253          * 11:0 : command_id
254          * 15:12 : reserved12
255          */
256         uint16_t command_id;
257
258         /* as appears in ena_aq_opcode */
259         uint8_t opcode;
260
261         /* 0 : phase
262          * 1 : ctrl_data - control buffer address valid
263          * 2 : ctrl_data_indirect - control buffer address
264          *    points to list of pages with addresses of control
265          *    buffers
266          * 7:3 : reserved3
267          */
268         uint8_t flags;
269 };
270
271 /* used in ena_aq_entry. Can point directly to control data, or to a page
272  * list chunk. Used also at the end of indirect mode page list chunks, for
273  * chaining.
274  */
275 struct ena_admin_ctrl_buff_info {
276         /* word 0 : indicates length of the buffer pointed by
277          * control_buffer_address.
278          */
279         uint32_t length;
280
281         /* words 1:2 : points to control buffer (direct or indirect) */
282         struct ena_common_mem_addr address;
283 };
284
285 /* submission queue full identification */
286 struct ena_admin_sq {
287         /* word 0 : */
288         /* queue id */
289         uint16_t sq_idx;
290
291         /* 4:0 : reserved
292          * 7:5 : sq_direction - 0x1 - Tx; 0x2 - Rx
293          */
294         uint8_t sq_identity;
295
296         uint8_t reserved1;
297 };
298
299 /* AQ entry format */
300 struct ena_admin_aq_entry {
301         /* words 0 :  */
302         struct ena_admin_aq_common_desc aq_common_descriptor;
303
304         /* words 1:3 :  */
305         union {
306                 /* command specific inline data */
307                 uint32_t inline_data_w1[3];
308
309                 /* words 1:3 : points to control buffer (direct or
310                  * indirect, chained if needed)
311                  */
312                 struct ena_admin_ctrl_buff_info control_buffer;
313         } u;
314
315         /* command specific inline data */
316         uint32_t inline_data_w4[12];
317 };
318
319 /* ENA Admin Completion Queue (ACQ) common descriptor */
320 struct ena_admin_acq_common_desc {
321         /* word 0 : */
322         /* command identifier to associate it with the aq descriptor
323          * 11:0 : command_id
324          * 15:12 : reserved12
325          */
326         uint16_t command;
327
328         /* status of request execution */
329         uint8_t status;
330
331         /* 0 : phase
332          * 7:1 : reserved1
333          */
334         uint8_t flags;
335
336         /* word 1 : */
337         /* provides additional info */
338         uint16_t extended_status;
339
340         /* submission queue head index, serves as a hint what AQ entries can
341          *    be revoked
342          */
343         uint16_t sq_head_indx;
344 };
345
346 /* ACQ entry format */
347 struct ena_admin_acq_entry {
348         /* words 0:1 :  */
349         struct ena_admin_acq_common_desc acq_common_descriptor;
350
351         /* response type specific data */
352         uint32_t response_specific_data[14];
353 };
354
355 /* ENA AQ Create Submission Queue command. Placed in control buffer pointed
356  * by AQ entry
357  */
358 struct ena_admin_aq_create_sq_cmd {
359         /* words 0 :  */
360         struct ena_admin_aq_common_desc aq_common_descriptor;
361
362         /* word 1 : */
363         /* 4:0 : reserved0_w1
364          * 7:5 : sq_direction - 0x1 - Tx, 0x2 - Rx
365          */
366         uint8_t sq_identity;
367
368         uint8_t reserved8_w1;
369
370         /* 3:0 : placement_policy - Describing where the SQ
371          *    descriptor ring and the SQ packet headers reside:
372          *    0x1 - descriptors and headers are in OS memory,
373          *    0x3 - descriptors and headers in device memory
374          *    (a.k.a Low Latency Queue)
375          * 6:4 : completion_policy - Describing what policy
376          *    to use for generation completion entry (cqe) in
377          *    the CQ associated with this SQ: 0x0 - cqe for each
378          *    sq descriptor, 0x1 - cqe upon request in sq
379          *    descriptor, 0x2 - current queue head pointer is
380          *    updated in OS memory upon sq descriptor request
381          *    0x3 - current queue head pointer is updated in OS
382          *    memory for each sq descriptor
383          * 7 : reserved15_w1
384          */
385         uint8_t sq_caps_2;
386
387         /* 0 : is_physically_contiguous - Described if the
388          *    queue ring memory is allocated in physical
389          *    contiguous pages or split.
390          * 7:1 : reserved17_w1
391          */
392         uint8_t sq_caps_3;
393
394         /* word 2 : */
395         /* associated completion queue id. This CQ must be created prior to
396          *    SQ creation
397          */
398         uint16_t cq_idx;
399
400         /* submission queue depth in entries */
401         uint16_t sq_depth;
402
403         /* words 3:4 : SQ physical base address in OS memory. This field
404          * should not be used for Low Latency queues. Has to be page
405          * aligned.
406          */
407         struct ena_common_mem_addr sq_ba;
408
409         /* words 5:6 : specifies queue head writeback location in OS
410          * memory. Valid if completion_policy is set to
411          * completion_policy_head_on_demand or completion_policy_head. Has
412          * to be cache aligned
413          */
414         struct ena_common_mem_addr sq_head_writeback;
415
416         /* word 7 : reserved word */
417         uint32_t reserved0_w7;
418
419         /* word 8 : reserved word */
420         uint32_t reserved0_w8;
421 };
422
423 /* submission queue direction */
424 enum ena_admin_sq_direction {
425         ENA_ADMIN_SQ_DIRECTION_TX = 1,
426
427         ENA_ADMIN_SQ_DIRECTION_RX = 2,
428 };
429
430 /* ENA Response for Create SQ Command. Appears in ACQ entry as
431  * response_specific_data
432  */
433 struct ena_admin_acq_create_sq_resp_desc {
434         /* words 0:1 : Common Admin Queue completion descriptor */
435         struct ena_admin_acq_common_desc acq_common_desc;
436
437         /* word 2 : */
438         /* sq identifier */
439         uint16_t sq_idx;
440
441         uint16_t reserved;
442
443         /* word 3 : queue doorbell address as and offset to PCIe MMIO REG
444          * BAR
445          */
446         uint32_t sq_doorbell_offset;
447
448         /* word 4 : low latency queue ring base address as an offset to
449          * PCIe MMIO LLQ_MEM BAR
450          */
451         uint32_t llq_descriptors_offset;
452
453         /* word 5 : low latency queue headers' memory as an offset to PCIe
454          * MMIO LLQ_MEM BAR
455          */
456         uint32_t llq_headers_offset;
457 };
458
459 /* ENA AQ Destroy Submission Queue command. Placed in control buffer
460  * pointed by AQ entry
461  */
462 struct ena_admin_aq_destroy_sq_cmd {
463         /* words 0 :  */
464         struct ena_admin_aq_common_desc aq_common_descriptor;
465
466         /* words 1 :  */
467         struct ena_admin_sq sq;
468 };
469
470 /* ENA Response for Destroy SQ Command. Appears in ACQ entry as
471  * response_specific_data
472  */
473 struct ena_admin_acq_destroy_sq_resp_desc {
474         /* words 0:1 : Common Admin Queue completion descriptor */
475         struct ena_admin_acq_common_desc acq_common_desc;
476 };
477
478 /* ENA AQ Create Completion Queue command */
479 struct ena_admin_aq_create_cq_cmd {
480         /* words 0 :  */
481         struct ena_admin_aq_common_desc aq_common_descriptor;
482
483         /* word 1 : */
484         /* 4:0 : reserved5
485          * 5 : interrupt_mode_enabled - if set, cq operates
486          *    in interrupt mode, otherwise - polling
487          * 7:6 : reserved6
488          */
489         uint8_t cq_caps_1;
490
491         /* 4:0 : cq_entry_size_words - size of CQ entry in
492          *    32-bit words, valid values: 4, 8.
493          * 7:5 : reserved7
494          */
495         uint8_t cq_caps_2;
496
497         /* completion queue depth in # of entries. must be power of 2 */
498         uint16_t cq_depth;
499
500         /* word 2 : msix vector assigned to this cq */
501         uint32_t msix_vector;
502
503         /* words 3:4 : cq physical base address in OS memory. CQ must be
504          * physically contiguous
505          */
506         struct ena_common_mem_addr cq_ba;
507 };
508
509 /* ENA Response for Create CQ Command. Appears in ACQ entry as response
510  * specific data
511  */
512 struct ena_admin_acq_create_cq_resp_desc {
513         /* words 0:1 : Common Admin Queue completion descriptor */
514         struct ena_admin_acq_common_desc acq_common_desc;
515
516         /* word 2 : */
517         /* cq identifier */
518         uint16_t cq_idx;
519
520         /* actual cq depth in # of entries */
521         uint16_t cq_actual_depth;
522
523         /* word 3 : doorbell address as an offset to PCIe MMIO REG BAR */
524         uint32_t cq_doorbell_offset;
525
526         /* word 4 : completion head doorbell address as an offset to PCIe
527          * MMIO REG BAR
528          */
529         uint32_t cq_head_db_offset;
530
531         /* word 5 : interrupt unmask register address as an offset into
532          * PCIe MMIO REG BAR
533          */
534         uint32_t cq_interrupt_unmask_register;
535 };
536
537 /* ENA AQ Destroy Completion Queue command. Placed in control buffer
538  * pointed by AQ entry
539  */
540 struct ena_admin_aq_destroy_cq_cmd {
541         /* words 0 :  */
542         struct ena_admin_aq_common_desc aq_common_descriptor;
543
544         /* word 1 : */
545         /* associated queue id. */
546         uint16_t cq_idx;
547
548         uint16_t reserved1;
549 };
550
551 /* ENA Response for Destroy CQ Command. Appears in ACQ entry as
552  * response_specific_data
553  */
554 struct ena_admin_acq_destroy_cq_resp_desc {
555         /* words 0:1 : Common Admin Queue completion descriptor */
556         struct ena_admin_acq_common_desc acq_common_desc;
557 };
558
559 /* ENA AQ Get Statistics command. Extended statistics are placed in control
560  * buffer pointed by AQ entry
561  */
562 struct ena_admin_aq_get_stats_cmd {
563         /* words 0 :  */
564         struct ena_admin_aq_common_desc aq_common_descriptor;
565
566         /* words 1:3 :  */
567         union {
568                 /* command specific inline data */
569                 uint32_t inline_data_w1[3];
570
571                 /* words 1:3 : points to control buffer (direct or
572                  * indirect, chained if needed)
573                  */
574                 struct ena_admin_ctrl_buff_info control_buffer;
575         } u;
576
577         /* word 4 : */
578         /* stats type as defined in enum ena_admin_get_stats_type */
579         uint8_t type;
580
581         /* stats scope defined in enum ena_admin_get_stats_scope */
582         uint8_t scope;
583
584         uint16_t reserved3;
585
586         /* word 5 : */
587         /* queue id. used when scope is specific_queue */
588         uint16_t queue_idx;
589
590         /* device id, value 0xFFFF means mine. only privileged device can get
591          *    stats of other device
592          */
593         uint16_t device_id;
594 };
595
596 /* Basic Statistics Command. */
597 struct ena_admin_basic_stats {
598         /* word 0 :  */
599         uint32_t tx_bytes_low;
600
601         /* word 1 :  */
602         uint32_t tx_bytes_high;
603
604         /* word 2 :  */
605         uint32_t tx_pkts_low;
606
607         /* word 3 :  */
608         uint32_t tx_pkts_high;
609
610         /* word 4 :  */
611         uint32_t rx_bytes_low;
612
613         /* word 5 :  */
614         uint32_t rx_bytes_high;
615
616         /* word 6 :  */
617         uint32_t rx_pkts_low;
618
619         /* word 7 :  */
620         uint32_t rx_pkts_high;
621
622         /* word 8 :  */
623         uint32_t rx_drops_low;
624
625         /* word 9 :  */
626         uint32_t rx_drops_high;
627 };
628
629 /* ENA Response for Get Statistics Command. Appears in ACQ entry as
630  * response_specific_data
631  */
632 struct ena_admin_acq_get_stats_resp {
633         /* words 0:1 : Common Admin Queue completion descriptor */
634         struct ena_admin_acq_common_desc acq_common_desc;
635
636         /* words 2:11 :  */
637         struct ena_admin_basic_stats basic_stats;
638 };
639
640 /* ENA Get/Set Feature common descriptor. Appears as inline word in
641  * ena_aq_entry
642  */
643 struct ena_admin_get_set_feature_common_desc {
644         /* word 0 : */
645         /* 1:0 : select - 0x1 - current value; 0x3 - default
646          *    value
647          * 7:3 : reserved3
648          */
649         uint8_t flags;
650
651         /* as appears in ena_feature_id */
652         uint8_t feature_id;
653
654         /* reserved16 */
655         uint16_t reserved16;
656 };
657
658 /* ENA Device Attributes Feature descriptor. */
659 struct ena_admin_device_attr_feature_desc {
660         /* word 0 : implementation id */
661         uint32_t impl_id;
662
663         /* word 1 : device version */
664         uint32_t device_version;
665
666         /* word 2 : bit map of which bits are supported value of 1
667          * indicated that this feature is supported and can perform SET/GET
668          * for it
669          */
670         uint32_t supported_features;
671
672         /* word 3 :  */
673         uint32_t reserved3;
674
675         /* word 4 : Indicates how many bits are used physical address
676          * access.
677          */
678         uint32_t phys_addr_width;
679
680         /* word 5 : Indicates how many bits are used virtual address access. */
681         uint32_t virt_addr_width;
682
683         /* unicast MAC address (in Network byte order) */
684         uint8_t mac_addr[6];
685
686         uint8_t reserved7[2];
687
688         /* word 8 : Max supported MTU value */
689         uint32_t max_mtu;
690 };
691
692 /* ENA Max Queues Feature descriptor. */
693 struct ena_admin_queue_feature_desc {
694         /* word 0 : Max number of submission queues (including LLQs) */
695         uint32_t max_sq_num;
696
697         /* word 1 : Max submission queue depth */
698         uint32_t max_sq_depth;
699
700         /* word 2 : Max number of completion queues */
701         uint32_t max_cq_num;
702
703         /* word 3 : Max completion queue depth */
704         uint32_t max_cq_depth;
705
706         /* word 4 : Max number of LLQ submission queues */
707         uint32_t max_llq_num;
708
709         /* word 5 : Max submission queue depth of LLQ */
710         uint32_t max_llq_depth;
711
712         /* word 6 : Max header size */
713         uint32_t max_header_size;
714
715         /* word 7 : */
716         /* Maximum Descriptors number, including meta descriptors, allowed
717          *    for a single Tx packet
718          */
719         uint16_t max_packet_tx_descs;
720
721         /* Maximum Descriptors number allowed for a single Rx packet */
722         uint16_t max_packet_rx_descs;
723 };
724
725 /* ENA MTU Set Feature descriptor. */
726 struct ena_admin_set_feature_mtu_desc {
727         /* word 0 : mtu size including L2 */
728         uint32_t mtu;
729 };
730
731 /* ENA host attributes Set Feature descriptor. */
732 struct ena_admin_set_feature_host_attr_desc {
733         /* words 0:1 : host OS info base address in OS memory. host info is
734          * 4KB of physically contiguous
735          */
736         struct ena_common_mem_addr os_info_ba;
737
738         /* words 2:3 : host debug area base address in OS memory. debug
739          * area must be physically contiguous
740          */
741         struct ena_common_mem_addr debug_ba;
742
743         /* word 4 : debug area size */
744         uint32_t debug_area_size;
745 };
746
747 /* ENA Interrupt Moderation Get Feature descriptor. */
748 struct ena_admin_feature_intr_moder_desc {
749         /* word 0 : */
750         /* interrupt delay granularity in usec */
751         uint16_t intr_delay_resolution;
752
753         uint16_t reserved;
754 };
755
756 /* ENA Link Get Feature descriptor. */
757 struct ena_admin_get_feature_link_desc {
758         /* word 0 : Link speed in Mb */
759         uint32_t speed;
760
761         /* word 1 : supported speeds (bit field of enum ena_admin_link
762          * types)
763          */
764         uint32_t supported;
765
766         /* word 2 : */
767         /* 0 : autoneg - auto negotiation
768          * 1 : duplex - Full Duplex
769          * 31:2 : reserved2
770          */
771         uint32_t flags;
772 };
773
774 /* ENA AENQ Feature descriptor. */
775 struct ena_admin_feature_aenq_desc {
776         /* word 0 : bitmask for AENQ groups the device can report */
777         uint32_t supported_groups;
778
779         /* word 1 : bitmask for AENQ groups to report */
780         uint32_t enabled_groups;
781 };
782
783 /* ENA Stateless Offload Feature descriptor. */
784 struct ena_admin_feature_offload_desc {
785         /* word 0 : */
786         /* Trasmit side stateless offload
787          * 0 : TX_L3_csum_ipv4 - IPv4 checksum
788          * 1 : TX_L4_ipv4_csum_part - TCP/UDP over IPv4
789          *    checksum, the checksum field should be initialized
790          *    with pseudo header checksum
791          * 2 : TX_L4_ipv4_csum_full - TCP/UDP over IPv4
792          *    checksum
793          * 3 : TX_L4_ipv6_csum_part - TCP/UDP over IPv6
794          *    checksum, the checksum field should be initialized
795          *    with pseudo header checksum
796          * 4 : TX_L4_ipv6_csum_full - TCP/UDP over IPv6
797          *    checksum
798          * 5 : tso_ipv4 - TCP/IPv4 Segmentation Offloading
799          * 6 : tso_ipv6 - TCP/IPv6 Segmentation Offloading
800          * 7 : tso_ecn - TCP Segmentation with ECN
801          */
802         uint32_t tx;
803
804         /* word 1 : */
805         /* Receive side supported stateless offload
806          * 0 : RX_L3_csum_ipv4 - IPv4 checksum
807          * 1 : RX_L4_ipv4_csum - TCP/UDP/IPv4 checksum
808          * 2 : RX_L4_ipv6_csum - TCP/UDP/IPv6 checksum
809          * 3 : RX_hash - Hash calculation
810          */
811         uint32_t rx_supported;
812
813         /* word 2 : */
814         /* Receive side enabled stateless offload */
815         uint32_t rx_enabled;
816 };
817
818 /* hash functions */
819 enum ena_admin_hash_functions {
820         /* Toeplitz hash */
821         ENA_ADMIN_TOEPLITZ = 1,
822
823         /* CRC32 hash */
824         ENA_ADMIN_CRC32 = 2,
825 };
826
827 /* ENA RSS flow hash control buffer structure */
828 struct ena_admin_feature_rss_flow_hash_control {
829         /* word 0 : number of valid keys */
830         uint32_t keys_num;
831
832         /* word 1 :  */
833         uint32_t reserved;
834
835         /* Toeplitz keys */
836         uint32_t key[10];
837 };
838
839 /* ENA RSS Flow Hash Function */
840 struct ena_admin_feature_rss_flow_hash_function {
841         /* word 0 : */
842         /* supported hash functions
843          * 7:0 : funcs - supported hash functions (bitmask
844          *    accroding to ena_admin_hash_functions)
845          */
846         uint32_t supported_func;
847
848         /* word 1 : */
849         /* selected hash func
850          * 7:0 : selected_func - selected hash function
851          *    (bitmask accroding to ena_admin_hash_functions)
852          */
853         uint32_t selected_func;
854
855         /* word 2 : initial value */
856         uint32_t init_val;
857 };
858
859 /* RSS flow hash protocols */
860 enum ena_admin_flow_hash_proto {
861         /* tcp/ipv4 */
862         ENA_ADMIN_RSS_TCP4 = 0,
863
864         /* udp/ipv4 */
865         ENA_ADMIN_RSS_UDP4 = 1,
866
867         /* tcp/ipv6 */
868         ENA_ADMIN_RSS_TCP6 = 2,
869
870         /* udp/ipv6 */
871         ENA_ADMIN_RSS_UDP6 = 3,
872
873         /* ipv4 not tcp/udp */
874         ENA_ADMIN_RSS_IP4 = 4,
875
876         /* ipv6 not tcp/udp */
877         ENA_ADMIN_RSS_IP6 = 5,
878
879         /* fragmented ipv4 */
880         ENA_ADMIN_RSS_IP4_FRAG = 6,
881
882         /* not ipv4/6 */
883         ENA_ADMIN_RSS_NOT_IP = 7,
884
885         /* max number of protocols */
886         ENA_ADMIN_RSS_PROTO_NUM = 16,
887 };
888
889 /* RSS flow hash fields */
890 enum ena_admin_flow_hash_fields {
891         /* Ethernet Dest Addr */
892         ENA_ADMIN_RSS_L2_DA = 0,
893
894         /* Ethernet Src Addr */
895         ENA_ADMIN_RSS_L2_SA = 1,
896
897         /* ipv4/6 Dest Addr */
898         ENA_ADMIN_RSS_L3_DA = 2,
899
900         /* ipv4/6 Src Addr */
901         ENA_ADMIN_RSS_L3_SA = 5,
902
903         /* tcp/udp Dest Port */
904         ENA_ADMIN_RSS_L4_DP = 6,
905
906         /* tcp/udp Src Port */
907         ENA_ADMIN_RSS_L4_SP = 7,
908 };
909
910 /* hash input fields for flow protocol */
911 struct ena_admin_proto_input {
912         /* word 0 : */
913         /* flow hash fields (bitwise according to ena_admin_flow_hash_fields) */
914         uint16_t fields;
915
916         /* 0 : inner - for tunneled packet, select the fields
917          *    from inner header
918          */
919         uint16_t flags;
920 };
921
922 /* ENA RSS hash control buffer structure */
923 struct ena_admin_feature_rss_hash_control {
924         /* supported input fields */
925         struct ena_admin_proto_input supported_fields[ENA_ADMIN_RSS_PROTO_NUM];
926
927         /* selected input fields */
928         struct ena_admin_proto_input selected_fields[ENA_ADMIN_RSS_PROTO_NUM];
929
930         /* supported input fields for inner header */
931         struct ena_admin_proto_input supported_inner_fields[ENA_ADMIN_RSS_PROTO_NUM];
932
933         /* selected input fields */
934         struct ena_admin_proto_input selected_inner_fields[ENA_ADMIN_RSS_PROTO_NUM];
935 };
936
937 /* ENA RSS flow hash input */
938 struct ena_admin_feature_rss_flow_hash_input {
939         /* word 0 : */
940         /* supported hash input sorting
941          * 1 : L3_sort - support swap L3 addresses if DA
942          *    smaller than SA
943          * 2 : L4_sort - support swap L4 ports if DP smaller
944          *    SP
945          */
946         uint16_t supported_input_sort;
947
948         /* enabled hash input sorting
949          * 1 : enable_L3_sort - enable swap L3 addresses if
950          *    DA smaller than SA
951          * 2 : enable_L4_sort - enable swap L4 ports if DP
952          *    smaller than SP
953          */
954         uint16_t enabled_input_sort;
955 };
956
957 /* Operating system type */
958 enum ena_admin_os_type {
959         /* Linux OS */
960         ENA_ADMIN_OS_LINUX = 1,
961
962         /* Windows OS */
963         ENA_ADMIN_OS_WIN = 2,
964
965         /* DPDK OS */
966         ENA_ADMIN_OS_DPDK = 3,
967
968         /* FreeBSD OS */
969         ENA_ADMIN_OS_FREE_BSD = 4,
970
971         /* PXE OS */
972         ENA_ADMIN_OS_PXE = 5,
973 };
974
975 /* host info */
976 struct ena_admin_host_info {
977         /* word 0 : OS type defined in enum ena_os_type */
978         uint32_t os_type;
979
980         /* os distribution string format */
981         uint8_t os_dist_str[128];
982
983         /* word 33 : OS distribution numeric format */
984         uint32_t os_dist;
985
986         /* kernel version string format */
987         uint8_t kernel_ver_str[32];
988
989         /* word 42 : Kernel version numeric format */
990         uint32_t kernel_ver;
991
992         /* word 43 : */
993         /* driver version
994          * 7:0 : major - major
995          * 15:8 : minor - minor
996          * 23:16 : sub_minor - sub minor
997          */
998         uint32_t driver_version;
999
1000         /* features bitmap */
1001         uint32_t supported_network_features[4];
1002 };
1003
1004 /* ENA RSS indirection table entry */
1005 struct ena_admin_rss_ind_table_entry {
1006         /* word 0 : */
1007         /* cq identifier */
1008         uint16_t cq_idx;
1009
1010         uint16_t reserved;
1011 };
1012
1013 /* ENA RSS indirection table */
1014 struct ena_admin_feature_rss_ind_table {
1015         /* word 0 : */
1016         /* min supported table size (2^min_size) */
1017         uint16_t min_size;
1018
1019         /* max supported table size (2^max_size) */
1020         uint16_t max_size;
1021
1022         /* word 1 : */
1023         /* table size (2^size) */
1024         uint16_t size;
1025
1026         uint16_t reserved;
1027
1028         /* word 2 : index of the inline entry. 0xFFFFFFFF means invalid */
1029         uint32_t inline_index;
1030
1031         /* words 3 : used for updating single entry, ignored when setting
1032          * the entire table through the control buffer.
1033          */
1034         struct ena_admin_rss_ind_table_entry inline_entry;
1035 };
1036
1037 /* ENA Get Feature command */
1038 struct ena_admin_get_feat_cmd {
1039         /* words 0 :  */
1040         struct ena_admin_aq_common_desc aq_common_descriptor;
1041
1042         /* words 1:3 : points to control buffer (direct or indirect,
1043          * chained if needed)
1044          */
1045         struct ena_admin_ctrl_buff_info control_buffer;
1046
1047         /* words 4 :  */
1048         struct ena_admin_get_set_feature_common_desc feat_common;
1049
1050         /* words 5:15 :  */
1051         union {
1052                 /* raw words */
1053                 uint32_t raw[11];
1054         } u;
1055 };
1056
1057 /* ENA Get Feature command response */
1058 struct ena_admin_get_feat_resp {
1059         /* words 0:1 :  */
1060         struct ena_admin_acq_common_desc acq_common_desc;
1061
1062         /* words 2:15 :  */
1063         union {
1064                 /* raw words */
1065                 uint32_t raw[14];
1066
1067                 /* words 2:10 : Get Device Attributes */
1068                 struct ena_admin_device_attr_feature_desc dev_attr;
1069
1070                 /* words 2:5 : Max queues num */
1071                 struct ena_admin_queue_feature_desc max_queue;
1072
1073                 /* words 2:3 : AENQ configuration */
1074                 struct ena_admin_feature_aenq_desc aenq;
1075
1076                 /* words 2:4 : Get Link configuration */
1077                 struct ena_admin_get_feature_link_desc link;
1078
1079                 /* words 2:4 : offload configuration */
1080                 struct ena_admin_feature_offload_desc offload;
1081
1082                 /* words 2:4 : rss flow hash function */
1083                 struct ena_admin_feature_rss_flow_hash_function flow_hash_func;
1084
1085                 /* words 2 : rss flow hash input */
1086                 struct ena_admin_feature_rss_flow_hash_input flow_hash_input;
1087
1088                 /* words 2:3 : rss indirection table */
1089                 struct ena_admin_feature_rss_ind_table ind_table;
1090
1091                 /* words 2 : interrupt moderation configuration */
1092                 struct ena_admin_feature_intr_moder_desc intr_moderation;
1093         } u;
1094 };
1095
1096 /* ENA Set Feature command */
1097 struct ena_admin_set_feat_cmd {
1098         /* words 0 :  */
1099         struct ena_admin_aq_common_desc aq_common_descriptor;
1100
1101         /* words 1:3 : points to control buffer (direct or indirect,
1102          * chained if needed)
1103          */
1104         struct ena_admin_ctrl_buff_info control_buffer;
1105
1106         /* words 4 :  */
1107         struct ena_admin_get_set_feature_common_desc feat_common;
1108
1109         /* words 5:15 :  */
1110         union {
1111                 /* raw words */
1112                 uint32_t raw[11];
1113
1114                 /* words 5 : mtu size */
1115                 struct ena_admin_set_feature_mtu_desc mtu;
1116
1117                 /* words 5:7 : host attributes */
1118                 struct ena_admin_set_feature_host_attr_desc host_attr;
1119
1120                 /* words 5:6 : AENQ configuration */
1121                 struct ena_admin_feature_aenq_desc aenq;
1122
1123                 /* words 5:7 : rss flow hash function */
1124                 struct ena_admin_feature_rss_flow_hash_function flow_hash_func;
1125
1126                 /* words 5 : rss flow hash input */
1127                 struct ena_admin_feature_rss_flow_hash_input flow_hash_input;
1128
1129                 /* words 5:6 : rss indirection table */
1130                 struct ena_admin_feature_rss_ind_table ind_table;
1131         } u;
1132 };
1133
1134 /* ENA Set Feature command response */
1135 struct ena_admin_set_feat_resp {
1136         /* words 0:1 :  */
1137         struct ena_admin_acq_common_desc acq_common_desc;
1138
1139         /* words 2:15 :  */
1140         union {
1141                 /* raw words */
1142                 uint32_t raw[14];
1143         } u;
1144 };
1145
1146 /* ENA Asynchronous Event Notification Queue descriptor.  */
1147 struct ena_admin_aenq_common_desc {
1148         /* word 0 : */
1149         uint16_t group;
1150
1151         uint16_t syndrom;
1152
1153         /* word 1 : */
1154         /* 0 : phase */
1155         uint8_t flags;
1156
1157         uint8_t reserved1[3];
1158
1159         /* word 2 : Timestamp LSB */
1160         uint32_t timestamp_low;
1161
1162         /* word 3 : Timestamp MSB */
1163         uint32_t timestamp_high;
1164 };
1165
1166 /* asynchronous event notification groups */
1167 enum ena_admin_aenq_group {
1168         /* Link State Change */
1169         ENA_ADMIN_LINK_CHANGE = 0,
1170
1171         ENA_ADMIN_FATAL_ERROR = 1,
1172
1173         ENA_ADMIN_WARNING = 2,
1174
1175         ENA_ADMIN_NOTIFICATION = 3,
1176
1177         ENA_ADMIN_KEEP_ALIVE = 4,
1178
1179         ENA_ADMIN_AENQ_GROUPS_NUM = 5,
1180 };
1181
1182 /* syndorm of AENQ notification group */
1183 enum ena_admin_aenq_notification_syndrom {
1184         ENA_ADMIN_SUSPEND = 0,
1185
1186         ENA_ADMIN_RESUME = 1,
1187 };
1188
1189 /* ENA Asynchronous Event Notification generic descriptor.  */
1190 struct ena_admin_aenq_entry {
1191         /* words 0:3 :  */
1192         struct ena_admin_aenq_common_desc aenq_common_desc;
1193
1194         /* command specific inline data */
1195         uint32_t inline_data_w4[12];
1196 };
1197
1198 /* ENA Asynchronous Event Notification Queue Link Change descriptor.  */
1199 struct ena_admin_aenq_link_change_desc {
1200         /* words 0:3 :  */
1201         struct ena_admin_aenq_common_desc aenq_common_desc;
1202
1203         /* word 4 : */
1204         /* 0 : link_status */
1205         uint32_t flags;
1206 };
1207
1208 /* ENA MMIO Readless response interface */
1209 struct ena_admin_ena_mmio_req_read_less_resp {
1210         /* word 0 : */
1211         /* request id */
1212         uint16_t req_id;
1213
1214         /* register offset */
1215         uint16_t reg_off;
1216
1217         /* word 1 : value is valid when poll is cleared */
1218         uint32_t reg_val;
1219 };
1220
1221 /* aq_common_desc */
1222 #define ENA_ADMIN_AQ_COMMON_DESC_COMMAND_ID_MASK GENMASK(11, 0)
1223 #define ENA_ADMIN_AQ_COMMON_DESC_PHASE_MASK BIT(0)
1224 #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_SHIFT 1
1225 #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_MASK BIT(1)
1226 #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_SHIFT 2
1227 #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK BIT(2)
1228
1229 /* sq */
1230 #define ENA_ADMIN_SQ_SQ_DIRECTION_SHIFT 5
1231 #define ENA_ADMIN_SQ_SQ_DIRECTION_MASK GENMASK(7, 5)
1232
1233 /* acq_common_desc */
1234 #define ENA_ADMIN_ACQ_COMMON_DESC_COMMAND_ID_MASK GENMASK(11, 0)
1235 #define ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK BIT(0)
1236
1237 /* aq_create_sq_cmd */
1238 #define ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_SHIFT 5
1239 #define ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_MASK GENMASK(7, 5)
1240 #define ENA_ADMIN_AQ_CREATE_SQ_CMD_PLACEMENT_POLICY_MASK GENMASK(3, 0)
1241 #define ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_SHIFT 4
1242 #define ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_MASK GENMASK(6, 4)
1243 #define ENA_ADMIN_AQ_CREATE_SQ_CMD_IS_PHYSICALLY_CONTIGUOUS_MASK BIT(0)
1244
1245 /* aq_create_cq_cmd */
1246 #define ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_SHIFT 5
1247 #define ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_MASK BIT(5)
1248 #define ENA_ADMIN_AQ_CREATE_CQ_CMD_CQ_ENTRY_SIZE_WORDS_MASK GENMASK(4, 0)
1249
1250 /* get_set_feature_common_desc */
1251 #define ENA_ADMIN_GET_SET_FEATURE_COMMON_DESC_SELECT_MASK GENMASK(1, 0)
1252
1253 /* get_feature_link_desc */
1254 #define ENA_ADMIN_GET_FEATURE_LINK_DESC_AUTONEG_MASK BIT(0)
1255 #define ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_SHIFT 1
1256 #define ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_MASK BIT(1)
1257
1258 /* feature_offload_desc */
1259 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L3_CSUM_IPV4_MASK BIT(0)
1260 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_SHIFT 1
1261 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK BIT(1)
1262 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_SHIFT 2
1263 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_MASK BIT(2)
1264 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_SHIFT 3
1265 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK BIT(3)
1266 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_SHIFT 4
1267 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_MASK BIT(4)
1268 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_SHIFT 5
1269 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK BIT(5)
1270 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_SHIFT 6
1271 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK BIT(6)
1272 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_SHIFT 7
1273 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_MASK BIT(7)
1274 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L3_CSUM_IPV4_MASK BIT(0)
1275 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_SHIFT 1
1276 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK BIT(1)
1277 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_SHIFT 2
1278 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_MASK BIT(2)
1279 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_SHIFT 3
1280 #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK BIT(3)
1281
1282 /* feature_rss_flow_hash_function */
1283 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_FUNCS_MASK GENMASK(7, 0)
1284 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_SELECTED_FUNC_MASK \
1285         GENMASK(7, 0)
1286
1287 /* proto_input */
1288 #define ENA_ADMIN_PROTO_INPUT_INNER_MASK BIT(0)
1289
1290 /* feature_rss_flow_hash_input */
1291 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_SHIFT 1
1292 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_MASK BIT(1)
1293 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_SHIFT 2
1294 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_MASK BIT(2)
1295 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_SHIFT 1
1296 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_MASK BIT(1)
1297 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_SHIFT 2
1298 #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_MASK BIT(2)
1299
1300 /* host_info */
1301 #define ENA_ADMIN_HOST_INFO_MAJOR_MASK GENMASK(7, 0)
1302 #define ENA_ADMIN_HOST_INFO_MINOR_SHIFT 8
1303 #define ENA_ADMIN_HOST_INFO_MINOR_MASK GENMASK(15, 8)
1304 #define ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT 16
1305 #define ENA_ADMIN_HOST_INFO_SUB_MINOR_MASK GENMASK(23, 16)
1306
1307 /* aenq_common_desc */
1308 #define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0)
1309
1310 /* aenq_link_change_desc */
1311 #define ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK BIT(0)
1312
1313 #if !defined(ENA_DEFS_LINUX_MAINLINE)
1314 static inline uint16_t
1315 get_ena_admin_aq_common_desc_command_id(
1316                 const struct ena_admin_aq_common_desc *p)
1317 {
1318         return p->command_id & ENA_ADMIN_AQ_COMMON_DESC_COMMAND_ID_MASK;
1319 }
1320
1321 static inline void
1322 set_ena_admin_aq_common_desc_command_id(struct ena_admin_aq_common_desc *p,
1323                                         uint16_t val)
1324 {
1325         p->command_id |= val & ENA_ADMIN_AQ_COMMON_DESC_COMMAND_ID_MASK;
1326 }
1327
1328 static inline uint8_t
1329 get_ena_admin_aq_common_desc_phase(const struct ena_admin_aq_common_desc *p)
1330 {
1331         return p->flags & ENA_ADMIN_AQ_COMMON_DESC_PHASE_MASK;
1332 }
1333
1334 static inline void
1335 set_ena_admin_aq_common_desc_phase(struct ena_admin_aq_common_desc *p,
1336                                    uint8_t val)
1337 {
1338         p->flags |= val & ENA_ADMIN_AQ_COMMON_DESC_PHASE_MASK;
1339 }
1340
1341 static inline uint8_t
1342 get_ena_admin_aq_common_desc_ctrl_data(
1343                 const struct ena_admin_aq_common_desc *p)
1344 {
1345         return (p->flags & ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_MASK) >>
1346                ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_SHIFT;
1347 }
1348
1349 static inline void
1350 set_ena_admin_aq_common_desc_ctrl_data(struct ena_admin_aq_common_desc *p,
1351                                        uint8_t val)
1352 {
1353         p->flags |= (val << ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_SHIFT)
1354                      & ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_MASK;
1355 }
1356
1357 static inline uint8_t
1358 get_ena_admin_aq_common_desc_ctrl_data_indirect(
1359                 const struct ena_admin_aq_common_desc *p)
1360 {
1361         return (p->flags & ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK)
1362                 >> ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_SHIFT;
1363 }
1364
1365 static inline void
1366 set_ena_admin_aq_common_desc_ctrl_data_indirect(
1367                 struct ena_admin_aq_common_desc *p,
1368                 uint8_t val)
1369 {
1370         p->flags |= (val << ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_SHIFT)
1371                      & ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK;
1372 }
1373
1374 static inline uint8_t
1375 get_ena_admin_sq_sq_direction(const struct ena_admin_sq *p)
1376 {
1377         return (p->sq_identity & ENA_ADMIN_SQ_SQ_DIRECTION_MASK)
1378                 >> ENA_ADMIN_SQ_SQ_DIRECTION_SHIFT;
1379 }
1380
1381 static inline void
1382 set_ena_admin_sq_sq_direction(struct ena_admin_sq *p, uint8_t val)
1383 {
1384         p->sq_identity |= (val << ENA_ADMIN_SQ_SQ_DIRECTION_SHIFT) &
1385                           ENA_ADMIN_SQ_SQ_DIRECTION_MASK;
1386 }
1387
1388 static inline uint16_t
1389 get_ena_admin_acq_common_desc_command_id(
1390                 const struct ena_admin_acq_common_desc *p)
1391 {
1392         return p->command & ENA_ADMIN_ACQ_COMMON_DESC_COMMAND_ID_MASK;
1393 }
1394
1395 static inline void
1396 set_ena_admin_acq_common_desc_command_id(struct ena_admin_acq_common_desc *p,
1397                                          uint16_t val)
1398 {
1399         p->command |= val & ENA_ADMIN_ACQ_COMMON_DESC_COMMAND_ID_MASK;
1400 }
1401
1402 static inline uint8_t
1403 get_ena_admin_acq_common_desc_phase(const struct ena_admin_acq_common_desc *p)
1404 {
1405         return p->flags & ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK;
1406 }
1407
1408 static inline void
1409 set_ena_admin_acq_common_desc_phase(struct ena_admin_acq_common_desc *p,
1410                                     uint8_t val)
1411 {
1412         p->flags |= val & ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK;
1413 }
1414
1415 static inline uint8_t
1416 get_ena_admin_aq_create_sq_cmd_sq_direction(
1417                 const struct ena_admin_aq_create_sq_cmd *p)
1418 {
1419         return (p->sq_identity & ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_MASK)
1420                 >> ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_SHIFT;
1421 }
1422
1423 static inline void
1424 set_ena_admin_aq_create_sq_cmd_sq_direction(
1425                 struct ena_admin_aq_create_sq_cmd *p,
1426                 uint8_t val)
1427 {
1428         p->sq_identity |= (val <<
1429                            ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_SHIFT)
1430                           & ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_MASK;
1431 }
1432
1433 static inline uint8_t
1434 get_ena_admin_aq_create_sq_cmd_placement_policy(
1435                 const struct ena_admin_aq_create_sq_cmd *p)
1436 {
1437         return p->sq_caps_2 & ENA_ADMIN_AQ_CREATE_SQ_CMD_PLACEMENT_POLICY_MASK;
1438 }
1439
1440 static inline void
1441 set_ena_admin_aq_create_sq_cmd_placement_policy(
1442                 struct ena_admin_aq_create_sq_cmd *p,
1443                 uint8_t val)
1444 {
1445         p->sq_caps_2 |= val & ENA_ADMIN_AQ_CREATE_SQ_CMD_PLACEMENT_POLICY_MASK;
1446 }
1447
1448 static inline uint8_t
1449 get_ena_admin_aq_create_sq_cmd_completion_policy(
1450                 const struct ena_admin_aq_create_sq_cmd *p)
1451 {
1452         return (p->sq_caps_2
1453                 & ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_MASK)
1454                 >> ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_SHIFT;
1455 }
1456
1457 static inline void
1458 set_ena_admin_aq_create_sq_cmd_completion_policy(
1459                 struct ena_admin_aq_create_sq_cmd *p,
1460                 uint8_t val)
1461 {
1462         p->sq_caps_2 |=
1463                 (val << ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_SHIFT)
1464                 & ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_MASK;
1465 }
1466
1467 static inline uint8_t
1468 get_ena_admin_aq_create_sq_cmd_is_physically_contiguous(
1469                 const struct ena_admin_aq_create_sq_cmd *p)
1470 {
1471         return p->sq_caps_3 &
1472                 ENA_ADMIN_AQ_CREATE_SQ_CMD_IS_PHYSICALLY_CONTIGUOUS_MASK;
1473 }
1474
1475 static inline void
1476 set_ena_admin_aq_create_sq_cmd_is_physically_contiguous(
1477                 struct ena_admin_aq_create_sq_cmd *p,
1478                 uint8_t val)
1479 {
1480         p->sq_caps_3 |= val &
1481                 ENA_ADMIN_AQ_CREATE_SQ_CMD_IS_PHYSICALLY_CONTIGUOUS_MASK;
1482 }
1483
1484 static inline uint8_t
1485 get_ena_admin_aq_create_cq_cmd_interrupt_mode_enabled(
1486                 const struct ena_admin_aq_create_cq_cmd *p)
1487 {
1488         return (p->cq_caps_1 &
1489                 ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_MASK)
1490                 >> ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_SHIFT;
1491 }
1492
1493 static inline void
1494 set_ena_admin_aq_create_cq_cmd_interrupt_mode_enabled(
1495                 struct ena_admin_aq_create_cq_cmd *p,
1496                 uint8_t val)
1497 {
1498         p->cq_caps_1 |=
1499         (val << ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_SHIFT)
1500         & ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_MASK;
1501 }
1502
1503 static inline uint8_t
1504 get_ena_admin_aq_create_cq_cmd_cq_entry_size_words(
1505                 const struct ena_admin_aq_create_cq_cmd *p)
1506 {
1507         return p->cq_caps_2
1508                & ENA_ADMIN_AQ_CREATE_CQ_CMD_CQ_ENTRY_SIZE_WORDS_MASK;
1509 }
1510
1511 static inline void
1512 set_ena_admin_aq_create_cq_cmd_cq_entry_size_words(
1513                 struct ena_admin_aq_create_cq_cmd *p,
1514                 uint8_t val)
1515 {
1516         p->cq_caps_2 |=
1517                 val & ENA_ADMIN_AQ_CREATE_CQ_CMD_CQ_ENTRY_SIZE_WORDS_MASK;
1518 }
1519
1520 static inline uint8_t
1521 get_ena_admin_get_set_feature_common_desc_select(
1522                 const struct ena_admin_get_set_feature_common_desc *p)
1523 {
1524         return p->flags & ENA_ADMIN_GET_SET_FEATURE_COMMON_DESC_SELECT_MASK;
1525 }
1526
1527 static inline void
1528 set_ena_admin_get_set_feature_common_desc_select(
1529                 struct ena_admin_get_set_feature_common_desc *p,
1530                 uint8_t val)
1531 {
1532         p->flags |= val & ENA_ADMIN_GET_SET_FEATURE_COMMON_DESC_SELECT_MASK;
1533 }
1534
1535 static inline uint32_t
1536 get_ena_admin_get_feature_link_desc_autoneg(
1537                 const struct ena_admin_get_feature_link_desc *p)
1538 {
1539         return p->flags & ENA_ADMIN_GET_FEATURE_LINK_DESC_AUTONEG_MASK;
1540 }
1541
1542 static inline void
1543 set_ena_admin_get_feature_link_desc_autoneg(
1544                 struct ena_admin_get_feature_link_desc *p,
1545                 uint32_t val)
1546 {
1547         p->flags |= val & ENA_ADMIN_GET_FEATURE_LINK_DESC_AUTONEG_MASK;
1548 }
1549
1550 static inline uint32_t
1551 get_ena_admin_get_feature_link_desc_duplex(
1552                 const struct ena_admin_get_feature_link_desc *p)
1553 {
1554         return (p->flags & ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_MASK)
1555                 >> ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_SHIFT;
1556 }
1557
1558 static inline void
1559 set_ena_admin_get_feature_link_desc_duplex(
1560                 struct ena_admin_get_feature_link_desc *p,
1561                 uint32_t val)
1562 {
1563         p->flags |= (val << ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_SHIFT)
1564                         & ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_MASK;
1565 }
1566
1567 static inline uint32_t
1568 get_ena_admin_feature_offload_desc_TX_L3_csum_ipv4(
1569                 const struct ena_admin_feature_offload_desc *p)
1570 {
1571         return p->tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L3_CSUM_IPV4_MASK;
1572 }
1573
1574 static inline void
1575 set_ena_admin_feature_offload_desc_TX_L3_csum_ipv4(
1576                 struct ena_admin_feature_offload_desc *p,
1577                 uint32_t val)
1578 {
1579         p->tx |= val & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L3_CSUM_IPV4_MASK;
1580 }
1581
1582 static inline uint32_t
1583 get_ena_admin_feature_offload_desc_TX_L4_ipv4_csum_part(
1584                 const struct ena_admin_feature_offload_desc *p)
1585 {
1586         return (p->tx &
1587                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK)
1588                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_SHIFT;
1589 }
1590
1591 static inline void
1592 set_ena_admin_feature_offload_desc_TX_L4_ipv4_csum_part(
1593                 struct ena_admin_feature_offload_desc *p,
1594                 uint32_t val)
1595 {
1596         p->tx |= (val <<
1597                   ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_SHIFT)
1598                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK;
1599 }
1600
1601 static inline uint32_t
1602 get_ena_admin_feature_offload_desc_TX_L4_ipv4_csum_full(
1603                 const struct ena_admin_feature_offload_desc *p)
1604 {
1605         return (p->tx &
1606                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_MASK)
1607                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_SHIFT;
1608 }
1609
1610 static inline void
1611 set_ena_admin_feature_offload_desc_TX_L4_ipv4_csum_full(
1612                 struct ena_admin_feature_offload_desc *p,
1613                 uint32_t val)
1614 {
1615         p->tx |= (val <<
1616                   ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_SHIFT)
1617                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_MASK;
1618 }
1619
1620 static inline uint32_t
1621 get_ena_admin_feature_offload_desc_TX_L4_ipv6_csum_part(
1622                 const struct ena_admin_feature_offload_desc *p)
1623 {
1624         return (p->tx &
1625                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK)
1626                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_SHIFT;
1627 }
1628
1629 static inline void
1630 set_ena_admin_feature_offload_desc_TX_L4_ipv6_csum_part(
1631                 struct ena_admin_feature_offload_desc *p,
1632                 uint32_t val)
1633 {
1634         p->tx |= (val <<
1635                   ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_SHIFT)
1636                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK;
1637 }
1638
1639 static inline uint32_t
1640 get_ena_admin_feature_offload_desc_TX_L4_ipv6_csum_full(
1641                 const struct ena_admin_feature_offload_desc *p)
1642 {
1643         return (p->tx &
1644                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_MASK)
1645                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_SHIFT;
1646 }
1647
1648 static inline void
1649 set_ena_admin_feature_offload_desc_TX_L4_ipv6_csum_full(
1650                 struct ena_admin_feature_offload_desc *p,
1651                 uint32_t val)
1652 {
1653         p->tx |= (val <<
1654                   ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_SHIFT)
1655                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_MASK;
1656 }
1657
1658 static inline uint32_t
1659 get_ena_admin_feature_offload_desc_tso_ipv4(
1660                 const struct ena_admin_feature_offload_desc *p)
1661 {
1662         return (p->tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK)
1663                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_SHIFT;
1664 }
1665
1666 static inline void
1667 set_ena_admin_feature_offload_desc_tso_ipv4(
1668                 struct ena_admin_feature_offload_desc *p,
1669                 uint32_t val)
1670 {
1671         p->tx |= (val << ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_SHIFT)
1672                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK;
1673 }
1674
1675 static inline uint32_t
1676 get_ena_admin_feature_offload_desc_tso_ipv6(
1677                 const struct ena_admin_feature_offload_desc *p)
1678 {
1679         return (p->tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK)
1680                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_SHIFT;
1681 }
1682
1683 static inline void
1684 set_ena_admin_feature_offload_desc_tso_ipv6(
1685                 struct ena_admin_feature_offload_desc *p,
1686                 uint32_t val)
1687 {
1688         p->tx |= (val << ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_SHIFT)
1689                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK;
1690 }
1691
1692 static inline uint32_t
1693 get_ena_admin_feature_offload_desc_tso_ecn(
1694                 const struct ena_admin_feature_offload_desc *p)
1695 {
1696         return (p->tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_MASK)
1697                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_SHIFT;
1698 }
1699
1700 static inline void
1701 set_ena_admin_feature_offload_desc_tso_ecn(
1702                 struct ena_admin_feature_offload_desc *p,
1703                 uint32_t val)
1704 {
1705         p->tx |= (val << ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_SHIFT)
1706                  & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_MASK;
1707 }
1708
1709 static inline uint32_t
1710 get_ena_admin_feature_offload_desc_RX_L3_csum_ipv4(
1711                 const struct ena_admin_feature_offload_desc *p)
1712 {
1713         return p->rx_supported &
1714                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L3_CSUM_IPV4_MASK;
1715 }
1716
1717 static inline void
1718 set_ena_admin_feature_offload_desc_RX_L3_csum_ipv4(
1719                 struct ena_admin_feature_offload_desc *p,
1720                 uint32_t val)
1721 {
1722         p->rx_supported |=
1723                 val & ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L3_CSUM_IPV4_MASK;
1724 }
1725
1726 static inline uint32_t
1727 get_ena_admin_feature_offload_desc_RX_L4_ipv4_csum(
1728                 const struct ena_admin_feature_offload_desc *p)
1729 {
1730         return (p->rx_supported &
1731                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK)
1732                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_SHIFT;
1733 }
1734
1735 static inline void
1736 set_ena_admin_feature_offload_desc_RX_L4_ipv4_csum(
1737                 struct ena_admin_feature_offload_desc *p,
1738                 uint32_t val)
1739 {
1740         p->rx_supported |=
1741                 (val << ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_SHIFT)
1742                 & ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK;
1743 }
1744
1745 static inline uint32_t
1746 get_ena_admin_feature_offload_desc_RX_L4_ipv6_csum(
1747                 const struct ena_admin_feature_offload_desc *p)
1748 {
1749         return (p->rx_supported &
1750                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_MASK)
1751                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_SHIFT;
1752 }
1753
1754 static inline void
1755 set_ena_admin_feature_offload_desc_RX_L4_ipv6_csum(
1756                 struct ena_admin_feature_offload_desc *p,
1757                 uint32_t val)
1758 {
1759         p->rx_supported |=
1760                 (val << ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_SHIFT)
1761                 & ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_MASK;
1762 }
1763
1764 static inline uint32_t
1765 get_ena_admin_feature_offload_desc_RX_hash(
1766                 const struct ena_admin_feature_offload_desc *p)
1767 {
1768         return (p->rx_supported &
1769                 ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK)
1770                 >> ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_SHIFT;
1771 }
1772
1773 static inline void
1774 set_ena_admin_feature_offload_desc_RX_hash(
1775                 struct ena_admin_feature_offload_desc *p,
1776                 uint32_t val)
1777 {
1778         p->rx_supported |=
1779                 (val << ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_SHIFT)
1780                 & ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK;
1781 }
1782
1783 static inline uint32_t
1784 get_ena_admin_feature_rss_flow_hash_function_funcs(
1785                 const struct ena_admin_feature_rss_flow_hash_function *p)
1786 {
1787         return p->supported_func &
1788                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_FUNCS_MASK;
1789 }
1790
1791 static inline void
1792 set_ena_admin_feature_rss_flow_hash_function_funcs(
1793                 struct ena_admin_feature_rss_flow_hash_function *p,
1794                 uint32_t val)
1795 {
1796         p->supported_func |=
1797                 val & ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_FUNCS_MASK;
1798 }
1799
1800 static inline uint32_t
1801 get_ena_admin_feature_rss_flow_hash_function_selected_func(
1802                 const struct ena_admin_feature_rss_flow_hash_function *p)
1803 {
1804         return p->selected_func &
1805                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_SELECTED_FUNC_MASK;
1806 }
1807
1808 static inline void
1809 set_ena_admin_feature_rss_flow_hash_function_selected_func(
1810                 struct ena_admin_feature_rss_flow_hash_function *p,
1811                 uint32_t val)
1812 {
1813         p->selected_func |=
1814                 val &
1815                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_SELECTED_FUNC_MASK;
1816 }
1817
1818 static inline uint16_t
1819 get_ena_admin_proto_input_inner(const struct ena_admin_proto_input *p)
1820 {
1821         return p->flags & ENA_ADMIN_PROTO_INPUT_INNER_MASK;
1822 }
1823
1824 static inline void
1825 set_ena_admin_proto_input_inner(struct ena_admin_proto_input *p, uint16_t val)
1826 {
1827         p->flags |= val & ENA_ADMIN_PROTO_INPUT_INNER_MASK;
1828 }
1829
1830 static inline uint16_t
1831 get_ena_admin_feature_rss_flow_hash_input_L3_sort(
1832                 const struct ena_admin_feature_rss_flow_hash_input *p)
1833 {
1834         return (p->supported_input_sort &
1835                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_MASK)
1836                 >> ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_SHIFT;
1837 }
1838
1839 static inline void
1840 set_ena_admin_feature_rss_flow_hash_input_L3_sort(
1841                 struct ena_admin_feature_rss_flow_hash_input *p,
1842                 uint16_t val)
1843 {
1844         p->supported_input_sort |=
1845                 (val << ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_SHIFT)
1846                  & ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_MASK;
1847 }
1848
1849 static inline uint16_t
1850 get_ena_admin_feature_rss_flow_hash_input_L4_sort(
1851                 const struct ena_admin_feature_rss_flow_hash_input *p)
1852 {
1853         return (p->supported_input_sort &
1854                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_MASK)
1855                 >> ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_SHIFT;
1856 }
1857
1858 static inline void
1859 set_ena_admin_feature_rss_flow_hash_input_L4_sort(
1860                 struct ena_admin_feature_rss_flow_hash_input *p,
1861                 uint16_t val)
1862 {
1863         p->supported_input_sort |=
1864                 (val << ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_SHIFT)
1865                 & ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_MASK;
1866 }
1867
1868 static inline uint16_t
1869 get_ena_admin_feature_rss_flow_hash_input_enable_L3_sort(
1870                 const struct ena_admin_feature_rss_flow_hash_input *p)
1871 {
1872         return (p->enabled_input_sort &
1873                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_MASK)
1874                 >> ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_SHIFT;
1875 }
1876
1877 static inline void
1878 set_ena_admin_feature_rss_flow_hash_input_enable_L3_sort(
1879                 struct ena_admin_feature_rss_flow_hash_input *p,
1880                 uint16_t val)
1881 {
1882         p->enabled_input_sort |=
1883                 (val <<
1884                  ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_SHIFT)
1885                 & ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_MASK;
1886 }
1887
1888 static inline uint16_t
1889 get_ena_admin_feature_rss_flow_hash_input_enable_L4_sort(
1890                 const struct ena_admin_feature_rss_flow_hash_input *p)
1891 {
1892         return (p->enabled_input_sort &
1893                 ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_MASK)
1894                 >> ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_SHIFT;
1895 }
1896
1897 static inline void
1898 set_ena_admin_feature_rss_flow_hash_input_enable_L4_sort(
1899                 struct ena_admin_feature_rss_flow_hash_input *p,
1900                 uint16_t val)
1901 {
1902         p->enabled_input_sort |=
1903                 (val <<
1904                  ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_SHIFT)
1905                 & ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_MASK;
1906 }
1907
1908 static inline uint32_t
1909 get_ena_admin_host_info_major(const struct ena_admin_host_info *p)
1910 {
1911         return p->driver_version & ENA_ADMIN_HOST_INFO_MAJOR_MASK;
1912 }
1913
1914 static inline void
1915 set_ena_admin_host_info_major(struct ena_admin_host_info *p, uint32_t val)
1916 {
1917         p->driver_version |= val & ENA_ADMIN_HOST_INFO_MAJOR_MASK;
1918 }
1919
1920 static inline uint32_t
1921 get_ena_admin_host_info_minor(const struct ena_admin_host_info *p)
1922 {
1923         return (p->driver_version & ENA_ADMIN_HOST_INFO_MINOR_MASK)
1924                 >> ENA_ADMIN_HOST_INFO_MINOR_SHIFT;
1925 }
1926
1927 static inline void
1928 set_ena_admin_host_info_minor(struct ena_admin_host_info *p, uint32_t val)
1929 {
1930         p->driver_version |= (val << ENA_ADMIN_HOST_INFO_MINOR_SHIFT)
1931                 & ENA_ADMIN_HOST_INFO_MINOR_MASK;
1932 }
1933
1934 static inline uint32_t
1935 get_ena_admin_host_info_sub_minor(const struct ena_admin_host_info *p)
1936 {
1937         return (p->driver_version & ENA_ADMIN_HOST_INFO_SUB_MINOR_MASK)
1938                 >> ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT;
1939 }
1940
1941 static inline void
1942 set_ena_admin_host_info_sub_minor(struct ena_admin_host_info *p, uint32_t val)
1943 {
1944         p->driver_version |= (val << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT)
1945                              & ENA_ADMIN_HOST_INFO_SUB_MINOR_MASK;
1946 }
1947
1948 static inline uint8_t
1949 get_ena_admin_aenq_common_desc_phase(
1950                 const struct ena_admin_aenq_common_desc *p)
1951 {
1952         return p->flags & ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK;
1953 }
1954
1955 static inline void
1956 set_ena_admin_aenq_common_desc_phase(
1957                 struct ena_admin_aenq_common_desc *p,
1958                 uint8_t val)
1959 {
1960         p->flags |= val & ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK;
1961 }
1962
1963 static inline uint32_t
1964 get_ena_admin_aenq_link_change_desc_link_status(
1965                 const struct ena_admin_aenq_link_change_desc *p)
1966 {
1967         return p->flags & ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK;
1968 }
1969
1970 static inline void
1971 set_ena_admin_aenq_link_change_desc_link_status(
1972                 struct ena_admin_aenq_link_change_desc *p,
1973                 uint32_t val)
1974 {
1975         p->flags |= val & ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK;
1976 }
1977
1978 #endif /* !defined(ENA_DEFS_LINUX_MAINLINE) */
1979 #endif /*_ENA_ADMIN_H_ */