1 /* SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2020-21 Intel Corporation.
6 #ifndef IOSM_IPC_PROTOCOL_OPS_H
7 #define IOSM_IPC_PROTOCOL_OPS_H
9 #define SIZE_MASK 0x00FFFFFF
10 #define COMPLETION_STATUS 24
14 * enum ipc_mem_td_cs - Completion status of a TD
15 * @IPC_MEM_TD_CS_INVALID: Initial status - td not yet used.
16 * @IPC_MEM_TD_CS_PARTIAL_TRANSFER: More data pending -> next TD used for this
17 * @IPC_MEM_TD_CS_END_TRANSFER: IO transfer is complete.
18 * @IPC_MEM_TD_CS_OVERFLOW: IO transfer to small for the buff to write
19 * @IPC_MEM_TD_CS_ABORT: TD marked as abort and shall be discarded
21 * @IPC_MEM_TD_CS_ERROR: General error.
24 IPC_MEM_TD_CS_INVALID,
25 IPC_MEM_TD_CS_PARTIAL_TRANSFER,
26 IPC_MEM_TD_CS_END_TRANSFER,
27 IPC_MEM_TD_CS_OVERFLOW,
33 * enum ipc_mem_msg_cs - Completion status of IPC Message
34 * @IPC_MEM_MSG_CS_INVALID: Initial status.
35 * @IPC_MEM_MSG_CS_SUCCESS: IPC Message completion success.
36 * @IPC_MEM_MSG_CS_ERROR: Message send error.
39 IPC_MEM_MSG_CS_INVALID,
40 IPC_MEM_MSG_CS_SUCCESS,
45 * struct ipc_msg_prep_args_pipe - struct for pipe args for message preparation
46 * @pipe: Pipe to open/close
48 struct ipc_msg_prep_args_pipe {
49 struct ipc_pipe *pipe;
53 * struct ipc_msg_prep_args_sleep - struct for sleep args for message
55 * @target: 0=host, 1=device
56 * @state: 0=enter sleep, 1=exit sleep
58 struct ipc_msg_prep_args_sleep {
64 * struct ipc_msg_prep_feature_set - struct for feature set argument for
66 * @reset_enable: 0=out-of-band, 1=in-band-crash notification
68 struct ipc_msg_prep_feature_set {
73 * struct ipc_msg_prep_map - struct for map argument for message preparation
74 * @region_id: Region to map
75 * @addr: Pcie addr of region to map
76 * @size: Size of the region to map
78 struct ipc_msg_prep_map {
79 unsigned int region_id;
85 * struct ipc_msg_prep_unmap - struct for unmap argument for message preparation
86 * @region_id: Region to unmap
88 struct ipc_msg_prep_unmap {
89 unsigned int region_id;
93 * struct ipc_msg_prep_args - Union to handle different message types
94 * @pipe_open: Pipe open message preparation struct
95 * @pipe_close: Pipe close message preparation struct
96 * @sleep: Sleep message preparation struct
97 * @feature_set: Feature set message preparation struct
98 * @map: Memory map message preparation struct
99 * @unmap: Memory unmap message preparation struct
101 union ipc_msg_prep_args {
102 struct ipc_msg_prep_args_pipe pipe_open;
103 struct ipc_msg_prep_args_pipe pipe_close;
104 struct ipc_msg_prep_args_sleep sleep;
105 struct ipc_msg_prep_feature_set feature_set;
106 struct ipc_msg_prep_map map;
107 struct ipc_msg_prep_unmap unmap;
111 * enum ipc_msg_prep_type - Enum for message prepare actions
112 * @IPC_MSG_PREP_SLEEP: Sleep message preparation type
113 * @IPC_MSG_PREP_PIPE_OPEN: Pipe open message preparation type
114 * @IPC_MSG_PREP_PIPE_CLOSE: Pipe close message preparation type
115 * @IPC_MSG_PREP_FEATURE_SET: Feature set message preparation type
116 * @IPC_MSG_PREP_MAP: Memory map message preparation type
117 * @IPC_MSG_PREP_UNMAP: Memory unmap message preparation type
119 enum ipc_msg_prep_type {
121 IPC_MSG_PREP_PIPE_OPEN,
122 IPC_MSG_PREP_PIPE_CLOSE,
123 IPC_MSG_PREP_FEATURE_SET,
129 * struct ipc_rsp - Response to sent message
130 * @completion: For waking up requestor
131 * @status: Completion status
134 struct completion completion;
135 enum ipc_mem_msg_cs status;
139 * enum ipc_mem_msg - Type-definition of the messages.
140 * @IPC_MEM_MSG_OPEN_PIPE: AP ->CP: Open a pipe
141 * @IPC_MEM_MSG_CLOSE_PIPE: AP ->CP: Close a pipe
142 * @IPC_MEM_MSG_ABORT_PIPE: AP ->CP: wait for completion of the
143 * running transfer and abort all pending
144 * IO-transfers for the pipe
145 * @IPC_MEM_MSG_SLEEP: AP ->CP: host enter or exit sleep
146 * @IPC_MEM_MSG_FEATURE_SET: AP ->CP: Intel feature configuration
149 IPC_MEM_MSG_OPEN_PIPE = 0x01,
150 IPC_MEM_MSG_CLOSE_PIPE = 0x02,
151 IPC_MEM_MSG_ABORT_PIPE = 0x03,
152 IPC_MEM_MSG_SLEEP = 0x04,
153 IPC_MEM_MSG_FEATURE_SET = 0xF0,
157 * struct ipc_mem_msg_open_pipe - Message structure for open pipe
158 * @tdr_addr: Tdr address
159 * @tdr_entries: Tdr entries
160 * @pipe_nr: Pipe number
161 * @type_of_message: Message type
162 * @irq_vector: MSI vector number
163 * @accumulation_backoff: Time in usec for data accumalation
164 * @completion_status: Message Completion Status
166 struct ipc_mem_msg_open_pipe {
172 __le32 accumulation_backoff;
173 __le32 completion_status;
177 * struct ipc_mem_msg_close_pipe - Message structure for close pipe
178 * @reserved1: Reserved
179 * @reserved2: Reserved
180 * @pipe_nr: Pipe number
181 * @type_of_message: Message type
182 * @reserved3: Reserved
183 * @reserved4: Reserved
184 * @completion_status: Message Completion Status
186 struct ipc_mem_msg_close_pipe {
193 __le32 completion_status;
197 * struct ipc_mem_msg_abort_pipe - Message structure for abort pipe
198 * @reserved1: Reserved
199 * @reserved2: Reserved
200 * @pipe_nr: Pipe number
201 * @type_of_message: Message type
202 * @reserved3: Reserved
203 * @reserved4: Reserved
204 * @completion_status: Message Completion Status
206 struct ipc_mem_msg_abort_pipe {
213 __le32 completion_status;
217 * struct ipc_mem_msg_host_sleep - Message structure for sleep message.
218 * @reserved1: Reserved
219 * @target: 0=host, 1=device, host or EP devie
220 * is the message target
221 * @state: 0=enter sleep, 1=exit sleep,
222 * 2=enter sleep no protocol
223 * @reserved2: Reserved
224 * @type_of_message: Message type
225 * @reserved3: Reserved
226 * @reserved4: Reserved
227 * @completion_status: Message Completion Status
229 struct ipc_mem_msg_host_sleep {
237 __le32 completion_status;
241 * struct ipc_mem_msg_feature_set - Message structure for feature_set message
242 * @reserved1: Reserved
243 * @reserved2: Reserved
244 * @reset_enable: 0=out-of-band, 1=in-band-crash notification
245 * @type_of_message: Message type
246 * @reserved3: Reserved
247 * @reserved4: Reserved
248 * @completion_status: Message Completion Status
250 struct ipc_mem_msg_feature_set {
257 __le32 completion_status;
261 * struct ipc_mem_msg_common - Message structure for completion status update.
262 * @reserved1: Reserved
263 * @reserved2: Reserved
264 * @type_of_message: Message type
265 * @reserved3: Reserved
266 * @reserved4: Reserved
267 * @completion_status: Message Completion Status
269 struct ipc_mem_msg_common {
275 __le32 completion_status;
279 * union ipc_mem_msg_entry - Union with all possible messages.
280 * @open_pipe: Open pipe message struct
281 * @close_pipe: Close pipe message struct
282 * @abort_pipe: Abort pipe message struct
283 * @host_sleep: Host sleep message struct
284 * @feature_set: Featuer set message struct
285 * @common: Used to access msg_type and to set the completion status
287 union ipc_mem_msg_entry {
288 struct ipc_mem_msg_open_pipe open_pipe;
289 struct ipc_mem_msg_close_pipe close_pipe;
290 struct ipc_mem_msg_abort_pipe abort_pipe;
291 struct ipc_mem_msg_host_sleep host_sleep;
292 struct ipc_mem_msg_feature_set feature_set;
293 struct ipc_mem_msg_common common;
296 /* Transfer descriptor definition. */
297 struct ipc_protocol_td {
299 /* 0 : 63 - 64-bit address of a buffer in host memory. */
302 /* 0 : 31 - 32 bit address */
304 /* 32 : 63 - corresponding descriptor */
309 /* 0 - 2nd byte - Size of the buffer.
310 * The host provides the size of the buffer queued.
311 * The EP device reads this value and shall update
312 * it for downlink transfers to indicate the
313 * amount of data written in buffer.
314 * 3rd byte - This field provides the completion status
315 * of the TD. When queuing the TD, the host sets
316 * the status to 0. The EP device updates this
317 * field when completing the TD.
321 /* 0th - nr of following descriptors
322 * 1 - 3rd byte - reserved
328 * ipc_protocol_msg_prep - Prepare message based upon message type
329 * @ipc_imem: iosm_protocol instance
330 * @msg_type: message prepare type
331 * @args: message arguments
333 * Return: 0 on success and failure value on error
335 int ipc_protocol_msg_prep(struct iosm_imem *ipc_imem,
336 enum ipc_msg_prep_type msg_type,
337 union ipc_msg_prep_args *args);
340 * ipc_protocol_msg_hp_update - Function for head pointer update
342 * @ipc_imem: iosm_protocol instance
344 void ipc_protocol_msg_hp_update(struct iosm_imem *ipc_imem);
347 * ipc_protocol_msg_process - Function for processing responses
349 * @ipc_imem: iosm_protocol instance
352 * Return: True on success, false if error
354 bool ipc_protocol_msg_process(struct iosm_imem *ipc_imem, int irq);
357 * ipc_protocol_ul_td_send - Function for sending the data to CP
358 * @ipc_protocol: iosm_protocol instance
359 * @pipe: Pipe instance
360 * @p_ul_list: uplink sk_buff list
362 * Return: true in success, false in case of error
364 bool ipc_protocol_ul_td_send(struct iosm_protocol *ipc_protocol,
365 struct ipc_pipe *pipe,
366 struct sk_buff_head *p_ul_list);
369 * ipc_protocol_ul_td_process - Function for processing the sent data
370 * @ipc_protocol: iosm_protocol instance
371 * @pipe: Pipe instance
373 * Return: sk_buff instance
375 struct sk_buff *ipc_protocol_ul_td_process(struct iosm_protocol *ipc_protocol,
376 struct ipc_pipe *pipe);
379 * ipc_protocol_dl_td_prepare - Function for providing DL TDs to CP
380 * @ipc_protocol: iosm_protocol instance
381 * @pipe: Pipe instance
383 * Return: true in success, false in case of error
385 bool ipc_protocol_dl_td_prepare(struct iosm_protocol *ipc_protocol,
386 struct ipc_pipe *pipe);
389 * ipc_protocol_dl_td_process - Function for processing the DL data
390 * @ipc_protocol: iosm_protocol instance
391 * @pipe: Pipe instance
393 * Return: sk_buff instance
395 struct sk_buff *ipc_protocol_dl_td_process(struct iosm_protocol *ipc_protocol,
396 struct ipc_pipe *pipe);
399 * ipc_protocol_get_head_tail_index - Function for getting Head and Tail
400 * pointer index of given pipe
401 * @ipc_protocol: iosm_protocol instance
402 * @pipe: Pipe Instance
403 * @head: head pointer index of the given pipe
404 * @tail: tail pointer index of the given pipe
406 void ipc_protocol_get_head_tail_index(struct iosm_protocol *ipc_protocol,
407 struct ipc_pipe *pipe, u32 *head,
410 * ipc_protocol_get_ipc_status - Function for getting the IPC Status
411 * @ipc_protocol: iosm_protocol instance
413 * Return: Returns IPC State
415 enum ipc_mem_device_ipc_state ipc_protocol_get_ipc_status(struct iosm_protocol
419 * ipc_protocol_pipe_cleanup - Function to cleanup pipe resources
420 * @ipc_protocol: iosm_protocol instance
421 * @pipe: Pipe instance
423 void ipc_protocol_pipe_cleanup(struct iosm_protocol *ipc_protocol,
424 struct ipc_pipe *pipe);
427 * ipc_protocol_get_ap_exec_stage - Function for getting AP Exec Stage
428 * @ipc_protocol: pointer to struct iosm protocol
430 * Return: returns BOOT Stages
432 enum ipc_mem_exec_stage
433 ipc_protocol_get_ap_exec_stage(struct iosm_protocol *ipc_protocol);
436 * ipc_protocol_pm_dev_get_sleep_notification - Function for getting Dev Sleep
438 * @ipc_protocol: iosm_protocol instance
440 * Return: Returns dev PM State
442 u32 ipc_protocol_pm_dev_get_sleep_notification(struct iosm_protocol