xref: /openbmc/linux/drivers/net/wireless/intel/iwlwifi/dvm/agn.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
18e99ea8dSJohannes Berg /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
28e99ea8dSJohannes Berg /*
3e5f1cc98SJohannes Berg  * Copyright (C) 2005-2014, 2021 Intel Corporation
48e99ea8dSJohannes Berg  */
5e705c121SKalle Valo #ifndef __iwl_agn_h__
6e705c121SKalle Valo #define __iwl_agn_h__
7e705c121SKalle Valo 
8e705c121SKalle Valo #include "iwl-config.h"
9e705c121SKalle Valo 
10e705c121SKalle Valo #include "dev.h"
11e705c121SKalle Valo 
12e705c121SKalle Valo /* The first 11 queues (0-10) are used otherwise */
13e705c121SKalle Valo #define IWLAGN_FIRST_AMPDU_QUEUE	11
14e705c121SKalle Valo 
15e705c121SKalle Valo /* AUX (TX during scan dwell) queue */
16e705c121SKalle Valo #define IWL_AUX_QUEUE		10
17e705c121SKalle Valo 
18e705c121SKalle Valo #define IWL_INVALID_STATION	255
19e705c121SKalle Valo 
20e705c121SKalle Valo /* device operations */
21e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_1000_cfg;
22e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_2000_cfg;
23e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_105_cfg;
24e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_2030_cfg;
25e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_5000_cfg;
26e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_5150_cfg;
27e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_6000_cfg;
28e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_6005_cfg;
29e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_6050_cfg;
30e705c121SKalle Valo extern const struct iwl_dvm_cfg iwl_dvm_6030_cfg;
31e705c121SKalle Valo 
32e705c121SKalle Valo 
33e705c121SKalle Valo #define TIME_UNIT		1024
34e705c121SKalle Valo 
35e705c121SKalle Valo /*****************************************************
36e705c121SKalle Valo * DRIVER STATUS FUNCTIONS
37e705c121SKalle Valo ******************************************************/
38e705c121SKalle Valo #define STATUS_RF_KILL_HW	0
39e705c121SKalle Valo #define STATUS_CT_KILL		1
40e705c121SKalle Valo #define STATUS_ALIVE		2
41e705c121SKalle Valo #define STATUS_READY		3
42e705c121SKalle Valo #define STATUS_EXIT_PENDING	5
43e705c121SKalle Valo #define STATUS_STATISTICS	6
44e705c121SKalle Valo #define STATUS_SCANNING		7
45e705c121SKalle Valo #define STATUS_SCAN_ABORTING	8
46e705c121SKalle Valo #define STATUS_SCAN_HW		9
47e705c121SKalle Valo #define STATUS_FW_ERROR		10
48e705c121SKalle Valo #define STATUS_CHANNEL_SWITCH_PENDING 11
49e705c121SKalle Valo #define STATUS_SCAN_COMPLETE	12
50e705c121SKalle Valo #define STATUS_POWER_PMI	13
51e705c121SKalle Valo 
52e705c121SKalle Valo struct iwl_ucode_capabilities;
53e705c121SKalle Valo 
54e705c121SKalle Valo extern const struct ieee80211_ops iwlagn_hw_ops;
55e705c121SKalle Valo 
iwl_set_calib_hdr(struct iwl_calib_hdr * hdr,u8 cmd)56e705c121SKalle Valo static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd)
57e705c121SKalle Valo {
58e705c121SKalle Valo 	hdr->op_code = cmd;
59e705c121SKalle Valo 	hdr->first_group = 0;
60e705c121SKalle Valo 	hdr->groups_num = 1;
61e705c121SKalle Valo 	hdr->data_valid = 1;
62e705c121SKalle Valo }
63e705c121SKalle Valo 
64e705c121SKalle Valo void iwl_down(struct iwl_priv *priv);
65e705c121SKalle Valo void iwl_cancel_deferred_work(struct iwl_priv *priv);
66e705c121SKalle Valo void iwlagn_prepare_restart(struct iwl_priv *priv);
67e705c121SKalle Valo void iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct napi_struct *napi,
68e705c121SKalle Valo 		     struct iwl_rx_cmd_buffer *rxb);
69e705c121SKalle Valo 
70e705c121SKalle Valo bool iwl_check_for_ct_kill(struct iwl_priv *priv);
71e705c121SKalle Valo 
72e705c121SKalle Valo void iwlagn_lift_passive_no_rx(struct iwl_priv *priv);
73e705c121SKalle Valo 
74e705c121SKalle Valo /* MAC80211 */
75e705c121SKalle Valo struct ieee80211_hw *iwl_alloc_all(void);
76e705c121SKalle Valo int iwlagn_mac_setup_register(struct iwl_priv *priv,
77e705c121SKalle Valo 			      const struct iwl_ucode_capabilities *capa);
78e705c121SKalle Valo void iwlagn_mac_unregister(struct iwl_priv *priv);
79e705c121SKalle Valo 
80e705c121SKalle Valo /* commands */
81e705c121SKalle Valo int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
82e705c121SKalle Valo int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id,
83e705c121SKalle Valo 			 u32 flags, u16 len, const void *data);
84e705c121SKalle Valo 
85e705c121SKalle Valo /* RXON */
86e705c121SKalle Valo void iwl_connection_init_rx_config(struct iwl_priv *priv,
87e705c121SKalle Valo 				   struct iwl_rxon_context *ctx);
88e705c121SKalle Valo int iwlagn_set_pan_params(struct iwl_priv *priv);
89e705c121SKalle Valo int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
90e705c121SKalle Valo void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
91e705c121SKalle Valo int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed);
92e705c121SKalle Valo void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
93e705c121SKalle Valo 			     struct ieee80211_vif *vif,
94e705c121SKalle Valo 			     struct ieee80211_bss_conf *bss_conf,
957b7090b4SJohannes Berg 			     u64 changes);
96e705c121SKalle Valo void iwlagn_config_ht40(struct ieee80211_conf *conf,
97e705c121SKalle Valo 			struct iwl_rxon_context *ctx);
98e705c121SKalle Valo void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
99e705c121SKalle Valo void iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
100e705c121SKalle Valo 			 struct iwl_rxon_context *ctx);
101e705c121SKalle Valo void iwl_set_flags_for_band(struct iwl_priv *priv,
102e705c121SKalle Valo 			    struct iwl_rxon_context *ctx,
10357fbcce3SJohannes Berg 			    enum nl80211_band band,
104e705c121SKalle Valo 			    struct ieee80211_vif *vif);
105e705c121SKalle Valo 
106e705c121SKalle Valo /* uCode */
107e705c121SKalle Valo int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
108e705c121SKalle Valo void iwl_send_prio_tbl(struct iwl_priv *priv);
109e705c121SKalle Valo int iwl_init_alive_start(struct iwl_priv *priv);
110e705c121SKalle Valo int iwl_run_init_ucode(struct iwl_priv *priv);
111e705c121SKalle Valo int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
112e705c121SKalle Valo 			      enum iwl_ucode_type ucode_type);
113e705c121SKalle Valo int iwl_send_calib_results(struct iwl_priv *priv);
114e705c121SKalle Valo int iwl_calib_set(struct iwl_priv *priv,
115*0d24201fSKees Cook 		  const struct iwl_calib_cmd *cmd, size_t len);
116e705c121SKalle Valo void iwl_calib_free_results(struct iwl_priv *priv);
117e705c121SKalle Valo int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
118e705c121SKalle Valo 			    char **buf);
119e705c121SKalle Valo int iwlagn_hw_valid_rtc_data_addr(u32 addr);
120e705c121SKalle Valo 
121e705c121SKalle Valo /* lib */
122e705c121SKalle Valo int iwlagn_send_tx_power(struct iwl_priv *priv);
123e705c121SKalle Valo void iwlagn_temperature(struct iwl_priv *priv);
124e705c121SKalle Valo int iwlagn_txfifo_flush(struct iwl_priv *priv, u32 scd_q_msk);
125e705c121SKalle Valo void iwlagn_dev_txfifo_flush(struct iwl_priv *priv);
126e705c121SKalle Valo int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
127e705c121SKalle Valo int iwl_send_statistics_request(struct iwl_priv *priv,
128e705c121SKalle Valo 				u8 flags, bool clear);
129e705c121SKalle Valo 
iwl_get_hw_mode(struct iwl_priv * priv,enum nl80211_band band)130e705c121SKalle Valo static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
13157fbcce3SJohannes Berg 			struct iwl_priv *priv, enum nl80211_band band)
132e705c121SKalle Valo {
133e705c121SKalle Valo 	return priv->hw->wiphy->bands[band];
134e705c121SKalle Valo }
135e705c121SKalle Valo 
136e705c121SKalle Valo #ifdef CONFIG_PM_SLEEP
137e705c121SKalle Valo int iwlagn_send_patterns(struct iwl_priv *priv,
138e705c121SKalle Valo 			 struct cfg80211_wowlan *wowlan);
139e705c121SKalle Valo int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan);
140e705c121SKalle Valo #endif
141e705c121SKalle Valo 
142e705c121SKalle Valo /* rx */
14357fbcce3SJohannes Berg int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum nl80211_band band);
144e705c121SKalle Valo void iwl_setup_rx_handlers(struct iwl_priv *priv);
145e705c121SKalle Valo void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
146e705c121SKalle Valo 
147e705c121SKalle Valo 
148e705c121SKalle Valo /* tx */
149e705c121SKalle Valo int iwlagn_tx_skb(struct iwl_priv *priv,
150e705c121SKalle Valo 		  struct ieee80211_sta *sta,
151e705c121SKalle Valo 		  struct sk_buff *skb);
152e705c121SKalle Valo int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
153e705c121SKalle Valo 			struct ieee80211_sta *sta, u16 tid, u16 *ssn);
154e705c121SKalle Valo int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
155e705c121SKalle Valo 			struct ieee80211_sta *sta, u16 tid, u8 buf_size);
156e705c121SKalle Valo int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
157e705c121SKalle Valo 		       struct ieee80211_sta *sta, u16 tid);
158e705c121SKalle Valo int iwlagn_tx_agg_flush(struct iwl_priv *priv, struct ieee80211_vif *vif,
159e705c121SKalle Valo 			struct ieee80211_sta *sta, u16 tid);
160e705c121SKalle Valo void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
161e705c121SKalle Valo 				   struct iwl_rx_cmd_buffer *rxb);
162e705c121SKalle Valo void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb);
163e705c121SKalle Valo 
iwl_tx_status_to_mac80211(u32 status)164e705c121SKalle Valo static inline u32 iwl_tx_status_to_mac80211(u32 status)
165e705c121SKalle Valo {
166e705c121SKalle Valo 	status &= TX_STATUS_MSK;
167e705c121SKalle Valo 
168e705c121SKalle Valo 	switch (status) {
169e705c121SKalle Valo 	case TX_STATUS_SUCCESS:
170e705c121SKalle Valo 	case TX_STATUS_DIRECT_DONE:
171e705c121SKalle Valo 		return IEEE80211_TX_STAT_ACK;
172e705c121SKalle Valo 	case TX_STATUS_FAIL_DEST_PS:
173e705c121SKalle Valo 	case TX_STATUS_FAIL_PASSIVE_NO_RX:
174e705c121SKalle Valo 		return IEEE80211_TX_STAT_TX_FILTERED;
175e705c121SKalle Valo 	default:
176e705c121SKalle Valo 		return 0;
177e705c121SKalle Valo 	}
178e705c121SKalle Valo }
179e705c121SKalle Valo 
iwl_is_tx_success(u32 status)180e705c121SKalle Valo static inline bool iwl_is_tx_success(u32 status)
181e705c121SKalle Valo {
182e705c121SKalle Valo 	status &= TX_STATUS_MSK;
183e705c121SKalle Valo 	return (status == TX_STATUS_SUCCESS) ||
184e705c121SKalle Valo 	       (status == TX_STATUS_DIRECT_DONE);
185e705c121SKalle Valo }
186e705c121SKalle Valo 
187e705c121SKalle Valo u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid);
188e705c121SKalle Valo 
189e705c121SKalle Valo /* scan */
190e705c121SKalle Valo void iwlagn_post_scan(struct iwl_priv *priv);
191e705c121SKalle Valo int iwl_force_rf_reset(struct iwl_priv *priv, bool external);
192e705c121SKalle Valo void iwl_init_scan_params(struct iwl_priv *priv);
193e705c121SKalle Valo int iwl_scan_cancel(struct iwl_priv *priv);
194e705c121SKalle Valo void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
195e705c121SKalle Valo void iwl_force_scan_end(struct iwl_priv *priv);
196e705c121SKalle Valo void iwl_internal_short_hw_scan(struct iwl_priv *priv);
197e705c121SKalle Valo void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
198e705c121SKalle Valo void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
199e705c121SKalle Valo void iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
200e705c121SKalle Valo int __must_check iwl_scan_initiate(struct iwl_priv *priv,
201e705c121SKalle Valo 				   struct ieee80211_vif *vif,
202e705c121SKalle Valo 				   enum iwl_scan_type scan_type,
20357fbcce3SJohannes Berg 				   enum nl80211_band band);
204e705c121SKalle Valo 
205e705c121SKalle Valo /* For faster active scanning, scan will move to the next channel if fewer than
206e705c121SKalle Valo  * PLCP_QUIET_THRESH packets are heard on this channel within
207e705c121SKalle Valo  * ACTIVE_QUIET_TIME after sending probe request.  This shortens the dwell
208e705c121SKalle Valo  * time if it's a quiet channel (nothing responded to our probe, and there's
209e705c121SKalle Valo  * no other traffic).
210e705c121SKalle Valo  * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
211e705c121SKalle Valo #define IWL_ACTIVE_QUIET_TIME       cpu_to_le16(10)  /* msec */
212e705c121SKalle Valo #define IWL_PLCP_QUIET_THRESH       cpu_to_le16(1)  /* packets */
213e705c121SKalle Valo 
214e705c121SKalle Valo #define IWL_SCAN_CHECK_WATCHDOG		(HZ * 15)
215e705c121SKalle Valo 
216e705c121SKalle Valo 
217e705c121SKalle Valo /* bt coex */
218e705c121SKalle Valo void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
219e705c121SKalle Valo void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv);
220e705c121SKalle Valo void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv);
221e705c121SKalle Valo void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv);
222e705c121SKalle Valo void iwlagn_bt_coex_rssi_monitor(struct iwl_priv *priv);
223e705c121SKalle Valo void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena);
224e705c121SKalle Valo 
iwl_advanced_bt_coexist(struct iwl_priv * priv)225e705c121SKalle Valo static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
226e705c121SKalle Valo {
227e705c121SKalle Valo 	return priv->lib->bt_params &&
228e705c121SKalle Valo 	       priv->lib->bt_params->advanced_bt_coexist;
229e705c121SKalle Valo }
230e705c121SKalle Valo 
231e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUG
232e705c121SKalle Valo const char *iwl_get_tx_fail_reason(u32 status);
233e705c121SKalle Valo const char *iwl_get_agg_tx_fail_reason(u16 status);
234e705c121SKalle Valo #else
iwl_get_tx_fail_reason(u32 status)235e705c121SKalle Valo static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
iwl_get_agg_tx_fail_reason(u16 status)236e705c121SKalle Valo static inline const char *iwl_get_agg_tx_fail_reason(u16 status) { return ""; }
237e705c121SKalle Valo #endif
238e705c121SKalle Valo 
239e705c121SKalle Valo 
240e705c121SKalle Valo /* station management */
241e705c121SKalle Valo int iwlagn_manage_ibss_station(struct iwl_priv *priv,
242e705c121SKalle Valo 			       struct ieee80211_vif *vif, bool add);
243e705c121SKalle Valo #define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
244e705c121SKalle Valo #define IWL_STA_UCODE_ACTIVE  BIT(1) /* ucode entry is active */
245e705c121SKalle Valo #define IWL_STA_UCODE_INPROGRESS  BIT(2) /* ucode entry is in process of
246e705c121SKalle Valo 					    being activated */
247e705c121SKalle Valo #define IWL_STA_LOCAL BIT(3) /* station state not directed by mac80211;
248e705c121SKalle Valo 				(this is for the IBSS BSSID stations) */
249e705c121SKalle Valo #define IWL_STA_BCAST BIT(4) /* this station is the special bcast station */
250e705c121SKalle Valo 
251e705c121SKalle Valo 
252e705c121SKalle Valo void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
253e705c121SKalle Valo void iwl_clear_ucode_stations(struct iwl_priv *priv,
254e705c121SKalle Valo 			      struct iwl_rxon_context *ctx);
255e705c121SKalle Valo void iwl_dealloc_bcast_stations(struct iwl_priv *priv);
256e705c121SKalle Valo int iwl_get_free_ucode_key_offset(struct iwl_priv *priv);
257e705c121SKalle Valo int iwl_send_add_sta(struct iwl_priv *priv,
258e705c121SKalle Valo 		     struct iwl_addsta_cmd *sta, u8 flags);
259e705c121SKalle Valo int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
260e705c121SKalle Valo 			   const u8 *addr, bool is_ap,
261e705c121SKalle Valo 			   struct ieee80211_sta *sta, u8 *sta_id_r);
262e705c121SKalle Valo int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
263e705c121SKalle Valo 		       const u8 *addr);
264e705c121SKalle Valo void iwl_deactivate_station(struct iwl_priv *priv, const u8 sta_id,
265e705c121SKalle Valo 			    const u8 *addr);
266e705c121SKalle Valo u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
267e705c121SKalle Valo 		    const u8 *addr, bool is_ap, struct ieee80211_sta *sta);
268e705c121SKalle Valo 
269e705c121SKalle Valo int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
270e705c121SKalle Valo 		    struct iwl_link_quality_cmd *lq, u8 flags, bool init);
271e705c121SKalle Valo void iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb);
272e705c121SKalle Valo int iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
273e705c121SKalle Valo 		      struct ieee80211_sta *sta);
274e705c121SKalle Valo 
275e705c121SKalle Valo bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
276e705c121SKalle Valo 			    struct iwl_rxon_context *ctx,
277e705c121SKalle Valo 			    struct ieee80211_sta *sta);
278e705c121SKalle Valo 
iwl_sta_id(struct ieee80211_sta * sta)279e705c121SKalle Valo static inline int iwl_sta_id(struct ieee80211_sta *sta)
280e705c121SKalle Valo {
281e705c121SKalle Valo 	if (WARN_ON(!sta))
282e705c121SKalle Valo 		return IWL_INVALID_STATION;
283e705c121SKalle Valo 
284e705c121SKalle Valo 	return ((struct iwl_station_priv *)sta->drv_priv)->sta_id;
285e705c121SKalle Valo }
286e705c121SKalle Valo 
287e705c121SKalle Valo int iwlagn_alloc_bcast_station(struct iwl_priv *priv,
288e705c121SKalle Valo 			       struct iwl_rxon_context *ctx);
289e705c121SKalle Valo int iwlagn_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
290e705c121SKalle Valo 			     const u8 *addr, u8 *sta_id_r);
291e705c121SKalle Valo int iwl_remove_default_wep_key(struct iwl_priv *priv,
292e705c121SKalle Valo 			       struct iwl_rxon_context *ctx,
293e705c121SKalle Valo 			       struct ieee80211_key_conf *key);
294e705c121SKalle Valo int iwl_set_default_wep_key(struct iwl_priv *priv,
295e705c121SKalle Valo 			    struct iwl_rxon_context *ctx,
296e705c121SKalle Valo 			    struct ieee80211_key_conf *key);
297e705c121SKalle Valo int iwl_restore_default_wep_keys(struct iwl_priv *priv,
298e705c121SKalle Valo 				 struct iwl_rxon_context *ctx);
299e705c121SKalle Valo int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
300e705c121SKalle Valo 			struct ieee80211_key_conf *key,
301e705c121SKalle Valo 			struct ieee80211_sta *sta);
302e705c121SKalle Valo int iwl_remove_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
303e705c121SKalle Valo 			   struct ieee80211_key_conf *key,
304e705c121SKalle Valo 			   struct ieee80211_sta *sta);
305e705c121SKalle Valo void iwl_update_tkip_key(struct iwl_priv *priv,
306e705c121SKalle Valo 			 struct ieee80211_vif *vif,
307e705c121SKalle Valo 			 struct ieee80211_key_conf *keyconf,
308e705c121SKalle Valo 			 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
309e705c121SKalle Valo int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid);
310e705c121SKalle Valo int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
311e705c121SKalle Valo 			 int tid, u16 ssn);
312e705c121SKalle Valo int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
313e705c121SKalle Valo 			int tid);
314e705c121SKalle Valo void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt);
315e705c121SKalle Valo int iwl_update_bcast_station(struct iwl_priv *priv,
316e705c121SKalle Valo 			     struct iwl_rxon_context *ctx);
317e705c121SKalle Valo int iwl_update_bcast_stations(struct iwl_priv *priv);
318e705c121SKalle Valo 
319e705c121SKalle Valo /* rate */
iwl_ant_idx_to_flags(u8 ant_idx)320e705c121SKalle Valo static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
321e705c121SKalle Valo {
322e705c121SKalle Valo 	return BIT(ant_idx) << RATE_MCS_ANT_POS;
323e705c121SKalle Valo }
324e705c121SKalle Valo 
iwl_hw_get_rate(__le32 rate_n_flags)325e705c121SKalle Valo static inline u8 iwl_hw_get_rate(__le32 rate_n_flags)
326e705c121SKalle Valo {
327e705c121SKalle Valo 	return le32_to_cpu(rate_n_flags) & RATE_MCS_RATE_MSK;
328e705c121SKalle Valo }
329e705c121SKalle Valo 
iwl_hw_set_rate_n_flags(u8 rate,u32 flags)330e705c121SKalle Valo static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
331e705c121SKalle Valo {
332e705c121SKalle Valo 	return cpu_to_le32(flags|(u32)rate);
333e705c121SKalle Valo }
334e705c121SKalle Valo 
335e705c121SKalle Valo int iwl_alive_start(struct iwl_priv *priv);
336e705c121SKalle Valo 
337e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUG
338e705c121SKalle Valo void iwl_print_rx_config_cmd(struct iwl_priv *priv,
339e705c121SKalle Valo 			     enum iwl_rxon_context_id ctxid);
340e705c121SKalle Valo #else
iwl_print_rx_config_cmd(struct iwl_priv * priv,enum iwl_rxon_context_id ctxid)341e705c121SKalle Valo static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
342e705c121SKalle Valo 					   enum iwl_rxon_context_id ctxid)
343e705c121SKalle Valo {
344e705c121SKalle Valo }
345e705c121SKalle Valo #endif
346e705c121SKalle Valo 
347e705c121SKalle Valo /* status checks */
348e705c121SKalle Valo 
iwl_is_ready(struct iwl_priv * priv)349e705c121SKalle Valo static inline int iwl_is_ready(struct iwl_priv *priv)
350e705c121SKalle Valo {
351e705c121SKalle Valo 	/* The adapter is 'ready' if READY EXIT_PENDING is not set */
352e705c121SKalle Valo 	return test_bit(STATUS_READY, &priv->status) &&
353e705c121SKalle Valo 	       !test_bit(STATUS_EXIT_PENDING, &priv->status);
354e705c121SKalle Valo }
355e705c121SKalle Valo 
iwl_is_alive(struct iwl_priv * priv)356e705c121SKalle Valo static inline int iwl_is_alive(struct iwl_priv *priv)
357e705c121SKalle Valo {
358e705c121SKalle Valo 	return test_bit(STATUS_ALIVE, &priv->status);
359e705c121SKalle Valo }
360e705c121SKalle Valo 
iwl_is_rfkill(struct iwl_priv * priv)361e705c121SKalle Valo static inline int iwl_is_rfkill(struct iwl_priv *priv)
362e705c121SKalle Valo {
363e705c121SKalle Valo 	return test_bit(STATUS_RF_KILL_HW, &priv->status);
364e705c121SKalle Valo }
365e705c121SKalle Valo 
iwl_is_ctkill(struct iwl_priv * priv)366e705c121SKalle Valo static inline int iwl_is_ctkill(struct iwl_priv *priv)
367e705c121SKalle Valo {
368e705c121SKalle Valo 	return test_bit(STATUS_CT_KILL, &priv->status);
369e705c121SKalle Valo }
370e705c121SKalle Valo 
iwl_is_ready_rf(struct iwl_priv * priv)371e705c121SKalle Valo static inline int iwl_is_ready_rf(struct iwl_priv *priv)
372e705c121SKalle Valo {
373e705c121SKalle Valo 	if (iwl_is_rfkill(priv))
374e705c121SKalle Valo 		return 0;
375e705c121SKalle Valo 
376e705c121SKalle Valo 	return iwl_is_ready(priv);
377e705c121SKalle Valo }
378e705c121SKalle Valo 
iwl_dvm_set_pmi(struct iwl_priv * priv,bool state)379e705c121SKalle Valo static inline void iwl_dvm_set_pmi(struct iwl_priv *priv, bool state)
380e705c121SKalle Valo {
381e705c121SKalle Valo 	if (state)
382e705c121SKalle Valo 		set_bit(STATUS_POWER_PMI, &priv->status);
383e705c121SKalle Valo 	else
384e705c121SKalle Valo 		clear_bit(STATUS_POWER_PMI, &priv->status);
385e705c121SKalle Valo 	iwl_trans_set_pmi(priv->trans, state);
386e705c121SKalle Valo }
387e705c121SKalle Valo 
388e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUGFS
38984caa1ddSGreg Kroah-Hartman void iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir);
390e705c121SKalle Valo #else
iwl_dbgfs_register(struct iwl_priv * priv,struct dentry * dbgfs_dir)39184caa1ddSGreg Kroah-Hartman static inline void iwl_dbgfs_register(struct iwl_priv *priv,
39284caa1ddSGreg Kroah-Hartman 				      struct dentry *dbgfs_dir) { }
393e705c121SKalle Valo #endif /* CONFIG_IWLWIFI_DEBUGFS */
394e705c121SKalle Valo 
395e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUG
396e705c121SKalle Valo #define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)	\
397e705c121SKalle Valo do {									\
398e705c121SKalle Valo 	if (!iwl_is_rfkill((m)))					\
399e705c121SKalle Valo 		IWL_ERR(m, fmt, ##args);				\
400e705c121SKalle Valo 	else								\
401e5f1cc98SJohannes Berg 		__iwl_err((m)->dev,					\
402e5f1cc98SJohannes Berg 			  iwl_have_debug_level(IWL_DL_RADIO) ?		\
403e5f1cc98SJohannes Berg 				IWL_ERR_MODE_RFKILL :			\
404e5f1cc98SJohannes Berg 				IWL_ERR_MODE_TRACE_ONLY,		\
405e705c121SKalle Valo 			  fmt, ##args);					\
406e705c121SKalle Valo } while (0)
407e705c121SKalle Valo #else
408e705c121SKalle Valo #define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)	\
409e705c121SKalle Valo do {									\
410e705c121SKalle Valo 	if (!iwl_is_rfkill((m)))					\
411e705c121SKalle Valo 		IWL_ERR(m, fmt, ##args);				\
412e705c121SKalle Valo 	else								\
413e5f1cc98SJohannes Berg 		__iwl_err((m)->dev, IWL_ERR_MODE_TRACE_ONLY,		\
414e5f1cc98SJohannes Berg 			  fmt, ##args);					\
415e705c121SKalle Valo } while (0)
416e705c121SKalle Valo #endif				/* CONFIG_IWLWIFI_DEBUG */
417e705c121SKalle Valo 
418e705c121SKalle Valo #endif /* __iwl_agn_h__ */
419