linux/drivers/misc/mei/hw.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2003-2022, Intel Corporation. All rights reserved
 * Intel Management Engine Interface (Intel MEI) Linux driver
 */

#ifndef _MEI_HW_TYPES_H_
#define _MEI_HW_TYPES_H_

#include <linux/mei.h>

/*
 * Timeouts in Seconds
 */
#define MEI_HW_READY_TIMEOUT
#define MEI_CONNECT_TIMEOUT

#define MEI_CL_CONNECT_TIMEOUT
#define MEI_CL_CONNECT_TIMEOUT_SLOW
#define MEI_CLIENTS_INIT_TIMEOUT

#define MEI_PGI_TIMEOUT
#define MEI_D0I3_TIMEOUT
#define MEI_HBM_TIMEOUT
#define MEI_HBM_TIMEOUT_SLOW

#define MKHI_RCV_TIMEOUT
#define MKHI_RCV_TIMEOUT_SLOW

/*
 * FW page size for DMA allocations
 */
#define MEI_FW_PAGE_SIZE

/*
 * MEI Version
 */
#define HBM_MINOR_VERSION
#define HBM_MAJOR_VERSION

/*
 * MEI version with PGI support
 */
#define HBM_MINOR_VERSION_PGI
#define HBM_MAJOR_VERSION_PGI

/*
 * MEI version with Dynamic clients support
 */
#define HBM_MINOR_VERSION_DC
#define HBM_MAJOR_VERSION_DC

/*
 * MEI version with immediate reply to enum request support
 */
#define HBM_MINOR_VERSION_IE
#define HBM_MAJOR_VERSION_IE

/*
 * MEI version with disconnect on connection timeout support
 */
#define HBM_MINOR_VERSION_DOT
#define HBM_MAJOR_VERSION_DOT

/*
 * MEI version with notification support
 */
#define HBM_MINOR_VERSION_EV
#define HBM_MAJOR_VERSION_EV

/*
 * MEI version with fixed address client support
 */
#define HBM_MINOR_VERSION_FA
#define HBM_MAJOR_VERSION_FA

/*
 * MEI version with OS ver message support
 */
#define HBM_MINOR_VERSION_OS
#define HBM_MAJOR_VERSION_OS

/*
 * MEI version with dma ring support
 */
#define HBM_MINOR_VERSION_DR
#define HBM_MAJOR_VERSION_DR

/*
 * MEI version with vm tag support
 */
#define HBM_MINOR_VERSION_VT
#define HBM_MAJOR_VERSION_VT

/*
 * MEI version with GSC support
 */
#define HBM_MINOR_VERSION_GSC
#define HBM_MAJOR_VERSION_GSC

/*
 * MEI version with capabilities message support
 */
#define HBM_MINOR_VERSION_CAP
#define HBM_MAJOR_VERSION_CAP

/*
 * MEI version with client DMA support
 */
#define HBM_MINOR_VERSION_CD
#define HBM_MAJOR_VERSION_CD

/* Host bus message command opcode */
#define MEI_HBM_CMD_OP_MSK
/* Host bus message command RESPONSE */
#define MEI_HBM_CMD_RES_MSK

/*
 * MEI Bus Message Command IDs
 */
#define HOST_START_REQ_CMD
#define HOST_START_RES_CMD

#define HOST_STOP_REQ_CMD
#define HOST_STOP_RES_CMD

#define ME_STOP_REQ_CMD

#define HOST_ENUM_REQ_CMD
#define HOST_ENUM_RES_CMD

#define HOST_CLIENT_PROPERTIES_REQ_CMD
#define HOST_CLIENT_PROPERTIES_RES_CMD

#define CLIENT_CONNECT_REQ_CMD
#define CLIENT_CONNECT_RES_CMD

#define CLIENT_DISCONNECT_REQ_CMD
#define CLIENT_DISCONNECT_RES_CMD

#define MEI_FLOW_CONTROL_CMD

#define MEI_PG_ISOLATION_ENTRY_REQ_CMD
#define MEI_PG_ISOLATION_ENTRY_RES_CMD
#define MEI_PG_ISOLATION_EXIT_REQ_CMD
#define MEI_PG_ISOLATION_EXIT_RES_CMD

