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