1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020-2021 NXP
4 #ifndef __BBDEV_LA12XX_IPC_H__
5 #define __BBDEV_LA12XX_IPC_H__
7 #define LA12XX_MAX_QUEUES 20
8 #define HOST_RX_QUEUEID_OFFSET LA12XX_MAX_QUEUES
10 /** No. of max channel per instance */
11 #define IPC_MAX_CHANNEL_COUNT (64)
13 /** No. of max channel per instance */
14 #define IPC_MAX_DEPTH (16)
16 /** No. of max IPC instance per modem */
17 #define IPC_MAX_INSTANCE_COUNT (1)
20 #define IPC_SUCCESS (0) /** IPC operation success */
21 #define IPC_INPUT_INVALID (-1) /** Invalid input to API */
22 #define IPC_CH_INVALID (-2) /** Channel no is invalid */
23 #define IPC_INSTANCE_INVALID (-3) /** Instance no is invalid */
24 #define IPC_MEM_INVALID (-4) /** Insufficient memory */
25 #define IPC_CH_FULL (-5) /** Channel is full */
26 #define IPC_CH_EMPTY (-6) /** Channel is empty */
27 #define IPC_BL_EMPTY (-7) /** Free buffer list is empty */
28 #define IPC_BL_FULL (-8) /** Free buffer list is full */
29 #define IPC_HOST_BUF_ALLOC_FAIL (-9) /** DPDK malloc fail */
30 #define IPC_MD_SZ_MISS_MATCH (-10) /** META DATA size in mhif miss matched*/
31 #define IPC_MALLOC_FAIL (-11) /** system malloc fail */
32 #define IPC_IOCTL_FAIL (-12) /** IOCTL call failed */
33 #define IPC_MMAP_FAIL (-14) /** MMAP fail */
34 #define IPC_OPEN_FAIL (-15) /** OPEN fail */
35 #define IPC_EVENTFD_FAIL (-16) /** eventfd initialization failed */
36 #define IPC_NOT_IMPLEMENTED (-17) /** IPC feature is not implemented yet*/
38 #define SET_HIF_HOST_RDY(hif, RDY_MASK) (hif->host_ready |= RDY_MASK)
39 #define CHK_HIF_MOD_RDY(hif, RDY_MASK) (hif->mod_ready & RDY_MASK)
42 #define HIF_HOST_READY_HOST_REGIONS (1 << 0)
43 #define HIF_HOST_READY_IPC_LIB (1 << 12)
44 #define HIF_HOST_READY_IPC_APP (1 << 13)
45 #define HIF_HOST_READY_FECA (1 << 14)
47 /* Modem Ready bits */
48 #define HIF_MOD_READY_IPC_LIB (1 << 5)
49 #define HIF_MOD_READY_IPC_APP (1 << 6)
50 #define HIF_MOD_READY_FECA (1 << 7)
68 #define GUL_IPC_MAGIC 'R'
70 #define IOCTL_GUL_IPC_GET_SYS_MAP _IOW(GUL_IPC_MAGIC, 1, struct ipc_msg *)
71 #define IOCTL_GUL_IPC_CHANNEL_REGISTER _IOWR(GUL_IPC_MAGIC, 4, struct ipc_msg *)
72 #define IOCTL_GUL_IPC_CHANNEL_DEREGISTER \
73 _IOWR(GUL_IPC_MAGIC, 5, struct ipc_msg *)
74 #define IOCTL_GUL_IPC_CHANNEL_RAISE_INTERRUPT _IOW(GUL_IPC_MAGIC, 6, int *)
76 /** buffer ring common metadata */
77 typedef struct ipc_bd_ring_md {
78 volatile uint32_t pi; /**< Producer index and flag (MSB)
79 * which flip for each Ring wrapping
81 volatile uint32_t ci; /**< Consumer index and flag (MSB)
82 * which flip for each Ring wrapping
84 uint32_t ring_size; /**< depth (Used to roll-over pi/ci) */
85 uint32_t msg_size; /**< Size of the each buffer */
86 } __rte_packed ipc_br_md_t;
88 /** IPC buffer descriptor */
89 typedef struct ipc_buffer_desc {
91 uint64_t host_virt; /**< msg's host virtual address */
97 uint32_t modem_ptr; /**< msg's modem physical address */
98 uint32_t len; /**< msg len */
99 } __rte_packed ipc_bd_t;
101 typedef struct ipc_channel {
102 uint32_t ch_id; /**< Channel id */
103 ipc_br_md_t md; /**< Metadata for BD ring */
104 ipc_bd_t bd_h[IPC_MAX_DEPTH]; /**< Buffer Descriptor on Host */
105 ipc_bd_t bd_m[IPC_MAX_DEPTH]; /**< Buffer Descriptor on Modem */
106 uint32_t op_type; /**< Type of the BBDEV operation
107 * supported on this channel
109 uint32_t depth; /**< Channel depth */
110 uint32_t feca_blk_id; /**< FECA Transport Block ID for processing */
111 uint32_t la12xx_core_id;/**< LA12xx core ID on which this will be
114 uint32_t feca_input_circ_size; /**< FECA transport block input
115 * circular buffer size
117 uint32_t host_ipc_params; /**< Address for host IPC parameters */
118 } __rte_packed ipc_ch_t;
120 typedef struct ipc_instance {
121 uint32_t instance_id; /**< instance id, use to init this
122 * instance by ipc_init API
124 uint32_t initialized; /**< Set in ipc_init */
125 ipc_ch_t ch_list[IPC_MAX_CHANNEL_COUNT];
126 /**< Channel descriptors in this instance */
127 } __rte_packed ipc_instance_t;
129 typedef struct ipc_metadata {
130 uint32_t ipc_host_signature; /**< IPC host signature, Set by host/L2 */
131 uint32_t ipc_geul_signature; /**< IPC geul signature, Set by modem */
132 ipc_instance_t instance_list[IPC_MAX_INSTANCE_COUNT];
133 } __rte_packed ipc_metadata_t;
135 typedef struct ipc_channel_us_priv {
138 /* In flight packets status for buffer list. */
139 uint8_t bufs_inflight[IPC_MAX_DEPTH];
149 mem_strt_addr_t modem_ccsrbar;
150 mem_strt_addr_t peb_start; /* PEB meta data */
151 mem_strt_addr_t mhif_start; /* MHIF meta daat */
152 mem_strt_addr_t hugepg_start; /* Modem to access hugepage */
155 typedef struct ipc_priv_t {
160 mem_range_t modem_ccsrbar;
161 mem_range_t peb_start;
162 mem_range_t mhif_start;
163 mem_range_t hugepg_start;
164 ipc_channel_us_t *channels[IPC_MAX_CHANNEL_COUNT];
165 ipc_instance_t *instance;
166 ipc_instance_t *instance_bk;
169 /** Structure specifying enqueue operation (enqueue at LA1224) */
170 struct bbdev_ipc_enqueue_op {
171 /** Status of operation that was performed */
173 /** CRC Status of SD operation that was performed */
174 int32_t crc_stat_addr;
175 /** HARQ Output buffer memory length for Shared Decode.
179 /** Reserved (for 8 byte alignment) */
183 /* This shared memory would be on the host side which have copy of some
184 * of the parameters which are also part of Shared BD ring. Read access
185 * of these parameters from the host side would not be over PCI.
187 typedef struct host_ipc_params {
188 volatile uint32_t pi;
189 volatile uint32_t ci;
190 volatile uint32_t bd_m_modem_ptr[IPC_MAX_DEPTH];
191 } __rte_packed host_ipc_params_t;
193 struct hif_ipc_regs {
194 uint32_t ipc_mdata_offset;
195 uint32_t ipc_mdata_size;
202 volatile uint32_t host_ready;
203 volatile uint32_t mod_ready;
204 struct hif_ipc_regs ipc_regs;