// SPDX-License-Identifier: GPL-2.0-only /* * NXP Wireless LAN device driver: association and ad-hoc start/join * * Copyright 2011-2020 NXP */ #include "decl.h" #include "ioctl.h" #include "util.h" #include "fw.h" #include "main.h" #include "wmm.h" #include "11n.h" #include "11ac.h" #define CAPINFO_MASK … /* * Append a generic IE as a pass through TLV to a TLV buffer. * * This function is called from the network join command preparation routine. * * If the IE buffer has been setup by the application, this routine appends * the buffer as a pass through TLV type to the request. */ static int mwifiex_cmd_append_generic_ie(struct mwifiex_private *priv, u8 **buffer) { … } /* * Append TSF tracking info from the scan table for the target AP. * * This function is called from the network join command preparation routine. * * The TSF table TSF sent to the firmware contains two TSF values: * - The TSF of the target AP from its previous beacon/probe response * - The TSF timestamp of our local MAC at the time we observed the * beacon/probe response. * * The firmware uses the timestamp values to set an initial TSF value * in the MAC for the new association after a reassociation attempt. */ static int mwifiex_cmd_append_tsf_tlv(struct mwifiex_private *priv, u8 **buffer, struct mwifiex_bssdescriptor *bss_desc) { … } /* * This function finds out the common rates between rate1 and rate2. * * It will fill common rates in rate1 as output if found. * * NOTE: Setting the MSB of the basic rates needs to be taken * care of, either before or after calling this function. */ static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1, u32 rate1_size, u8 *rate2, u32 rate2_size) { … } /* * This function creates the intersection of the rates supported by a * target BSS and our adapter settings for use in an assoc/join command. */ static int mwifiex_setup_rates_from_bssdesc(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc, u8 *out_rates, u32 *out_rates_size) { … } /* * This function appends a WPS IE. It is called from the network join command * preparation routine. * * If the IE buffer has been setup by the application, this routine appends * the buffer as a WPS TLV type to the request. */ static int mwifiex_cmd_append_wps_ie(struct mwifiex_private *priv, u8 **buffer) { … } /* * This function appends a WAPI IE. * * This function is called from the network join command preparation routine. * * If the IE buffer has been setup by the application, this routine appends * the buffer as a WAPI TLV type to the request. */ static int mwifiex_cmd_append_wapi_ie(struct mwifiex_private *priv, u8 **buffer) { … } /* * This function appends rsn ie tlv for wpa/wpa2 security modes. * It is called from the network join command preparation routine. */ static int mwifiex_append_rsn_ie_wpa_wpa2(struct mwifiex_private *priv, u8 **buffer) { … } /* * This function prepares command for association. * * This sets the following parameters - * - Peer MAC address * - Listen interval * - Beacon interval * - Capability information * * ...and the following TLVs, as required - * - SSID TLV * - PHY TLV * - SS TLV * - Rates TLV * - Authentication TLV * - Channel TLV * - WPA/WPA2 IE * - 11n TLV * - Vendor specific TLV * - WMM TLV * - WAPI IE * - Generic IE * - TSF TLV * * Preparation also includes - * - Setting command ID and proper size * - Ensuring correct endian-ness */ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, struct mwifiex_bssdescriptor *bss_desc) { … } static const char *assoc_failure_reason_to_str(u16 cap_info) { … } /* * Association firmware command response handler * * The response buffer for the association command has the following * memory layout. * * For cases where an association response was not received (indicated * by the CapInfo and AId field): * * .------------------------------------------------------------. * | Header(4 * sizeof(t_u16)): Standard command response hdr | * .------------------------------------------------------------. * | cap_info/Error Return(t_u16): | * | 0xFFFF(-1): Internal error | * | 0xFFFE(-2): Authentication unhandled message | * | 0xFFFD(-3): Authentication refused | * | 0xFFFC(-4): Timeout waiting for AP response | * .------------------------------------------------------------. * | status_code(t_u16): | * | If cap_info is -1: | * | An internal firmware failure prevented the | * | command from being processed. The status_code | * | will be set to 1. | * | | * | If cap_info is -2: | * | An authentication frame was received but was | * | not handled by the firmware. IEEE Status | * | code for the failure is returned. | * | | * | If cap_info is -3: | * | An authentication frame was received and the | * | status_code is the IEEE Status reported in the | * | response. | * | | * | If cap_info is -4: | * | (1) Association response timeout | * | (2) Authentication response timeout | * .------------------------------------------------------------. * | a_id(t_u16): 0xFFFF | * .------------------------------------------------------------. * * * For cases where an association response was received, the IEEE * standard association response frame is returned: * * .------------------------------------------------------------. * | Header(4 * sizeof(t_u16)): Standard command response hdr | * .------------------------------------------------------------. * | cap_info(t_u16): IEEE Capability | * .------------------------------------------------------------. * | status_code(t_u16): IEEE Status Code | * .------------------------------------------------------------. * | a_id(t_u16): IEEE Association ID | * .------------------------------------------------------------. * | IEEE IEs(variable): Any received IEs comprising the | * | remaining portion of a received | * | association response frame. | * .------------------------------------------------------------. * * For simplistic handling, the status_code field can be used to determine * an association success (0) or failure (non-zero). */ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) { … } /* * This function prepares command for ad-hoc start. * * Driver will fill up SSID, BSS mode, IBSS parameters, physical * parameters, probe delay, and capability information. Firmware * will fill up beacon period, basic rates and operational rates. * * In addition, the following TLVs are added - * - Channel TLV * - Vendor specific IE * - WPA/WPA2 IE * - HT Capabilities IE * - HT Information IE * * Preparation also includes - * - Setting command ID and proper size * - Ensuring correct endian-ness */ int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, struct cfg80211_ssid *req_ssid) { … } /* * This function prepares command for ad-hoc join. * * Most of the parameters are set up by copying from the target BSS descriptor * from the scan response. * * In addition, the following TLVs are added - * - Channel TLV * - Vendor specific IE * - WPA/WPA2 IE * - 11n IE * * Preparation also includes - * - Setting command ID and proper size * - Ensuring correct endian-ness */ int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, struct mwifiex_bssdescriptor *bss_desc) { … } /* * This function handles the command response of ad-hoc start and * ad-hoc join. * * The function generates a device-connected event to notify * the applications, in case of successful ad-hoc start/join, and * saves the beacon buffer. */ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) { … } /* * This function associates to a specific BSS discovered in a scan. * * It clears any past association response stored for application * retrieval and calls the command preparation routine to send the * command to firmware. */ int mwifiex_associate(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { … } /* * This function starts an ad-hoc network. * * It calls the command preparation routine to send the command to firmware. */ int mwifiex_adhoc_start(struct mwifiex_private *priv, struct cfg80211_ssid *adhoc_ssid) { … } /* * This function joins an ad-hoc network found in a previous scan. * * It calls the command preparation routine to send the command to firmware, * if already not connected to the requested SSID. */ int mwifiex_adhoc_join(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { … } /* * This function deauthenticates/disconnects from infra network by sending * deauthentication request. */ static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, u8 *mac) { … } /* * This function deauthenticates/disconnects from a BSS. * * In case of infra made, it sends deauthentication request, and * in case of ad-hoc mode, a stop network request is sent to the firmware. * In AP mode, a command to stop bss is sent to firmware. */ int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac) { … } /* This function deauthenticates/disconnects from all BSS. */ void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); /* * This function converts band to radio type used in channel TLV. */ u8 mwifiex_band_to_radio_type(u8 band) { … }