linux/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h

/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
 *
 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
 *
 ******************************************************************************/
#ifndef __RTW_MLME_EXT_H_
#define __RTW_MLME_EXT_H_


/* 	Commented by Albert 20101105 */
/* 	Increase the SURVEY_TO value from 100 to 150  (100ms to 150ms) */
/* 	The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
/* 	So, this driver tried to extend the dwell time for each scanning channel. */
/* 	This will increase the chance to receive the probe response from SoftAP. */

#define SURVEY_TO
#define REAUTH_TO
#define REASSOC_TO
/* define DISCONNECT_TO	(3000) */
#define ADDBA_TO

#define REAUTH_LIMIT
#define REASSOC_LIMIT

#define DYNAMIC_FUNC_DISABLE

/*  ====== ODM_ABILITY_E ======== */
/*  BB ODM section BIT 0-15 */
#define DYNAMIC_BB_DIG
#define DYNAMIC_BB_DYNAMIC_TXPWR
#define DYNAMIC_BB_ANT_DIV

/*  RF ODM section BIT 24-31 */
#define DYNAMIC_RF_CALIBRATION

#define DYNAMIC_ALL_FUNC_ENABLE

#define _HW_STATE_NOLINK_
#define _HW_STATE_ADHOC_
#define _HW_STATE_STATION_
#define _HW_STATE_AP_


#define _1M_RATE_
#define _2M_RATE_
#define _5M_RATE_
#define _11M_RATE_
#define _6M_RATE_
#define _9M_RATE_
#define _12M_RATE_
#define _18M_RATE_
#define _24M_RATE_
#define _36M_RATE_
#define _48M_RATE_
#define _54M_RATE_

/********************************************************
MCS rate definitions
*********************************************************/
#define MCS_RATE_1R

extern unsigned char RTW_WPA_OUI[];
extern unsigned char WMM_OUI[];
extern unsigned char WPS_OUI[];
extern unsigned char WFD_OUI[];
extern unsigned char P2P_OUI[];

extern unsigned char WMM_INFO_OUI[];
extern unsigned char WMM_PARA_OUI[];


/*  */
/*  Channel Plan Type. */
/*  Note: */
/* 	We just add new channel plan when the new channel plan is different from any of the following */
/* 	channel plan. */
/* 	If you just want to customize the actions(scan period or join actions) about one of the channel plan, */
/* 	customize them in rt_channel_info in the RT_CHANNEL_LIST. */
/*  */
enum {};

enum {};

#define rtw_is_channel_plan_valid(chplan)

struct rt_channel_plan {};

struct rt_channel_plan_2g {};

struct rt_channel_plan_map {};

enum {};


enum {};

struct mlme_handler {};

struct action_handler {};

struct	ss_res {};

/* define AP_MODE				0x0C */
/* define STATION_MODE	0x08 */
/* define AD_HOC_MODE		0x04 */
/* define NO_LINK_MODE	0x00 */

#define WIFI_FW_NULL_STATE
#define WIFI_FW_STATION_STATE
#define WIFI_FW_AP_STATE
#define WIFI_FW_ADHOC_STATE

#define WIFI_FW_AUTH_NULL
#define WIFI_FW_AUTH_STATE
#define WIFI_FW_AUTH_SUCCESS

#define WIFI_FW_ASSOC_STATE
#define WIFI_FW_ASSOC_SUCCESS

#define WIFI_FW_LINKING_STATE

struct FW_Sta_Info {};

/*
 * Usage:
 * When one iface acted as AP mode and the other iface is STA mode and scanning,
 * it should switch back to AP's operating channel periodically.
 * Parameters info:
 * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to AP's operating channel for
 * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
 * Example:
 * For chip supports 2.4G and AP mode is operating in channel 1,
 * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MILLISECOND is 3 and SURVEY_TO is 100.
 * When it's STA mode gets set_scan command,
 * it would
 * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
 * 2. Back to channel 1 for 300 milliseconds
 * 3. Go through doing site survey on channel 9.10.11
 * 4. Back to channel 1 for 300 milliseconds
 * 5. ... and so on, till survey done.
 */
struct mlme_ext_info {};

/*  The channel information about this channel including joining, scanning, and power constraints. */
struct rt_channel_info {};

int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch);

/*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
#define P2P_MAX_REG_CLASSES

/*  P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class */
#define P2P_MAX_REG_CLASS_CHANNELS

/*   struct p2p_channels - List of supported channels */
struct p2p_channels {};

struct p2p_oper_class_map {};

struct mlme_ext_priv {};

void init_mlme_default_rate_set(struct adapter *padapter);
void init_mlme_ext_priv(struct adapter *padapter);
int init_hw_mlme_ext(struct adapter *padapter);
void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext);
extern void init_mlme_ext_timer(struct adapter *padapter);
extern void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta);
extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);

/* void fill_fwpriv(struct adapter *padapter, struct fw_priv *pfwpriv); */

u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta);

void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len);
void set_mcs_rate_by_mask(u8 *mcs_set, u32 mask);
void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS);
void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen);

void Save_DM_Func_Flag(struct adapter *padapter);
void Restore_DM_Func_Flag(struct adapter *padapter);
void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable);

void Set_MSR(struct adapter *padapter, u8 type);

u8 rtw_get_oper_ch(struct adapter *adapter);
void rtw_set_oper_ch(struct adapter *adapter, u8 ch);
u8 rtw_get_oper_bw(struct adapter *adapter);
void rtw_set_oper_bw(struct adapter *adapter, u8 bw);
u8 rtw_get_oper_choffset(struct adapter *adapter);
void rtw_set_oper_choffset(struct adapter *adapter, u8 offset);
u8 rtw_get_center_ch(u8 channel, u8 chnl_bw, u8 chnl_offset);
unsigned long rtw_get_on_cur_ch_time(struct adapter *adapter);