#define MEI_HBM_ADD_CLIENT_REQ_CMD
#define MEI_HBM_ADD_CLIENT_RES_CMD

#define MEI_HBM_NOTIFY_REQ_CMD
#define MEI_HBM_NOTIFY_RES_CMD
#define MEI_HBM_NOTIFICATION_CMD

#define MEI_HBM_DMA_SETUP_REQ_CMD
#define MEI_HBM_DMA_SETUP_RES_CMD

#define MEI_HBM_CAPABILITIES_REQ_CMD
#define MEI_HBM_CAPABILITIES_RES_CMD

#define MEI_HBM_CLIENT_DMA_MAP_REQ_CMD
#define MEI_HBM_CLIENT_DMA_MAP_RES_CMD

#define MEI_HBM_CLIENT_DMA_UNMAP_REQ_CMD
#define MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD

/*
 * MEI Stop Reason
 * used by hbm_host_stop_request.reason
 */
enum mei_stop_reason_types {};


/**
 * enum mei_hbm_status  - mei host bus messages return values
 *
 * @MEI_HBMS_SUCCESS           : status success
 * @MEI_HBMS_CLIENT_NOT_FOUND  : client not found
 * @MEI_HBMS_ALREADY_EXISTS    : connection already established
 * @MEI_HBMS_REJECTED          : connection is rejected
 * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
 * @MEI_HBMS_NOT_ALLOWED       : operation not allowed
 * @MEI_HBMS_ALREADY_STARTED   : system is already started
 * @MEI_HBMS_NOT_STARTED       : system not started
 *
 * @MEI_HBMS_MAX               : sentinel
 */
enum mei_hbm_status {};


/*
 * Client Connect Status
 * used by hbm_client_connect_response.status
 */
enum mei_cl_connect_status {};

/*
 * Client Disconnect Status
 */
enum mei_cl_disconnect_status {};

/**
 * enum mei_ext_hdr_type - extended header type used in
 *    extended header TLV
 *
 * @MEI_EXT_HDR_NONE: sentinel
 * @MEI_EXT_HDR_VTAG: vtag header
 * @MEI_EXT_HDR_GSC: gsc header
 */
enum mei_ext_hdr_type {};

/**
 * struct mei_ext_hdr - extend header descriptor (TLV)
 * @type: enum mei_ext_hdr_type
 * @length: length excluding descriptor
 */
struct mei_ext_hdr {} __packed;

/**
 * struct mei_ext_meta_hdr - extend header meta data
 * @count: number of headers
 * @size: total size of the extended header list excluding meta header
 * @reserved: reserved
 * @hdrs: extended headers TLV list
 */
struct mei_ext_meta_hdr {} __packed;

/**
 * struct mei_ext_hdr_vtag - extend header for vtag
 *
 * @hdr: standard extend header
 * @vtag: virtual tag
 * @reserved: reserved
 */
struct mei_ext_hdr_vtag {} __packed;

/*
 * Extended header iterator functions
 */
/**
 * mei_ext_begin - extended header iterator begin
 *
 * @meta: meta header of the extended header list
 *
 * Return: The first extended header
 */
static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
{}

/**
 * mei_ext_last - check if the ext is the last one in the TLV list
 *
 * @meta: meta header of the extended header list
 * @ext: a meta header on the list
 *
 * Return: true if ext is the last header on the list
 */
static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
				struct mei_ext_hdr *ext)
{}

struct mei_gsc_sgl {} __packed;

#define GSC_HECI_MSG_KERNEL
#define GSC_HECI_MSG_USER

#define GSC_ADDRESS_TYPE_GTT
#define GSC_ADDRESS_TYPE_PPGTT
#define GSC_ADDRESS_TYPE_PHYSICAL_CONTINUOUS
#define GSC_ADDRESS_TYPE_PHYSICAL_SGL

/**
 * struct mei_ext_hdr_gsc_h2f - extended header: gsc host to firmware interface
 *
 * @hdr: extended header
 * @client_id: GSC_HECI_MSG_KERNEL or GSC_HECI_MSG_USER
 * @addr_type: GSC_ADDRESS_TYPE_{GTT, PPGTT, PHYSICAL_CONTINUOUS, PHYSICAL_SGL}
 * @fence_id: synchronization marker
 * @input_address_count: number of input sgl buffers
 * @output_address_count: number of output sgl buffers
 * @reserved: reserved
 * @sgl: sg list
 */
