11n.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Marvell Wireless LAN device driver: 802.11n
  3. *
  4. * Copyright (C) 2011-2014, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #ifndef _MWIFIEX_11N_H_
  20. #define _MWIFIEX_11N_H_
  21. #include "11n_aggr.h"
  22. #include "11n_rxreorder.h"
  23. #include "wmm.h"
  24. int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
  25. struct host_cmd_ds_command *resp);
  26. int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
  27. struct host_cmd_ds_command *resp);
  28. int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
  29. struct host_cmd_ds_command *cmd, u16 cmd_action,
  30. struct mwifiex_ds_11n_tx_cfg *txcfg);
  31. int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
  32. struct mwifiex_bssdescriptor *bss_desc,
  33. u8 **buffer);
  34. int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
  35. struct ieee80211_ht_cap *);
  36. int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
  37. u16 action, int *htcap_cfg);
  38. void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
  39. struct mwifiex_tx_ba_stream_tbl
  40. *tx_tbl);
  41. void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
  42. struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
  43. mwifiex_private
  44. *priv, int tid,
  45. u8 *ra);
  46. void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
  47. enum mwifiex_ba_status ba_status);
  48. int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
  49. int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
  50. int initiator);
  51. void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
  52. int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
  53. struct mwifiex_ds_rx_reorder_tbl *buf);
  54. int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
  55. struct mwifiex_ds_tx_ba_stream_tbl *buf);
  56. int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
  57. struct host_cmd_ds_command *cmd,
  58. int cmd_action, u16 *buf_size);
  59. int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
  60. int cmd_action,
  61. struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
  62. void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
  63. u8 mwifiex_get_sec_chan_offset(int chan);
  64. static inline u8
  65. mwifiex_is_station_ampdu_allowed(struct mwifiex_private *priv,
  66. struct mwifiex_ra_list_tbl *ptr, int tid)
  67. {
  68. struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ptr->ra);
  69. if (unlikely(!node))
  70. return false;
  71. return (node->ampdu_sta[tid] != BA_STREAM_NOT_ALLOWED) ? true : false;
  72. }
  73. /* This function checks whether AMPDU is allowed or not for a particular TID. */
  74. static inline u8
  75. mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
  76. struct mwifiex_ra_list_tbl *ptr, int tid)
  77. {
  78. if (is_broadcast_ether_addr(ptr->ra))
  79. return false;
  80. if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
  81. return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
  82. } else {
  83. if (ptr->tdls_link)
  84. return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
  85. return (priv->aggr_prio_tbl[tid].ampdu_ap !=
  86. BA_STREAM_NOT_ALLOWED) ? true : false;
  87. }
  88. }
  89. /*
  90. * This function checks whether AMSDU is allowed or not for a particular TID.
  91. */
  92. static inline u8
  93. mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
  94. {
  95. return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
  96. (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
  97. ? true : false);
  98. }
  99. /*
  100. * This function checks whether a space is available for new BA stream or not.
  101. */
  102. static inline u8 mwifiex_space_avail_for_new_ba_stream(
  103. struct mwifiex_adapter *adapter)
  104. {
  105. struct mwifiex_private *priv;
  106. u8 i;
  107. u32 ba_stream_num = 0, ba_stream_max;
  108. ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
  109. for (i = 0; i < adapter->priv_num; i++) {
  110. priv = adapter->priv[i];
  111. if (priv)
  112. ba_stream_num += mwifiex_wmm_list_len(
  113. &priv->tx_ba_stream_tbl_ptr);
  114. }
  115. if (adapter->fw_api_ver == MWIFIEX_FW_V15) {
  116. ba_stream_max =
  117. GETSUPP_TXBASTREAMS(adapter->hw_dot_11n_dev_cap);
  118. if (!ba_stream_max)
  119. ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
  120. }
  121. return ((ba_stream_num < ba_stream_max) ? true : false);
  122. }
  123. /*
  124. * This function finds the correct Tx BA stream to delete.
  125. *
  126. * Upon successfully locating, both the TID and the RA are returned.
  127. */
  128. static inline u8
  129. mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
  130. int *ptid, u8 *ra)
  131. {
  132. int tid;
  133. u8 ret = false;
  134. struct mwifiex_tx_ba_stream_tbl *tx_tbl;
  135. unsigned long flags;
  136. tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
  137. spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags);
  138. list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
  139. if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
  140. tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
  141. *ptid = tx_tbl->tid;
  142. memcpy(ra, tx_tbl->ra, ETH_ALEN);
  143. ret = true;
  144. }
  145. }
  146. spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags);
  147. return ret;
  148. }
  149. /*
  150. * This function checks whether associated station is 11n enabled
  151. */
  152. static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
  153. struct mwifiex_sta_node *node)
  154. {
  155. if (!node || (priv->bss_role != MWIFIEX_BSS_ROLE_UAP) ||
  156. !priv->ap_11n_enabled)
  157. return 0;
  158. return node->is_11n_enabled;
  159. }
  160. static inline u8
  161. mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra)
  162. {
  163. struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra);
  164. if (node)
  165. return node->is_11n_enabled;
  166. return false;
  167. }
  168. #endif /* !_MWIFIEX_11N_H_ */