1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * linux/drivers/misc/ibmvmc.h
5 * IBM Power Systems Virtual Management Channel Support.
7 * Copyright (c) 2004, 2018 IBM Corp.
8 * Dave Engebretsen engebret@us.ibm.com
9 * Steven Royer seroyer@linux.vnet.ibm.com
10 * Adam Reznechek adreznec@linux.vnet.ibm.com
11 * Bryant G. Ly <bryantly@linux.vnet.ibm.com>
16 #include <linux/types.h>
17 #include <linux/cdev.h>
21 #define IBMVMC_PROTOCOL_VERSION 0x0101
23 #define MIN_BUF_POOL_SIZE 16
26 #define MAX_BUF_POOL_SIZE 64
28 #define MAX_MTU (4 * 4096)
29 #define DEFAULT_BUF_POOL_SIZE 32
30 #define DEFAULT_HMCS 1
31 #define DEFAULT_MTU 4096
34 #define VMC_INVALID_BUFFER_ID 0xFFFF
38 #define VMC_IOCTL_SETHMCID _IOW(VMC_BASE, 0x00, unsigned char *)
39 #define VMC_IOCTL_QUERY _IOR(VMC_BASE, 0x01, struct ibmvmc_query_struct)
40 #define VMC_IOCTL_REQUESTVMC _IOR(VMC_BASE, 0x02, u32)
42 #define VMC_MSG_CAP 0x01
43 #define VMC_MSG_CAP_RESP 0x81
44 #define VMC_MSG_OPEN 0x02
45 #define VMC_MSG_OPEN_RESP 0x82
46 #define VMC_MSG_CLOSE 0x03
47 #define VMC_MSG_CLOSE_RESP 0x83
48 #define VMC_MSG_ADD_BUF 0x04
49 #define VMC_MSG_ADD_BUF_RESP 0x84
50 #define VMC_MSG_REM_BUF 0x05
51 #define VMC_MSG_REM_BUF_RESP 0x85
52 #define VMC_MSG_SIGNAL 0x06
54 #define VMC_MSG_SUCCESS 0
55 #define VMC_MSG_INVALID_HMC_INDEX 1
56 #define VMC_MSG_INVALID_BUFFER_ID 2
57 #define VMC_MSG_CLOSED_HMC 3
58 #define VMC_MSG_INTERFACE_FAILURE 4
59 #define VMC_MSG_NO_BUFFER 5
61 #define VMC_BUF_OWNER_ALPHA 0
62 #define VMC_BUF_OWNER_HV 1
65 ibmvmc_state_sched_reset = -1,
66 ibmvmc_state_initial = 0,
67 ibmvmc_state_crqinit = 1,
68 ibmvmc_state_capabilities = 2,
69 ibmvmc_state_ready = 3,
70 ibmvmc_state_failed = 4,
74 /* HMC connection not established */
75 ibmhmc_state_free = 0,
77 /* HMC connection established (open called) */
78 ibmhmc_state_initial = 1,
80 /* open msg sent to HV, due to ioctl(1) call */
81 ibmhmc_state_opening = 2,
83 /* HMC connection ready, open resp msg from HV */
84 ibmhmc_state_ready = 3,
86 /* HMC connection failure */
87 ibmhmc_state_failed = 4,
90 struct ibmvmc_buffer {
91 u8 valid; /* 1 when DMA storage allocated to buffer */
92 u8 free; /* 1 when buffer available for the Alpha Partition */
97 dma_addr_t dma_addr_local;
98 dma_addr_t dma_addr_remote;
99 void *real_addr_local;
102 struct ibmvmc_admin_crq_msg {
103 u8 valid; /* RPA Defined */
104 u8 type; /* ibmvmc msg type */
105 u8 status; /* Response msg status. Zero is success and on failure,
106 * either 1 - General Failure, or 2 - Invalid Version is
110 u8 max_hmc; /* Max # of independent HMC connections supported */
111 __be16 pool_size; /* Maximum number of buffers supported per HMC
114 __be32 max_mtu; /* Maximum message size supported (bytes) */
115 __be16 crq_size; /* # of entries available in the CRQ for the
116 * source partition. The target partition must
117 * limit the number of outstanding messages to
120 __be16 version; /* Indicates the code level of the management partition
121 * or the hypervisor with the high-order byte
122 * indicating a major version and the low-order byte
123 * indicating a minor version.
127 struct ibmvmc_crq_msg {
128 u8 valid; /* RPA Defined */
129 u8 type; /* ibmvmc msg type */
130 u8 status; /* Response msg status */
132 u8 rsvd; /* Reserved */
135 u8 hmc_session; /* Session Identifier for the current VMC connection */
136 u8 hmc_index; /* A unique HMC Idx would be used if multiple management
137 * applications running concurrently were desired
151 /* an RPA command/response transport queue */
153 struct ibmvmc_crq_msg *msgs;
155 dma_addr_t msg_token;
159 /* VMC server adapter settings */
160 struct crq_server_adapter {
162 struct crq_queue queue;
165 struct tasklet_struct work_task;
166 wait_queue_head_t reset_wait_queue;
167 struct task_struct *reset_task;
170 /* Driver wide settings */
171 struct ibmvmc_struct {
174 u32 max_buffer_pool_size;
176 struct crq_server_adapter *adapter;
181 struct ibmvmc_file_session;
183 /* Connection specific settings */
188 struct crq_server_adapter *adapter;
190 unsigned char hmc_id[HMC_ID_LEN];
191 struct ibmvmc_buffer buffer[MAX_BUF_POOL_SIZE];
192 unsigned short queue_outbound_msgs[MAX_BUF_POOL_SIZE];
193 int queue_head, queue_tail;
194 struct ibmvmc_file_session *file_session;
197 struct ibmvmc_file_session {
199 struct ibmvmc_hmc *hmc;
203 struct ibmvmc_query_struct {
209 #endif /* __IBMVMC_H */