// SPDX-License-Identifier: GPL-2.0-only /* * NXP Wireless LAN device driver: AP specific command handling * * Copyright 2011-2020 NXP
*/
#include"main.h" #include"11ac.h" #include"11n.h"
/* This function parses security related parameters from cfg80211_ap_settings * and sets into FW understandable bss_config structure.
*/ int mwifiex_set_secure_params(struct mwifiex_private *priv, struct mwifiex_uap_bss_param *bss_config, struct cfg80211_ap_settings *params) { int i; struct mwifiex_wep_key wep_key;
/* This function updates 11n related parameters from IE and sets them into * bss_config structure.
*/ void
mwifiex_set_ht_params(struct mwifiex_private *priv, struct mwifiex_uap_bss_param *bss_cfg, struct cfg80211_ap_settings *params)
{ const u8 *ht_ie;
if (!ISSUPP_11NENABLED(priv->adapter->fw_cap_info)) return;
/* This function updates 11ac related parameters from IE * and sets them into bss_config structure.
*/ void mwifiex_set_vht_params(struct mwifiex_private *priv, struct mwifiex_uap_bss_param *bss_cfg, struct cfg80211_ap_settings *params)
{ const u8 *vht_ie;
/* This function updates 11ac related parameters from IE * and sets them into bss_config structure.
*/ void mwifiex_set_tpc_params(struct mwifiex_private *priv, struct mwifiex_uap_bss_param *bss_cfg, struct cfg80211_ap_settings *params)
{ const u8 *tpc_ie;
/* This function initializes some of mwifiex_uap_bss_param variables. * This helps FW in ignoring invalid values. These values may or may not * be get updated to valid ones at later stage.
*/ void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config)
{
config->bcast_ssid_ctl = 0x7F;
config->radio_ctl = 0x7F;
config->dtim_period = 0x7F;
config->beacon_period = 0x7FFF;
config->auth_mode = 0x7F;
config->rts_threshold = 0x7FFF;
config->frag_threshold = 0x7FFF;
config->retry_limit = 0x7F;
config->qos_info = 0xFF;
}
/* This function parses BSS related parameters from structure * and prepares TLVs specific to WPA/WPA2 security. * These TLVs are appended to command buffer.
*/ staticvoid
mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size)
{ struct host_cmd_tlv_pwk_cipher *pwk_cipher; struct host_cmd_tlv_gwk_cipher *gwk_cipher; struct host_cmd_tlv_passphrase *passphrase; struct host_cmd_tlv_akmp *tlv_akmp; struct mwifiex_uap_bss_param *bss_cfg = cmd_buf;
u16 cmd_size = *param_size;
u8 *tlv = *tlv_buf;
/* This function enable 11D if userspace set the country IE.
*/ void mwifiex_config_uap_11d(struct mwifiex_private *priv, struct cfg80211_beacon_data *beacon_data)
{ enum state_11d_t state_11d; const u8 *country_ie;
country_ie = cfg80211_find_ie(WLAN_EID_COUNTRY, beacon_data->tail,
beacon_data->tail_len); if (country_ie) { /* Send cmd to FW to enable 11D function */
state_11d = ENABLE_11D; if (mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB,
HostCmd_ACT_GEN_SET, DOT11D_I,
&state_11d, true)) {
mwifiex_dbg(priv->adapter, ERROR, "11D: failed to enable 11D\n");
}
}
}
/* This function parses BSS related parameters from structure * and prepares TLVs. These TLVs are appended to command buffer.
*/ staticint
mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
{ struct host_cmd_tlv_mac_addr *mac_tlv; struct host_cmd_tlv_dtim_period *dtim_period; struct host_cmd_tlv_beacon_period *beacon_period; struct host_cmd_tlv_ssid *ssid; struct host_cmd_tlv_bcast_ssid *bcast_ssid; struct host_cmd_tlv_channel_band *chan_band; struct host_cmd_tlv_frag_threshold *frag_threshold; struct host_cmd_tlv_rts_threshold *rts_threshold; struct host_cmd_tlv_retry_limit *retry_limit; struct host_cmd_tlv_encrypt_protocol *encrypt_protocol; struct host_cmd_tlv_auth_type *auth_type; struct host_cmd_tlv_rates *tlv_rates; struct host_cmd_tlv_ageout_timer *ao_timer, *ps_ao_timer; struct host_cmd_tlv_power_constraint *pwr_ct; struct mwifiex_ie_types_htcap *htcap; struct mwifiex_ie_types_wmmcap *wmm_cap; struct mwifiex_uap_bss_param *bss_cfg = cmd_buf; int i;
u16 cmd_size = *param_size;
switch (type) { case UAP_BSS_PARAMS_I:
param_size = cmd_size; if (mwifiex_uap_bss_param_prepare(tlv, cmd_buf, ¶m_size)) return -1;
cmd->size = cpu_to_le16(param_size); break; case UAP_CUSTOM_IE_I:
ie_size = cmd_size; if (mwifiex_uap_custom_ie_prepare(tlv, cmd_buf, &ie_size)) return -1;
cmd->size = cpu_to_le16(ie_size); break; default: return -1;
}
return 0;
}
/* This function prepares AP start up command with or without host MLME
*/ staticvoid mwifiex_cmd_uap_bss_start(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd)
{ struct mwifiex_ie_types_host_mlme *tlv; int size;
/* This function prepares AP specific deauth command with mac supplied in * function parameter.
*/ staticint mwifiex_cmd_uap_sta_deauth(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, u8 *mac)
{ struct host_cmd_ds_sta_deauth *sta_deauth = &cmd->params.sta_deauth;
for (i = 0; i < MAX_NUM_TID; i++) { if (sta_ptr->is_11n_enabled)
sta_ptr->ampdu_sta[i] =
priv->aggr_prio_tbl[i].ampdu_user; else
sta_ptr->ampdu_sta[i] = BA_STREAM_NOT_ALLOWED;
}
/* This function prepares the AP specific commands before sending them * to the firmware. * This is a generic function which calls specific command preparation * routines based upon the command number.
*/ int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, u16 cmd_no,
u16 cmd_action, u32 type, void *data_buf, void *cmd_buf)
{ struct host_cmd_ds_command *cmd = cmd_buf;
switch (cmd_no) { case HostCmd_CMD_UAP_SYS_CONFIG: if (mwifiex_cmd_uap_sys_config(cmd, cmd_action, type, data_buf)) return -1; break; case HostCmd_CMD_UAP_BSS_START:
mwifiex_cmd_uap_bss_start(priv, cmd); break; case HostCmd_CMD_UAP_BSS_STOP: case HOST_CMD_APCMD_SYS_RESET: case HOST_CMD_APCMD_STA_LIST:
cmd->command = cpu_to_le16(cmd_no);
cmd->size = cpu_to_le16(S_DS_GEN); break; case HostCmd_CMD_UAP_STA_DEAUTH: if (mwifiex_cmd_uap_sta_deauth(priv, cmd, data_buf)) return -1; break; case HostCmd_CMD_CHAN_REPORT_REQUEST: if (mwifiex_cmd_issue_chan_report_request(priv, cmd_buf,
data_buf)) return -1; break; case HostCmd_CMD_ADD_NEW_STATION: if (mwifiex_cmd_uap_add_station(priv, cmd, cmd_action,
data_buf)) return -1; break; default:
mwifiex_dbg(priv->adapter, ERROR, "PREP_CMD: unknown cmd %#x\n", cmd_no); return -1;
}
if (chandef.width > NL80211_CHAN_WIDTH_20_NOHT)
config_bands |= BAND_AN;
if (chandef.width > NL80211_CHAN_WIDTH_40)
config_bands |= BAND_AAC;
}
switch (chandef.width) { case NL80211_CHAN_WIDTH_5: case NL80211_CHAN_WIDTH_10: case NL80211_CHAN_WIDTH_20_NOHT: case NL80211_CHAN_WIDTH_20: break; case NL80211_CHAN_WIDTH_40: if (chandef.center_freq1 < chandef.chan->center_freq)
bss_cfg->band_cfg |= MWIFIEX_SEC_CHAN_BELOW; else
bss_cfg->band_cfg |= MWIFIEX_SEC_CHAN_ABOVE; break; case NL80211_CHAN_WIDTH_80: case NL80211_CHAN_WIDTH_80P80: case NL80211_CHAN_WIDTH_160:
bss_cfg->band_cfg |=
mwifiex_get_sec_chan_offset(bss_cfg->channel) << 4; break; default:
mwifiex_dbg(priv->adapter,
WARN, "Unknown channel width: %d\n",
chandef.width); break;
}
priv->adapter->config_bands = config_bands;
if (old_bands != config_bands) {
mwifiex_send_domain_info_cmd_fw(priv->adapter->wiphy);
mwifiex_dnld_txpwr_table(priv);
}
}
int mwifiex_config_start_uap(struct mwifiex_private *priv, struct mwifiex_uap_bss_param *bss_cfg)
{ if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_SYS_CONFIG,
HostCmd_ACT_GEN_SET,
UAP_BSS_PARAMS_I, bss_cfg, true)) {
mwifiex_dbg(priv->adapter, ERROR, "Failed to set AP configuration\n"); return -1;
}
if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_START,
HostCmd_ACT_GEN_SET, 0, NULL, true)) {
mwifiex_dbg(priv->adapter, ERROR, "Failed to start the BSS\n"); return -1;
}
if (priv->sec_info.wep_enabled)
priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE; else
priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
if (mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
HostCmd_ACT_GEN_SET, 0,
&priv->curr_pkt_filter, true)) return -1;
return 0;
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.18Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.