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/module.h>
21 #include <linux/string.h>
22 #include <linux/errno.h>
23 #include <linux/kernel.h>
24 #include <linux/wait.h>
25 #include <linux/sched.h>
26 #include <linux/delay.h>
27 #include <linux/netdevice.h>
28 #include <linux/wireless.h>
29 #include <linux/cdev.h>
30 #include <linux/kthread.h>
31 #include <linux/freezer.h>
33 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
34 #include <linux/mmc/core.h>
35 #include <linux/mmc/card.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/sdio_func.h>
38 #include <linux/mmc/sdio_ids.h>
39 #include <linux/mmc/sdio.h>
40 #endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
45 #include <linux/wakelock.h>
48 #include "csr_wifi_hip_unifi.h"
49 #include "csr_wifi_hip_unifi_udi.h"
50 #include "csr_wifi_router_lib.h"
52 #ifndef CSR_WIFI_HIP_TA_DISABLE
53 #include "csr_wifi_vif_utils.h"
56 /* Define the unifi_priv_t before include the unifi_native.h */
58 typedef struct unifi_priv unifi_priv_t;
59 #ifdef CSR_SUPPORT_WEXT_AP
60 struct CsrWifiSmeApConfig;
61 typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
63 #ifdef CSR_SUPPORT_WEXT
64 #include "unifi_wext.h"
68 extern struct wake_lock unifi_sdio_wake_lock;
71 #include "unifi_clients.h"
73 #ifdef CSR_NATIVE_LINUX
74 #include "sme_native/unifi_native.h"
76 #include "unifi_sme.h"
79 /* The device major number to use when registering the udi driver */
80 #define UNIFI_NAME "unifi"
82 * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present.
83 * This number should be set to the number of SDIO slots supported by the SDIO
84 * host controller on the platform.
85 * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c
87 #define MAX_UNIFI_DEVS 2
89 /* 802.11 Mac header offsets */
90 #define MAC_HEADER_SIZE 24
91 #define QOS_CONTROL_HEADER_SIZE 2
92 #define HT_CONTROL_HEADER_SIZE 4
94 #define QOS_DATA_NULL 0xc
95 #define DATA_NULL 0x04
96 #define FRAME_CONTROL_ORDER_BIT 0x8000
97 #define FRAME_CONTROL_TYPE_FIELD_OFFSET 2
98 #define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET 4
99 #define IEEE802_11_FRAMETYPE_DATA 0x02
100 #define IEEE802_11_FRAMETYPE_CONTROL 0x01
101 #define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
102 #define IEEE802_11_FRAMETYPE_RESERVED 0x03
104 /* octet offset from start of mac header for certain fields */
105 #define IEEE802_11_ADDR3_OFFSET 16
106 #define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
107 #define IEEE802_11_MAX_DATA_LEN 2304
109 /* frame control (FC) masks, for frame control as 16 bit integer */
110 #define IEEE802_11_FC_TO_DS_MASK 0x100
111 #define IEEE802_11_FC_FROM_DS_MASK 0x200
112 #define IEEE802_11_FC_MOREDATA_MASK 0x2000
113 #define IEEE802_11_FC_PROTECTED_MASK 0x4000
114 #define IEEE80211_FC_ORDER_MASK 0x8000
115 #define IEEE80211_FC_SUBTYPE_MASK 0x00f0
116 #define IEEE80211_FC_TYPE_MASK 0x000c
117 #define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
119 /* selected type and subtype combinations as in 7.1.3.1 table 1
120 For frame control as 16 bit integer, or for ls octet
122 #define IEEE802_11_FC_TYPE_DATA 0x08
123 #define IEEE802_11_FC_TYPE_NULL 0x48
124 #define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
125 #define IEEE802_11_FC_TYPE_QOS_DATA 0x88
127 #define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
129 /* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
130 #define IEEE802_11_QC_TID_MASK 0x0f
131 #define IEEE802_11_QC_A_MSDU_PRESENT 0x80
133 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND))
134 #define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0
137 #define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
138 #define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
139 #define MAX_ACCESS_CATOGORY 4
141 /* Time in us to check for inactivity of stations 5 mins */
142 #define INACTIVITY_CHECK_INTERVAL 300000000
143 /* Time in us before a station is flagged as inactive */
144 #define MAX_INACTIVITY_INTERVAL 300000000
147 /* Define for maximum BA session */
148 #define MAX_SUPPORTED_BA_SESSIONS_TX 1
149 #define MAX_SUPPORTED_BA_SESSIONS_RX 4
151 #define MAX_BA_WIND_SIZE 64
152 #define MAC_HEADER_ADDR1_OFFSET 4
153 #define MAC_HEADER_ADDR2_OFFSET 10
155 /* Define for age (in us) value for frames in MPDU reorder buffer */
156 #define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000 /* 30 milli seconds */
158 /* This macro used in prepare_and_add_macheader*/
159 #define ADDRESS_ONE_OFFSET 20
161 /* Defines for STA inactivity detection */
162 #define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1 /* in number of stations */
163 #define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30 /* in seconds */
164 #define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000 /* 120 seconds */
166 /* Test for modes requiring AP firmware patch */
167 #define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \
168 ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE)
170 /* Defines used in beacon filtering in case of P2P */
171 #define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH 0x7
172 #define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON 0x8
173 #define CSR_WIFI_BEACON_FIXED_LENGTH 12
174 #define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET 4
175 #define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
177 #define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
178 ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
180 /* For M4 request received via netdev*/
182 typedef u8 CsrWifiPacketType;
183 #define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00)
184 #define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
185 #define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
187 #define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
189 /* Module parameter variables */
191 extern int sdio_clock;
193 extern int disable_hw_reset;
194 extern int disable_power_control;
195 extern int enable_wol;
196 extern int sme_debug;
197 extern int fw_init[MAX_UNIFI_DEVS];
198 extern int tl_80211d;
199 extern int sdio_byte_mode;
200 extern int sdio_block_size;
201 extern int coredump_max;
202 extern int run_bh_once;
203 extern int bh_priority;
204 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
205 extern int log_hip_signals;
209 const unsigned char *dl_data;
217 struct task_struct *thread_task;
219 /* wait_queue for waking the unifi_thread kernel thread */
220 wait_queue_head_t wakeup_q;
221 unsigned int wakeup_flag;
224 * Use it to block the I/O thread when
225 * an error occurs or UniFi is reinitialised.
234 * Link list to hold the received packets for the period the port
237 typedef struct rx_buffered_packets {
238 /* List link structure */
240 /* Packet to indicate when the port reopens */
242 /* Bulkdata to free in case the port closes and need to discard the packet */
243 bulk_data_param_t bulkdata;
244 /* The source address of the packet */
245 CsrWifiMacAddress sa;
246 /* The destination address of the packet */
247 CsrWifiMacAddress da;
248 /* Corresponding signal */
250 } rx_buffered_packets_t;
253 typedef u8 CsrWifiAcPowersaveMode;
254 #define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
255 #define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
256 #define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
257 #define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
260 #define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
261 #define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
262 #define IS_DTIM_ACTIVE(flag, hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
263 #define INVALID_HOST_TAG 0xFFFFFFFF
264 #define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
269 /* Queue to be used for contention priority */
272 * Link list to hold the tx packets for the period the peer
273 * powersave/free slots in unifi
275 typedef struct tx_buffered_packets {
276 /* List link structure */
279 CSR_CLIENT_TAG hostTag;
280 CSR_PROCESS_ID leSenderProcessId;
281 CSR_TRANSMISSION_CONTROL transmissionControl;
283 /* Bulkdata to free in case the port closes and need to discard the packet */
284 bulk_data_desc_t bulkdata;
285 /* The source address of the packet */
286 CsrWifiMacAddress peerMacAddress;
287 CSR_PRIORITY priority;
288 } tx_buffered_packets_t;
290 /* station record has this data structure */
291 typedef struct CsrWifiRouterCtrlStaInfo_t {
293 /* Sme sends these parameters */
294 CsrWifiMacAddress peerMacAddress;
297 CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
300 u16 noOfSpFramesSent;
302 /* Router/Driver database */
303 #ifdef CSR_SUPPORT_SME
304 unifi_port_cfg_t *peerControlledPort;
305 unifi_port_cfg_t *peerUnControlledPort;
307 /* Inactivity feature parameters */
308 struct netInterface_priv *interfacePriv;
309 struct work_struct send_disconnected_ind_task;
311 u16 listenIntervalInTus;
312 CSR_CLIENT_TAG nullDataHostTag;
314 /* Activity timestamps for the station */
317 /* during m/c transmission sp suspended */
319 CSR_PRIORITY triggerFramePriority;
321 CsrWifiRouterCtrlPeerStatus currentPeerState;
322 struct list_head dataPdu[MAX_ACCESS_CATOGORY];
323 struct list_head mgtFrames;
326 u8 prevFrmAccessCatogory;
331 /* Dont change the value of below macro for SET & RESET */
332 #define CSR_WIFI_TIM_RESET 0
333 #define CSR_WIFI_TIM_SET 1
334 #define CSR_WIFI_TIM_RESETTING 2
335 #define CSR_WIFI_TIM_SETTING 3
337 u8 timRequestPendingFlag;
338 u8 updateTimReqQueued;
340 }CsrWifiRouterCtrlStaInfo_t;
342 #ifdef CSR_SUPPORT_WEXT_AP
343 struct CsrWifiSmeApConfig {
346 CsrWifiNmeApCredentials credentials;
352 #ifdef CSR_WIFI_RX_PATH_SPLIT
353 /* This is a test code and may be removed later*/
354 #define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
358 u8 *bufptr; /* Signal Primitive */
359 bulk_data_param_t data_ptrs; /* Bulk Data pointers */
365 u8 writePointer; /**< write pointer */
366 u8 readPointer; /**< read pointer */
367 u8 size; /**< size of circular buffer */
368 rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE]; /**< Element of ciruclar buffer */
369 } rxCircularBuffer_t;
371 void rx_wq_handler(struct work_struct *work);
377 CsrSdioFunction *sdio;
379 /* Index into Unifi_instances[] for this device. */
381 /* Reference count for this instance */
384 /* Firmware images */
385 struct dlpriv fw_sta;
386 struct dlpriv fw_conv; /* used for conversion of production test image */
388 /* Char device related structures */
389 struct cdev unifi_cdev;
390 struct cdev unifiudi_cdev;
391 struct device *unifi_device;
393 /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
394 CSR_IFINTERFACE if_index;
396 /* For multiple interface support */
397 struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
398 struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
400 u8 totalInterfaceCount;
404 /* Name of node under /proc */
405 char proc_entry_name[64];
412 * - whether the netdev has been registered.
414 unsigned int drop_unencrypted : 1;
416 /* Our list of unifi linux clients. */
417 ul_client_t ul_clients[MAX_UDI_CLIENTS];
419 /* Mutex to protect using the logging hook after UDI client is gone */
420 struct semaphore udi_logging_mutex;
421 /* Pointer to the ul_clients[] array */
422 ul_client_t *logging_client;
424 /* A ul_client_t* used to send the netdev related MIB requests. */
425 ul_client_t *netdev_client;
427 /* The SME ul_client_t pointer. */
428 ul_client_t *sme_cli;
430 /* The AMP ul_client_t pointer. */
431 ul_client_t *amp_client;
434 * Semaphore for locking the top-half to one user process.
435 * This is necessary to prevent multiple processes calling driver
436 * operations. This can happen because the network driver entry points
437 * can be called from multiple processes.
439 #ifdef USE_DRIVER_LOCK
440 struct semaphore lock;
441 #endif /* USE_DRIVER_LOCK */
443 /* Flag to say that an operation was aborted */
446 struct uf_thread bh_thread;
448 #define UNIFI_INIT_NONE 0x00
449 #define UNIFI_INIT_IN_PROGRESS 0x01
450 #define UNIFI_INIT_FW_DOWNLOADED 0x02
451 #define UNIFI_INIT_COMPLETED 0x04
452 unsigned char init_progress;
456 /* The WMM features that UniFi uses in the current BSS */
457 unsigned int sta_wmm_capabilities;
460 char last_debug_string[256];
461 unsigned short last_debug_word16[16];
463 #ifdef CSR_SUPPORT_SME
464 /* lock to protect the tx queues list */
465 spinlock_t tx_q_lock;
467 u8 pausedStaHandle[MAX_ACCESS_CATOGORY];
468 /* Max packet the driver can queue, irrespective of interface number */
469 u16 noOfPktQueuedInDriver;
470 #define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
471 #define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
472 #define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
474 u8 routerBufferEnable[MAX_ACCESS_CATOGORY];
475 /* lock to protect stainfo members and priv members*/
476 spinlock_t staRecord_lock;
478 #ifdef CSR_NATIVE_LINUX
479 #ifdef CSR_SUPPORT_WEXT
480 /* wireless config */
481 struct wext_config wext_conf;
484 /* Mutex to protect the MLME blocking requests */
485 struct semaphore mlme_blocking_mutex;
487 /* The ul_client that provides the blocking API for WEXT calls */
488 ul_client_t *wext_client;
490 #endif /* CSR_NATIVE_LINUX */
492 #ifdef CSR_SUPPORT_SME
493 wait_queue_head_t sme_request_wq;
494 /* Semaphore to protect the SME blocking requests */
495 struct semaphore sme_sem;
496 /* Structure to hold the SME blocking requests data*/
497 sme_reply_t sme_reply;
499 /* Structure to hold a traffic protocol indication */
501 struct work_struct task;
502 CsrWifiRouterCtrlTrafficPacketType packet_type;
503 CsrWifiRouterCtrlProtocolDirection direction;
504 CsrWifiMacAddress src_addr;
508 struct ta_sample_ind {
509 struct work_struct task;
510 CsrWifiRouterCtrlTrafficStats stats;
512 } ta_sample_ind_work;
514 __be32 sta_ip_address;
515 CsrWifiRouterCtrlSmeVersions sme_versions;
518 * Flag to reflect state of unifi_sys_wifi_on_*() progress.
519 * This indicates whether we are in an "wifi on" state when we are
520 * allowed to indication errors with unifi_mgt_wifi_off_ind()
523 wifi_on_unspecified = -1,
524 wifi_on_in_progress = 0,
528 /* Userspace TaskId for the SME Set when a wifi on req is received */
529 CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
531 struct work_struct multicast_list_task;
533 * The SME installs filters to ask for specific MA-UNITDATA.req
534 * to be passed to different SME components.
536 #define MAX_MA_UNIDATA_IND_FILTERS 8
537 sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
539 /* UNIFI_CFG related parameters */
540 uf_cfg_bcast_packet_filter_t packet_filters;
541 unsigned char *filter_tclas_ies;
542 /* The structure that holds all the connection configuration. */
543 CsrWifiSmeConnectionConfig connection_config;
544 #ifdef CSR_SUPPORT_WEXT
546 int ignore_bssid_join;
547 struct iw_statistics wext_wireless_stats;
549 /* The MIB and MAC address files contents, read from userspace */
550 CsrWifiSmeDataBlock mib_data;
551 CsrWifiMacAddress sta_mac_address;
553 int wep_tx_key_index;
554 wep_key_t wep_keys[NUM_WEPKEYS];
557 #ifdef CSR_SUPPORT_WEXT_AP
558 CsrWifiSmeApMacConfig ap_mac_config;
559 CsrWifiNmeApConfig group_sec_config;
560 CsrWifiSmeApConfig_t ap_config;
562 struct work_struct sme_config_task;
564 #endif /* CSR_SUPPORT_WEXT */
566 #endif /* CSR_SUPPORT_SME */
568 #ifdef CSR_SME_USERSPACE
570 #endif /* CSR_SME_USERSPACE */
572 card_info_t card_info;
574 /* Mutex to protect unifi_send_signal() */
575 spinlock_t send_signal_lock;
579 * The workqueue to offload the TA run
580 * and the multicast addresses list set
582 struct workqueue_struct *unifi_workqueue;
584 unsigned char *mib_cfm_buffer;
585 unsigned int mib_cfm_buffer_length;
587 int ptest_mode; /* Set when in production test mode */
588 int coredump_mode; /* Set when SME has requested a coredump */
589 u8 wol_suspend; /* Set when suspending with UniFi powered */
591 #define UF_UNCONTROLLED_PORT_Q 0
592 #define UF_CONTROLLED_PORT_Q 1
594 /* Semaphore to protect the rx queues list */
595 struct semaphore rx_q_sem;
597 /* Spinlock to protect M4 data */
599 /* Mutex to protect BA RX data */
600 struct semaphore ba_mutex;
602 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
603 /* Spinlock to protect the WAPI data */
604 spinlock_t wapi_lock;
607 /* Array to indicate if a particular Tx queue is paused, this may not be
608 * required in a multiqueue implementation since we can directly stop kernel
610 u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
612 #ifdef CSR_WIFI_RX_PATH_SPLIT
613 struct workqueue_struct *rx_workqueue;
614 struct work_struct rx_work_struct;
615 rxCircularBuffer_t rxSignalBuffer;
624 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
625 /*Set if multicast KeyID = 1*/
626 u8 wapi_multicast_filter;
627 /*Set if unicast KeyID = 1*/
628 u8 wapi_unicast_filter;
629 u8 wapi_unicast_queued_pkt_filter;
630 #ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
635 #ifdef CSR_WIFI_SPLIT_PATCH
636 CsrWifiRouterCtrlModeSetReq pending_mode_set;
640 CSR_RATE cmanrTestModeTransmitRate;
652 bulk_data_param_t bulkdata;
659 frame_desc_struct *buffer;
662 struct timer_list timer;
666 u8 trigger_ba_after_ssn;
667 struct netInterface_priv *interfacePriv;
669 CsrWifiMacAddress macAddress;
670 struct work_struct send_ba_err_task;
671 } ba_session_rx_struct;
675 struct netInterface_priv *interfacePriv;
677 CsrWifiMacAddress macAddress;
678 } ba_session_tx_struct;
680 typedef struct netInterface_priv
683 struct unifi_priv *privPtr;
684 ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
685 ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
686 frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
687 u8 ba_complete_index;
688 u8 queueEnabled[UNIFI_NO_OF_TX_QS];
689 struct work_struct send_m4_ready_task;
690 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
691 struct work_struct send_pkt_to_encrypt;
693 struct net_device_stats stats;
696 CsrWifiMacAddress bssid;
698 * Flag to reflect state of CONNECTED indication signal.
699 * This indicates whether we are "joined" an Access Point (i.e. have
700 * nominated an AP and are receiving beacons) but give no indication
701 * of whether we are authenticated and/or associated.
704 UnifiConnectedUnknown = -1,
705 UnifiNotConnected = 0,
708 #ifdef CSR_SUPPORT_WEXT
709 /* Tracks when we are waiting for a netdevice state change callback */
710 u8 wait_netdev_change;
711 /* True if we have successfully registered for netdev callbacks */
712 u8 netdev_callback_registered;
713 #endif /* CSR_SUPPORT_WEXT */
714 unsigned int netdev_registered;
715 #define UNIFI_MAX_MULTICAST_ADDRESSES 10
716 /* The multicast addresses list that the thread needs to set. */
717 u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
718 /* The multicast addresses count that the thread needs to set. */
721 #ifdef CSR_SUPPORT_SME
722 /* (un)controlled port configuration */
723 unifi_port_config_t controlled_data_port;
724 unifi_port_config_t uncontrolled_data_port;
726 /* station record maintenance related data structures */
727 u8 num_stations_joined;
728 CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
729 struct list_head genericMgtFrames;
730 struct list_head genericMulticastOrBroadCastFrames;
731 struct list_head genericMulticastOrBroadCastMgtFrames;
733 /* Timer for detecting station inactivity */
734 struct timer_list sta_activity_check_timer;
735 u8 sta_activity_check_enabled;
737 /* Timestamp when the last inactivity check was done */
738 u32 last_inactivity_check;
740 /*number of multicast or borad cast packets queued*/
741 u16 noOfbroadcastPktQueued;
743 /* A list to hold the buffered uncontrolled port packets */
744 struct list_head rx_uncontrolled_list;
745 /* A list to hold the buffered controlled port packets */
746 struct list_head rx_controlled_list;
747 /* Buffered M4 signal to take care of WPA race condition */
748 CSR_SIGNAL m4_signal;
749 bulk_data_desc_t m4_bulk_data;
751 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
752 /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */
753 CSR_SIGNAL wapi_unicast_ma_pkt_sig;
754 bulk_data_desc_t wapi_unicast_bulk_data;
757 /* This should be removed and m4_hostTag should be used for checking*/
759 CSR_CLIENT_TAG m4_hostTag;
762 u32 multicastPduHostTag; /* Used to set the tim after getting
765 u8 bcTimSetReqPendingFlag;
766 u8 bcTimSetReqQueued;
767 } netInterface_priv_t;
769 #ifdef CSR_SUPPORT_SME
770 #define routerStartBuffering(priv, queue) priv->routerBufferEnable[(queue)] = TRUE;
771 #define routerStopBuffering(priv, queue) priv->routerBufferEnable[(queue)] = FALSE;
772 #define isRouterBufferEnabled(priv, queue) priv->routerBufferEnable[(queue)]
775 #ifdef USE_DRIVER_LOCK
776 #define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock)
777 #define UNLOCK_DRIVER(_p) up(&(_p)->lock)
779 #define LOCK_DRIVER(_p) (void)(_p); /* as nothing */
780 #define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */
781 #endif /* USE_DRIVER_LOCK */
783 s32 CsrHipResultToStatus(CsrResult csrResult);
787 * SDIO related functions and callbacks
789 int uf_sdio_load(void);
790 void uf_sdio_unload(void);
791 unifi_priv_t *uf_find_instance(int inst);
792 int uf_find_priv(unifi_priv_t *priv);
793 int uf_find_netdev_priv(netInterface_priv_t *priv);
794 unifi_priv_t *uf_get_instance(int inst);
795 void uf_put_instance(int inst);
796 int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
797 int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
799 void uf_add_os_device(int bus_id, struct device *os_device);
800 void uf_remove_os_device(int bus_id);
807 * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
808 * as this prevents other functions using SDIO.
809 * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
810 * we have followed this scheme:
811 * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
812 * then we call CsrSdioClaim/CsrSdioRelease().
813 * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
814 * then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
815 * to the SDIO glue layer only (e.g. sdio_mmc.c).
816 * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
817 * then we call directly the sdio_claim_host/sdio_release_host().
818 * Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
820 * Note: The _func and function pointers are _not_ the same.
821 * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
822 * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
825 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
827 #ifdef CSR_WIFI_SINGLE_FUNCTION
828 #define CsrSdioClaim(function) sdio_claim_host((function)->priv);
829 #define CsrSdioRelease(function) sdio_release_host((function)->priv);
831 #define _sdio_claim_host(_func)
832 #define _sdio_release_host(_func)
835 #define CsrSdioClaim(function)
836 #define CsrSdioRelease(function)
838 #define _sdio_claim_host(_func) sdio_claim_host(_func)
839 #define _sdio_release_host(_func) sdio_release_host(_func)
841 #endif /* CSR_WIFI_SINGLE_FUNCTION */
844 #define _sdio_claim_host(_func)
845 #define _sdio_release_host(_func)
847 #define CsrSdioClaim(function)
848 #define CsrSdioRelease(function)
850 #endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
854 * Functions to allocate and free an ethernet device.
856 unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
857 int uf_free_netdevice(unifi_priv_t *priv);
859 /* Allocating function for other interfaces */
860 u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag);
863 * Firmware download related functions.
865 int uf_run_unifihelper(unifi_priv_t *priv);
866 int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
867 int uf_release_firmware_files(unifi_priv_t *priv);
868 int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
871 * Functions to create and delete the device nodes.
873 int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
874 void uf_destroy_device_nodes(unifi_priv_t *priv);
877 * Upper Edge Initialisation functions
879 int uf_init_bh(unifi_priv_t *priv);
880 int uf_init_hw(unifi_priv_t *priv);
882 /* Thread related helper functions */
883 int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
884 void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
885 void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
889 * Unifi Linux functions
891 void ul_init_clients(unifi_priv_t *priv);
893 /* Configuration flags */
894 #define CLI_USING_WIRE_FORMAT 0x0002
895 #define CLI_SME_USERSPACE 0x0020
896 ul_client_t *ul_register_client(unifi_priv_t *priv,
897 unsigned int configuration,
898 udi_event_t udi_event_clbk);
899 int ul_deregister_client(ul_client_t *pcli);
901 int ul_send_signal_unpacked(unifi_priv_t *priv,
903 bulk_data_param_t *bulkdata);
904 int ul_send_signal_raw(unifi_priv_t *priv,
905 unsigned char *sigptr, int siglen,
906 bulk_data_param_t *bulkdata);
908 void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
912 * Data plane operations
917 int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
918 unsigned int length);
920 #ifdef CSR_SUPPORT_SME
921 u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
922 u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, u8 pmBit, u16 interfaceTag);
923 void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag);
924 int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
925 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
926 const CSR_SIGNAL *signal,
927 bulk_data_param_t *bulkdata,
928 u8 macHeaderLengthInBytes);
929 u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
930 void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t * priv,
931 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
935 void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
936 void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
938 void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
939 void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
940 void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
945 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);
946 void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata, u32 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, u16 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 tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList);
960 void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag);
961 void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag);
962 void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag);
968 #ifndef P80211_OUI_LEN
969 #define P80211_OUI_LEN 3
972 u8 dsap; /* always 0xAA */
973 u8 ssap; /* always 0xAA */
974 u8 ctrl; /* always 0x03 */
975 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
977 } __attribute__ ((packed)) llc_snap_hdr_t;
978 int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto);
979 int skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
980 const unsigned char *daddr, const unsigned char *saddr,
981 const CSR_SIGNAL *signal,
982 bulk_data_param_t *bulkdata);
984 const char *result_code_str(int result);
987 /* prepares & appends the Mac header for the payload */
988 int prepare_and_add_macheader(unifi_priv_t *priv,
990 struct sk_buff *newSkb,
991 CSR_PRIORITY priority,
992 bulk_data_param_t *bulkdata,
998 get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
1001 unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
1002 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
1003 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
1004 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
1005 CSR_SIGNAL *signal);
1008 /* Pack the LSB to include station handle & status of tim set */
1009 #define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
1010 /* get the station record handle from the sender ID */
1011 #define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
1012 /* get the timSet status from the sender ID */
1013 #define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
1015 /* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */
1016 #define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
1018 void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle);
1019 void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId);
1021 /* Clear the Peer station Record, in case of wifioff/unexpected card removal */
1022 void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
1024 void scroll_ba_window(unifi_priv_t *priv,
1025 netInterface_priv_t *interfacePriv,
1026 ba_session_rx_struct *ba_session,
1029 u8 blockack_session_stop(unifi_priv_t *priv,
1031 CsrWifiRouterCtrlBlockAckRole role,
1033 CsrWifiMacAddress macAddress);
1034 #ifdef CSR_SUPPORT_SME
1035 /* Fetch the protection information from interface Mode */
1036 s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr);
1039 /* Fetch the station record handler from data base for matching Mac address */
1040 #ifdef CSR_SUPPORT_SME
1041 CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
1042 const u8 *peerMacAddress,
1045 /* Fetch the station record handler from data base for matching handle */
1046 CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
1050 void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress);
1051 void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
1054 void uf_resume_data_plane(unifi_priv_t *priv, int queue,
1055 CsrWifiMacAddress peer_address,
1057 void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
1058 CsrWifiMacAddress peer_address, u16 interfaceTag);
1060 int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
1061 void uf_unregister_netdev(unifi_priv_t *priv);
1063 void uf_net_get_name(struct net_device *dev, char *name, int len);
1065 void uf_send_queue_info(unifi_priv_t *priv);
1066 u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag);
1068 void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
1069 CsrWifiMacAddress source_address,
1070 int indicate, u16 interfaceTag);
1072 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1073 int uf_register_hip_offline_debug(unifi_priv_t *priv);
1074 int uf_unregister_hip_offline_debug(unifi_priv_t *priv);
1080 void uf_register_inet_notifier(void);
1081 void uf_unregister_inet_notifier(void);
1085 * Suspend / Resume handlers
1087 void unifi_resume(void *ospriv);
1088 void unifi_suspend(void *ospriv);
1091 #define QOS_CAPABILITY_WMM_ENABLED 0x0001
1092 #define QOS_CAPABILITY_WMM_UAPSD 0x0002
1093 #define QOS_CAPABILITY_ACM_BE_ENABLED 0x0010
1094 #define QOS_CAPABILITY_ACM_BK_ENABLED 0x0020
1095 #define QOS_CAPABILITY_ACM_VI_ENABLED 0x0040
1096 #define QOS_CAPABILITY_ACM_VO_ENABLED 0x0080
1097 #define QOS_CAPABILITY_TS_BE_ENABLED 0x0100
1098 #define QOS_CAPABILITY_TS_BK_ENABLED 0x0200
1099 #define QOS_CAPABILITY_TS_VI_ENABLED 0x0400
1100 #define QOS_CAPABILITY_TS_VO_ENABLED 0x0800
1105 #define ETH_P_PAE 0x888e
1108 #define ETH_P_WAI 0x88b4
1113 void debug_string_indication(unifi_priv_t *priv,
1114 const unsigned char *extra,
1115 unsigned int extralen);
1116 void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1117 void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1123 int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
1124 int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
1125 int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
1126 int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
1127 int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
1128 int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
1129 int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
1130 int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
1131 int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
1133 int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
1134 int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
1136 #endif /* __LINUX_UNIFI_PRIV_H__ */