2 *****************************************************************************
6 * PURPOSE : Private header file for unifi driver.
8 * UDI = UniFi Debug Interface
10 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
12 * Refer to LICENSE.txt included with this source code for details on
15 *****************************************************************************
17 #ifndef __LINUX_UNIFI_PRIV_H__
18 #define __LINUX_UNIFI_PRIV_H__ 1
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>
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 */
46 #include <linux/wakelock.h>
49 #include "csr_wifi_hip_unifi.h"
50 #include "csr_wifi_hip_unifi_udi.h"
51 #include "csr_wifi_router_lib.h"
53 #ifndef CSR_WIFI_HIP_TA_DISABLE
54 #include "csr_wifi_vif_utils.h"
57 /* Define the unifi_priv_t before include the unifi_native.h */
59 typedef struct unifi_priv unifi_priv_t;
60 #ifdef CSR_SUPPORT_WEXT_AP
61 struct CsrWifiSmeApConfig;
62 typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
64 #ifdef CSR_SUPPORT_WEXT
65 #include "unifi_wext.h"
69 extern struct wake_lock unifi_sdio_wake_lock;
72 #include "unifi_clients.h"
74 #ifdef CSR_NATIVE_LINUX
75 #include "sme_native/unifi_native.h"
77 #include "unifi_sme.h"
80 /* The device major number to use when registering the udi driver */
81 #define UNIFI_NAME "unifi"
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
88 #define MAX_UNIFI_DEVS 2
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
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
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
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
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
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
128 #define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
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
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
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
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
148 /* Define for maximum BA session */
149 #define MAX_SUPPORTED_BA_SESSIONS_TX 1
150 #define MAX_SUPPORTED_BA_SESSIONS_RX 4
152 #define MAX_BA_WIND_SIZE 64
153 #define MAC_HEADER_ADDR1_OFFSET 4
154 #define MAC_HEADER_ADDR2_OFFSET 10
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 */
159 /* This macro used in prepare_and_add_macheader*/
160 #define ADDRESS_ONE_OFFSET 20
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 */
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)
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))
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)
181 /* For M4 request received via netdev*/
183 typedef u8 CsrWifiPacketType;
184 #define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00)
185 #define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
186 #define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
188 #define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
190 /* Module parameter variables */
192 extern int sdio_clock;
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;
210 const unsigned char *dl_data;
218 struct task_struct *thread_task;
220 /* wait_queue for waking the unifi_thread kernel thread */
221 wait_queue_head_t wakeup_q;
222 unsigned int wakeup_flag;
225 * Use it to block the I/O thread when
226 * an error occurs or UniFi is reinitialised.
235 * Link list to hold the received packets for the period the port
238 typedef struct rx_buffered_packets {
239 /* List link structure */
241 /* Packet to indicate when the port reopens */
243 /* Bulkdata to free in case the port closes and need to discard the packet */
244 bulk_data_param_t bulkdata;
245 /* The source address of the packet */
246 CsrWifiMacAddress sa;
247 /* The destination address of the packet */
248 CsrWifiMacAddress da;
249 /* Corresponding signal */
251 } rx_buffered_packets_t;
254 typedef u8 CsrWifiAcPowersaveMode;
255 #define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
256 #define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
257 #define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
258 #define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
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
270 /* Queue to be used for contention priority */
273 * Link list to hold the tx packets for the period the peer
274 * powersave/free slots in unifi
276 typedef struct tx_buffered_packets {
277 /* List link structure */
280 CSR_CLIENT_TAG hostTag;
281 CSR_PROCESS_ID leSenderProcessId;
282 CSR_TRANSMISSION_CONTROL transmissionControl;
284 /* Bulkdata to free in case the port closes and need to discard the packet */
285 bulk_data_desc_t bulkdata;
286 /* The source address of the packet */
287 CsrWifiMacAddress peerMacAddress;
288 CSR_PRIORITY priority;
289 } tx_buffered_packets_t;
291 /* station record has this data structure */
292 typedef struct CsrWifiRouterCtrlStaInfo_t {
294 /* Sme sends these parameters */
295 CsrWifiMacAddress peerMacAddress;
298 CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
301 u16 noOfSpFramesSent;
303 /* Router/Driver database */
304 #ifdef CSR_SUPPORT_SME
305 unifi_port_cfg_t *peerControlledPort;
306 unifi_port_cfg_t *peerUnControlledPort;
308 /* Inactivity feature parameters */
309 struct netInterface_priv *interfacePriv;
310 struct work_struct send_disconnected_ind_task;
312 u16 listenIntervalInTus;
313 CSR_CLIENT_TAG nullDataHostTag;
315 /* Activity timestamps for the station */
316 CsrTime lastActivity;
318 /* during m/c transmission sp suspended */
320 CSR_PRIORITY triggerFramePriority;
322 CsrWifiRouterCtrlPeerStatus currentPeerState;
323 struct list_head dataPdu[MAX_ACCESS_CATOGORY];
324 struct list_head mgtFrames;
327 u8 prevFrmAccessCatogory;
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
338 u8 timRequestPendingFlag;
339 u8 updateTimReqQueued;
341 }CsrWifiRouterCtrlStaInfo_t;
343 #ifdef CSR_SUPPORT_WEXT_AP
344 struct CsrWifiSmeApConfig {
347 CsrWifiNmeApCredentials credentials;
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)
359 u8 *bufptr; /* Signal Primitive */
360 bulk_data_param_t data_ptrs; /* Bulk Data pointers */
366 u8 writePointer; /**< write pointer */
367 u8 readPointer; /**< read pointer */
368 u8 size; /**< size of circular buffer */
369 rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE]; /**< Element of ciruclar buffer */
370 } rxCircularBuffer_t;
372 void rx_wq_handler(struct work_struct *work);
378 CsrSdioFunction *sdio;
380 /* Index into Unifi_instances[] for this device. */
382 /* Reference count for this instance */
385 /* Firmware images */
386 struct dlpriv fw_sta;
387 struct dlpriv fw_conv; /* used for conversion of production test image */
389 /* Char device related structures */
390 struct cdev unifi_cdev;
391 struct cdev unifiudi_cdev;
392 struct device *unifi_device;
394 /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
395 CSR_IFINTERFACE if_index;
397 /* For multiple interface support */
398 struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
399 struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
401 u8 totalInterfaceCount;
405 /* Name of node under /proc */
406 char proc_entry_name[64];
413 * - whether the netdev has been registered.
415 unsigned int drop_unencrypted : 1;
417 /* Our list of unifi linux clients. */
418 ul_client_t ul_clients[MAX_UDI_CLIENTS];
420 /* Mutex to protect using the logging hook after UDI client is gone */
421 struct semaphore udi_logging_mutex;
422 /* Pointer to the ul_clients[] array */
423 ul_client_t *logging_client;
425 /* A ul_client_t* used to send the netdev related MIB requests. */
426 ul_client_t *netdev_client;
428 /* The SME ul_client_t pointer. */
429 ul_client_t *sme_cli;
431 /* The AMP ul_client_t pointer. */
432 ul_client_t *amp_client;
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.
440 #ifdef USE_DRIVER_LOCK
441 struct semaphore lock;
442 #endif /* USE_DRIVER_LOCK */
444 /* Flag to say that an operation was aborted */
447 struct uf_thread bh_thread;
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;
457 /* The WMM features that UniFi uses in the current BSS */
458 unsigned int sta_wmm_capabilities;
461 char last_debug_string[256];
462 unsigned short last_debug_word16[16];
464 #ifdef CSR_SUPPORT_SME
465 /* lock to protect the tx queues list */
466 spinlock_t tx_q_lock;
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
475 u8 routerBufferEnable[MAX_ACCESS_CATOGORY];
476 /* lock to protect stainfo members and priv members*/
477 spinlock_t staRecord_lock;
479 #ifdef CSR_NATIVE_LINUX
480 #ifdef CSR_SUPPORT_WEXT
481 /* wireless config */
482 struct wext_config wext_conf;
485 /* Mutex to protect the MLME blocking requests */
486 struct semaphore mlme_blocking_mutex;
488 /* The ul_client that provides the blocking API for WEXT calls */
489 ul_client_t *wext_client;
491 #endif /* CSR_NATIVE_LINUX */
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;
500 /* Structure to hold a traffic protocol indication */
502 struct work_struct task;
503 CsrWifiRouterCtrlTrafficPacketType packet_type;
504 CsrWifiRouterCtrlProtocolDirection direction;
505 CsrWifiMacAddress src_addr;
509 struct ta_sample_ind {
510 struct work_struct task;
511 CsrWifiRouterCtrlTrafficStats stats;
513 } ta_sample_ind_work;
515 __be32 sta_ip_address;
516 CsrWifiRouterCtrlSmeVersions sme_versions;
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()
524 wifi_on_unspecified = -1,
525 wifi_on_in_progress = 0,
529 /* Userspace TaskId for the SME Set when a wifi on req is received */
530 CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
532 struct work_struct multicast_list_task;
534 * The SME installs filters to ask for specific MA-UNITDATA.req
535 * to be passed to different SME components.
537 #define MAX_MA_UNIDATA_IND_FILTERS 8
538 sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
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
547 int ignore_bssid_join;
548 struct iw_statistics wext_wireless_stats;
550 /* The MIB and MAC address files contents, read from userspace */
551 CsrWifiSmeDataBlock mib_data;
552 CsrWifiMacAddress sta_mac_address;
554 int wep_tx_key_index;
555 wep_key_t wep_keys[NUM_WEPKEYS];
558 #ifdef CSR_SUPPORT_WEXT_AP
559 CsrWifiSmeApMacConfig ap_mac_config;
560 CsrWifiNmeApConfig group_sec_config;
561 CsrWifiSmeApConfig_t ap_config;
563 struct work_struct sme_config_task;
565 #endif /* CSR_SUPPORT_WEXT */
567 #endif /* CSR_SUPPORT_SME */
569 #ifdef CSR_SME_USERSPACE
571 #endif /* CSR_SME_USERSPACE */
573 card_info_t card_info;
575 /* Mutex to protect unifi_send_signal() */
576 spinlock_t send_signal_lock;
580 * The workqueue to offload the TA run
581 * and the multicast addresses list set
583 struct workqueue_struct *unifi_workqueue;
585 unsigned char *mib_cfm_buffer;
586 unsigned int mib_cfm_buffer_length;
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 */
592 #define UF_UNCONTROLLED_PORT_Q 0
593 #define UF_CONTROLLED_PORT_Q 1
595 /* Semaphore to protect the rx queues list */
596 struct semaphore rx_q_sem;
598 /* Spinlock to protect M4 data */
600 /* Mutex to protect BA RX data */
601 struct semaphore ba_mutex;
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;
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
611 u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
613 #ifdef CSR_WIFI_RX_PATH_SPLIT
614 struct workqueue_struct *rx_workqueue;
615 struct work_struct rx_work_struct;
616 rxCircularBuffer_t rxSignalBuffer;
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
636 #ifdef CSR_WIFI_SPLIT_PATCH
637 CsrWifiRouterCtrlModeSetReq pending_mode_set;
641 CSR_RATE cmanrTestModeTransmitRate;
653 bulk_data_param_t bulkdata;
660 frame_desc_struct *buffer;
663 struct timer_list timer;
667 u8 trigger_ba_after_ssn;
668 struct netInterface_priv *interfacePriv;
670 CsrWifiMacAddress macAddress;
671 struct work_struct send_ba_err_task;
672 } ba_session_rx_struct;
676 struct netInterface_priv *interfacePriv;
678 CsrWifiMacAddress macAddress;
679 } ba_session_tx_struct;
681 typedef struct netInterface_priv
684 struct unifi_priv *privPtr;
685 ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
686 ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
687 frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
688 u8 ba_complete_index;
689 u8 queueEnabled[UNIFI_NO_OF_TX_QS];
690 struct work_struct send_m4_ready_task;
691 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
692 struct work_struct send_pkt_to_encrypt;
694 struct net_device_stats stats;
697 CsrWifiMacAddress bssid;
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.
705 UnifiConnectedUnknown = -1,
706 UnifiNotConnected = 0,
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. */
718 u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
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;
727 /* station record maintenance related data structures */
728 u8 num_stations_joined;
729 CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
730 struct list_head genericMgtFrames;
731 struct list_head genericMulticastOrBroadCastFrames;
732 struct list_head genericMulticastOrBroadCastMgtFrames;
734 /* Timer for detecting station inactivity */
735 struct timer_list sta_activity_check_timer;
736 u8 sta_activity_check_enabled;
738 /* Timestamp when the last inactivity check was done */
739 CsrTime last_inactivity_check;
741 /*number of multicast or borad cast packets queued*/
742 u16 noOfbroadcastPktQueued;
744 /* A list to hold the buffered uncontrolled port packets */
745 struct list_head rx_uncontrolled_list;
746 /* A list to hold the buffered controlled port packets */
747 struct list_head rx_controlled_list;
748 /* Buffered M4 signal to take care of WPA race condition */
749 CSR_SIGNAL m4_signal;
750 bulk_data_desc_t m4_bulk_data;
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;
758 /* This should be removed and m4_hostTag should be used for checking*/
760 CSR_CLIENT_TAG m4_hostTag;
763 u32 multicastPduHostTag; /* Used to set the tim after getting
766 u8 bcTimSetReqPendingFlag;
767 u8 bcTimSetReqQueued;
768 } netInterface_priv_t;
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)]
776 #ifdef USE_DRIVER_LOCK
777 #define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock)
778 #define UNLOCK_DRIVER(_p) up(&(_p)->lock)
780 #define LOCK_DRIVER(_p) (void)(_p); /* as nothing */
781 #define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */
782 #endif /* USE_DRIVER_LOCK */
784 s32 CsrHipResultToStatus(CsrResult csrResult);
788 * SDIO related functions and callbacks
790 int uf_sdio_load(void);
791 void uf_sdio_unload(void);
792 unifi_priv_t *uf_find_instance(int inst);
793 int uf_find_priv(unifi_priv_t *priv);
794 int uf_find_netdev_priv(netInterface_priv_t *priv);
795 unifi_priv_t *uf_get_instance(int inst);
796 void uf_put_instance(int inst);
797 int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
798 int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
800 void uf_add_os_device(int bus_id, struct device *os_device);
801 void uf_remove_os_device(int bus_id);
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).
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.
826 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
828 #ifdef CSR_WIFI_SINGLE_FUNCTION
829 #define CsrSdioClaim(function) sdio_claim_host((function)->priv);
830 #define CsrSdioRelease(function) sdio_release_host((function)->priv);
832 #define _sdio_claim_host(_func)
833 #define _sdio_release_host(_func)
836 #define CsrSdioClaim(function)
837 #define CsrSdioRelease(function)
839 #define _sdio_claim_host(_func) sdio_claim_host(_func)
840 #define _sdio_release_host(_func) sdio_release_host(_func)
842 #endif /* CSR_WIFI_SINGLE_FUNCTION */
845 #define _sdio_claim_host(_func)
846 #define _sdio_release_host(_func)
848 #define CsrSdioClaim(function)
849 #define CsrSdioRelease(function)
851 #endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
855 * Functions to allocate and free an ethernet device.
857 unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
858 int uf_free_netdevice(unifi_priv_t *priv);
860 /* Allocating function for other interfaces */
861 u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag);
864 * Firmware download related functions.
866 int uf_run_unifihelper(unifi_priv_t *priv);
867 int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
868 int uf_release_firmware_files(unifi_priv_t *priv);
869 int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
872 * Functions to create and delete the device nodes.
874 int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
875 void uf_destroy_device_nodes(unifi_priv_t *priv);
878 * Upper Edge Initialisation functions
880 int uf_init_bh(unifi_priv_t *priv);
881 int uf_init_hw(unifi_priv_t *priv);
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);
890 * Unifi Linux functions
892 void ul_init_clients(unifi_priv_t *priv);
894 /* Configuration flags */
895 #define CLI_USING_WIRE_FORMAT 0x0002
896 #define CLI_SME_USERSPACE 0x0020
897 ul_client_t *ul_register_client(unifi_priv_t *priv,
898 unsigned int configuration,
899 udi_event_t udi_event_clbk);
900 int ul_deregister_client(ul_client_t *pcli);
902 int ul_send_signal_unpacked(unifi_priv_t *priv,
904 bulk_data_param_t *bulkdata);
905 int ul_send_signal_raw(unifi_priv_t *priv,
906 unsigned char *sigptr, int siglen,
907 bulk_data_param_t *bulkdata);
909 void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
913 * Data plane operations
918 int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
919 unsigned int length);
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,
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);
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);
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);
956 void send_auto_ma_packet_confirm(unifi_priv_t *priv,
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);
969 #ifndef P80211_OUI_LEN
970 #define P80211_OUI_LEN 3
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;
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);
985 const char *result_code_str(int result);
988 /* prepares & appends the Mac header for the payload */
989 int prepare_and_add_macheader(unifi_priv_t *priv,
991 struct sk_buff *newSkb,
992 CSR_PRIORITY priority,
993 bulk_data_param_t *bulkdata,
999 get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
1002 unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
1003 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
1004 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
1005 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
1006 CSR_SIGNAL *signal);
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)
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
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);
1022 /* Clear the Peer station Record, in case of wifioff/unexpected card removal */
1023 void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
1025 void scroll_ba_window(unifi_priv_t *priv,
1026 netInterface_priv_t *interfacePriv,
1027 ba_session_rx_struct *ba_session,
1030 u8 blockack_session_stop(unifi_priv_t *priv,
1032 CsrWifiRouterCtrlBlockAckRole role,
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);
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,
1046 /* Fetch the station record handler from data base for matching handle */
1047 CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
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);
1055 void uf_resume_data_plane(unifi_priv_t *priv, int queue,
1056 CsrWifiMacAddress peer_address,
1058 void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
1059 CsrWifiMacAddress peer_address,u16 interfaceTag);
1061 int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
1062 void uf_unregister_netdev(unifi_priv_t *priv);
1064 void uf_net_get_name(struct net_device *dev, char *name, int len);
1066 void uf_send_queue_info(unifi_priv_t *priv);
1067 u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag);
1069 void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
1070 CsrWifiMacAddress source_address,
1071 int indicate, u16 interfaceTag);
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);
1081 void uf_register_inet_notifier(void);
1082 void uf_unregister_inet_notifier(void);
1086 * Suspend / Resume handlers
1088 void unifi_resume(void *ospriv);
1089 void unifi_suspend(void *ospriv);
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
1106 #define ETH_P_PAE 0x888e
1109 #define ETH_P_WAI 0x88b4
1114 void debug_string_indication(unifi_priv_t *priv,
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);
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);
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);
1137 #endif /* __LINUX_UNIFI_PRIV_H__ */