Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * NXP Wireless LAN device driver: 802.11n
0004  *
0005  * Copyright 2011-2020 NXP
0006  */
0007 
0008 #ifndef _MWIFIEX_11N_H_
0009 #define _MWIFIEX_11N_H_
0010 
0011 #include "11n_aggr.h"
0012 #include "11n_rxreorder.h"
0013 #include "wmm.h"
0014 
0015 int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
0016               struct host_cmd_ds_command *resp);
0017 int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
0018                   struct host_cmd_ds_command *resp);
0019 int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
0020             struct host_cmd_ds_command *cmd, u16 cmd_action,
0021             struct mwifiex_ds_11n_tx_cfg *txcfg);
0022 int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
0023                    struct mwifiex_bssdescriptor *bss_desc,
0024                    u8 **buffer);
0025 int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
0026               struct ieee80211_ht_cap *);
0027 int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
0028                   u16 action, int *htcap_cfg);
0029 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
0030                          struct mwifiex_tx_ba_stream_tbl
0031                          *tx_tbl);
0032 void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
0033 struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
0034                                  mwifiex_private
0035                                  *priv, int tid,
0036                                  u8 *ra);
0037 void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
0038                enum mwifiex_ba_status ba_status);
0039 int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
0040 int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
0041                int initiator);
0042 void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
0043 int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
0044                   struct mwifiex_ds_rx_reorder_tbl *buf);
0045 int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
0046                    struct mwifiex_ds_tx_ba_stream_tbl *buf);
0047 int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
0048                  struct host_cmd_ds_command *cmd,
0049                  int cmd_action, u16 *buf_size);
0050 int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
0051                 int cmd_action,
0052                 struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
0053 void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
0054 u8 mwifiex_get_sec_chan_offset(int chan);
0055 
0056 static inline u8
0057 mwifiex_is_station_ampdu_allowed(struct mwifiex_private *priv,
0058                  struct mwifiex_ra_list_tbl *ptr, int tid)
0059 {
0060     struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ptr->ra);
0061 
0062     if (unlikely(!node))
0063         return false;
0064 
0065     return (node->ampdu_sta[tid] != BA_STREAM_NOT_ALLOWED) ? true : false;
0066 }
0067 
0068 /* This function checks whether AMPDU is allowed or not for a particular TID. */
0069 static inline u8
0070 mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
0071              struct mwifiex_ra_list_tbl *ptr, int tid)
0072 {
0073     if (is_broadcast_ether_addr(ptr->ra))
0074         return false;
0075     if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
0076         return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
0077     } else {
0078         if (ptr->tdls_link)
0079             return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
0080 
0081         return (priv->aggr_prio_tbl[tid].ampdu_ap !=
0082             BA_STREAM_NOT_ALLOWED) ? true : false;
0083     }
0084 }
0085 
0086 /*
0087  * This function checks whether AMSDU is allowed or not for a particular TID.
0088  */
0089 static inline u8
0090 mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
0091 {
0092     return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
0093          (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
0094         ? true : false);
0095 }
0096 
0097 /*
0098  * This function checks whether a space is available for new BA stream or not.
0099  */
0100 static inline u8 mwifiex_space_avail_for_new_ba_stream(
0101                     struct mwifiex_adapter *adapter)
0102 {
0103     struct mwifiex_private *priv;
0104     u8 i;
0105     u32 ba_stream_num = 0, ba_stream_max;
0106 
0107     ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
0108 
0109     for (i = 0; i < adapter->priv_num; i++) {
0110         priv = adapter->priv[i];
0111         if (priv)
0112             ba_stream_num += mwifiex_wmm_list_len(
0113                 &priv->tx_ba_stream_tbl_ptr);
0114     }
0115 
0116     if (adapter->fw_api_ver == MWIFIEX_FW_V15) {
0117         ba_stream_max =
0118                    GETSUPP_TXBASTREAMS(adapter->hw_dot_11n_dev_cap);
0119         if (!ba_stream_max)
0120             ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
0121     }
0122 
0123     return ((ba_stream_num < ba_stream_max) ? true : false);
0124 }
0125 
0126 /*
0127  * This function finds the correct Tx BA stream to delete.
0128  *
0129  * Upon successfully locating, both the TID and the RA are returned.
0130  */
0131 static inline u8
0132 mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
0133                   int *ptid, u8 *ra)
0134 {
0135     int tid;
0136     u8 ret = false;
0137     struct mwifiex_tx_ba_stream_tbl *tx_tbl;
0138 
0139     tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
0140 
0141     spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0142     list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
0143         if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
0144             tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
0145             *ptid = tx_tbl->tid;
0146             memcpy(ra, tx_tbl->ra, ETH_ALEN);
0147             ret = true;
0148         }
0149     }
0150     spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0151 
0152     return ret;
0153 }
0154 
0155 /*
0156  * This function checks whether associated station is 11n enabled
0157  */
0158 static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
0159                          struct mwifiex_sta_node *node)
0160 {
0161     if (!node || ((priv->bss_role == MWIFIEX_BSS_ROLE_UAP) &&
0162               !priv->ap_11n_enabled) ||
0163         ((priv->bss_mode == NL80211_IFTYPE_ADHOC) &&
0164          !priv->adapter->adhoc_11n_enabled))
0165         return 0;
0166 
0167     return node->is_11n_enabled;
0168 }
0169 
0170 static inline u8
0171 mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra)
0172 {
0173     struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra);
0174     if (node)
0175         return node->is_11n_enabled;
0176 
0177     return false;
0178 }
0179 #endif /* !_MWIFIEX_11N_H_ */