sta_info.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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_STATE_INITIATOR_SHIFT (4)
  33. #define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3)
  34. #define HT_AGG_STATE_IDLE (0x0)
  35. #define HT_AGG_STATE_OPERATIONAL (0x7)
  36. /**
  37. * struct tid_ampdu_rx - TID aggregation information (Rx).
  38. *
  39. * @state: TID's state in session state machine.
  40. * @dialog_token: dialog token for aggregation session
  41. * @ssn: Starting Sequence Number expected to be aggregated.
  42. * @buf_size: buffer size for incoming A-MPDUs
  43. * @timeout: reset timer value.
  44. * @head_seq_num: head sequence number in reordering buffer.
  45. * @stored_mpdu_num: number of MPDUs in reordering buffer
  46. * @reorder_buf: buffer to reorder incoming aggregated MPDUs
  47. * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
  48. */
  49. struct tid_ampdu_rx {
  50. u8 state;
  51. u8 dialog_token;
  52. u16 ssn;
  53. u16 buf_size;
  54. u16 timeout;
  55. u16 head_seq_num;
  56. u16 stored_mpdu_num;
  57. struct sk_buff **reorder_buf;
  58. struct timer_list session_timer;
  59. };
  60. /**
  61. * struct sta_ampdu_mlme - STA aggregation information.
  62. *
  63. * @tid_agg_info_rx: aggregation info for Rx per TID
  64. * @ampdu_rx: for locking sections in aggregation Rx flow
  65. */
  66. struct sta_ampdu_mlme {
  67. struct tid_ampdu_rx tid_rx[STA_TID_NUM];
  68. spinlock_t ampdu_rx;
  69. };
  70. struct sta_info {
  71. struct kref kref;
  72. struct list_head list;
  73. struct sta_info *hnext; /* next entry in hash table list */
  74. struct ieee80211_local *local;
  75. u8 addr[ETH_ALEN];
  76. u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */
  77. u32 flags; /* WLAN_STA_ */
  78. struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in
  79. * power saving state */
  80. int pspoll; /* whether STA has send a PS Poll frame */
  81. struct sk_buff_head tx_filtered; /* buffer of TX frames that were
  82. * already given to low-level driver,
  83. * but were filtered */
  84. int clear_dst_mask;
  85. unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */
  86. unsigned long rx_bytes, tx_bytes;
  87. unsigned long tx_retry_failed, tx_retry_count;
  88. unsigned long tx_filtered_count;
  89. unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */
  90. unsigned long last_rx;
  91. u32 supp_rates; /* bitmap of supported rates in local->curr_rates */
  92. int txrate; /* index in local->curr_rates */
  93. int last_txrate; /* last rate used to send a frame to this STA */
  94. int last_nonerp_idx;
  95. struct net_device *dev; /* which net device is this station associated
  96. * to */
  97. struct ieee80211_key *key;
  98. u32 tx_num_consecutive_failures;
  99. u32 tx_num_mpdu_ok;
  100. u32 tx_num_mpdu_fail;
  101. struct rate_control_ref *rate_ctrl;
  102. void *rate_ctrl_priv;
  103. /* last received seq/frag number from this STA (per RX queue) */
  104. __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES];
  105. unsigned long num_duplicates; /* number of duplicate frames received
  106. * from this STA */
  107. unsigned long tx_fragments; /* number of transmitted MPDUs */
  108. unsigned long rx_fragments; /* number of received MPDUs */
  109. unsigned long rx_dropped; /* number of dropped MPDUs from this STA */
  110. int last_rssi; /* RSSI of last received frame from this STA */
  111. int last_signal; /* signal of last received frame from this STA */
  112. int last_noise; /* noise of last received frame from this STA */
  113. int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
  114. unsigned long last_ack;
  115. int channel_use;
  116. int channel_use_raw;
  117. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  118. unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
  119. unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
  120. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  121. u16 listen_interval;
  122. struct ieee80211_ht_info ht_info; /* 802.11n HT capabilities
  123. of this STA */
  124. struct sta_ampdu_mlme ampdu_mlme;
  125. u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */
  126. #ifdef CONFIG_MAC80211_DEBUGFS
  127. struct sta_info_debugfsdentries {
  128. struct dentry *dir;
  129. struct dentry *flags;
  130. struct dentry *num_ps_buf_frames;
  131. struct dentry *last_ack_rssi;
  132. struct dentry *last_ack_ms;
  133. struct dentry *inactive_ms;
  134. struct dentry *last_seq_ctrl;
  135. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  136. struct dentry *wme_rx_queue;
  137. struct dentry *wme_tx_queue;
  138. #endif
  139. } debugfs;
  140. #endif
  141. };
  142. /* Maximum number of concurrently registered stations */
  143. #define MAX_STA_COUNT 2007
  144. #define STA_HASH_SIZE 256
  145. #define STA_HASH(sta) (sta[5])
  146. /* Maximum number of frames to buffer per power saving station */
  147. #define STA_MAX_TX_BUFFER 128
  148. /* Minimum buffered frame expiry time. If STA uses listen interval that is
  149. * smaller than this value, the minimum value here is used instead. */
  150. #define STA_TX_BUFFER_EXPIRE (10 * HZ)
  151. /* How often station data is cleaned up (e.g., expiration of buffered frames)
  152. */
  153. #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
  154. static inline void __sta_info_get(struct sta_info *sta)
  155. {
  156. kref_get(&sta->kref);
  157. }
  158. struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
  159. int sta_info_min_txrate_get(struct ieee80211_local *local);
  160. void sta_info_put(struct sta_info *sta);
  161. struct sta_info * sta_info_add(struct ieee80211_local *local,
  162. struct net_device *dev, u8 *addr, gfp_t gfp);
  163. void sta_info_remove(struct sta_info *sta);
  164. void sta_info_free(struct sta_info *sta);
  165. void sta_info_init(struct ieee80211_local *local);
  166. int sta_info_start(struct ieee80211_local *local);
  167. void sta_info_stop(struct ieee80211_local *local);
  168. void sta_info_remove_aid_ptr(struct sta_info *sta);
  169. void sta_info_flush(struct ieee80211_local *local, struct net_device *dev);
  170. #endif /* STA_INFO_H */