struct mei_ext_hdr_gsc_h2f {} __packed;

/**
 * struct mei_ext_hdr_gsc_f2h - gsc firmware to host interface
 *
 * @hdr: extended header
 * @client_id: GSC_HECI_MSG_KERNEL or GSC_HECI_MSG_USER
 * @reserved: reserved
 * @fence_id: synchronization marker
 * @written: number of bytes written to firmware
 */
struct mei_ext_hdr_gsc_f2h {} __packed;

/**
 * mei_ext_next - following extended header on the TLV list
 *
 * @ext: current extend header
 *
 * Context: The function does not check for the overflows,
 *          one should call mei_ext_last before.
 *
 * Return: The following extend header after @ext
 */
static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
{}

/**
 * mei_ext_hdr_len - get ext header length in bytes
 *
 * @ext: extend header
 *
 * Return: extend header length in bytes
 */
static inline u32 mei_ext_hdr_len(const struct mei_ext_hdr *ext)
{}

/**
 * struct mei_msg_hdr - MEI BUS Interface Section
 *
 * @me_addr: device address
 * @host_addr: host address
 * @length: message length
 * @reserved: reserved
 * @extended: message has extended header
 * @dma_ring: message is on dma ring
 * @internal: message is internal
 * @msg_complete: last packet of the message
 * @extension: extension of the header
 */
struct mei_msg_hdr {} __packed;

/* The length is up to 9 bits */
#define MEI_MSG_MAX_LEN_MASK

struct mei_bus_message {} __packed;

/**
 * struct mei_hbm_cl_cmd - client specific host bus command
 *	CONNECT, DISCONNECT, and FlOW CONTROL
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @host_addr: address of the client in the driver
 * @data: generic data
 */
struct mei_hbm_cl_cmd {};

struct hbm_version {} __packed;

struct hbm_host_version_request {} __packed;

struct hbm_host_version_response {} __packed;

struct hbm_host_stop_request {} __packed;

struct hbm_host_stop_response {} __packed;

struct hbm_me_stop_request {} __packed;

/**
 * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
 *
 * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
 * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
 */
enum hbm_host_enum_flags {};

/**
 * struct hbm_host_enum_request - enumeration request from host to fw
 *
 * @hbm_cmd : bus message command header
 * @flags   : request flags
 * @reserved: reserved
 */
struct hbm_host_enum_request {} __packed;

struct hbm_host_enum_response {} __packed;

/**
 * struct mei_client_properties - mei client properties
 *
 * @protocol_name: guid of the client
 * @protocol_version: client protocol version
 * @max_number_of_connections: number of possible connections.
 * @fixed_address: fixed me address (0 if the client is dynamic)
 * @single_recv_buf: 1 if all connections share a single receive buffer.
 * @vt_supported: the client support vtag
 * @reserved: reserved
 * @max_msg_length: MTU of the client
 */
struct mei_client_properties {} __packed;

struct hbm_props_request {} __packed;

struct hbm_props_response {} __packed;

/**
 * struct hbm_add_client_request - request to add a client
 *     might be sent by fw after enumeration has already completed
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @reserved: reserved
 * @client_properties: client properties
 */
struct hbm_add_client_request {} __packed;

/**
 * struct hbm_add_client_response - response to add a client
 *     sent by the host to report client addition status to fw
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @status: if HBMS_SUCCESS then the client can now accept connections.
 * @reserved: reserved
 */
struct hbm_add_client_response {} __packed;

/**
 * struct hbm_power_gate - power gate request/response
 *
 * @hbm_cmd: bus message command header
 * @reserved: reserved
 */
struct hbm_power_gate {} __packed;

/**
 * struct hbm_client_connect_request - connect/disconnect request
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @host_addr: address of the client in the driver
 * @reserved: reserved
 */
struct hbm_client_connect_request {} __packed;

/**
 * struct hbm_client_connect_response - connect/disconnect response
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @host_addr: address of the client in the driver
 * @status: status of the request
 */
struct hbm_client_connect_response {} __packed;


