sta_info.h 7.4 KB

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