[RAMEN9610-20413][9610] wlbt: SCSC Driver version 10.6.1.0
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / drivers / net / wireless / scsc / hip4_sampler.h
1 /****************************************************************************
2 *
3 * Copyright (c) 2014 - 2018 Samsung Electronics Co., Ltd. All rights reserved
4 *
5 ****************************************************************************/
6
7 #include <linux/proc_fs.h>
8 #include <linux/version.h>
9 #include <linux/seq_file.h>
10 #include <net/tcp.h>
11
12 #include "dev.h"
13
14 /* TCP send buffer sizes */
15 extern int sysctl_tcp_wmem[3];
16
17 #ifndef __HIP4_SAMPLER_H__
18 #define __HIP4_SAMPLER_H__
19
20 #define HIP4_SAMPLER_SIGNAL_CTRLTX 0x20
21 #define HIP4_SAMPLER_SIGNAL_CTRLRX 0x21
22 #define HIP4_SAMPLER_THROUG 0x22
23 #define HIP4_SAMPLER_THROUG_K 0x23
24 #define HIP4_SAMPLER_THROUG_M 0x24
25 #define HIP4_SAMPLER_STOP_Q 0x25
26 #define HIP4_SAMPLER_START_Q 0x26
27 #define HIP4_SAMPLER_QREF 0x27
28 #define HIP4_SAMPLER_PEER 0x29
29 #define HIP4_SAMPLER_BOT_RX 0x2a
30 #define HIP4_SAMPLER_BOT_TX 0x2b
31 #define HIP4_SAMPLER_BOT_ADD 0x2c
32 #define HIP4_SAMPLER_BOT_REMOVE 0x2d
33 #define HIP4_SAMPLER_BOT_STOP_Q 0x2e
34 #define HIP4_SAMPLER_BOT_START_Q 0x2f
35 #define HIP4_SAMPLER_BOT_QMOD_RX 0x30
36 #define HIP4_SAMPLER_BOT_QMOD_TX 0x31
37 #define HIP4_SAMPLER_BOT_QMOD_STOP 0x32
38 #define HIP4_SAMPLER_BOT_QMOD_START 0x33
39 #define HIP4_SAMPLER_PKT_TX 0x40
40 #define HIP4_SAMPLER_PKT_TX_HIP4 0x41
41 #define HIP4_SAMPLER_PKT_TX_FB 0x42
42 #define HIP4_SAMPLER_SUSPEND 0x50
43 #define HIP4_SAMPLER_RESUME 0x51
44
45 #define HIP4_SAMPLER_TCP_SYN 0x60
46 #define HIP4_SAMPLER_TCP_FIN 0x61
47 #define HIP4_SAMPLER_TCP_DATA 0x62
48 #define HIP4_SAMPLER_TCP_ACK 0x63
49 #define HIP4_SAMPLER_TCP_RWND 0x64
50 #define HIP4_SAMPLER_TCP_CWND 0x65
51 #define HIP4_SAMPLER_TCP_SEND_BUF 0x66
52 #define HIP4_SAMPLER_TCP_DATA_IN 0x67
53 #define HIP4_SAMPLER_TCP_ACK_IN 0x68
54
55 #define HIP4_SAMPLER_MBULK 0xaa
56 #define HIP4_SAMPLER_QFULL 0xbb
57 #define HIP4_SAMPLER_MFULL 0xcc
58 #define HIP4_SAMPLER_INT 0xdd
59 #define HIP4_SAMPLER_INT_OUT 0xee
60 #define HIP4_SAMPLER_INT_BH 0xde
61 #define HIP4_SAMPLER_INT_OUT_BH 0xef
62 #define HIP4_SAMPLER_RESET 0xff
63
64 #define SCSC_HIP4_INTERFACES 1
65
66 #define SCSC_HIP4_STREAM_CH 1
67 #define SCSC_HIP4_OFFLINE_CH SCSC_HIP4_STREAM_CH
68
69 #if (SCSC_HIP4_OFFLINE_CH != SCSC_HIP4_STREAM_CH)
70 #error "SCSC_HIP4_STREAM_CH has to be equal to SCSC_HIP4_OFFLINE_CH"
71 #endif
72
73 #define SCSC_HIP4_DEBUG_INTERFACES ((SCSC_HIP4_INTERFACES) * (SCSC_HIP4_STREAM_CH + SCSC_HIP4_OFFLINE_CH))
74
75 struct scsc_mx;
76
77 void hip4_sampler_create(struct slsi_dev *sdev, struct scsc_mx *mx);
78 void hip4_sampler_destroy(struct slsi_dev *sdev, struct scsc_mx *mx);
79
80 /* Register hip4 instance with the logger */
81 /* return char device minor associated with the maxwell instance*/
82 int hip4_sampler_register_hip(struct scsc_mx *mx);
83
84 void hip4_sampler_update_record(u32 minor, u8 param1, u8 param2, u8 param3, u8 param4, u32 param5);
85 void hip4_sampler_tcp_decode(struct slsi_dev *sdev, struct net_device *dev, u8 *frame, bool from_ba);
86
87 extern bool hip4_sampler_sample_q;
88 extern bool hip4_sampler_sample_qref;
89 extern bool hip4_sampler_sample_int;
90 extern bool hip4_sampler_sample_fapi;
91 extern bool hip4_sampler_sample_through;
92 extern bool hip4_sampler_sample_tcp;
93 extern bool hip4_sampler_sample_start_stop_q;
94 extern bool hip4_sampler_sample_mbulk;
95 extern bool hip4_sampler_sample_qfull;
96 extern bool hip4_sampler_sample_mfull;
97 extern bool hip4_sampler_vif;
98 extern bool hip4_sampler_bot;
99 extern bool hip4_sampler_pkt_tx;
100 extern bool hip4_sampler_suspend_resume;
101
102 #ifdef CONFIG_SCSC_WLAN_HIP4_PROFILING
103 #define SCSC_HIP4_SAMPLER_Q(minor, q, idx_rw, value, rw) \
104 do { \
105 if (hip4_sampler_sample_q) { \
106 hip4_sampler_update_record(minor, q, idx_rw, value, rw, 0); \
107 } \
108 } while (0)
109 #define SCSC_HIP4_SAMPLER_QREF(minor, ref, q) \
110 do { \
111 if (hip4_sampler_sample_qref) { \
112 hip4_sampler_update_record(minor, HIP4_SAMPLER_QREF, (ref & 0xff0000) >> 16, (ref & 0xff00) >> 8, (ref & 0xf0) | q, 0); \
113 } \
114 } while (0)
115 #define SCSC_HIP4_SAMPLER_SIGNAL_CTRLTX(minor, bytes16_h, bytes16_l) \
116 do { \
117 if (hip4_sampler_sample_fapi) { \
118 hip4_sampler_update_record(minor, HIP4_SAMPLER_SIGNAL_CTRLTX, 0, bytes16_h, bytes16_l, 0); \
119 } \
120 } while (0)
121 #define SCSC_HIP4_SAMPLER_SIGNAL_CTRLRX(minor, bytes16_h, bytes16_l) \
122 do { \
123 if (hip4_sampler_sample_fapi) { \
124 hip4_sampler_update_record(minor, HIP4_SAMPLER_SIGNAL_CTRLRX, 0, bytes16_h, bytes16_l, 0); \
125 } \
126 } while (0)
127
128 #define SCSC_HIP4_SAMPLER_TCP_DECODE(sdev, dev, frame, from_ba) \
129 do { \
130 if (hip4_sampler_sample_tcp) { \
131 hip4_sampler_tcp_decode(sdev, dev, frame, from_ba); \
132 } \
133 } while (0)
134 #define SCSC_HIP4_SAMPLER_THROUG(minor, rx_tx, bytes16_h, bytes16_l) \
135 do { \
136 if (hip4_sampler_sample_through) { \
137 hip4_sampler_update_record(minor, HIP4_SAMPLER_THROUG, rx_tx, bytes16_h, bytes16_l, 0); \
138 } \
139 } while (0)
140 #define SCSC_HIP4_SAMPLER_THROUG_K(minor, rx_tx, bytes16_h, bytes16_l) \
141 do { \
142 if (hip4_sampler_sample_through) { \
143 hip4_sampler_update_record(minor, HIP4_SAMPLER_THROUG_K, rx_tx, bytes16_h, bytes16_l, 0); \
144 } \
145 } while (0)
146 #define SCSC_HIP4_SAMPLER_THROUG_M(minor, rx_tx, bytes16_h, bytes16_l) \
147 do { \
148 if (hip4_sampler_sample_through) { \
149 hip4_sampler_update_record(minor, HIP4_SAMPLER_THROUG_M, rx_tx, bytes16_h, bytes16_l, 0); \
150 } \
151 } while (0)
152 #define SCSC_HIP4_SAMPLER_STOP_Q(minor, vif_id) \
153 do { \
154 if (hip4_sampler_sample_start_stop_q) { \
155 hip4_sampler_update_record(minor, HIP4_SAMPLER_STOP_Q, 0, 0, vif_id, 0); \
156 } \
157 } while (0)
158 #define SCSC_HIP4_SAMPLER_START_Q(minor, vif_id) \
159 do { \
160 if (hip4_sampler_sample_start_stop_q) { \
161 hip4_sampler_update_record(minor, HIP4_SAMPLER_START_Q, 0, 0, vif_id, 0); \
162 } \
163 } while (0)
164 #define SCSC_HIP4_SAMPLER_MBULK(minor, bytes16_h, bytes16_l, clas) \
165 do { \
166 if (hip4_sampler_sample_mbulk) { \
167 hip4_sampler_update_record(minor, HIP4_SAMPLER_MBULK, clas, bytes16_h, bytes16_l, 0); \
168 } \
169 } while (0)
170 #define SCSC_HIP4_SAMPLER_QFULL(minor, q) \
171 do { \
172 if (hip4_sampler_sample_qfull) { \
173 hip4_sampler_update_record(minor, HIP4_SAMPLER_QFULL, 0, 0, q, 0); \
174 } \
175 } while (0)
176 #define SCSC_HIP4_SAMPLER_MFULL(minor) \
177 do { \
178 if (hip4_sampler_sample_mfull) { \
179 hip4_sampler_update_record(minor, HIP4_SAMPLER_MFULL, 0, 0, 0, 0); \
180 } \
181 } while (0)
182 #define SCSC_HIP4_SAMPLER_INT(minor, id) \
183 do { \
184 if (hip4_sampler_sample_int) { \
185 hip4_sampler_update_record(minor, HIP4_SAMPLER_INT, 0, 0, id, 0); \
186 } \
187 } while (0)
188 #define SCSC_HIP4_SAMPLER_INT_OUT(minor, id) \
189 do { \
190 if (hip4_sampler_sample_int) { \
191 hip4_sampler_update_record(minor, HIP4_SAMPLER_INT_OUT, 0, 0, id, 0); \
192 } \
193 } while (0)
194 #define SCSC_HIP4_SAMPLER_INT_BH(minor, id) \
195 do { \
196 if (hip4_sampler_sample_int) { \
197 hip4_sampler_update_record(minor, HIP4_SAMPLER_INT_BH, 0, 0, id, 0); \
198 } \
199 } while (0)
200 #define SCSC_HIP4_SAMPLER_INT_OUT_BH(minor, id) \
201 do { \
202 if (hip4_sampler_sample_int) { \
203 hip4_sampler_update_record(minor, HIP4_SAMPLER_INT_OUT_BH, 0, 0, id, 0); \
204 } \
205 } while (0)
206 #define SCSC_HIP4_SAMPLER_RESET(minor) \
207 hip4_sampler_update_record(minor, HIP4_SAMPLER_RESET, 0, 0, 0, 0)
208
209 #define SCSC_HIP4_SAMPLER_VIF_PEER(minor, tx, vif, peer_index) \
210 do { \
211 if (hip4_sampler_vif) { \
212 hip4_sampler_update_record(minor, HIP4_SAMPLER_PEER, tx, vif, peer_index, 0); \
213 } \
214 } while (0)
215
216 #define SCSC_HIP4_SAMPLER_BOT_RX(minor, scod, smod, vif_peer) \
217 do { \
218 if (hip4_sampler_bot) { \
219 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_RX, scod, smod, vif_peer, 0); \
220 } \
221 } while (0)
222
223 #define SCSC_HIP4_SAMPLER_BOT_TX(minor, scod, smod, vif_peer) \
224 do { \
225 if (hip4_sampler_bot) { \
226 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_TX, scod, smod, vif_peer, 0); \
227 } \
228 } while (0)
229 #define SCSC_HIP4_SAMPLER_BOT_ADD(minor, addr_1, addr_2, vif_peer) \
230 do { \
231 if (hip4_sampler_bot) { \
232 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_ADD, addr_1, addr_2, vif_peer, 0); \
233 } \
234 } while (0)
235
236 #define SCSC_HIP4_SAMPLER_BOT_REMOVE(minor, addr_1, addr_2, vif_peer) \
237 do { \
238 if (hip4_sampler_bot) { \
239 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_REMOVE, addr_1, addr_2, vif_peer, 0); \
240 } \
241 } while (0)
242
243 #define SCSC_HIP4_SAMPLER_BOT_START_Q(minor, vif_peer) \
244 do { \
245 if (hip4_sampler_bot) { \
246 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_START_Q, 0, 0, vif_peer, 0); \
247 } \
248 } while (0)
249
250 #define SCSC_HIP4_SAMPLER_BOT_STOP_Q(minor, vif_peer) \
251 do { \
252 if (hip4_sampler_bot) { \
253 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_STOP_Q, 0, 0, vif_peer, 0); \
254 } \
255 } while (0)
256 #define SCSC_HIP4_SAMPLER_BOT_QMOD_RX(minor, qcod, qmod, vif_peer) \
257 do { \
258 if (hip4_sampler_bot) { \
259 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_QMOD_RX, qcod, qmod, vif_peer, 0); \
260 } \
261 } while (0)
262
263 #define SCSC_HIP4_SAMPLER_BOT_QMOD_TX(minor, qcod, qmod, vif_peer) \
264 do { \
265 if (hip4_sampler_bot) { \
266 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_QMOD_TX, qcod, qmod, vif_peer, 0); \
267 } \
268 } while (0)
269 #define SCSC_HIP4_SAMPLER_BOT_QMOD_START(minor, vif_peer) \
270 do { \
271 if (hip4_sampler_sample_start_stop_q || hip4_sampler_bot) { \
272 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_QMOD_START, 0, 0, vif_peer, 0); \
273 } \
274 } while (0)
275
276 #define SCSC_HIP4_SAMPLER_BOT_QMOD_STOP(minor, vif_peer) \
277 do { \
278 if (hip4_sampler_sample_start_stop_q || hip4_sampler_bot) { \
279 hip4_sampler_update_record(minor, HIP4_SAMPLER_BOT_QMOD_STOP, 0, 0, vif_peer, 0); \
280 } \
281 } while (0)
282 #define SCSC_HIP4_SAMPLER_PKT_TX(minor, host_tag) \
283 do { \
284 if (hip4_sampler_pkt_tx) { \
285 hip4_sampler_update_record(minor, HIP4_SAMPLER_PKT_TX, 0, (host_tag >> 8) & 0xff, host_tag & 0xff, 0); \
286 } \
287 } while (0)
288 #define SCSC_HIP4_SAMPLER_PKT_TX_HIP4(minor, host_tag) \
289 do { \
290 if (hip4_sampler_pkt_tx) { \
291 hip4_sampler_update_record(minor, HIP4_SAMPLER_PKT_TX_HIP4, 0, (host_tag >> 8) & 0xff, host_tag & 0xff, 0); \
292 } \
293 } while (0)
294 #define SCSC_HIP4_SAMPLER_PKT_TX_FB(minor, host_tag) \
295 do { \
296 if (hip4_sampler_pkt_tx) { \
297 hip4_sampler_update_record(minor, HIP4_SAMPLER_PKT_TX_FB, 0, (host_tag >> 8) & 0xff, host_tag & 0xff, 0); \
298 } \
299 } while (0)
300 #define SCSC_HIP4_SAMPLER_SUSPEND(minor) \
301 do { \
302 if (hip4_sampler_suspend_resume) { \
303 hip4_sampler_update_record(minor, HIP4_SAMPLER_SUSPEND, 0, 0, 0, 0); \
304 } \
305 } while (0)
306 #define SCSC_HIP4_SAMPLER_RESUME(minor) \
307 do { \
308 if (hip4_sampler_suspend_resume) { \
309 hip4_sampler_update_record(minor, HIP4_SAMPLER_RESUME, 0, 0, 0, 0); \
310 } \
311 } while (0)
312 #define SCSC_HIP4_SAMPLER_TCP_SYN(minor, id, mss) \
313 do { \
314 if (hip4_sampler_sample_tcp) { \
315 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_SYN, id, 0, 0, mss); \
316 } \
317 } while (0)
318 #define SCSC_HIP4_SAMPLER_TCP_FIN(minor, id) \
319 do { \
320 if (hip4_sampler_sample_tcp) { \
321 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_FIN, id, 0, 0, 0); \
322 } \
323 } while (0)
324 #define SCSC_HIP4_SAMPLER_TCP_DATA(minor, id, seq_num) \
325 do { \
326 if (hip4_sampler_sample_tcp) { \
327 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_DATA, id, 0, 0, seq_num); \
328 } \
329 } while (0)
330 #define SCSC_HIP4_SAMPLER_TCP_ACK(minor, id, ack_num) \
331 do { \
332 if (hip4_sampler_sample_tcp) { \
333 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_ACK, id, 0, 0, ack_num); \
334 } \
335 } while (0)
336 #define SCSC_HIP4_SAMPLER_TCP_DATA_IN(minor, id, seq_num) \
337 do { \
338 if (hip4_sampler_sample_tcp) { \
339 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_DATA_IN, id, 0, 0, seq_num); \
340 } \
341 } while (0)
342 #define SCSC_HIP4_SAMPLER_TCP_ACK_IN(minor, id, ack_num) \
343 do { \
344 if (hip4_sampler_sample_tcp) { \
345 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_ACK_IN, id, 0, 0, ack_num); \
346 } \
347 } while (0)
348 #define SCSC_HIP4_SAMPLER_TCP_RWND(minor, id, rwnd) \
349 do { \
350 if (hip4_sampler_sample_tcp) { \
351 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_RWND, id, 0, 0, rwnd); \
352 } \
353 } while (0)
354 #define SCSC_HIP4_SAMPLER_TCP_CWND(minor, id, cwnd) \
355 do { \
356 if (hip4_sampler_sample_tcp) { \
357 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_CWND, id, 0, 0, cwnd); \
358 } \
359 } while (0)
360 #define SCSC_HIP4_SAMPLER_TCP_SEND_BUF(minor, id, send_buff_size) \
361 do { \
362 if (hip4_sampler_sample_tcp) { \
363 hip4_sampler_update_record(minor, HIP4_SAMPLER_TCP_SEND_BUF, id, 0, 0, send_buff_size); \
364 } \
365 } while (0)
366 #else
367 #define SCSC_HIP4_SAMPLER_Q(minor, q, idx_rw, value, rw)
368 #define SCSC_HIP4_SAMPLER_QREF(minor, ref, q)
369 #define SCSC_HIP4_SAMPLER_SIGNAL_CTRLTX(minor, bytes16_h, bytes16_l)
370 #define SCSC_HIP4_SAMPLER_SIGNAL_CTRLRX(minor, bytes16_h, bytes16_l)
371 #define SCSC_HIP4_SAMPLER_TPUT(minor, rx_tx, payload)
372 #define SCSC_HIP4_SAMPLER_THROUG(minor, bytes16_h, bytes16_l)
373 #define SCSC_HIP4_SAMPLER_THROUG_K(minor, bytes16_h, bytes16_l)
374 #define SCSC_HIP4_SAMPLER_THROUG_M(minor, bytes16_h, bytes16_l)
375 #define SCSC_HIP4_SAMPLER_MBULK(minor, bytes16_h, bytes16_l, clas)
376 #define SCSC_HIP4_SAMPLER_QFULL(minor, q)
377 #define SCSC_HIP4_SAMPLER_MFULL(minor)
378 #define SCSC_HIP4_SAMPLER_INT(minor, id)
379 #define SCSC_HIP4_SAMPLER_INT_BH(minor, id)
380 #define SCSC_HIP4_SAMPLER_INT_OUT(minor, id)
381 #define SCSC_HIP4_SAMPLER_INT_OUT_BH(minor, id)
382 #define SCSC_HIP4_SAMPLER_RESET(minor)
383 #define SCSC_HIP4_SAMPLER_VIF_PEER(minor, tx, vif, peer_index)
384 #define SCSC_HIP4_SAMPLER_BOT_RX(minor, scod, smod, vif_peer)
385 #define SCSC_HIP4_SAMPLER_BOT_TX(minor, scod, smod, vif_peer)
386 #define SCSC_HIP4_SAMPLER_BOT(minor, init, addr_1, addr_2, vif_peer)
387 #define SCSC_HIP4_SAMPLER_BOT_ADD(minor, addr_1, addr_2, vif_peer)
388 #define SCSC_HIP4_SAMPLER_BOT_REMOVE(minor, addr_1, addr_2, vif_peer)
389 #define SCSC_HIP4_SAMPLER_BOT_START_Q(minor, vif_peer)
390 #define SCSC_HIP4_SAMPLER_BOT_STOP_Q(minor, vif_peer)
391 #define SCSC_HIP4_SAMPLER_BOT_QMOD_RX(minor, qcod, qmod, vif_peer)
392 #define SCSC_HIP4_SAMPLER_BOT_QMOD_TX(minor, qcod, qmod, vif_peer)
393 #define SCSC_HIP4_SAMPLER_BOT_QMOD_START(minor, vif_peer)
394 #define SCSC_HIP4_SAMPLER_BOT_QMOD_STOP(minor, vif_peer)
395 #define SCSC_HIP4_SAMPLER_PKT_TX(minor, host_tag)
396 #define SCSC_HIP4_SAMPLER_PKT_TX_HIP4(minor, host_tag)
397 #define SCSC_HIP4_SAMPLER_PKT_TX_FB(minor, host_tag)
398 #define SCSC_HIP4_SAMPLER_SUSPEND(minor)
399 #define SCSC_HIP4_SAMPLER_RESUME(minor)
400 #define SCSC_HIP4_SAMPLER_TCP_SYN(minor, id, mss)
401 #define SCSC_HIP4_SAMPLER_TCP_FIN(minor, id)
402 #define SCSC_HIP4_SAMPLER_TCP_DATA(minor, id, seq_num)
403 #define SCSC_HIP4_SAMPLER_TCP_ACK(minor, id, ack_num)
404 #define SCSC_HIP4_SAMPLER_TCP_DATA_IN(minor, id, seq_num)
405 #define SCSC_HIP4_SAMPLER_TCP_ACK_IN(minor, id, ack_num)
406 #define SCSC_HIP4_SAMPLER_TCP_RWND(minor, id, rwnd)
407 #define SCSC_HIP4_SAMPLER_TCP_CWND(minor, id, cwnd)
408 #define SCSC_HIP4_SAMPLER_TCP_SEND_BUF(minor, id, send_buff_size)
409 #define SCSC_HIP4_SAMPLER_TCP_DECODE(sdev, dev, frame, from_ba)
410 #endif /* CONFIG_SCSC_WLAN_HIP4_PROFILING */
411
412 #endif /* __HIP4_SAMPLER_H__ */