void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode);
void SelectChannel(struct adapter *padapter, unsigned char channel);

unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval);

void read_cam(struct adapter *padapter, u8 entry, u8 *get_key);

/* modify HW only */
void _write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
void _clear_cam_entry(struct adapter *padapter, u8 entry);

/* modify both HW and cache */
void write_cam(struct adapter *padapter, u8 id, u16 ctrl, u8 *mac, u8 *key);
void clear_cam_entry(struct adapter *padapter, u8 id);

/* modify cache only */
void write_cam_cache(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key);
void clear_cam_cache(struct adapter *adapter, u8 id);

void invalidate_cam_all(struct adapter *padapter);


int allocate_fw_sta_entry(struct adapter *padapter);
void flush_all_cam_entry(struct adapter *padapter);

void site_survey(struct adapter *padapter);
u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, struct wlan_bssid_ex *bssid);
void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *padapter, bool update_ie);

u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork);
u16 get_beacon_interval(struct wlan_bssid_ex *bss);

int is_client_associated_to_ap(struct adapter *padapter);
int is_client_associated_to_ibss(struct adapter *padapter);
int is_IBSS_empty(struct adapter *padapter);

unsigned char check_assoc_AP(u8 *pframe, uint len);

int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void WMMOnAssocRsp(struct adapter *padapter);

void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void HTOnAssocRsp(struct adapter *padapter);

void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void VCS_update(struct adapter *padapter, struct sta_info *psta);
void update_ldpc_stbc_cap(struct sta_info *psta);

void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, struct sta_info *psta);
int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len);
void update_IOT_info(struct adapter *padapter);
void update_capinfo(struct adapter *Adapter, u16 updateCap);
void update_wireless_mode(struct adapter *padapter);
void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode);
int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx);

/* for sta/adhoc mode */
void update_sta_info(struct adapter *padapter, struct sta_info *psta);
void Update_RA_Entry(struct adapter *padapter, struct sta_info *psta);
void set_sta_rate(struct adapter *padapter, struct sta_info *psta);

unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);

unsigned char get_highest_rate_idx(u32 mask);
int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode);
unsigned int is_ap_in_tkip(struct adapter *padapter);

s16 rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid);
s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid);
void rtw_camid_free(struct adapter *adapter, u8 cam_id);

extern void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta);
extern void rtw_release_macid(struct adapter *padapter, struct sta_info *psta);
extern u8 rtw_search_max_mac_id(struct adapter *padapter);

void report_join_res(struct adapter *padapter, int res);
void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame);
void report_surveydone_event(struct adapter *padapter);
void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);
void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx);
void report_wmm_edca_update(struct adapter *padapter);

u8 chk_bmc_sleepq_cmd(struct adapter *padapter);
extern u8 set_tx_beacon_cmd(struct adapter *padapter);
unsigned int setup_beacon_frame(struct adapter *padapter, unsigned char *beacon_frame);
void update_mgnt_tx_rate(struct adapter *padapter, u8 rate);
void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib);
void update_mgntframe_attrib_addr(struct adapter *padapter, struct xmit_frame *pmgntframe);
void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe);
s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms);
s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe);

void issue_beacon(struct adapter *padapter, int timeout_ms);
void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq);
void issue_assocreq(struct adapter *padapter);
void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status);
void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
s32 issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, u8 ch, bool append_wps, int try_cnt, int wait_ms);
int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da);
int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms);
int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason);
int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt, int wait_ms);
void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status);
void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short tid);
unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
unsigned int send_beacon(struct adapter *padapter);

void start_clnt_assoc(struct adapter *padapter);
void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame);

unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_sa_query(struct adapter *padapter, union recv_frame *precv_frame);

void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res);
void mlmeext_sta_del_event_callback(struct adapter *padapter);
void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta);

void linked_status_chk(struct adapter *padapter);

void _linked_info_dump(struct adapter *padapter);

void survey_timer_hdl(struct timer_list *t);
void link_timer_hdl(struct timer_list *t);
void addba_timer_hdl(struct timer_list *t);
void sa_query_timer_hdl(struct timer_list *t);
/* void reauth_timer_hdl(struct adapter *padapter); */
/* void reassoc_timer_hdl(struct adapter *padapter); */

#define set_survey_timer(mlmeext, ms)

#define set_link_timer(mlmeext, ms)
#define set_sa_query_timer(mlmeext, ms)

extern void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr);

extern void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
extern void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext);
extern void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
extern u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer);

int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset);

struct cmd_hdl {};


u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf);
u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf);
u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf);


u8 NULL_hdl(struct adapter *padapter, u8 *pbuf);
u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf);
u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf);
u8 createbss_hdl(struct adapter *padapter, u8 *pbuf);
u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf);
u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf);
u8 setauth_hdl(struct adapter *padapter, u8 *pbuf);
u8 setkey_hdl(struct adapter *padapter, u8 *pbuf);
u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf);
u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf);

u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf);	/* Kurt: Handling DFS channel switch announcement ie. */
u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf);


#define GEN_DRV_CMD_HANDLER(size, cmd)
#define GEN_MLME_EXT_HANDLER(size, cmd)

struct C2HEvent_Header {};

void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf);
void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf);

enum {};


#ifdef _RTW_MLME_EXT_C_

#endif/* _RTL8192C_CMD_C_ */

#endif