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>
28 #include <linux/netdevice.h>
29 #include <linux/wireless.h>
34 #ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
46 #include <linux/wakelock.h>
53 #ifndef CSR_WIFI_HIP_TA_DISABLE
60 #ifdef CSR_SUPPORT_WEXT_AP
61 struct CsrWifiSmeApConfig;
62 typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
64 #ifdef CSR_SUPPORT_WEXT
69 extern struct wake_lock unifi_sdio_wake_lock;
74 #ifdef CSR_NATIVE_LINUX
75 #include "sme_native/unifi_native.h"
81 #define UNIFI_NAME "unifi"
88 #define MAX_UNIFI_DEVS 2
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
106 #define IEEE802_11_ADDR3_OFFSET 16
107 #define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
108 #define IEEE802_11_MAX_DATA_LEN 2304
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
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
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
143 #define INACTIVITY_CHECK_INTERVAL 300000000
145 #define MAX_INACTIVITY_INTERVAL 300000000
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
157 #define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000
160 #define ADDRESS_ONE_OFFSET 20
163 #define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1
164 #define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30
165 #define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000
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)
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)
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)
205 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
206 extern int log_hip_signals;
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
304 #ifdef CSR_SUPPORT_SME
312 u16 listenIntervalInTus;
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
343 #ifdef CSR_SUPPORT_WEXT_AP
344 struct CsrWifiSmeApConfig {
353 #ifdef CSR_WIFI_RX_PATH_SPLIT
355 #define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
369 rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE];
370 } rxCircularBuffer_t;
440 #ifdef USE_DRIVER_LOCK
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
464 #ifdef CSR_SUPPORT_SME
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
479 #ifdef CSR_NATIVE_LINUX
480 #ifdef CSR_SUPPORT_WEXT
482 struct wext_config wext_conf;
493 #ifdef CSR_SUPPORT_SME
509 struct ta_sample_ind {
513 } ta_sample_ind_work;
524 wifi_on_unspecified = -1,
525 wifi_on_in_progress = 0,
537 #define MAX_MA_UNIDATA_IND_FILTERS 8
542 unsigned char *filter_tclas_ies;
545 #ifdef CSR_SUPPORT_WEXT
547 int ignore_bssid_join;
554 int wep_tx_key_index;
558 #ifdef CSR_SUPPORT_WEXT_AP
561 CsrWifiSmeApConfig_t ap_config;
569 #ifdef CSR_SME_USERSPACE
592 #define UF_UNCONTROLLED_PORT_Q 0
593 #define UF_CONTROLLED_PORT_Q 1
603 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
613 #ifdef CSR_WIFI_RX_PATH_SPLIT
616 rxCircularBuffer_t rxSignalBuffer;
625 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
627 u8 wapi_multicast_filter;
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
691 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
709 #ifdef CSR_SUPPORT_WEXT
711 u8 wait_netdev_change;
713 u8 netdev_callback_registered;
716 #define UNIFI_MAX_MULTICAST_ADDRESSES 10
722 #ifdef CSR_SUPPORT_SME
728 u8 num_stations_joined;
731 struct list_head genericMulticastOrBroadCastFrames;
732 struct list_head genericMulticastOrBroadCastMgtFrames;
736 u8 sta_activity_check_enabled;
742 u16 noOfbroadcastPktQueued;
752 #if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
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);
781 #define UNLOCK_DRIVER(_p) (void)(_p);
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)
845 #define _sdio_claim_host(_func)
846 #define _sdio_release_host(_func)
848 #define CsrSdioClaim(function)
849 #define CsrSdioRelease(function)
895 #define CLI_USING_WIRE_FORMAT 0x0002
896 #define CLI_SME_USERSPACE 0x0020
898 unsigned int configuration,
906 unsigned char *sigptr,
int siglen,
921 #ifdef CSR_SUPPORT_SME
929 u8 macHeaderLengthInBytes);
931 void uf_process_wmm_deliver_ac_uapsd (
unifi_priv_t * priv,
948 #ifdef CSR_SUPPORT_SME
950 int uf_process_station_records_for_sending_data(
unifi_priv_t *priv,
u16 interfaceTag,
953 void uf_prepare_send_cfm_list_for_queued_pkts(
unifi_priv_t * priv,
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);
969 #ifndef P80211_OUI_LEN
970 #define P80211_OUI_LEN 3
1010 #define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
1012 #define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
1014 #define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
1017 #define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
1035 #ifdef CSR_SUPPORT_SME
1037 s8 uf_get_protection_bit_from_interfacemode(
unifi_priv_t *priv,
u16 interfaceTag,
const u8 *daddr);
1041 #ifdef CSR_SUPPORT_SME
1043 const u8 *peerMacAddress,
1051 void uf_update_sta_activity(
unifi_priv_t *priv,
u16 interfaceTag,
const u8 *peerMacAddress);
1071 int indicate,
u16 interfaceTag);
1073 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1075 int uf_unregister_hip_offline_debug(
unifi_priv_t *priv);
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
1115 const unsigned char *
extra,
1116 unsigned int extralen);