1 /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 2 * 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License version 2 and 5 * only version 2 as published by the Free Software Foundation. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 */ 12 13 #ifndef _RMNET_IPA_FD_IOCTL_H 14 #define _RMNET_IPA_FD_IOCTL_H 15 16 #include <linux/ioctl.h> 17 #include <linux/ipa_qmi_service_v01.h> 18 #include <linux/msm_ipa.h> 19 20 /** 21 * unique magic number of the IPA_WAN device 22 */ 23 #define WAN_IOC_MAGIC 0x69 24 25 #define WAN_IOCTL_ADD_FLT_RULE 0 26 #define WAN_IOCTL_ADD_FLT_INDEX 1 27 #define WAN_IOCTL_VOTE_FOR_BW_MBPS 2 28 #define WAN_IOCTL_POLL_TETHERING_STATS 3 29 #define WAN_IOCTL_SET_DATA_QUOTA 4 30 #define WAN_IOCTL_SET_TETHER_CLIENT_PIPE 5 31 #define WAN_IOCTL_QUERY_TETHER_STATS 6 32 #define WAN_IOCTL_RESET_TETHER_STATS 7 33 #define WAN_IOCTL_QUERY_DL_FILTER_STATS 8 34 #define WAN_IOCTL_ADD_FLT_RULE_EX 9 35 #define WAN_IOCTL_QUERY_TETHER_STATS_ALL 10 36 #define WAN_IOCTL_NOTIFY_WAN_STATE 11 37 #define WAN_IOCTL_ADD_UL_FLT_RULE 12 38 #define WAN_IOCTL_ENABLE_PER_CLIENT_STATS 13 39 #define WAN_IOCTL_QUERY_PER_CLIENT_STATS 14 40 #define WAN_IOCTL_SET_LAN_CLIENT_INFO 15 41 #define WAN_IOCTL_CLEAR_LAN_CLIENT_INFO 16 42 #define WAN_IOCTL_SEND_LAN_CLIENT_MSG 17 43 44 /* User space may not have this defined. */ 45 #ifndef IFNAMSIZ 46 #define IFNAMSIZ 16 47 #endif 48 49 /** 50 * struct wan_ioctl_poll_tethering_stats - structure used for 51 * WAN_IOCTL_POLL_TETHERING_STATS IOCTL. 52 * 53 * @polling_interval_secs: Polling interval in seconds. 54 * @reset_stats: Indicate whether to reset the stats (use 1) or not. 55 * 56 * The structure to be used by the user space in order to request for the 57 * tethering stats to be polled. Setting the interval to 0 indicates to stop 58 * the polling process. 59 */ 60 struct wan_ioctl_poll_tethering_stats { 61 uint64_t polling_interval_secs; 62 uint8_t reset_stats; 63 }; 64 65 /** 66 * struct wan_ioctl_set_data_quota - structure used for 67 * WAN_IOCTL_SET_DATA_QUOTA IOCTL. 68 * 69 * @interface_name: Name of the interface on which to set the quota. 70 * @quota_mbytes: Quota (in Mbytes) for the above interface. 71 * @set_quota: Indicate whether to set the quota (use 1) or 72 * unset the quota. 73 * 74 * The structure to be used by the user space in order to request 75 * a quota to be set on a specific interface (by specifying its name). 76 */ 77 struct wan_ioctl_set_data_quota { 78 char interface_name[IFNAMSIZ]; 79 uint64_t quota_mbytes; 80 uint8_t set_quota; 81 }; 82 83 struct wan_ioctl_set_tether_client_pipe { 84 /* enum of tether interface */ 85 enum ipacm_client_enum ipa_client; 86 uint8_t reset_client; 87 uint32_t ul_src_pipe_len; 88 uint32_t ul_src_pipe_list[QMI_IPA_MAX_PIPES_V01]; 89 uint32_t dl_dst_pipe_len; 90 uint32_t dl_dst_pipe_list[QMI_IPA_MAX_PIPES_V01]; 91 }; 92 93 struct wan_ioctl_query_tether_stats { 94 /* Name of the upstream interface */ 95 char upstreamIface[IFNAMSIZ]; 96 /* Name of the tethered interface */ 97 char tetherIface[IFNAMSIZ]; 98 /* enum of tether interface */ 99 enum ipacm_client_enum ipa_client; 100 uint64_t ipv4_tx_packets; 101 uint64_t ipv4_tx_bytes; 102 uint64_t ipv4_rx_packets; 103 uint64_t ipv4_rx_bytes; 104 uint64_t ipv6_tx_packets; 105 uint64_t ipv6_tx_bytes; 106 uint64_t ipv6_rx_packets; 107 uint64_t ipv6_rx_bytes; 108 }; 109 110 struct wan_ioctl_query_tether_stats_all { 111 /* Name of the upstream interface */ 112 char upstreamIface[IFNAMSIZ]; 113 /* enum of tether interface */ 114 enum ipacm_client_enum ipa_client; 115 uint8_t reset_stats; 116 uint64_t tx_bytes; 117 uint64_t rx_bytes; 118 }; 119 120 struct wan_ioctl_reset_tether_stats { 121 /* Name of the upstream interface, not support now */ 122 char upstreamIface[IFNAMSIZ]; 123 /* Indicate whether to reset the stats (use 1) or not */ 124 uint8_t reset_stats; 125 }; 126 127 struct wan_ioctl_query_dl_filter_stats { 128 /* Indicate whether to reset the filter stats (use 1) or not*/ 129 uint8_t reset_stats; 130 /* Modem response QMI */ 131 struct ipa_get_data_stats_resp_msg_v01 stats_resp; 132 /* provide right index to 1st firewall rule */ 133 uint32_t index; 134 }; 135 136 struct wan_ioctl_notify_wan_state { 137 uint8_t up; 138 }; 139 struct wan_ioctl_send_lan_client_msg { 140 /* Lan client info. */ 141 struct ipa_lan_client_msg lan_client; 142 /* Event to indicate whether client is 143 * connected or disconnected. 144 */ 145 enum ipa_per_client_stats_event client_event; 146 }; 147 148 struct wan_ioctl_lan_client_info { 149 /* Device type of the client. */ 150 enum ipacm_per_client_device_type device_type; 151 /* MAC Address of the client. */ 152 uint8_t mac[IPA_MAC_ADDR_SIZE]; 153 /* Init client. */ 154 uint8_t client_init; 155 /* Client Index */ 156 int8_t client_idx; 157 /* Header length of the client. */ 158 uint8_t hdr_len; 159 /* Source pipe of the lan client. */ 160 enum ipa_client_type ul_src_pipe; 161 }; 162 163 struct wan_ioctl_per_client_info { 164 /* MAC Address of the client. */ 165 uint8_t mac[IPA_MAC_ADDR_SIZE]; 166 /* Ipv4 UL traffic bytes. */ 167 uint64_t ipv4_tx_bytes; 168 /* Ipv4 DL traffic bytes. */ 169 uint64_t ipv4_rx_bytes; 170 /* Ipv6 UL traffic bytes. */ 171 uint64_t ipv6_tx_bytes; 172 /* Ipv6 DL traffic bytes. */ 173 uint64_t ipv6_rx_bytes; 174 }; 175 176 struct wan_ioctl_query_per_client_stats { 177 /* Device type of the client. */ 178 enum ipacm_per_client_device_type device_type; 179 /* Indicate whether to reset the stats (use 1) or not */ 180 uint8_t reset_stats; 181 /* Indicates whether client is disconnected. */ 182 uint8_t disconnect_clnt; 183 /* Number of clients. */ 184 uint8_t num_clients; 185 /* Client information. */ 186 struct wan_ioctl_per_client_info 187 client_info[IPA_MAX_NUM_HW_PATH_CLIENTS]; 188 }; 189 190 #define WAN_IOC_ADD_FLT_RULE _IOWR(WAN_IOC_MAGIC, \ 191 WAN_IOCTL_ADD_FLT_RULE, \ 192 struct ipa_install_fltr_rule_req_msg_v01 *) 193 194 #define WAN_IOC_ADD_FLT_RULE_INDEX _IOWR(WAN_IOC_MAGIC, \ 195 WAN_IOCTL_ADD_FLT_INDEX, \ 196 struct ipa_fltr_installed_notif_req_msg_v01 *) 197 198 #define WAN_IOC_VOTE_FOR_BW_MBPS _IOWR(WAN_IOC_MAGIC, \ 199 WAN_IOCTL_VOTE_FOR_BW_MBPS, \ 200 uint32_t *) 201 202 #define WAN_IOC_POLL_TETHERING_STATS _IOWR(WAN_IOC_MAGIC, \ 203 WAN_IOCTL_POLL_TETHERING_STATS, \ 204 struct wan_ioctl_poll_tethering_stats *) 205 206 #define WAN_IOC_SET_DATA_QUOTA _IOWR(WAN_IOC_MAGIC, \ 207 WAN_IOCTL_SET_DATA_QUOTA, \ 208 struct wan_ioctl_set_data_quota *) 209 210 #define WAN_IOC_SET_TETHER_CLIENT_PIPE _IOWR(WAN_IOC_MAGIC, \ 211 WAN_IOCTL_SET_TETHER_CLIENT_PIPE, \ 212 struct wan_ioctl_set_tether_client_pipe *) 213 214 #define WAN_IOC_QUERY_TETHER_STATS _IOWR(WAN_IOC_MAGIC, \ 215 WAN_IOCTL_QUERY_TETHER_STATS, \ 216 struct wan_ioctl_query_tether_stats *) 217 218 #define WAN_IOC_RESET_TETHER_STATS _IOWR(WAN_IOC_MAGIC, \ 219 WAN_IOCTL_RESET_TETHER_STATS, \ 220 struct wan_ioctl_reset_tether_stats *) 221 222 #define WAN_IOC_QUERY_DL_FILTER_STATS _IOWR(WAN_IOC_MAGIC, \ 223 WAN_IOCTL_QUERY_DL_FILTER_STATS, \ 224 struct wan_ioctl_query_dl_filter_stats *) 225 226 #define WAN_IOC_ADD_FLT_RULE_EX _IOWR(WAN_IOC_MAGIC, \ 227 WAN_IOCTL_ADD_FLT_RULE_EX, \ 228 struct ipa_install_fltr_rule_req_ex_msg_v01 *) 229 230 #define WAN_IOC_QUERY_TETHER_STATS_ALL _IOWR(WAN_IOC_MAGIC, \ 231 WAN_IOCTL_QUERY_TETHER_STATS_ALL, \ 232 struct wan_ioctl_query_tether_stats_all *) 233 234 #define WAN_IOC_NOTIFY_WAN_STATE _IOWR(WAN_IOC_MAGIC, \ 235 WAN_IOCTL_NOTIFY_WAN_STATE, \ 236 struct wan_ioctl_notify_wan_state *) 237 238 #define WAN_IOC_ADD_UL_FLT_RULE _IOWR(WAN_IOC_MAGIC, \ 239 WAN_IOCTL_ADD_UL_FLT_RULE, \ 240 struct ipa_configure_ul_firewall_rules_req_msg_v01 *) 241 242 #define WAN_IOC_ENABLE_PER_CLIENT_STATS _IOWR(WAN_IOC_MAGIC, \ 243 WAN_IOCTL_ENABLE_PER_CLIENT_STATS, \ 244 bool *) 245 246 #define WAN_IOC_QUERY_PER_CLIENT_STATS _IOWR(WAN_IOC_MAGIC, \ 247 WAN_IOCTL_QUERY_PER_CLIENT_STATS, \ 248 struct wan_ioctl_query_per_client_stats *) 249 250 #define WAN_IOC_SET_LAN_CLIENT_INFO _IOWR(WAN_IOC_MAGIC, \ 251 WAN_IOCTL_SET_LAN_CLIENT_INFO, \ 252 struct wan_ioctl_lan_client_info *) 253 254 #define WAN_IOC_SEND_LAN_CLIENT_MSG _IOWR(WAN_IOC_MAGIC, \ 255 WAN_IOCTL_SEND_LAN_CLIENT_MSG, \ 256 struct wan_ioctl_send_lan_client_msg *) 257 258 #define WAN_IOC_CLEAR_LAN_CLIENT_INFO _IOWR(WAN_IOC_MAGIC, \ 259 WAN_IOCTL_CLEAR_LAN_CLIENT_INFO, \ 260 struct wan_ioctl_lan_client_info *) 261 #endif /* _RMNET_IPA_FD_IOCTL_H */ 262