1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ 3 4 #ifndef __RTW_MLME_EXT_H_ 5 #define __RTW_MLME_EXT_H_ 6 7 #include "osdep_service.h" 8 #include "drv_types.h" 9 #include "wlan_bssdef.h" 10 11 /* Commented by Albert 20101105 */ 12 /* Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms ) */ 13 /* The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */ 14 /* So, this driver tried to extend the dwell time for each scanning channel. */ 15 /* This will increase the chance to receive the probe response from SoftAP. */ 16 17 #define SURVEY_TO (100) 18 #define REAUTH_TO (300) /* 50) */ 19 #define REASSOC_TO (300) /* 50) */ 20 /* define DISCONNECT_TO (3000) */ 21 #define ADDBA_TO (2000) 22 23 #define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */ 24 25 #define REAUTH_LIMIT (4) 26 #define REASSOC_LIMIT (4) 27 28 #define DYNAMIC_FUNC_DISABLE (0x0) 29 30 /* ====== ODM_ABILITY_E ======== */ 31 /* BB ODM section BIT 0-15 */ 32 #define DYNAMIC_BB_DIG BIT(0) 33 34 #define DYNAMIC_ALL_FUNC_ENABLE 0xFFFFFFF 35 36 #define _HW_STATE_NOLINK_ 0x00 37 #define _HW_STATE_ADHOC_ 0x01 38 #define _HW_STATE_STATION_ 0x02 39 #define _HW_STATE_AP_ 0x03 40 41 #define _1M_RATE_ 0 42 #define _2M_RATE_ 1 43 #define _5M_RATE_ 2 44 #define _11M_RATE_ 3 45 #define _6M_RATE_ 4 46 #define _9M_RATE_ 5 47 #define _12M_RATE_ 6 48 #define _18M_RATE_ 7 49 #define _24M_RATE_ 8 50 #define _36M_RATE_ 9 51 #define _48M_RATE_ 10 52 #define _54M_RATE_ 11 53 54 extern unsigned char RTW_WPA_OUI[]; 55 extern unsigned char WMM_OUI[]; 56 extern unsigned char WPS_OUI[]; 57 extern unsigned char WFD_OUI[]; 58 extern unsigned char P2P_OUI[]; 59 60 extern unsigned char WMM_INFO_OUI[]; 61 extern unsigned char WMM_PARA_OUI[]; 62 63 /* Channel Plan Type. */ 64 /* Note: */ 65 /* We just add new channel plan when the new channel plan is different 66 * from any of the following channel plan. */ 67 /* If you just want to customize the actions(scan period or join actions) 68 * about one of the channel plan, */ 69 /* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */ 70 enum RT_CHANNEL_DOMAIN { 71 /* old channel plan mapping ===== */ 72 RT_CHANNEL_DOMAIN_FCC = 0x00, 73 RT_CHANNEL_DOMAIN_IC = 0x01, 74 RT_CHANNEL_DOMAIN_ETSI = 0x02, 75 RT_CHANNEL_DOMAIN_SPAIN = 0x03, 76 RT_CHANNEL_DOMAIN_FRANCE = 0x04, 77 RT_CHANNEL_DOMAIN_MKK = 0x05, 78 RT_CHANNEL_DOMAIN_MKK1 = 0x06, 79 RT_CHANNEL_DOMAIN_ISRAEL = 0x07, 80 RT_CHANNEL_DOMAIN_TELEC = 0x08, 81 RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09, 82 RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A, 83 RT_CHANNEL_DOMAIN_TAIWAN = 0x0B, 84 RT_CHANNEL_DOMAIN_CHINA = 0x0C, 85 RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D, 86 RT_CHANNEL_DOMAIN_KOREA = 0x0E, 87 RT_CHANNEL_DOMAIN_TURKEY = 0x0F, 88 RT_CHANNEL_DOMAIN_JAPAN = 0x10, 89 RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11, 90 RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12, 91 RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14, 92 93 /* new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */ 94 RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20, 95 RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21, 96 RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22, 97 RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23, 98 RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24, 99 RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25, 100 RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26, 101 RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27, 102 RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28, 103 RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29, 104 RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30, 105 RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31, 106 RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32, 107 RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33, 108 RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34, 109 RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35, 110 RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36, 111 RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37, 112 RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38, 113 RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39, 114 RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40, 115 RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41, 116 /* Add new channel plan above this line=============== */ 117 RT_CHANNEL_DOMAIN_MAX, 118 RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F, 119 }; 120 121 enum RT_CHANNEL_DOMAIN_2G { 122 RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwide 13 */ 123 RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */ 124 RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */ 125 RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03, /* Japan */ 126 RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04, /* France */ 127 RT_CHANNEL_DOMAIN_2G_NULL = 0x05, 128 /* Add new channel plan above this line=============== */ 129 RT_CHANNEL_DOMAIN_2G_MAX, 130 }; 131 132 #define rtw_is_channel_plan_valid(chplan) \ 133 (chplan < RT_CHANNEL_DOMAIN_MAX || \ 134 chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) 135 136 struct rt_channel_plan { 137 unsigned char Channel[MAX_CHANNEL_NUM]; 138 unsigned char Len; 139 }; 140 141 struct rt_channel_plan_map { 142 unsigned char Index2G; 143 }; 144 145 enum Associated_AP { 146 atherosAP = 0, 147 broadcomAP = 1, 148 ciscoAP = 2, 149 marvellAP = 3, 150 ralinkAP = 4, 151 realtekAP = 5, 152 airgocapAP = 6, 153 unknownAP = 7, 154 maxAP, 155 }; 156 157 enum HT_IOT_PEER { 158 HT_IOT_PEER_UNKNOWN = 0, 159 HT_IOT_PEER_REALTEK = 1, 160 HT_IOT_PEER_REALTEK_92SE = 2, 161 HT_IOT_PEER_BROADCOM = 3, 162 HT_IOT_PEER_RALINK = 4, 163 HT_IOT_PEER_ATHEROS = 5, 164 HT_IOT_PEER_CISCO = 6, 165 HT_IOT_PEER_MERU = 7, 166 HT_IOT_PEER_MARVELL = 8, 167 HT_IOT_PEER_REALTEK_SOFTAP = 9,/* peer is RealTek SOFT_AP */ 168 HT_IOT_PEER_SELF_SOFTAP = 10, /* Self is SoftAP */ 169 HT_IOT_PEER_AIRGO = 11, 170 HT_IOT_PEER_INTEL = 12, 171 HT_IOT_PEER_RTK_APCLIENT = 13, 172 HT_IOT_PEER_REALTEK_81XX = 14, 173 HT_IOT_PEER_REALTEK_WOW = 15, 174 HT_IOT_PEER_TENDA = 16, 175 HT_IOT_PEER_MAX = 17 176 }; 177 178 enum SCAN_STATE { 179 SCAN_DISABLE = 0, 180 SCAN_START = 1, 181 SCAN_TXNULL = 2, 182 SCAN_PROCESS = 3, 183 SCAN_COMPLETE = 4, 184 SCAN_STATE_MAX, 185 }; 186 187 typedef unsigned int (*mlme_handler)(struct adapter *adapt, struct recv_frame *frame); 188 189 struct ss_res { 190 int state; 191 int bss_cnt; 192 int channel_idx; 193 int scan_mode; 194 u8 ssid_num; 195 u8 ch_num; 196 struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; 197 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; 198 }; 199 200 /* define AP_MODE 0x0C */ 201 /* define STATION_MODE 0x08 */ 202 /* define AD_HOC_MODE 0x04 */ 203 /* define NO_LINK_MODE 0x00 */ 204 205 #define WIFI_FW_NULL_STATE _HW_STATE_NOLINK_ 206 #define WIFI_FW_STATION_STATE _HW_STATE_STATION_ 207 #define WIFI_FW_AP_STATE _HW_STATE_AP_ 208 #define WIFI_FW_ADHOC_STATE _HW_STATE_ADHOC_ 209 210 #define WIFI_FW_AUTH_NULL 0x00000100 211 #define WIFI_FW_AUTH_STATE 0x00000200 212 #define WIFI_FW_AUTH_SUCCESS 0x00000400 213 214 #define WIFI_FW_ASSOC_STATE 0x00002000 215 #define WIFI_FW_ASSOC_SUCCESS 0x00004000 216 217 #define WIFI_FW_LINKING_STATE (WIFI_FW_AUTH_NULL | \ 218 WIFI_FW_AUTH_STATE | \ 219 WIFI_FW_AUTH_SUCCESS | \ 220 WIFI_FW_ASSOC_STATE) 221 222 struct FW_Sta_Info { 223 struct sta_info *psta; 224 u32 status; 225 u32 rx_pkt; 226 u32 retry; 227 unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; 228 }; 229 230 /* 231 * Usage: 232 * When one iface acted as AP mode and the other iface is STA mode and scanning, 233 * it should switch back to AP's operating channel periodically. 234 * Parameters info: 235 * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to 236 * AP's operating channel for 237 * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds. 238 * Example: 239 * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1, 240 * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100. 241 * When it's STA mode gets set_scan command, 242 * it would 243 * 1. Doing the scan on channel 1.2.3.4.5.6.7.8 244 * 2. Back to channel 1 for 300 milliseconds 245 * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52 246 * 4. Back to channel 1 for 300 milliseconds 247 * 5. ... and so on, till survey done. 248 */ 249 250 struct mlme_ext_info { 251 u32 state; 252 u32 reauth_count; 253 u32 reassoc_count; 254 u32 link_count; 255 u32 auth_seq; 256 u32 auth_algo; /* 802.11 auth, could be open, shared, auto */ 257 u32 authModeToggle; 258 u32 enc_algo;/* encrypt algorithm; */ 259 u32 key_index; /* this is only valid for legacy wep, 260 * 0~3 for key id. */ 261 u32 iv; 262 u8 chg_txt[128]; 263 u16 aid; 264 u16 bcn_interval; 265 u16 capability; 266 u8 assoc_AP_vendor; 267 u8 slotTime; 268 u8 preamble_mode; 269 u8 WMM_enable; 270 u8 ERP_enable; 271 u8 ERP_IE; 272 u8 HT_enable; 273 u8 HT_caps_enable; 274 u8 HT_info_enable; 275 u8 HT_protection; 276 u8 turboMode_cts2self; 277 u8 turboMode_rtsen; 278 u8 SM_PS; 279 u8 agg_enable_bitmap; 280 u8 ADDBA_retry_count; 281 u8 candidate_tid_bitmap; 282 u8 dialogToken; 283 /* Accept ADDBA Request */ 284 bool bAcceptAddbaReq; 285 u8 bwmode_updated; 286 u8 hidden_ssid_mode; 287 288 struct ADDBA_request ADDBA_req; 289 struct WMM_para_element WMM_param; 290 struct HT_caps_element HT_caps; 291 struct HT_info_element HT_info; 292 struct wlan_bssid_ex network;/* join network or bss_network, 293 * if in ap mode, it is the same 294 * as cur_network.network */ 295 struct FW_Sta_Info FW_sta_info[NUM_STA]; 296 }; 297 298 /* The channel information about this channel including joining, 299 * scanning, and power constraints. */ 300 struct rt_channel_info { 301 u8 ChannelNum; /* The channel number. */ 302 enum rt_scan_type ScanType; /* Scan type such as passive 303 * or active scan. */ 304 u32 rx_count; 305 }; 306 307 int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch); 308 309 /* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */ 310 #define P2P_MAX_REG_CLASSES 10 311 312 /* P2P_MAX_REG_CLASS_CHANNELS - Maximum number of chan per regulatory class */ 313 #define P2P_MAX_REG_CLASS_CHANNELS 20 314 315 /* struct p2p_channels - List of supported channels */ 316 struct p2p_channels { 317 /* struct p2p_reg_class - Supported regulatory class */ 318 struct p2p_reg_class { 319 /* reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */ 320 u8 reg_class; 321 322 /* channel - Supported channels */ 323 u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; 324 325 /* channels - Number of channel entries in use */ 326 size_t channels; 327 } reg_class[P2P_MAX_REG_CLASSES]; 328 329 /* reg_classes - Number of reg_class entries in use */ 330 size_t reg_classes; 331 }; 332 333 struct p2p_oper_class_map { 334 enum hw_mode {IEEE80211G} mode; 335 u8 op_class; 336 u8 min_chan; 337 u8 max_chan; 338 u8 inc; 339 enum {BW20, BW40PLUS, BW40MINUS} bw; 340 }; 341 342 struct mlme_ext_priv { 343 struct adapter *padapter; 344 u8 mlmeext_init; 345 atomic_t event_seq; 346 u16 mgnt_seq; 347 348 unsigned char cur_channel; 349 unsigned char cur_bwmode; 350 unsigned char cur_ch_offset;/* PRIME_CHNL_OFFSET */ 351 unsigned char cur_wireless_mode; /* NETWORK_TYPE */ 352 353 unsigned char oper_channel; /* saved chan info when call 354 * set_channel_bw */ 355 unsigned char oper_bwmode; 356 unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */ 357 358 unsigned char max_chan_nums; 359 struct rt_channel_info channel_set[MAX_CHANNEL_NUM]; 360 struct p2p_channels channel_list; 361 unsigned char basicrate[NumRates]; 362 unsigned char datarate[NumRates]; 363 364 struct ss_res sitesurvey_res; 365 struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including 366 * current scan/connecting/connected 367 * related info. For ap mode, 368 * network includes ap's cap_info*/ 369 struct timer_list survey_timer; 370 struct timer_list link_timer; 371 u16 chan_scan_time; 372 373 u8 scan_abort; 374 u8 tx_rate; /* TXRATE when USERATE is set. */ 375 376 u32 retry; /* retry for issue probereq */ 377 378 u64 TSFValue; 379 380 unsigned char bstart_bss; 381 u8 update_channel_plan_by_ap_done; 382 /* recv_decache check for Action_public frame */ 383 u8 action_public_dialog_token; 384 u16 action_public_rxseq; 385 u8 active_keep_alive_check; 386 }; 387 388 void init_mlme_ext_priv(struct adapter *adapter); 389 int init_hw_mlme_ext(struct adapter *padapter); 390 void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext); 391 extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); 392 393 unsigned char networktype_to_raid(unsigned char network_type); 394 u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len); 395 void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len); 396 397 void Save_DM_Func_Flag(struct adapter *padapter); 398 void Restore_DM_Func_Flag(struct adapter *padapter); 399 400 void Set_MSR(struct adapter *padapter, u8 type); 401 402 u8 rtw_get_oper_ch(struct adapter *adapter); 403 void rtw_set_oper_ch(struct adapter *adapter, u8 ch); 404 void rtw_set_oper_bw(struct adapter *adapter, u8 bw); 405 void rtw_set_oper_choffset(struct adapter *adapter, u8 offset); 406 407 void set_channel_bwmode(struct adapter *padapter, unsigned char channel, 408 unsigned char channel_offset, unsigned short bwmode); 409 void SelectChannel(struct adapter *padapter, unsigned char channel); 410 void SetBWMode(struct adapter *padapter, unsigned short bwmode, 411 unsigned char channel_offset); 412 413 unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval); 414 415 void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); 416 void clear_cam_entry(struct adapter *padapter, u8 entry); 417 418 void invalidate_cam_all(struct adapter *padapter); 419 420 int allocate_fw_sta_entry(struct adapter *padapter); 421 void flush_all_cam_entry(struct adapter *padapter); 422 423 void rtw_mlme_under_site_survey(struct adapter *adapter); 424 void rtw_mlme_site_survey_done(struct adapter *adapter); 425 426 void site_survey(struct adapter *padapter); 427 u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, 428 struct wlan_bssid_ex *bssid); 429 void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, 430 struct adapter *adapter, bool update_ie); 431 432 u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); 433 u16 get_beacon_interval(struct wlan_bssid_ex *bss); 434 435 int is_client_associated_to_ap(struct adapter *padapter); 436 int is_client_associated_to_ibss(struct adapter *padapter); 437 int is_IBSS_empty(struct adapter *padapter); 438 439 unsigned char check_assoc_AP(u8 *pframe, uint len); 440 441 int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); 442 void WMMOnAssocRsp(struct adapter *padapter); 443 444 void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); 445 void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); 446 void HTOnAssocRsp(struct adapter *padapter); 447 448 void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); 449 void VCS_update(struct adapter *padapter, struct sta_info *psta); 450 451 void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, 452 struct sta_info *psta); 453 int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len); 454 void update_IOT_info(struct adapter *padapter); 455 void update_capinfo(struct adapter *adapter, u16 updatecap); 456 void update_wireless_mode(struct adapter *padapter); 457 void rtw_set_basic_rate(struct adapter *adapter, u8 *rates); 458 void update_tx_basic_rate(struct adapter *padapter, u8 modulation); 459 void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id); 460 int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, 461 uint var_ie_len, int cam_idx); 462 463 /* for sta/adhoc mode */ 464 void update_sta_info(struct adapter *padapter, struct sta_info *psta); 465 unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz); 466 unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz); 467 unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps); 468 void Update_RA_Entry(struct adapter *padapter, u32 mac_id); 469 void set_sta_rate(struct adapter *padapter, struct sta_info *psta); 470 471 void receive_disconnect(struct adapter *padapter, unsigned char *macaddr, unsigned short reason); 472 473 unsigned char get_highest_rate_idx(u32 mask); 474 int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps); 475 bool is_ap_in_tkip(struct adapter *padapter); 476 477 void report_join_res(struct adapter *padapter, int res); 478 void report_survey_event(struct adapter *padapter, struct recv_frame *precv_frame); 479 void report_surveydone_event(struct adapter *padapter); 480 void report_del_sta_event(struct adapter *padapter, 481 unsigned char *addr, unsigned short reason); 482 void report_add_sta_event(struct adapter *padapter, unsigned char* addr, 483 int cam_idx); 484 485 void beacon_timing_control(struct adapter *padapter); 486 extern u8 set_tx_beacon_cmd(struct adapter*padapter); 487 unsigned int setup_beacon_frame(struct adapter *padapter, 488 unsigned char *beacon_frame); 489 void update_mgnt_tx_rate(struct adapter *padapter, u8 rate); 490 void update_mgntframe_attrib(struct adapter *padapter, 491 struct pkt_attrib *pattrib); 492 void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe); 493 s32 dump_mgntframe_and_wait(struct adapter *padapter, 494 struct xmit_frame *pmgntframe, int timeout_ms); 495 s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, 496 struct xmit_frame *pmgntframe); 497 498 void issue_probersp_p2p(struct adapter *padapter, unsigned char *da); 499 void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, 500 u8 ussidlen, u8 *pdev_raddr); 501 void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr); 502 void issue_probereq_p2p(struct adapter *padapter, u8 *da); 503 void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, 504 u8 dialogToken, u8 success); 505 void issue_p2p_invitation_request(struct adapter *padapter, u8* raddr); 506 void issue_beacon(struct adapter *padapter, int timeout_ms); 507 void issue_probersp(struct adapter *padapter, unsigned char *da, 508 u8 is_valid_p2p_probereq); 509 void issue_assocreq(struct adapter *padapter); 510 void issue_asocrsp(struct adapter *padapter, unsigned short status, 511 struct sta_info *pstat, int pkt_type); 512 void issue_auth(struct adapter *padapter, struct sta_info *psta, 513 unsigned short status); 514 void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, 515 u8 *da); 516 s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid, 517 u8* da, int try_cnt, int wait_ms); 518 int issue_nulldata(struct adapter *padapter, unsigned char *da, 519 unsigned int power_mode, int try_cnt, int wait_ms); 520 int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, 521 u16 tid, int try_cnt, int wait_ms); 522 int issue_deauth(struct adapter *padapter, unsigned char *da, 523 unsigned short reason); 524 int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, 525 int try_cnt, int wait_ms); 526 void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 action, u16 status); 527 unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr); 528 unsigned int send_beacon(struct adapter *padapter); 529 bool get_beacon_valid_bit(struct adapter *adapter); 530 void clear_beacon_valid_bit(struct adapter *adapter); 531 void rtw_resume_tx_beacon(struct adapter *adapt); 532 void rtw_stop_tx_beacon(struct adapter *adapt); 533 534 void start_clnt_assoc(struct adapter *padapter); 535 void start_clnt_auth(struct adapter *padapter); 536 void start_clnt_join(struct adapter *padapter); 537 void start_create_ibss(struct adapter *padapter); 538 539 unsigned int OnAssocReq(struct adapter *padapter, 540 struct recv_frame *precv_frame); 541 unsigned int OnAssocRsp(struct adapter *padapter, 542 struct recv_frame *precv_frame); 543 unsigned int OnProbeReq(struct adapter *padapter, 544 struct recv_frame *precv_frame); 545 unsigned int OnProbeRsp(struct adapter *padapter, 546 struct recv_frame *precv_frame); 547 unsigned int OnBeacon(struct adapter *padapter, 548 struct recv_frame *precv_frame); 549 unsigned int OnDisassoc(struct adapter *padapter, 550 struct recv_frame *precv_frame); 551 unsigned int OnAuth(struct adapter *padapter, 552 struct recv_frame *precv_frame); 553 unsigned int OnAuthClient(struct adapter *padapter, 554 struct recv_frame *precv_frame); 555 unsigned int OnDeAuth(struct adapter *padapter, 556 struct recv_frame *precv_frame); 557 unsigned int OnAction(struct adapter *padapter, 558 struct recv_frame *precv_frame); 559 560 unsigned int OnAction_back(struct adapter *padapter, 561 struct recv_frame *precv_frame); 562 unsigned int on_action_public(struct adapter *padapter, 563 struct recv_frame *precv_frame); 564 unsigned int OnAction_p2p(struct adapter *padapter, 565 struct recv_frame *precv_frame); 566 567 void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); 568 void mlmeext_sta_del_event_callback(struct adapter *padapter); 569 void mlmeext_sta_add_event_callback(struct adapter *padapter, 570 struct sta_info *psta); 571 572 void linked_status_chk(struct adapter *padapter); 573 574 void survey_timer_hdl (struct adapter *padapter); 575 void link_timer_hdl (struct adapter *padapter); 576 void addba_timer_hdl(struct sta_info *psta); 577 578 #define set_survey_timer(mlmeext, ms) \ 579 do { \ 580 _set_timer(&(mlmeext)->survey_timer, (ms)); \ 581 } while (0) 582 583 #define set_link_timer(mlmeext, ms) \ 584 do { \ 585 _set_timer(&(mlmeext)->link_timer, (ms)); \ 586 } while (0) 587 588 bool cckrates_included(unsigned char *rate, int ratelen); 589 bool cckratesonly_included(unsigned char *rate, int ratelen); 590 591 struct cmd_hdl { 592 uint parmsize; 593 u8 (*h2cfuns)(struct adapter *padapter, u8 *pbuf); 594 }; 595 596 u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf); 597 u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf); 598 u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf); 599 u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf); 600 u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf); 601 u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf); 602 u8 NULL_hdl(struct adapter *padapter, u8 *pbuf); 603 u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf); 604 u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf); 605 u8 createbss_hdl(struct adapter *padapter, u8 *pbuf); 606 u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf); 607 u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf); 608 u8 setauth_hdl(struct adapter *padapter, u8 *pbuf); 609 u8 setkey_hdl(struct adapter *padapter, u8 *pbuf); 610 u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf); 611 u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf); 612 u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf); 613 u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf); 614 615 u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf); 616 u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf); 617 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf); 618 u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf); 619 u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf); 620 u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf); 621 /* Handling DFS channel switch announcement ie. */ 622 u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf); 623 u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf); 624 625 #define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl}, 626 #define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd}, 627 628 #ifdef _RTW_CMD_C_ 629 630 static struct cmd_hdl wlancmds[] = { 631 GEN_DRV_CMD_HANDLER(0, NULL) /*0*/ 632 GEN_DRV_CMD_HANDLER(0, NULL) 633 GEN_DRV_CMD_HANDLER(0, NULL) 634 GEN_DRV_CMD_HANDLER(0, NULL) 635 GEN_DRV_CMD_HANDLER(0, NULL) 636 GEN_DRV_CMD_HANDLER(0, NULL) 637 GEN_MLME_EXT_HANDLER(0, NULL) 638 GEN_MLME_EXT_HANDLER(0, NULL) 639 GEN_MLME_EXT_HANDLER(0, NULL) 640 GEN_MLME_EXT_HANDLER(0, NULL) 641 GEN_MLME_EXT_HANDLER(0, NULL) /*10*/ 642 GEN_MLME_EXT_HANDLER(0, NULL) 643 GEN_MLME_EXT_HANDLER(0, NULL) 644 GEN_MLME_EXT_HANDLER(0, NULL) 645 GEN_MLME_EXT_HANDLER(sizeof (struct joinbss_parm), join_cmd_hdl) /*14*/ 646 GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl) 647 GEN_MLME_EXT_HANDLER(sizeof (struct createbss_parm), createbss_hdl) 648 GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl) 649 GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), 650 sitesurvey_cmd_hdl) /*18*/ 651 GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl) 652 GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) /*20*/ 653 GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl) 654 GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) 655 GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL) 656 GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL) 657 GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL) 658 GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL) 659 GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL) 660 GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL) 661 GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL) 662 GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL) /*30*/ 663 GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL) 664 GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL) 665 GEN_MLME_EXT_HANDLER(0, NULL) 666 GEN_MLME_EXT_HANDLER(0, NULL) 667 GEN_MLME_EXT_HANDLER(0, NULL) 668 GEN_MLME_EXT_HANDLER(0, NULL) 669 GEN_MLME_EXT_HANDLER(0, NULL) 670 GEN_MLME_EXT_HANDLER(0, NULL) 671 GEN_MLME_EXT_HANDLER(0, NULL) 672 GEN_MLME_EXT_HANDLER(0, NULL) /*40*/ 673 GEN_MLME_EXT_HANDLER(0, NULL) 674 GEN_MLME_EXT_HANDLER(0, NULL) 675 GEN_MLME_EXT_HANDLER(0, NULL) 676 GEN_MLME_EXT_HANDLER(0, NULL) 677 GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl) 678 GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) /* 46 */ 679 GEN_MLME_EXT_HANDLER(0, NULL) 680 GEN_MLME_EXT_HANDLER(0, NULL) 681 GEN_MLME_EXT_HANDLER(0, NULL) 682 GEN_MLME_EXT_HANDLER(0, NULL) /*50*/ 683 GEN_MLME_EXT_HANDLER(0, NULL) 684 GEN_MLME_EXT_HANDLER(0, NULL) 685 GEN_MLME_EXT_HANDLER(0, NULL) 686 GEN_MLME_EXT_HANDLER(0, NULL) 687 GEN_MLME_EXT_HANDLER(sizeof(struct Tx_Beacon_param), 688 tx_beacon_hdl) /*55*/ 689 690 GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl) /*56*/ 691 GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl) /*57*/ 692 693 GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl) /*58*/ 694 GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), 695 set_chplan_hdl) /*59*/ 696 GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param), 697 led_blink_hdl) /*60*/ 698 699 GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), 700 set_csa_hdl) /*61*/ 701 GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), 702 tdls_hdl) /*62*/ 703 }; 704 705 #endif 706 707 struct C2HEvent_Header { 708 #ifdef __LITTLE_ENDIAN 709 unsigned int len:16; 710 unsigned int ID:8; 711 unsigned int seq:8; 712 #elif defined(__BIG_ENDIAN) 713 unsigned int seq:8; 714 unsigned int ID:8; 715 unsigned int len:16; 716 #endif 717 unsigned int rsvd; 718 }; 719 720 enum rtw_c2h_event { 721 GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/ 722 GEN_EVT_CODE(_Read_BBREG), 723 GEN_EVT_CODE(_Read_RFREG), 724 GEN_EVT_CODE(_Read_EEPROM), 725 GEN_EVT_CODE(_Read_EFUSE), 726 GEN_EVT_CODE(_Read_CAM), /*5*/ 727 GEN_EVT_CODE(_Get_BasicRate), 728 GEN_EVT_CODE(_Get_DataRate), 729 GEN_EVT_CODE(_Survey), /*8*/ 730 GEN_EVT_CODE(_SurveyDone), /*9*/ 731 732 GEN_EVT_CODE(_JoinBss) , /*10*/ 733 GEN_EVT_CODE(_AddSTA), 734 GEN_EVT_CODE(_DelSTA), 735 GEN_EVT_CODE(_AtimDone), 736 GEN_EVT_CODE(_TX_Report), 737 GEN_EVT_CODE(_CCX_Report), /*15*/ 738 GEN_EVT_CODE(_DTM_Report), 739 GEN_EVT_CODE(_TX_Rate_Statistics), 740 GEN_EVT_CODE(_C2HLBK), 741 GEN_EVT_CODE(_FWDBG), 742 GEN_EVT_CODE(_C2HFEEDBACK), /*20*/ 743 GEN_EVT_CODE(_ADDBA), 744 GEN_EVT_CODE(_C2HBCN), 745 GEN_EVT_CODE(_ReportPwrState), /* filen: only for PCIE, USB */ 746 GEN_EVT_CODE(_CloseRF), /* filen: only for PCIE, 747 * work around ASPM */ 748 MAX_C2HEVT 749 }; 750 751 #ifdef _RTW_MLME_EXT_C_ 752 753 static struct fwevent wlanevents[] = { 754 {0, NULL}, /*0*/ 755 {0, NULL}, 756 {0, NULL}, 757 {0, NULL}, 758 {0, NULL}, 759 {0, NULL}, 760 {0, NULL}, 761 {0, NULL}, 762 {0, &rtw_survey_event_callback}, /*8*/ 763 {sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ 764 {0, &rtw_joinbss_event_callback}, /*10*/ 765 {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, 766 {sizeof(struct stadel_event), &rtw_stadel_event_callback}, 767 {0, NULL}, 768 {0, NULL}, 769 {0, NULL}, /*15*/ 770 {0, NULL}, 771 {0, NULL}, 772 {0, NULL}, 773 {0, NULL}, 774 {0, NULL}, /*20*/ 775 {0, NULL}, 776 {0, NULL}, 777 {0, NULL}, 778 {0, NULL}, 779 }; 780 781 #endif/* _RTL_MLME_EXT_C_ */ 782 783 #endif /* __RTW_MLME_EXT_H_ */ 784