1/* SPDX-License-Identifier: GPL-2.0 */
2
3/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2020 Linaro Ltd.
5 */
6#ifndef _IPA_QMI_MSG_H_
7#define _IPA_QMI_MSG_H_
8
9/* === Only "ipa_qmi" and "ipa_qmi_msg.c" should include this file === */
10
11#include <linux/types.h>
12#include <linux/soc/qcom/qmi.h>
13
14/* Request/response/indication QMI message ids used for IPA.  Receiving
15 * end issues a response for requests; indications require no response.
16 */
17#define IPA_QMI_INDICATION_REGISTER	0x20	/* modem -> AP request */
18#define IPA_QMI_INIT_DRIVER		0x21	/* AP -> modem request */
19#define IPA_QMI_INIT_COMPLETE		0x22	/* AP -> modem indication */
20#define IPA_QMI_DRIVER_INIT_COMPLETE	0x35	/* modem -> AP request */
21
22/* The maximum size required for message types.  These sizes include
23 * the message data, along with type (1 byte) and length (2 byte)
24 * information for each field.  The qmi_send_*() interfaces require
25 * the message size to be provided.
26 */
27#define IPA_QMI_INDICATION_REGISTER_REQ_SZ	12	/* -> server handle */
28#define IPA_QMI_INDICATION_REGISTER_RSP_SZ	7	/* <- server handle */
29#define IPA_QMI_INIT_DRIVER_REQ_SZ		162	/* client handle -> */
30#define IPA_QMI_INIT_DRIVER_RSP_SZ		25	/* client handle <- */
31#define IPA_QMI_INIT_COMPLETE_IND_SZ		7	/* <- server handle */
32#define IPA_QMI_DRIVER_INIT_COMPLETE_REQ_SZ	4	/* -> server handle */
33#define IPA_QMI_DRIVER_INIT_COMPLETE_RSP_SZ	7	/* <- server handle */
34
35/* Maximum size of messages we expect the AP to receive (max of above) */
36#define IPA_QMI_SERVER_MAX_RCV_SZ		8
37#define IPA_QMI_CLIENT_MAX_RCV_SZ		25
38
39/* Request message for the IPA_QMI_INDICATION_REGISTER request */
40struct ipa_indication_register_req {
41	u8 master_driver_init_complete_valid;
42	u8 master_driver_init_complete;
43	u8 data_usage_quota_reached_valid;
44	u8 data_usage_quota_reached;
45	u8 ipa_mhi_ready_ind_valid;
46	u8 ipa_mhi_ready_ind;
47};
48
49/* The response to a IPA_QMI_INDICATION_REGISTER request consists only of
50 * a standard QMI response.
51 */
52struct ipa_indication_register_rsp {
53	struct qmi_response_type_v01 rsp;
54};
55
56/* Request message for the IPA_QMI_DRIVER_INIT_COMPLETE request */
57struct ipa_driver_init_complete_req {
58	u8 status;
59};
60
61/* The response to a IPA_QMI_DRIVER_INIT_COMPLETE request consists only
62 * of a standard QMI response.
63 */
64struct ipa_driver_init_complete_rsp {
65	struct qmi_response_type_v01 rsp;
66};
67
68/* The message for the IPA_QMI_INIT_COMPLETE_IND indication consists
69 * only of a standard QMI response.
70 */
71struct ipa_init_complete_ind {
72	struct qmi_response_type_v01 status;
73};
74
75/* The AP tells the modem its platform type.  We assume Android. */
76enum ipa_platform_type {
77	IPA_QMI_PLATFORM_TYPE_INVALID		= 0,	/* Invalid */
78	IPA_QMI_PLATFORM_TYPE_TN		= 1,	/* Data card */
79	IPA_QMI_PLATFORM_TYPE_LE		= 2,	/* Data router */
80	IPA_QMI_PLATFORM_TYPE_MSM_ANDROID	= 3,	/* Android MSM */
81	IPA_QMI_PLATFORM_TYPE_MSM_WINDOWS	= 4,	/* Windows MSM */
82	IPA_QMI_PLATFORM_TYPE_MSM_QNX_V01	= 5,	/* QNX MSM */
83};
84
85/* This defines the start and end offset of a range of memory.  The start
86 * value is a byte offset relative to the start of IPA shared memory.  The
87 * end value is the last addressable unit *within* the range.  Typically
88 * the end value is in units of bytes, however it can also be a maximum
89 * array index value.
90 */
91struct ipa_mem_bounds {
92	u32 start;
93	u32 end;
94};
95
96/* This defines the location and size of an array.  The start value
97 * is an offset relative to the start of IPA shared memory.  The
98 * size of the array is implied by the number of entries (the entry
99 * size is assumed to be known).
100 */
101struct ipa_mem_array {
102	u32 start;
103	u32 count;
104};
105
106/* This defines the location and size of a range of memory.  The
107 * start is an offset relative to the start of IPA shared memory.
108 * This differs from the ipa_mem_bounds structure in that the size
109 * (in bytes) of the memory region is specified rather than the
110 * offset of its last byte.
111 */
112struct ipa_mem_range {
113	u32 start;
114	u32 size;
115};
116
117/* The message for the IPA_QMI_INIT_DRIVER request contains information
118 * from the AP that affects modem initialization.
119 */
120struct ipa_init_modem_driver_req {
121	u8			platform_type_valid;
122	u32			platform_type;	/* enum ipa_platform_type */
123
124	/* Modem header table information.  This defines the IPA shared
125	 * memory in which the modem may insert header table entries.
126	 */
127	u8			hdr_tbl_info_valid;
128	struct ipa_mem_bounds	hdr_tbl_info;
129
130	/* Routing table information.  These define the location and maximum
131	 * *index* (not byte) for the modem portion of non-hashable IPv4 and
132	 * IPv6 routing tables.  The start values are byte offsets relative
133	 * to the start of IPA shared memory.
134	 */
135	u8			v4_route_tbl_info_valid;
136	struct ipa_mem_bounds	v4_route_tbl_info;
137	u8			v6_route_tbl_info_valid;
138	struct ipa_mem_bounds	v6_route_tbl_info;
139
140	/* Filter table information.  These define the location of the
141	 * non-hashable IPv4 and IPv6 filter tables.  The start values are
142	 * byte offsets relative to the start of IPA shared memory.
143	 */
144	u8			v4_filter_tbl_start_valid;
145	u32			v4_filter_tbl_start;
146	u8			v6_filter_tbl_start_valid;
147	u32			v6_filter_tbl_start;
148
149	/* Modem memory information.  This defines the location and
150	 * size of memory available for the modem to use.
151	 */
152	u8			modem_mem_info_valid;
153	struct ipa_mem_range	modem_mem_info;
154
155	/* This defines the destination endpoint on the AP to which
156	 * the modem driver can send control commands.  Must be less
157	 * than ipa_endpoint_max().
158	 */
159	u8			ctrl_comm_dest_end_pt_valid;
160	u32			ctrl_comm_dest_end_pt;
161
162	/* This defines whether the modem should load the microcontroller
163	 * or not.  It is unnecessary to reload it if the modem is being
164	 * restarted.
165	 *
166	 * NOTE: this field is named "is_ssr_bootup" elsewhere.
167	 */
168	u8			skip_uc_load_valid;
169	u8			skip_uc_load;
170
171	/* Processing context memory information.  This defines the memory in
172	 * which the modem may insert header processing context table entries.
173	 */
174	u8			hdr_proc_ctx_tbl_info_valid;
175	struct ipa_mem_bounds	hdr_proc_ctx_tbl_info;
176
177	/* Compression command memory information.  This defines the memory
178	 * in which the modem may insert compression/decompression commands.
179	 */
180	u8			zip_tbl_info_valid;
181	struct ipa_mem_bounds	zip_tbl_info;
182
183	/* Routing table information.  These define the location and maximum
184	 * *index* (not byte) for the modem portion of hashable IPv4 and IPv6
185	 * routing tables (if supported by hardware).  The start values are
186	 * byte offsets relative to the start of IPA shared memory.
187	 */
188	u8			v4_hash_route_tbl_info_valid;
189	struct ipa_mem_bounds	v4_hash_route_tbl_info;
190	u8			v6_hash_route_tbl_info_valid;
191	struct ipa_mem_bounds	v6_hash_route_tbl_info;
192
193	/* Filter table information.  These define the location and size
194	 * of hashable IPv4 and IPv6 filter tables (if supported by hardware).
195	 * The start values are byte offsets relative to the start of IPA
196	 * shared memory.
197	 */
198	u8			v4_hash_filter_tbl_start_valid;
199	u32			v4_hash_filter_tbl_start;
200	u8			v6_hash_filter_tbl_start_valid;
201	u32			v6_hash_filter_tbl_start;
202
203	/* Statistics information.  These define the locations of the
204	 * first and last statistics sub-regions.  (IPA v4.0 and above)
205	 */
206	u8			hw_stats_quota_base_addr_valid;
207	u32			hw_stats_quota_base_addr;
208	u8			hw_stats_quota_size_valid;
209	u32			hw_stats_quota_size;
210	u8			hw_stats_drop_base_addr_valid;
211	u32			hw_stats_drop_base_addr;
212	u8			hw_stats_drop_size_valid;
213	u32			hw_stats_drop_size;
214};
215
216/* The response to a IPA_QMI_INIT_DRIVER request begins with a standard
217 * QMI response, but contains other information as well.  Currently we
218 * simply wait for the the INIT_DRIVER transaction to complete and
219 * ignore any other data that might be returned.
220 */
221struct ipa_init_modem_driver_rsp {
222	struct qmi_response_type_v01	rsp;
223
224	/* This defines the destination endpoint on the modem to which
225	 * the AP driver can send control commands.  Must be less than
226	 * ipa_endpoint_max().
227	 */
228	u8				ctrl_comm_dest_end_pt_valid;
229	u32				ctrl_comm_dest_end_pt;
230
231	/* This defines the default endpoint.  The AP driver is not
232	 * required to configure the hardware with this value.  Must
233	 * be less than ipa_endpoint_max().
234	 */
235	u8				default_end_pt_valid;
236	u32				default_end_pt;
237
238	/* This defines whether a second handshake is required to complete
239	 * initialization.
240	 */
241	u8				modem_driver_init_pending_valid;
242	u8				modem_driver_init_pending;
243};
244
245/* Message structure definitions defined in "ipa_qmi_msg.c" */
246extern struct qmi_elem_info ipa_indication_register_req_ei[];
247extern struct qmi_elem_info ipa_indication_register_rsp_ei[];
248extern struct qmi_elem_info ipa_driver_init_complete_req_ei[];
249extern struct qmi_elem_info ipa_driver_init_complete_rsp_ei[];
250extern struct qmi_elem_info ipa_init_complete_ind_ei[];
251extern struct qmi_elem_info ipa_mem_bounds_ei[];
252extern struct qmi_elem_info ipa_mem_array_ei[];
253extern struct qmi_elem_info ipa_mem_range_ei[];
254extern struct qmi_elem_info ipa_init_modem_driver_req_ei[];
255extern struct qmi_elem_info ipa_init_modem_driver_rsp_ei[];
256
257#endif /* !_IPA_QMI_MSG_H_ */
258