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