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