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