11n.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Marvell Wireless LAN device driver: 802.11n
  3. *
  4. * Copyright (C) 2011, 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 host_cmd_ds_command *cmd, u16 cmd_action,
  29. struct mwifiex_ds_11n_tx_cfg *txcfg);
  30. int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
  31. struct mwifiex_bssdescriptor *bss_desc,
  32. u8 **buffer);
  33. void mwifiex_cfg_tx_buf(struct mwifiex_private *priv,
  34. struct mwifiex_bssdescriptor *bss_desc);
  35. void mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
  36. struct mwifiex_ie_types_htcap *);
  37. int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
  38. u16 action, int *htcap_cfg);
  39. void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
  40. struct mwifiex_tx_ba_stream_tbl
  41. *tx_tbl);
  42. void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
  43. struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
  44. mwifiex_private
  45. *priv, int tid,
  46. u8 *ra);
  47. void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
  48. enum mwifiex_ba_status ba_status);
  49. int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
  50. int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
  51. int initiator);
  52. void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
  53. int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
  54. struct mwifiex_ds_rx_reorder_tbl *buf);
  55. int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
  56. struct mwifiex_ds_tx_ba_stream_tbl *buf);
  57. int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp,
  58. struct mwifiex_ds_11n_amsdu_aggr_ctrl
  59. *amsdu_aggr_ctrl);
  60. int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
  61. struct host_cmd_ds_command *cmd,
  62. int cmd_action, u16 *buf_size);
  63. int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
  64. int cmd_action,
  65. struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
  66. void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
  67. /*
  68. * This function checks whether AMPDU is allowed or not for a particular TID.
  69. */
  70. static inline u8
  71. mwifiex_is_ampdu_allowed(struct mwifiex_private *priv, int tid)
  72. {
  73. return ((priv->aggr_prio_tbl[tid].ampdu_ap != BA_STREAM_NOT_ALLOWED)
  74. ? true : false);
  75. }
  76. /*
  77. * This function checks whether AMSDU is allowed or not for a particular TID.
  78. */
  79. static inline u8
  80. mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
  81. {
  82. return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
  83. (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
  84. ? true : false);
  85. }
  86. /*
  87. * This function checks whether a space is available for new BA stream or not.
  88. */
  89. static inline u8 mwifiex_space_avail_for_new_ba_stream(
  90. struct mwifiex_adapter *adapter)
  91. {
  92. struct mwifiex_private *priv;
  93. u8 i;
  94. u32 ba_stream_num = 0;
  95. for (i = 0; i < adapter->priv_num; i++) {
  96. priv = adapter->priv[i];
  97. if (priv)
  98. ba_stream_num += mwifiex_wmm_list_len(
  99. &priv->tx_ba_stream_tbl_ptr);
  100. }
  101. return ((ba_stream_num <
  102. MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) ? true : false);
  103. }
  104. /*
  105. * This function finds the correct Tx BA stream to delete.
  106. *
  107. * Upon successfully locating, both the TID and the RA are returned.
  108. */
  109. static inline u8
  110. mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
  111. int *ptid, u8 *ra)
  112. {
  113. int tid;
  114. u8 ret = false;
  115. struct mwifiex_tx_ba_stream_tbl *tx_tbl;
  116. unsigned long flags;
  117. tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
  118. spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags);
  119. list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
  120. if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
  121. tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
  122. *ptid = tx_tbl->tid;
  123. memcpy(ra, tx_tbl->ra, ETH_ALEN);
  124. ret = true;
  125. }
  126. }
  127. spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags);
  128. return ret;
  129. }
  130. /*
  131. * This function checks whether BA stream is set up or not.
  132. */
  133. static inline int
  134. mwifiex_is_ba_stream_setup(struct mwifiex_private *priv,
  135. struct mwifiex_ra_list_tbl *ptr, int tid)
  136. {
  137. struct mwifiex_tx_ba_stream_tbl *tx_tbl;
  138. tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra);
  139. if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl))
  140. return true;
  141. return false;
  142. }
  143. /*
  144. * This function checks whether associated station is 11n enabled
  145. */
  146. static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
  147. struct mwifiex_sta_node *node)
  148. {
  149. if (!node || (priv->bss_role != MWIFIEX_BSS_ROLE_UAP) ||
  150. !priv->ap_11n_enabled)
  151. return 0;
  152. return node->is_11n_enabled;
  153. }
  154. #endif /* !_MWIFIEX_11N_H_ */