root/drivers/staging/rtl8723bs/include/sta_info.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. wifi_mac_hash

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /******************************************************************************
   3  *
   4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5  *
   6  ******************************************************************************/
   7 #ifndef __STA_INFO_H_
   8 #define __STA_INFO_H_
   9 
  10 
  11 #define IBSS_START_MAC_ID       2
  12 #define NUM_STA 32
  13 #define NUM_ACL 16
  14 
  15 
  16 /* if mode == 0, then the sta is allowed once the addr is hit. */
  17 /* if mode == 1, then the sta is rejected once the addr is non-hit. */
  18 struct rtw_wlan_acl_node {
  19         struct list_head                        list;
  20         u8       addr[ETH_ALEN];
  21         u8       valid;
  22 };
  23 
  24 /* mode = 0, disable */
  25 /* mode = 1, accept unless in deny list */
  26 /* mode =2, deny unless in accept list */
  27 struct wlan_acl_pool {
  28         int mode;
  29         int num;
  30         struct rtw_wlan_acl_node aclnode[NUM_ACL];
  31         struct __queue  acl_node_q;
  32 };
  33 
  34 typedef struct _RSSI_STA{
  35         s32     UndecoratedSmoothedPWDB;
  36         s32     UndecoratedSmoothedCCK;
  37         s32     UndecoratedSmoothedOFDM;
  38         u64     PacketMap;
  39         u8 ValidBit;
  40 }RSSI_STA, *PRSSI_STA;
  41 
  42 struct  stainfo_stats   {
  43 
  44         u64 rx_mgnt_pkts;
  45                 u64 rx_beacon_pkts;
  46                 u64 rx_probereq_pkts;
  47                 u64 rx_probersp_pkts;
  48                 u64 rx_probersp_bm_pkts;
  49                 u64 rx_probersp_uo_pkts;
  50         u64 rx_ctrl_pkts;
  51         u64 rx_data_pkts;
  52 
  53         u64     last_rx_mgnt_pkts;
  54                 u64 last_rx_beacon_pkts;
  55                 u64 last_rx_probereq_pkts;
  56                 u64 last_rx_probersp_pkts;
  57                 u64 last_rx_probersp_bm_pkts;
  58                 u64 last_rx_probersp_uo_pkts;
  59         u64     last_rx_ctrl_pkts;
  60         u64     last_rx_data_pkts;
  61 
  62         u64     rx_bytes;
  63         u64     rx_drops;
  64 
  65         u64     tx_pkts;
  66         u64     tx_bytes;
  67         u64  tx_drops;
  68 };
  69 
  70 struct sta_info {
  71 
  72         _lock   lock;
  73         struct list_head        list; /* free_sta_queue */
  74         struct list_head        hash_list; /* sta_hash */
  75         struct adapter *padapter;
  76 
  77         struct sta_xmit_priv sta_xmitpriv;
  78         struct sta_recv_priv sta_recvpriv;
  79 
  80         struct __queue sleep_q;
  81         unsigned int sleepq_len;
  82 
  83         uint state;
  84         uint aid;
  85         uint mac_id;
  86         uint qos_option;
  87         u8 hwaddr[ETH_ALEN];
  88 
  89         uint    ieee8021x_blocked;      /* 0: allowed, 1:blocked */
  90         uint    dot118021XPrivacy; /* aes, tkip... */
  91         union Keytype   dot11tkiptxmickey;
  92         union Keytype   dot11tkiprxmickey;
  93         union Keytype   dot118021x_UncstKey;
  94         union pn48              dot11txpn;                      /*  PN48 used for Unicast xmit */
  95 #ifdef CONFIG_GTK_OL
  96         u8 kek[RTW_KEK_LEN];
  97         u8 kck[RTW_KCK_LEN];
  98         u8 replay_ctr[RTW_REPLAY_CTR_LEN];
  99 #endif /* CONFIG_GTK_OL */
 100         union pn48              dot11wtxpn;                     /*  PN48 used for Unicast mgmt xmit. */
 101         union pn48              dot11rxpn;                      /*  PN48 used for Unicast recv. */
 102 
 103 
 104         u8 bssrateset[16];
 105         u32 bssratelen;
 106         s32  rssi;
 107         s32     signal_quality;
 108 
 109         u8 cts2self;
 110         u8 rtsen;
 111 
 112         u8 raid;
 113         u8 init_rate;
 114         u32 ra_mask;
 115         u8 wireless_mode;       /*  NETWORK_TYPE */
 116         u8 bw_mode;
 117 
 118         u8 ldpc;
 119         u8 stbc;
 120 
 121         struct stainfo_stats sta_stats;
 122 
 123         /* for A-MPDU TX, ADDBA timeout check */
 124         _timer addba_retry_timer;
 125 
 126         /* for A-MPDU Rx reordering buffer control */
 127         struct recv_reorder_ctrl recvreorder_ctrl[16];
 128 
 129         /* for A-MPDU Tx */
 130         /* unsigned char        ampdu_txen_bitmap; */
 131         u16 BA_starting_seqctrl[16];
 132 
 133 
 134         struct ht_priv htpriv;
 135 
 136         /* Notes: */
 137         /* STA_Mode: */
 138         /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
 139         /* scan_q: AP CAP/INFO */
 140 
 141         /* AP_Mode: */
 142         /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
 143         /* sta_info: (AP & STA) CAP/INFO */
 144 
 145         struct list_head asoc_list;
 146         struct list_head auth_list;
 147 
 148         unsigned int expire_to;
 149         unsigned int auth_seq;
 150         unsigned int authalg;
 151         unsigned char chg_txt[128];
 152 
 153         u16 capability;
 154         int flags;
 155 
 156         int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
 157         int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
 158         int wpa_group_cipher;
 159         int wpa2_group_cipher;
 160         int wpa_pairwise_cipher;
 161         int wpa2_pairwise_cipher;
 162 
 163         u8 bpairwise_key_installed;
 164 
 165         u8 wpa_ie[32];
 166 
 167         u8 nonerp_set;
 168         u8 no_short_slot_time_set;
 169         u8 no_short_preamble_set;
 170         u8 no_ht_gf_set;
 171         u8 no_ht_set;
 172         u8 ht_20mhz_set;
 173 
 174         unsigned int tx_ra_bitmap;
 175         u8 qos_info;
 176 
 177         u8 max_sp_len;
 178         u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
 179         u8 uapsd_be;
 180         u8 uapsd_vi;
 181         u8 uapsd_vo;
 182 
 183         u8 has_legacy_ac;
 184         unsigned int sleepq_ac_len;
 185 
 186         u8 under_exist_checking;
 187 
 188         u8 keep_alive_trycnt;
 189 
 190 #ifdef CONFIG_AUTO_AP_MODE
 191         u8 isrc; /* this device is rc */
 192         u16 pid; /*  pairing id */
 193 #endif
 194 
 195         u8 *passoc_req;
 196         u32 assoc_req_len;
 197 
 198         /* for DM */
 199         RSSI_STA         rssi_stat;
 200 
 201         /* ODM_STA_INFO_T */
 202         /*  ================ODM Relative Info ======================= */
 203         /*  Please be care, dont declare too much structure here. It will cost memory * STA support num. */
 204         /*  */
 205         /*  */
 206         /*  2011/10/20 MH Add for ODM STA info. */
 207         /*  */
 208         /*  Driver Write */
 209         u8 bValid;                              /*  record the sta status link or not? */
 210         u8 IOTPeer;                     /*  Enum value. HT_IOT_PEER_E */
 211         /*  ODM Write */
 212         /* 1 PHY_STATUS_INFO */
 213         u8 RSSI_Path[4];                /*  */
 214         u8 RSSI_Ave;
 215         u8 RXEVM[4];
 216         u8 RXSNR[4];
 217 
 218         u8 rssi_level;                  /* for Refresh RA mask */
 219         /*  ODM Write */
 220         /* 1 TX_INFO (may changed by IC) */
 221         /* TX_INFO_T            pTxInfo;                 Define in IC folder. Move lower layer. */
 222         /*  */
 223         /*  ================ODM Relative Info ======================= */
 224         /*  */
 225 
 226         /* To store the sequence number of received management frame */
 227         u16 RxMgmtFrameSeqNum;
 228 };
 229 
 230 #define sta_rx_pkts(sta) \
 231         (sta->sta_stats.rx_mgnt_pkts \
 232         + sta->sta_stats.rx_ctrl_pkts \
 233         + sta->sta_stats.rx_data_pkts)
 234 
 235 #define sta_last_rx_pkts(sta) \
 236         (sta->sta_stats.last_rx_mgnt_pkts \
 237         + sta->sta_stats.last_rx_ctrl_pkts \
 238         + sta->sta_stats.last_rx_data_pkts)
 239 
 240 #define sta_rx_data_pkts(sta) \
 241         (sta->sta_stats.rx_data_pkts)
 242 
 243 #define sta_last_rx_data_pkts(sta) \
 244         (sta->sta_stats.last_rx_data_pkts)
 245 
 246 #define sta_rx_mgnt_pkts(sta) \
 247         (sta->sta_stats.rx_mgnt_pkts)
 248 
 249 #define sta_last_rx_mgnt_pkts(sta) \
 250         (sta->sta_stats.last_rx_mgnt_pkts)
 251 
 252 #define sta_rx_beacon_pkts(sta) \
 253         (sta->sta_stats.rx_beacon_pkts)
 254 
 255 #define sta_last_rx_beacon_pkts(sta) \
 256         (sta->sta_stats.last_rx_beacon_pkts)
 257 
 258 #define sta_rx_probereq_pkts(sta) \
 259         (sta->sta_stats.rx_probereq_pkts)
 260 
 261 #define sta_last_rx_probereq_pkts(sta) \
 262         (sta->sta_stats.last_rx_probereq_pkts)
 263 
 264 #define sta_rx_probersp_pkts(sta) \
 265         (sta->sta_stats.rx_probersp_pkts)
 266 
 267 #define sta_last_rx_probersp_pkts(sta) \
 268         (sta->sta_stats.last_rx_probersp_pkts)
 269 
 270 #define sta_rx_probersp_bm_pkts(sta) \
 271         (sta->sta_stats.rx_probersp_bm_pkts)
 272 
 273 #define sta_last_rx_probersp_bm_pkts(sta) \
 274         (sta->sta_stats.last_rx_probersp_bm_pkts)
 275 
 276 #define sta_rx_probersp_uo_pkts(sta) \
 277         (sta->sta_stats.rx_probersp_uo_pkts)
 278 
 279 #define sta_last_rx_probersp_uo_pkts(sta) \
 280         (sta->sta_stats.last_rx_probersp_uo_pkts)
 281 
 282 #define sta_update_last_rx_pkts(sta) \
 283         do { \
 284                 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
 285                 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
 286                 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
 287                 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
 288                 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
 289                 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
 290                 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
 291                 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
 292         } while (0)
 293 
 294 #define STA_RX_PKTS_ARG(sta) \
 295         sta->sta_stats.rx_mgnt_pkts \
 296         , sta->sta_stats.rx_ctrl_pkts \
 297         , sta->sta_stats.rx_data_pkts
 298 
 299 #define STA_LAST_RX_PKTS_ARG(sta) \
 300         sta->sta_stats.last_rx_mgnt_pkts \
 301         , sta->sta_stats.last_rx_ctrl_pkts \
 302         , sta->sta_stats.last_rx_data_pkts
 303 
 304 #define STA_RX_PKTS_DIFF_ARG(sta) \
 305         sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
 306         , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
 307         , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
 308 
 309 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
 310 
 311 struct  sta_priv {
 312 
 313         u8 *pallocated_stainfo_buf;
 314         u8 *pstainfo_buf;
 315         struct __queue  free_sta_queue;
 316 
 317         _lock sta_hash_lock;
 318         struct list_head   sta_hash[NUM_STA];
 319         int asoc_sta_count;
 320         struct __queue sleep_q;
 321         struct __queue wakeup_q;
 322 
 323         struct adapter *padapter;
 324 
 325         struct list_head asoc_list;
 326         struct list_head auth_list;
 327         _lock asoc_list_lock;
 328         _lock auth_list_lock;
 329         u8 asoc_list_cnt;
 330         u8 auth_list_cnt;
 331 
 332         unsigned int auth_to;  /* sec, time to expire in authenticating. */
 333         unsigned int assoc_to; /* sec, time to expire before associating. */
 334         unsigned int expire_to; /* sec , time to expire after associated. */
 335 
 336         /* pointers to STA info; based on allocated AID or NULL if AID free
 337          * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
 338          * and so on
 339          */
 340         struct sta_info *sta_aid[NUM_STA];
 341 
 342         u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
 343         u16 tim_bitmap;/* only support 15 stations, aid = 0~15 mapping bit0~bit15 */
 344 
 345         u16 max_num_sta;
 346 
 347         struct wlan_acl_pool acl_list;
 348 };
 349 
 350 
 351 static inline u32 wifi_mac_hash(u8 *mac)
 352 {
 353         u32 x;
 354 
 355         x = mac[0];
 356         x = (x << 2) ^ mac[1];
 357         x = (x << 2) ^ mac[2];
 358         x = (x << 2) ^ mac[3];
 359         x = (x << 2) ^ mac[4];
 360         x = (x << 2) ^ mac[5];
 361 
 362         x ^= x >> 8;
 363         x  = x & (NUM_STA - 1);
 364 
 365         return x;
 366 }
 367 
 368 
 369 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
 370 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
 371 
 372 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
 373 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
 374 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
 375 
 376 extern struct sta_info *rtw_alloc_stainfo(struct        sta_priv *pstapriv, u8 *hwaddr);
 377 extern u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta);
 378 extern void rtw_free_all_stainfo(struct adapter *padapter);
 379 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
 380 extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter);
 381 extern struct sta_info* rtw_get_bcmc_stainfo(struct adapter *padapter);
 382 extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
 383 
 384 #endif /* _STA_INFO_H_ */

/* [<][>][^][v][top][bottom][index][help] */