18c2ecf20Sopenharmony_ci/****************************************************************************** 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 118c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 128c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 158c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 168c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 178c2ecf20Sopenharmony_ci * General Public License for more details. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * The full GNU General Public License is included in this distribution 208c2ecf20Sopenharmony_ci * in the file called COPYING. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Contact Information: 238c2ecf20Sopenharmony_ci * Intel Linux Wireless <linuxwifi@intel.com> 248c2ecf20Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 258c2ecf20Sopenharmony_ci * 268c2ecf20Sopenharmony_ci * BSD LICENSE 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. 298c2ecf20Sopenharmony_ci * All rights reserved. 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 328c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 338c2ecf20Sopenharmony_ci * are met: 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * * Redistributions of source code must retain the above copyright 368c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 378c2ecf20Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 388c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 398c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 408c2ecf20Sopenharmony_ci * distribution. 418c2ecf20Sopenharmony_ci * * Neither the name Intel Corporation nor the names of its 428c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived 438c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 448c2ecf20Sopenharmony_ci * 458c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 468c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 478c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 488c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 498c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 508c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 518c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 528c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 538c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 548c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 558c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 568c2ecf20Sopenharmony_ci *****************************************************************************/ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#ifndef __iwl_agn_h__ 598c2ecf20Sopenharmony_ci#define __iwl_agn_h__ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#include "iwl-config.h" 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#include "dev.h" 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* The first 11 queues (0-10) are used otherwise */ 668c2ecf20Sopenharmony_ci#define IWLAGN_FIRST_AMPDU_QUEUE 11 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* AUX (TX during scan dwell) queue */ 698c2ecf20Sopenharmony_ci#define IWL_AUX_QUEUE 10 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define IWL_INVALID_STATION 255 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* device operations */ 748c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_1000_cfg; 758c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_2000_cfg; 768c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_105_cfg; 778c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_2030_cfg; 788c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_5000_cfg; 798c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_5150_cfg; 808c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6000_cfg; 818c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6005_cfg; 828c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6050_cfg; 838c2ecf20Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6030_cfg; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define TIME_UNIT 1024 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/***************************************************** 898c2ecf20Sopenharmony_ci* DRIVER STATUS FUNCTIONS 908c2ecf20Sopenharmony_ci******************************************************/ 918c2ecf20Sopenharmony_ci#define STATUS_RF_KILL_HW 0 928c2ecf20Sopenharmony_ci#define STATUS_CT_KILL 1 938c2ecf20Sopenharmony_ci#define STATUS_ALIVE 2 948c2ecf20Sopenharmony_ci#define STATUS_READY 3 958c2ecf20Sopenharmony_ci#define STATUS_EXIT_PENDING 5 968c2ecf20Sopenharmony_ci#define STATUS_STATISTICS 6 978c2ecf20Sopenharmony_ci#define STATUS_SCANNING 7 988c2ecf20Sopenharmony_ci#define STATUS_SCAN_ABORTING 8 998c2ecf20Sopenharmony_ci#define STATUS_SCAN_HW 9 1008c2ecf20Sopenharmony_ci#define STATUS_FW_ERROR 10 1018c2ecf20Sopenharmony_ci#define STATUS_CHANNEL_SWITCH_PENDING 11 1028c2ecf20Sopenharmony_ci#define STATUS_SCAN_COMPLETE 12 1038c2ecf20Sopenharmony_ci#define STATUS_POWER_PMI 13 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistruct iwl_ucode_capabilities; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ciextern const struct ieee80211_ops iwlagn_hw_ops; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistatic inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) 1108c2ecf20Sopenharmony_ci{ 1118c2ecf20Sopenharmony_ci hdr->op_code = cmd; 1128c2ecf20Sopenharmony_ci hdr->first_group = 0; 1138c2ecf20Sopenharmony_ci hdr->groups_num = 1; 1148c2ecf20Sopenharmony_ci hdr->data_valid = 1; 1158c2ecf20Sopenharmony_ci} 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_civoid iwl_down(struct iwl_priv *priv); 1188c2ecf20Sopenharmony_civoid iwl_cancel_deferred_work(struct iwl_priv *priv); 1198c2ecf20Sopenharmony_civoid iwlagn_prepare_restart(struct iwl_priv *priv); 1208c2ecf20Sopenharmony_civoid iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct napi_struct *napi, 1218c2ecf20Sopenharmony_ci struct iwl_rx_cmd_buffer *rxb); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cibool iwl_check_for_ct_kill(struct iwl_priv *priv); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_civoid iwlagn_lift_passive_no_rx(struct iwl_priv *priv); 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci/* MAC80211 */ 1288c2ecf20Sopenharmony_cistruct ieee80211_hw *iwl_alloc_all(void); 1298c2ecf20Sopenharmony_ciint iwlagn_mac_setup_register(struct iwl_priv *priv, 1308c2ecf20Sopenharmony_ci const struct iwl_ucode_capabilities *capa); 1318c2ecf20Sopenharmony_civoid iwlagn_mac_unregister(struct iwl_priv *priv); 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci/* commands */ 1348c2ecf20Sopenharmony_ciint iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); 1358c2ecf20Sopenharmony_ciint iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id, 1368c2ecf20Sopenharmony_ci u32 flags, u16 len, const void *data); 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* RXON */ 1398c2ecf20Sopenharmony_civoid iwl_connection_init_rx_config(struct iwl_priv *priv, 1408c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 1418c2ecf20Sopenharmony_ciint iwlagn_set_pan_params(struct iwl_priv *priv); 1428c2ecf20Sopenharmony_ciint iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 1438c2ecf20Sopenharmony_civoid iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 1448c2ecf20Sopenharmony_ciint iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed); 1458c2ecf20Sopenharmony_civoid iwlagn_bss_info_changed(struct ieee80211_hw *hw, 1468c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 1478c2ecf20Sopenharmony_ci struct ieee80211_bss_conf *bss_conf, 1488c2ecf20Sopenharmony_ci u32 changes); 1498c2ecf20Sopenharmony_civoid iwlagn_config_ht40(struct ieee80211_conf *conf, 1508c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 1518c2ecf20Sopenharmony_civoid iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf); 1528c2ecf20Sopenharmony_civoid iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, 1538c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 1548c2ecf20Sopenharmony_civoid iwl_set_flags_for_band(struct iwl_priv *priv, 1558c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx, 1568c2ecf20Sopenharmony_ci enum nl80211_band band, 1578c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* uCode */ 1608c2ecf20Sopenharmony_ciint iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); 1618c2ecf20Sopenharmony_civoid iwl_send_prio_tbl(struct iwl_priv *priv); 1628c2ecf20Sopenharmony_ciint iwl_init_alive_start(struct iwl_priv *priv); 1638c2ecf20Sopenharmony_ciint iwl_run_init_ucode(struct iwl_priv *priv); 1648c2ecf20Sopenharmony_ciint iwl_load_ucode_wait_alive(struct iwl_priv *priv, 1658c2ecf20Sopenharmony_ci enum iwl_ucode_type ucode_type); 1668c2ecf20Sopenharmony_ciint iwl_send_calib_results(struct iwl_priv *priv); 1678c2ecf20Sopenharmony_ciint iwl_calib_set(struct iwl_priv *priv, 1688c2ecf20Sopenharmony_ci const struct iwl_calib_hdr *cmd, int len); 1698c2ecf20Sopenharmony_civoid iwl_calib_free_results(struct iwl_priv *priv); 1708c2ecf20Sopenharmony_ciint iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log, 1718c2ecf20Sopenharmony_ci char **buf); 1728c2ecf20Sopenharmony_ciint iwlagn_hw_valid_rtc_data_addr(u32 addr); 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* lib */ 1758c2ecf20Sopenharmony_ciint iwlagn_send_tx_power(struct iwl_priv *priv); 1768c2ecf20Sopenharmony_civoid iwlagn_temperature(struct iwl_priv *priv); 1778c2ecf20Sopenharmony_ciint iwlagn_txfifo_flush(struct iwl_priv *priv, u32 scd_q_msk); 1788c2ecf20Sopenharmony_civoid iwlagn_dev_txfifo_flush(struct iwl_priv *priv); 1798c2ecf20Sopenharmony_ciint iwlagn_send_beacon_cmd(struct iwl_priv *priv); 1808c2ecf20Sopenharmony_ciint iwl_send_statistics_request(struct iwl_priv *priv, 1818c2ecf20Sopenharmony_ci u8 flags, bool clear); 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_cistatic inline const struct ieee80211_supported_band *iwl_get_hw_mode( 1848c2ecf20Sopenharmony_ci struct iwl_priv *priv, enum nl80211_band band) 1858c2ecf20Sopenharmony_ci{ 1868c2ecf20Sopenharmony_ci return priv->hw->wiphy->bands[band]; 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP 1908c2ecf20Sopenharmony_ciint iwlagn_send_patterns(struct iwl_priv *priv, 1918c2ecf20Sopenharmony_ci struct cfg80211_wowlan *wowlan); 1928c2ecf20Sopenharmony_ciint iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan); 1938c2ecf20Sopenharmony_ci#endif 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/* rx */ 1968c2ecf20Sopenharmony_ciint iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum nl80211_band band); 1978c2ecf20Sopenharmony_civoid iwl_setup_rx_handlers(struct iwl_priv *priv); 1988c2ecf20Sopenharmony_civoid iwl_chswitch_done(struct iwl_priv *priv, bool is_success); 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* tx */ 2028c2ecf20Sopenharmony_ciint iwlagn_tx_skb(struct iwl_priv *priv, 2038c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, 2048c2ecf20Sopenharmony_ci struct sk_buff *skb); 2058c2ecf20Sopenharmony_ciint iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, 2068c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u16 tid, u16 *ssn); 2078c2ecf20Sopenharmony_ciint iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif, 2088c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u16 tid, u8 buf_size); 2098c2ecf20Sopenharmony_ciint iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, 2108c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u16 tid); 2118c2ecf20Sopenharmony_ciint iwlagn_tx_agg_flush(struct iwl_priv *priv, struct ieee80211_vif *vif, 2128c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u16 tid); 2138c2ecf20Sopenharmony_civoid iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, 2148c2ecf20Sopenharmony_ci struct iwl_rx_cmd_buffer *rxb); 2158c2ecf20Sopenharmony_civoid iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb); 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_cistatic inline u32 iwl_tx_status_to_mac80211(u32 status) 2188c2ecf20Sopenharmony_ci{ 2198c2ecf20Sopenharmony_ci status &= TX_STATUS_MSK; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci switch (status) { 2228c2ecf20Sopenharmony_ci case TX_STATUS_SUCCESS: 2238c2ecf20Sopenharmony_ci case TX_STATUS_DIRECT_DONE: 2248c2ecf20Sopenharmony_ci return IEEE80211_TX_STAT_ACK; 2258c2ecf20Sopenharmony_ci case TX_STATUS_FAIL_DEST_PS: 2268c2ecf20Sopenharmony_ci case TX_STATUS_FAIL_PASSIVE_NO_RX: 2278c2ecf20Sopenharmony_ci return IEEE80211_TX_STAT_TX_FILTERED; 2288c2ecf20Sopenharmony_ci default: 2298c2ecf20Sopenharmony_ci return 0; 2308c2ecf20Sopenharmony_ci } 2318c2ecf20Sopenharmony_ci} 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cistatic inline bool iwl_is_tx_success(u32 status) 2348c2ecf20Sopenharmony_ci{ 2358c2ecf20Sopenharmony_ci status &= TX_STATUS_MSK; 2368c2ecf20Sopenharmony_ci return (status == TX_STATUS_SUCCESS) || 2378c2ecf20Sopenharmony_ci (status == TX_STATUS_DIRECT_DONE); 2388c2ecf20Sopenharmony_ci} 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ciu8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci/* scan */ 2438c2ecf20Sopenharmony_civoid iwlagn_post_scan(struct iwl_priv *priv); 2448c2ecf20Sopenharmony_ciint iwl_force_rf_reset(struct iwl_priv *priv, bool external); 2458c2ecf20Sopenharmony_civoid iwl_init_scan_params(struct iwl_priv *priv); 2468c2ecf20Sopenharmony_ciint iwl_scan_cancel(struct iwl_priv *priv); 2478c2ecf20Sopenharmony_civoid iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 2488c2ecf20Sopenharmony_civoid iwl_force_scan_end(struct iwl_priv *priv); 2498c2ecf20Sopenharmony_civoid iwl_internal_short_hw_scan(struct iwl_priv *priv); 2508c2ecf20Sopenharmony_civoid iwl_setup_rx_scan_handlers(struct iwl_priv *priv); 2518c2ecf20Sopenharmony_civoid iwl_setup_scan_deferred_work(struct iwl_priv *priv); 2528c2ecf20Sopenharmony_civoid iwl_cancel_scan_deferred_work(struct iwl_priv *priv); 2538c2ecf20Sopenharmony_ciint __must_check iwl_scan_initiate(struct iwl_priv *priv, 2548c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 2558c2ecf20Sopenharmony_ci enum iwl_scan_type scan_type, 2568c2ecf20Sopenharmony_ci enum nl80211_band band); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* For faster active scanning, scan will move to the next channel if fewer than 2598c2ecf20Sopenharmony_ci * PLCP_QUIET_THRESH packets are heard on this channel within 2608c2ecf20Sopenharmony_ci * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell 2618c2ecf20Sopenharmony_ci * time if it's a quiet channel (nothing responded to our probe, and there's 2628c2ecf20Sopenharmony_ci * no other traffic). 2638c2ecf20Sopenharmony_ci * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ 2648c2ecf20Sopenharmony_ci#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ 2658c2ecf20Sopenharmony_ci#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci#define IWL_SCAN_CHECK_WATCHDOG (HZ * 15) 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* bt coex */ 2718c2ecf20Sopenharmony_civoid iwlagn_send_advance_bt_config(struct iwl_priv *priv); 2728c2ecf20Sopenharmony_civoid iwlagn_bt_rx_handler_setup(struct iwl_priv *priv); 2738c2ecf20Sopenharmony_civoid iwlagn_bt_setup_deferred_work(struct iwl_priv *priv); 2748c2ecf20Sopenharmony_civoid iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv); 2758c2ecf20Sopenharmony_civoid iwlagn_bt_coex_rssi_monitor(struct iwl_priv *priv); 2768c2ecf20Sopenharmony_civoid iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena); 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cistatic inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci return priv->lib->bt_params && 2818c2ecf20Sopenharmony_ci priv->lib->bt_params->advanced_bt_coexist; 2828c2ecf20Sopenharmony_ci} 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUG 2858c2ecf20Sopenharmony_ciconst char *iwl_get_tx_fail_reason(u32 status); 2868c2ecf20Sopenharmony_ciconst char *iwl_get_agg_tx_fail_reason(u16 status); 2878c2ecf20Sopenharmony_ci#else 2888c2ecf20Sopenharmony_cistatic inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; } 2898c2ecf20Sopenharmony_cistatic inline const char *iwl_get_agg_tx_fail_reason(u16 status) { return ""; } 2908c2ecf20Sopenharmony_ci#endif 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci/* station management */ 2948c2ecf20Sopenharmony_ciint iwlagn_manage_ibss_station(struct iwl_priv *priv, 2958c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, bool add); 2968c2ecf20Sopenharmony_ci#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ 2978c2ecf20Sopenharmony_ci#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ 2988c2ecf20Sopenharmony_ci#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of 2998c2ecf20Sopenharmony_ci being activated */ 3008c2ecf20Sopenharmony_ci#define IWL_STA_LOCAL BIT(3) /* station state not directed by mac80211; 3018c2ecf20Sopenharmony_ci (this is for the IBSS BSSID stations) */ 3028c2ecf20Sopenharmony_ci#define IWL_STA_BCAST BIT(4) /* this station is the special bcast station */ 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_civoid iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 3068c2ecf20Sopenharmony_civoid iwl_clear_ucode_stations(struct iwl_priv *priv, 3078c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 3088c2ecf20Sopenharmony_civoid iwl_dealloc_bcast_stations(struct iwl_priv *priv); 3098c2ecf20Sopenharmony_ciint iwl_get_free_ucode_key_offset(struct iwl_priv *priv); 3108c2ecf20Sopenharmony_ciint iwl_send_add_sta(struct iwl_priv *priv, 3118c2ecf20Sopenharmony_ci struct iwl_addsta_cmd *sta, u8 flags); 3128c2ecf20Sopenharmony_ciint iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3138c2ecf20Sopenharmony_ci const u8 *addr, bool is_ap, 3148c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u8 *sta_id_r); 3158c2ecf20Sopenharmony_ciint iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, 3168c2ecf20Sopenharmony_ci const u8 *addr); 3178c2ecf20Sopenharmony_civoid iwl_deactivate_station(struct iwl_priv *priv, const u8 sta_id, 3188c2ecf20Sopenharmony_ci const u8 *addr); 3198c2ecf20Sopenharmony_ciu8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3208c2ecf20Sopenharmony_ci const u8 *addr, bool is_ap, struct ieee80211_sta *sta); 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ciint iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3238c2ecf20Sopenharmony_ci struct iwl_link_quality_cmd *lq, u8 flags, bool init); 3248c2ecf20Sopenharmony_civoid iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb); 3258c2ecf20Sopenharmony_ciint iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3268c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cibool iwl_is_ht40_tx_allowed(struct iwl_priv *priv, 3298c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx, 3308c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistatic inline int iwl_sta_id(struct ieee80211_sta *sta) 3338c2ecf20Sopenharmony_ci{ 3348c2ecf20Sopenharmony_ci if (WARN_ON(!sta)) 3358c2ecf20Sopenharmony_ci return IWL_INVALID_STATION; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci return ((struct iwl_station_priv *)sta->drv_priv)->sta_id; 3388c2ecf20Sopenharmony_ci} 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ciint iwlagn_alloc_bcast_station(struct iwl_priv *priv, 3418c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 3428c2ecf20Sopenharmony_ciint iwlagn_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3438c2ecf20Sopenharmony_ci const u8 *addr, u8 *sta_id_r); 3448c2ecf20Sopenharmony_ciint iwl_remove_default_wep_key(struct iwl_priv *priv, 3458c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx, 3468c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 3478c2ecf20Sopenharmony_ciint iwl_set_default_wep_key(struct iwl_priv *priv, 3488c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx, 3498c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 3508c2ecf20Sopenharmony_ciint iwl_restore_default_wep_keys(struct iwl_priv *priv, 3518c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 3528c2ecf20Sopenharmony_ciint iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3538c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key, 3548c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 3558c2ecf20Sopenharmony_ciint iwl_remove_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 3568c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key, 3578c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 3588c2ecf20Sopenharmony_civoid iwl_update_tkip_key(struct iwl_priv *priv, 3598c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 3608c2ecf20Sopenharmony_ci struct ieee80211_key_conf *keyconf, 3618c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); 3628c2ecf20Sopenharmony_ciint iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid); 3638c2ecf20Sopenharmony_ciint iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, 3648c2ecf20Sopenharmony_ci int tid, u16 ssn); 3658c2ecf20Sopenharmony_ciint iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, 3668c2ecf20Sopenharmony_ci int tid); 3678c2ecf20Sopenharmony_civoid iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt); 3688c2ecf20Sopenharmony_ciint iwl_update_bcast_station(struct iwl_priv *priv, 3698c2ecf20Sopenharmony_ci struct iwl_rxon_context *ctx); 3708c2ecf20Sopenharmony_ciint iwl_update_bcast_stations(struct iwl_priv *priv); 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci/* rate */ 3738c2ecf20Sopenharmony_cistatic inline u32 iwl_ant_idx_to_flags(u8 ant_idx) 3748c2ecf20Sopenharmony_ci{ 3758c2ecf20Sopenharmony_ci return BIT(ant_idx) << RATE_MCS_ANT_POS; 3768c2ecf20Sopenharmony_ci} 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_cistatic inline u8 iwl_hw_get_rate(__le32 rate_n_flags) 3798c2ecf20Sopenharmony_ci{ 3808c2ecf20Sopenharmony_ci return le32_to_cpu(rate_n_flags) & RATE_MCS_RATE_MSK; 3818c2ecf20Sopenharmony_ci} 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_cistatic inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) 3848c2ecf20Sopenharmony_ci{ 3858c2ecf20Sopenharmony_ci return cpu_to_le32(flags|(u32)rate); 3868c2ecf20Sopenharmony_ci} 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ciint iwl_alive_start(struct iwl_priv *priv); 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUG 3918c2ecf20Sopenharmony_civoid iwl_print_rx_config_cmd(struct iwl_priv *priv, 3928c2ecf20Sopenharmony_ci enum iwl_rxon_context_id ctxid); 3938c2ecf20Sopenharmony_ci#else 3948c2ecf20Sopenharmony_cistatic inline void iwl_print_rx_config_cmd(struct iwl_priv *priv, 3958c2ecf20Sopenharmony_ci enum iwl_rxon_context_id ctxid) 3968c2ecf20Sopenharmony_ci{ 3978c2ecf20Sopenharmony_ci} 3988c2ecf20Sopenharmony_ci#endif 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci/* status checks */ 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_cistatic inline int iwl_is_ready(struct iwl_priv *priv) 4038c2ecf20Sopenharmony_ci{ 4048c2ecf20Sopenharmony_ci /* The adapter is 'ready' if READY EXIT_PENDING is not set */ 4058c2ecf20Sopenharmony_ci return test_bit(STATUS_READY, &priv->status) && 4068c2ecf20Sopenharmony_ci !test_bit(STATUS_EXIT_PENDING, &priv->status); 4078c2ecf20Sopenharmony_ci} 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_cistatic inline int iwl_is_alive(struct iwl_priv *priv) 4108c2ecf20Sopenharmony_ci{ 4118c2ecf20Sopenharmony_ci return test_bit(STATUS_ALIVE, &priv->status); 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_cistatic inline int iwl_is_rfkill(struct iwl_priv *priv) 4158c2ecf20Sopenharmony_ci{ 4168c2ecf20Sopenharmony_ci return test_bit(STATUS_RF_KILL_HW, &priv->status); 4178c2ecf20Sopenharmony_ci} 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_cistatic inline int iwl_is_ctkill(struct iwl_priv *priv) 4208c2ecf20Sopenharmony_ci{ 4218c2ecf20Sopenharmony_ci return test_bit(STATUS_CT_KILL, &priv->status); 4228c2ecf20Sopenharmony_ci} 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_cistatic inline int iwl_is_ready_rf(struct iwl_priv *priv) 4258c2ecf20Sopenharmony_ci{ 4268c2ecf20Sopenharmony_ci if (iwl_is_rfkill(priv)) 4278c2ecf20Sopenharmony_ci return 0; 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci return iwl_is_ready(priv); 4308c2ecf20Sopenharmony_ci} 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_cistatic inline void iwl_dvm_set_pmi(struct iwl_priv *priv, bool state) 4338c2ecf20Sopenharmony_ci{ 4348c2ecf20Sopenharmony_ci if (state) 4358c2ecf20Sopenharmony_ci set_bit(STATUS_POWER_PMI, &priv->status); 4368c2ecf20Sopenharmony_ci else 4378c2ecf20Sopenharmony_ci clear_bit(STATUS_POWER_PMI, &priv->status); 4388c2ecf20Sopenharmony_ci iwl_trans_set_pmi(priv->trans, state); 4398c2ecf20Sopenharmony_ci} 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUGFS 4428c2ecf20Sopenharmony_civoid iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir); 4438c2ecf20Sopenharmony_ci#else 4448c2ecf20Sopenharmony_cistatic inline void iwl_dbgfs_register(struct iwl_priv *priv, 4458c2ecf20Sopenharmony_ci struct dentry *dbgfs_dir) { } 4468c2ecf20Sopenharmony_ci#endif /* CONFIG_IWLWIFI_DEBUGFS */ 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUG 4498c2ecf20Sopenharmony_ci#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ 4508c2ecf20Sopenharmony_cido { \ 4518c2ecf20Sopenharmony_ci if (!iwl_is_rfkill((m))) \ 4528c2ecf20Sopenharmony_ci IWL_ERR(m, fmt, ##args); \ 4538c2ecf20Sopenharmony_ci else \ 4548c2ecf20Sopenharmony_ci __iwl_err((m)->dev, true, \ 4558c2ecf20Sopenharmony_ci !iwl_have_debug_level(IWL_DL_RADIO), \ 4568c2ecf20Sopenharmony_ci fmt, ##args); \ 4578c2ecf20Sopenharmony_ci} while (0) 4588c2ecf20Sopenharmony_ci#else 4598c2ecf20Sopenharmony_ci#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ 4608c2ecf20Sopenharmony_cido { \ 4618c2ecf20Sopenharmony_ci if (!iwl_is_rfkill((m))) \ 4628c2ecf20Sopenharmony_ci IWL_ERR(m, fmt, ##args); \ 4638c2ecf20Sopenharmony_ci else \ 4648c2ecf20Sopenharmony_ci __iwl_err((m)->dev, true, true, fmt, ##args); \ 4658c2ecf20Sopenharmony_ci} while (0) 4668c2ecf20Sopenharmony_ci#endif /* CONFIG_IWLWIFI_DEBUG */ 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci#endif /* __iwl_agn_h__ */ 469