sta_info.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2005, Devicescape Software, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 2 as
00006  * published by the Free Software Foundation.
00007  */
00008 
00009 #ifndef STA_INFO_H
00010 #define STA_INFO_H
00011 
00012 #include <linux/list.h>
00013 #include <linux/types.h>
00014 #include <linux/if_ether.h>
00015 #include <linux/workqueue.h>
00016 #include <linux/average.h>
00017 #include "key.h"
00018 
00056 enum ieee80211_sta_info_flags {
00057         WLAN_STA_AUTH,
00058         WLAN_STA_ASSOC,
00059         WLAN_STA_PS_STA,
00060         WLAN_STA_AUTHORIZED,
00061         WLAN_STA_SHORT_PREAMBLE,
00062         WLAN_STA_ASSOC_AP,
00063         WLAN_STA_WME,
00064         WLAN_STA_WDS,
00065         WLAN_STA_CLEAR_PS_FILT,
00066         WLAN_STA_MFP,
00067         WLAN_STA_BLOCK_BA,
00068         WLAN_STA_PS_DRIVER,
00069         WLAN_STA_PSPOLL,
00070         WLAN_STA_TDLS_PEER,
00071         WLAN_STA_TDLS_PEER_AUTH,
00072         WLAN_STA_UAPSD,
00073         WLAN_STA_SP,
00074 };
00075 
00076 #define STA_TID_NUM 16
00077 #define ADDBA_RESP_INTERVAL HZ
00078 #define HT_AGG_MAX_RETRIES              0x3
00079 
00080 #define HT_AGG_STATE_DRV_READY          0
00081 #define HT_AGG_STATE_RESPONSE_RECEIVED  1
00082 #define HT_AGG_STATE_OPERATIONAL        2
00083 #define HT_AGG_STATE_STOPPING           3
00084 #define HT_AGG_STATE_WANT_START         4
00085 #define HT_AGG_STATE_WANT_STOP          5
00086 
00111 struct tid_ampdu_tx {
00112         struct rcu_head rcu_head;
00113         struct timer_list addba_resp_timer;
00114         struct sk_buff_head pending;
00115         unsigned long state;
00116         u16 timeout;
00117         u8 dialog_token;
00118         u8 stop_initiator;
00119         bool tx_stop;
00120         u8 buf_size;
00121 
00122         u16 failed_bar_ssn;
00123         bool bar_pending;
00124 };
00125 
00150 struct tid_ampdu_rx {
00151         struct rcu_head rcu_head;
00152         spinlock_t reorder_lock;
00153         struct sk_buff **reorder_buf;
00154         unsigned long *reorder_time;
00155         struct timer_list session_timer;
00156         struct timer_list reorder_timer;
00157         u16 head_seq_num;
00158         u16 stored_mpdu_num;
00159         u16 ssn;
00160         u16 buf_size;
00161         u16 timeout;
00162         u8 dialog_token;
00163 };
00164 
00181 struct sta_ampdu_mlme {
00182         struct mutex mtx;
00183         /* rx */
00184         struct tid_ampdu_rx __rcu *tid_rx[STA_TID_NUM];
00185         unsigned long tid_rx_timer_expired[BITS_TO_LONGS(STA_TID_NUM)];
00186         unsigned long tid_rx_stop_requested[BITS_TO_LONGS(STA_TID_NUM)];
00187         /* tx */
00188         struct work_struct work;
00189         struct tid_ampdu_tx __rcu *tid_tx[STA_TID_NUM];
00190         struct tid_ampdu_tx *tid_start_tx[STA_TID_NUM];
00191         u8 addba_req_num[STA_TID_NUM];
00192         u8 dialog_token_allocator;
00193 };
00194 
00195 
00264 struct sta_info {
00265         /* General information, mostly static */
00266         struct list_head list;
00267         struct sta_info __rcu *hnext;
00268         struct ieee80211_local *local;
00269         struct ieee80211_sub_if_data *sdata;
00270         struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
00271         struct ieee80211_key __rcu *ptk;
00272         struct rate_control_ref *rate_ctrl;
00273         void *rate_ctrl_priv;
00274         spinlock_t lock;
00275 
00276         struct work_struct drv_unblock_wk;
00277 
00278         u16 listen_interval;
00279 
00280         bool dead;
00281 
00282         bool uploaded;
00283 
00284         /* use the accessors defined below */
00285         unsigned long _flags;
00286 
00287         /*
00288          * STA powersave frame queues, no more than the internal
00289          * locking required.
00290          */
00291         struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
00292         struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
00293         unsigned long driver_buffered_tids;
00294 
00295         /* Updated from RX path only, no locking requirements */
00296         unsigned long rx_packets, rx_bytes;
00297         unsigned long wep_weak_iv_count;
00298         unsigned long last_rx;
00299         long last_connected;
00300         unsigned long num_duplicates;
00301         unsigned long rx_fragments;
00302         unsigned long rx_dropped;
00303         int last_signal;
00304         struct ewma avg_signal;
00305         /* Plus 1 for non-QoS frames */
00306         __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES + 1];
00307 
00308         /* Updated from TX status path only, no locking requirements */
00309         unsigned long tx_filtered_count;
00310         unsigned long tx_retry_failed, tx_retry_count;
00311         /* moving percentage of failed MSDUs */
00312         unsigned int fail_avg;
00313 
00314         /* Updated from TX path only, no locking requirements */
00315         unsigned long tx_packets;
00316         unsigned long tx_bytes;
00317         unsigned long tx_fragments;
00318         struct ieee80211_tx_rate last_tx_rate;
00319         int last_rx_rate_idx;
00320         int last_rx_rate_flag;
00321         u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
00322 
00323         /*
00324          * Aggregation information, locked with lock.
00325          */
00326         struct sta_ampdu_mlme ampdu_mlme;
00327         u8 timer_to_tid[STA_TID_NUM];
00328 
00329 #ifdef CONFIG_MAC80211_MESH
00330         /*
00331          * Mesh peer link attributes
00332          * TODO: move to a sub-structure that is referenced with pointer?
00333          */
00334         __le16 llid;
00335         __le16 plid;
00336         __le16 reason;
00337         u8 plink_retries;
00338         bool ignore_plink_timer;
00339         bool plink_timer_was_running;
00340         enum nl80211_plink_state plink_state;
00341         u32 plink_timeout;
00342         struct timer_list plink_timer;
00343 #endif
00344 
00345 #ifdef CONFIG_MAC80211_DEBUGFS
00346         struct sta_info_debugfsdentries {
00347                 struct dentry *dir;
00348                 bool add_has_run;
00349         } debugfs;
00350 #endif
00351 
00352         unsigned int lost_packets;
00353 
00354         /* should be right in front of sta to be in the same cache line */
00355         bool dummy;
00356 
00357         /* keep last! */
00358         struct ieee80211_sta sta;
00359 };
00360 
00361 static inline enum nl80211_plink_state sta_plink_state(struct sta_info *sta)
00362 {
00363 #ifdef CONFIG_MAC80211_MESH
00364         return sta->plink_state;
00365 #endif
00366         return NL80211_PLINK_LISTEN;
00367 }
00368 
00369 static inline void set_sta_flag(struct sta_info *sta,
00370                                 enum ieee80211_sta_info_flags flag)
00371 {
00372         set_bit(flag, &sta->_flags);
00373 }
00374 
00375 static inline void clear_sta_flag(struct sta_info *sta,
00376                                   enum ieee80211_sta_info_flags flag)
00377 {
00378         clear_bit(flag, &sta->_flags);
00379 }
00380 
00381 static inline int test_sta_flag(struct sta_info *sta,
00382                                 enum ieee80211_sta_info_flags flag)
00383 {
00384         return test_bit(flag, &sta->_flags);
00385 }
00386 
00387 static inline int test_and_clear_sta_flag(struct sta_info *sta,
00388                                           enum ieee80211_sta_info_flags flag)
00389 {
00390         return test_and_clear_bit(flag, &sta->_flags);
00391 }
00392 
00393 void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
00394                              struct tid_ampdu_tx *tid_tx);
00395 
00396 static inline struct tid_ampdu_tx *
00397 rcu_dereference_protected_tid_tx(struct sta_info *sta, int tid)
00398 {
00399         return rcu_dereference_protected(sta->ampdu_mlme.tid_tx[tid],
00400                                          lockdep_is_held(&sta->lock) ||
00401                                          lockdep_is_held(&sta->ampdu_mlme.mtx));
00402 }
00403 
00404 #define STA_HASH_SIZE 256
00405 #define STA_HASH(sta) (sta[5])
00406 
00407 
00408 /* Maximum number of frames to buffer per power saving station per AC */
00409 #define STA_MAX_TX_BUFFER       64
00410 
00411 /* Minimum buffered frame expiry time. If STA uses listen interval that is
00412  * smaller than this value, the minimum value here is used instead. */
00413 #define STA_TX_BUFFER_EXPIRE (10 * HZ)
00414 
00415 /* How often station data is cleaned up (e.g., expiration of buffered frames)
00416  */
00417 #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
00418 
00419 /*
00420  * Get a STA info, must be under RCU read lock.
00421  */
00422 struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
00423                               const u8 *addr);
00424 
00425 struct sta_info *sta_info_get_rx(struct ieee80211_sub_if_data *sdata,
00426                               const u8 *addr);
00427 
00428 struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
00429                                   const u8 *addr);
00430 
00431 struct sta_info *sta_info_get_bss_rx(struct ieee80211_sub_if_data *sdata,
00432                                   const u8 *addr);
00433 
00434 static inline
00435 void for_each_sta_info_type_check(struct ieee80211_local *local,
00436                                   const u8 *addr,
00437                                   struct sta_info *sta,
00438                                   struct sta_info *nxt)
00439 {
00440 }
00441 
00442 #define for_each_sta_info(local, _addr, _sta, nxt)                      \
00443         for (   /* initialise loop */                                   \
00444                 _sta = rcu_dereference(local->sta_hash[STA_HASH(_addr)]),\
00445                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL;       \
00446                 /* typecheck */                                         \
00447                 for_each_sta_info_type_check(local, (_addr), _sta, nxt),\
00448                 /* continue condition */                                \
00449                 _sta;                                                   \
00450                 /* advance loop */                                      \
00451                 _sta = nxt,                                             \
00452                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL        \
00453              )                                                          \
00454         /* run code only if address matches and it's not a dummy sta */ \
00455         if (memcmp(_sta->sta.addr, (_addr), ETH_ALEN) == 0 &&           \
00456                 !_sta->dummy)
00457 
00458 #define for_each_sta_info_rx(local, _addr, _sta, nxt)                   \
00459         for (   /* initialise loop */                                   \
00460                 _sta = rcu_dereference(local->sta_hash[STA_HASH(_addr)]),\
00461                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL;       \
00462                 /* typecheck */                                         \
00463                 for_each_sta_info_type_check(local, (_addr), _sta, nxt),\
00464                 /* continue condition */                                \
00465                 _sta;                                                   \
00466                 /* advance loop */                                      \
00467                 _sta = nxt,                                             \
00468                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL        \
00469              )                                                          \
00470         /* compare address and run code only if it matches */           \
00471         if (memcmp(_sta->sta.addr, (_addr), ETH_ALEN) == 0)
00472 
00473 /*
00474  * Get STA info by index, BROKEN!
00475  */
00476 struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
00477                                      int idx);
00478 /*
00479  * Create a new STA info, caller owns returned structure
00480  * until sta_info_insert().
00481  */
00482 struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
00483                                 u8 *addr, gfp_t gfp);
00484 /*
00485  * Insert STA info into hash table/list, returns zero or a
00486  * -EEXIST if (if the same MAC address is already present).
00487  *
00488  * Calling the non-rcu version makes the caller relinquish,
00489  * the _rcu version calls read_lock_rcu() and must be called
00490  * without it held.
00491  */
00492 int sta_info_insert(struct sta_info *sta);
00493 int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU);
00494 int sta_info_insert_atomic(struct sta_info *sta);
00495 int sta_info_reinsert(struct sta_info *sta);
00496 
00497 int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata,
00498                           const u8 *addr);
00499 int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
00500                               const u8 *addr);
00501 
00502 void sta_info_recalc_tim(struct sta_info *sta);
00503 
00504 void sta_info_init(struct ieee80211_local *local);
00505 void sta_info_stop(struct ieee80211_local *local);
00506 int sta_info_flush(struct ieee80211_local *local,
00507                    struct ieee80211_sub_if_data *sdata);
00508 void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
00509                           unsigned long exp_time);
00510 
00511 void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta);
00512 void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta);
00513 void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta);
00514 
00515 #endif /* STA_INFO_H */


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:55