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 <linux/etherdevice.h>
00018 #include "key.h"
00019 
00060 enum ieee80211_sta_info_flags {
00061         WLAN_STA_AUTH,
00062         WLAN_STA_ASSOC,
00063         WLAN_STA_PS_STA,
00064         WLAN_STA_AUTHORIZED,
00065         WLAN_STA_SHORT_PREAMBLE,
00066         WLAN_STA_WME,
00067         WLAN_STA_WDS,
00068         WLAN_STA_CLEAR_PS_FILT,
00069         WLAN_STA_MFP,
00070         WLAN_STA_BLOCK_BA,
00071         WLAN_STA_PS_DRIVER,
00072         WLAN_STA_PSPOLL,
00073         WLAN_STA_TDLS_PEER,
00074         WLAN_STA_TDLS_PEER_AUTH,
00075         WLAN_STA_UAPSD,
00076         WLAN_STA_SP,
00077         WLAN_STA_4ADDR_EVENT,
00078         WLAN_STA_INSERTED,
00079         WLAN_STA_RATE_CONTROL,
00080         WLAN_STA_TOFFSET_KNOWN,
00081 };
00082 
00083 #define STA_TID_NUM 16
00084 #define ADDBA_RESP_INTERVAL HZ
00085 #define HT_AGG_MAX_RETRIES              15
00086 #define HT_AGG_BURST_RETRIES            3
00087 #define HT_AGG_RETRIES_PERIOD           (15 * HZ)
00088 
00089 #define HT_AGG_STATE_DRV_READY          0
00090 #define HT_AGG_STATE_RESPONSE_RECEIVED  1
00091 #define HT_AGG_STATE_OPERATIONAL        2
00092 #define HT_AGG_STATE_STOPPING           3
00093 #define HT_AGG_STATE_WANT_START         4
00094 #define HT_AGG_STATE_WANT_STOP          5
00095 
00122 struct tid_ampdu_tx {
00123         struct rcu_head rcu_head;
00124         struct timer_list session_timer;
00125         struct timer_list addba_resp_timer;
00126         struct sk_buff_head pending;
00127         unsigned long state;
00128         unsigned long last_tx;
00129         u16 timeout;
00130         u8 dialog_token;
00131         u8 stop_initiator;
00132         bool tx_stop;
00133         u8 buf_size;
00134 
00135         u16 failed_bar_ssn;
00136         bool bar_pending;
00137 };
00138 
00164 struct tid_ampdu_rx {
00165         struct rcu_head rcu_head;
00166         spinlock_t reorder_lock;
00167         struct sk_buff **reorder_buf;
00168         unsigned long *reorder_time;
00169         struct timer_list session_timer;
00170         struct timer_list reorder_timer;
00171         unsigned long last_rx;
00172         u16 head_seq_num;
00173         u16 stored_mpdu_num;
00174         u16 ssn;
00175         u16 buf_size;
00176         u16 timeout;
00177         u8 dialog_token;
00178 };
00179 
00197 struct sta_ampdu_mlme {
00198         struct mutex mtx;
00199         /* rx */
00200         struct tid_ampdu_rx __rcu *tid_rx[STA_TID_NUM];
00201         unsigned long tid_rx_timer_expired[BITS_TO_LONGS(STA_TID_NUM)];
00202         unsigned long tid_rx_stop_requested[BITS_TO_LONGS(STA_TID_NUM)];
00203         /* tx */
00204         struct work_struct work;
00205         struct tid_ampdu_tx __rcu *tid_tx[STA_TID_NUM];
00206         struct tid_ampdu_tx *tid_start_tx[STA_TID_NUM];
00207         unsigned long last_addba_req_time[STA_TID_NUM];
00208         u8 addba_req_num[STA_TID_NUM];
00209         u8 dialog_token_allocator;
00210 };
00211 
00212 
00287 struct sta_info {
00288         /* General information, mostly static */
00289         struct list_head list;
00290         struct sta_info __rcu *hnext;
00291         struct ieee80211_local *local;
00292         struct ieee80211_sub_if_data *sdata;
00293         struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
00294         struct ieee80211_key __rcu *ptk;
00295         struct rate_control_ref *rate_ctrl;
00296         void *rate_ctrl_priv;
00297         spinlock_t lock;
00298 
00299         struct work_struct drv_unblock_wk;
00300 
00301         u16 listen_interval;
00302 
00303         bool dead;
00304 
00305         bool uploaded;
00306 
00307         enum ieee80211_sta_state sta_state;
00308 
00309         /* use the accessors defined below */
00310         unsigned long _flags;
00311 
00312         /*
00313          * STA powersave frame queues, no more than the internal
00314          * locking required.
00315          */
00316         struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
00317         struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
00318         unsigned long driver_buffered_tids;
00319 
00320         /* Updated from RX path only, no locking requirements */
00321         unsigned long rx_packets, rx_bytes;
00322         unsigned long wep_weak_iv_count;
00323         unsigned long last_rx;
00324         long last_connected;
00325         unsigned long num_duplicates;
00326         unsigned long rx_fragments;
00327         unsigned long rx_dropped;
00328         int last_signal;
00329         struct ewma avg_signal;
00330         /* Plus 1 for non-QoS frames */
00331         __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES + 1];
00332 
00333         /* Updated from TX status path only, no locking requirements */
00334         unsigned long tx_filtered_count;
00335         unsigned long tx_retry_failed, tx_retry_count;
00336         /* moving percentage of failed MSDUs */
00337         unsigned int fail_avg;
00338 
00339         /* Updated from TX path only, no locking requirements */
00340         unsigned long tx_packets;
00341         unsigned long tx_bytes;
00342         unsigned long tx_fragments;
00343         struct ieee80211_tx_rate last_tx_rate;
00344         int last_rx_rate_idx;
00345         int last_rx_rate_flag;
00346         u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
00347 
00348         /*
00349          * Aggregation information, locked with lock.
00350          */
00351         struct sta_ampdu_mlme ampdu_mlme;
00352         u8 timer_to_tid[STA_TID_NUM];
00353 
00354 #ifdef CONFIG_MAC80211_MESH
00355         /*
00356          * Mesh peer link attributes
00357          * TODO: move to a sub-structure that is referenced with pointer?
00358          */
00359         __le16 llid;
00360         __le16 plid;
00361         __le16 reason;
00362         u8 plink_retries;
00363         bool ignore_plink_timer;
00364         bool plink_timer_was_running;
00365         enum nl80211_plink_state plink_state;
00366         u32 plink_timeout;
00367         struct timer_list plink_timer;
00368         s64 t_offset;
00369         s64 t_offset_setpoint;
00370         enum nl80211_channel_type ch_type;
00371 #endif
00372 
00373 #ifdef CONFIG_MAC80211_DEBUGFS
00374         struct sta_info_debugfsdentries {
00375                 struct dentry *dir;
00376                 bool add_has_run;
00377         } debugfs;
00378 #endif
00379 
00380         unsigned int lost_packets;
00381         unsigned int beacon_loss_count;
00382 
00383         bool supports_40mhz;
00384 
00385         /* keep last! */
00386         struct ieee80211_sta sta;
00387 };
00388 
00389 static inline enum nl80211_plink_state sta_plink_state(struct sta_info *sta)
00390 {
00391 #ifdef CONFIG_MAC80211_MESH
00392         return sta->plink_state;
00393 #endif
00394         return NL80211_PLINK_LISTEN;
00395 }
00396 
00397 static inline void set_sta_flag(struct sta_info *sta,
00398                                 enum ieee80211_sta_info_flags flag)
00399 {
00400         WARN_ON(flag == WLAN_STA_AUTH ||
00401                 flag == WLAN_STA_ASSOC ||
00402                 flag == WLAN_STA_AUTHORIZED);
00403         set_bit(flag, &sta->_flags);
00404 }
00405 
00406 static inline void clear_sta_flag(struct sta_info *sta,
00407                                   enum ieee80211_sta_info_flags flag)
00408 {
00409         WARN_ON(flag == WLAN_STA_AUTH ||
00410                 flag == WLAN_STA_ASSOC ||
00411                 flag == WLAN_STA_AUTHORIZED);
00412         clear_bit(flag, &sta->_flags);
00413 }
00414 
00415 static inline int test_sta_flag(struct sta_info *sta,
00416                                 enum ieee80211_sta_info_flags flag)
00417 {
00418         return test_bit(flag, &sta->_flags);
00419 }
00420 
00421 static inline int test_and_clear_sta_flag(struct sta_info *sta,
00422                                           enum ieee80211_sta_info_flags flag)
00423 {
00424         WARN_ON(flag == WLAN_STA_AUTH ||
00425                 flag == WLAN_STA_ASSOC ||
00426                 flag == WLAN_STA_AUTHORIZED);
00427         return test_and_clear_bit(flag, &sta->_flags);
00428 }
00429 
00430 static inline int test_and_set_sta_flag(struct sta_info *sta,
00431                                         enum ieee80211_sta_info_flags flag)
00432 {
00433         WARN_ON(flag == WLAN_STA_AUTH ||
00434                 flag == WLAN_STA_ASSOC ||
00435                 flag == WLAN_STA_AUTHORIZED);
00436         return test_and_set_bit(flag, &sta->_flags);
00437 }
00438 
00439 int sta_info_move_state(struct sta_info *sta,
00440                         enum ieee80211_sta_state new_state);
00441 
00442 static inline void sta_info_pre_move_state(struct sta_info *sta,
00443                                            enum ieee80211_sta_state new_state)
00444 {
00445         int ret;
00446 
00447         WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
00448 
00449         ret = sta_info_move_state(sta, new_state);
00450         WARN_ON_ONCE(ret);
00451 }
00452 
00453 
00454 void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
00455                              struct tid_ampdu_tx *tid_tx);
00456 
00457 static inline struct tid_ampdu_tx *
00458 rcu_dereference_protected_tid_tx(struct sta_info *sta, int tid)
00459 {
00460         return rcu_dereference_protected(sta->ampdu_mlme.tid_tx[tid],
00461                                          lockdep_is_held(&sta->lock) ||
00462                                          lockdep_is_held(&sta->ampdu_mlme.mtx));
00463 }
00464 
00465 #define STA_HASH_SIZE 256
00466 #define STA_HASH(sta) (sta[5])
00467 
00468 
00469 /* Maximum number of frames to buffer per power saving station per AC */
00470 #define STA_MAX_TX_BUFFER       64
00471 
00472 /* Minimum buffered frame expiry time. If STA uses listen interval that is
00473  * smaller than this value, the minimum value here is used instead. */
00474 #define STA_TX_BUFFER_EXPIRE (10 * HZ)
00475 
00476 /* How often station data is cleaned up (e.g., expiration of buffered frames)
00477  */
00478 #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
00479 
00480 /*
00481  * Get a STA info, must be under RCU read lock.
00482  */
00483 struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
00484                               const u8 *addr);
00485 
00486 struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
00487                                   const u8 *addr);
00488 
00489 static inline
00490 void for_each_sta_info_type_check(struct ieee80211_local *local,
00491                                   const u8 *addr,
00492                                   struct sta_info *sta,
00493                                   struct sta_info *nxt)
00494 {
00495 }
00496 
00497 #define for_each_sta_info(local, _addr, _sta, nxt)                      \
00498         for (   /* initialise loop */                                   \
00499                 _sta = rcu_dereference(local->sta_hash[STA_HASH(_addr)]),\
00500                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL;       \
00501                 /* typecheck */                                         \
00502                 for_each_sta_info_type_check(local, (_addr), _sta, nxt),\
00503                 /* continue condition */                                \
00504                 _sta;                                                   \
00505                 /* advance loop */                                      \
00506                 _sta = nxt,                                             \
00507                 nxt = _sta ? rcu_dereference(_sta->hnext) : NULL        \
00508              )                                                          \
00509         /* compare address and run code only if it matches */           \
00510         if (ether_addr_equal(_sta->sta.addr, (_addr)))
00511 
00512 /*
00513  * Get STA info by index, BROKEN!
00514  */
00515 struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
00516                                      int idx);
00517 /*
00518  * Create a new STA info, caller owns returned structure
00519  * until sta_info_insert().
00520  */
00521 struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
00522                                 const u8 *addr, gfp_t gfp);
00523 
00524 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta);
00525 
00526 /*
00527  * Insert STA info into hash table/list, returns zero or a
00528  * -EEXIST if (if the same MAC address is already present).
00529  *
00530  * Calling the non-rcu version makes the caller relinquish,
00531  * the _rcu version calls read_lock_rcu() and must be called
00532  * without it held.
00533  */
00534 int sta_info_insert(struct sta_info *sta);
00535 int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU);
00536 
00537 int __must_check __sta_info_destroy(struct sta_info *sta);
00538 int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata,
00539                           const u8 *addr);
00540 int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
00541                               const u8 *addr);
00542 
00543 void sta_info_recalc_tim(struct sta_info *sta);
00544 
00545 void sta_info_init(struct ieee80211_local *local);
00546 void sta_info_stop(struct ieee80211_local *local);
00547 int sta_info_flush(struct ieee80211_local *local,
00548                    struct ieee80211_sub_if_data *sdata);
00549 void sta_set_rate_info_tx(struct sta_info *sta,
00550                           const struct ieee80211_tx_rate *rate,
00551                           struct rate_info *rinfo);
00552 void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
00553                           unsigned long exp_time);
00554 
00555 void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta);
00556 void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta);
00557 void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta);
00558 
00559 #endif /* STA_INFO_H */


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:11