common.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <net/mac80211.h>
  17. #include "../ath.h"
  18. #include "../debug.h"
  19. #include "hw.h"
  20. /* Common header for Atheros 802.11n base driver cores */
  21. #define IEEE80211_WEP_NKID 4
  22. #define WME_NUM_TID 16
  23. #define WME_BA_BMP_SIZE 64
  24. #define WME_MAX_BA WME_BA_BMP_SIZE
  25. #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
  26. #define WME_AC_BE 0
  27. #define WME_AC_BK 1
  28. #define WME_AC_VI 2
  29. #define WME_AC_VO 3
  30. #define WME_NUM_AC 4
  31. #define ATH_RSSI_DUMMY_MARKER 0x127
  32. #define ATH_RSSI_LPF_LEN 10
  33. #define RSSI_LPF_THRESHOLD -20
  34. #define ATH_RSSI_EP_MULTIPLIER (1<<7)
  35. #define ATH_EP_MUL(x, mul) ((x) * (mul))
  36. #define ATH_RSSI_IN(x) (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER))
  37. #define ATH_LPF_RSSI(x, y, len) \
  38. ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y))
  39. #define ATH_RSSI_LPF(x, y) do { \
  40. if ((y) >= RSSI_LPF_THRESHOLD) \
  41. x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \
  42. } while (0)
  43. #define ATH_EP_RND(x, mul) \
  44. ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
  45. struct ath_atx_ac {
  46. int sched;
  47. int qnum;
  48. struct list_head list;
  49. struct list_head tid_q;
  50. };
  51. struct ath_buf_state {
  52. int bfs_nframes;
  53. u16 bfs_al;
  54. u16 bfs_frmlen;
  55. int bfs_seqno;
  56. int bfs_tidno;
  57. int bfs_retries;
  58. u8 bf_type;
  59. u32 bfs_keyix;
  60. enum ath9k_key_type bfs_keytype;
  61. };
  62. struct ath_buf {
  63. struct list_head list;
  64. struct ath_buf *bf_lastbf; /* last buf of this unit (a frame or
  65. an aggregate) */
  66. struct ath_buf *bf_next; /* next subframe in the aggregate */
  67. struct sk_buff *bf_mpdu; /* enclosing frame structure */
  68. struct ath_desc *bf_desc; /* virtual addr of desc */
  69. dma_addr_t bf_daddr; /* physical addr of desc */
  70. dma_addr_t bf_buf_addr; /* physical addr of data buffer */
  71. bool bf_stale;
  72. bool bf_isnullfunc;
  73. u16 bf_flags;
  74. struct ath_buf_state bf_state;
  75. dma_addr_t bf_dmacontext;
  76. struct ath_wiphy *aphy;
  77. };
  78. struct ath_atx_tid {
  79. struct list_head list;
  80. struct list_head buf_q;
  81. struct ath_node *an;
  82. struct ath_atx_ac *ac;
  83. struct ath_buf *tx_buf[ATH_TID_MAX_BUFS];
  84. u16 seq_start;
  85. u16 seq_next;
  86. u16 baw_size;
  87. int tidno;
  88. int baw_head; /* first un-acked tx buffer */
  89. int baw_tail; /* next unused tx buffer slot */
  90. int sched;
  91. int paused;
  92. u8 state;
  93. };
  94. struct ath_node {
  95. struct ath_common *common;
  96. struct ath_atx_tid tid[WME_NUM_TID];
  97. struct ath_atx_ac ac[WME_NUM_AC];
  98. u16 maxampdu;
  99. u8 mpdudensity;
  100. int last_rssi;
  101. };
  102. int ath9k_cmn_rx_skb_preprocess(struct ath_common *common,
  103. struct ieee80211_hw *hw,
  104. struct sk_buff *skb,
  105. struct ath_rx_status *rx_stats,
  106. struct ieee80211_rx_status *rx_status,
  107. bool *decrypt_error);
  108. void ath9k_cmn_rx_skb_postprocess(struct ath_common *common,
  109. struct sk_buff *skb,
  110. struct ath_rx_status *rx_stats,
  111. struct ieee80211_rx_status *rxs,
  112. bool decrypt_error);
  113. int ath9k_cmn_padpos(__le16 frame_control);
  114. int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
  115. void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
  116. struct ath9k_channel *ichan);
  117. struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
  118. struct ath_hw *ah);
  119. int ath9k_cmn_key_config(struct ath_common *common,
  120. struct ieee80211_vif *vif,
  121. struct ieee80211_sta *sta,
  122. struct ieee80211_key_conf *key);
  123. void ath9k_cmn_key_delete(struct ath_common *common,
  124. struct ieee80211_key_conf *key);