/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2023 Intel Corporation */
#ifndef _VIRTCHNL2_H_
#define _VIRTCHNL2_H_
#include <linux/if_ether.h>
/* All opcodes associated with virtchnl2 are prefixed with virtchnl2 or
* VIRTCHNL2. Any future opcodes, offloads/capabilities, structures,
* and defines must be prefixed with virtchnl2 or VIRTCHNL2 to avoid confusion.
*
* PF/VF uses the virtchnl2 interface defined in this header file to communicate
* with device Control Plane (CP). Driver and the CP may run on different
* platforms with different endianness. To avoid byte order discrepancies,
* all the structures in this header follow little-endian format.
*
* This is an interface definition file where existing enums and their values
* must remain unchanged over time, so we specify explicit values for all enums.
*/
/* This macro is used to generate compilation errors if a structure
* is not exactly the correct length.
*/
#define VIRTCHNL2_CHECK_STRUCT_LEN(n, X) \
static_assert((n) == sizeof(struct X))
/* New major set of opcodes introduced and so leaving room for
* old misc opcodes to be added in future. Also these opcodes may only
* be used if both the PF and VF have successfully negotiated the
* VIRTCHNL version as 2.0 during VIRTCHNL2_OP_VERSION exchange.
*/
enum virtchnl2_op {
VIRTCHNL2_OP_UNKNOWN = 0,
VIRTCHNL2_OP_VERSION = 1,
VIRTCHNL2_OP_GET_CAPS = 500,
VIRTCHNL2_OP_CREATE_VPORT = 501,
VIRTCHNL2_OP_DESTROY_VPORT = 502,
VIRTCHNL2_OP_ENABLE_VPORT = 503,
VIRTCHNL2_OP_DISABLE_VPORT = 504,
VIRTCHNL2_OP_CONFIG_TX_QUEUES = 505,
VIRTCHNL2_OP_CONFIG_RX_QUEUES = 506,
VIRTCHNL2_OP_ENABLE_QUEUES = 507,
VIRTCHNL2_OP_DISABLE_QUEUES = 508,
VIRTCHNL2_OP_ADD_QUEUES = 509,
VIRTCHNL2_OP_DEL_QUEUES = 510,
VIRTCHNL2_OP_MAP_QUEUE_VECTOR = 511,
VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR = 512,
VIRTCHNL2_OP_GET_RSS_KEY = 513,
VIRTCHNL2_OP_SET_RSS_KEY = 514,
VIRTCHNL2_OP_GET_RSS_LUT = 515,
VIRTCHNL2_OP_SET_RSS_LUT = 516,
VIRTCHNL2_OP_GET_RSS_HASH = 517,
VIRTCHNL2_OP_SET_RSS_HASH = 518,
VIRTCHNL2_OP_SET_SRIOV_VFS = 519,
VIRTCHNL2_OP_ALLOC_VECTORS = 520,
VIRTCHNL2_OP_DEALLOC_VECTORS = 521,
VIRTCHNL2_OP_EVENT = 522,
VIRTCHNL2_OP_GET_STATS = 523,
VIRTCHNL2_OP_RESET_VF = 524,
VIRTCHNL2_OP_GET_EDT_CAPS = 525,
VIRTCHNL2_OP_GET_PTYPE_INFO = 526,
/* Opcode 527 and 528 are reserved for VIRTCHNL2_OP_GET_PTYPE_ID and
* VIRTCHNL2_OP_GET_PTYPE_INFO_RAW.
* Opcodes 529, 530, 531, 532 and 533 are reserved.
*/
VIRTCHNL2_OP_LOOPBACK = 534,
VIRTCHNL2_OP_ADD_MAC_ADDR = 535,
VIRTCHNL2_OP_DEL_MAC_ADDR = 536,
VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE = 537,
};
/**
* enum virtchnl2_vport_type - Type of virtual port.
* @VIRTCHNL2_VPORT_TYPE_DEFAULT: Default virtual port type.
*/
enum virtchnl2_vport_type {
VIRTCHNL2_VPORT_TYPE_DEFAULT = 0,
};
/**
* enum virtchnl2_queue_model - Type of queue model.
* @VIRTCHNL2_QUEUE_MODEL_SINGLE: Single queue model.
* @VIRTCHNL2_QUEUE_MODEL_SPLIT: Split queue model.
*
* In the single queue model, the same transmit descriptor queue is used by
* software to post descriptors to hardware and by hardware to post completed
* descriptors to software.
* Likewise, the same receive descriptor queue is used by hardware to post
* completions to software and by software to post buffers to hardware.
*
* In the split queue model, hardware uses transmit completion queues to post
* descriptor/buffer completions to software, while software uses transmit
* descriptor queues to post descriptors to hardware.
* Likewise, hardware posts descriptor completions to the receive descriptor
* queue, while software uses receive buffer queues to post buffers to hardware.
*/
enum virtchnl2_queue_model {
VIRTCHNL2_QUEUE_MODEL_SINGLE = 0,
VIRTCHNL2_QUEUE_MODEL_SPLIT = 1,
};
/* Checksum offload capability flags */
enum virtchnl2_cap_txrx_csum {
VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 = BIT(0),
VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP = BIT(1),
VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP = BIT(2),
VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP = BIT(3),
VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP = BIT(4),
VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP = BIT(5),
VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP = BIT(6),
VIRTCHNL2_CAP_TX_CSUM_GENERIC = BIT(7),
VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 = BIT(8),
VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP = BIT(9),
VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP = BIT(10),
VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP = BIT(11),
VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP = BIT(12),
VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP = BIT(13),
VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP = BIT(14),
VIRTCHNL2_CAP_RX_CSUM_GENERIC = BIT(15),
VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL = BIT(16),
VIRTCHNL2_CAP_TX_CSUM_L3_DOUBLE_TUNNEL = BIT(17),
VIRTCHNL2_CAP_RX_CSUM_L3_SINGLE_TUNNEL = BIT(18),
VIRTCHNL2_CAP_RX_CSUM_L3_DOUBLE_TUNNEL = BIT(19),
VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL =