6658988a352ccf895e20e4928f4fc8d28235823f
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / drivers / net / wireless / scsc / dev.h
1 /*****************************************************************************
2 *
3 * Copyright (c) 2012 - 2019 Samsung Electronics Co., Ltd. All rights reserved
4 *
5 ****************************************************************************/
6
7 #ifndef __SLSI_DEVICE_H__
8 #define __SLSI_DEVICE_H__
9
10 #include <linux/init.h>
11 #include <linux/device.h>
12 #include <linux/inetdevice.h>
13 #include <net/addrconf.h>
14
15 #include <linux/version.h>
16 #include <linux/module.h>
17 #include <linux/string.h>
18 #include <linux/kernel.h>
19 #include <linux/netdevice.h>
20 #include <linux/etherdevice.h>
21 #include <linux/ratelimit.h>
22 #include <linux/ip.h>
23
24 #include <linux/completion.h>
25 #include <linux/workqueue.h>
26 #include <linux/time.h>
27 #include <linux/sched.h>
28
29 #include <linux/nl80211.h>
30 #include <linux/wireless.h>
31 #include <linux/proc_fs.h>
32 #include <linux/ieee80211.h>
33 #include <net/cfg80211.h>
34 #include <linux/nl80211.h>
35
36 #include <scsc/scsc_mx.h>
37
38 #include "fapi.h"
39 #include "const.h"
40 #include "utils.h"
41 #include "hip.h"
42 #include "log_clients.h"
43 #include "src_sink.h"
44 #include "scsc_wifi_fcq.h"
45 #include "scsc_wifi_cm_if.h"
46 #include "hip4.h"
47 #include "nl80211_vendor.h"
48 #include "traffic_monitor.h"
49
50 #define FAPI_MAJOR_VERSION(v) (((v) >> 8) & 0xFF)
51 #define FAPI_MINOR_VERSION(v) ((v) & 0xFF)
52
53 /* Modes for CMDGETBSSINFO and CMDGETSTAINFO */
54 #define SLSI_80211_MODE_11B 0
55 #define SLSI_80211_MODE_11G 1
56 #define SLSI_80211_MODE_11N 2
57 #define SLSI_80211_MODE_11A 3
58 #define SLSI_80211_MODE_11AC 4
59
60 #define SLSI_FW_API_RATE_HT_SELECTOR_FIELD 0xc000
61 #define SLSI_FW_API_RATE_NON_HT_SELECTED 0x4000
62 #define SLSI_FW_API_RATE_HT_SELECTED 0x8000
63 #define SLSI_FW_API_RATE_VHT_SELECTED 0xc000
64
65 #define SLSI_FW_API_RATE_VHT_MCS_FIELD 0x000F
66 #define SLSI_FW_API_RATE_HT_MCS_FIELD 0x003F
67 #define SLSI_FW_API_RATE_INDEX_FIELD 0x1fff
68 #define SLSI_FW_API_RATE_VHT_NSS_FIELD 0x0070
69 #define SLSI_FW_API_RATE_HT_NSS_FIELD 0x0040
70
71 #define SLSI_FW_API_RATE_BW_FIELD 0x0600
72 #define SLSI_FW_API_RATE_BW_40MHZ 0x0200
73 #define SLSI_FW_API_RATE_BW_20MHZ 0x0000
74
75 #define SLSI_FW_API_RATE_SGI 0x0100
76 #define SLSI_FW_API_RATE_GF 0x0080
77
78 #define SLSI_HOSTSTATE_LCD_ACTIVE 0x0001
79 #define SLSI_HOSTSTATE_CELLULAR_ACTIVE 0x0002
80 #define SLSI_HOSTSTATE_SAR_ACTIVE 0x0004
81 #define SLSI_HOSTSTATE_GRIP_ACTIVE 0x0040
82 #define SLSI_HOSTSTATE_LOW_LATENCY_ACTIVE 0x0080
83
84 /* indices: 3= BW20->idx_0, BW40->idx_1, BW80->idx_2.
85 * 2= noSGI->idx_0, SGI->idx_1
86 * 10= mcs index
87 * rate units 100kbps
88 * This table for single stream Nss=1and does not include 160MHz BW and 80+80MHz BW.
89 */
90 static const u16 slsi_rates_table[3][2][10] = {
91 { /* BW20 */
92 { /* no SGI */
93 65, 130, 195, 260, 390, 520, 585, 650, 780, 0
94 },
95 { /* SGI */
96 72, 144, 217, 289, 433, 578, 650, 722, 867, 0
97 }
98 },
99 { /* BW40 */
100 { /* no SGI */
101 135, 270, 405, 540, 810, 1080, 1215, 1350, 1620, 1800
102 },
103 { /* SGI */
104 150, 300, 450, 600, 900, 1200, 1350, 1500, 1800, 2000
105 }
106 },
107 { /* BW80 */
108 { /* no SGI */
109 293, 585, 878, 1170, 1755, 2340, 2633, 2925, 3510, 3900
110 },
111 { /* SGI */
112 325, 650, 975, 1300, 1950, 2600, 2925, 3250, 3900, 4333
113 }
114 }
115 };
116 /* MSDU subframe Header */
117 struct msduhdr {
118 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
119 unsigned char h_source[ETH_ALEN]; /* source ether addr */
120 __be16 len; /* MSDU Subframe length */
121 unsigned char dsap; /* DSAP field - SNAP 0xaa */
122 unsigned char ssap; /* SSAP field - SNAP 0xaa */
123 unsigned char ui; /* Control field: U, func UI - 0x03 */
124 unsigned char oui[3]; /* Organization Code - 0x000000 */
125 __be16 type; /* Type - 0x0800 (IPv4)*/
126 } __attribute__((packed));
127
128 static inline void ethr_ii_to_subframe_msdu(struct sk_buff *skb)
129 {
130 struct ethhdr *ehdr;
131 struct msduhdr msduh;
132
133 ehdr = eth_hdr(skb);
134 ether_addr_copy(msduh.h_dest, ehdr->h_dest);
135 ether_addr_copy(msduh.h_source, ehdr->h_source);
136 /* adjust packet length */
137 msduh.len = cpu_to_be16(skb->len - 6);
138 msduh.dsap = 0xaa;
139 msduh.ssap = 0xaa;
140 msduh.ui = 0x03;
141 memset(msduh.oui, 0x0, 3);
142 msduh.type = ehdr->h_proto;
143 (void)skb_push(skb, sizeof(struct msduhdr) - sizeof(struct ethhdr));
144 /* update SKB mac_header to point to start of MSDU header */
145 skb->mac_header -= (sizeof(struct msduhdr) - sizeof(struct ethhdr));
146 memcpy(skb->data, &msduh, sizeof(struct msduhdr));
147 }
148
149 #define SLSI_TX_PROCESS_ID_MIN (0xC001)
150 #define SLSI_TX_PROCESS_ID_MAX (0xCF00)
151 #define SLSI_TX_PROCESS_ID_UDI_MIN (0xCF01)
152 #define SLSI_TX_PROCESS_ID_UDI_MAX (0xCFFE)
153
154 /* There are no wakelocks in kernel/supplicant/hostapd.
155 * So keep the platform active for some time after receiving any data packet.
156 * This timeout value can be fine-tuned based on the test results.
157 */
158 #define SLSI_RX_WAKELOCK_TIME (200)
159 #define MAX_BA_BUFFER_SIZE 64
160 #define NUM_BA_SESSIONS_PER_PEER 8
161 #define MAX_CHANNEL_LIST 20
162 #define SLSI_MAX_RX_BA_SESSIONS (8)
163 #define SLSI_STA_ACTION_FRAME_BITMAP (SLSI_ACTION_FRAME_PUBLIC | SLSI_ACTION_FRAME_WMM | SLSI_ACTION_FRAME_WNM |\
164 SLSI_ACTION_FRAME_QOS | SLSI_ACTION_FRAME_PROTECTED_DUAL |\
165 SLSI_ACTION_FRAME_RADIO_MEASUREMENT)
166
167 /* Default value for MIB SLSI_PSID_UNIFI_DISCONNECT_TIMEOUT + 1 sec*/
168 #define SLSI_DEFAULT_AP_DISCONNECT_IND_TIMEOUT 3000
169
170 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
171 #define WLAN_EID_VHT_CAPABILITY 191
172 #define WLAN_EID_VHT_OPERATION 192
173 #endif
174
175 #define NUM_COUNTRY (300)
176
177 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
178 #define SLSI_MUTEX_INIT(slsi_mutex__) \
179 { \
180 (slsi_mutex__).owner = NULL; \
181 mutex_init(&(slsi_mutex__).mutex); \
182 (slsi_mutex__).valid = true; \
183 }
184
185 #define SLSI_MUTEX_LOCK(slsi_mutex_to_lock) \
186 { \
187 (slsi_mutex_to_lock).line_no_before = __LINE__; \
188 (slsi_mutex_to_lock).file_name_before = __FILE__; \
189 mutex_lock(&(slsi_mutex_to_lock).mutex); \
190 (slsi_mutex_to_lock).owner = current; \
191 (slsi_mutex_to_lock).line_no_after = __LINE__; \
192 (slsi_mutex_to_lock).file_name_after = __FILE__; \
193 (slsi_mutex_to_lock).function = __func__; \
194 }
195
196 #define SLSI_MUTEX_UNLOCK(slsi_mutex_to_unlock) \
197 { \
198 (slsi_mutex_to_unlock).owner = NULL; \
199 mutex_unlock(&(slsi_mutex_to_unlock).mutex); \
200 }
201 #define SLSI_MUTEX_IS_LOCKED(slsi_mutex__) mutex_is_locked(&(slsi_mutex__).mutex)
202
203 struct slsi_mutex {
204 bool valid;
205 u32 line_no_before;
206 const u8 *file_name_before;
207 /* a std mutex */
208 struct mutex mutex;
209 u32 line_no_after;
210 const u8 *file_name_after;
211 const u8 *function;
212 struct task_struct *owner;
213 };
214
215 #else
216 #define SLSI_MUTEX_INIT(mutex__) mutex_init(&(mutex__))
217 #define SLSI_MUTEX_LOCK(mutex_to_lock) mutex_lock(&(mutex_to_lock))
218 #define SLSI_MUTEX_UNLOCK(mutex_to_unlock) mutex_unlock(&(mutex_to_unlock))
219 #define SLSI_MUTEX_IS_LOCKED(mutex__) mutex_is_locked(&(mutex__))
220 #endif
221
222 #define OS_UNUSED_PARAMETER(x) ((void)(x))
223
224 #define SLSI_HOST_TAG_TRAFFIC_QUEUE(htag) (htag & 0x00000003)
225
226 /* For each mlme-req a mlme-cfm is expected to be received from the
227 * firmware. The host is not allowed to send another mlme-req until
228 * the mlme-cfm is received.
229 *
230 * However there are also instances where we need to wait for an mlme-ind
231 * following a mlme-req/cfm exchange. One example of this is the disconnect
232 * sequence:
233 * mlme-disconnect-req - host requests disconnection
234 * mlme-disconnect-cfm - firmware accepts disconnection request but hasn't
235 * disconnected yet.
236 * mlme-disconnect-ind - firmware reports final result of disconnection
237 *
238 * Assuming that waiting for the mlme-ind following on from the mlme-req/cfm
239 * is ok.
240 */
241 struct slsi_sig_send {
242 /* a std spinlock */
243 spinlock_t send_signal_lock;
244 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
245 struct slsi_mutex mutex;
246 #else
247 /* a std mutex */
248 struct mutex mutex;
249 #endif
250 struct completion completion;
251
252 u16 process_id;
253 u16 req_id;
254 u16 cfm_id;
255 u16 ind_id;
256 struct sk_buff *cfm;
257 struct sk_buff *ind;
258 struct sk_buff *mib_error;
259 };
260
261 static inline void slsi_sig_send_init(struct slsi_sig_send *sig_send)
262 {
263 spin_lock_init(&sig_send->send_signal_lock);
264 sig_send->req_id = 0;
265 sig_send->cfm_id = 0;
266 sig_send->process_id = SLSI_TX_PROCESS_ID_MIN;
267 SLSI_MUTEX_INIT(sig_send->mutex);
268 init_completion(&sig_send->completion);
269 }
270
271 struct slsi_ba_frame_desc {
272 bool active;
273 struct sk_buff *signal;
274 u16 sn;
275 };
276
277 struct slsi_ba_session_rx {
278 bool active;
279 bool used;
280 void *vif;
281 struct slsi_ba_frame_desc buffer[MAX_BA_BUFFER_SIZE];
282 u16 buffer_size;
283 u16 occupied_slots;
284 u16 expected_sn;
285 u16 start_sn;
286 u16 highest_received_sn;
287 bool trigger_ba_after_ssn;
288 u8 tid;
289
290 /* Aging timer parameters */
291 bool timer_on;
292 struct timer_list ba_age_timer;
293 struct slsi_spinlock ba_lock;
294 struct net_device *dev;
295 };
296
297 #define SLSI_TID_MAX (16)
298 #define SLSI_AMPDU_F_INITIATED (0x0001)
299 #define SLSI_AMPDU_F_CREATED (0x0002)
300 #define SLSI_AMPDU_F_OPERATIONAL (0x0004)
301
302 #define SLSI_SCAN_HW_ID 0
303 #define SLSI_SCAN_SCHED_ID 1
304 #define SLSI_SCAN_MAX 3
305
306 #define SLSI_SCAN_SSID_MAP_MAX 10 /* Arbitrary value */
307 #define SLSI_SCAN_SSID_MAP_EXPIRY_AGE 2 /* If hidden bss not found these many scan cycles, remove map. Arbitrary value*/
308 #define SLSI_FW_SCAN_DONE_TIMEOUT_MSEC (15 * 1000)
309
310 struct slsi_scan_result {
311 u8 bssid[ETH_ALEN];
312 u8 hidden;
313 int rssi;
314 struct sk_buff *probe_resp;
315 struct sk_buff *beacon;
316 struct slsi_scan_result *next;
317 int band;
318 };
319
320 /* Per Interface Scan Data
321 * Access protected by: cfg80211_lock
322 */
323 struct slsi_scan {
324 /* When a Scan is running this not NULL. */
325 struct cfg80211_scan_request *scan_req;
326 struct slsi_acs_request *acs_request;
327 struct cfg80211_sched_scan_request *sched_req;
328 bool requeue_timeout_work;
329
330 /* Indicates if the scan req is blocking. i.e, waiting until scan_done_ind received */
331 bool is_blocking_scan;
332
333 struct slsi_scan_result *scan_results; /* head for scan_results list*/
334 };
335
336 struct slsi_ssid_map {
337 u8 bssid[ETH_ALEN];
338 u8 ssid[32];
339 u8 ssid_len;
340 u8 age;
341 int band;
342 };
343
344 #ifdef CONFIG_SCSC_WLAN_STA_ENHANCED_ARP_DETECT
345 struct slsi_enhanced_arp_counters {
346 u16 arp_req_count_from_netdev;
347 u16 arp_req_count_to_lower_mac;
348 u16 arp_req_rx_count_by_lower_mac;
349 u16 arp_req_count_tx_success;
350 u16 arp_rsp_rx_count_by_lower_mac;
351 u16 arp_rsp_rx_count_by_upper_mac;
352 u16 arp_rsp_count_to_netdev;
353 u16 arp_rsp_count_out_of_order_drop;
354 u16 ap_link_active;
355 bool is_duplicate_addr_detected;
356 };
357 #endif
358
359 struct slsi_peer {
360 /* Flag MUST be set last when creating a record and immediately when removing.
361 * Otherwise another process could test the flag and start using the data.
362 */
363 bool valid;
364 u8 address[ETH_ALEN];
365
366 /* Presently connected_state is used only for AP/GO mode*/
367 u8 connected_state;
368 u16 aid;
369 /* Presently is_wps is used only in P2P GO mode */
370 bool is_wps;
371 u16 capabilities;
372 bool qos_enabled;
373 u8 queueset;
374 struct scsc_wifi_fcq_data_qset data_qs;
375 struct scsc_wifi_fcq_ctrl_q ctrl_q;
376
377 bool authorized;
378 bool pairwise_key_set;
379
380 /* Needed for STA/AP VIF */
381 struct sk_buff *assoc_ie;
382 struct sk_buff_head buffered_frames;
383 /* Needed for STA VIF */
384 struct sk_buff *assoc_resp_ie;
385
386 /* bitmask that keeps the status of acm bit for each AC
387 * bit 7 6 5 4 3 2 1 0
388 * | | | | | | | |
389 * vo vo vi vi be bk bk be
390 */
391 u8 wmm_acm;
392 /* bitmask that keeps the status of tspec establishment for each priority
393 * bit 7 6 5 4 3 2 1 0
394 * | | | | | | | |
395 * p7 p6 p5 p4 p3 p2 p1 p0
396 */
397 u8 tspec_established;
398 u8 uapsd;
399
400 /* TODO_HARDMAC:
401 * Q: Can we obtain stats from the firmware?
402 * Yes - then this is NOT needed and we can just get from the firmware when requested.
403 * No - How much can we get from the PSCHED?
404 */
405 struct station_info sinfo;
406 /* rate limit for peer sinfo mib reads */
407 struct ratelimit_state sinfo_mib_get_rs;
408 struct slsi_ba_session_rx *ba_session_rx[NUM_BA_SESSIONS_PER_PEER];
409
410 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
411 /* qos map configured at peer end*/
412 bool qos_map_set;
413 struct cfg80211_qos_map qos_map;
414 #endif
415 };
416
417 /* Used to update vif type on vif deactivation indicating vif is no longer available */
418 #define SLSI_VIFTYPE_UNSPECIFIED 0xFFFF
419
420 struct slsi_vif_mgmt_tx {
421 u64 cookie; /* Cookie assigned by Host for the tx mgmt frame */
422 u16 host_tag; /* Host tag for the tx mgmt frame */
423 const u8 *buf; /* Buffer - Mgmt frame requested for tx */
424 size_t buf_len; /* Buffer length */
425 u8 exp_frame; /* Next expected Public action frame subtype from peer */
426 };
427
428 struct slsi_wmm_ac {
429 u8 aci_aifsn;
430 u8 ecw;
431 u16 txop_limit;
432 } __packed;
433
434 /* struct slsi_wmm_parameter_element
435 *
436 * eid - Vendor Specific
437 * len - Remaining Length of IE
438 * oui - Microsoft OUI
439 * oui_type - WMM
440 * oui_subtype - Param IE
441 * version - 1
442 * qos_info - Qos
443 * reserved -
444 * ac - BE,BK,VI,VO
445 */
446 struct slsi_wmm_parameter_element {
447 u8 eid;
448 u8 len;
449 u8 oui[3];
450 u8 oui_type;
451 u8 oui_subtype;
452 u8 version;
453 u8 qos_info;
454 u8 reserved;
455 struct slsi_wmm_ac ac[4];
456 } __packed;
457
458 #define SLSI_MIN_FILTER_ID 0x80 /* Start of filter range reserved for host */
459
460 /* for AP */
461 #define SLSI_AP_ALL_IPV6_PKTS_FILTER_ID 0x80
462
463 /* filter IDs for filters installed by driver */
464 #ifdef CONFIG_SCSC_WLAN_BLOCK_IPV6
465
466 enum slsi_filter_id {
467 SLSI_ALL_ARP_FILTER_ID = SLSI_MIN_FILTER_ID, /* 0x80 */
468 SLSI_LOCAL_ARP_FILTER_ID, /* 0x81 */
469 SLSI_ALL_BC_MC_FILTER_ID, /* 0x82 */
470 SLSI_PROXY_ARP_FILTER_ID, /* 0x83 */
471 SLSI_ALL_IPV6_PKTS_FILTER_ID, /* 0x84 */
472 #ifndef CONFIG_SCSC_WLAN_DISABLE_NAT_KA
473 SLSI_NAT_IPSEC_FILTER_ID, /* 0x85 */
474 #endif
475 #ifdef CONFIG_SCSC_WLAN_ENHANCED_PKT_FILTER
476 SLSI_OPT_OUT_ALL_FILTER_ID, /* 0x86 */
477 SLSI_OPT_IN_TCP4_FILTER_ID, /* 0x87 */
478 SLSI_OPT_IN_TCP6_FILTER_ID, /* 0x88 */
479 #endif
480 SLSI_OPT_OUT_ABNORMAL_MULTICAST_ID, /* 0x89 */
481 SLSI_REGD_MC_FILTER_ID, /* 0x8A */
482 };
483 #else
484
485 /* for STA */
486 enum slsi_filter_id {
487 SLSI_ALL_ARP_FILTER_ID = SLSI_MIN_FILTER_ID, /* 0x80 */
488 SLSI_LOCAL_ARP_FILTER_ID, /* 0x81 */
489 SLSI_ALL_BC_MC_FILTER_ID, /* 0x82 */
490 SLSI_PROXY_ARP_FILTER_ID, /* 0x83 */
491 SLSI_LOCAL_NS_FILTER_ID, /* 0x84 */
492 SLSI_PROXY_ARP_NA_FILTER_ID, /* 0x85 */
493 #ifndef CONFIG_SCSC_WLAN_DISABLE_NAT_KA
494 SLSI_NAT_IPSEC_FILTER_ID, /* 0x86 */
495 #endif
496 #ifdef CONFIG_SCSC_WLAN_ENHANCED_PKT_FILTER
497 SLSI_OPT_OUT_ALL_FILTER_ID, /* 0x87 */
498 SLSI_OPT_IN_TCP4_FILTER_ID, /* 0x88 */
499 SLSI_OPT_IN_TCP6_FILTER_ID, /* 0x89 */
500 #endif
501 SLSI_OPT_OUT_ABNORMAL_MULTICAST_ID, /* 0x8a */
502 SLSI_REGD_MC_FILTER_ID, /* 0x8b */
503 };
504
505 #endif
506
507 #define SLSI_MAX_PKT_FILTERS 16
508
509 #ifndef CONFIG_SCSC_WLAN_DISABLE_NAT_KA
510 /* default config */
511 #define SLSI_MC_ADDR_ENTRY_MAX (SLSI_MIN_FILTER_ID + SLSI_MAX_PKT_FILTERS - SLSI_REGD_MC_FILTER_ID)
512 #else
513 #define SLSI_MC_ADDR_ENTRY_MAX (SLSI_MIN_FILTER_ID + SLSI_MAX_PKT_FILTERS - SLSI_REGD_MC_FILTER_ID + 1)
514 #endif
515
516 /* Values for vif_status field
517 *
518 * Used to indicate the status of an activated VIF, to help resolve
519 * conflicting activities with indications from the firmware eg.
520 * cfg80211 triggers a disconnection before a STA completes its
521 * connection to an AP.
522 */
523 #define SLSI_VIF_STATUS_UNSPECIFIED 0
524 #define SLSI_VIF_STATUS_CONNECTING 1
525 #define SLSI_VIF_STATUS_CONNECTED 2
526 #define SLSI_VIF_STATUS_DISCONNECTING 3
527
528 /*From wifi_offload.h (N_AVAIL_ID=3)*/
529 #define SLSI_MAX_KEEPALIVE_ID 3
530
531 struct slsi_last_connected_bss {
532 u8 address[ETH_ALEN];
533 int antenna_mode;
534 int rssi;
535 int mode;
536 int passpoint_version;
537 int snr;
538 int noise_level;
539 u16 bandwidth;
540 u16 roaming_count;
541 u16 channel_freq;
542 u16 tx_data_rate;
543 u8 roaming_akm;
544 u8 kv;
545 u32 kvie;
546 bool mimo_used;
547 };
548
549 struct slsi_vif_sta {
550 /* Only valid when the VIF is activated */
551 u8 vif_status;
552 bool is_wps;
553 u16 eap_hosttag;
554 u16 m4_host_tag;
555 u16 keepalive_host_tag[SLSI_MAX_KEEPALIVE_ID];
556
557 struct sk_buff *roam_mlme_procedure_started_ind;
558
559 /* This id is used to find out which response (connect resp/roamed resp/reassoc resp)
560 * is to be sent once M4 is transmitted successfully
561 */
562 u16 resp_id;
563 bool gratuitous_arp_needed;
564
565 /* regd multicast address*/
566 u8 regd_mc_addr_count;
567 u8 regd_mc_addr[SLSI_MC_ADDR_ENTRY_MAX][ETH_ALEN];
568 bool group_key_set;
569 struct sk_buff *mlme_scan_ind_skb;
570 bool roam_in_progress;
571 int tdls_peer_sta_records;
572 bool tdls_enabled;
573 struct cfg80211_bss *sta_bss;
574 u8 *assoc_req_add_info_elem;
575 u8 assoc_req_add_info_elem_len;
576
577 /* List of seen ESS and Freq associated with them */
578 struct list_head network_map;
579
580 struct slsi_wmm_ac wmm_ac[4];
581 bool nd_offload_enabled;
582 unsigned long data_rate_mbps;
583 unsigned long max_rate_mbps;
584
585 /*This structure is used to store last disconnected bss info and valid even when vif is deactivated. */
586 struct slsi_last_connected_bss last_connected_bss;
587 struct cfg80211_crypto_settings crypto;
588
589 /* Variable to indicate if roamed_ind needs to be dropped in driver, to maintain roam synchronization. */
590 atomic_t drop_roamed_ind;
591 u8 *vendor_disconnect_ies;
592 int vendor_disconnect_ies_len;
593 };
594
595 struct slsi_vif_unsync {
596 struct delayed_work roc_expiry_work; /* Work on ROC duration expiry */
597 struct delayed_work del_vif_work; /* Work on unsync vif retention timeout */
598 struct delayed_work hs2_del_vif_work; /* Work on HS2 unsync vif retention timeout */
599 struct delayed_work unset_channel_expiry_work; /*unset channel after a timer */
600 u64 roc_cookie; /* Cookie id for ROC */
601 u8 *probe_rsp_ies; /* Probe response IEs to be configured in firmware */
602 size_t probe_rsp_ies_len; /* Probe response IE length */
603 bool ies_changed; /* To indicate if Probe Response IEs have changed from that previously stored */
604 bool listen_offload; /* To indicate if Listen Offload is started */
605 bool slsi_p2p_continuous_fullscan;
606 };
607
608 struct slsi_last_disconnected_sta {
609 u8 address[ETH_ALEN];
610 u32 rx_retry_packets;
611 u32 rx_bc_mc_packets;
612 u16 capabilities;
613 int bandwidth;
614 int antenna_mode;
615 int rssi;
616 int mode;
617 u16 tx_data_rate;
618 bool mimo_used;
619 u16 reason;
620 int support_mode;
621 };
622
623 struct slsi_vif_ap {
624 struct slsi_wmm_parameter_element wmm_ie;
625 struct slsi_last_disconnected_sta last_disconnected_sta;
626 u8 *cache_wmm_ie;
627 u8 *cache_wpa_ie;
628 u8 *add_info_ies;
629 size_t wmm_ie_len;
630 size_t wpa_ie_len;
631 size_t add_info_ies_len;
632 bool p2p_gc_keys_set; /* Used in GO mode to identify that a CLI has connected after WPA2 handshake */
633 bool privacy; /* Used for port enabling based on the open/secured AP configuration */
634 bool qos_enabled;
635 int beacon_interval; /* Beacon interval in AP/GO mode */
636 int mode;
637 bool non_ht_bss_present; /* Non HT BSS observed in HT20 OBSS scan */
638 struct scsc_wifi_fcq_data_qset group_data_qs;
639 u32 cipher;
640 u16 channel_freq;
641 u8 ssid[IEEE80211_MAX_SSID_LEN];
642 u8 ssid_len;
643 };
644
645 #define SLSI_NAN_MAX_PUBLISH_ID 16
646 #define SLSI_NAN_MAX_SUBSCRIBE_ID 16
647
648 struct slsi_vif_nan {
649 u32 publish_id_map;
650 u32 subscribe_id_map;
651 };
652
653 #define TCP_ACK_SUPPRESSION_RECORDS_MAX 16
654 #define TCP_ACK_SUPPRESSION_RECORD_UNUSED_TIMEOUT 10 /* in seconds */
655
656 #define TCP_ACK_SUPPRESSION_OPTIONS_OFFSET 20
657 #define TCP_ACK_SUPPRESSION_OPTION_EOL 0
658 #define TCP_ACK_SUPPRESSION_OPTION_NOP 1
659 #define TCP_ACK_SUPPRESSION_OPTION_MSS 2
660 #define TCP_ACK_SUPPRESSION_OPTION_WINDOW 3
661 #define TCP_ACK_SUPPRESSION_OPTION_SACK 5
662
663 #define SLSI_IS_VIF_CHANNEL_5G(ndev_vif) (((ndev_vif)->chan) ? ((ndev_vif)->chan->hw_value > 14) : 0)
664
665 struct slsi_tcp_ack_s {
666 u32 daddr;
667 u32 dport;
668 u32 saddr;
669 u32 sport;
670 struct sk_buff_head list;
671 u8 window_multiplier;
672 u16 mss;
673 u32 ack_seq;
674 u16 slow_start_count;
675 u8 count;
676 u8 max;
677 u8 age;
678 struct timer_list timer;
679 struct slsi_spinlock lock;
680 bool state;
681 ktime_t last_sent;
682 bool tcp_slow_start;
683
684 /* TCP session throughput monitor */
685 u16 hysteresis;
686 u32 last_tcp_rate;
687 ktime_t last_sample_time;
688 u32 last_ack_seq;
689 u64 num_bytes;
690 #ifdef CONFIG_SCSC_WLAN_HIP4_PROFILING
691 u8 stream_id;
692 u8 rx_window_scale;
693 #endif
694 };
695
696 struct slsi_tcp_ack_stats {
697 u32 tack_acks;
698 u32 tack_suppressed;
699 u32 tack_sent;
700 u32 tack_max;
701 u32 tack_timeout;
702 u32 tack_dacks;
703 u32 tack_sacks;
704 u32 tack_delay_acks;
705 u32 tack_low_window;
706 u32 tack_nocache;
707 u32 tack_norecord;
708 u32 tack_hasdata;
709 u32 tack_psh;
710 u32 tack_dropped;
711 u32 tack_ktime;
712 u32 tack_lastrecord;
713 u32 tack_searchrecord;
714 u32 tack_ece;
715 };
716
717 struct netdev_vif {
718 struct slsi_dev *sdev;
719 struct wireless_dev wdev;
720 atomic_t is_registered; /* Has the net dev been registered */
721 bool is_available; /* Has the net dev been opened AND is usable */
722 bool is_fw_test; /* Is the device in use as a test device via UDI */
723 #ifdef CONFIG_SLSI_WLAN_STA_FWD_BEACON
724 bool is_wips_running;
725 #endif
726 /* Structure can be accessed by cfg80211 ops, procfs/ioctls and as a result
727 * of receiving MLME indications e.g. MLME-CONNECT-IND that can affect the
728 * status of the interface eg. STA connect failure will delete the VIF.
729 */
730 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
731 struct slsi_mutex vif_mutex;
732 #else
733 /* a std mutex */
734 struct mutex vif_mutex;
735 #endif
736 struct slsi_sig_send sig_wait;
737
738 struct slsi_skb_work rx_data;
739 struct slsi_skb_work rx_mlme;
740 u16 ifnum;
741 enum nl80211_iftype iftype;
742 enum nl80211_channel_type channel_type;
743 struct ieee80211_channel *chan;
744 u16 driver_channel;
745 bool drv_in_p2p_procedure;
746 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 9))
747 struct cfg80211_chan_def *chandef;
748 #endif
749
750 /* NOTE: The Address is a __be32
751 * It needs converting to pass to the FW
752 * But not for the Arp or trace %pI4
753 */
754 __be32 ipaddress;
755
756 #ifndef CONFIG_SCSC_WLAN_BLOCK_IPV6
757 struct in6_addr ipv6address;
758 struct slsi_spinlock ipv6addr_lock;
759 #endif
760 struct net_device_stats stats;
761 u32 rx_packets[SLSI_LLS_AC_MAX];
762 u32 tx_packets[SLSI_LLS_AC_MAX];
763 u32 tx_no_ack[SLSI_LLS_AC_MAX];
764 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
765 struct slsi_mutex scan_mutex;
766 struct slsi_mutex scan_result_mutex;
767 #else
768 /* a std mutex */
769 struct mutex scan_mutex;
770 struct mutex scan_result_mutex;
771
772 #endif
773 struct slsi_scan scan[SLSI_SCAN_MAX];
774
775 struct slsi_src_sink_params src_sink_params;
776 u16 power_mode;
777 u16 set_power_mode;
778
779 bool activated; /* VIF is created in firmware and ready to use */
780 u16 vif_type;
781 struct slsi_spinlock peer_lock;
782 int peer_sta_records;
783 struct slsi_peer *peer_sta_record[SLSI_ADHOC_PEER_CONNECTIONS_MAX];
784
785 /* Used to populate the cfg80211 station_info structure generation variable.
786 * This number should increase every time the list of stations changes
787 * i.e. when a station is added or removed, so that userspace can tell
788 * whether it got a consistent snapshot.
789 */
790 int cfg80211_sinfo_generation;
791
792 /* Block Ack MPDU Re-order */
793 struct sk_buff_head ba_complete;
794 atomic_t ba_flush;
795
796 u64 mgmt_tx_cookie; /* Cookie id for mgmt tx */
797 struct slsi_vif_mgmt_tx mgmt_tx_data;
798 struct delayed_work scan_timeout_work; /* Work on scan timeout */
799 bool delete_probe_req_ies; /* Delete probe request stored at probe_req_ies, if
800 * connected for WAP2 at mlme_del_vif or in all cases
801 * if STA
802 */
803 u8 *probe_req_ies;
804 size_t probe_req_ie_len;
805
806 struct slsi_vif_unsync unsync;
807 struct slsi_vif_sta sta;
808 struct slsi_vif_ap ap;
809 struct slsi_vif_nan nan;
810
811 /* TCP ack suppression. */
812 struct slsi_tcp_ack_s *last_tcp_ack;
813 struct slsi_tcp_ack_s ack_suppression[TCP_ACK_SUPPRESSION_RECORDS_MAX];
814 struct slsi_tcp_ack_stats tcp_ack_stats;
815 /* traffic monitor */
816 ktime_t last_timer_time;
817 u32 report_time;
818 u32 num_bytes_tx_per_timer;
819 u32 num_bytes_rx_per_timer;
820 u32 num_bytes_tx_per_sec;
821 u32 num_bytes_rx_per_sec;
822 u32 throughput_tx;
823 u32 throughput_rx;
824 u32 throughput_tx_bps;
825 u32 throughput_rx_bps;
826 #ifdef CONFIG_SCSC_WLAN_STA_ENHANCED_ARP_DETECT
827 bool enhanced_arp_detect_enabled;
828 struct slsi_enhanced_arp_counters enhanced_arp_stats;
829 u8 target_ip_addr[4];
830 int enhanced_arp_host_tag[5];
831 #endif
832 struct cfg80211_ap_settings backup_settings;
833 };
834
835 struct slsi_802_11d_reg_domain {
836 u8 *countrylist;
837 struct ieee80211_regdomain *regdomain;
838 int country_len;
839 };
840
841 struct slsi_apf_capabilities {
842 u16 version;
843 u16 max_length;
844 };
845
846 #ifdef CONFIG_SCSC_WLAN_WES_NCHO
847 struct slsi_wes_mode_roam_scan_channels {
848 int n;
849 u8 channels[MAX_CHANNEL_LIST];
850 };
851 #endif
852
853 struct slsi_dev_config {
854 /* Supported Freq Band (Dynamic)
855 * Set via the freq_band procfs
856 */
857 #define SLSI_FREQ_BAND_AUTO 0
858 #define SLSI_FREQ_BAND_5GHZ 1
859 #define SLSI_FREQ_BAND_2GHZ 2
860 int supported_band;
861
862 struct ieee80211_supported_band *band_5G;
863 struct ieee80211_supported_band *band_2G;
864
865 /* current user suspend mode
866 * Set via the suspend_mode procfs
867 * 0 : not suspended
868 * 1 : suspended
869 */
870 int user_suspend_mode;
871
872 /* Rx filtering rule
873 * Set via the rx_filter_num procfs
874 * 0: Unicast, 1: Broadcast, 2:Multicast IPv4, 3: Multicast IPv6
875 */
876 int rx_filter_num;
877
878 /* Rx filter rule enabled
879 * Set via the rx_filter_start & rx_filter_stop procfs
880 */
881 bool rx_filter_rule_started;
882
883 /* AP Auto channel Selection */
884 #define SLSI_NO_OF_SCAN_CHANLS_FOR_AUTO_CHAN_MAX 14
885 int ap_auto_chan;
886
887 /*QoS capability for a non-AP Station*/
888 int qos_info;
889 #ifdef CONFIG_SCSC_WLAN_WES_NCHO
890 /* NCHO OKC mode */
891 int okc_mode;
892
893 /*NCHO WES mode */
894 int wes_mode;
895
896 int roam_scan_mode;
897
898 /*WES mode roam scan channels*/
899 struct slsi_wes_mode_roam_scan_channels wes_roam_scan_list;
900 #endif
901 struct slsi_802_11d_reg_domain domain_info;
902
903 int ap_disconnect_ind_timeout;
904
905 u8 host_state;
906
907 int rssi_boost_5g;
908 int rssi_boost_2g;
909 bool disable_ch12_ch13;
910 bool fw_enhanced_arp_detect_supported;
911 bool fw_apf_supported;
912 struct slsi_apf_capabilities apf_cap;
913 };
914
915 #define SLSI_DEVICE_STATE_ATTACHING 0
916 #define SLSI_DEVICE_STATE_STOPPED 1
917 #define SLSI_DEVICE_STATE_STARTING 2
918 #define SLSI_DEVICE_STATE_STARTED 3
919 #define SLSI_DEVICE_STATE_STOPPING 4
920
921 #define SLSI_NET_INDEX_WLAN 1
922 #define SLSI_NET_INDEX_P2P 2
923 #define SLSI_NET_INDEX_P2PX_SWLAN 3
924 #define SLSI_NET_INDEX_NAN 4
925
926 /* States used during P2P operations */
927 enum slsi_p2p_states {
928 P2P_IDLE_NO_VIF, /* Initial state - Unsync vif is not present */
929 P2P_IDLE_VIF_ACTIVE, /* Unsync vif is present but no P2P procedure in progress */
930 P2P_SCANNING, /* P2P SOCIAL channel (1,6,11) scan in progress. Not used for P2P full scan */
931 P2P_LISTENING, /* P2P Listen (ROC) in progress */
932 P2P_ACTION_FRAME_TX_RX, /* P2P Action frame Tx in progress or waiting for a peer action frame Rx (i.e. in response to the Tx frame) */
933 P2P_GROUP_FORMED_CLI, /* P2P Group Formed - CLI role */
934 P2P_GROUP_FORMED_GO, /* P2P Group Formed - GO role */
935 /* NOTE: In P2P_LISTENING state if frame transmission is requested to driver then a peer response is ideally NOT expected.
936 * This is an assumption based on the fact that FIND would be stopped prior to group formation/connection.
937 * If driver were to receive a peer frame in P2P_LISTENING state then it would most probably be a REQUEST frame and the supplicant would respond to it.
938 * Hence the driver should get only RESPONSE frames for transmission in P2P_LISTENING state.
939 */
940 };
941
942 enum slsi_wlan_state {
943 WLAN_UNSYNC_NO_VIF = 0, /* Initial state - Unsync vif is not present */
944 WLAN_UNSYNC_VIF_ACTIVE, /* Unsync vif is activated but no wlan procedure in progress */
945 WLAN_UNSYNC_VIF_TX /* Unsync vif is activated and wlan procedure in progress */
946 };
947
948 /* Wakelock timeouts */
949 #define SLSI_WAKELOCK_TIME_MSEC_EAPOL (1000)
950
951 struct slsi_chip_info_mib {
952 u16 chip_version;
953 };
954
955 struct slsi_plat_info_mib {
956 u16 plat_build;
957 };
958
959 /* P2P States in text format for debug purposes */
960 static inline char *slsi_p2p_state_text(u8 state)
961 {
962 switch (state) {
963 case P2P_IDLE_NO_VIF:
964 return "P2P_IDLE_NO_VIF";
965 case P2P_IDLE_VIF_ACTIVE:
966 return "P2P_IDLE_VIF_ACTIVE";
967 case P2P_SCANNING:
968 return "P2P_SCANNING";
969 case P2P_LISTENING:
970 return "P2P_LISTENING";
971 case P2P_ACTION_FRAME_TX_RX:
972 return "P2P_ACTION_FRAME_TX_RX";
973 case P2P_GROUP_FORMED_CLI:
974 return "P2P_GROUP_FORMED_CLI";
975 case P2P_GROUP_FORMED_GO:
976 return "P2P_GROUP_FORMED_GO";
977 default:
978 return "UNKNOWN";
979 }
980 }
981
982 #define SLSI_WLAN_MAX_HCF_PLATFORM_LEN (128)
983
984 struct slsi_dev_mib_info {
985 char *mib_file_name;
986 unsigned int mib_hash;
987
988 /* Cached File MIB Configuration values from User Space */
989 u8 *mib_data;
990 u32 mib_len;
991 char platform[SLSI_WLAN_MAX_HCF_PLATFORM_LEN];
992 };
993
994 #define SLSI_WLAN_MAX_MIB_FILE 2 /* Number of WLAN HCFs to load */
995
996 #ifdef CONFIG_SCSC_LOG_COLLECTION
997 struct slsi_dev_mib_collect_file {
998 char file_name[32];
999 u16 len;
1000 u8 *data;
1001 } __packed;
1002
1003 struct slsi_dev_mib_collect {
1004 bool enabled;
1005 /* Serialize writers/readers */
1006 spinlock_t in_collection;
1007 char num_files;
1008 /* +1 represents local_mib */
1009 struct slsi_dev_mib_collect_file file[SLSI_WLAN_MAX_MIB_FILE + 1];
1010 };
1011
1012 #endif
1013
1014 struct slsi_dev {
1015 /* Devices */
1016 struct device *dev;
1017 struct wiphy *wiphy;
1018
1019 struct slsi_hip hip; /* HIP bookkeeping block */
1020 struct slsi_hip4 hip4_inst; /* The handler to parse to HIP */
1021
1022 struct scsc_wifi_cm_if cm_if; /* cm_if bookkeeping block */
1023 struct scsc_mx *maxwell_core;
1024 struct scsc_service_client mx_wlan_client;
1025 struct scsc_service *service;
1026 struct slsi_chip_info_mib chip_info_mib;
1027 struct slsi_plat_info_mib plat_info_mib;
1028 u16 reg_dom_version;
1029
1030 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
1031 struct slsi_mutex netdev_add_remove_mutex;
1032 #else
1033 /* a std mutex */
1034 struct mutex netdev_add_remove_mutex;
1035 #endif
1036 /* mutex to protect dynamic netdev removal */
1037 struct mutex netdev_remove_mutex;
1038 int netdev_up_count;
1039 struct net_device __rcu *netdev[CONFIG_SCSC_WLAN_MAX_INTERFACES + 1]; /* 0 is reserved */
1040 struct net_device __rcu *netdev_ap;
1041 u8 netdev_addresses[CONFIG_SCSC_WLAN_MAX_INTERFACES + 1][ETH_ALEN]; /* 0 is reserved */
1042
1043 int device_state;
1044
1045 /* BoT */
1046 atomic_t in_pause_state;
1047 #ifdef CONFIG_SCSC_WLAN_SILENT_RECOVERY
1048 struct work_struct recovery_work; /* Work on failure_reset recovery*/
1049 #endif
1050 /* Locking used to control Starting and stopping the chip */
1051 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
1052 struct slsi_mutex start_stop_mutex;
1053 #else
1054 /* a std mutex */
1055 struct mutex start_stop_mutex;
1056 #endif
1057 /* UDI Logging */
1058 struct slsi_log_clients log_clients;
1059 void *uf_cdev;
1060
1061 /* ProcFS */
1062 int procfs_instance;
1063 struct proc_dir_entry *procfs_dir;
1064
1065 /* Configuration */
1066 u8 hw_addr[ETH_ALEN];
1067 struct slsi_dev_mib_info mib[SLSI_WLAN_MAX_MIB_FILE];
1068 struct slsi_dev_mib_info local_mib;
1069 #ifdef CONFIG_SCSC_LOG_COLLECTION
1070 struct slsi_dev_mib_collect collect_mib;
1071 #endif
1072 char *maddr_file_name;
1073 bool *term_udi_users; /* Try to terminate UDI users during unload */
1074 int *sig_wait_cfm_timeout;
1075
1076 struct slsi_wake_lock wlan_wl;
1077 struct slsi_wake_lock wlan_wl_mlme;
1078 struct slsi_wake_lock wlan_wl_ma;
1079 #if !defined SLSI_TEST_DEV && defined CONFIG_ANDROID
1080 struct wake_lock wlan_wl_roam;
1081 #endif
1082 struct slsi_sig_send sig_wait;
1083 struct slsi_skb_work rx_dbg_sap;
1084 atomic_t tx_host_tag[SLSI_LLS_AC_MAX];
1085 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
1086 struct slsi_mutex device_config_mutex;
1087 #else
1088 /* a std mutex */
1089 struct mutex device_config_mutex;
1090 #endif
1091 struct slsi_dev_config device_config;
1092
1093 struct notifier_block inetaddr_notifier;
1094 #ifndef CONFIG_SCSC_WLAN_BLOCK_IPV6
1095 struct notifier_block inet6addr_notifier;
1096 #endif
1097
1098 struct workqueue_struct *device_wq; /* Driver Workqueue */
1099 enum slsi_p2p_states p2p_state; /* Store current P2P operation */
1100
1101 enum slsi_wlan_state wlan_unsync_vif_state; /* Store current sate of unsync wlan vif */
1102
1103 int current_tspec_id;
1104 int tspec_error_code;
1105 u8 p2p_group_exp_frame; /* Next expected Public action frame subtype from peer */
1106 bool initial_scan;
1107
1108 #ifdef CONFIG_SCSC_WLAN_GSCAN_ENABLE
1109 struct slsi_gscan *gscan;
1110 struct slsi_gscan_result *gscan_hash_table[SLSI_GSCAN_HASH_TABLE_SIZE];
1111 int num_gscan_results;
1112 int buffer_threshold;
1113 int buffer_consumed;
1114 struct slsi_bucket bucket[SLSI_GSCAN_MAX_BUCKETS];
1115 struct list_head hotlist_results;
1116 bool epno_active;
1117 #endif
1118 #ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
1119 u8 scan_mac_addr[6];
1120 bool scan_addr_set;
1121 #endif
1122 #ifdef CONFIG_SCSC_WLAN_HIP4_PROFILING
1123 int minor_prof;
1124 #endif
1125 struct slsi_ba_session_rx rx_ba_buffer_pool[SLSI_MAX_RX_BA_SESSIONS];
1126 struct slsi_spinlock rx_ba_buffer_pool_lock;
1127 bool fail_reported;
1128 bool p2p_certif; /* Set to true to idenitfy p2p_certification testing is going on*/
1129 bool mlme_blocked; /* When true do not send mlme signals to FW */
1130 atomic_t debug_inds;
1131 int recovery_next_state;
1132 struct completion recovery_remove_completion;
1133 struct completion recovery_stop_completion;
1134 struct completion recovery_completed;
1135 int recovery_status;
1136 struct slsi_ssid_map ssid_map[SLSI_SCAN_SSID_MAP_MAX];
1137 bool band_5g_supported;
1138 int supported_2g_channels[14];
1139 int supported_5g_channels[25];
1140 int enabled_channel_count;
1141 bool fw_ht_enabled;
1142 u8 fw_ht_cap[4]; /* HT capabilities is 21 bytes but host is never intersted in last 17 bytes*/
1143 bool fw_vht_enabled;
1144 u8 fw_vht_cap[4];
1145 #ifdef CONFIG_SCSC_WLAN_WIFI_SHARING
1146 u8 wifi_sharing_5ghz_channel[8];
1147 int valid_5g_freq[25];
1148 int wifi_sharing_5g_restricted_channels[25];
1149 int num_5g_restricted_channels;
1150 #endif
1151 bool fw_SoftAp_2g_40mhz_enabled;
1152 bool nan_enabled;
1153 u16 assoc_result_code; /* Status of latest association in STA mode */
1154 bool allow_switch_40_mhz; /* Used in AP cert to disable HT40 when not configured */
1155 bool allow_switch_80_mhz; /* Used in AP cert to disable VHT when not configured */
1156 #ifdef CONFIG_SCSC_WLAN_AP_INFO_FILE
1157 /* Parameters in '/data/vendor/conn/.softap.info' */
1158 bool dualband_concurrency;
1159 u32 softap_max_client;
1160 #endif
1161 u32 fw_dwell_time;
1162 int lls_num_radio;
1163
1164 #ifdef CONFIG_SCSC_WLAN_MUTEX_DEBUG
1165 struct slsi_mutex logger_mutex;
1166 #else
1167 /* a std mutex */
1168 struct mutex logger_mutex;
1169 #endif
1170 struct slsi_traffic_mon_clients traffic_mon_clients;
1171 /*Store vif index corresponding to rtt id for FTM*/
1172 u16 rtt_vif[8];
1173 bool acs_channel_switched;
1174 int recovery_timeout; /* ms autorecovery completion timeout */
1175 #ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
1176 bool fw_mac_randomization_enabled;
1177 #endif
1178
1179 #ifdef CONFIG_SCSC_WLAN_ENHANCED_PKT_FILTER
1180 bool enhanced_pkt_filter_enabled;
1181 #endif
1182 #ifdef CONFIG_SCSC_WLAN_ABNORMAL_MULTICAST_PKT_FILTER
1183 bool abnormal_multicast_pkt_filter_enabled;
1184 #endif
1185 };
1186
1187 /* Compact representation of channels a ESS has been seen on
1188 * This is sized correctly for the Channels we currently support,
1189 * 2.4Ghz Channels 1 - 14
1190 * 5 Ghz Channels Uni1, Uni2 and Uni3
1191 */
1192 struct slsi_roaming_network_map_entry {
1193 struct list_head list;
1194 unsigned long last_seen_jiffies; /* Timestamp of the last time we saw this ESS */
1195 struct cfg80211_ssid ssid; /* SSID of the ESS */
1196 u8 initial_bssid[ETH_ALEN]; /* Bssid of the first ap seen in this ESS */
1197 bool only_one_ap_seen; /* Has more than one AP for this ESS been seen */
1198 u16 channels_24_ghz; /* 2.4 Ghz Channels Bit Map */
1199 /* 5 Ghz Channels Bit Map
1200 * channels_5_ghz & 0x000000FF = 4 Uni1 Channels
1201 * channels_5_ghz & 0x00FFFF00 = 15 Uni2 Channels
1202 * channels_5_ghz & 0xFF000000 = 5 Uni3 Channels
1203 */
1204 u32 channels_5_ghz;
1205 };
1206
1207 #define LLC_SNAP_HDR_LEN 8
1208 struct llc_snap_hdr {
1209 u8 llc_dsap;
1210 u8 llc_ssap;
1211 u8 llc_ctrl;
1212 u8 snap_oui[3];
1213 u16 snap_type;
1214 } __packed;
1215
1216 void slsi_rx_data_deliver_skb(struct slsi_dev *sdev, struct net_device *dev, struct sk_buff *skb, bool from_ba_timer);
1217 void slsi_rx_dbg_sap_work(struct work_struct *work);
1218 void slsi_rx_netdev_data_work(struct work_struct *work);
1219 void slsi_rx_netdev_mlme_work(struct work_struct *work);
1220 int slsi_rx_enqueue_netdev_mlme(struct slsi_dev *sdev, struct sk_buff *skb, u16 vif);
1221 void slsi_rx_scan_pass_to_cfg80211(struct slsi_dev *sdev, struct net_device *dev, struct sk_buff *skb);
1222 void slsi_rx_buffered_frames(struct slsi_dev *sdev, struct net_device *dev, struct slsi_peer *peer);
1223 int slsi_rx_blocking_signals(struct slsi_dev *sdev, struct sk_buff *skb);
1224 void slsi_scan_complete(struct slsi_dev *sdev, struct net_device *dev, u16 scan_id, bool aborted);
1225
1226 void slsi_tx_pause_queues(struct slsi_dev *sdev);
1227 void slsi_tx_unpause_queues(struct slsi_dev *sdev);
1228 int slsi_tx_control(struct slsi_dev *sdev, struct net_device *dev, struct sk_buff *skb);
1229 int slsi_tx_data(struct slsi_dev *sdev, struct net_device *dev, struct sk_buff *skb);
1230 int slsi_tx_data_lower(struct slsi_dev *sdev, struct sk_buff *skb);
1231 bool slsi_is_test_mode_enabled(void);
1232 bool slsi_is_rf_test_mode_enabled(void);
1233 int slsi_check_rf_test_mode(void);
1234 void slsi_regd_deinit(struct slsi_dev *sdev);
1235 void slsi_init_netdev_mac_addr(struct slsi_dev *sdev);
1236 bool slsi_dev_lls_supported(void);
1237 bool slsi_dev_gscan_supported(void);
1238 bool slsi_dev_epno_supported(void);
1239 bool slsi_dev_vo_vi_block_ack(void);
1240 int slsi_dev_get_scan_result_count(void);
1241 bool slsi_dev_llslogs_supported(void);
1242 int slsi_dev_nan_supported(struct slsi_dev *sdev);
1243 void slsi_regd_init(struct slsi_dev *sdev);
1244 bool slsi_dev_rtt_supported(void);
1245
1246 //BEGIN IKSAMP-1972
1247 #ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
1248 bool slsi_dev_mac_randomisation_support(void);
1249 #endif
1250 //END IKSAMP-1972
1251
1252 static inline u16 slsi_tx_host_tag(struct slsi_dev *sdev, enum slsi_traffic_q tq)
1253 {
1254 /* host_tag:
1255 * bit 0,1 = trafficqueue identifier
1256 * bit 2-15 = incremental number
1257 * So increment by 4 to get bit 2-15 a incremental sequence
1258 */
1259 return (u16)atomic_add_return(4, &sdev->tx_host_tag[tq]);
1260 }
1261
1262 static inline u16 slsi_tx_mgmt_host_tag(struct slsi_dev *sdev)
1263 {
1264 /* Doesn't matter which traffic queue host tag is selected.*/
1265 return slsi_tx_host_tag(sdev, 0);
1266 }
1267
1268 static inline struct net_device *slsi_get_netdev_rcu(struct slsi_dev *sdev, u16 ifnum)
1269 {
1270 WARN_ON(!rcu_read_lock_held());
1271 if (ifnum > CONFIG_SCSC_WLAN_MAX_INTERFACES) {
1272 /* WARN(1, "ifnum:%d", ifnum); WARN() is used like this to avoid Coverity Error */
1273 return NULL;
1274 }
1275 return rcu_dereference(sdev->netdev[ifnum]);
1276 }
1277
1278 static inline struct net_device *slsi_get_netdev_locked(struct slsi_dev *sdev, u16 ifnum)
1279 {
1280 WARN_ON(!SLSI_MUTEX_IS_LOCKED(sdev->netdev_add_remove_mutex));
1281 if (ifnum > CONFIG_SCSC_WLAN_MAX_INTERFACES) {
1282 WARN(1, "ifnum:%d", ifnum); /* WARN() is used like this to avoid Coverity Error */
1283 return NULL;
1284 }
1285 return sdev->netdev[ifnum];
1286 }
1287
1288 static inline struct net_device *slsi_get_netdev(struct slsi_dev *sdev, u16 ifnum)
1289 {
1290 struct net_device *dev;
1291
1292 SLSI_MUTEX_LOCK(sdev->netdev_add_remove_mutex);
1293 dev = slsi_get_netdev_locked(sdev, ifnum);
1294 SLSI_MUTEX_UNLOCK(sdev->netdev_add_remove_mutex);
1295
1296 return dev;
1297 }
1298
1299 static inline int slsi_get_supported_mode(const u8 *peer_ie)
1300 {
1301 const u8 *peer_ie_data;
1302 u8 peer_ie_len;
1303 int i;
1304 int supported_rate;
1305
1306 peer_ie_len = peer_ie[1];
1307 peer_ie_data = &peer_ie[2];
1308 for (i = 0; i < peer_ie_len; i++) {
1309 supported_rate = ((peer_ie_data[i] & 0x7F) / 2);
1310 if (supported_rate > 11)
1311 return SLSI_80211_MODE_11G;
1312 }
1313 return SLSI_80211_MODE_11B;
1314 }
1315
1316 /* Names of full mode HCF files */
1317 extern char *slsi_mib_file;
1318 extern char *slsi_mib_file2;
1319
1320 #endif