11n.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * NXP Wireless LAN device driver: 802.11n
  4. *
  5. * Copyright 2011-2020 NXP
  6. */
  7. #ifndef _MWIFIEX_11N_H_
  8. #define _MWIFIEX_11N_H_
  9. #include "11n_aggr.h"
  10. #include "11n_rxreorder.h"
  11. #include "wmm.h"
  12. int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
  13. struct host_cmd_ds_command *resp);
  14. int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
  15. struct host_cmd_ds_command *resp);
  16. int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
  17. struct host_cmd_ds_command *cmd, u16 cmd_action,
  18. struct mwifiex_ds_11n_tx_cfg *txcfg);
  19. int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
  20. struct mwifiex_bssdescriptor *bss_desc,
  21. u8 **buffer);
  22. int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
  23. struct ieee80211_ht_cap *);
  24. int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
  25. u16 action, int *htcap_cfg);
  26. void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
  27. struct mwifiex_tx_ba_stream_tbl
  28. *tx_tbl);
  29. void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
  30. struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
  31. mwifiex_private
  32. *priv, int tid,
  33. u8 *ra);
  34. void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
  35. enum mwifiex_ba_status ba_status);
  36. int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
  37. int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
  38. int initiator);
  39. void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
  40. int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
  41. struct mwifiex_ds_rx_reorder_tbl *buf);
  42. int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
  43. struct mwifiex_ds_tx_ba_stream_tbl *buf);
  44. int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
  45. struct host_cmd_ds_command *cmd,
  46. int cmd_action, u16 *buf_size);
  47. int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
  48. int cmd_action,
  49. struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
  50. void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
  51. u8 mwifiex_get_sec_chan_offset(int chan);
  52. static inline u8
  53. mwifiex_is_station_ampdu_allowed(struct mwifiex_private *priv,
  54. struct mwifiex_ra_list_tbl *ptr, int tid)
  55. {
  56. struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ptr->ra);
  57. if (unlikely(!node))
  58. return false;
  59. return (node->ampdu_sta[tid] != BA_STREAM_NOT_ALLOWED) ? true : false;
  60. }
  61. /* This function checks whether AMPDU is allowed or not for a particular TID. */
  62. static inline u8
  63. mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
  64. struct mwifiex_ra_list_tbl *ptr, int tid)
  65. {
  66. if (is_broadcast_ether_addr(ptr->ra))
  67. return false;
  68. if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
  69. return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
  70. } else {
  71. if (ptr->tdls_link)
  72. return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
  73. return (priv->aggr_prio_tbl[tid].ampdu_ap !=
  74. BA_STREAM_NOT_ALLOWED) ? true : false;
  75. }
  76. }
  77. /*
  78. * This function checks whether AMSDU is allowed or not for a particular TID.
  79. */
  80. static inline u8
  81. mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
  82. {
  83. return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
  84. (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
  85. ? true : false);
  86. }
  87. /*
  88. * This function checks whether a space is available for new BA stream or not.
  89. */
  90. static inline u8 mwifiex_space_avail_for_new_ba_stream(
  91. struct mwifiex_adapter *adapter)
  92. {
  93. struct mwifiex_private *priv;
  94. u8 i;
  95. u32 ba_stream_num = 0, ba_stream_max;
  96. ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
  97. for (i = 0; i < adapter->priv_num; i++) {
  98. priv = adapter->priv[i];
  99. if (priv)
  100. ba_stream_num += mwifiex_wmm_list_len(
  101. &priv->tx_ba_stream_tbl_ptr);
  102. }
  103. if (adapter->fw_api_ver == MWIFIEX_FW_V15) {
  104. ba_stream_max =
  105. GETSUPP_TXBASTREAMS(adapter->hw_dot_11n_dev_cap);
  106. if (!ba_stream_max)
  107. ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
  108. }
  109. return ((ba_stream_num < ba_stream_max) ? true : false);
  110. }
  111. /*
  112. * This function finds the correct Tx BA stream to delete.
  113. *
  114. * Upon successfully locating, both the TID and the RA are returned.
  115. */
  116. static inline u8
  117. mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
  118. int *ptid, u8 *ra)
  119. {
  120. int tid;
  121. u8 ret = false;
  122. struct mwifiex_tx_ba_stream_tbl *tx_tbl;
  123. tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
  124. spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
  125. list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
  126. if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
  127. tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
  128. *ptid = tx_tbl->tid;
  129. memcpy(ra, tx_tbl->ra, ETH_ALEN);
  130. ret = true;
  131. }
  132. }
  133. spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
  134. return ret;
  135. }
  136. /*
  137. * This function checks whether associated station is 11n enabled
  138. */
  139. static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
  140. struct mwifiex_sta_node *node)
  141. {
  142. if (!node || ((priv->bss_role == MWIFIEX_BSS_ROLE_UAP) &&
  143. !priv->ap_11n_enabled) ||
  144. ((priv->bss_mode == NL80211_IFTYPE_ADHOC) &&
  145. !priv->adapter->adhoc_11n_enabled))
  146. return 0;
  147. return node->is_11n_enabled;
  148. }
  149. static inline u8
  150. mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra)
  151. {
  152. struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra);
  153. if (node)
  154. return node->is_11n_enabled;
  155. return false;
  156. }
  157. #endif /* !_MWIFIEX_11N_H_ */