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