linux/drivers/crypto/intel/qat/qat_common/adf_pfvf_msg.h

/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */
/* Copyright(c) 2015 - 2021 Intel Corporation */
#ifndef ADF_PFVF_MSG_H
#define ADF_PFVF_MSG_H

#include <linux/bits.h>

/*
 * PF<->VF Gen2 Messaging format
 *
 * The PF has an array of 32-bit PF2VF registers, one for each VF. The
 * PF can access all these registers while each VF can access only the one
 * register associated with that particular VF.
 *
 * The register functionally is split into two parts:
 * The bottom half is for PF->VF messages. In particular when the first
 * bit of this register (bit 0) gets set an interrupt will be triggered
 * in the respective VF.
 * The top half is for VF->PF messages. In particular when the first bit
 * of this half of register (bit 16) gets set an interrupt will be triggered
 * in the PF.
 *
 * The remaining bits within this register are available to encode messages.
 * and implement a collision control mechanism to prevent concurrent use of
 * the PF2VF register by both the PF and VF.
 *
 *  31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
 *  _______________________________________________
 * |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
 * +-----------------------------------------------+
 *  \___________________________/ \_________/ ^   ^
 *                ^                    ^      |   |
 *                |                    |      |   VF2PF Int
 *                |                    |      Message Origin
 *                |                    Message Type
 *                Message-specific Data/Reserved
 *
 *  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
 *  _______________________________________________
 * |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
 * +-----------------------------------------------+
 *  \___________________________/ \_________/ ^   ^
 *                ^                    ^      |   |
 *                |                    |      |   PF2VF Int
 *                |                    |      Message Origin
 *                |                    Message Type
 *                Message-specific Data/Reserved
 *
 * Message Origin (Should always be 1)
 * A legacy out-of-tree QAT driver allowed for a set of messages not supported
 * by this driver; these had a Msg Origin of 0 and are ignored by this driver.
 *
 * When a PF or VF attempts to send a message in the lower or upper 16 bits,
 * respectively, the other 16 bits are written to first with a defined
 * IN_USE_BY pattern as part of a collision control scheme (see function
 * adf_gen2_pfvf_send() in adf_pf2vf_msg.c).
 *
 *
 * PF<->VF Gen4 Messaging format
 *
 * Similarly to the gen2 messaging format, 32-bit long registers are used for
 * communication between PF and VFs. However, each VF and PF share a pair of
 * 32-bits register to avoid collisions: one for PV to VF messages and one
 * for VF to PF messages.
 *
 * Both the Interrupt bit and the Message Origin bit retain the same position
 * and meaning, although non-system messages are now deprecated and not
 * expected.
 *
 *  31 30              9  8  7  6  5  4  3  2  1  0
 *  _______________________________________________
 * |  |  |   . . .   |  |  |  |  |  |  |  |  |  |  |
 * +-----------------------------------------------+
 *  \_____________________/ \_______________/  ^  ^
 *             ^                     ^         |  |
 *             |                     |         |  PF/VF Int
 *             |                     |         Message Origin
 *             |                     Message Type
 *             Message-specific Data/Reserved
 *
 * For both formats, the message reception is acknowledged by lowering the
 * interrupt bit on the register where the message was sent.
 */

/* PFVF message common bits */
#define ADF_PFVF_INT
#define ADF_PFVF_MSGORIGIN_SYSTEM

/* Different generations have different CSR layouts, use this struct
 * to abstract these differences away
 */
struct pfvf_message {};

/* PF->VF messages */
enum pf2vf_msgtype {};

/* VF->PF messages */
enum vf2pf_msgtype {};

/* VF/PF compatibility version. */
enum pfvf_compatibility_version {};

/* PF->VF Version Response */
#define ADF_PF2VF_VERSION_RESP_VERS_MASK
#define ADF_PF2VF_VERSION_RESP_RESULT_MASK

enum pf2vf_compat_response {};

enum ring_reset_result {};

#define ADF_VF2PF_RNG_RESET_RP_MASK
#define ADF_VF2PF_RNG_RESET_RSVD_MASK

/* PF->VF Block Responses */
#define ADF_PF2VF_BLKMSG_RESP_TYPE_MASK
#define ADF_PF2VF_BLKMSG_RESP_DATA_MASK

enum pf2vf_blkmsg_resp_type {};

/* PF->VF Block Error Code */
enum pf2vf_blkmsg_error {};

/* VF->PF Block Requests */
#define ADF_VF2PF_LARGE_BLOCK_TYPE_MASK
#define ADF_VF2PF_LARGE_BLOCK_BYTE_MASK
#define ADF_VF2PF_MEDIUM_BLOCK_TYPE_MASK
#define ADF_VF2PF_MEDIUM_BLOCK_BYTE_MASK
#define ADF_VF2PF_SMALL_BLOCK_TYPE_MASK
#define ADF_VF2PF_SMALL_BLOCK_BYTE_MASK
#define ADF_VF2PF_BLOCK_CRC_REQ_MASK

/* PF->VF Block Request Types
 *  0..15 - 32 byte message
 * 16..23 - 64 byte message
 * 24..27 - 128 byte message
 */
enum vf2pf_blkmsg_req_type {};

#define ADF_VF2PF_SMALL_BLOCK_TYPE_MAX

#define ADF_VF2PF_MEDIUM_BLOCK_TYPE_MAX

#define ADF_VF2PF_LARGE_BLOCK_TYPE_MAX

#define ADF_VF2PF_SMALL_BLOCK_BYTE_MAX

#define ADF_VF2PF_MEDIUM_BLOCK_BYTE_MAX

#define ADF_VF2PF_LARGE_BLOCK_BYTE_MAX

struct pfvf_blkmsg_header {} __packed;

#define ADF_PFVF_BLKMSG_HEADER_SIZE
#define ADF_PFVF_BLKMSG_PAYLOAD_SIZE(blkmsg)
#define ADF_PFVF_BLKMSG_MSG_SIZE(blkmsg)
#define ADF_PFVF_BLKMSG_MSG_MAX_SIZE

/* PF->VF Block message header bytes */
#define ADF_PFVF_BLKMSG_VER_BYTE
#define ADF_PFVF_BLKMSG_LEN_BYTE

/* PF/VF Capabilities message values */
enum blkmsg_capabilities_versions {};

struct capabilities_v1 {} __packed;

struct capabilities_v2 {} __packed;

struct capabilities_v3 {} __packed;

/* PF/VF Ring to service mapping values */
enum blkmsg_ring_to_svc_versions {};

struct ring_to_svc_map_v1 {} __packed;

#endif /* ADF_PFVF_MSG_H */