xref: /freebsd/sys/dev/gve/gve_adminq.h (revision b044f125373e05c20ca16edfd29cccad1f4025bd)
154dfc97bSShailend Chand /*-
254dfc97bSShailend Chand  * SPDX-License-Identifier: BSD-3-Clause
354dfc97bSShailend Chand  *
4d438b4efSShailend Chand  * Copyright (c) 2023-2024 Google LLC
554dfc97bSShailend Chand  *
654dfc97bSShailend Chand  * Redistribution and use in source and binary forms, with or without modification,
754dfc97bSShailend Chand  * are permitted provided that the following conditions are met:
854dfc97bSShailend Chand  *
954dfc97bSShailend Chand  * 1. Redistributions of source code must retain the above copyright notice, this
1054dfc97bSShailend Chand  *    list of conditions and the following disclaimer.
1154dfc97bSShailend Chand  *
1254dfc97bSShailend Chand  * 2. Redistributions in binary form must reproduce the above copyright notice,
1354dfc97bSShailend Chand  *    this list of conditions and the following disclaimer in the documentation
1454dfc97bSShailend Chand  *    and/or other materials provided with the distribution.
1554dfc97bSShailend Chand  *
1654dfc97bSShailend Chand  * 3. Neither the name of the copyright holder nor the names of its contributors
1754dfc97bSShailend Chand  *    may be used to endorse or promote products derived from this software without
1854dfc97bSShailend Chand  *    specific prior written permission.
1954dfc97bSShailend Chand  *
2054dfc97bSShailend Chand  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2154dfc97bSShailend Chand  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2254dfc97bSShailend Chand  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2354dfc97bSShailend Chand  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
2454dfc97bSShailend Chand  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2554dfc97bSShailend Chand  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2654dfc97bSShailend Chand  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
2754dfc97bSShailend Chand  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2854dfc97bSShailend Chand  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2954dfc97bSShailend Chand  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3054dfc97bSShailend Chand  */
3154dfc97bSShailend Chand #ifndef _GVE_AQ_H_
3254dfc97bSShailend Chand #define _GVE_AQ_H_ 1
3354dfc97bSShailend Chand 
3454dfc97bSShailend Chand #include <sys/types.h>
3554dfc97bSShailend Chand #include <net/if.h>
3654dfc97bSShailend Chand #include <net/iflib.h>
3754dfc97bSShailend Chand #include <machine/bus.h>
3854dfc97bSShailend Chand #include <machine/resource.h>
3954dfc97bSShailend Chand 
4054dfc97bSShailend Chand /* Admin queue opcodes */
4154dfc97bSShailend Chand enum gve_adminq_opcodes {
4254dfc97bSShailend Chand 	GVE_ADMINQ_DESCRIBE_DEVICE		= 0x1,
4354dfc97bSShailend Chand 	GVE_ADMINQ_CONFIGURE_DEVICE_RESOURCES	= 0x2,
4454dfc97bSShailend Chand 	GVE_ADMINQ_REGISTER_PAGE_LIST		= 0x3,
4554dfc97bSShailend Chand 	GVE_ADMINQ_UNREGISTER_PAGE_LIST		= 0x4,
4654dfc97bSShailend Chand 	GVE_ADMINQ_CREATE_TX_QUEUE		= 0x5,
4754dfc97bSShailend Chand 	GVE_ADMINQ_CREATE_RX_QUEUE		= 0x6,
4854dfc97bSShailend Chand 	GVE_ADMINQ_DESTROY_TX_QUEUE		= 0x7,
4954dfc97bSShailend Chand 	GVE_ADMINQ_DESTROY_RX_QUEUE		= 0x8,
5054dfc97bSShailend Chand 	GVE_ADMINQ_DECONFIGURE_DEVICE_RESOURCES	= 0x9,
5154dfc97bSShailend Chand 	GVE_ADMINQ_SET_DRIVER_PARAMETER		= 0xB,
5254dfc97bSShailend Chand 	GVE_ADMINQ_REPORT_STATS			= 0xC,
5354dfc97bSShailend Chand 	GVE_ADMINQ_REPORT_LINK_SPEED		= 0xD,
5454dfc97bSShailend Chand 	GVE_ADMINQ_GET_PTYPE_MAP		= 0xE,
5554dfc97bSShailend Chand 	GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY	= 0xF,
5654dfc97bSShailend Chand };
5754dfc97bSShailend Chand 
5854dfc97bSShailend Chand /* Admin queue status codes */
5954dfc97bSShailend Chand enum gve_adminq_statuses {
6054dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
6154dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_PASSED			= 0x1,
6254dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_ABORTED		= 0xFFFFFFF0,
6354dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_ALREADY_EXISTS		= 0xFFFFFFF1,
6454dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_CANCELLED		= 0xFFFFFFF2,
6554dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_DATALOSS		= 0xFFFFFFF3,
6654dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_DEADLINE_EXCEEDED	= 0xFFFFFFF4,
6754dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_FAILED_PRECONDITION	= 0xFFFFFFF5,
6854dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_INTERNAL_ERROR		= 0xFFFFFFF6,
6954dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_INVALID_ARGUMENT	= 0xFFFFFFF7,
7054dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_NOT_FOUND		= 0xFFFFFFF8,
7154dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_OUT_OF_RANGE		= 0xFFFFFFF9,
7254dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_PERMISSION_DENIED	= 0xFFFFFFFA,
7354dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_UNAUTHENTICATED	= 0xFFFFFFFB,
7454dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_RESOURCE_EXHAUSTED	= 0xFFFFFFFC,
7554dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_UNAVAILABLE		= 0xFFFFFFFD,
7654dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_UNIMPLEMENTED		= 0xFFFFFFFE,
7754dfc97bSShailend Chand 	GVE_ADMINQ_COMMAND_ERROR_UNKNOWN_ERROR		= 0xFFFFFFFF,
7854dfc97bSShailend Chand };
7954dfc97bSShailend Chand 
8054dfc97bSShailend Chand #define GVE_ADMINQ_DEVICE_DESCRIPTOR_VERSION 1
8154dfc97bSShailend Chand 
8254dfc97bSShailend Chand /*
8354dfc97bSShailend Chand  * All AdminQ command structs should be naturally packed. The static_assert
8454dfc97bSShailend Chand  * calls make sure this is the case at compile time.
8554dfc97bSShailend Chand  */
8654dfc97bSShailend Chand 
8754dfc97bSShailend Chand struct gve_adminq_describe_device {
8854dfc97bSShailend Chand 	__be64 device_descriptor_addr;
8954dfc97bSShailend Chand 	__be32 device_descriptor_version;
9054dfc97bSShailend Chand 	__be32 available_length;
9154dfc97bSShailend Chand };
9254dfc97bSShailend Chand 
9354dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_describe_device) == 16,
9454dfc97bSShailend Chand     "gve: bad admin queue struct length");
9554dfc97bSShailend Chand 
9654dfc97bSShailend Chand struct gve_device_descriptor {
9754dfc97bSShailend Chand 	__be64 max_registered_pages;
9854dfc97bSShailend Chand 	__be16 reserved1;
9954dfc97bSShailend Chand 	__be16 tx_queue_entries;
10054dfc97bSShailend Chand 	__be16 rx_queue_entries;
10154dfc97bSShailend Chand 	__be16 default_num_queues;
10254dfc97bSShailend Chand 	__be16 mtu;
10354dfc97bSShailend Chand 	__be16 counters;
10454dfc97bSShailend Chand 	__be16 reserved2;
10554dfc97bSShailend Chand 	__be16 rx_pages_per_qpl;
10654dfc97bSShailend Chand 	uint8_t  mac[ETHER_ADDR_LEN];
10754dfc97bSShailend Chand 	__be16 num_device_options;
10854dfc97bSShailend Chand 	__be16 total_length;
10954dfc97bSShailend Chand 	uint8_t  reserved3[6];
11054dfc97bSShailend Chand };
11154dfc97bSShailend Chand 
11254dfc97bSShailend Chand _Static_assert(sizeof(struct gve_device_descriptor) == 40,
11354dfc97bSShailend Chand     "gve: bad admin queue struct length");
11454dfc97bSShailend Chand 
11554dfc97bSShailend Chand struct gve_device_option {
11654dfc97bSShailend Chand 	__be16 option_id;
11754dfc97bSShailend Chand 	__be16 option_length;
11854dfc97bSShailend Chand 	__be32 required_features_mask;
11954dfc97bSShailend Chand };
12054dfc97bSShailend Chand 
12154dfc97bSShailend Chand _Static_assert(sizeof(struct gve_device_option) == 8,
12254dfc97bSShailend Chand     "gve: bad admin queue struct length");
12354dfc97bSShailend Chand 
12454dfc97bSShailend Chand struct gve_device_option_gqi_rda {
12554dfc97bSShailend Chand 	__be32 supported_features_mask;
12654dfc97bSShailend Chand };
12754dfc97bSShailend Chand 
12854dfc97bSShailend Chand _Static_assert(sizeof(struct gve_device_option_gqi_rda) == 4,
12954dfc97bSShailend Chand     "gve: bad admin queue struct length");
13054dfc97bSShailend Chand 
13154dfc97bSShailend Chand struct gve_device_option_gqi_qpl {
13254dfc97bSShailend Chand 	__be32 supported_features_mask;
13354dfc97bSShailend Chand };
13454dfc97bSShailend Chand 
13554dfc97bSShailend Chand _Static_assert(sizeof(struct gve_device_option_gqi_qpl) == 4,
13654dfc97bSShailend Chand     "gve: bad admin queue struct length");
13754dfc97bSShailend Chand 
13854dfc97bSShailend Chand struct gve_device_option_dqo_rda {
13954dfc97bSShailend Chand 	__be32 supported_features_mask;
140d438b4efSShailend Chand 	__be16 tx_comp_ring_entries;
141d438b4efSShailend Chand 	__be16 rx_buff_ring_entries;
14254dfc97bSShailend Chand };
14354dfc97bSShailend Chand 
144d438b4efSShailend Chand _Static_assert(sizeof(struct gve_device_option_dqo_rda) == 8,
14554dfc97bSShailend Chand     "gve: bad admin queue struct length");
14654dfc97bSShailend Chand 
1472348ac89SShailend Chand struct gve_device_option_dqo_qpl {
1482348ac89SShailend Chand 	__be32 supported_features_mask;
1492348ac89SShailend Chand 	__be16 tx_comp_ring_entries;
1502348ac89SShailend Chand 	__be16 rx_buff_ring_entries;
1512348ac89SShailend Chand };
1522348ac89SShailend Chand 
1532348ac89SShailend Chand _Static_assert(sizeof(struct gve_device_option_dqo_qpl) == 8,
1542348ac89SShailend Chand     "gve: bad admin queue struct length");
1552348ac89SShailend Chand 
15622fe926aSVee Agarwal struct gve_ring_size_bound {
15722fe926aSVee Agarwal 	__be16 rx;
15822fe926aSVee Agarwal 	__be16 tx;
15954dfc97bSShailend Chand };
16054dfc97bSShailend Chand 
16122fe926aSVee Agarwal _Static_assert(sizeof(struct gve_ring_size_bound) == 4,
16222fe926aSVee Agarwal     "gve: bad admin queue struct length");
16322fe926aSVee Agarwal 
16422fe926aSVee Agarwal struct gve_device_option_modify_ring {
16522fe926aSVee Agarwal 	__be32 supported_features_mask;
16622fe926aSVee Agarwal 	struct gve_ring_size_bound max_ring_size;
16722fe926aSVee Agarwal 	struct gve_ring_size_bound min_ring_size;
16822fe926aSVee Agarwal };
16922fe926aSVee Agarwal 
17022fe926aSVee Agarwal _Static_assert(sizeof(struct gve_device_option_modify_ring) == 12,
17154dfc97bSShailend Chand     "gve: bad admin queue struct length");
17254dfc97bSShailend Chand 
17354dfc97bSShailend Chand struct gve_device_option_jumbo_frames {
17454dfc97bSShailend Chand 	__be32 supported_features_mask;
17554dfc97bSShailend Chand 	__be16 max_mtu;
17654dfc97bSShailend Chand 	uint8_t padding[2];
17754dfc97bSShailend Chand };
17854dfc97bSShailend Chand 
17954dfc97bSShailend Chand _Static_assert(sizeof(struct gve_device_option_jumbo_frames) == 8,
18054dfc97bSShailend Chand     "gve: bad admin queue struct length");
18154dfc97bSShailend Chand 
18254dfc97bSShailend Chand enum gve_dev_opt_id {
18354dfc97bSShailend Chand 	GVE_DEV_OPT_ID_GQI_RAW_ADDRESSING = 0x1,
18454dfc97bSShailend Chand 	GVE_DEV_OPT_ID_GQI_RDA = 0x2,
18554dfc97bSShailend Chand 	GVE_DEV_OPT_ID_GQI_QPL = 0x3,
18654dfc97bSShailend Chand 	GVE_DEV_OPT_ID_DQO_RDA = 0x4,
18754dfc97bSShailend Chand 	GVE_DEV_OPT_ID_MODIFY_RING = 0x6,
1882348ac89SShailend Chand 	GVE_DEV_OPT_ID_DQO_QPL = 0x7,
18954dfc97bSShailend Chand 	GVE_DEV_OPT_ID_JUMBO_FRAMES = 0x8,
19054dfc97bSShailend Chand };
19154dfc97bSShailend Chand 
19254dfc97bSShailend Chand /*
19354dfc97bSShailend Chand  * These masks are way to predicate the use of a particular option on the driver
19454dfc97bSShailend Chand  * having particular bug fixes represented by each bit position in the mask.
19554dfc97bSShailend Chand  * Currently they are all zero because there are no known bugs preventing the
19654dfc97bSShailend Chand  * use of any option.
19754dfc97bSShailend Chand  */
19854dfc97bSShailend Chand enum gve_dev_opt_req_feat_mask {
19954dfc97bSShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RAW_ADDRESSING = 0x0,
20054dfc97bSShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA = 0x0,
20154dfc97bSShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL = 0x0,
20254dfc97bSShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA = 0x0,
2032348ac89SShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_DQO_QPL = 0x0,
20454dfc97bSShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING = 0x0,
20554dfc97bSShailend Chand 	GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES = 0x0,
20654dfc97bSShailend Chand };
20754dfc97bSShailend Chand 
20854dfc97bSShailend Chand enum gve_sup_feature_mask {
20954dfc97bSShailend Chand 	GVE_SUP_MODIFY_RING_MASK  = 1 << 0,
21054dfc97bSShailend Chand 	GVE_SUP_JUMBO_FRAMES_MASK = 1 << 2,
21154dfc97bSShailend Chand };
21254dfc97bSShailend Chand 
21354dfc97bSShailend Chand #define GVE_VERSION_STR_LEN 128
21454dfc97bSShailend Chand 
21554dfc97bSShailend Chand enum gve_driver_capability {
21654dfc97bSShailend Chand 	gve_driver_capability_gqi_qpl = 0,
21754dfc97bSShailend Chand 	gve_driver_capability_gqi_rda = 1,
2182348ac89SShailend Chand 	gve_driver_capability_dqo_qpl = 2,
21954dfc97bSShailend Chand 	gve_driver_capability_dqo_rda = 3,
22054dfc97bSShailend Chand };
22154dfc97bSShailend Chand 
22254dfc97bSShailend Chand #define GVE_CAP1(a) BIT((int) a)
22354dfc97bSShailend Chand #define GVE_CAP2(a) BIT(((int) a) - 64)
22454dfc97bSShailend Chand #define GVE_CAP3(a) BIT(((int) a) - 128)
22554dfc97bSShailend Chand #define GVE_CAP4(a) BIT(((int) a) - 192)
22654dfc97bSShailend Chand 
22754dfc97bSShailend Chand /*
22854dfc97bSShailend Chand  * The following four defines describe 256 compatibility bits.
22954dfc97bSShailend Chand  * Only a few bits (as shown in `gve_driver_compatibility`) are currently
23054dfc97bSShailend Chand  * defined. The rest are reserved for future use.
23154dfc97bSShailend Chand  */
232d438b4efSShailend Chand #define GVE_DRIVER_CAPABILITY_FLAGS1 \
233d438b4efSShailend Chand 	(GVE_CAP1(gve_driver_capability_gqi_qpl) | \
2342348ac89SShailend Chand 	 GVE_CAP1(gve_driver_capability_dqo_qpl) | \
235d438b4efSShailend Chand 	 GVE_CAP1(gve_driver_capability_dqo_rda))
23654dfc97bSShailend Chand #define GVE_DRIVER_CAPABILITY_FLAGS2 0x0
23754dfc97bSShailend Chand #define GVE_DRIVER_CAPABILITY_FLAGS3 0x0
23854dfc97bSShailend Chand #define GVE_DRIVER_CAPABILITY_FLAGS4 0x0
23954dfc97bSShailend Chand 
24054dfc97bSShailend Chand struct gve_driver_info {
24154dfc97bSShailend Chand 	uint8_t os_type;
24254dfc97bSShailend Chand 	uint8_t driver_major;
24354dfc97bSShailend Chand 	uint8_t driver_minor;
24454dfc97bSShailend Chand 	uint8_t driver_sub;
24554dfc97bSShailend Chand 	__be32 os_version_major;
24654dfc97bSShailend Chand 	__be32 os_version_minor;
24754dfc97bSShailend Chand 	__be32 os_version_sub;
24854dfc97bSShailend Chand 	__be64 driver_capability_flags[4];
24954dfc97bSShailend Chand 	uint8_t os_version_str1[GVE_VERSION_STR_LEN];
25054dfc97bSShailend Chand 	uint8_t os_version_str2[GVE_VERSION_STR_LEN];
25154dfc97bSShailend Chand };
25254dfc97bSShailend Chand 
25354dfc97bSShailend Chand struct gve_adminq_verify_driver_compatibility {
25454dfc97bSShailend Chand 	__be64 driver_info_len;
25554dfc97bSShailend Chand 	__be64 driver_info_addr;
25654dfc97bSShailend Chand };
25754dfc97bSShailend Chand 
25854dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_verify_driver_compatibility) == 16,
25954dfc97bSShailend Chand     "gve: bad admin queue struct length");
26054dfc97bSShailend Chand 
26154dfc97bSShailend Chand struct gve_adminq_configure_device_resources {
26254dfc97bSShailend Chand 	__be64 counter_array;
26354dfc97bSShailend Chand 	__be64 irq_db_addr;
26454dfc97bSShailend Chand 	__be32 num_counters;
26554dfc97bSShailend Chand 	__be32 num_irq_dbs;
26654dfc97bSShailend Chand 	__be32 irq_db_stride;
26754dfc97bSShailend Chand 	__be32 ntfy_blk_msix_base_idx;
26854dfc97bSShailend Chand 	uint8_t queue_format;
26954dfc97bSShailend Chand 	uint8_t padding[7];
27054dfc97bSShailend Chand };
27154dfc97bSShailend Chand 
27254dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_configure_device_resources) == 40,
27354dfc97bSShailend Chand     "gve: bad admin queue struct length");
27454dfc97bSShailend Chand 
27554dfc97bSShailend Chand struct gve_adminq_register_page_list {
27654dfc97bSShailend Chand 	__be32 page_list_id;
27754dfc97bSShailend Chand 	__be32 num_pages;
27854dfc97bSShailend Chand 	__be64 page_address_list_addr;
27954dfc97bSShailend Chand 	__be64 page_size;
28054dfc97bSShailend Chand };
28154dfc97bSShailend Chand 
28254dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_register_page_list) == 24,
28354dfc97bSShailend Chand     "gve: bad admin queue struct length");
28454dfc97bSShailend Chand 
28554dfc97bSShailend Chand struct gve_adminq_unregister_page_list {
28654dfc97bSShailend Chand 	__be32 page_list_id;
28754dfc97bSShailend Chand };
28854dfc97bSShailend Chand 
28954dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_unregister_page_list) == 4,
29054dfc97bSShailend Chand     "gve: bad admin queue struct length");
29154dfc97bSShailend Chand 
29254dfc97bSShailend Chand struct gve_adminq_create_tx_queue {
29354dfc97bSShailend Chand 	__be32 queue_id;
29454dfc97bSShailend Chand 	__be32 reserved;
29554dfc97bSShailend Chand 	__be64 queue_resources_addr;
29654dfc97bSShailend Chand 	__be64 tx_ring_addr;
29754dfc97bSShailend Chand 	__be32 queue_page_list_id;
29854dfc97bSShailend Chand 	__be32 ntfy_id;
29954dfc97bSShailend Chand 	__be64 tx_comp_ring_addr;
30054dfc97bSShailend Chand 	__be16 tx_ring_size;
30154dfc97bSShailend Chand 	__be16 tx_comp_ring_size;
30254dfc97bSShailend Chand 	uint8_t padding[4];
30354dfc97bSShailend Chand };
30454dfc97bSShailend Chand 
30554dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_create_tx_queue) == 48,
30654dfc97bSShailend Chand     "gve: bad admin queue struct length");
30754dfc97bSShailend Chand 
308d438b4efSShailend Chand #define GVE_RAW_ADDRESSING_QPL_ID 0xFFFFFFFF
309d438b4efSShailend Chand 
31054dfc97bSShailend Chand struct gve_adminq_create_rx_queue {
31154dfc97bSShailend Chand 	__be32 queue_id;
31254dfc97bSShailend Chand 	__be32 index;
31354dfc97bSShailend Chand 	__be32 reserved;
31454dfc97bSShailend Chand 	__be32 ntfy_id;
31554dfc97bSShailend Chand 	__be64 queue_resources_addr;
31654dfc97bSShailend Chand 	__be64 rx_desc_ring_addr;
31754dfc97bSShailend Chand 	__be64 rx_data_ring_addr;
31854dfc97bSShailend Chand 	__be32 queue_page_list_id;
31954dfc97bSShailend Chand 	__be16 rx_ring_size;
32054dfc97bSShailend Chand 	__be16 packet_buffer_size;
32154dfc97bSShailend Chand 	__be16 rx_buff_ring_size;
32254dfc97bSShailend Chand 	uint8_t enable_rsc;
32354dfc97bSShailend Chand 	uint8_t padding[5];
32454dfc97bSShailend Chand };
32554dfc97bSShailend Chand 
32654dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_create_rx_queue) == 56,
32754dfc97bSShailend Chand     "gve: bad admin queue struct length");
32854dfc97bSShailend Chand 
32954dfc97bSShailend Chand /* Queue resources that are shared with the device */
33054dfc97bSShailend Chand struct gve_queue_resources {
33154dfc97bSShailend Chand 	union {
33254dfc97bSShailend Chand 		struct {
33354dfc97bSShailend Chand 			__be32 db_index;	/* Device -> Guest */
33454dfc97bSShailend Chand 			__be32 counter_index;	/* Device -> Guest */
33554dfc97bSShailend Chand 		};
33654dfc97bSShailend Chand 		uint8_t reserved[64];
33754dfc97bSShailend Chand 	};
33854dfc97bSShailend Chand };
33954dfc97bSShailend Chand 
34054dfc97bSShailend Chand _Static_assert(sizeof(struct gve_queue_resources) == 64,
34154dfc97bSShailend Chand     "gve: bad admin queue struct length");
34254dfc97bSShailend Chand 
34354dfc97bSShailend Chand struct gve_adminq_destroy_tx_queue {
34454dfc97bSShailend Chand 	__be32 queue_id;
34554dfc97bSShailend Chand };
34654dfc97bSShailend Chand 
34754dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_destroy_tx_queue) == 4,
34854dfc97bSShailend Chand     "gve: bad admin queue struct length");
34954dfc97bSShailend Chand 
35054dfc97bSShailend Chand struct gve_adminq_destroy_rx_queue {
35154dfc97bSShailend Chand 	__be32 queue_id;
35254dfc97bSShailend Chand };
35354dfc97bSShailend Chand 
35454dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_destroy_rx_queue) == 4,
35554dfc97bSShailend Chand     "gve: bad admin queue struct length");
35654dfc97bSShailend Chand 
35754dfc97bSShailend Chand /* GVE Set Driver Parameter Types */
35854dfc97bSShailend Chand enum gve_set_driver_param_types {
35954dfc97bSShailend Chand 	GVE_SET_PARAM_MTU	= 0x1,
36054dfc97bSShailend Chand };
36154dfc97bSShailend Chand 
36254dfc97bSShailend Chand struct gve_adminq_set_driver_parameter {
36354dfc97bSShailend Chand 	__be32 parameter_type;
36454dfc97bSShailend Chand 	uint8_t reserved[4];
36554dfc97bSShailend Chand 	__be64 parameter_value;
36654dfc97bSShailend Chand };
36754dfc97bSShailend Chand 
36854dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_set_driver_parameter) == 16,
36954dfc97bSShailend Chand     "gve: bad admin queue struct length");
37054dfc97bSShailend Chand 
37154dfc97bSShailend Chand struct stats {
37254dfc97bSShailend Chand 	__be32 stat_name;
37354dfc97bSShailend Chand 	__be32 queue_id;
37454dfc97bSShailend Chand 	__be64 value;
37554dfc97bSShailend Chand };
37654dfc97bSShailend Chand 
37754dfc97bSShailend Chand _Static_assert(sizeof(struct stats) == 16,
37854dfc97bSShailend Chand     "gve: bad admin queue struct length");
37954dfc97bSShailend Chand 
380*b044f125SJasper Tran O'Leary /*
381*b044f125SJasper Tran O'Leary  * These are control path types for PTYPE which are the same as the data path
382d438b4efSShailend Chand  * types.
383d438b4efSShailend Chand  */
384d438b4efSShailend Chand struct gve_ptype_entry {
385d438b4efSShailend Chand 	uint8_t l3_type;
386d438b4efSShailend Chand 	uint8_t l4_type;
387d438b4efSShailend Chand };
388d438b4efSShailend Chand 
389d438b4efSShailend Chand struct gve_ptype_map {
390d438b4efSShailend Chand 	struct gve_ptype_entry ptypes[1 << 10]; /* PTYPES are always 10 bits. */
391d438b4efSShailend Chand };
392d438b4efSShailend Chand 
393d438b4efSShailend Chand struct gve_adminq_get_ptype_map {
394d438b4efSShailend Chand 	__be64 ptype_map_len;
395d438b4efSShailend Chand 	__be64 ptype_map_addr;
396d438b4efSShailend Chand };
397d438b4efSShailend Chand 
39854dfc97bSShailend Chand struct gve_adminq_command {
39954dfc97bSShailend Chand 	__be32 opcode;
40054dfc97bSShailend Chand 	__be32 status;
40154dfc97bSShailend Chand 	union {
40254dfc97bSShailend Chand 		struct gve_adminq_configure_device_resources
40354dfc97bSShailend Chand 					configure_device_resources;
40454dfc97bSShailend Chand 		struct gve_adminq_create_tx_queue create_tx_queue;
40554dfc97bSShailend Chand 		struct gve_adminq_create_rx_queue create_rx_queue;
40654dfc97bSShailend Chand 		struct gve_adminq_destroy_tx_queue destroy_tx_queue;
40754dfc97bSShailend Chand 		struct gve_adminq_destroy_rx_queue destroy_rx_queue;
40854dfc97bSShailend Chand 		struct gve_adminq_describe_device describe_device;
40954dfc97bSShailend Chand 		struct gve_adminq_register_page_list reg_page_list;
41054dfc97bSShailend Chand 		struct gve_adminq_unregister_page_list unreg_page_list;
41154dfc97bSShailend Chand 		struct gve_adminq_set_driver_parameter set_driver_param;
41254dfc97bSShailend Chand 		struct gve_adminq_verify_driver_compatibility
41354dfc97bSShailend Chand 					verify_driver_compatibility;
414d438b4efSShailend Chand 		struct gve_adminq_get_ptype_map get_ptype_map;
41554dfc97bSShailend Chand 		uint8_t reserved[56];
41654dfc97bSShailend Chand 	};
41754dfc97bSShailend Chand };
41854dfc97bSShailend Chand 
41954dfc97bSShailend Chand _Static_assert(sizeof(struct gve_adminq_command) == 64,
42054dfc97bSShailend Chand     "gve: bad admin queue struct length");
42154dfc97bSShailend Chand 
422d438b4efSShailend Chand enum gve_l3_type {
423d438b4efSShailend Chand 	/* Must be zero so zero initialized LUT is unknown. */
424d438b4efSShailend Chand 	GVE_L3_TYPE_UNKNOWN = 0,
425d438b4efSShailend Chand 	GVE_L3_TYPE_OTHER,
426d438b4efSShailend Chand 	GVE_L3_TYPE_IPV4,
427d438b4efSShailend Chand 	GVE_L3_TYPE_IPV6,
428d438b4efSShailend Chand };
429d438b4efSShailend Chand 
430d438b4efSShailend Chand enum gve_l4_type {
431d438b4efSShailend Chand 	/* Must be zero so zero initialized LUT is unknown. */
432d438b4efSShailend Chand 	GVE_L4_TYPE_UNKNOWN = 0,
433d438b4efSShailend Chand 	GVE_L4_TYPE_OTHER,
434d438b4efSShailend Chand 	GVE_L4_TYPE_TCP,
435d438b4efSShailend Chand 	GVE_L4_TYPE_UDP,
436d438b4efSShailend Chand 	GVE_L4_TYPE_ICMP,
437d438b4efSShailend Chand 	GVE_L4_TYPE_SCTP,
438d438b4efSShailend Chand };
439d438b4efSShailend Chand 
44054dfc97bSShailend Chand int gve_adminq_create_rx_queues(struct gve_priv *priv, uint32_t num_queues);
44154dfc97bSShailend Chand int gve_adminq_create_tx_queues(struct gve_priv *priv, uint32_t num_queues);
44254dfc97bSShailend Chand int gve_adminq_destroy_tx_queues(struct gve_priv *priv, uint32_t num_queues);
44354dfc97bSShailend Chand int gve_adminq_destroy_rx_queues(struct gve_priv *priv, uint32_t num_queues);
44454dfc97bSShailend Chand int gve_adminq_set_mtu(struct gve_priv *priv, uint32_t mtu);
44554dfc97bSShailend Chand int gve_adminq_alloc(struct gve_priv *priv);
44654dfc97bSShailend Chand void gve_reset_adminq(struct gve_priv *priv);
44754dfc97bSShailend Chand int gve_adminq_describe_device(struct gve_priv *priv);
44854dfc97bSShailend Chand int gve_adminq_configure_device_resources(struct gve_priv *priv);
44954dfc97bSShailend Chand int gve_adminq_deconfigure_device_resources(struct gve_priv *priv);
45054dfc97bSShailend Chand void gve_release_adminq(struct gve_priv *priv);
45154dfc97bSShailend Chand int gve_adminq_register_page_list(struct gve_priv *priv,
45254dfc97bSShailend Chand     struct gve_queue_page_list *qpl);
45354dfc97bSShailend Chand int gve_adminq_unregister_page_list(struct gve_priv *priv, uint32_t page_list_id);
45454dfc97bSShailend Chand int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
45554dfc97bSShailend Chand     uint64_t driver_info_len, vm_paddr_t driver_info_addr);
456d438b4efSShailend Chand int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
457d438b4efSShailend Chand     struct gve_ptype_lut *ptype_lut);
45854dfc97bSShailend Chand #endif /* _GVE_AQ_H_ */
459