/* * Copyright (c) 2014 Redpine Signals Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/etherdevice.h> #include <linux/timer.h> #include "rsi_mgmt.h" #include "rsi_common.h" #include "rsi_ps.h" #include "rsi_hal.h" static struct bootup_params boot_params_20 = …; static struct bootup_params boot_params_40 = …; static struct bootup_params_9116 boot_params_9116_20 = …; static struct bootup_params_9116 boot_params_9116_40 = …; static u16 mcs[] = …; /** * rsi_set_default_parameters() - This function sets default parameters. * @common: Pointer to the driver private structure. * * Return: none */ static void rsi_set_default_parameters(struct rsi_common *common) { … } void init_bgscan_params(struct rsi_common *common) { … } /** * rsi_set_contention_vals() - This function sets the contention values for the * backoff procedure. * @common: Pointer to the driver private structure. * * Return: None. */ static void rsi_set_contention_vals(struct rsi_common *common) { … } /** * rsi_send_internal_mgmt_frame() - This function sends management frames to * firmware.Also schedules packet to queue * for transmission. * @common: Pointer to the driver private structure. * @skb: Pointer to the socket buffer structure. * * Return: 0 on success, -1 on failure. */ static int rsi_send_internal_mgmt_frame(struct rsi_common *common, struct sk_buff *skb) { … } /** * rsi_load_radio_caps() - This function is used to send radio capabilities * values to firmware. * @common: Pointer to the driver private structure. * * Return: 0 on success, corresponding negative error code on failure. */ static int rsi_load_radio_caps(struct rsi_common *common) { … } /** * rsi_mgmt_pkt_to_core() - This function is the entry point for Mgmt module. * @common: Pointer to the driver private structure. * @msg: Pointer to received packet. * @msg_len: Length of the received packet. * * Return: 0 on success, -1 on failure. */ static int rsi_mgmt_pkt_to_core(struct rsi_common *common, u8 *msg, s32 msg_len) { … } /** * rsi_hal_send_sta_notify_frame() - This function sends the station notify * frame to firmware. * @common: Pointer to the driver private structure. * @opmode: Operating mode of device. * @notify_event: Notification about station connection. * @bssid: bssid. * @qos_enable: Qos is enabled. * @aid: Aid (unique for all STA). * @sta_id: station id. * @vif: Pointer to the ieee80211_vif structure. * * Return: status: 0 on success, corresponding negative error code on failure. */ int rsi_hal_send_sta_notify_frame(struct rsi_common *common, enum opmode opmode, u8 notify_event, const unsigned char *bssid, u8 qos_enable, u16 aid, u16 sta_id, struct ieee80211_vif *vif) { … } /** * rsi_send_aggregation_params_frame() - This function sends the ampdu * indication frame to firmware. * @common: Pointer to the driver private structure. * @tid: traffic identifier. * @ssn: ssn. * @buf_size: buffer size. * @event: notification about station connection. * @sta_id: station id. * * Return: 0 on success, corresponding negative error code on failure. */ int rsi_send_aggregation_params_frame(struct rsi_common *common, u16 tid, u16 ssn, u8 buf_size, u8 event, u8 sta_id) { … } /** * rsi_program_bb_rf() - This function starts base band and RF programming. * This is called after initial configurations are done. * @common: Pointer to the driver private structure. * * Return: 0 on success, corresponding negative error code on failure. */ static int rsi_program_bb_rf(struct rsi_common *common) { … } /** * rsi_set_vap_capabilities() - This function send vap capability to firmware. * @common: Pointer to the driver private structure. * @mode: Operating mode of device. * @mac_addr: MAC address * @vap_id: Rate information - offset and mask * @vap_status: VAP status - ADD, DELETE or UPDATE * * Return: 0 on success, corresponding negative error code on failure. */ int rsi_set_vap_capabilities(struct rsi_common *common, enum opmode mode, u8 *mac_addr, u8 vap_id, u8 vap_status) { … } /** * rsi_hal_load_key() - This function is used to load keys within the firmware. * @common: Pointer to the driver private structure. * @data: Pointer to the key data. * @key_len: Key length to be loaded. * @key_type: Type of key: GROUP/PAIRWISE. * @key_id: Key index. * @cipher: Type of cipher used. * @sta_id: Station id. * @vif: Pointer to the ieee80211_vif structure. * * Return: 0 on success, -1 on failure. */ int rsi_hal_load_key(struct rsi_common *common, u8 *data, u16 key_len, u8 key_type, u8 key_id, u32 cipher, s16 sta_id, struct ieee80211_vif *vif) { … } /* * This function sends the common device configuration parameters to device. * This frame includes the useful information to make device works on * specific operating mode. */ static int rsi_send_common_dev_params(struct rsi_common *common) { … } /* * rsi_load_bootup_params() - This function send bootup params to the firmware. * @common: Pointer to the driver private structure. * * Return: 0 on success, corresponding error code on failure. */ static int rsi_load_bootup_params(struct rsi_common *common) { … } static int rsi_load_9116_bootup_params(struct rsi_common *common) { … } /** * rsi_send_reset_mac() - This function prepares reset MAC request and sends an * internal management frame to indicate it to firmware. * @common: Pointer to the driver private structure. * * Return: 0 on success, corresponding error code on failure. */ static int rsi_send_reset_mac(struct rsi_common *common) { … } /** * rsi_band_check() - This function programs the band * @common: Pointer to the driver private structure. * @curchan: Pointer to the current channel structure. * * Return: 0 on success, corresponding error code on failure. */ int rsi_band_check(struct rsi_common *common, struct ieee80211_channel *curchan) { … } /** * rsi_set_channel() - This function programs the channel. * @common: Pointer to the driver private structure. * @channel: Channel value to be set. * * Return: 0 on success, corresponding error code on failure. */ int rsi_set_channel(struct rsi_common *common, struct ieee80211_channel *channel) { … } /** * rsi_send_radio_params_update() - This function sends the radio * parameters update to device * @common: Pointer to the driver private structure. * * Return: 0 on success, corresponding error code on failure. */ int rsi_send_radio_params_update(struct rsi_common *common) { … } /* This function programs the threshold. */ int rsi_send_vap_dynamic_update(struct rsi_common *common) { … } /** * rsi_compare() - This function is used to compare two integers * @a: pointer to the first integer * @b: pointer to the second integer * * Return: 0 if both are equal, -1 if the first is smaller, else 1 */ static int rsi_compare(const void *a, const void *b) { … } /** * rsi_map_rates() - This function is used to map selected rates to hw rates. * @rate: The standard rate to be mapped. * @offset: Offset that will be returned. * * Return: 0 if it is a mcs rate, else 1 */ static bool rsi_map_rates(u16 rate, int *offset) { … } /** * rsi_send_auto_rate_request() - This function is to set rates for connection * and send autorate request to firmware. * @common: Pointer to the driver private structure. * @sta: mac80211 station. * @sta_id: station id. * @vif: Pointer to the ieee80211_vif structure. * * Return: 0 on success, corresponding error code on failure. */ static int rsi_send_auto_rate_request(struct rsi_common *common, struct ieee80211_sta *sta, u16 sta_id, struct ieee80211_vif *vif) { … } /** * rsi_inform_bss_status() - This function informs about bss status with the * help of sta notify params by sending an internal * management frame to firmware. * @common: Pointer to the driver private structure. * @opmode: Operating mode of device. * @status: Bss status type. * @addr: Address of the register. * @qos_enable: Qos is enabled. * @aid: Aid (unique for all STAs). * @sta: mac80211 station. * @sta_id: station id. * @assoc_cap: capabilities. * @vif: Pointer to the ieee80211_vif structure. * * Return: None. */ void rsi_inform_bss_status(struct rsi_common *common, enum opmode opmode, u8 status, const u8 *addr, u8 qos_enable, u16 aid, struct ieee80211_sta *sta, u16 sta_id, u16 assoc_cap, struct ieee80211_vif *vif) { … } /** * rsi_eeprom_read() - This function sends a frame to read the mac address * from the eeprom. * @common: Pointer to the driver private structure. * * Return: 0 on success, -1 on failure. */ static int rsi_eeprom_read(struct rsi_common *common) { … } /** * rsi_send_block_unblock_frame() - This function sends a frame to block/unblock * data queues in the firmware * * @common: Pointer to the driver private structure. * @block_event: Event block if true, unblock if false * returns 0 on success, -1 on failure. */ int rsi_send_block_unblock_frame(struct rsi_common *common, bool block_event) { … } /** * rsi_send_rx_filter_frame() - Sends a frame to filter the RX packets * * @common: Pointer to the driver private structure. * @rx_filter_word: Flags of filter packets * * Returns 0 on success, -1 on failure. */ int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word) { … } int rsi_send_ps_request(struct rsi_hw *adapter, bool enable, struct ieee80211_vif *vif) { … } static int rsi_send_w9116_features(struct rsi_common *common) { … } /** * rsi_set_antenna() - This function send antenna configuration request * to device * * @common: Pointer to the driver private structure. * @antenna: bitmap for tx antenna selection * * Return: 0 on Success, negative error code on failure */ int rsi_set_antenna(struct rsi_common *common, u8 antenna) { … } static int rsi_send_beacon(struct rsi_common *common) { … } #ifdef CONFIG_PM int rsi_send_wowlan_request(struct rsi_common *common, u16 flags, u16 sleep_status) { … } #endif int rsi_send_bgscan_params(struct rsi_common *common, int enable) { … } /* This function sends the probe request to be used by firmware in * background scan */ int rsi_send_bgscan_probe_req(struct rsi_common *common, struct ieee80211_vif *vif) { … } /** * rsi_handle_ta_confirm_type() - This function handles the confirm frames. * @common: Pointer to the driver private structure. * @msg: Pointer to received packet. * * Return: 0 on success, -1 on failure. */ static int rsi_handle_ta_confirm_type(struct rsi_common *common, u8 *msg) { … } int rsi_handle_card_ready(struct rsi_common *common, u8 *msg) { … } /** * rsi_mgmt_pkt_recv() - This function processes the management packets * received from the hardware. * @common: Pointer to the driver private structure. * @msg: Pointer to the received packet. * * Return: 0 on success, -1 on failure. */ int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg) { … }