Staging: add CSR wifi module
[linux-2.6-block.git] / drivers / staging / csr / unifi_priv.h
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 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
33 #include <linux/freezer.h>
34 #endif
35
36 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
37 #include <linux/mmc/core.h>
38 #include <linux/mmc/card.h>
39 #include <linux/mmc/host.h>
40 #include <linux/mmc/sdio_func.h>
41 #include <linux/mmc/sdio_ids.h>
42 #include <linux/mmc/sdio.h>
43 #endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
44
45 #include <linux/fs.h>
46
47 #include "csr_wifi_hip_unifi.h"
48 #include "csr_wifi_hip_unifi_udi.h"
49 #include "csr_wifi_router_lib.h"
50 #include "unifiio.h"
51 #ifndef CSR_WIFI_HIP_TA_DISABLE
52 #include "csr_wifi_vif_utils.h"
53 #endif
54
55 /* Define the unifi_priv_t before include the unifi_native.h */
56 struct unifi_priv;
57 typedef struct unifi_priv unifi_priv_t;
58 #ifdef CSR_SUPPORT_WEXT_AP
59 struct CsrWifiSmeApConfig;
60 typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
61 #endif
62 #ifdef CSR_SUPPORT_WEXT
63 #include "unifi_wext.h"
64 #endif
65
66 #include "unifi_clients.h"
67
68
69 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
70 #include <linux/workqueue.h>
71
72 #undef INIT_WORK
73 #define INIT_WORK(_work, _func)                                         \
74     do {                                                                \
75         INIT_LIST_HEAD(&(_work)->entry);                                \
76         (_work)->pending = 0;                                           \
77         PREPARE_WORK((_work), (_func), (_work));                        \
78         init_timer(&(_work)->timer);                                    \
79     } while(0)
80
81 #endif  /* Linux kernel < 2.6.20 */
82
83
84 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
85 #define UF_NETIF_TX_WAKE_ALL_QUEUES(_netdev)    netif_tx_wake_all_queues(_netdev)
86 #define UF_NETIF_TX_START_ALL_QUEUES(_netdev)   netif_tx_start_all_queues(_netdev)
87 #define UF_NETIF_TX_STOP_ALL_QUEUES(_netdev)    netif_tx_stop_all_queues(_netdev)
88 #else
89 #define UF_NETIF_TX_WAKE_ALL_QUEUES(_netdev)    netif_wake_queue(_netdev)
90 #define UF_NETIF_TX_START_ALL_QUEUES(_netdev)   netif_start_queue(_netdev)
91 #define UF_NETIF_TX_STOP_ALL_QUEUES(_netdev)    netif_stop_queue(_netdev)
92 #endif  /* Linux kernel >= 2.6.27 */
93
94
95 #ifdef CSR_NATIVE_LINUX
96 #include "sme_native/unifi_native.h"
97 #else
98 #include "unifi_sme.h"
99 #endif
100
101 #undef  COMPARE_HOST_TAG_TO_ENQUEUE
102 #define COMPARE_HOST_TAG_TO_ENQUEUE(tx_q_item_hosttag,maPktHostTag)        \
103       if(tx_q_item_hosttag > maPktHostTag){                                \
104         locationFound = TRUE;                                              \
105         ii++;                                                              \
106         break;                                                             \
107     }                                                                      \
108     ii++;                                                                  \
109
110
111 /* The device major number to use when registering the udi driver */
112 #define UNIFI_NAME      "unifi"
113 #define MAX_UNIFI_DEVS  2
114
115 /* 802.11 Mac header offsets */
116 #define MAC_HEADER_SIZE  24
117 #define QOS_CONTROL_HEADER_SIZE 2
118 #define HT_CONTROL_HEADER_SIZE  4
119 #define QOS_DATA 0x8
120 #define QOS_DATA_NULL 0xc
121 #define DATA_NULL 0x04
122 #define FRAME_CONTROL_ORDER_BIT 0x8000
123 #define FRAME_CONTROL_TYPE_FIELD_OFFSET  2
124 #define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET  4
125 #define IEEE802_11_FRAMETYPE_DATA 0x02
126 #define IEEE802_11_FRAMETYPE_CONTROL 0x01
127 #define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
128 #define IEEE802_11_FRAMETYPE_RESERVED 0x03
129
130 /* octet offset from start of mac header for certain fields */
131 #define IEEE802_11_ADDR3_OFFSET 16
132 #define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
133 #define IEEE802_11_MAX_DATA_LEN 2304
134
135 /* frame control (FC) masks, for frame control as 16 bit integer */
136 #define IEEE802_11_FC_TO_DS_MASK 0x100
137 #define IEEE802_11_FC_FROM_DS_MASK 0x200
138 #define IEEE802_11_FC_MOREDATA_MASK 0x2000
139 #define IEEE802_11_FC_PROTECTED_MASK 0x4000
140 #define IEEE80211_FC_ORDER_MASK 0x8000
141 #define IEEE80211_FC_SUBTYPE_MASK 0x00f0
142 #define IEEE80211_FC_TYPE_MASK 0x000c
143 #define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
144
145 /*  selected type and subtype combinations as in 7.1.3.1 table 1
146     For frame control as 16 bit integer, or for ls octet
147 */
148 #define IEEE802_11_FC_TYPE_DATA 0x08
149 #define IEEE802_11_FC_TYPE_NULL 0x48
150 #define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
151 #define IEEE802_11_FC_TYPE_QOS_DATA 0x88
152
153 #define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
154
155 /* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
156 #define IEEE802_11_QC_TID_MASK 0x0f
157 #define IEEE802_11_QC_A_MSDU_PRESENT 0x80
158
159 #define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
160 #define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
161 #define MAX_ACCESS_CATOGORY 4
162
163 /* Time in us to check for inactivity of stations 5 mins */
164 #define INACTIVITY_CHECK_INTERVAL   300000000
165 /* Time in us before a station is flagged as inactive */
166 #define MAX_INACTIVITY_INTERVAL     300000000
167
168
169 /* Define for maximum BA session */
170 #define MAX_SUPPORTED_BA_SESSIONS_TX   1
171 #define MAX_SUPPORTED_BA_SESSIONS_RX   4
172
173 #define MAX_BA_WIND_SIZE 64
174 #define MAC_HEADER_ADDR1_OFFSET     4
175 #define MAC_HEADER_ADDR2_OFFSET     10
176
177 /* Define for age (in us) value for frames in MPDU reorder buffer */
178 #define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT  30000 /* 30 milli seconds */
179
180 /* This macro used in prepare_and_add_macheader*/
181 #define ADDRESS_ONE_OFFSET 20
182
183 /* Defines for STA inactivity detection */
184 #define     STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD           1                /* in number of stations */
185 #define     STA_INACTIVE_DETECTION_TIMER_INTERVAL              30               /* in seconds */
186 #define     STA_INACTIVE_TIMEOUT_VAL                           120*1000*1000    /* 120 seconds */
187
188
189 /* Defines used in beacon filtering in case of P2P */
190 #define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH        0x7
191 #define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON      0x8
192 #define CSR_WIFI_BEACON_FIXED_LENGTH             12
193 #define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET        4
194 #define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK    ((CsrUint8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
195
196 #define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
197     ((CsrUint8)(((CsrUint8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
198
199 /* For M4 request received via netdev*/
200
201 typedef CsrUint8 CsrWifiPacketType;
202 #define CSR_WIFI_UNICAST_PDU   ((CsrWifiPacketType) 0x00)
203 #define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
204 #define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
205
206 #define PRIO_TO_NICE(prio)  ((prio) - MAX_RT_PRIO - 20)
207
208 /* Module parameter variables */
209 extern int buswidth;
210 extern int sdio_clock;
211 extern int use_5g;
212 extern int disable_hw_reset;
213 extern int disable_power_control;
214 extern int enable_wol;
215 extern int sme_debug;
216 extern int fw_init[MAX_UNIFI_DEVS];
217 extern int tl_80211d;
218 extern int sdio_byte_mode;
219 extern int sdio_block_size;
220 extern int coredump_max;
221 extern int run_bh_once;
222 extern int bh_priority;
223
224 struct dlpriv {
225     const unsigned char *dl_data;
226     int dl_len;
227     void *fw_desc;
228 };
229
230
231 struct uf_thread {
232
233     struct task_struct *thread_task;
234
235     /* wait_queue for waking the unifi_thread kernel thread */
236     wait_queue_head_t wakeup_q;
237     unsigned int wakeup_flag;
238
239     /*
240      * Use it to block the I/O thread when
241      * an error occurs or UniFi is reinitialised.
242      */
243     int block_thread;
244
245     char name[16];
246     int prio;
247 };
248
249 /*
250  * Link list to hold the received packets for the period the port
251  * remains closed.
252  */
253 typedef struct rx_buffered_packets {
254     /* List link structure */
255     struct list_head q;
256     /* Packet to indicate when the port reopens */
257     struct sk_buff *skb;
258     /* Bulkdata to free in case the port closes and need to discard the packet */
259     bulk_data_param_t bulkdata;
260     /* The source address of the packet */
261     CsrWifiMacAddress sa;
262     /* The destination address of the packet */
263     CsrWifiMacAddress da;
264     /* Corresponding signal */
265     CSR_SIGNAL signal;
266 } rx_buffered_packets_t;
267
268
269 typedef CsrUint8 CsrWifiAcPowersaveMode;
270 #define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
271 #define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
272 #define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
273 #define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
274
275
276 #define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
277 #define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
278 #define IS_DTIM_ACTIVE(flag,hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
279 #define INVALID_HOST_TAG 0xFFFFFFFF
280 #define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
281
282
283
284
285 /* Queue to be used for contention priority */
286
287 /*
288  * Link list to hold the tx packets for the period the peer
289  * powersave/free slots in unifi
290  */
291 typedef struct tx_buffered_packets {
292     /* List link structure */
293     struct list_head q;
294     CsrUint16 interfaceTag;
295     CSR_CLIENT_TAG hostTag;
296     CSR_PROCESS_ID leSenderProcessId;
297     CSR_TRANSMISSION_CONTROL transmissionControl;
298     CSR_RATE rate;
299     /* Bulkdata to free in case the port closes and need to discard the packet */
300     bulk_data_desc_t bulkdata;
301     /* The source address of the packet */
302     CsrWifiMacAddress peerMacAddress;
303     CSR_PRIORITY priority;
304 } tx_buffered_packets_t;
305
306 /* station record has this data structure */
307 typedef struct CsrWifiRouterCtrlStaInfo_t {
308
309     /* Sme sends these parameters */
310     CsrWifiMacAddress peerMacAddress;
311     CsrUint32 assignedHandle;
312     CsrBool wmmOrQosEnabled;
313     CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
314     CsrUint16 maxSpLength;
315     CsrBool uapsdActive;
316     CsrUint16 noOfSpFramesSent;
317
318     /* Router/Driver database */
319 #ifdef CSR_SUPPORT_SME
320     unifi_port_cfg_t *peerControlledPort;
321     unifi_port_cfg_t *peerUnControlledPort;
322
323     /* Inactivity feature parameters */
324     struct netInterface_priv *interfacePriv;
325     struct work_struct send_disconnected_ind_task;
326     CsrBool activity_flag;
327     CsrUint16 listenIntervalInTus;
328     CSR_CLIENT_TAG nullDataHostTag;
329
330     /* Activity timestamps for the station */
331     CsrTime lastActivity;
332
333     /* during m/c transmission sp suspended */
334     CsrBool uapsdSuspended;
335 #endif
336     CsrWifiRouterCtrlPeerStatus currentPeerState;
337     struct list_head dataPdu[MAX_ACCESS_CATOGORY];
338     struct list_head mgtFrames;
339     CsrUint8 spStatus;
340     CsrUint8 prevFrmType;
341     CsrUint8 prevFrmAccessCatogory;
342     CsrBool protection;
343     CsrUint16 aid;
344     CsrBool txSuspend;
345     CsrUint8 timSet;
346     /* Dont change the value of below macro for SET & RESET */
347 #define CSR_WIFI_TIM_RESET       0
348 #define CSR_WIFI_TIM_SET         1
349 #define CSR_WIFI_TIM_RESETTING   2
350 #define CSR_WIFI_TIM_SETTING     3
351
352     CsrUint16 noOfPktQueued;
353 }CsrWifiRouterCtrlStaInfo_t;
354
355 #ifdef CSR_SUPPORT_WEXT_AP
356 struct CsrWifiSmeApConfig {
357     CsrWifiSsid ssid;
358     CsrUint16 channel;
359     CsrWifiNmeApCredentials credentials;
360     CsrUint8 max_connections;
361     CsrUint8 if_index;
362 };
363 #endif
364
365 #ifdef CSR_WIFI_RX_PATH_SPLIT
366 /* This is a test code and may be removed later*/
367 #define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE    (60+1)
368
369 typedef struct
370 {
371     CsrUint8 *bufptr; /* Signal Primitive */
372     bulk_data_param_t data_ptrs; /* Bulk Data pointers */
373     CsrUint16 sig_len;
374 }rx_buff_struct_t;
375
376 typedef struct
377 {
378     CsrUint8 writePointer; /**< write pointer */
379     CsrUint8 readPointer;  /**< read pointer */
380     CsrUint8 size;         /**< size of circular buffer */
381     rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE];    /**< Element of ciruclar buffer */
382 } rxCircularBuffer_t;
383
384 void rx_wq_handler(struct work_struct *work);
385 #endif
386
387 struct unifi_priv {
388
389     card_t *card;
390     CsrSdioFunction *sdio;
391
392     /* Index into Unifi_instances[] for this device. */
393     int instance;
394     /* Reference count for this instance */
395     int ref_count;
396
397     /* Firmware images */
398     struct dlpriv fw_sta;
399     struct dlpriv fw_conv;  /* used for conversion of production test image */
400
401     /* Char device related structures */
402     struct cdev unifi_cdev;
403     struct cdev unifiudi_cdev;
404     struct device *unifi_device;
405
406     /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
407     CSR_IFINTERFACE if_index;
408
409     /* For multiple interface support */
410     struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
411     struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
412
413     CsrUint8 totalInterfaceCount;
414
415     int prev_queue;
416
417     /* Name of node under /proc */
418     char proc_entry_name[64];
419
420     /*
421      * Flags:
422      *  drop_unencrypted
423      *                - Not used?
424      *  netdev_registered
425      *                - whether the netdev has been registered.
426      */
427     unsigned int drop_unencrypted       : 1;
428
429     /* Our list of unifi linux clients. */
430     ul_client_t ul_clients[MAX_UDI_CLIENTS];
431
432     /* Mutex to protect using the logging hook after UDI client is gone */
433     struct semaphore udi_logging_mutex;
434     /* Pointer to the ul_clients[] array */
435     ul_client_t *logging_client;
436
437     /* A ul_client_t* used to send the netdev related MIB requests. */
438     ul_client_t *netdev_client;
439
440     /* The SME ul_client_t pointer. */
441     ul_client_t *sme_cli;
442
443     /* The AMP ul_client_t pointer. */
444     ul_client_t *amp_client;
445
446     /*
447      * Semaphore for locking the top-half to one user process.
448      * This is necessary to prevent multiple processes calling driver
449      * operations. This can happen because the network driver entry points
450      * can be called from multiple processes.
451      */
452 #ifdef USE_DRIVER_LOCK
453     struct semaphore lock;
454 #endif /* USE_DRIVER_LOCK */
455
456     /* Flag to say that an operation was aborted */
457     int io_aborted;
458
459     struct uf_thread bh_thread;
460
461 #define UNIFI_INIT_NONE         0x00
462 #define UNIFI_INIT_IN_PROGRESS  0x01
463 #define UNIFI_INIT_FW_DOWNLOADED 0x02
464 #define UNIFI_INIT_COMPLETED    0x04
465     unsigned char init_progress;
466
467     int sme_is_present;
468
469     /* The WMM features that UniFi uses in the current BSS */
470     unsigned int sta_wmm_capabilities;
471
472     /* Debug only */
473     char last_debug_string[256];
474     unsigned short last_debug_word16[16];
475
476 #ifdef CSR_SUPPORT_SME
477   /* lock to protect the tx queues list */
478     spinlock_t tx_q_lock;
479     CsrUint8 allPeerDozing;
480     CsrUint8 pausedStaHandle[MAX_ACCESS_CATOGORY];
481     /* Max packet the driver can queue, irrespective of interface number */
482     CsrUint16 noOfPktQueuedInDriver;
483 #define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
484 #define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
485 #define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
486
487     CsrBool routerBufferEnable[MAX_ACCESS_CATOGORY];
488     /* lock to protect stainfo members and priv members*/
489     spinlock_t staRecord_lock;
490 #endif
491 #ifdef CSR_NATIVE_LINUX
492 #ifdef CSR_SUPPORT_WEXT
493     /* wireless config */
494     struct wext_config wext_conf;
495 #endif
496
497     /* Mutex to protect the MLME blocking requests */
498     struct semaphore mlme_blocking_mutex;
499
500     /* The ul_client that provides the blocking API for WEXT calls */
501     ul_client_t *wext_client;
502
503 #endif /* CSR_NATIVE_LINUX */
504
505 #ifdef CSR_SUPPORT_SME
506     wait_queue_head_t sme_request_wq;
507     /* Semaphore to protect the SME blocking requests */
508     struct semaphore sme_sem;
509     /* Structure to hold the SME blocking requests data*/
510     sme_reply_t sme_reply;
511
512     /* Structure to hold a traffic protocol indication */
513     struct ta_ind {
514         struct work_struct task;
515         CsrWifiRouterCtrlTrafficPacketType packet_type;
516         CsrWifiRouterCtrlProtocolDirection direction;
517         CsrWifiMacAddress src_addr;
518         int in_use;
519     } ta_ind_work;
520
521     struct ta_sample_ind {
522         struct work_struct task;
523         CsrWifiRouterCtrlTrafficStats stats;
524         int in_use;
525     } ta_sample_ind_work;
526
527     __be32 sta_ip_address;
528     CsrWifiRouterCtrlSmeVersions    sme_versions;
529
530     /*
531      * Flag to reflect state of unifi_sys_wifi_on_*() progress.
532      * This indicates whether we are in an "wifi on" state when we are
533      * allowed to indication errors with unifi_mgt_wifi_off_ind()
534      */
535     enum {
536         wifi_on_unspecified = -1,
537         wifi_on_in_progress = 0,
538         wifi_on_done = 1,
539     } wifi_on_state;
540
541     /* Userspace TaskId for the SME Set when a wifi on req is received */
542     CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
543
544     struct work_struct multicast_list_task;
545     /*
546      * The SME installs filters to ask for specific MA-UNITDATA.req
547      * to be passed to different SME components.
548      */
549 #define MAX_MA_UNIDATA_IND_FILTERS      8
550     sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
551
552 /* UNIFI_CFG related parameters */
553     uf_cfg_bcast_packet_filter_t packet_filters;
554     unsigned char *filter_tclas_ies;
555  /* The structure that holds all the connection configuration. */
556     CsrWifiSmeConnectionConfig connection_config;
557 #ifdef CSR_SUPPORT_WEXT
558
559     int ignore_bssid_join;
560     struct iw_statistics wext_wireless_stats;
561
562     /* The MIB and MAC address files contents, read from userspace */
563     CsrWifiSmeDataBlock mib_data;
564     CsrWifiMacAddress sta_mac_address;
565
566     int wep_tx_key_index;
567     wep_key_t wep_keys[NUM_WEPKEYS];
568
569
570 #ifdef CSR_SUPPORT_WEXT_AP
571     CsrWifiSmeApMacConfig ap_mac_config;
572     CsrWifiNmeApConfig group_sec_config;
573     CsrWifiSmeApConfig_t ap_config;
574 #endif
575     struct work_struct sme_config_task;
576
577 #endif /* CSR_SUPPORT_WEXT */
578
579 #endif /* CSR_SUPPORT_SME */
580
581 #ifdef CSR_SME_USERSPACE
582     void *smepriv;
583 #endif /* CSR_SME_USERSPACE */
584
585     card_info_t card_info;
586
587     /* Mutex to protect unifi_send_signal() */
588     spinlock_t send_signal_lock;
589
590
591     /*
592      * The workqueue to offload the TA run
593      * and the multicast addresses list set
594      */
595     struct workqueue_struct *unifi_workqueue;
596
597     unsigned char *mib_cfm_buffer;
598     unsigned int mib_cfm_buffer_length;
599
600     int ptest_mode;     /* Set when in production test mode */
601     int coredump_mode;  /* Set when SME has requested a coredump */
602     CsrBool wol_suspend; /* Set when suspending with UniFi powered */
603
604 #define UF_UNCONTROLLED_PORT_Q      0
605 #define UF_CONTROLLED_PORT_Q        1
606
607     /* Semaphore to protect the rx queues list */
608     struct semaphore rx_q_sem;
609
610     /* Spinlock to protect M4 data */
611     spinlock_t m4_lock;
612     /* Spinlock to protect BA RX data */
613     spinlock_t ba_lock;
614 #ifndef ALLOW_Q_PAUSE
615     /* Array to indicate if a particular Tx queue is paused, this may not be
616      * required in a multiqueue implementation since we can directly stop kernel
617      * queues */
618     CsrUint8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
619 #endif
620
621 #ifdef CSR_WIFI_RX_PATH_SPLIT
622     struct workqueue_struct *rx_workqueue;
623     struct work_struct rx_work_struct;
624     rxCircularBuffer_t rxSignalBuffer;
625
626 #endif
627
628     CsrUint32 rxTcpThroughput;
629     CsrUint32 txTcpThroughput;
630     CsrUint32 rxUdpThroughput;
631     CsrUint32 txUdpThroughput;
632
633
634     CsrUint8 wapi_multicast_filter;
635     CsrUint8 wapi_unicast_filter;
636     CsrUint8 wapi_unicast_queued_pkt_filter;
637 };
638
639 typedef struct {
640     CsrUint16 queue_length[4];
641     CsrUint8 os_queue_paused;
642 } unifi_OsQosInfo;
643
644
645 typedef struct {
646     CsrBool active;
647     bulk_data_param_t bulkdata;
648     CSR_SIGNAL signal;
649     CsrUint16 sn;
650     CsrTime recv_time;
651 } frame_desc_struct;
652
653 typedef struct {
654     frame_desc_struct *buffer;
655     CsrUint16 wind_size;
656     CsrUint16 occupied_slots;
657     struct timer_list timer;
658     CsrUint16 timeout;
659     CsrUint16 expected_sn;
660     CsrUint16 start_sn;
661     CsrBool   trigger_ba_after_ssn;
662     struct netInterface_priv *interfacePriv;
663     CsrUint16 tID;
664     CsrWifiMacAddress macAddress;
665     struct work_struct send_ba_err_task;
666 } ba_session_rx_struct;
667
668
669 typedef struct {
670     struct netInterface_priv *interfacePriv;
671     CsrUint16 tID;
672     CsrWifiMacAddress macAddress;
673 } ba_session_tx_struct;
674
675 typedef struct netInterface_priv
676 {
677     CsrUint16 InterfaceTag;
678     struct unifi_priv *privPtr;
679     ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
680     ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
681     frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
682     CsrUint8 ba_complete_index;
683     CsrUint8 queueEnabled[UNIFI_NO_OF_TX_QS];
684     struct work_struct send_m4_ready_task;
685     struct net_device_stats stats;
686     CsrUint8 interfaceMode;
687     CsrBool protect;
688     CsrWifiMacAddress bssid;
689     /*
690     * Flag to reflect state of CONNECTED indication signal.
691     * This indicates whether we are "joined" an Access Point (i.e. have
692     * nominated an AP and are receiving beacons) but give no indication
693     * of whether we are authenticated and/or associated.
694     */
695     enum {
696         UnifiConnectedUnknown = -1,
697         UnifiNotConnected = 0,
698         UnifiConnected = 1,
699     } connected;
700 #ifdef CSR_SUPPORT_WEXT
701     /* Tracks when we are waiting for a netdevice state change callback */
702     CsrBool wait_netdev_change;
703     /* True if we have successfully registered for netdev callbacks */
704     CsrBool netdev_callback_registered;
705 #endif /* CSR_SUPPORT_WEXT */
706     unsigned int netdev_registered;
707 #define UNIFI_MAX_MULTICAST_ADDRESSES 10
708     /* The multicast addresses list that the thread needs to set. */
709     u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
710     /* The multicast addresses count that the thread needs to set. */
711     int mc_list_count;
712     CsrUint32 tag;
713 #ifdef CSR_SUPPORT_SME
714     /* (un)controlled port configuration */
715     unifi_port_config_t controlled_data_port;
716     unifi_port_config_t uncontrolled_data_port;
717
718     /* station record maintenance related data structures */
719     CsrUint8 num_stations_joined;
720     CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
721     struct list_head genericMgtFrames;
722     struct list_head genericMulticastOrBroadCastFrames;
723     struct list_head genericMulticastOrBroadCastMgtFrames;
724     struct list_head directedMaPktReq;
725
726     /* Timer for detecting station inactivity */
727     struct timer_list sta_activity_check_timer;
728     CsrBool sta_activity_check_enabled;
729
730     /* Timestamp when the last inactivity check was done */
731     CsrTime last_inactivity_check;
732
733     /*number of multicast or borad cast packets  queued*/
734     CsrUint16 noOfbroadcastPktQueued;
735 #endif
736     /* A list to hold the buffered uncontrolled port packets */
737     struct list_head rx_uncontrolled_list;
738     /* A list to hold the buffered controlled port packets */
739     struct list_head rx_controlled_list;
740     /* Buffered M4 signal to take care of WPA race condition */
741     CSR_SIGNAL m4_signal;
742     bulk_data_desc_t m4_bulk_data;
743     /* This should be removed and m4_hostTag should be used for checking*/
744     CsrBool m4_sent;
745     CSR_CLIENT_TAG m4_hostTag;
746     CsrBool dtimActive;
747     CsrBool intraBssEnabled;
748     CsrUint32 multicastPduHostTag; /* Used to set the tim after getting
749        a confirm for it */
750 } netInterface_priv_t;
751
752 typedef struct maPktReqList{
753     struct list_head q;
754     struct sk_buff *skb;
755     CSR_SIGNAL signal;
756     CSR_CLIENT_TAG hostTag;
757     CsrUint32 staHandler;
758     unsigned long jiffeTime;
759 }maPktReqList_t;
760
761 #ifndef ALLOW_Q_PAUSE
762 #define net_is_tx_q_paused(priv, q)   (priv->tx_q_paused_flag[q])
763 #define net_tx_q_unpause(priv, q)   (priv->tx_q_paused_flag[q] = 0)
764 #define net_tx_q_pause(priv, q)   (priv->tx_q_paused_flag[q] = 1)
765 #endif
766
767 #ifdef CSR_SUPPORT_SME
768 #define routerStartBuffering(priv,queue) priv->routerBufferEnable[(queue)] = TRUE;
769 #define routerStopBuffering(priv,queue) priv->routerBufferEnable[(queue)]  = FALSE;
770 #define isRouterBufferEnabled(priv,queue) priv->routerBufferEnable[(queue)]
771 #endif
772
773 #ifdef USE_DRIVER_LOCK
774 #define LOCK_DRIVER(_p)         down_interruptible(&(_p)->lock)
775 #define UNLOCK_DRIVER(_p)       up(&(_p)->lock)
776 #else
777 #define LOCK_DRIVER(_p)         (void)(_p); /* as nothing */
778 #define UNLOCK_DRIVER(_p)       (void)(_p); /* as nothing */
779 #endif /* USE_DRIVER_LOCK */
780
781 CsrInt32 CsrHipResultToStatus(CsrResult csrResult);
782
783
784 /*
785  * SDIO related functions and callbacks
786  */
787 int  uf_sdio_load(void);
788 void uf_sdio_unload(void);
789 unifi_priv_t *uf_find_instance(int inst);
790 int uf_find_priv(unifi_priv_t *priv);
791 int uf_find_netdev_priv(netInterface_priv_t *priv);
792 unifi_priv_t *uf_get_instance(int inst);
793 void uf_put_instance(int inst);
794 int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
795 int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
796
797 void uf_add_os_device(int bus_id, struct device *os_device);
798 void uf_remove_os_device(int bus_id);
799
800
801
802 /*
803  * Claim/release SDIO
804  *
805  * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
806  * as this prevents other functions using SDIO.
807  * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
808  * we have followed this scheme:
809  * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
810  *    then we call CsrSdioClaim/CsrSdioRelease().
811  * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
812  *    then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
813  *    to the SDIO glue layer only (e.g. sdio_mmc.c).
814  * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
815  *    then we call directly the sdio_claim_host/sdio_release_host().
816  *    Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
817  *
818  * Note: The _func and function pointers are _not_ the same.
819  * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
820  * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
821  */
822
823 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
824
825 #ifdef CSR_WIFI_SINGLE_FUNCTION
826 #define CsrSdioClaim(function)    sdio_claim_host((function)->priv);
827 #define CsrSdioRelease(function)  sdio_release_host((function)->priv);
828
829 #define _sdio_claim_host(_func)
830 #define _sdio_release_host(_func)
831
832 #else
833 #define CsrSdioClaim(function)
834 #define CsrSdioRelease(function)
835
836 #define _sdio_claim_host(_func)     sdio_claim_host(_func)
837 #define _sdio_release_host(_func)   sdio_release_host(_func)
838
839 #endif /* CSR_WIFI_SINGLE_FUNCTION */
840
841 #else
842 #define _sdio_claim_host(_func)
843 #define _sdio_release_host(_func)
844
845 #define CsrSdioClaim(function)
846 #define CsrSdioRelease(function)
847
848 #endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
849
850
851 /*
852  * Functions to allocate and free an ethernet device.
853  */
854 unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
855 int uf_free_netdevice(unifi_priv_t *priv);
856
857 /* Allocating function for other interfaces */
858 CsrBool uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, CsrUint16 interfaceTag);
859
860 /*
861  * Firmware download related functions.
862  */
863 int uf_run_unifihelper(unifi_priv_t *priv);
864 int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
865 int uf_release_firmware_files(unifi_priv_t *priv);
866 int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
867
868 /*
869  * Functions to create and delete the device nodes.
870  */
871 int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
872 void uf_destroy_device_nodes(unifi_priv_t *priv);
873
874 /*
875  * Upper Edge Initialisation functions
876  */
877 int uf_init_bh(unifi_priv_t *priv);
878 int uf_init_hw(unifi_priv_t *priv);
879
880 /* Thread related helper functions */
881 int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
882 void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
883 void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
884
885
886 /*
887  * Unifi Linux functions
888  */
889 void ul_init_clients(unifi_priv_t *priv);
890
891 /* Configuration flags */
892 #define CLI_USING_WIRE_FORMAT   0x0002
893 #define CLI_SME_USERSPACE       0x0020
894 ul_client_t *ul_register_client(unifi_priv_t *priv,
895         unsigned int configuration,
896         udi_event_t udi_event_clbk);
897 int ul_deregister_client(ul_client_t *pcli);
898
899 int ul_send_signal_unpacked(unifi_priv_t *priv,
900                             CSR_SIGNAL *sigptr,
901                             bulk_data_param_t *bulkdata);
902 int ul_send_signal_raw(unifi_priv_t *priv,
903                        unsigned char *sigptr, int siglen,
904                        bulk_data_param_t *bulkdata);
905
906 void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
907
908
909 /*
910  * Data plane operations
911  */
912 /*
913  *      data_tx.c
914  */
915 int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
916         unsigned int length);
917
918 #ifdef CSR_SUPPORT_SME
919 CsrBool uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
920 CsrBool uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,CsrUint8 pmBit,CsrUint16 interfaceTag);
921 void uf_process_ps_poll(unifi_priv_t *priv,CsrUint8* sa,CsrUint8* da,CsrUint8 pmBit,CsrUint16 interfaceTag);
922 int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
923                    struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
924                    const CSR_SIGNAL *signal,
925                    bulk_data_param_t *bulkdata,
926                    CsrUint8 macHeaderLengthInBytes);
927 CsrBool uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
928 CsrBool uf_is_more_data_for_delivery_ac(unifi_priv_t *priv,CsrWifiRouterCtrlStaInfo_t *staRecord,CsrBool mgtCheck);
929 void uf_process_wmm_deliver_ac_uapsd (  unifi_priv_t * priv,
930                                         CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
931                                         CsrUint16 qosControl,
932                                         CsrUint16 interfaceTag);
933
934 void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, CsrUint8 queue, struct list_head *txList);
935 void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, CsrUint8 queue, struct list_head *txList);
936
937 void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
938 void uf_send_qos_null(unifi_priv_t * priv,CsrUint16 interfaceTag, const CsrUint8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
939 void uf_send_nulldata(unifi_priv_t * priv,CsrUint16 interfaceTag, const CsrUint8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
940 void uf_store_directed_ma_packet_referenece(unifi_priv_t *priv, bulk_data_param_t *bulkdata,CSR_SIGNAL *sigptr,CsrUint32 alignOffset);
941
942
943
944 #endif
945 CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,  CsrUint8 *peerMacAddress, CSR_CLIENT_TAG hostTag, CsrUint16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, CSR_RATE TransmitRate, CSR_PRIORITY priority, CSR_PROCESS_ID senderId, bulk_data_param_t *bulkdata);
946 void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,CsrUint8 *sigdata, CsrUint32 siglen);
947 #ifdef CSR_SUPPORT_SME
948 void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue queue);
949 int uf_process_station_records_for_sending_data(unifi_priv_t *priv,CsrUint16 interfaceTag,
950                                                  CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
951                                                  CsrWifiRouterCtrlStaInfo_t *dstStaInfo);
952 void 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);
955 void send_auto_ma_packet_confirm(unifi_priv_t *priv,
956                                  netInterface_priv_t *interfacePriv,
957                                  struct list_head *buffered_frames_list);
958 void uf_flush_list(unifi_priv_t * priv, struct list_head * list);
959 void uf_flush_maPktlist(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, CsrUint16 interfaceTag);
962 void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,CsrUint16 interfaceTag);
963 void resume_suspended_uapsd(unifi_priv_t* priv,CsrUint16 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 */
977     u16 protocol;
978 } __attribute__ ((packed)) llc_snap_hdr_t;
979 int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto);
980 int 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
985 const char *result_code_str(int result);
986
987
988 /* prepares & appends the Mac header for the payload */
989 int 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                               CsrUint16 interfaceTag,
995                               const CsrUint8 *daddr,
996                               const CsrUint8 *saddr,
997                               CsrBool protection);
998 CSR_PRIORITY
999 get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
1000
1001 void
1002 unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
1003                           CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
1004                           CsrUint16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
1005                           CSR_PROCESS_ID leSenderProcessId, CsrUint8 *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) (CsrUint8) ((receiverProcessId & 0xff) >> 2)
1013 /* get the timSet status from the sender ID */
1014 #define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId)  (CsrUint8) (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, CsrUint16 aid, CsrUint8 setTim, CsrUint16 interfaceTag, CsrUint32 handle);
1020 void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, CsrUint16 senderProcessId);
1021
1022 /* Clear the Peer station Record, in case of wifioff/unexpected card removal */
1023 void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, CsrUint16 interfaceTag);
1024
1025 void scroll_ba_window(unifi_priv_t *priv,
1026                       netInterface_priv_t *interfacePriv,
1027                       ba_session_rx_struct *ba_session,
1028                       CsrUint16 sn);
1029
1030 CsrBool blockack_session_stop(unifi_priv_t *priv,
1031                               CsrUint16 interfaceTag,
1032                               CsrWifiRouterCtrlBlockAckRole role,
1033                               CsrUint16 tID,
1034                               CsrWifiMacAddress macAddress);
1035 #ifdef CSR_SUPPORT_SME
1036 /* Fetch the protection information from interface Mode */
1037 CsrInt8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, CsrUint16 interfaceTag, const CsrUint8 *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 CsrUint8 *peerMacAddress,
1044                                                                                 CsrUint16 interfaceTag);
1045
1046 /* Fetch the station record handler from data base for matching handle */
1047 CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
1048                                                                  CsrUint32 handle,
1049                                                                  CsrUint16 interfaceTag);
1050
1051 void uf_update_sta_activity(unifi_priv_t *priv, CsrUint16 interfaceTag, const CsrUint8 *peerMacAddress);
1052 void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,CsrUint16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
1053 #endif
1054 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
1055 int uf_install_qdisc(struct net_device *dev);
1056 #endif
1057
1058 void uf_resume_data_plane(unifi_priv_t *priv, int queue,
1059                           CsrWifiMacAddress peer_address,
1060                           CsrUint16 interfaceTag);
1061 void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
1062         CsrWifiMacAddress peer_address,CsrUint16 interfaceTag);
1063
1064 int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
1065 void uf_unregister_netdev(unifi_priv_t *priv);
1066
1067 void uf_net_get_name(struct net_device *dev, char *name, int len);
1068
1069 void uf_send_queue_info(unifi_priv_t *priv);
1070 CsrUint16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, CsrUint16 tag);
1071
1072 void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
1073                                  CsrWifiMacAddress source_address,
1074                                  int indicate, CsrUint16 interfaceTag);
1075
1076 /*
1077  *      inet.c
1078  */
1079 void uf_register_inet_notifier(void);
1080 void uf_unregister_inet_notifier(void);
1081
1082
1083 /*
1084  * Suspend / Resume handlers
1085  */
1086 void unifi_resume(void *ospriv);
1087 void unifi_suspend(void *ospriv);
1088
1089
1090 #define QOS_CAPABILITY_WMM_ENABLED      0x0001
1091 #define QOS_CAPABILITY_WMM_UAPSD        0x0002
1092 #define QOS_CAPABILITY_ACM_BE_ENABLED   0x0010
1093 #define QOS_CAPABILITY_ACM_BK_ENABLED   0x0020
1094 #define QOS_CAPABILITY_ACM_VI_ENABLED   0x0040
1095 #define QOS_CAPABILITY_ACM_VO_ENABLED   0x0080
1096 #define QOS_CAPABILITY_TS_BE_ENABLED    0x0100
1097 #define QOS_CAPABILITY_TS_BK_ENABLED    0x0200
1098 #define QOS_CAPABILITY_TS_VI_ENABLED    0x0400
1099 #define QOS_CAPABILITY_TS_VO_ENABLED    0x0800
1100
1101
1102 /* EAPOL PDUS */
1103 #ifndef ETH_P_PAE
1104 #define ETH_P_PAE 0x888e
1105 #endif
1106 #ifndef ETH_P_WAI
1107 #define ETH_P_WAI 0x88b4
1108 #endif
1109 /*
1110  * unifi_dbg.c
1111  */
1112 void debug_string_indication(unifi_priv_t *priv,
1113         const unsigned char *extra,
1114         unsigned int extralen);
1115 void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1116 void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1117
1118
1119 /*
1120  * putest.c
1121  */
1122 int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
1123 int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
1124 int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
1125 int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
1126 int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
1127 int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
1128 int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
1129 int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
1130 int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
1131
1132 int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
1133 int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
1134
1135
1136 /* Macro for formatting a MAC address with a prefix string */
1137 #define UF_TRACE_MAC(priv, lvl, msg, addr) \
1138         unifi_trace(priv, lvl, \
1139                                 "%s %02x-%02x-%02x-%02x-%02x-%02x\n", \
1140                                 msg,    \
1141                                 *(((CsrUint8 *)addr)+0),  \
1142                                 *(((CsrUint8 *)addr)+1),  \
1143                                 *(((CsrUint8 *)addr)+2),  \
1144                                 *(((CsrUint8 *)addr)+3),  \
1145                                 *(((CsrUint8 *)addr)+4),  \
1146                                 *(((CsrUint8 *)addr)+5))
1147
1148 #endif /* __LINUX_UNIFI_PRIV_H__ */