sta_info.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * Copyright 2002-2005, Devicescape Software, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef STA_INFO_H
  9. #define STA_INFO_H
  10. #include <linux/list.h>
  11. #include <linux/types.h>
  12. #include <linux/if_ether.h>
  13. #include <linux/kref.h>
  14. #include "ieee80211_key.h"
  15. /**
  16. * enum ieee80211_sta_info_flags - Stations flags
  17. *
  18. * These flags are used with &struct sta_info's @flags member.
  19. *
  20. * @WLAN_STA_AUTH: Station is authenticated.
  21. * @WLAN_STA_ASSOC: Station is associated.
  22. * @WLAN_STA_PS: Station is in power-save mode
  23. * @WLAN_STA_TIM: TIM bit is on for this PS station (traffic buffered)
  24. * @WLAN_STA_AUTHORIZED: Station is authorized to send/receive traffic.
  25. * This bit is always checked so needs to be enabled for all stations
  26. * when virtual port control is not in use.
  27. * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
  28. * frames.
  29. * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
  30. * @WLAN_STA_WME: Station is a QoS-STA.
  31. * @WLAN_STA_WDS: Station is one of our WDS peers.
  32. * @WLAN_STA_PSPOLL: Station has just PS-polled us.
  33. */
  34. enum ieee80211_sta_info_flags {
  35. WLAN_STA_AUTH = 1<<0,
  36. WLAN_STA_ASSOC = 1<<1,
  37. WLAN_STA_PS = 1<<2,
  38. WLAN_STA_TIM = 1<<3,
  39. WLAN_STA_AUTHORIZED = 1<<4,
  40. WLAN_STA_SHORT_PREAMBLE = 1<<5,
  41. WLAN_STA_ASSOC_AP = 1<<6,
  42. WLAN_STA_WME = 1<<7,
  43. WLAN_STA_WDS = 1<<8,
  44. WLAN_STA_PSPOLL = 1<<9,
  45. };
  46. #define STA_TID_NUM 16
  47. #define ADDBA_RESP_INTERVAL HZ
  48. #define HT_AGG_MAX_RETRIES (0x3)
  49. #define HT_AGG_STATE_INITIATOR_SHIFT (4)
  50. #define HT_ADDBA_REQUESTED_MSK BIT(0)
  51. #define HT_ADDBA_DRV_READY_MSK BIT(1)
  52. #define HT_ADDBA_RECEIVED_MSK BIT(2)
  53. #define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3)
  54. #define HT_AGG_STATE_INITIATOR_MSK BIT(HT_AGG_STATE_INITIATOR_SHIFT)
  55. #define HT_AGG_STATE_IDLE (0x0)
  56. #define HT_AGG_STATE_OPERATIONAL (HT_ADDBA_REQUESTED_MSK | \
  57. HT_ADDBA_DRV_READY_MSK | \
  58. HT_ADDBA_RECEIVED_MSK)
  59. /**
  60. * struct tid_ampdu_tx - TID aggregation information (Tx).
  61. *
  62. * @state: TID's state in session state machine.
  63. * @dialog_token: dialog token for aggregation session
  64. * @ssn: Starting Sequence Number expected to be aggregated.
  65. * @addba_resp_timer: timer for peer's response to addba request
  66. * @addba_req_num: number of times addBA request has been sent.
  67. */
  68. struct tid_ampdu_tx {
  69. u8 state;
  70. u8 dialog_token;
  71. u16 ssn;
  72. struct timer_list addba_resp_timer;
  73. u8 addba_req_num;
  74. };
  75. /**
  76. * struct tid_ampdu_rx - TID aggregation information (Rx).
  77. *
  78. * @state: TID's state in session state machine.
  79. * @dialog_token: dialog token for aggregation session
  80. * @ssn: Starting Sequence Number expected to be aggregated.
  81. * @buf_size: buffer size for incoming A-MPDUs
  82. * @timeout: reset timer value.
  83. * @head_seq_num: head sequence number in reordering buffer.
  84. * @stored_mpdu_num: number of MPDUs in reordering buffer
  85. * @reorder_buf: buffer to reorder incoming aggregated MPDUs
  86. * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
  87. */
  88. struct tid_ampdu_rx {
  89. u8 state;
  90. u8 dialog_token;
  91. u16 ssn;
  92. u16 buf_size;
  93. u16 timeout;
  94. u16 head_seq_num;
  95. u16 stored_mpdu_num;
  96. struct sk_buff **reorder_buf;
  97. struct timer_list session_timer;
  98. };
  99. /**
  100. * struct sta_ampdu_mlme - STA aggregation information.
  101. *
  102. * @tid_rx: aggregation info for Rx per TID
  103. * @tid_tx: aggregation info for Tx per TID
  104. * @ampdu_rx: for locking sections in aggregation Rx flow
  105. * @ampdu_tx: for locking sectionsi in aggregation Tx flow
  106. * @dialog_token_allocator: dialog token enumerator for each new session;
  107. */
  108. struct sta_ampdu_mlme {
  109. struct tid_ampdu_rx tid_rx[STA_TID_NUM];
  110. struct tid_ampdu_tx tid_tx[STA_TID_NUM];
  111. spinlock_t ampdu_rx;
  112. spinlock_t ampdu_tx;
  113. u8 dialog_token_allocator;
  114. };
  115. struct sta_info {
  116. struct kref kref;
  117. struct list_head list;
  118. struct sta_info *hnext; /* next entry in hash table list */
  119. struct ieee80211_local *local;
  120. u8 addr[ETH_ALEN];
  121. u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */
  122. u32 flags; /* WLAN_STA_ */
  123. struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in
  124. * power saving state */
  125. struct sk_buff_head tx_filtered; /* buffer of TX frames that were
  126. * already given to low-level driver,
  127. * but were filtered */
  128. int clear_dst_mask;
  129. unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */
  130. unsigned long rx_bytes, tx_bytes;
  131. unsigned long tx_retry_failed, tx_retry_count;
  132. unsigned long tx_filtered_count;
  133. unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */
  134. unsigned long last_rx;
  135. /* bitmap of supported rates per band */
  136. u64 supp_rates[IEEE80211_NUM_BANDS];
  137. int txrate_idx;
  138. /* last rates used to send a frame to this STA */
  139. int last_txrate_idx, last_nonerp_txrate_idx;
  140. struct net_device *dev; /* which net device is this station associated
  141. * to */
  142. struct ieee80211_key *key;
  143. u32 tx_num_consecutive_failures;
  144. u32 tx_num_mpdu_ok;
  145. u32 tx_num_mpdu_fail;
  146. struct rate_control_ref *rate_ctrl;
  147. void *rate_ctrl_priv;
  148. /* last received seq/frag number from this STA (per RX queue) */
  149. __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES];
  150. unsigned long num_duplicates; /* number of duplicate frames received
  151. * from this STA */
  152. unsigned long tx_fragments; /* number of transmitted MPDUs */
  153. unsigned long rx_fragments; /* number of received MPDUs */
  154. unsigned long rx_dropped; /* number of dropped MPDUs from this STA */
  155. int last_rssi; /* RSSI of last received frame from this STA */
  156. int last_signal; /* signal of last received frame from this STA */
  157. int last_noise; /* noise of last received frame from this STA */
  158. int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
  159. unsigned long last_ack;
  160. int channel_use;
  161. int channel_use_raw;
  162. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  163. unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
  164. unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
  165. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  166. u16 listen_interval;
  167. struct ieee80211_ht_info ht_info; /* 802.11n HT capabilities
  168. of this STA */
  169. struct sta_ampdu_mlme ampdu_mlme;
  170. u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */
  171. u8 tid_to_tx_q[STA_TID_NUM]; /* map tid to tx queue */
  172. #ifdef CONFIG_MAC80211_DEBUGFS
  173. struct sta_info_debugfsdentries {
  174. struct dentry *dir;
  175. struct dentry *flags;
  176. struct dentry *num_ps_buf_frames;
  177. struct dentry *last_ack_rssi;
  178. struct dentry *last_ack_ms;
  179. struct dentry *inactive_ms;
  180. struct dentry *last_seq_ctrl;
  181. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  182. struct dentry *wme_rx_queue;
  183. struct dentry *wme_tx_queue;
  184. #endif
  185. struct dentry *agg_status;
  186. } debugfs;
  187. #endif
  188. };
  189. /* Maximum number of concurrently registered stations */
  190. #define MAX_STA_COUNT 2007
  191. #define STA_HASH_SIZE 256
  192. #define STA_HASH(sta) (sta[5])
  193. /* Maximum number of frames to buffer per power saving station */
  194. #define STA_MAX_TX_BUFFER 128
  195. /* Minimum buffered frame expiry time. If STA uses listen interval that is
  196. * smaller than this value, the minimum value here is used instead. */
  197. #define STA_TX_BUFFER_EXPIRE (10 * HZ)
  198. /* How often station data is cleaned up (e.g., expiration of buffered frames)
  199. */
  200. #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
  201. static inline void __sta_info_get(struct sta_info *sta)
  202. {
  203. kref_get(&sta->kref);
  204. }
  205. struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
  206. void sta_info_put(struct sta_info *sta);
  207. struct sta_info * sta_info_add(struct ieee80211_local *local,
  208. struct net_device *dev, u8 *addr, gfp_t gfp);
  209. void sta_info_remove(struct sta_info *sta);
  210. void sta_info_free(struct sta_info *sta);
  211. void sta_info_init(struct ieee80211_local *local);
  212. int sta_info_start(struct ieee80211_local *local);
  213. void sta_info_stop(struct ieee80211_local *local);
  214. void sta_info_remove_aid_ptr(struct sta_info *sta);
  215. void sta_info_flush(struct ieee80211_local *local, struct net_device *dev);
  216. #endif /* STA_INFO_H */