#define MEI_FC_MESSAGE_RESERVED_LENGTH

struct hbm_flow_control {} __packed;

#define MEI_HBM_NOTIFICATION_START
#define MEI_HBM_NOTIFICATION_STOP
/**
 * struct hbm_notification_request - start/stop notification request
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @host_addr: address of the client in the driver
 * @start:  start = 1 or stop = 0 asynchronous notifications
 */
struct hbm_notification_request {} __packed;

/**
 * struct hbm_notification_response - start/stop notification response
 *
 * @hbm_cmd: bus message command header
 * @me_addr: address of the client in ME
 * @host_addr: - address of the client in the driver
 * @status: (mei_hbm_status) response status for the request
 *  - MEI_HBMS_SUCCESS: successful stop/start
 *  - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
 *  - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
 *                         started notification.
 *  - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
 *                         asynchronous notifications are currently disabled.
 *
 * @start:  start = 1 or stop = 0 asynchronous notifications
 * @reserved: reserved
 */
struct hbm_notification_response {} __packed;

/**
 * struct hbm_notification - notification event
 *
 * @hbm_cmd: bus message command header
 * @me_addr:  address of the client in ME
 * @host_addr:  address of the client in the driver
 * @reserved: reserved for alignment
 */
struct hbm_notification {} __packed;

/**
 * struct hbm_dma_mem_dscr - dma ring
 *
 * @addr_hi: the high 32bits of 64 bit address
 * @addr_lo: the low  32bits of 64 bit address
 * @size   : size in bytes (must be power of 2)
 */
struct hbm_dma_mem_dscr {} __packed;

enum {};

/**
 * struct hbm_dma_setup_request - dma setup request
 *
 * @hbm_cmd: bus message command header
 * @reserved: reserved for alignment
 * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
 */
struct hbm_dma_setup_request {} __packed;

/**
 * struct hbm_dma_setup_response - dma setup response
 *
 * @hbm_cmd: bus message command header
 * @status: 0 on success; otherwise DMA setup failed.
 * @reserved: reserved for alignment
 */
struct hbm_dma_setup_response {} __packed;

/**
 * struct hbm_dma_ring_ctrl - dma ring control block
 *
 * @hbuf_wr_idx: host circular buffer write index in slots
 * @reserved1: reserved for alignment
 * @hbuf_rd_idx: host circular buffer read index in slots
 * @reserved2: reserved for alignment
 * @dbuf_wr_idx: device circular buffer write index in slots
 * @reserved3: reserved for alignment
 * @dbuf_rd_idx: device circular buffer read index in slots
 * @reserved4: reserved for alignment
 */
struct hbm_dma_ring_ctrl {} __packed;

/* virtual tag supported */
#define HBM_CAP_VT

/* gsc extended header support */
#define HBM_CAP_GSC

/* client dma supported */
#define HBM_CAP_CD

/**
 * struct hbm_capability_request - capability request from host to fw
 *
 * @hbm_cmd : bus message command header
 * @capability_requested: bitmask of capabilities requested by host
 */
struct hbm_capability_request {} __packed;

/**
 * struct hbm_capability_response - capability response from fw to host
 *
 * @hbm_cmd : bus message command header
 * @capability_granted: bitmask of capabilities granted by FW
 */
struct hbm_capability_response {} __packed;

/**
 * struct hbm_client_dma_map_request - client dma map request from host to fw
 *
 * @hbm_cmd: bus message command header
 * @client_buffer_id: client buffer id
 * @reserved: reserved
 * @address_lsb: DMA address LSB
 * @address_msb: DMA address MSB
 * @size: DMA size
 */
struct hbm_client_dma_map_request {} __packed;

/**
 * struct hbm_client_dma_unmap_request - client dma unmap request
 *        from the host to the firmware
 *
 * @hbm_cmd: bus message command header
 * @status: unmap status
 * @client_buffer_id: client buffer id
 * @reserved: reserved
 */
struct hbm_client_dma_unmap_request {} __packed;

/**
 * struct hbm_client_dma_response - client dma unmap response
 *        from the firmware to the host
 *
 * @hbm_cmd: bus message command header
 * @status: command status
 */
struct hbm_client_dma_response {} __packed;

#endif