Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /******************************************************************************
0003  *
0004  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
0005  *
0006  * Modifications for inclusion into the Linux staging tree are
0007  * Copyright(c) 2010 Larry Finger. All rights reserved.
0008  *
0009  * Contact information:
0010  * WLAN FAE <wlanfae@realtek.com>
0011  * Larry Finger <Larry.Finger@lwfinger.net>
0012  *
0013  ******************************************************************************/
0014 #ifndef __RTL871X_MLME_H_
0015 #define __RTL871X_MLME_H_
0016 
0017 #include "osdep_service.h"
0018 #include "drv_types.h"
0019 #include "wlan_bssdef.h"
0020 
0021 #define MAX_BSS_CNT 64
0022 #define   MAX_JOIN_TIMEOUT  6000
0023 
0024 #define     SCANNING_TIMEOUT    4500
0025 
0026 #define SCANQUEUE_LIFETIME 20 /* unit:sec */
0027 
0028 #define     WIFI_NULL_STATE 0x00000000
0029 #define WIFI_ASOC_STATE     0x00000001  /* Under Linked state...*/
0030 #define     WIFI_REASOC_STATE 0x00000002
0031 #define WIFI_SLEEP_STATE    0x00000004
0032 #define WIFI_STATION_STATE  0x00000008
0033 #define WIFI_AP_STATE       0x00000010
0034 #define WIFI_ADHOC_STATE    0x00000020
0035 #define   WIFI_ADHOC_MASTER_STATE 0x00000040
0036 #define   WIFI_UNDER_LINKING    0x00000080
0037 #define WIFI_SITE_MONITOR   0x00000800  /* to indicate the station
0038                          * is under site surveying
0039                          */
0040 #define WIFI_MP_STATE       0x00010000
0041 #define WIFI_MP_CTX_BACKGROUND  0x00020000  /* in cont. tx background*/
0042 #define WIFI_MP_CTX_ST      0x00040000  /* in cont. tx with
0043                          * single-tone
0044                          */
0045 #define WIFI_MP_CTX_BACKGROUND_PENDING  0x00080000 /* pending in cont, tx
0046                             * background due
0047                             * to out of skb
0048                             */
0049 #define WIFI_MP_CTX_CCK_HW  0x00100000  /* in continuous tx*/
0050 #define WIFI_MP_CTX_CCK_CS  0x00200000  /* in cont, tx with carrier
0051                          * suppression
0052                          */
0053 #define   WIFI_MP_LPBK_STATE    0x00400000
0054 
0055 #define _FW_UNDER_LINKING   WIFI_UNDER_LINKING
0056 #define _FW_LINKED      WIFI_ASOC_STATE
0057 #define _FW_UNDER_SURVEY    WIFI_SITE_MONITOR
0058 
0059 /*
0060  * there are several "locks" in mlme_priv,
0061  * since mlme_priv is a shared resource between many threads,
0062  * like ISR/Call-Back functions, the OID handlers, and even timer functions.
0063  * Each _queue has its own locks, already.
0064  * Other items are protected by mlme_priv.lock.
0065  * To avoid possible dead lock, any thread trying to modify mlme_priv
0066  * SHALL not lock up more than one lock at a time!
0067  */
0068 
0069 #define traffic_threshold   10
0070 #define traffic_scan_period 500
0071 
0072 struct sitesurvey_ctrl {
0073     u64 last_tx_pkts;
0074     uint    last_rx_pkts;
0075     sint    traffic_busy;
0076     struct timer_list sitesurvey_ctrl_timer;
0077 };
0078 
0079 struct mlme_priv {
0080     spinlock_t lock;
0081     spinlock_t lock2;
0082     sint    fw_state;   /*shall we protect this variable? */
0083     u8 to_join; /*flag*/
0084     u8 *nic_hdl;
0085     struct list_head *pscanned;
0086     struct  __queue free_bss_pool;
0087     struct  __queue scanned_queue;
0088     u8 *free_bss_buf;
0089     unsigned long num_of_scanned;
0090     u8 passive_mode; /*add for Android's SCAN-ACTIVE/SCAN-PASSIVE */
0091     struct ndis_802_11_ssid assoc_ssid;
0092     u8 assoc_bssid[6];
0093     struct wlan_network cur_network;
0094     struct sitesurvey_ctrl sitesurveyctrl;
0095     struct timer_list assoc_timer;
0096     uint assoc_by_bssid;
0097     uint assoc_by_rssi;
0098     struct timer_list scan_to_timer; /* driver handles scan_timeout.*/
0099     struct timer_list dhcp_timer; /* set dhcp to if driver in ps mode.*/
0100     struct qos_priv qospriv;
0101     struct ht_priv  htpriv;
0102     struct timer_list wdg_timer; /*watchdog periodic timer*/
0103 };
0104 
0105 static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
0106 {
0107     return pmlmepriv->cur_network.network.MacAddress;
0108 }
0109 
0110 static inline u8 check_fwstate(struct mlme_priv *pmlmepriv, sint state)
0111 {
0112     if (pmlmepriv->fw_state & state)
0113         return true;
0114     return false;
0115 }
0116 
0117 static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
0118 {
0119     return pmlmepriv->fw_state;
0120 }
0121 
0122 /*
0123  * No Limit on the calling context,
0124  * therefore set it to be the critical section...
0125  *
0126  * ### NOTE:#### (!!!!)
0127  * TAKE CARE BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
0128  */
0129 static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
0130 {
0131     pmlmepriv->fw_state |= state;
0132 }
0133 
0134 static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
0135 {
0136     pmlmepriv->fw_state &= ~state;
0137 }
0138 
0139 /*
0140  * No Limit on the calling context,
0141  * therefore set it to be the critical section...
0142  */
0143 static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
0144 {
0145     unsigned long irqL;
0146 
0147     spin_lock_irqsave(&pmlmepriv->lock, irqL);
0148     if (check_fwstate(pmlmepriv, state))
0149         pmlmepriv->fw_state ^= state;
0150     spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
0151 }
0152 
0153 static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
0154                          sint val)
0155 {
0156     unsigned long irqL;
0157 
0158     spin_lock_irqsave(&pmlmepriv->lock, irqL);
0159     pmlmepriv->num_of_scanned = val;
0160     spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
0161 }
0162 
0163 void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf);
0164 void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf);
0165 void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf);
0166 void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf);
0167 void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf);
0168 void r8712_atimdone_event_callback(struct _adapter *adapter, u8 *pbuf);
0169 void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf);
0170 void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf);
0171 void r8712_free_network_queue(struct _adapter *adapter);
0172 int r8712_init_mlme_priv(struct _adapter *adapter);
0173 void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
0174 int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
0175 int r8712_set_key(struct _adapter *adapter,
0176           struct security_priv *psecuritypriv, sint keyid);
0177 int r8712_set_auth(struct _adapter *adapter,
0178            struct security_priv *psecuritypriv);
0179 uint r8712_get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss);
0180 void r8712_generate_random_ibss(u8 *pibss);
0181 u8 *r8712_get_capability_from_ie(u8 *ie);
0182 struct wlan_network *r8712_get_oldest_wlan_network(
0183                 struct  __queue *scanned_queue);
0184 void r8712_free_assoc_resources(struct _adapter *adapter);
0185 void r8712_ind_disconnect(struct _adapter *adapter);
0186 void r8712_indicate_connect(struct _adapter *adapter);
0187 int r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
0188               u8 *out_ie, uint in_len);
0189 int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie,
0190               u8 *out_ie, uint in_len, uint initial_out_len);
0191 void r8712_init_registrypriv_dev_network(struct _adapter *adapter);
0192 void r8712_update_registrypriv_dev_network(struct _adapter *adapter);
0193 void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter);
0194 void _r8712_join_timeout_handler(struct _adapter *adapter);
0195 void r8712_scan_timeout_handler(struct _adapter *adapter);
0196 void _r8712_dhcp_timeout_handler(struct _adapter *adapter);
0197 struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv);
0198 sint r8712_if_up(struct _adapter *padapter);
0199 void r8712_joinbss_reset(struct _adapter *padapter);
0200 unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
0201                      u8 *out_ie, uint in_len, uint *pout_len);
0202 void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority);
0203 int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork);
0204 
0205 #endif /*__RTL871X_MLME_H_*/