162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2005-2014, 2021 Intel Corporation
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci#ifndef __iwl_agn_h__
662306a36Sopenharmony_ci#define __iwl_agn_h__
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "iwl-config.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include "dev.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/* The first 11 queues (0-10) are used otherwise */
1362306a36Sopenharmony_ci#define IWLAGN_FIRST_AMPDU_QUEUE	11
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/* AUX (TX during scan dwell) queue */
1662306a36Sopenharmony_ci#define IWL_AUX_QUEUE		10
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define IWL_INVALID_STATION	255
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* device operations */
2162306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_1000_cfg;
2262306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_2000_cfg;
2362306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_105_cfg;
2462306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_2030_cfg;
2562306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_5000_cfg;
2662306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_5150_cfg;
2762306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6000_cfg;
2862306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6005_cfg;
2962306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6050_cfg;
3062306a36Sopenharmony_ciextern const struct iwl_dvm_cfg iwl_dvm_6030_cfg;
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define TIME_UNIT		1024
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/*****************************************************
3662306a36Sopenharmony_ci* DRIVER STATUS FUNCTIONS
3762306a36Sopenharmony_ci******************************************************/
3862306a36Sopenharmony_ci#define STATUS_RF_KILL_HW	0
3962306a36Sopenharmony_ci#define STATUS_CT_KILL		1
4062306a36Sopenharmony_ci#define STATUS_ALIVE		2
4162306a36Sopenharmony_ci#define STATUS_READY		3
4262306a36Sopenharmony_ci#define STATUS_EXIT_PENDING	5
4362306a36Sopenharmony_ci#define STATUS_STATISTICS	6
4462306a36Sopenharmony_ci#define STATUS_SCANNING		7
4562306a36Sopenharmony_ci#define STATUS_SCAN_ABORTING	8
4662306a36Sopenharmony_ci#define STATUS_SCAN_HW		9
4762306a36Sopenharmony_ci#define STATUS_FW_ERROR		10
4862306a36Sopenharmony_ci#define STATUS_CHANNEL_SWITCH_PENDING 11
4962306a36Sopenharmony_ci#define STATUS_SCAN_COMPLETE	12
5062306a36Sopenharmony_ci#define STATUS_POWER_PMI	13
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistruct iwl_ucode_capabilities;
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciextern const struct ieee80211_ops iwlagn_hw_ops;
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_cistatic inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd)
5762306a36Sopenharmony_ci{
5862306a36Sopenharmony_ci	hdr->op_code = cmd;
5962306a36Sopenharmony_ci	hdr->first_group = 0;
6062306a36Sopenharmony_ci	hdr->groups_num = 1;
6162306a36Sopenharmony_ci	hdr->data_valid = 1;
6262306a36Sopenharmony_ci}
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_civoid iwl_down(struct iwl_priv *priv);
6562306a36Sopenharmony_civoid iwl_cancel_deferred_work(struct iwl_priv *priv);
6662306a36Sopenharmony_civoid iwlagn_prepare_restart(struct iwl_priv *priv);
6762306a36Sopenharmony_civoid iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct napi_struct *napi,
6862306a36Sopenharmony_ci		     struct iwl_rx_cmd_buffer *rxb);
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cibool iwl_check_for_ct_kill(struct iwl_priv *priv);
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_civoid iwlagn_lift_passive_no_rx(struct iwl_priv *priv);
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/* MAC80211 */
7562306a36Sopenharmony_cistruct ieee80211_hw *iwl_alloc_all(void);
7662306a36Sopenharmony_ciint iwlagn_mac_setup_register(struct iwl_priv *priv,
7762306a36Sopenharmony_ci			      const struct iwl_ucode_capabilities *capa);
7862306a36Sopenharmony_civoid iwlagn_mac_unregister(struct iwl_priv *priv);
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* commands */
8162306a36Sopenharmony_ciint iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
8262306a36Sopenharmony_ciint iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id,
8362306a36Sopenharmony_ci			 u32 flags, u16 len, const void *data);
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci/* RXON */
8662306a36Sopenharmony_civoid iwl_connection_init_rx_config(struct iwl_priv *priv,
8762306a36Sopenharmony_ci				   struct iwl_rxon_context *ctx);
8862306a36Sopenharmony_ciint iwlagn_set_pan_params(struct iwl_priv *priv);
8962306a36Sopenharmony_ciint iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
9062306a36Sopenharmony_civoid iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
9162306a36Sopenharmony_ciint iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed);
9262306a36Sopenharmony_civoid iwlagn_bss_info_changed(struct ieee80211_hw *hw,
9362306a36Sopenharmony_ci			     struct ieee80211_vif *vif,
9462306a36Sopenharmony_ci			     struct ieee80211_bss_conf *bss_conf,
9562306a36Sopenharmony_ci			     u64 changes);
9662306a36Sopenharmony_civoid iwlagn_config_ht40(struct ieee80211_conf *conf,
9762306a36Sopenharmony_ci			struct iwl_rxon_context *ctx);
9862306a36Sopenharmony_civoid iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
9962306a36Sopenharmony_civoid iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
10062306a36Sopenharmony_ci			 struct iwl_rxon_context *ctx);
10162306a36Sopenharmony_civoid iwl_set_flags_for_band(struct iwl_priv *priv,
10262306a36Sopenharmony_ci			    struct iwl_rxon_context *ctx,
10362306a36Sopenharmony_ci			    enum nl80211_band band,
10462306a36Sopenharmony_ci			    struct ieee80211_vif *vif);
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* uCode */
10762306a36Sopenharmony_ciint iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
10862306a36Sopenharmony_civoid iwl_send_prio_tbl(struct iwl_priv *priv);
10962306a36Sopenharmony_ciint iwl_init_alive_start(struct iwl_priv *priv);
11062306a36Sopenharmony_ciint iwl_run_init_ucode(struct iwl_priv *priv);
11162306a36Sopenharmony_ciint iwl_load_ucode_wait_alive(struct iwl_priv *priv,
11262306a36Sopenharmony_ci			      enum iwl_ucode_type ucode_type);
11362306a36Sopenharmony_ciint iwl_send_calib_results(struct iwl_priv *priv);
11462306a36Sopenharmony_ciint iwl_calib_set(struct iwl_priv *priv,
11562306a36Sopenharmony_ci		  const struct iwl_calib_cmd *cmd, size_t len);
11662306a36Sopenharmony_civoid iwl_calib_free_results(struct iwl_priv *priv);
11762306a36Sopenharmony_ciint iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
11862306a36Sopenharmony_ci			    char **buf);
11962306a36Sopenharmony_ciint iwlagn_hw_valid_rtc_data_addr(u32 addr);
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/* lib */
12262306a36Sopenharmony_ciint iwlagn_send_tx_power(struct iwl_priv *priv);
12362306a36Sopenharmony_civoid iwlagn_temperature(struct iwl_priv *priv);
12462306a36Sopenharmony_ciint iwlagn_txfifo_flush(struct iwl_priv *priv, u32 scd_q_msk);
12562306a36Sopenharmony_civoid iwlagn_dev_txfifo_flush(struct iwl_priv *priv);
12662306a36Sopenharmony_ciint iwlagn_send_beacon_cmd(struct iwl_priv *priv);
12762306a36Sopenharmony_ciint iwl_send_statistics_request(struct iwl_priv *priv,
12862306a36Sopenharmony_ci				u8 flags, bool clear);
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_cistatic inline const struct ieee80211_supported_band *iwl_get_hw_mode(
13162306a36Sopenharmony_ci			struct iwl_priv *priv, enum nl80211_band band)
13262306a36Sopenharmony_ci{
13362306a36Sopenharmony_ci	return priv->hw->wiphy->bands[band];
13462306a36Sopenharmony_ci}
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
13762306a36Sopenharmony_ciint iwlagn_send_patterns(struct iwl_priv *priv,
13862306a36Sopenharmony_ci			 struct cfg80211_wowlan *wowlan);
13962306a36Sopenharmony_ciint iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan);
14062306a36Sopenharmony_ci#endif
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci/* rx */
14362306a36Sopenharmony_ciint iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum nl80211_band band);
14462306a36Sopenharmony_civoid iwl_setup_rx_handlers(struct iwl_priv *priv);
14562306a36Sopenharmony_civoid iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci/* tx */
14962306a36Sopenharmony_ciint iwlagn_tx_skb(struct iwl_priv *priv,
15062306a36Sopenharmony_ci		  struct ieee80211_sta *sta,
15162306a36Sopenharmony_ci		  struct sk_buff *skb);
15262306a36Sopenharmony_ciint iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
15362306a36Sopenharmony_ci			struct ieee80211_sta *sta, u16 tid, u16 *ssn);
15462306a36Sopenharmony_ciint iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
15562306a36Sopenharmony_ci			struct ieee80211_sta *sta, u16 tid, u8 buf_size);
15662306a36Sopenharmony_ciint iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
15762306a36Sopenharmony_ci		       struct ieee80211_sta *sta, u16 tid);
15862306a36Sopenharmony_ciint iwlagn_tx_agg_flush(struct iwl_priv *priv, struct ieee80211_vif *vif,
15962306a36Sopenharmony_ci			struct ieee80211_sta *sta, u16 tid);
16062306a36Sopenharmony_civoid iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
16162306a36Sopenharmony_ci				   struct iwl_rx_cmd_buffer *rxb);
16262306a36Sopenharmony_civoid iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb);
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_cistatic inline u32 iwl_tx_status_to_mac80211(u32 status)
16562306a36Sopenharmony_ci{
16662306a36Sopenharmony_ci	status &= TX_STATUS_MSK;
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci	switch (status) {
16962306a36Sopenharmony_ci	case TX_STATUS_SUCCESS:
17062306a36Sopenharmony_ci	case TX_STATUS_DIRECT_DONE:
17162306a36Sopenharmony_ci		return IEEE80211_TX_STAT_ACK;
17262306a36Sopenharmony_ci	case TX_STATUS_FAIL_DEST_PS:
17362306a36Sopenharmony_ci	case TX_STATUS_FAIL_PASSIVE_NO_RX:
17462306a36Sopenharmony_ci		return IEEE80211_TX_STAT_TX_FILTERED;
17562306a36Sopenharmony_ci	default:
17662306a36Sopenharmony_ci		return 0;
17762306a36Sopenharmony_ci	}
17862306a36Sopenharmony_ci}
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_cistatic inline bool iwl_is_tx_success(u32 status)
18162306a36Sopenharmony_ci{
18262306a36Sopenharmony_ci	status &= TX_STATUS_MSK;
18362306a36Sopenharmony_ci	return (status == TX_STATUS_SUCCESS) ||
18462306a36Sopenharmony_ci	       (status == TX_STATUS_DIRECT_DONE);
18562306a36Sopenharmony_ci}
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ciu8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid);
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci/* scan */
19062306a36Sopenharmony_civoid iwlagn_post_scan(struct iwl_priv *priv);
19162306a36Sopenharmony_ciint iwl_force_rf_reset(struct iwl_priv *priv, bool external);
19262306a36Sopenharmony_civoid iwl_init_scan_params(struct iwl_priv *priv);
19362306a36Sopenharmony_ciint iwl_scan_cancel(struct iwl_priv *priv);
19462306a36Sopenharmony_civoid iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
19562306a36Sopenharmony_civoid iwl_force_scan_end(struct iwl_priv *priv);
19662306a36Sopenharmony_civoid iwl_internal_short_hw_scan(struct iwl_priv *priv);
19762306a36Sopenharmony_civoid iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
19862306a36Sopenharmony_civoid iwl_setup_scan_deferred_work(struct iwl_priv *priv);
19962306a36Sopenharmony_civoid iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
20062306a36Sopenharmony_ciint __must_check iwl_scan_initiate(struct iwl_priv *priv,
20162306a36Sopenharmony_ci				   struct ieee80211_vif *vif,
20262306a36Sopenharmony_ci				   enum iwl_scan_type scan_type,
20362306a36Sopenharmony_ci				   enum nl80211_band band);
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci/* For faster active scanning, scan will move to the next channel if fewer than
20662306a36Sopenharmony_ci * PLCP_QUIET_THRESH packets are heard on this channel within
20762306a36Sopenharmony_ci * ACTIVE_QUIET_TIME after sending probe request.  This shortens the dwell
20862306a36Sopenharmony_ci * time if it's a quiet channel (nothing responded to our probe, and there's
20962306a36Sopenharmony_ci * no other traffic).
21062306a36Sopenharmony_ci * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
21162306a36Sopenharmony_ci#define IWL_ACTIVE_QUIET_TIME       cpu_to_le16(10)  /* msec */
21262306a36Sopenharmony_ci#define IWL_PLCP_QUIET_THRESH       cpu_to_le16(1)  /* packets */
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci#define IWL_SCAN_CHECK_WATCHDOG		(HZ * 15)
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ci/* bt coex */
21862306a36Sopenharmony_civoid iwlagn_send_advance_bt_config(struct iwl_priv *priv);
21962306a36Sopenharmony_civoid iwlagn_bt_rx_handler_setup(struct iwl_priv *priv);
22062306a36Sopenharmony_civoid iwlagn_bt_setup_deferred_work(struct iwl_priv *priv);
22162306a36Sopenharmony_civoid iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv);
22262306a36Sopenharmony_civoid iwlagn_bt_coex_rssi_monitor(struct iwl_priv *priv);
22362306a36Sopenharmony_civoid iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena);
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_cistatic inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
22662306a36Sopenharmony_ci{
22762306a36Sopenharmony_ci	return priv->lib->bt_params &&
22862306a36Sopenharmony_ci	       priv->lib->bt_params->advanced_bt_coexist;
22962306a36Sopenharmony_ci}
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUG
23262306a36Sopenharmony_ciconst char *iwl_get_tx_fail_reason(u32 status);
23362306a36Sopenharmony_ciconst char *iwl_get_agg_tx_fail_reason(u16 status);
23462306a36Sopenharmony_ci#else
23562306a36Sopenharmony_cistatic inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
23662306a36Sopenharmony_cistatic inline const char *iwl_get_agg_tx_fail_reason(u16 status) { return ""; }
23762306a36Sopenharmony_ci#endif
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci/* station management */
24162306a36Sopenharmony_ciint iwlagn_manage_ibss_station(struct iwl_priv *priv,
24262306a36Sopenharmony_ci			       struct ieee80211_vif *vif, bool add);
24362306a36Sopenharmony_ci#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
24462306a36Sopenharmony_ci#define IWL_STA_UCODE_ACTIVE  BIT(1) /* ucode entry is active */
24562306a36Sopenharmony_ci#define IWL_STA_UCODE_INPROGRESS  BIT(2) /* ucode entry is in process of
24662306a36Sopenharmony_ci					    being activated */
24762306a36Sopenharmony_ci#define IWL_STA_LOCAL BIT(3) /* station state not directed by mac80211;
24862306a36Sopenharmony_ci				(this is for the IBSS BSSID stations) */
24962306a36Sopenharmony_ci#define IWL_STA_BCAST BIT(4) /* this station is the special bcast station */
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_civoid iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
25362306a36Sopenharmony_civoid iwl_clear_ucode_stations(struct iwl_priv *priv,
25462306a36Sopenharmony_ci			      struct iwl_rxon_context *ctx);
25562306a36Sopenharmony_civoid iwl_dealloc_bcast_stations(struct iwl_priv *priv);
25662306a36Sopenharmony_ciint iwl_get_free_ucode_key_offset(struct iwl_priv *priv);
25762306a36Sopenharmony_ciint iwl_send_add_sta(struct iwl_priv *priv,
25862306a36Sopenharmony_ci		     struct iwl_addsta_cmd *sta, u8 flags);
25962306a36Sopenharmony_ciint iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
26062306a36Sopenharmony_ci			   const u8 *addr, bool is_ap,
26162306a36Sopenharmony_ci			   struct ieee80211_sta *sta, u8 *sta_id_r);
26262306a36Sopenharmony_ciint iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
26362306a36Sopenharmony_ci		       const u8 *addr);
26462306a36Sopenharmony_civoid iwl_deactivate_station(struct iwl_priv *priv, const u8 sta_id,
26562306a36Sopenharmony_ci			    const u8 *addr);
26662306a36Sopenharmony_ciu8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
26762306a36Sopenharmony_ci		    const u8 *addr, bool is_ap, struct ieee80211_sta *sta);
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ciint iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
27062306a36Sopenharmony_ci		    struct iwl_link_quality_cmd *lq, u8 flags, bool init);
27162306a36Sopenharmony_civoid iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb);
27262306a36Sopenharmony_ciint iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
27362306a36Sopenharmony_ci		      struct ieee80211_sta *sta);
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_cibool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
27662306a36Sopenharmony_ci			    struct iwl_rxon_context *ctx,
27762306a36Sopenharmony_ci			    struct ieee80211_sta *sta);
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_cistatic inline int iwl_sta_id(struct ieee80211_sta *sta)
28062306a36Sopenharmony_ci{
28162306a36Sopenharmony_ci	if (WARN_ON(!sta))
28262306a36Sopenharmony_ci		return IWL_INVALID_STATION;
28362306a36Sopenharmony_ci
28462306a36Sopenharmony_ci	return ((struct iwl_station_priv *)sta->drv_priv)->sta_id;
28562306a36Sopenharmony_ci}
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ciint iwlagn_alloc_bcast_station(struct iwl_priv *priv,
28862306a36Sopenharmony_ci			       struct iwl_rxon_context *ctx);
28962306a36Sopenharmony_ciint iwlagn_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
29062306a36Sopenharmony_ci			     const u8 *addr, u8 *sta_id_r);
29162306a36Sopenharmony_ciint iwl_remove_default_wep_key(struct iwl_priv *priv,
29262306a36Sopenharmony_ci			       struct iwl_rxon_context *ctx,
29362306a36Sopenharmony_ci			       struct ieee80211_key_conf *key);
29462306a36Sopenharmony_ciint iwl_set_default_wep_key(struct iwl_priv *priv,
29562306a36Sopenharmony_ci			    struct iwl_rxon_context *ctx,
29662306a36Sopenharmony_ci			    struct ieee80211_key_conf *key);
29762306a36Sopenharmony_ciint iwl_restore_default_wep_keys(struct iwl_priv *priv,
29862306a36Sopenharmony_ci				 struct iwl_rxon_context *ctx);
29962306a36Sopenharmony_ciint iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
30062306a36Sopenharmony_ci			struct ieee80211_key_conf *key,
30162306a36Sopenharmony_ci			struct ieee80211_sta *sta);
30262306a36Sopenharmony_ciint iwl_remove_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
30362306a36Sopenharmony_ci			   struct ieee80211_key_conf *key,
30462306a36Sopenharmony_ci			   struct ieee80211_sta *sta);
30562306a36Sopenharmony_civoid iwl_update_tkip_key(struct iwl_priv *priv,
30662306a36Sopenharmony_ci			 struct ieee80211_vif *vif,
30762306a36Sopenharmony_ci			 struct ieee80211_key_conf *keyconf,
30862306a36Sopenharmony_ci			 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
30962306a36Sopenharmony_ciint iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid);
31062306a36Sopenharmony_ciint iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
31162306a36Sopenharmony_ci			 int tid, u16 ssn);
31262306a36Sopenharmony_ciint iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
31362306a36Sopenharmony_ci			int tid);
31462306a36Sopenharmony_civoid iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt);
31562306a36Sopenharmony_ciint iwl_update_bcast_station(struct iwl_priv *priv,
31662306a36Sopenharmony_ci			     struct iwl_rxon_context *ctx);
31762306a36Sopenharmony_ciint iwl_update_bcast_stations(struct iwl_priv *priv);
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci/* rate */
32062306a36Sopenharmony_cistatic inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
32162306a36Sopenharmony_ci{
32262306a36Sopenharmony_ci	return BIT(ant_idx) << RATE_MCS_ANT_POS;
32362306a36Sopenharmony_ci}
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_cistatic inline u8 iwl_hw_get_rate(__le32 rate_n_flags)
32662306a36Sopenharmony_ci{
32762306a36Sopenharmony_ci	return le32_to_cpu(rate_n_flags) & RATE_MCS_RATE_MSK;
32862306a36Sopenharmony_ci}
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_cistatic inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
33162306a36Sopenharmony_ci{
33262306a36Sopenharmony_ci	return cpu_to_le32(flags|(u32)rate);
33362306a36Sopenharmony_ci}
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ciint iwl_alive_start(struct iwl_priv *priv);
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUG
33862306a36Sopenharmony_civoid iwl_print_rx_config_cmd(struct iwl_priv *priv,
33962306a36Sopenharmony_ci			     enum iwl_rxon_context_id ctxid);
34062306a36Sopenharmony_ci#else
34162306a36Sopenharmony_cistatic inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
34262306a36Sopenharmony_ci					   enum iwl_rxon_context_id ctxid)
34362306a36Sopenharmony_ci{
34462306a36Sopenharmony_ci}
34562306a36Sopenharmony_ci#endif
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_ci/* status checks */
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_cistatic inline int iwl_is_ready(struct iwl_priv *priv)
35062306a36Sopenharmony_ci{
35162306a36Sopenharmony_ci	/* The adapter is 'ready' if READY EXIT_PENDING is not set */
35262306a36Sopenharmony_ci	return test_bit(STATUS_READY, &priv->status) &&
35362306a36Sopenharmony_ci	       !test_bit(STATUS_EXIT_PENDING, &priv->status);
35462306a36Sopenharmony_ci}
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_cistatic inline int iwl_is_alive(struct iwl_priv *priv)
35762306a36Sopenharmony_ci{
35862306a36Sopenharmony_ci	return test_bit(STATUS_ALIVE, &priv->status);
35962306a36Sopenharmony_ci}
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_cistatic inline int iwl_is_rfkill(struct iwl_priv *priv)
36262306a36Sopenharmony_ci{
36362306a36Sopenharmony_ci	return test_bit(STATUS_RF_KILL_HW, &priv->status);
36462306a36Sopenharmony_ci}
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_cistatic inline int iwl_is_ctkill(struct iwl_priv *priv)
36762306a36Sopenharmony_ci{
36862306a36Sopenharmony_ci	return test_bit(STATUS_CT_KILL, &priv->status);
36962306a36Sopenharmony_ci}
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_cistatic inline int iwl_is_ready_rf(struct iwl_priv *priv)
37262306a36Sopenharmony_ci{
37362306a36Sopenharmony_ci	if (iwl_is_rfkill(priv))
37462306a36Sopenharmony_ci		return 0;
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci	return iwl_is_ready(priv);
37762306a36Sopenharmony_ci}
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_cistatic inline void iwl_dvm_set_pmi(struct iwl_priv *priv, bool state)
38062306a36Sopenharmony_ci{
38162306a36Sopenharmony_ci	if (state)
38262306a36Sopenharmony_ci		set_bit(STATUS_POWER_PMI, &priv->status);
38362306a36Sopenharmony_ci	else
38462306a36Sopenharmony_ci		clear_bit(STATUS_POWER_PMI, &priv->status);
38562306a36Sopenharmony_ci	iwl_trans_set_pmi(priv->trans, state);
38662306a36Sopenharmony_ci}
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUGFS
38962306a36Sopenharmony_civoid iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir);
39062306a36Sopenharmony_ci#else
39162306a36Sopenharmony_cistatic inline void iwl_dbgfs_register(struct iwl_priv *priv,
39262306a36Sopenharmony_ci				      struct dentry *dbgfs_dir) { }
39362306a36Sopenharmony_ci#endif /* CONFIG_IWLWIFI_DEBUGFS */
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUG
39662306a36Sopenharmony_ci#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)	\
39762306a36Sopenharmony_cido {									\
39862306a36Sopenharmony_ci	if (!iwl_is_rfkill((m)))					\
39962306a36Sopenharmony_ci		IWL_ERR(m, fmt, ##args);				\
40062306a36Sopenharmony_ci	else								\
40162306a36Sopenharmony_ci		__iwl_err((m)->dev,					\
40262306a36Sopenharmony_ci			  iwl_have_debug_level(IWL_DL_RADIO) ?		\
40362306a36Sopenharmony_ci				IWL_ERR_MODE_RFKILL :			\
40462306a36Sopenharmony_ci				IWL_ERR_MODE_TRACE_ONLY,		\
40562306a36Sopenharmony_ci			  fmt, ##args);					\
40662306a36Sopenharmony_ci} while (0)
40762306a36Sopenharmony_ci#else
40862306a36Sopenharmony_ci#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)	\
40962306a36Sopenharmony_cido {									\
41062306a36Sopenharmony_ci	if (!iwl_is_rfkill((m)))					\
41162306a36Sopenharmony_ci		IWL_ERR(m, fmt, ##args);				\
41262306a36Sopenharmony_ci	else								\
41362306a36Sopenharmony_ci		__iwl_err((m)->dev, IWL_ERR_MODE_TRACE_ONLY,		\
41462306a36Sopenharmony_ci			  fmt, ##args);					\
41562306a36Sopenharmony_ci} while (0)
41662306a36Sopenharmony_ci#endif				/* CONFIG_IWLWIFI_DEBUG */
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci#endif /* __iwl_agn_h__ */
419