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