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 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
33 #include <linux/freezer.h>
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 */
48 #include <linux/wakelock.h>
51 #include "csr_wifi_hip_unifi.h"
52 #include "csr_wifi_hip_unifi_udi.h"
53 #include "csr_wifi_router_lib.h"
55 #ifndef CSR_WIFI_HIP_TA_DISABLE
56 #include "csr_wifi_vif_utils.h"
59 /* Define the unifi_priv_t before include the unifi_native.h */
61 typedef struct unifi_priv unifi_priv_t
;
62 #ifdef CSR_SUPPORT_WEXT_AP
63 struct CsrWifiSmeApConfig
;
64 typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t
;
66 #ifdef CSR_SUPPORT_WEXT
67 #include "unifi_wext.h"
71 extern struct wake_lock unifi_sdio_wake_lock
;
74 #include "unifi_clients.h"
77 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
78 #include <linux/workqueue.h>
81 #define INIT_WORK(_work, _func) \
83 INIT_LIST_HEAD(&(_work)->entry); \
84 (_work)->pending = 0; \
85 PREPARE_WORK((_work), (_func), (_work)); \
86 init_timer(&(_work)->timer); \
89 #endif /* Linux kernel < 2.6.20 */
92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
93 #define UF_NETIF_TX_WAKE_ALL_QUEUES(_netdev) netif_tx_wake_all_queues(_netdev)
94 #define UF_NETIF_TX_START_ALL_QUEUES(_netdev) netif_tx_start_all_queues(_netdev)
95 #define UF_NETIF_TX_STOP_ALL_QUEUES(_netdev) netif_tx_stop_all_queues(_netdev)
97 #define UF_NETIF_TX_WAKE_ALL_QUEUES(_netdev) netif_wake_queue(_netdev)
98 #define UF_NETIF_TX_START_ALL_QUEUES(_netdev) netif_start_queue(_netdev)
99 #define UF_NETIF_TX_STOP_ALL_QUEUES(_netdev) netif_stop_queue(_netdev)
100 #endif /* Linux kernel >= 2.6.27 */
103 #ifdef CSR_NATIVE_LINUX
104 #include "sme_native/unifi_native.h"
106 #include "unifi_sme.h"
109 /* The device major number to use when registering the udi driver */
110 #define UNIFI_NAME "unifi"
112 * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present.
113 * This number should be set to the number of SDIO slots supported by the SDIO
114 * host controller on the platform.
115 * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c
117 #define MAX_UNIFI_DEVS 2
119 /* 802.11 Mac header offsets */
120 #define MAC_HEADER_SIZE 24
121 #define QOS_CONTROL_HEADER_SIZE 2
122 #define HT_CONTROL_HEADER_SIZE 4
124 #define QOS_DATA_NULL 0xc
125 #define DATA_NULL 0x04
126 #define FRAME_CONTROL_ORDER_BIT 0x8000
127 #define FRAME_CONTROL_TYPE_FIELD_OFFSET 2
128 #define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET 4
129 #define IEEE802_11_FRAMETYPE_DATA 0x02
130 #define IEEE802_11_FRAMETYPE_CONTROL 0x01
131 #define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
132 #define IEEE802_11_FRAMETYPE_RESERVED 0x03
134 /* octet offset from start of mac header for certain fields */
135 #define IEEE802_11_ADDR3_OFFSET 16
136 #define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
137 #define IEEE802_11_MAX_DATA_LEN 2304
139 /* frame control (FC) masks, for frame control as 16 bit integer */
140 #define IEEE802_11_FC_TO_DS_MASK 0x100
141 #define IEEE802_11_FC_FROM_DS_MASK 0x200
142 #define IEEE802_11_FC_MOREDATA_MASK 0x2000
143 #define IEEE802_11_FC_PROTECTED_MASK 0x4000
144 #define IEEE80211_FC_ORDER_MASK 0x8000
145 #define IEEE80211_FC_SUBTYPE_MASK 0x00f0
146 #define IEEE80211_FC_TYPE_MASK 0x000c
147 #define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
149 /* selected type and subtype combinations as in 7.1.3.1 table 1
150 For frame control as 16 bit integer, or for ls octet
152 #define IEEE802_11_FC_TYPE_DATA 0x08
153 #define IEEE802_11_FC_TYPE_NULL 0x48
154 #define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
155 #define IEEE802_11_FC_TYPE_QOS_DATA 0x88
157 #define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
159 /* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
160 #define IEEE802_11_QC_TID_MASK 0x0f
161 #define IEEE802_11_QC_A_MSDU_PRESENT 0x80
163 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND))
164 #define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0
167 #define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
168 #define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
169 #define MAX_ACCESS_CATOGORY 4
171 /* Time in us to check for inactivity of stations 5 mins */
172 #define INACTIVITY_CHECK_INTERVAL 300000000
173 /* Time in us before a station is flagged as inactive */
174 #define MAX_INACTIVITY_INTERVAL 300000000
177 /* Define for maximum BA session */
178 #define MAX_SUPPORTED_BA_SESSIONS_TX 1
179 #define MAX_SUPPORTED_BA_SESSIONS_RX 4
181 #define MAX_BA_WIND_SIZE 64
182 #define MAC_HEADER_ADDR1_OFFSET 4
183 #define MAC_HEADER_ADDR2_OFFSET 10
185 /* Define for age (in us) value for frames in MPDU reorder buffer */
186 #define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000 /* 30 milli seconds */
188 /* This macro used in prepare_and_add_macheader*/
189 #define ADDRESS_ONE_OFFSET 20
191 /* Defines for STA inactivity detection */
192 #define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1 /* in number of stations */
193 #define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30 /* in seconds */
194 #define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000 /* 120 seconds */
196 /* Test for modes requiring AP firmware patch */
197 #define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \
198 ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE)
200 /* Defines used in beacon filtering in case of P2P */
201 #define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH 0x7
202 #define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON 0x8
203 #define CSR_WIFI_BEACON_FIXED_LENGTH 12
204 #define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET 4
205 #define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
207 #define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
208 ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
210 /* For M4 request received via netdev*/
212 typedef u8 CsrWifiPacketType
;
213 #define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00)
214 #define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
215 #define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
217 #define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
219 /* Module parameter variables */
221 extern int sdio_clock
;
223 extern int disable_hw_reset
;
224 extern int disable_power_control
;
225 extern int enable_wol
;
226 extern int sme_debug
;
227 extern int fw_init
[MAX_UNIFI_DEVS
];
228 extern int tl_80211d
;
229 extern int sdio_byte_mode
;
230 extern int sdio_block_size
;
231 extern int coredump_max
;
232 extern int run_bh_once
;
233 extern int bh_priority
;
234 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
235 extern int log_hip_signals
;
239 const unsigned char *dl_data
;
247 struct task_struct
*thread_task
;
249 /* wait_queue for waking the unifi_thread kernel thread */
250 wait_queue_head_t wakeup_q
;
251 unsigned int wakeup_flag
;
254 * Use it to block the I/O thread when
255 * an error occurs or UniFi is reinitialised.
264 * Link list to hold the received packets for the period the port
267 typedef struct rx_buffered_packets
{
268 /* List link structure */
270 /* Packet to indicate when the port reopens */
272 /* Bulkdata to free in case the port closes and need to discard the packet */
273 bulk_data_param_t bulkdata
;
274 /* The source address of the packet */
275 CsrWifiMacAddress sa
;
276 /* The destination address of the packet */
277 CsrWifiMacAddress da
;
278 /* Corresponding signal */
280 } rx_buffered_packets_t
;
283 typedef u8 CsrWifiAcPowersaveMode
;
284 #define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
285 #define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
286 #define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
287 #define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
290 #define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
291 #define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
292 #define IS_DTIM_ACTIVE(flag,hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
293 #define INVALID_HOST_TAG 0xFFFFFFFF
294 #define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
299 /* Queue to be used for contention priority */
302 * Link list to hold the tx packets for the period the peer
303 * powersave/free slots in unifi
305 typedef struct tx_buffered_packets
{
306 /* List link structure */
309 CSR_CLIENT_TAG hostTag
;
310 CSR_PROCESS_ID leSenderProcessId
;
311 CSR_TRANSMISSION_CONTROL transmissionControl
;
313 /* Bulkdata to free in case the port closes and need to discard the packet */
314 bulk_data_desc_t bulkdata
;
315 /* The source address of the packet */
316 CsrWifiMacAddress peerMacAddress
;
317 CSR_PRIORITY priority
;
318 } tx_buffered_packets_t
;
320 /* station record has this data structure */
321 typedef struct CsrWifiRouterCtrlStaInfo_t
{
323 /* Sme sends these parameters */
324 CsrWifiMacAddress peerMacAddress
;
327 CsrWifiAcPowersaveMode powersaveMode
[MAX_ACCESS_CATOGORY
];
330 u16 noOfSpFramesSent
;
332 /* Router/Driver database */
333 #ifdef CSR_SUPPORT_SME
334 unifi_port_cfg_t
*peerControlledPort
;
335 unifi_port_cfg_t
*peerUnControlledPort
;
337 /* Inactivity feature parameters */
338 struct netInterface_priv
*interfacePriv
;
339 struct work_struct send_disconnected_ind_task
;
341 u16 listenIntervalInTus
;
342 CSR_CLIENT_TAG nullDataHostTag
;
344 /* Activity timestamps for the station */
345 CsrTime lastActivity
;
347 /* during m/c transmission sp suspended */
349 CSR_PRIORITY triggerFramePriority
;
351 CsrWifiRouterCtrlPeerStatus currentPeerState
;
352 struct list_head dataPdu
[MAX_ACCESS_CATOGORY
];
353 struct list_head mgtFrames
;
356 u8 prevFrmAccessCatogory
;
361 /* Dont change the value of below macro for SET & RESET */
362 #define CSR_WIFI_TIM_RESET 0
363 #define CSR_WIFI_TIM_SET 1
364 #define CSR_WIFI_TIM_RESETTING 2
365 #define CSR_WIFI_TIM_SETTING 3
367 u8 timRequestPendingFlag
;
368 u8 updateTimReqQueued
;
370 }CsrWifiRouterCtrlStaInfo_t
;
372 #ifdef CSR_SUPPORT_WEXT_AP
373 struct CsrWifiSmeApConfig
{
376 CsrWifiNmeApCredentials credentials
;
382 #ifdef CSR_WIFI_RX_PATH_SPLIT
383 /* This is a test code and may be removed later*/
384 #define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
388 u8
*bufptr
; /* Signal Primitive */
389 bulk_data_param_t data_ptrs
; /* Bulk Data pointers */
395 u8 writePointer
; /**< write pointer */
396 u8 readPointer
; /**< read pointer */
397 u8 size
; /**< size of circular buffer */
398 rx_buff_struct_t rx_buff
[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE
]; /**< Element of ciruclar buffer */
399 } rxCircularBuffer_t
;
401 void rx_wq_handler(struct work_struct
*work
);
407 CsrSdioFunction
*sdio
;
409 /* Index into Unifi_instances[] for this device. */
411 /* Reference count for this instance */
414 /* Firmware images */
415 struct dlpriv fw_sta
;
416 struct dlpriv fw_conv
; /* used for conversion of production test image */
418 /* Char device related structures */
419 struct cdev unifi_cdev
;
420 struct cdev unifiudi_cdev
;
421 struct device
*unifi_device
;
423 /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
424 CSR_IFINTERFACE if_index
;
426 /* For multiple interface support */
427 struct net_device
*netdev
[CSR_WIFI_NUM_INTERFACES
];
428 struct netInterface_priv
*interfacePriv
[CSR_WIFI_NUM_INTERFACES
];
430 u8 totalInterfaceCount
;
434 /* Name of node under /proc */
435 char proc_entry_name
[64];
442 * - whether the netdev has been registered.
444 unsigned int drop_unencrypted
: 1;
446 /* Our list of unifi linux clients. */
447 ul_client_t ul_clients
[MAX_UDI_CLIENTS
];
449 /* Mutex to protect using the logging hook after UDI client is gone */
450 struct semaphore udi_logging_mutex
;
451 /* Pointer to the ul_clients[] array */
452 ul_client_t
*logging_client
;
454 /* A ul_client_t* used to send the netdev related MIB requests. */
455 ul_client_t
*netdev_client
;
457 /* The SME ul_client_t pointer. */
458 ul_client_t
*sme_cli
;
460 /* The AMP ul_client_t pointer. */
461 ul_client_t
*amp_client
;
464 * Semaphore for locking the top-half to one user process.
465 * This is necessary to prevent multiple processes calling driver
466 * operations. This can happen because the network driver entry points
467 * can be called from multiple processes.
469 #ifdef USE_DRIVER_LOCK
470 struct semaphore lock
;
471 #endif /* USE_DRIVER_LOCK */
473 /* Flag to say that an operation was aborted */
476 struct uf_thread bh_thread
;
478 #define UNIFI_INIT_NONE 0x00
479 #define UNIFI_INIT_IN_PROGRESS 0x01
480 #define UNIFI_INIT_FW_DOWNLOADED 0x02
481 #define UNIFI_INIT_COMPLETED 0x04
482 unsigned char init_progress
;
486 /* The WMM features that UniFi uses in the current BSS */
487 unsigned int sta_wmm_capabilities
;
490 char last_debug_string
[256];
491 unsigned short last_debug_word16
[16];
493 #ifdef CSR_SUPPORT_SME
494 /* lock to protect the tx queues list */
495 spinlock_t tx_q_lock
;
497 u8 pausedStaHandle
[MAX_ACCESS_CATOGORY
];
498 /* Max packet the driver can queue, irrespective of interface number */
499 u16 noOfPktQueuedInDriver
;
500 #define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
501 #define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
502 #define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
504 u8 routerBufferEnable
[MAX_ACCESS_CATOGORY
];
505 /* lock to protect stainfo members and priv members*/
506 spinlock_t staRecord_lock
;
508 #ifdef CSR_NATIVE_LINUX
509 #ifdef CSR_SUPPORT_WEXT
510 /* wireless config */
511 struct wext_config wext_conf
;
514 /* Mutex to protect the MLME blocking requests */
515 struct semaphore mlme_blocking_mutex
;
517 /* The ul_client that provides the blocking API for WEXT calls */
518 ul_client_t
*wext_client
;
520 #endif /* CSR_NATIVE_LINUX */
522 #ifdef CSR_SUPPORT_SME
523 wait_queue_head_t sme_request_wq
;
524 /* Semaphore to protect the SME blocking requests */
525 struct semaphore sme_sem
;
526 /* Structure to hold the SME blocking requests data*/
527 sme_reply_t sme_reply
;
529 /* Structure to hold a traffic protocol indication */
531 struct work_struct task
;
532 CsrWifiRouterCtrlTrafficPacketType packet_type
;
533 CsrWifiRouterCtrlProtocolDirection direction
;
534 CsrWifiMacAddress src_addr
;
538 struct ta_sample_ind
{
539 struct work_struct task
;
540 CsrWifiRouterCtrlTrafficStats stats
;
542 } ta_sample_ind_work
;
544 __be32 sta_ip_address
;
545 CsrWifiRouterCtrlSmeVersions sme_versions
;
548 * Flag to reflect state of unifi_sys_wifi_on_*() progress.
549 * This indicates whether we are in an "wifi on" state when we are
550 * allowed to indication errors with unifi_mgt_wifi_off_ind()
553 wifi_on_unspecified
= -1,
554 wifi_on_in_progress
= 0,
558 /* Userspace TaskId for the SME Set when a wifi on req is received */
559 CsrSchedQid CSR_WIFI_SME_IFACEQUEUE
;
561 struct work_struct multicast_list_task
;
563 * The SME installs filters to ask for specific MA-UNITDATA.req
564 * to be passed to different SME components.
566 #define MAX_MA_UNIDATA_IND_FILTERS 8
567 sme_ma_unidata_ind_filter_t sme_unidata_ind_filters
[MAX_MA_UNIDATA_IND_FILTERS
];
569 /* UNIFI_CFG related parameters */
570 uf_cfg_bcast_packet_filter_t packet_filters
;
571 unsigned char *filter_tclas_ies
;
572 /* The structure that holds all the connection configuration. */
573 CsrWifiSmeConnectionConfig connection_config
;
574 #ifdef CSR_SUPPORT_WEXT
576 int ignore_bssid_join
;
577 struct iw_statistics wext_wireless_stats
;
579 /* The MIB and MAC address files contents, read from userspace */
580 CsrWifiSmeDataBlock mib_data
;
581 CsrWifiMacAddress sta_mac_address
;
583 int wep_tx_key_index
;
584 wep_key_t wep_keys
[NUM_WEPKEYS
];
587 #ifdef CSR_SUPPORT_WEXT_AP
588 CsrWifiSmeApMacConfig ap_mac_config
;
589 CsrWifiNmeApConfig group_sec_config
;
590 CsrWifiSmeApConfig_t ap_config
;
592 struct work_struct sme_config_task
;
594 #endif /* CSR_SUPPORT_WEXT */
596 #endif /* CSR_SUPPORT_SME */
598 #ifdef CSR_SME_USERSPACE
600 #endif /* CSR_SME_USERSPACE */
602 card_info_t card_info
;
604 /* Mutex to protect unifi_send_signal() */
605 spinlock_t send_signal_lock
;
609 * The workqueue to offload the TA run
610 * and the multicast addresses list set
612 struct workqueue_struct
*unifi_workqueue
;
614 unsigned char *mib_cfm_buffer
;
615 unsigned int mib_cfm_buffer_length
;
617 int ptest_mode
; /* Set when in production test mode */
618 int coredump_mode
; /* Set when SME has requested a coredump */
619 u8 wol_suspend
; /* Set when suspending with UniFi powered */
621 #define UF_UNCONTROLLED_PORT_Q 0
622 #define UF_CONTROLLED_PORT_Q 1
624 /* Semaphore to protect the rx queues list */
625 struct semaphore rx_q_sem
;
627 /* Spinlock to protect M4 data */
629 /* Mutex to protect BA RX data */
630 struct semaphore ba_mutex
;
632 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
633 /* Spinlock to protect the WAPI data */
634 spinlock_t wapi_lock
;
637 #ifndef ALLOW_Q_PAUSE
638 /* Array to indicate if a particular Tx queue is paused, this may not be
639 * required in a multiqueue implementation since we can directly stop kernel
641 u8 tx_q_paused_flag
[UNIFI_TRAFFIC_Q_MAX
];
644 #ifdef CSR_WIFI_RX_PATH_SPLIT
645 struct workqueue_struct
*rx_workqueue
;
646 struct work_struct rx_work_struct
;
647 rxCircularBuffer_t rxSignalBuffer
;
656 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
657 /*Set if multicast KeyID = 1*/
658 u8 wapi_multicast_filter
;
659 /*Set if unicast KeyID = 1*/
660 u8 wapi_unicast_filter
;
661 u8 wapi_unicast_queued_pkt_filter
;
662 #ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
667 #ifdef CSR_WIFI_SPLIT_PATCH
668 CsrWifiRouterCtrlModeSetReq pending_mode_set
;
672 CSR_RATE cmanrTestModeTransmitRate
;
684 bulk_data_param_t bulkdata
;
691 frame_desc_struct
*buffer
;
694 struct timer_list timer
;
698 u8 trigger_ba_after_ssn
;
699 struct netInterface_priv
*interfacePriv
;
701 CsrWifiMacAddress macAddress
;
702 struct work_struct send_ba_err_task
;
703 } ba_session_rx_struct
;
707 struct netInterface_priv
*interfacePriv
;
709 CsrWifiMacAddress macAddress
;
710 } ba_session_tx_struct
;
712 typedef struct netInterface_priv
715 struct unifi_priv
*privPtr
;
716 ba_session_tx_struct
*ba_session_tx
[MAX_SUPPORTED_BA_SESSIONS_TX
];
717 ba_session_rx_struct
*ba_session_rx
[MAX_SUPPORTED_BA_SESSIONS_RX
];
718 frame_desc_struct ba_complete
[MAX_BA_WIND_SIZE
];
719 u8 ba_complete_index
;
720 u8 queueEnabled
[UNIFI_NO_OF_TX_QS
];
721 struct work_struct send_m4_ready_task
;
722 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
723 struct work_struct send_pkt_to_encrypt
;
725 struct net_device_stats stats
;
728 CsrWifiMacAddress bssid
;
730 * Flag to reflect state of CONNECTED indication signal.
731 * This indicates whether we are "joined" an Access Point (i.e. have
732 * nominated an AP and are receiving beacons) but give no indication
733 * of whether we are authenticated and/or associated.
736 UnifiConnectedUnknown
= -1,
737 UnifiNotConnected
= 0,
740 #ifdef CSR_SUPPORT_WEXT
741 /* Tracks when we are waiting for a netdevice state change callback */
742 u8 wait_netdev_change
;
743 /* True if we have successfully registered for netdev callbacks */
744 u8 netdev_callback_registered
;
745 #endif /* CSR_SUPPORT_WEXT */
746 unsigned int netdev_registered
;
747 #define UNIFI_MAX_MULTICAST_ADDRESSES 10
748 /* The multicast addresses list that the thread needs to set. */
749 u8 mc_list
[UNIFI_MAX_MULTICAST_ADDRESSES
*ETH_ALEN
];
750 /* The multicast addresses count that the thread needs to set. */
753 #ifdef CSR_SUPPORT_SME
754 /* (un)controlled port configuration */
755 unifi_port_config_t controlled_data_port
;
756 unifi_port_config_t uncontrolled_data_port
;
758 /* station record maintenance related data structures */
759 u8 num_stations_joined
;
760 CsrWifiRouterCtrlStaInfo_t
*(staInfo
)[UNIFI_MAX_CONNECTIONS
];
761 struct list_head genericMgtFrames
;
762 struct list_head genericMulticastOrBroadCastFrames
;
763 struct list_head genericMulticastOrBroadCastMgtFrames
;
765 /* Timer for detecting station inactivity */
766 struct timer_list sta_activity_check_timer
;
767 u8 sta_activity_check_enabled
;
769 /* Timestamp when the last inactivity check was done */
770 CsrTime last_inactivity_check
;
772 /*number of multicast or borad cast packets queued*/
773 u16 noOfbroadcastPktQueued
;
775 /* A list to hold the buffered uncontrolled port packets */
776 struct list_head rx_uncontrolled_list
;
777 /* A list to hold the buffered controlled port packets */
778 struct list_head rx_controlled_list
;
779 /* Buffered M4 signal to take care of WPA race condition */
780 CSR_SIGNAL m4_signal
;
781 bulk_data_desc_t m4_bulk_data
;
783 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
784 /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */
785 CSR_SIGNAL wapi_unicast_ma_pkt_sig
;
786 bulk_data_desc_t wapi_unicast_bulk_data
;
789 /* This should be removed and m4_hostTag should be used for checking*/
791 CSR_CLIENT_TAG m4_hostTag
;
794 u32 multicastPduHostTag
; /* Used to set the tim after getting
797 u8 bcTimSetReqPendingFlag
;
798 u8 bcTimSetReqQueued
;
799 } netInterface_priv_t
;
801 #ifndef ALLOW_Q_PAUSE
802 #define net_is_tx_q_paused(priv, q) (priv->tx_q_paused_flag[q])
803 #define net_tx_q_unpause(priv, q) (priv->tx_q_paused_flag[q] = 0)
804 #define net_tx_q_pause(priv, q) (priv->tx_q_paused_flag[q] = 1)
807 #ifdef CSR_SUPPORT_SME
808 #define routerStartBuffering(priv,queue) priv->routerBufferEnable[(queue)] = TRUE;
809 #define routerStopBuffering(priv,queue) priv->routerBufferEnable[(queue)] = FALSE;
810 #define isRouterBufferEnabled(priv,queue) priv->routerBufferEnable[(queue)]
813 #ifdef USE_DRIVER_LOCK
814 #define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock)
815 #define UNLOCK_DRIVER(_p) up(&(_p)->lock)
817 #define LOCK_DRIVER(_p) (void)(_p); /* as nothing */
818 #define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */
819 #endif /* USE_DRIVER_LOCK */
821 s32
CsrHipResultToStatus(CsrResult csrResult
);
825 * SDIO related functions and callbacks
827 int uf_sdio_load(void);
828 void uf_sdio_unload(void);
829 unifi_priv_t
*uf_find_instance(int inst
);
830 int uf_find_priv(unifi_priv_t
*priv
);
831 int uf_find_netdev_priv(netInterface_priv_t
*priv
);
832 unifi_priv_t
*uf_get_instance(int inst
);
833 void uf_put_instance(int inst
);
834 int csr_sdio_linux_install_irq(CsrSdioFunction
*sdio
);
835 int csr_sdio_linux_remove_irq(CsrSdioFunction
*sdio
);
837 void uf_add_os_device(int bus_id
, struct device
*os_device
);
838 void uf_remove_os_device(int bus_id
);
845 * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
846 * as this prevents other functions using SDIO.
847 * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
848 * we have followed this scheme:
849 * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
850 * then we call CsrSdioClaim/CsrSdioRelease().
851 * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
852 * then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
853 * to the SDIO glue layer only (e.g. sdio_mmc.c).
854 * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
855 * then we call directly the sdio_claim_host/sdio_release_host().
856 * Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
858 * Note: The _func and function pointers are _not_ the same.
859 * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
860 * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
863 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
865 #ifdef CSR_WIFI_SINGLE_FUNCTION
866 #define CsrSdioClaim(function) sdio_claim_host((function)->priv);
867 #define CsrSdioRelease(function) sdio_release_host((function)->priv);
869 #define _sdio_claim_host(_func)
870 #define _sdio_release_host(_func)
873 #define CsrSdioClaim(function)
874 #define CsrSdioRelease(function)
876 #define _sdio_claim_host(_func) sdio_claim_host(_func)
877 #define _sdio_release_host(_func) sdio_release_host(_func)
879 #endif /* CSR_WIFI_SINGLE_FUNCTION */
882 #define _sdio_claim_host(_func)
883 #define _sdio_release_host(_func)
885 #define CsrSdioClaim(function)
886 #define CsrSdioRelease(function)
888 #endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
892 * Functions to allocate and free an ethernet device.
894 unifi_priv_t
*uf_alloc_netdevice(CsrSdioFunction
*sdio_dev
, int bus_id
);
895 int uf_free_netdevice(unifi_priv_t
*priv
);
897 /* Allocating function for other interfaces */
898 u8
uf_alloc_netdevice_for_other_interfaces(unifi_priv_t
*priv
, u16 interfaceTag
);
901 * Firmware download related functions.
903 int uf_run_unifihelper(unifi_priv_t
*priv
);
904 int uf_request_firmware_files(unifi_priv_t
*priv
, int is_fw
);
905 int uf_release_firmware_files(unifi_priv_t
*priv
);
906 int uf_release_firmware(unifi_priv_t
*priv
, struct dlpriv
*to_free
);
909 * Functions to create and delete the device nodes.
911 int uf_create_device_nodes(unifi_priv_t
*priv
, int bus_id
);
912 void uf_destroy_device_nodes(unifi_priv_t
*priv
);
915 * Upper Edge Initialisation functions
917 int uf_init_bh(unifi_priv_t
*priv
);
918 int uf_init_hw(unifi_priv_t
*priv
);
920 /* Thread related helper functions */
921 int uf_start_thread(unifi_priv_t
*priv
, struct uf_thread
*thread
, int (*func
)(void *));
922 void uf_stop_thread(unifi_priv_t
*priv
, struct uf_thread
*thread
);
923 void uf_wait_for_thread_to_stop(unifi_priv_t
*priv
, struct uf_thread
*thread
);
927 * Unifi Linux functions
929 void ul_init_clients(unifi_priv_t
*priv
);
931 /* Configuration flags */
932 #define CLI_USING_WIRE_FORMAT 0x0002
933 #define CLI_SME_USERSPACE 0x0020
934 ul_client_t
*ul_register_client(unifi_priv_t
*priv
,
935 unsigned int configuration
,
936 udi_event_t udi_event_clbk
);
937 int ul_deregister_client(ul_client_t
*pcli
);
939 int ul_send_signal_unpacked(unifi_priv_t
*priv
,
941 bulk_data_param_t
*bulkdata
);
942 int ul_send_signal_raw(unifi_priv_t
*priv
,
943 unsigned char *sigptr
, int siglen
,
944 bulk_data_param_t
*bulkdata
);
946 void ul_log_config_ind(unifi_priv_t
*priv
, u8
*conf_param
, int len
);
950 * Data plane operations
955 int uf_verify_m4(unifi_priv_t
*priv
, const unsigned char *packet
,
956 unsigned int length
);
958 #ifdef CSR_SUPPORT_SME
959 u8
uf_check_broadcast_bssid(unifi_priv_t
*priv
, const bulk_data_param_t
*bulkdata
);
960 u8
uf_process_pm_bit_for_peer(unifi_priv_t
* priv
, CsrWifiRouterCtrlStaInfo_t
* srcStaInfo
,u8 pmBit
,u16 interfaceTag
);
961 void uf_process_ps_poll(unifi_priv_t
*priv
,u8
* sa
,u8
* da
,u8 pmBit
,u16 interfaceTag
);
962 int uf_ap_process_data_pdu(unifi_priv_t
*priv
, struct sk_buff
*skb
,
963 struct ethhdr
*ehdr
, CsrWifiRouterCtrlStaInfo_t
* srcStaInfo
,
964 const CSR_SIGNAL
*signal
,
965 bulk_data_param_t
*bulkdata
,
966 u8 macHeaderLengthInBytes
);
967 u8
uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t
*staRecord
);
968 void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t
* priv
,
969 CsrWifiRouterCtrlStaInfo_t
* srcStaInfo
,
973 void uf_send_buffered_data_from_ac(unifi_priv_t
*priv
, CsrWifiRouterCtrlStaInfo_t
* staInfo
, u8 queue
, struct list_head
*txList
);
974 void uf_send_buffered_data_from_delivery_ac(unifi_priv_t
*priv
, CsrWifiRouterCtrlStaInfo_t
* staInfo
, u8 queue
, struct list_head
*txList
);
976 void uf_continue_uapsd(unifi_priv_t
*priv
, CsrWifiRouterCtrlStaInfo_t
* staInfo
);
977 void uf_send_qos_null(unifi_priv_t
* priv
,u16 interfaceTag
, const u8
*da
,CSR_PRIORITY priority
,CsrWifiRouterCtrlStaInfo_t
* srcStaInfo
);
978 void uf_send_nulldata(unifi_priv_t
* priv
,u16 interfaceTag
, const u8
*da
,CSR_PRIORITY priority
,CsrWifiRouterCtrlStaInfo_t
* srcStaInfo
);
983 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
);
984 void uf_process_ma_vif_availibility_ind(unifi_priv_t
*priv
,u8
*sigdata
, u32 siglen
);
985 #ifdef CSR_SUPPORT_SME
986 void uf_send_buffered_frames(unifi_priv_t
*priv
,unifi_TrafficQueue queue
);
987 int uf_process_station_records_for_sending_data(unifi_priv_t
*priv
,u16 interfaceTag
,
988 CsrWifiRouterCtrlStaInfo_t
*srcStaInfo
,
989 CsrWifiRouterCtrlStaInfo_t
*dstStaInfo
);
990 void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t
* priv
,
991 struct list_head
*frames_need_cfm_list
,
992 struct list_head
* list
);
993 void send_auto_ma_packet_confirm(unifi_priv_t
*priv
,
994 netInterface_priv_t
*interfacePriv
,
995 struct list_head
*buffered_frames_list
);
996 void uf_flush_list(unifi_priv_t
* priv
, struct list_head
* list
);
997 tx_buffered_packets_t
*dequeue_tx_data_pdu(unifi_priv_t
*priv
, struct list_head
*txList
);
998 void resume_unicast_buffered_frames(unifi_priv_t
*priv
, u16 interfaceTag
);
999 void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t
*priv
,u16 interfaceTag
);
1000 void resume_suspended_uapsd(unifi_priv_t
* priv
,u16 interfaceTag
);
1006 #ifndef P80211_OUI_LEN
1007 #define P80211_OUI_LEN 3
1010 u8 dsap
; /* always 0xAA */
1011 u8 ssap
; /* always 0xAA */
1012 u8 ctrl
; /* always 0x03 */
1013 u8 oui
[P80211_OUI_LEN
]; /* organizational universal id */
1015 } __attribute__ ((packed
)) llc_snap_hdr_t
;
1016 int skb_add_llc_snap(struct net_device
*dev
, struct sk_buff
*skb
, int proto
);
1017 int skb_80211_to_ether(unifi_priv_t
*priv
, struct sk_buff
*skb
,
1018 const unsigned char *daddr
, const unsigned char *saddr
,
1019 const CSR_SIGNAL
*signal
,
1020 bulk_data_param_t
*bulkdata
);
1022 const char *result_code_str(int result
);
1025 /* prepares & appends the Mac header for the payload */
1026 int prepare_and_add_macheader(unifi_priv_t
*priv
,
1027 struct sk_buff
*skb
,
1028 struct sk_buff
*newSkb
,
1029 CSR_PRIORITY priority
,
1030 bulk_data_param_t
*bulkdata
,
1036 get_packet_priority(unifi_priv_t
*priv
, struct sk_buff
*skb
, const struct ethhdr
*ehdr
, netInterface_priv_t
*interfacePriv
);
1039 unifi_frame_ma_packet_req(unifi_priv_t
*priv
, CSR_PRIORITY priority
,
1040 CSR_RATE TransmitRate
, CSR_CLIENT_TAG hostTag
,
1041 u16 interfaceTag
, CSR_TRANSMISSION_CONTROL transmissionControl
,
1042 CSR_PROCESS_ID leSenderProcessId
, u8
*peerMacAddress
,
1043 CSR_SIGNAL
*signal
);
1046 /* Pack the LSB to include station handle & status of tim set */
1047 #define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
1048 /* get the station record handle from the sender ID */
1049 #define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
1050 /* get the timSet status from the sender ID */
1051 #define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
1053 /* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */
1054 #define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
1056 void update_tim(unifi_priv_t
* priv
, u16 aid
, u8 setTim
, u16 interfaceTag
, u32 handle
);
1057 void uf_handle_tim_cfm(unifi_priv_t
*priv
, CSR_MLME_SET_TIM_CONFIRM
*cfm
, u16 senderProcessId
);
1059 /* Clear the Peer station Record, in case of wifioff/unexpected card removal */
1060 void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t
*priv
, u16 interfaceTag
);
1062 void scroll_ba_window(unifi_priv_t
*priv
,
1063 netInterface_priv_t
*interfacePriv
,
1064 ba_session_rx_struct
*ba_session
,
1067 u8
blockack_session_stop(unifi_priv_t
*priv
,
1069 CsrWifiRouterCtrlBlockAckRole role
,
1071 CsrWifiMacAddress macAddress
);
1072 #ifdef CSR_SUPPORT_SME
1073 /* Fetch the protection information from interface Mode */
1074 s8
uf_get_protection_bit_from_interfacemode(unifi_priv_t
*priv
, u16 interfaceTag
, const u8
*daddr
);
1077 /* Fetch the station record handler from data base for matching Mac address */
1078 #ifdef CSR_SUPPORT_SME
1079 CsrWifiRouterCtrlStaInfo_t
*CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t
*priv
,
1080 const u8
*peerMacAddress
,
1083 /* Fetch the station record handler from data base for matching handle */
1084 CsrWifiRouterCtrlStaInfo_t
* CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t
*priv
,
1088 void uf_update_sta_activity(unifi_priv_t
*priv
, u16 interfaceTag
, const u8
*peerMacAddress
);
1089 void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t
*priv
,u16 interfaceTag
, const CSR_MA_PACKET_CONFIRM
*pkt_cfm
);
1091 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
1092 int uf_install_qdisc(struct net_device
*dev
);
1095 void uf_resume_data_plane(unifi_priv_t
*priv
, int queue
,
1096 CsrWifiMacAddress peer_address
,
1098 void uf_free_pending_rx_packets(unifi_priv_t
*priv
, int queue
,
1099 CsrWifiMacAddress peer_address
,u16 interfaceTag
);
1101 int uf_register_netdev(unifi_priv_t
*priv
, int numOfInterface
);
1102 void uf_unregister_netdev(unifi_priv_t
*priv
);
1104 void uf_net_get_name(struct net_device
*dev
, char *name
, int len
);
1106 void uf_send_queue_info(unifi_priv_t
*priv
);
1107 u16
uf_get_vif_identifier(CsrWifiRouterCtrlMode mode
, u16 tag
);
1109 void uf_process_rx_pending_queue(unifi_priv_t
*priv
, int queue
,
1110 CsrWifiMacAddress source_address
,
1111 int indicate
, u16 interfaceTag
);
1113 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1114 int uf_register_hip_offline_debug(unifi_priv_t
*priv
);
1115 int uf_unregister_hip_offline_debug(unifi_priv_t
*priv
);
1121 void uf_register_inet_notifier(void);
1122 void uf_unregister_inet_notifier(void);
1126 * Suspend / Resume handlers
1128 void unifi_resume(void *ospriv
);
1129 void unifi_suspend(void *ospriv
);
1132 #define QOS_CAPABILITY_WMM_ENABLED 0x0001
1133 #define QOS_CAPABILITY_WMM_UAPSD 0x0002
1134 #define QOS_CAPABILITY_ACM_BE_ENABLED 0x0010
1135 #define QOS_CAPABILITY_ACM_BK_ENABLED 0x0020
1136 #define QOS_CAPABILITY_ACM_VI_ENABLED 0x0040
1137 #define QOS_CAPABILITY_ACM_VO_ENABLED 0x0080
1138 #define QOS_CAPABILITY_TS_BE_ENABLED 0x0100
1139 #define QOS_CAPABILITY_TS_BK_ENABLED 0x0200
1140 #define QOS_CAPABILITY_TS_VI_ENABLED 0x0400
1141 #define QOS_CAPABILITY_TS_VO_ENABLED 0x0800
1146 #define ETH_P_PAE 0x888e
1149 #define ETH_P_WAI 0x88b4
1154 void debug_string_indication(unifi_priv_t
*priv
,
1155 const unsigned char *extra
,
1156 unsigned int extralen
);
1157 void debug_word16_indication(unifi_priv_t
*priv
, const CSR_SIGNAL
*sigptr
);
1158 void debug_generic_indication(unifi_priv_t
*priv
, const CSR_SIGNAL
*sigptr
);
1164 int unifi_putest_start(unifi_priv_t
*priv
, unsigned char *arg
);
1165 int unifi_putest_cmd52_block_read(unifi_priv_t
*priv
, unsigned char *arg
);
1166 int unifi_putest_stop(unifi_priv_t
*priv
, unsigned char *arg
);
1167 int unifi_putest_set_sdio_clock(unifi_priv_t
*priv
, unsigned char *arg
);
1168 int unifi_putest_cmd52_read(unifi_priv_t
*priv
, unsigned char *arg
);
1169 int unifi_putest_coredump_prepare(unifi_priv_t
*priv
, unsigned char *arg
);
1170 int unifi_putest_cmd52_write(unifi_priv_t
*priv
, unsigned char *arg
);
1171 int unifi_putest_gp_read16(unifi_priv_t
*priv
, unsigned char *arg
);
1172 int unifi_putest_gp_write16(unifi_priv_t
*priv
, unsigned char *arg
);
1174 int unifi_putest_dl_fw(unifi_priv_t
*priv
, unsigned char *arg
);
1175 int unifi_putest_dl_fw_buff(unifi_priv_t
*priv
, unsigned char *arg
);
1177 #endif /* __LINUX_UNIFI_PRIV_H__ */