1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __LINUX_UNIFI_PRIV_H__
18#define __LINUX_UNIFI_PRIV_H__ 1
19
20#include <linux/version.h>
21#include <linux/module.h>
22#include <linux/string.h>
23#include <linux/errno.h>
24#include <linux/kernel.h>
25#include <linux/wait.h>
26#include <linux/sched.h>
27#include <linux/delay.h>
28#include <linux/netdevice.h>
29#include <linux/wireless.h>
30#include <linux/cdev.h>
31#include <linux/kthread.h>
32#include <linux/freezer.h>
33
34#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
35#include <linux/mmc/core.h>
36#include <linux/mmc/card.h>
37#include <linux/mmc/host.h>
38#include <linux/mmc/sdio_func.h>
39#include <linux/mmc/sdio_ids.h>
40#include <linux/mmc/sdio.h>
41#endif
42
43#include <linux/fs.h>
44
45#ifdef ANDROID_BUILD
46#include <linux/wakelock.h>
47#endif
48
49#include "csr_wifi_hip_unifi.h"
50#include "csr_wifi_hip_unifi_udi.h"
51#include "csr_wifi_router_lib.h"
52#include "unifiio.h"
53#ifndef CSR_WIFI_HIP_TA_DISABLE
54#include "csr_wifi_vif_utils.h"
55#endif
56
57
58struct unifi_priv;
59typedef struct unifi_priv unifi_priv_t;
60#ifdef CSR_SUPPORT_WEXT_AP
61struct CsrWifiSmeApConfig;
62typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
63#endif
64#ifdef CSR_SUPPORT_WEXT
65#include "unifi_wext.h"
66#endif
67
68#ifdef ANDROID_BUILD
69extern struct wake_lock unifi_sdio_wake_lock;
70#endif
71
72#include "unifi_clients.h"
73
74#ifdef CSR_NATIVE_LINUX
75#include "sme_native/unifi_native.h"
76#else
77#include "unifi_sme.h"
78#endif
79
80
81#define UNIFI_NAME "unifi"
82
83
84
85
86
87
88#define MAX_UNIFI_DEVS 2
89
90
91#define MAC_HEADER_SIZE 24
92#define QOS_CONTROL_HEADER_SIZE 2
93#define HT_CONTROL_HEADER_SIZE 4
94#define QOS_DATA 0x8
95#define QOS_DATA_NULL 0xc
96#define DATA_NULL 0x04
97#define FRAME_CONTROL_ORDER_BIT 0x8000
98#define FRAME_CONTROL_TYPE_FIELD_OFFSET 2
99#define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET 4
100#define IEEE802_11_FRAMETYPE_DATA 0x02
101#define IEEE802_11_FRAMETYPE_CONTROL 0x01
102#define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
103#define IEEE802_11_FRAMETYPE_RESERVED 0x03
104
105
106#define IEEE802_11_ADDR3_OFFSET 16
107#define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
108#define IEEE802_11_MAX_DATA_LEN 2304
109
110
111#define IEEE802_11_FC_TO_DS_MASK 0x100
112#define IEEE802_11_FC_FROM_DS_MASK 0x200
113#define IEEE802_11_FC_MOREDATA_MASK 0x2000
114#define IEEE802_11_FC_PROTECTED_MASK 0x4000
115#define IEEE80211_FC_ORDER_MASK 0x8000
116#define IEEE80211_FC_SUBTYPE_MASK 0x00f0
117#define IEEE80211_FC_TYPE_MASK 0x000c
118#define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
119
120
121
122
123#define IEEE802_11_FC_TYPE_DATA 0x08
124#define IEEE802_11_FC_TYPE_NULL 0x48
125#define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
126#define IEEE802_11_FC_TYPE_QOS_DATA 0x88
127
128#define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
129
130
131#define IEEE802_11_QC_TID_MASK 0x0f
132#define IEEE802_11_QC_A_MSDU_PRESENT 0x80
133
134#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND))
135#define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0
136#endif
137
138#define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
139#define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
140#define MAX_ACCESS_CATOGORY 4
141
142
143#define INACTIVITY_CHECK_INTERVAL 300000000
144
145#define MAX_INACTIVITY_INTERVAL 300000000
146
147
148
149#define MAX_SUPPORTED_BA_SESSIONS_TX 1
150#define MAX_SUPPORTED_BA_SESSIONS_RX 4
151
152#define MAX_BA_WIND_SIZE 64
153#define MAC_HEADER_ADDR1_OFFSET 4
154#define MAC_HEADER_ADDR2_OFFSET 10
155
156
157#define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000
158
159
160#define ADDRESS_ONE_OFFSET 20
161
162
163#define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1
164#define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30
165#define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000
166
167
168#define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \
169 ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE)
170
171
172#define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH 0x7
173#define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON 0x8
174#define CSR_WIFI_BEACON_FIXED_LENGTH 12
175#define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET 4
176#define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
177
178#define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
179 ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
180
181
182
183typedef u8 CsrWifiPacketType;
184#define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00)
185#define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
186#define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
187
188#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
189
190
191extern int buswidth;
192extern int sdio_clock;
193extern int use_5g;
194extern int disable_hw_reset;
195extern int disable_power_control;
196extern int enable_wol;
197extern int sme_debug;
198extern int fw_init[MAX_UNIFI_DEVS];
199extern int tl_80211d;
200extern int sdio_byte_mode;
201extern int sdio_block_size;
202extern int coredump_max;
203extern int run_bh_once;
204extern int bh_priority;
205#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
206extern int log_hip_signals;
207#endif
208
209struct dlpriv {
210 const unsigned char *dl_data;
211 int dl_len;
212 void *fw_desc;
213};
214
215
216struct uf_thread {
217
218 struct task_struct *thread_task;
219
220
221 wait_queue_head_t wakeup_q;
222 unsigned int wakeup_flag;
223
224
225
226
227
228 int block_thread;
229
230 char name[16];
231 int prio;
232};
233
234
235
236
237
238typedef struct rx_buffered_packets {
239
240 struct list_head q;
241
242 struct sk_buff *skb;
243
244 bulk_data_param_t bulkdata;
245
246 CsrWifiMacAddress sa;
247
248 CsrWifiMacAddress da;
249
250 CSR_SIGNAL signal;
251} rx_buffered_packets_t;
252
253
254typedef u8 CsrWifiAcPowersaveMode;
255#define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
256#define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
257#define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
258#define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
259
260
261#define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
262#define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
263#define IS_DTIM_ACTIVE(flag,hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
264#define INVALID_HOST_TAG 0xFFFFFFFF
265#define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
266
267
268
269
270
271
272
273
274
275
276typedef struct tx_buffered_packets {
277
278 struct list_head q;
279 u16 interfaceTag;
280 CSR_CLIENT_TAG hostTag;
281 CSR_PROCESS_ID leSenderProcessId;
282 CSR_TRANSMISSION_CONTROL transmissionControl;
283 CSR_RATE rate;
284
285 bulk_data_desc_t bulkdata;
286
287 CsrWifiMacAddress peerMacAddress;
288 CSR_PRIORITY priority;
289} tx_buffered_packets_t;
290
291
292typedef struct CsrWifiRouterCtrlStaInfo_t {
293
294
295 CsrWifiMacAddress peerMacAddress;
296 u32 assignedHandle;
297 u8 wmmOrQosEnabled;
298 CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
299 u16 maxSpLength;
300 u8 uapsdActive;
301 u16 noOfSpFramesSent;
302
303
304#ifdef CSR_SUPPORT_SME
305 unifi_port_cfg_t *peerControlledPort;
306 unifi_port_cfg_t *peerUnControlledPort;
307
308
309 struct netInterface_priv *interfacePriv;
310 struct work_struct send_disconnected_ind_task;
311 u8 activity_flag;
312 u16 listenIntervalInTus;
313 CSR_CLIENT_TAG nullDataHostTag;
314
315
316 CsrTime lastActivity;
317
318
319 u8 uspSuspend;
320 CSR_PRIORITY triggerFramePriority;
321#endif
322 CsrWifiRouterCtrlPeerStatus currentPeerState;
323 struct list_head dataPdu[MAX_ACCESS_CATOGORY];
324 struct list_head mgtFrames;
325 u8 spStatus;
326 u8 prevFrmType;
327 u8 prevFrmAccessCatogory;
328 u8 protection;
329 u16 aid;
330 u8 txSuspend;
331 u8 timSet;
332
333#define CSR_WIFI_TIM_RESET 0
334#define CSR_WIFI_TIM_SET 1
335#define CSR_WIFI_TIM_RESETTING 2
336#define CSR_WIFI_TIM_SETTING 3
337
338 u8 timRequestPendingFlag;
339 u8 updateTimReqQueued;
340 u16 noOfPktQueued;
341}CsrWifiRouterCtrlStaInfo_t;
342
343#ifdef CSR_SUPPORT_WEXT_AP
344struct CsrWifiSmeApConfig {
345 CsrWifiSsid ssid;
346 u16 channel;
347 CsrWifiNmeApCredentials credentials;
348 u8 max_connections;
349 u8 if_index;
350};
351#endif
352
353#ifdef CSR_WIFI_RX_PATH_SPLIT
354
355#define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
356
357typedef struct
358{
359 u8 *bufptr;
360 bulk_data_param_t data_ptrs;
361 u16 sig_len;
362}rx_buff_struct_t;
363
364typedef struct
365{
366 u8 writePointer;
367 u8 readPointer;
368 u8 size;
369 rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE];
370} rxCircularBuffer_t;
371
372void rx_wq_handler(struct work_struct *work);
373#endif
374
375struct unifi_priv {
376
377 card_t *card;
378 CsrSdioFunction *sdio;
379
380
381 int instance;
382
383 int ref_count;
384
385
386 struct dlpriv fw_sta;
387 struct dlpriv fw_conv;
388
389
390 struct cdev unifi_cdev;
391 struct cdev unifiudi_cdev;
392 struct device *unifi_device;
393
394
395 CSR_IFINTERFACE if_index;
396
397
398 struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
399 struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
400
401 u8 totalInterfaceCount;
402
403 int prev_queue;
404
405
406 char proc_entry_name[64];
407
408
409
410
411
412
413
414
415 unsigned int drop_unencrypted : 1;
416
417
418 ul_client_t ul_clients[MAX_UDI_CLIENTS];
419
420
421 struct semaphore udi_logging_mutex;
422
423 ul_client_t *logging_client;
424
425
426 ul_client_t *netdev_client;
427
428
429 ul_client_t *sme_cli;
430
431
432 ul_client_t *amp_client;
433
434
435
436
437
438
439
440#ifdef USE_DRIVER_LOCK
441 struct semaphore lock;
442#endif
443
444
445 int io_aborted;
446
447 struct uf_thread bh_thread;
448
449#define UNIFI_INIT_NONE 0x00
450#define UNIFI_INIT_IN_PROGRESS 0x01
451#define UNIFI_INIT_FW_DOWNLOADED 0x02
452#define UNIFI_INIT_COMPLETED 0x04
453 unsigned char init_progress;
454
455 int sme_is_present;
456
457
458 unsigned int sta_wmm_capabilities;
459
460
461 char last_debug_string[256];
462 unsigned short last_debug_word16[16];
463
464#ifdef CSR_SUPPORT_SME
465
466 spinlock_t tx_q_lock;
467 u8 allPeerDozing;
468 u8 pausedStaHandle[MAX_ACCESS_CATOGORY];
469
470 u16 noOfPktQueuedInDriver;
471#define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
472#define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
473#define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
474
475 u8 routerBufferEnable[MAX_ACCESS_CATOGORY];
476
477 spinlock_t staRecord_lock;
478#endif
479#ifdef CSR_NATIVE_LINUX
480#ifdef CSR_SUPPORT_WEXT
481
482 struct wext_config wext_conf;
483#endif
484
485
486 struct semaphore mlme_blocking_mutex;
487
488
489 ul_client_t *wext_client;
490
491#endif
492
493#ifdef CSR_SUPPORT_SME
494 wait_queue_head_t sme_request_wq;
495
496 struct semaphore sme_sem;
497
498 sme_reply_t sme_reply;
499
500
501 struct ta_ind {
502 struct work_struct task;
503 CsrWifiRouterCtrlTrafficPacketType packet_type;
504 CsrWifiRouterCtrlProtocolDirection direction;
505 CsrWifiMacAddress src_addr;
506 int in_use;
507 } ta_ind_work;
508
509 struct ta_sample_ind {
510 struct work_struct task;
511 CsrWifiRouterCtrlTrafficStats stats;
512 int in_use;
513 } ta_sample_ind_work;
514
515 __be32 sta_ip_address;
516 CsrWifiRouterCtrlSmeVersions sme_versions;
517
518
519
520
521
522
523 enum {
524 wifi_on_unspecified = -1,
525 wifi_on_in_progress = 0,
526 wifi_on_done = 1,
527 } wifi_on_state;
528
529
530 CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
531
532 struct work_struct multicast_list_task;
533
534
535
536
537#define MAX_MA_UNIDATA_IND_FILTERS 8
538 sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
539
540
541 uf_cfg_bcast_packet_filter_t packet_filters;
542 unsigned char *filter_tclas_ies;
543
544 CsrWifiSmeConnectionConfig connection_config;
545#ifdef CSR_SUPPORT_WEXT
546
547 int ignore_bssid_join;
548 struct iw_statistics wext_wireless_stats;
549
550
551 CsrWifiSmeDataBlock mib_data;
552 CsrWifiMacAddress sta_mac_address;
553
554 int wep_tx_key_index;
555 wep_key_t wep_keys[NUM_WEPKEYS];
556
557
558#ifdef CSR_SUPPORT_WEXT_AP
559 CsrWifiSmeApMacConfig ap_mac_config;
560 CsrWifiNmeApConfig group_sec_config;
561 CsrWifiSmeApConfig_t ap_config;
562#endif
563 struct work_struct sme_config_task;
564
565#endif
566
567#endif
568
569#ifdef CSR_SME_USERSPACE
570 void *smepriv;
571#endif
572
573 card_info_t card_info;
574
575
576 spinlock_t send_signal_lock;
577
578
579
580
581
582
583 struct workqueue_struct *unifi_workqueue;
584
585 unsigned char *mib_cfm_buffer;
586 unsigned int mib_cfm_buffer_length;
587
588 int ptest_mode;
589 int coredump_mode;
590 u8 wol_suspend;
591
592#define UF_UNCONTROLLED_PORT_Q 0
593#define UF_CONTROLLED_PORT_Q 1
594
595
596 struct semaphore rx_q_sem;
597
598
599 spinlock_t m4_lock;
600
601 struct semaphore ba_mutex;
602
603#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
604
605 spinlock_t wapi_lock;
606#endif
607
608
609
610
611 u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
612
613#ifdef CSR_WIFI_RX_PATH_SPLIT
614 struct workqueue_struct *rx_workqueue;
615 struct work_struct rx_work_struct;
616 rxCircularBuffer_t rxSignalBuffer;
617
618#endif
619
620 u32 rxTcpThroughput;
621 u32 txTcpThroughput;
622 u32 rxUdpThroughput;
623 u32 txUdpThroughput;
624
625#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
626
627 u8 wapi_multicast_filter;
628
629 u8 wapi_unicast_filter;
630 u8 wapi_unicast_queued_pkt_filter;
631#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
632 u8 isWapiConnection;
633#endif
634#endif
635
636#ifdef CSR_WIFI_SPLIT_PATCH
637 CsrWifiRouterCtrlModeSetReq pending_mode_set;
638#endif
639
640 u8 cmanrTestMode;
641 CSR_RATE cmanrTestModeTransmitRate;
642
643};
644
645typedef struct {
646 u16 queue_length[4];
647 u8 os_queue_paused;
648} unifi_OsQosInfo;
649
650
651typedef struct {
652 u8 active;
653 bulk_data_param_t bulkdata;
654 CSR_SIGNAL signal;
655 u16 sn;
656 CsrTime recv_time;
657} frame_desc_struct;
658
659typedef struct {
660 frame_desc_struct *buffer;
661 u16 wind_size;
662 u16 occupied_slots;
663 struct timer_list timer;
664 u16 timeout;
665 u16 expected_sn;
666 u16 start_sn;
667 u8 trigger_ba_after_ssn;
668 struct netInterface_priv *interfacePriv;
669 u16 tID;
670 CsrWifiMacAddress macAddress;
671 struct work_struct send_ba_err_task;
672} ba_session_rx_struct;
673
674
675typedef struct {
676 struct netInterface_priv *interfacePriv;
677 u16 tID;
678 CsrWifiMacAddress macAddress;
679} ba_session_tx_struct;
680
681typedef struct netInterface_priv
682{
683 u16 InterfaceTag;
684 struct unifi_priv *privPtr;
685 ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
686 ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
687 frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
688 u8 ba_complete_index;
689 u8 queueEnabled[UNIFI_NO_OF_TX_QS];
690 struct work_struct send_m4_ready_task;
691#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
692 struct work_struct send_pkt_to_encrypt;
693#endif
694 struct net_device_stats stats;
695 u8 interfaceMode;
696 u8 protect;
697 CsrWifiMacAddress bssid;
698
699
700
701
702
703
704 enum {
705 UnifiConnectedUnknown = -1,
706 UnifiNotConnected = 0,
707 UnifiConnected = 1,
708 } connected;
709#ifdef CSR_SUPPORT_WEXT
710
711 u8 wait_netdev_change;
712
713 u8 netdev_callback_registered;
714#endif
715 unsigned int netdev_registered;
716#define UNIFI_MAX_MULTICAST_ADDRESSES 10
717
718 u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
719
720 int mc_list_count;
721 u32 tag;
722#ifdef CSR_SUPPORT_SME
723
724 unifi_port_config_t controlled_data_port;
725 unifi_port_config_t uncontrolled_data_port;
726
727
728 u8 num_stations_joined;
729 CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
730 struct list_head genericMgtFrames;
731 struct list_head genericMulticastOrBroadCastFrames;
732 struct list_head genericMulticastOrBroadCastMgtFrames;
733
734
735 struct timer_list sta_activity_check_timer;
736 u8 sta_activity_check_enabled;
737
738
739 CsrTime last_inactivity_check;
740
741
742 u16 noOfbroadcastPktQueued;
743#endif
744
745 struct list_head rx_uncontrolled_list;
746
747 struct list_head rx_controlled_list;
748
749 CSR_SIGNAL m4_signal;
750 bulk_data_desc_t m4_bulk_data;
751
752#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
753
754 CSR_SIGNAL wapi_unicast_ma_pkt_sig;
755 bulk_data_desc_t wapi_unicast_bulk_data;
756#endif
757
758
759 u8 m4_sent;
760 CSR_CLIENT_TAG m4_hostTag;
761 u8 dtimActive;
762 u8 intraBssEnabled;
763 u32 multicastPduHostTag;
764
765 u8 bcTimSet;
766 u8 bcTimSetReqPendingFlag;
767 u8 bcTimSetReqQueued;
768} netInterface_priv_t;
769
770#ifdef CSR_SUPPORT_SME
771#define routerStartBuffering(priv,queue) priv->routerBufferEnable[(queue)] = TRUE;
772#define routerStopBuffering(priv,queue) priv->routerBufferEnable[(queue)] = FALSE;
773#define isRouterBufferEnabled(priv,queue) priv->routerBufferEnable[(queue)]
774#endif
775
776#ifdef USE_DRIVER_LOCK
777#define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock)
778#define UNLOCK_DRIVER(_p) up(&(_p)->lock)
779#else
780#define LOCK_DRIVER(_p) (void)(_p);
781#define UNLOCK_DRIVER(_p) (void)(_p);
782#endif
783
784s32 CsrHipResultToStatus(CsrResult csrResult);
785
786
787
788
789
790int uf_sdio_load(void);
791void uf_sdio_unload(void);
792unifi_priv_t *uf_find_instance(int inst);
793int uf_find_priv(unifi_priv_t *priv);
794int uf_find_netdev_priv(netInterface_priv_t *priv);
795unifi_priv_t *uf_get_instance(int inst);
796void uf_put_instance(int inst);
797int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
798int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
799
800void uf_add_os_device(int bus_id, struct device *os_device);
801void uf_remove_os_device(int bus_id);
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
827
828#ifdef CSR_WIFI_SINGLE_FUNCTION
829#define CsrSdioClaim(function) sdio_claim_host((function)->priv);
830#define CsrSdioRelease(function) sdio_release_host((function)->priv);
831
832#define _sdio_claim_host(_func)
833#define _sdio_release_host(_func)
834
835#else
836#define CsrSdioClaim(function)
837#define CsrSdioRelease(function)
838
839#define _sdio_claim_host(_func) sdio_claim_host(_func)
840#define _sdio_release_host(_func) sdio_release_host(_func)
841
842#endif
843
844#else
845#define _sdio_claim_host(_func)
846#define _sdio_release_host(_func)
847
848#define CsrSdioClaim(function)
849#define CsrSdioRelease(function)
850
851#endif
852
853
854
855
856
857unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
858int uf_free_netdevice(unifi_priv_t *priv);
859
860
861u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag);
862
863
864
865
866int uf_run_unifihelper(unifi_priv_t *priv);
867int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
868int uf_release_firmware_files(unifi_priv_t *priv);
869int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
870
871
872
873
874int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
875void uf_destroy_device_nodes(unifi_priv_t *priv);
876
877
878
879
880int uf_init_bh(unifi_priv_t *priv);
881int uf_init_hw(unifi_priv_t *priv);
882
883
884int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
885void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
886void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
887
888
889
890
891
892void ul_init_clients(unifi_priv_t *priv);
893
894
895#define CLI_USING_WIRE_FORMAT 0x0002
896#define CLI_SME_USERSPACE 0x0020
897ul_client_t *ul_register_client(unifi_priv_t *priv,
898 unsigned int configuration,
899 udi_event_t udi_event_clbk);
900int ul_deregister_client(ul_client_t *pcli);
901
902int ul_send_signal_unpacked(unifi_priv_t *priv,
903 CSR_SIGNAL *sigptr,
904 bulk_data_param_t *bulkdata);
905int ul_send_signal_raw(unifi_priv_t *priv,
906 unsigned char *sigptr, int siglen,
907 bulk_data_param_t *bulkdata);
908
909void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
910
911
912
913
914
915
916
917
918int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
919 unsigned int length);
920
921#ifdef CSR_SUPPORT_SME
922u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
923u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,u8 pmBit,u16 interfaceTag);
924void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag);
925int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
926 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
927 const CSR_SIGNAL *signal,
928 bulk_data_param_t *bulkdata,
929 u8 macHeaderLengthInBytes);
930u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
931void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t * priv,
932 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
933 u16 qosControl,
934 u16 interfaceTag);
935
936void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
937void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
938
939void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
940void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
941void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
942
943
944
945#endif
946CsrResult uf_process_ma_packet_req(unifi_priv_t *priv, u8 *peerMacAddress, CSR_CLIENT_TAG hostTag, u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, CSR_RATE TransmitRate, CSR_PRIORITY priority, CSR_PROCESS_ID senderId, bulk_data_param_t *bulkdata);
947void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata, u32 siglen);
948#ifdef CSR_SUPPORT_SME
949void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue queue);
950int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
951 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
952 CsrWifiRouterCtrlStaInfo_t *dstStaInfo);
953void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
954 struct list_head *frames_need_cfm_list,
955 struct list_head * list);
956void send_auto_ma_packet_confirm(unifi_priv_t *priv,
957 netInterface_priv_t *interfacePriv,
958 struct list_head *buffered_frames_list);
959void uf_flush_list(unifi_priv_t * priv, struct list_head * list);
960tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList);
961void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag);
962void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag);
963void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag);
964#endif
965
966
967
968
969#ifndef P80211_OUI_LEN
970#define P80211_OUI_LEN 3
971#endif
972typedef struct {
973 u8 dsap;
974 u8 ssap;
975 u8 ctrl;
976 u8 oui[P80211_OUI_LEN];
977 u16 protocol;
978} __attribute__ ((packed)) llc_snap_hdr_t;
979int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto);
980int skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
981 const unsigned char *daddr, const unsigned char *saddr,
982 const CSR_SIGNAL *signal,
983 bulk_data_param_t *bulkdata);
984
985const char *result_code_str(int result);
986
987
988
989int prepare_and_add_macheader(unifi_priv_t *priv,
990 struct sk_buff *skb,
991 struct sk_buff *newSkb,
992 CSR_PRIORITY priority,
993 bulk_data_param_t *bulkdata,
994 u16 interfaceTag,
995 const u8 *daddr,
996 const u8 *saddr,
997 u8 protection);
998CSR_PRIORITY
999get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
1000
1001void
1002unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
1003 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
1004 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
1005 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
1006 CSR_SIGNAL *signal);
1007
1008
1009
1010#define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
1011
1012#define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
1013
1014#define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
1015
1016
1017#define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
1018
1019void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle);
1020void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId);
1021
1022
1023void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
1024
1025void scroll_ba_window(unifi_priv_t *priv,
1026 netInterface_priv_t *interfacePriv,
1027 ba_session_rx_struct *ba_session,
1028 u16 sn);
1029
1030u8 blockack_session_stop(unifi_priv_t *priv,
1031 u16 interfaceTag,
1032 CsrWifiRouterCtrlBlockAckRole role,
1033 u16 tID,
1034 CsrWifiMacAddress macAddress);
1035#ifdef CSR_SUPPORT_SME
1036
1037s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr);
1038#endif
1039
1040
1041#ifdef CSR_SUPPORT_SME
1042CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
1043 const u8 *peerMacAddress,
1044 u16 interfaceTag);
1045
1046
1047CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
1048 u32 handle,
1049 u16 interfaceTag);
1050
1051void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress);
1052void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
1053#endif
1054
1055void uf_resume_data_plane(unifi_priv_t *priv, int queue,
1056 CsrWifiMacAddress peer_address,
1057 u16 interfaceTag);
1058void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
1059 CsrWifiMacAddress peer_address,u16 interfaceTag);
1060
1061int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
1062void uf_unregister_netdev(unifi_priv_t *priv);
1063
1064void uf_net_get_name(struct net_device *dev, char *name, int len);
1065
1066void uf_send_queue_info(unifi_priv_t *priv);
1067u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag);
1068
1069void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
1070 CsrWifiMacAddress source_address,
1071 int indicate, u16 interfaceTag);
1072
1073#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1074int uf_register_hip_offline_debug(unifi_priv_t *priv);
1075int uf_unregister_hip_offline_debug(unifi_priv_t *priv);
1076#endif
1077
1078
1079
1080
1081void uf_register_inet_notifier(void);
1082void uf_unregister_inet_notifier(void);
1083
1084
1085
1086
1087
1088void unifi_resume(void *ospriv);
1089void unifi_suspend(void *ospriv);
1090
1091
1092#define QOS_CAPABILITY_WMM_ENABLED 0x0001
1093#define QOS_CAPABILITY_WMM_UAPSD 0x0002
1094#define QOS_CAPABILITY_ACM_BE_ENABLED 0x0010
1095#define QOS_CAPABILITY_ACM_BK_ENABLED 0x0020
1096#define QOS_CAPABILITY_ACM_VI_ENABLED 0x0040
1097#define QOS_CAPABILITY_ACM_VO_ENABLED 0x0080
1098#define QOS_CAPABILITY_TS_BE_ENABLED 0x0100
1099#define QOS_CAPABILITY_TS_BK_ENABLED 0x0200
1100#define QOS_CAPABILITY_TS_VI_ENABLED 0x0400
1101#define QOS_CAPABILITY_TS_VO_ENABLED 0x0800
1102
1103
1104
1105#ifndef ETH_P_PAE
1106#define ETH_P_PAE 0x888e
1107#endif
1108#ifndef ETH_P_WAI
1109#define ETH_P_WAI 0x88b4
1110#endif
1111
1112
1113
1114void debug_string_indication(unifi_priv_t *priv,
1115 const unsigned char *extra,
1116 unsigned int extralen);
1117void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1118void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1119
1120
1121
1122
1123
1124int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
1125int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
1126int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
1127int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
1128int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
1129int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
1130int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
1131int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
1132int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
1133
1134int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
1135int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
1136
1137#endif
1138