Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
unifi_priv.h
Go to the documentation of this file.
1 /*
2  *****************************************************************************
3  *
4  * FILE : unifi_priv.h
5  *
6  * PURPOSE : Private header file for unifi driver.
7  *
8  * UDI = UniFi Debug Interface
9  *
10  * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
11  *
12  * Refer to LICENSE.txt included with this source code for details on
13  * the license terms.
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 /* CSR_WIFI_SUPPORT_MMC_DRIVER */
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 /* Define the unifi_priv_t before include the unifi_native.h */
58 struct unifi_priv;
59 typedef struct unifi_priv unifi_priv_t;
60 #ifdef CSR_SUPPORT_WEXT_AP
61 struct CsrWifiSmeApConfig;
62 typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
63 #endif
64 #ifdef CSR_SUPPORT_WEXT
65 #include "unifi_wext.h"
66 #endif
67 
68 #ifdef ANDROID_BUILD
69 extern 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 /* The device major number to use when registering the udi driver */
81 #define UNIFI_NAME "unifi"
82 /*
83  * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present.
84  * This number should be set to the number of SDIO slots supported by the SDIO
85  * host controller on the platform.
86  * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c
87  */
88 #define MAX_UNIFI_DEVS 2
89 
90 /* 802.11 Mac header offsets */
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 /* octet offset from start of mac header for certain fields */
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 /* frame control (FC) masks, for frame control as 16 bit integer */
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 /* selected type and subtype combinations as in 7.1.3.1 table 1
121  For frame control as 16 bit integer, or for ls octet
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 /* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
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 /* Time in us to check for inactivity of stations 5 mins */
143 #define INACTIVITY_CHECK_INTERVAL 300000000
144 /* Time in us before a station is flagged as inactive */
145 #define MAX_INACTIVITY_INTERVAL 300000000
146 
147 
148 /* Define for maximum BA session */
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 /* Define for age (in us) value for frames in MPDU reorder buffer */
157 #define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000 /* 30 milli seconds */
158 
159 /* This macro used in prepare_and_add_macheader*/
160 #define ADDRESS_ONE_OFFSET 20
161 
162 /* Defines for STA inactivity detection */
163 #define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1 /* in number of stations */
164 #define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30 /* in seconds */
165 #define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000 /* 120 seconds */
166 
167 /* Test for modes requiring AP firmware patch */
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 /* Defines used in beacon filtering in case of P2P */
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 /* For M4 request received via netdev*/
182 
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 /* Module parameter variables */
191 extern int buswidth;
192 extern int sdio_clock;
193 extern int use_5g;
194 extern int disable_hw_reset;
195 extern int disable_power_control;
196 extern int enable_wol;
197 extern int sme_debug;
198 extern int fw_init[MAX_UNIFI_DEVS];
199 extern int tl_80211d;
200 extern int sdio_byte_mode;
201 extern int sdio_block_size;
202 extern int coredump_max;
203 extern int run_bh_once;
204 extern int bh_priority;
205 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
206 extern int log_hip_signals;
207 #endif
208 
209 struct dlpriv {
210  const unsigned char *dl_data;
211  int dl_len;
212  void *fw_desc;
213 };
214 
215 
216 struct uf_thread {
217 
219 
220  /* wait_queue for waking the unifi_thread kernel thread */
222  unsigned int wakeup_flag;
223 
224  /*
225  * Use it to block the I/O thread when
226  * an error occurs or UniFi is reinitialised.
227  */
229 
230  char name[16];
231  int prio;
232 };
233 
234 /*
235  * Link list to hold the received packets for the period the port
236  * remains closed.
237  */
238 typedef struct rx_buffered_packets {
239  /* List link structure */
240  struct list_head q;
241  /* Packet to indicate when the port reopens */
242  struct sk_buff *skb;
243  /* Bulkdata to free in case the port closes and need to discard the packet */
245  /* The source address of the packet */
247  /* The destination address of the packet */
249  /* Corresponding signal */
252 
253 
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 /* Queue to be used for contention priority */
271 
272 /*
273  * Link list to hold the tx packets for the period the peer
274  * powersave/free slots in unifi
275  */
276 typedef struct tx_buffered_packets {
277  /* List link structure */
278  struct list_head q;
284  /* Bulkdata to free in case the port closes and need to discard the packet */
286  /* The source address of the packet */
290 
291 /* station record has this data structure */
293 
294  /* Sme sends these parameters */
302 
303  /* Router/Driver database */
304 #ifdef CSR_SUPPORT_SME
305  unifi_port_cfg_t *peerControlledPort;
306  unifi_port_cfg_t *peerUnControlledPort;
307 
308  /* Inactivity feature parameters */
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  /* Activity timestamps for the station */
316  CsrTime lastActivity;
317 
318  /* during m/c transmission sp suspended */
319  u8 uspSuspend;
320  CSR_PRIORITY triggerFramePriority;
321 #endif
332  /* Dont change the value of below macro for SET & RESET */
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 
342 
343 #ifdef CSR_SUPPORT_WEXT_AP
344 struct CsrWifiSmeApConfig {
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 /* This is a test code and may be removed later*/
355 #define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
356 
357 typedef struct
358 {
359  u8 *bufptr; /* Signal Primitive */
360  bulk_data_param_t data_ptrs; /* Bulk Data pointers */
361  u16 sig_len;
362 }rx_buff_struct_t;
363 
364 typedef 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 
372 void rx_wq_handler(struct work_struct *work);
373 #endif
374 
375 struct unifi_priv {
376 
379 
380  /* Index into Unifi_instances[] for this device. */
381  int instance;
382  /* Reference count for this instance */
384 
385  /* Firmware images */
386  struct dlpriv fw_sta;
387  struct dlpriv fw_conv; /* used for conversion of production test image */
388 
389  /* Char device related structures */
390  struct cdev unifi_cdev;
393 
394  /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
396 
397  /* For multiple interface support */
400 
402 
404 
405  /* Name of node under /proc */
406  char proc_entry_name[64];
407 
408  /*
409  * Flags:
410  * drop_unencrypted
411  * - Not used?
412  * netdev_registered
413  * - whether the netdev has been registered.
414  */
415  unsigned int drop_unencrypted : 1;
416 
417  /* Our list of unifi linux clients. */
419 
420  /* Mutex to protect using the logging hook after UDI client is gone */
422  /* Pointer to the ul_clients[] array */
424 
425  /* A ul_client_t* used to send the netdev related MIB requests. */
427 
428  /* The SME ul_client_t pointer. */
430 
431  /* The AMP ul_client_t pointer. */
433 
434  /*
435  * Semaphore for locking the top-half to one user process.
436  * This is necessary to prevent multiple processes calling driver
437  * operations. This can happen because the network driver entry points
438  * can be called from multiple processes.
439  */
440 #ifdef USE_DRIVER_LOCK
441  struct semaphore lock;
442 #endif /* USE_DRIVER_LOCK */
443 
444  /* Flag to say that an operation was aborted */
446 
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 
456 
457  /* The WMM features that UniFi uses in the current BSS */
458  unsigned int sta_wmm_capabilities;
459 
460  /* Debug only */
461  char last_debug_string[256];
462  unsigned short last_debug_word16[16];
463 
464 #ifdef CSR_SUPPORT_SME
465  /* lock to protect the tx queues list */
466  spinlock_t tx_q_lock;
467  u8 allPeerDozing;
468  u8 pausedStaHandle[MAX_ACCESS_CATOGORY];
469  /* Max packet the driver can queue, irrespective of interface number */
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  /* lock to protect stainfo members and priv members*/
477  spinlock_t staRecord_lock;
478 #endif
479 #ifdef CSR_NATIVE_LINUX
480 #ifdef CSR_SUPPORT_WEXT
481  /* wireless config */
482  struct wext_config wext_conf;
483 #endif
484 
485  /* Mutex to protect the MLME blocking requests */
486  struct semaphore mlme_blocking_mutex;
487 
488  /* The ul_client that provides the blocking API for WEXT calls */
489  ul_client_t *wext_client;
490 
491 #endif /* CSR_NATIVE_LINUX */
492 
493 #ifdef CSR_SUPPORT_SME
494  wait_queue_head_t sme_request_wq;
495  /* Semaphore to protect the SME blocking requests */
496  struct semaphore sme_sem;
497  /* Structure to hold the SME blocking requests data*/
498  sme_reply_t sme_reply;
499 
500  /* Structure to hold a traffic protocol indication */
501  struct ta_ind {
502  struct work_struct task;
506  int in_use;
507  } ta_ind_work;
508 
509  struct ta_sample_ind {
510  struct work_struct task;
512  int in_use;
513  } ta_sample_ind_work;
514 
515  __be32 sta_ip_address;
516  CsrWifiRouterCtrlSmeVersions sme_versions;
517 
518  /*
519  * Flag to reflect state of unifi_sys_wifi_on_*() progress.
520  * This indicates whether we are in an "wifi on" state when we are
521  * allowed to indication errors with unifi_mgt_wifi_off_ind()
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  /* Userspace TaskId for the SME Set when a wifi on req is received */
531 
532  struct work_struct multicast_list_task;
533  /*
534  * The SME installs filters to ask for specific MA-UNITDATA.req
535  * to be passed to different SME components.
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 /* UNIFI_CFG related parameters */
541  uf_cfg_bcast_packet_filter_t packet_filters;
542  unsigned char *filter_tclas_ies;
543  /* The structure that holds all the connection configuration. */
544  CsrWifiSmeConnectionConfig connection_config;
545 #ifdef CSR_SUPPORT_WEXT
546 
547  int ignore_bssid_join;
548  struct iw_statistics wext_wireless_stats;
549 
550  /* The MIB and MAC address files contents, read from userspace */
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 /* CSR_SUPPORT_WEXT */
566 
567 #endif /* CSR_SUPPORT_SME */
568 
569 #ifdef CSR_SME_USERSPACE
570  void *smepriv;
571 #endif /* CSR_SME_USERSPACE */
572 
574 
575  /* Mutex to protect unifi_send_signal() */
577 
578 
579  /*
580  * The workqueue to offload the TA run
581  * and the multicast addresses list set
582  */
584 
585  unsigned char *mib_cfm_buffer;
586  unsigned int mib_cfm_buffer_length;
587 
588  int ptest_mode; /* Set when in production test mode */
589  int coredump_mode; /* Set when SME has requested a coredump */
590  u8 wol_suspend; /* Set when suspending with UniFi powered */
591 
592 #define UF_UNCONTROLLED_PORT_Q 0
593 #define UF_CONTROLLED_PORT_Q 1
594 
595  /* Semaphore to protect the rx queues list */
597 
598  /* Spinlock to protect M4 data */
600  /* Mutex to protect BA RX data */
602 
603 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
604  /* Spinlock to protect the WAPI data */
605  spinlock_t wapi_lock;
606 #endif
607 
608  /* Array to indicate if a particular Tx queue is paused, this may not be
609  * required in a multiqueue implementation since we can directly stop kernel
610  * queues */
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 
624 
625 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
626  /*Set if multicast KeyID = 1*/
627  u8 wapi_multicast_filter;
628  /*Set if unicast KeyID = 1*/
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 
642 
643 };
644 
645 typedef struct {
646  u16 queue_length[4];
649 
650 
651 typedef struct {
658 
659 typedef struct {
671  struct work_struct send_ba_err_task;
673 
674 
675 typedef struct {
680 
681 typedef struct netInterface_priv
682 {
691 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
692  struct work_struct send_pkt_to_encrypt;
693 #endif
698  /*
699  * Flag to reflect state of CONNECTED indication signal.
700  * This indicates whether we are "joined" an Access Point (i.e. have
701  * nominated an AP and are receiving beacons) but give no indication
702  * of whether we are authenticated and/or associated.
703  */
704  enum {
708  } connected;
709 #ifdef CSR_SUPPORT_WEXT
710  /* Tracks when we are waiting for a netdevice state change callback */
711  u8 wait_netdev_change;
712  /* True if we have successfully registered for netdev callbacks */
713  u8 netdev_callback_registered;
714 #endif /* CSR_SUPPORT_WEXT */
715  unsigned int netdev_registered;
716 #define UNIFI_MAX_MULTICAST_ADDRESSES 10
717  /* The multicast addresses list that the thread needs to set. */
719  /* The multicast addresses count that the thread needs to set. */
722 #ifdef CSR_SUPPORT_SME
723  /* (un)controlled port configuration */
724  unifi_port_config_t controlled_data_port;
725  unifi_port_config_t uncontrolled_data_port;
726 
727  /* station record maintenance related data structures */
728  u8 num_stations_joined;
730  struct list_head genericMgtFrames;
731  struct list_head genericMulticastOrBroadCastFrames;
732  struct list_head genericMulticastOrBroadCastMgtFrames;
733 
734  /* Timer for detecting station inactivity */
735  struct timer_list sta_activity_check_timer;
736  u8 sta_activity_check_enabled;
737 
738  /* Timestamp when the last inactivity check was done */
739  CsrTime last_inactivity_check;
740 
741  /*number of multicast or borad cast packets queued*/
742  u16 noOfbroadcastPktQueued;
743 #endif
744  /* A list to hold the buffered uncontrolled port packets */
746  /* A list to hold the buffered controlled port packets */
748  /* Buffered M4 signal to take care of WPA race condition */
751 
752 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
753  /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */
754  CSR_SIGNAL wapi_unicast_ma_pkt_sig;
755  bulk_data_desc_t wapi_unicast_bulk_data;
756 #endif
757 
758  /* This should be removed and m4_hostTag should be used for checking*/
763  u32 multicastPduHostTag; /* Used to set the tim after getting
764  a confirm for it */
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); /* as nothing */
781 #define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */
782 #endif /* USE_DRIVER_LOCK */
783 
785 
786 
787 /*
788  * SDIO related functions and callbacks
789  */
790 int uf_sdio_load(void);
791 void uf_sdio_unload(void);
792 unifi_priv_t *uf_find_instance(int inst);
795 unifi_priv_t *uf_get_instance(int inst);
796 void uf_put_instance(int inst);
799 
800 void uf_add_os_device(int bus_id, struct device *os_device);
801 void uf_remove_os_device(int bus_id);
802 
803 
804 
805 /*
806  * Claim/release SDIO
807  *
808  * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
809  * as this prevents other functions using SDIO.
810  * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
811  * we have followed this scheme:
812  * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
813  * then we call CsrSdioClaim/CsrSdioRelease().
814  * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
815  * then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
816  * to the SDIO glue layer only (e.g. sdio_mmc.c).
817  * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
818  * then we call directly the sdio_claim_host/sdio_release_host().
819  * Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
820  *
821  * Note: The _func and function pointers are _not_ the same.
822  * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
823  * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
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 /* CSR_WIFI_SINGLE_FUNCTION */
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 /* CSR_WIFI_SUPPORT_MMC_DRIVER */
852 
853 
854 /*
855  * Functions to allocate and free an ethernet device.
856  */
857 unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
859 
860 /* Allocating function for other interfaces */
862 
863 /*
864  * Firmware download related functions.
865  */
869 int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
870 
871 /*
872  * Functions to create and delete the device nodes.
873  */
874 int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
876 
877 /*
878  * Upper Edge Initialisation functions
879  */
882 
883 /* Thread related helper functions */
884 int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
885 void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
886 void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
887 
888 
889 /*
890  * Unifi Linux functions
891  */
892 void ul_init_clients(unifi_priv_t *priv);
893 
894 /* Configuration flags */
895 #define CLI_USING_WIRE_FORMAT 0x0002
896 #define CLI_SME_USERSPACE 0x0020
898  unsigned int configuration,
899  udi_event_t udi_event_clbk);
901 
903  CSR_SIGNAL *sigptr,
904  bulk_data_param_t *bulkdata);
906  unsigned char *sigptr, int siglen,
907  bulk_data_param_t *bulkdata);
908 
909 void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
910 
911 
912 /*
913  * Data plane operations
914  */
915 /*
916  * data_tx.c
917  */
918 int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
919  unsigned int length);
920 
921 #ifdef CSR_SUPPORT_SME
922 u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
923 u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,u8 pmBit,u16 interfaceTag);
924 void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag);
925 int 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);
930 u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
931 void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t * priv,
932  CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
933  u16 qosControl,
934  u16 interfaceTag);
935 
936 void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
937 void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
938 
939 void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
940 void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
941 void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
942 
943 
944 
945 #endif
946 CsrResult 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);
947 void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata, u32 siglen);
948 #ifdef CSR_SUPPORT_SME
949 void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue queue);
950 int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
951  CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
952  CsrWifiRouterCtrlStaInfo_t *dstStaInfo);
953 void 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);
957  netInterface_priv_t *interfacePriv,
958  struct list_head *buffered_frames_list);
959 void uf_flush_list(unifi_priv_t * priv, struct list_head * list);
960 tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList);
961 void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag);
962 void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag);
963 void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag);
964 #endif
965 /*
966  * netdev.c
967  */
968 
969 #ifndef P80211_OUI_LEN
970 #define P80211_OUI_LEN 3
971 #endif
972 typedef struct {
973  u8 dsap; /* always 0xAA */
974  u8 ssap; /* always 0xAA */
975  u8 ctrl; /* always 0x03 */
976  u8 oui[P80211_OUI_LEN]; /* organizational universal id */
978 } __attribute__ ((packed)) llc_snap_hdr_t;
981  const unsigned char *daddr, const unsigned char *saddr,
982  const CSR_SIGNAL *signal,
983  bulk_data_param_t *bulkdata);
984 
985 const char *result_code_str(int result);
986 
987 
988 /* prepares & appends the Mac header for the payload */
990  struct sk_buff *skb,
991  struct sk_buff *newSkb,
993  bulk_data_param_t *bulkdata,
994  u16 interfaceTag,
995  const u8 *daddr,
996  const u8 *saddr,
997  u8 protection);
1000 
1001 void
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 /* Pack the LSB to include station handle & status of tim set */
1010 #define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
1011 /* get the station record handle from the sender ID */
1012 #define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
1013 /* get the timSet status from the sender ID */
1014 #define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
1015 
1016 /* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */
1017 #define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
1018 
1019 void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle);
1020 void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId);
1021 
1022 /* Clear the Peer station Record, in case of wifioff/unexpected card removal */
1023 void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
1024 
1025 void scroll_ba_window(unifi_priv_t *priv,
1026  netInterface_priv_t *interfacePriv,
1027  ba_session_rx_struct *ba_session,
1028  u16 sn);
1029 
1031  u16 interfaceTag,
1033  u16 tID,
1034  CsrWifiMacAddress macAddress);
1035 #ifdef CSR_SUPPORT_SME
1036 /* Fetch the protection information from interface Mode */
1037 s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr);
1038 #endif
1039 
1040 /* Fetch the station record handler from data base for matching Mac address */
1041 #ifdef CSR_SUPPORT_SME
1042 CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
1043  const u8 *peerMacAddress,
1044  u16 interfaceTag);
1045 
1046 /* Fetch the station record handler from data base for matching handle */
1047 CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
1048  u32 handle,
1049  u16 interfaceTag);
1050 
1051 void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress);
1052 void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
1053 #endif
1054 
1055 void uf_resume_data_plane(unifi_priv_t *priv, int queue,
1056  CsrWifiMacAddress peer_address,
1057  u16 interfaceTag);
1059  CsrWifiMacAddress peer_address,u16 interfaceTag);
1060 
1061 int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
1063 
1064 void uf_net_get_name(struct net_device *dev, char *name, int len);
1065 
1066 void uf_send_queue_info(unifi_priv_t *priv);
1068 
1070  CsrWifiMacAddress source_address,
1071  int indicate, u16 interfaceTag);
1072 
1073 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1074 int uf_register_hip_offline_debug(unifi_priv_t *priv);
1075 int uf_unregister_hip_offline_debug(unifi_priv_t *priv);
1076 #endif
1077 
1078 /*
1079  * inet.c
1080  */
1081 void uf_register_inet_notifier(void);
1082 void uf_unregister_inet_notifier(void);
1083 
1084 
1085 /*
1086  * Suspend / Resume handlers
1087  */
1088 void unifi_resume(void *ospriv);
1089 void 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 /* EAPOL PDUS */
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  * unifi_dbg.c
1113  */
1115  const unsigned char *extra,
1116  unsigned int extralen);
1117 void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1118 void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1119 
1120 
1121 /*
1122  * putest.c
1123  */
1124 int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
1125 int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
1126 int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
1127 int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
1128 int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
1129 int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
1130 int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
1131 int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
1132 int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
1133 
1134 int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
1135 int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
1136 
1137 #endif /* __LINUX_UNIFI_PRIV_H__ */