14273a380SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2e705c121SKalle Valo /******************************************************************************
3e705c121SKalle Valo *
4e705c121SKalle Valo * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
539bdb17eSSharon Dvir * Copyright(c) 2015 Intel Deutschland GmbH
6f0c86427SJohannes Berg * Copyright(c) 2018, 2020-2021 Intel Corporation
7e705c121SKalle Valo *
8e705c121SKalle Valo * Portions of this file are derived from the ipw3945 project, as well
9e705c121SKalle Valo * as portionhelp of the ieee80211 subsystem header files.
10e705c121SKalle Valo *****************************************************************************/
11e705c121SKalle Valo
12e705c121SKalle Valo #include <linux/etherdevice.h>
13e705c121SKalle Valo #include <linux/slab.h>
14e705c121SKalle Valo #include <linux/sched.h>
15e705c121SKalle Valo #include <net/mac80211.h>
16e705c121SKalle Valo #include <asm/unaligned.h>
1739bdb17eSSharon Dvir
1839bdb17eSSharon Dvir #include "iwl-trans.h"
19e705c121SKalle Valo #include "iwl-io.h"
20e705c121SKalle Valo #include "dev.h"
21e705c121SKalle Valo #include "calib.h"
22e705c121SKalle Valo #include "agn.h"
23e705c121SKalle Valo
24e705c121SKalle Valo /******************************************************************************
25e705c121SKalle Valo *
26e705c121SKalle Valo * Generic RX handler implementations
27e705c121SKalle Valo *
28e705c121SKalle Valo ******************************************************************************/
29e705c121SKalle Valo
iwlagn_rx_reply_error(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)30e705c121SKalle Valo static void iwlagn_rx_reply_error(struct iwl_priv *priv,
31e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
32e705c121SKalle Valo {
33e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
34e705c121SKalle Valo struct iwl_error_resp *err_resp = (void *)pkt->data;
35e705c121SKalle Valo
36e705c121SKalle Valo IWL_ERR(priv, "Error Reply type 0x%08X cmd REPLY_ERROR (0x%02X) "
37e705c121SKalle Valo "seq 0x%04X ser 0x%08X\n",
38e705c121SKalle Valo le32_to_cpu(err_resp->error_type),
39e705c121SKalle Valo err_resp->cmd_id,
40e705c121SKalle Valo le16_to_cpu(err_resp->bad_cmd_seq_num),
41e705c121SKalle Valo le32_to_cpu(err_resp->error_info));
42e705c121SKalle Valo }
43e705c121SKalle Valo
iwlagn_rx_csa(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)44e705c121SKalle Valo static void iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb)
45e705c121SKalle Valo {
46e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
47e705c121SKalle Valo struct iwl_csa_notification *csa = (void *)pkt->data;
48e705c121SKalle Valo /*
49e705c121SKalle Valo * MULTI-FIXME
50e705c121SKalle Valo * See iwlagn_mac_channel_switch.
51e705c121SKalle Valo */
52e705c121SKalle Valo struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
53e705c121SKalle Valo struct iwl_rxon_cmd *rxon = (void *)&ctx->active;
54e705c121SKalle Valo
55e705c121SKalle Valo if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
56e705c121SKalle Valo return;
57e705c121SKalle Valo
58e705c121SKalle Valo if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) {
59e705c121SKalle Valo rxon->channel = csa->channel;
60e705c121SKalle Valo ctx->staging.channel = csa->channel;
61e705c121SKalle Valo IWL_DEBUG_11H(priv, "CSA notif: channel %d\n",
62e705c121SKalle Valo le16_to_cpu(csa->channel));
63e705c121SKalle Valo iwl_chswitch_done(priv, true);
64e705c121SKalle Valo } else {
65e705c121SKalle Valo IWL_ERR(priv, "CSA notif (fail) : channel %d\n",
66e705c121SKalle Valo le16_to_cpu(csa->channel));
67e705c121SKalle Valo iwl_chswitch_done(priv, false);
68e705c121SKalle Valo }
69e705c121SKalle Valo }
70e705c121SKalle Valo
71e705c121SKalle Valo
iwlagn_rx_spectrum_measure_notif(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)72e705c121SKalle Valo static void iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv,
73e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
74e705c121SKalle Valo {
75e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
76e705c121SKalle Valo struct iwl_spectrum_notification *report = (void *)pkt->data;
77e705c121SKalle Valo
78e705c121SKalle Valo if (!report->state) {
79e705c121SKalle Valo IWL_DEBUG_11H(priv,
80e705c121SKalle Valo "Spectrum Measure Notification: Start\n");
81e705c121SKalle Valo return;
82e705c121SKalle Valo }
83e705c121SKalle Valo
84e705c121SKalle Valo memcpy(&priv->measure_report, report, sizeof(*report));
85e705c121SKalle Valo priv->measurement_status |= MEASUREMENT_READY;
86e705c121SKalle Valo }
87e705c121SKalle Valo
iwlagn_rx_pm_sleep_notif(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)88e705c121SKalle Valo static void iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv,
89e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
90e705c121SKalle Valo {
91e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUG
92e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
93e705c121SKalle Valo struct iwl_sleep_notification *sleep = (void *)pkt->data;
94e705c121SKalle Valo IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
95e705c121SKalle Valo sleep->pm_sleep_mode, sleep->pm_wakeup_src);
96e705c121SKalle Valo #endif
97e705c121SKalle Valo }
98e705c121SKalle Valo
iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)99e705c121SKalle Valo static void iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
100e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
101e705c121SKalle Valo {
102e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
103e705c121SKalle Valo u32 __maybe_unused len = iwl_rx_packet_len(pkt);
104e705c121SKalle Valo IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
105e705c121SKalle Valo "notification for PM_DEBUG_STATISTIC_NOTIFIC:\n", len);
106e705c121SKalle Valo iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->data, len);
107e705c121SKalle Valo }
108e705c121SKalle Valo
iwlagn_rx_beacon_notif(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)109e705c121SKalle Valo static void iwlagn_rx_beacon_notif(struct iwl_priv *priv,
110e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
111e705c121SKalle Valo {
112e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
113e705c121SKalle Valo struct iwlagn_beacon_notif *beacon = (void *)pkt->data;
114e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUG
115e705c121SKalle Valo u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status);
116e705c121SKalle Valo u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
117e705c121SKalle Valo
118e705c121SKalle Valo IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d "
119e705c121SKalle Valo "tsf:0x%.8x%.8x rate:%d\n",
120e705c121SKalle Valo status & TX_STATUS_MSK,
121e705c121SKalle Valo beacon->beacon_notify_hdr.failure_frame,
122e705c121SKalle Valo le32_to_cpu(beacon->ibss_mgr_status),
123e705c121SKalle Valo le32_to_cpu(beacon->high_tsf),
124e705c121SKalle Valo le32_to_cpu(beacon->low_tsf), rate);
125e705c121SKalle Valo #endif
126e705c121SKalle Valo
127e705c121SKalle Valo priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);
128e705c121SKalle Valo }
129e705c121SKalle Valo
130108285ecSLee Jones /*
131e705c121SKalle Valo * iwl_good_plcp_health - checks for plcp error.
132e705c121SKalle Valo *
133e705c121SKalle Valo * When the plcp error is exceeding the thresholds, reset the radio
134e705c121SKalle Valo * to improve the throughput.
135e705c121SKalle Valo */
iwlagn_good_plcp_health(struct iwl_priv * priv,struct statistics_rx_phy * cur_ofdm,struct statistics_rx_ht_phy * cur_ofdm_ht,unsigned int msecs)136e705c121SKalle Valo static bool iwlagn_good_plcp_health(struct iwl_priv *priv,
137e705c121SKalle Valo struct statistics_rx_phy *cur_ofdm,
138e705c121SKalle Valo struct statistics_rx_ht_phy *cur_ofdm_ht,
139e705c121SKalle Valo unsigned int msecs)
140e705c121SKalle Valo {
141e705c121SKalle Valo int delta;
142e705c121SKalle Valo int threshold = priv->plcp_delta_threshold;
143e705c121SKalle Valo
144e705c121SKalle Valo if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
145e705c121SKalle Valo IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
146e705c121SKalle Valo return true;
147e705c121SKalle Valo }
148e705c121SKalle Valo
149e705c121SKalle Valo delta = le32_to_cpu(cur_ofdm->plcp_err) -
150e705c121SKalle Valo le32_to_cpu(priv->statistics.rx_ofdm.plcp_err) +
151e705c121SKalle Valo le32_to_cpu(cur_ofdm_ht->plcp_err) -
152e705c121SKalle Valo le32_to_cpu(priv->statistics.rx_ofdm_ht.plcp_err);
153e705c121SKalle Valo
154e705c121SKalle Valo /* Can be negative if firmware reset statistics */
155e705c121SKalle Valo if (delta <= 0)
156e705c121SKalle Valo return true;
157e705c121SKalle Valo
158e705c121SKalle Valo if ((delta * 100 / msecs) > threshold) {
159e705c121SKalle Valo IWL_DEBUG_RADIO(priv,
160e705c121SKalle Valo "plcp health threshold %u delta %d msecs %u\n",
161e705c121SKalle Valo threshold, delta, msecs);
162e705c121SKalle Valo return false;
163e705c121SKalle Valo }
164e705c121SKalle Valo
165e705c121SKalle Valo return true;
166e705c121SKalle Valo }
167e705c121SKalle Valo
iwl_force_rf_reset(struct iwl_priv * priv,bool external)168e705c121SKalle Valo int iwl_force_rf_reset(struct iwl_priv *priv, bool external)
169e705c121SKalle Valo {
170e705c121SKalle Valo struct iwl_rf_reset *rf_reset;
171e705c121SKalle Valo
172e705c121SKalle Valo if (test_bit(STATUS_EXIT_PENDING, &priv->status))
173e705c121SKalle Valo return -EAGAIN;
174e705c121SKalle Valo
175e705c121SKalle Valo if (!iwl_is_any_associated(priv)) {
176e705c121SKalle Valo IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n");
177e705c121SKalle Valo return -ENOLINK;
178e705c121SKalle Valo }
179e705c121SKalle Valo
180e705c121SKalle Valo rf_reset = &priv->rf_reset;
181e705c121SKalle Valo rf_reset->reset_request_count++;
182e705c121SKalle Valo if (!external && rf_reset->last_reset_jiffies &&
183e705c121SKalle Valo time_after(rf_reset->last_reset_jiffies +
184e705c121SKalle Valo IWL_DELAY_NEXT_FORCE_RF_RESET, jiffies)) {
185e705c121SKalle Valo IWL_DEBUG_INFO(priv, "RF reset rejected\n");
186e705c121SKalle Valo rf_reset->reset_reject_count++;
187e705c121SKalle Valo return -EAGAIN;
188e705c121SKalle Valo }
189e705c121SKalle Valo rf_reset->reset_success_count++;
190e705c121SKalle Valo rf_reset->last_reset_jiffies = jiffies;
191e705c121SKalle Valo
192e705c121SKalle Valo /*
193e705c121SKalle Valo * There is no easy and better way to force reset the radio,
194e705c121SKalle Valo * the only known method is switching channel which will force to
195e705c121SKalle Valo * reset and tune the radio.
196e705c121SKalle Valo * Use internal short scan (single channel) operation to should
197e705c121SKalle Valo * achieve this objective.
198e705c121SKalle Valo * Driver should reset the radio when number of consecutive missed
199e705c121SKalle Valo * beacon, or any other uCode error condition detected.
200e705c121SKalle Valo */
201e705c121SKalle Valo IWL_DEBUG_INFO(priv, "perform radio reset.\n");
202e705c121SKalle Valo iwl_internal_short_hw_scan(priv);
203e705c121SKalle Valo return 0;
204e705c121SKalle Valo }
205e705c121SKalle Valo
206e705c121SKalle Valo
iwlagn_recover_from_statistics(struct iwl_priv * priv,struct statistics_rx_phy * cur_ofdm,struct statistics_rx_ht_phy * cur_ofdm_ht,struct statistics_tx * tx,unsigned long stamp)207e705c121SKalle Valo static void iwlagn_recover_from_statistics(struct iwl_priv *priv,
208e705c121SKalle Valo struct statistics_rx_phy *cur_ofdm,
209e705c121SKalle Valo struct statistics_rx_ht_phy *cur_ofdm_ht,
210e705c121SKalle Valo struct statistics_tx *tx,
211e705c121SKalle Valo unsigned long stamp)
212e705c121SKalle Valo {
213e705c121SKalle Valo unsigned int msecs;
214e705c121SKalle Valo
215e705c121SKalle Valo if (test_bit(STATUS_EXIT_PENDING, &priv->status))
216e705c121SKalle Valo return;
217e705c121SKalle Valo
218e705c121SKalle Valo msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies);
219e705c121SKalle Valo
220e705c121SKalle Valo /* Only gather statistics and update time stamp when not associated */
221e705c121SKalle Valo if (!iwl_is_any_associated(priv))
222e705c121SKalle Valo return;
223e705c121SKalle Valo
224e705c121SKalle Valo /* Do not check/recover when do not have enough statistics data */
225e705c121SKalle Valo if (msecs < 99)
226e705c121SKalle Valo return;
227e705c121SKalle Valo
228e705c121SKalle Valo if (!iwlagn_good_plcp_health(priv, cur_ofdm, cur_ofdm_ht, msecs))
229e705c121SKalle Valo iwl_force_rf_reset(priv, false);
230e705c121SKalle Valo }
231e705c121SKalle Valo
232e705c121SKalle Valo /* Calculate noise level, based on measurements during network silence just
233e705c121SKalle Valo * before arriving beacon. This measurement can be done only if we know
234e705c121SKalle Valo * exactly when to expect beacons, therefore only when we're associated. */
iwlagn_rx_calc_noise(struct iwl_priv * priv)235e705c121SKalle Valo static void iwlagn_rx_calc_noise(struct iwl_priv *priv)
236e705c121SKalle Valo {
237e705c121SKalle Valo struct statistics_rx_non_phy *rx_info;
238e705c121SKalle Valo int num_active_rx = 0;
239e705c121SKalle Valo int total_silence = 0;
240e705c121SKalle Valo int bcn_silence_a, bcn_silence_b, bcn_silence_c;
241e705c121SKalle Valo int last_rx_noise;
242e705c121SKalle Valo
243e705c121SKalle Valo rx_info = &priv->statistics.rx_non_phy;
244e705c121SKalle Valo
245e705c121SKalle Valo bcn_silence_a =
246e705c121SKalle Valo le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER;
247e705c121SKalle Valo bcn_silence_b =
248e705c121SKalle Valo le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER;
249e705c121SKalle Valo bcn_silence_c =
250e705c121SKalle Valo le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER;
251e705c121SKalle Valo
252e705c121SKalle Valo if (bcn_silence_a) {
253e705c121SKalle Valo total_silence += bcn_silence_a;
254e705c121SKalle Valo num_active_rx++;
255e705c121SKalle Valo }
256e705c121SKalle Valo if (bcn_silence_b) {
257e705c121SKalle Valo total_silence += bcn_silence_b;
258e705c121SKalle Valo num_active_rx++;
259e705c121SKalle Valo }
260e705c121SKalle Valo if (bcn_silence_c) {
261e705c121SKalle Valo total_silence += bcn_silence_c;
262e705c121SKalle Valo num_active_rx++;
263e705c121SKalle Valo }
264e705c121SKalle Valo
265e705c121SKalle Valo /* Average among active antennas */
266e705c121SKalle Valo if (num_active_rx)
267e705c121SKalle Valo last_rx_noise = (total_silence / num_active_rx) - 107;
268e705c121SKalle Valo else
269e705c121SKalle Valo last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
270e705c121SKalle Valo
271e705c121SKalle Valo IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n",
272e705c121SKalle Valo bcn_silence_a, bcn_silence_b, bcn_silence_c,
273e705c121SKalle Valo last_rx_noise);
274e705c121SKalle Valo }
275e705c121SKalle Valo
276e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUGFS
277e705c121SKalle Valo /*
278e705c121SKalle Valo * based on the assumption of all statistics counter are in DWORD
279e705c121SKalle Valo * FIXME: This function is for debugging, do not deal with
280e705c121SKalle Valo * the case of counters roll-over.
281e705c121SKalle Valo */
accum_stats(__le32 * prev,__le32 * cur,__le32 * delta,__le32 * max_delta,__le32 * accum,int size)282e705c121SKalle Valo static void accum_stats(__le32 *prev, __le32 *cur, __le32 *delta,
283e705c121SKalle Valo __le32 *max_delta, __le32 *accum, int size)
284e705c121SKalle Valo {
285e705c121SKalle Valo int i;
286e705c121SKalle Valo
287e705c121SKalle Valo for (i = 0;
288e705c121SKalle Valo i < size / sizeof(__le32);
289e705c121SKalle Valo i++, prev++, cur++, delta++, max_delta++, accum++) {
290e705c121SKalle Valo if (le32_to_cpu(*cur) > le32_to_cpu(*prev)) {
291e705c121SKalle Valo *delta = cpu_to_le32(
292e705c121SKalle Valo le32_to_cpu(*cur) - le32_to_cpu(*prev));
293e705c121SKalle Valo le32_add_cpu(accum, le32_to_cpu(*delta));
294e705c121SKalle Valo if (le32_to_cpu(*delta) > le32_to_cpu(*max_delta))
295e705c121SKalle Valo *max_delta = *delta;
296e705c121SKalle Valo }
297e705c121SKalle Valo }
298e705c121SKalle Valo }
299e705c121SKalle Valo
300e705c121SKalle Valo static void
iwlagn_accumulative_statistics(struct iwl_priv * priv,struct statistics_general_common * common,struct statistics_rx_non_phy * rx_non_phy,struct statistics_rx_phy * rx_ofdm,struct statistics_rx_ht_phy * rx_ofdm_ht,struct statistics_rx_phy * rx_cck,struct statistics_tx * tx,struct statistics_bt_activity * bt_activity)301e705c121SKalle Valo iwlagn_accumulative_statistics(struct iwl_priv *priv,
302e705c121SKalle Valo struct statistics_general_common *common,
303e705c121SKalle Valo struct statistics_rx_non_phy *rx_non_phy,
304e705c121SKalle Valo struct statistics_rx_phy *rx_ofdm,
305e705c121SKalle Valo struct statistics_rx_ht_phy *rx_ofdm_ht,
306e705c121SKalle Valo struct statistics_rx_phy *rx_cck,
307e705c121SKalle Valo struct statistics_tx *tx,
308e705c121SKalle Valo struct statistics_bt_activity *bt_activity)
309e705c121SKalle Valo {
310e705c121SKalle Valo #define ACCUM(_name) \
311e705c121SKalle Valo accum_stats((__le32 *)&priv->statistics._name, \
312e705c121SKalle Valo (__le32 *)_name, \
313e705c121SKalle Valo (__le32 *)&priv->delta_stats._name, \
314e705c121SKalle Valo (__le32 *)&priv->max_delta_stats._name, \
315e705c121SKalle Valo (__le32 *)&priv->accum_stats._name, \
3162b06127dSTom Rix sizeof(*_name))
317e705c121SKalle Valo
318e705c121SKalle Valo ACCUM(common);
319e705c121SKalle Valo ACCUM(rx_non_phy);
320e705c121SKalle Valo ACCUM(rx_ofdm);
321e705c121SKalle Valo ACCUM(rx_ofdm_ht);
322e705c121SKalle Valo ACCUM(rx_cck);
323e705c121SKalle Valo ACCUM(tx);
324e705c121SKalle Valo if (bt_activity)
325e705c121SKalle Valo ACCUM(bt_activity);
326e705c121SKalle Valo #undef ACCUM
327e705c121SKalle Valo }
328e705c121SKalle Valo #else
329e705c121SKalle Valo static inline void
iwlagn_accumulative_statistics(struct iwl_priv * priv,struct statistics_general_common * common,struct statistics_rx_non_phy * rx_non_phy,struct statistics_rx_phy * rx_ofdm,struct statistics_rx_ht_phy * rx_ofdm_ht,struct statistics_rx_phy * rx_cck,struct statistics_tx * tx,struct statistics_bt_activity * bt_activity)330e705c121SKalle Valo iwlagn_accumulative_statistics(struct iwl_priv *priv,
331e705c121SKalle Valo struct statistics_general_common *common,
332e705c121SKalle Valo struct statistics_rx_non_phy *rx_non_phy,
333e705c121SKalle Valo struct statistics_rx_phy *rx_ofdm,
334e705c121SKalle Valo struct statistics_rx_ht_phy *rx_ofdm_ht,
335e705c121SKalle Valo struct statistics_rx_phy *rx_cck,
336e705c121SKalle Valo struct statistics_tx *tx,
337e705c121SKalle Valo struct statistics_bt_activity *bt_activity)
338e705c121SKalle Valo {
339e705c121SKalle Valo }
340e705c121SKalle Valo #endif
341e705c121SKalle Valo
iwlagn_rx_statistics(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)342e705c121SKalle Valo static void iwlagn_rx_statistics(struct iwl_priv *priv,
343e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
344e705c121SKalle Valo {
345e705c121SKalle Valo unsigned long stamp = jiffies;
346e705c121SKalle Valo const int reg_recalib_period = 60;
347e705c121SKalle Valo int change;
348e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
349e705c121SKalle Valo u32 len = iwl_rx_packet_payload_len(pkt);
350e705c121SKalle Valo __le32 *flag;
351e705c121SKalle Valo struct statistics_general_common *common;
352e705c121SKalle Valo struct statistics_rx_non_phy *rx_non_phy;
353e705c121SKalle Valo struct statistics_rx_phy *rx_ofdm;
354e705c121SKalle Valo struct statistics_rx_ht_phy *rx_ofdm_ht;
355e705c121SKalle Valo struct statistics_rx_phy *rx_cck;
356e705c121SKalle Valo struct statistics_tx *tx;
357e705c121SKalle Valo struct statistics_bt_activity *bt_activity;
358e705c121SKalle Valo
359e705c121SKalle Valo IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n",
360e705c121SKalle Valo len);
361e705c121SKalle Valo
362e705c121SKalle Valo spin_lock(&priv->statistics.lock);
363e705c121SKalle Valo
364e705c121SKalle Valo if (len == sizeof(struct iwl_bt_notif_statistics)) {
365e705c121SKalle Valo struct iwl_bt_notif_statistics *stats;
366e705c121SKalle Valo stats = (void *)&pkt->data;
367e705c121SKalle Valo flag = &stats->flag;
368e705c121SKalle Valo common = &stats->general.common;
369e705c121SKalle Valo rx_non_phy = &stats->rx.general.common;
370e705c121SKalle Valo rx_ofdm = &stats->rx.ofdm;
371e705c121SKalle Valo rx_ofdm_ht = &stats->rx.ofdm_ht;
372e705c121SKalle Valo rx_cck = &stats->rx.cck;
373e705c121SKalle Valo tx = &stats->tx;
374e705c121SKalle Valo bt_activity = &stats->general.activity;
375e705c121SKalle Valo
376e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUGFS
377e705c121SKalle Valo /* handle this exception directly */
378e705c121SKalle Valo priv->statistics.num_bt_kills = stats->rx.general.num_bt_kills;
379e705c121SKalle Valo le32_add_cpu(&priv->statistics.accum_num_bt_kills,
380e705c121SKalle Valo le32_to_cpu(stats->rx.general.num_bt_kills));
381e705c121SKalle Valo #endif
382e705c121SKalle Valo } else if (len == sizeof(struct iwl_notif_statistics)) {
383e705c121SKalle Valo struct iwl_notif_statistics *stats;
384e705c121SKalle Valo stats = (void *)&pkt->data;
385e705c121SKalle Valo flag = &stats->flag;
386e705c121SKalle Valo common = &stats->general.common;
387e705c121SKalle Valo rx_non_phy = &stats->rx.general;
388e705c121SKalle Valo rx_ofdm = &stats->rx.ofdm;
389e705c121SKalle Valo rx_ofdm_ht = &stats->rx.ofdm_ht;
390e705c121SKalle Valo rx_cck = &stats->rx.cck;
391e705c121SKalle Valo tx = &stats->tx;
392e705c121SKalle Valo bt_activity = NULL;
393e705c121SKalle Valo } else {
394e705c121SKalle Valo WARN_ONCE(1, "len %d doesn't match BT (%zu) or normal (%zu)\n",
395e705c121SKalle Valo len, sizeof(struct iwl_bt_notif_statistics),
396e705c121SKalle Valo sizeof(struct iwl_notif_statistics));
397e705c121SKalle Valo spin_unlock(&priv->statistics.lock);
398e705c121SKalle Valo return;
399e705c121SKalle Valo }
400e705c121SKalle Valo
401e705c121SKalle Valo change = common->temperature != priv->statistics.common.temperature ||
402e705c121SKalle Valo (*flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
403e705c121SKalle Valo (priv->statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK);
404e705c121SKalle Valo
405e705c121SKalle Valo iwlagn_accumulative_statistics(priv, common, rx_non_phy, rx_ofdm,
406e705c121SKalle Valo rx_ofdm_ht, rx_cck, tx, bt_activity);
407e705c121SKalle Valo
408e705c121SKalle Valo iwlagn_recover_from_statistics(priv, rx_ofdm, rx_ofdm_ht, tx, stamp);
409e705c121SKalle Valo
410e705c121SKalle Valo priv->statistics.flag = *flag;
411e705c121SKalle Valo memcpy(&priv->statistics.common, common, sizeof(*common));
412e705c121SKalle Valo memcpy(&priv->statistics.rx_non_phy, rx_non_phy, sizeof(*rx_non_phy));
413e705c121SKalle Valo memcpy(&priv->statistics.rx_ofdm, rx_ofdm, sizeof(*rx_ofdm));
414e705c121SKalle Valo memcpy(&priv->statistics.rx_ofdm_ht, rx_ofdm_ht, sizeof(*rx_ofdm_ht));
415e705c121SKalle Valo memcpy(&priv->statistics.rx_cck, rx_cck, sizeof(*rx_cck));
416e705c121SKalle Valo memcpy(&priv->statistics.tx, tx, sizeof(*tx));
417e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUGFS
418e705c121SKalle Valo if (bt_activity)
419e705c121SKalle Valo memcpy(&priv->statistics.bt_activity, bt_activity,
420e705c121SKalle Valo sizeof(*bt_activity));
421e705c121SKalle Valo #endif
422e705c121SKalle Valo
423e705c121SKalle Valo priv->rx_statistics_jiffies = stamp;
424e705c121SKalle Valo
425e705c121SKalle Valo set_bit(STATUS_STATISTICS, &priv->status);
426e705c121SKalle Valo
427e705c121SKalle Valo /* Reschedule the statistics timer to occur in
428e705c121SKalle Valo * reg_recalib_period seconds to ensure we get a
429e705c121SKalle Valo * thermal update even if the uCode doesn't give
430e705c121SKalle Valo * us one */
431e705c121SKalle Valo mod_timer(&priv->statistics_periodic, jiffies +
432e705c121SKalle Valo msecs_to_jiffies(reg_recalib_period * 1000));
433e705c121SKalle Valo
434e705c121SKalle Valo if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) &&
435e705c121SKalle Valo (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) {
436e705c121SKalle Valo iwlagn_rx_calc_noise(priv);
437e705c121SKalle Valo queue_work(priv->workqueue, &priv->run_time_calib_work);
438e705c121SKalle Valo }
439e705c121SKalle Valo if (priv->lib->temperature && change)
440e705c121SKalle Valo priv->lib->temperature(priv);
441e705c121SKalle Valo
442e705c121SKalle Valo spin_unlock(&priv->statistics.lock);
443e705c121SKalle Valo }
444e705c121SKalle Valo
iwlagn_rx_reply_statistics(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)445e705c121SKalle Valo static void iwlagn_rx_reply_statistics(struct iwl_priv *priv,
446e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
447e705c121SKalle Valo {
448e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
449e705c121SKalle Valo struct iwl_notif_statistics *stats = (void *)pkt->data;
450e705c121SKalle Valo
451e705c121SKalle Valo if (le32_to_cpu(stats->flag) & UCODE_STATISTICS_CLEAR_MSK) {
452e705c121SKalle Valo #ifdef CONFIG_IWLWIFI_DEBUGFS
453e705c121SKalle Valo memset(&priv->accum_stats, 0,
454e705c121SKalle Valo sizeof(priv->accum_stats));
455e705c121SKalle Valo memset(&priv->delta_stats, 0,
456e705c121SKalle Valo sizeof(priv->delta_stats));
457e705c121SKalle Valo memset(&priv->max_delta_stats, 0,
458e705c121SKalle Valo sizeof(priv->max_delta_stats));
459e705c121SKalle Valo #endif
460e705c121SKalle Valo IWL_DEBUG_RX(priv, "Statistics have been cleared\n");
461e705c121SKalle Valo }
462e705c121SKalle Valo
463e705c121SKalle Valo iwlagn_rx_statistics(priv, rxb);
464e705c121SKalle Valo }
465e705c121SKalle Valo
466e705c121SKalle Valo /* Handle notification from uCode that card's power state is changing
467e705c121SKalle Valo * due to software, hardware, or critical temperature RFKILL */
iwlagn_rx_card_state_notif(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)468e705c121SKalle Valo static void iwlagn_rx_card_state_notif(struct iwl_priv *priv,
469e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
470e705c121SKalle Valo {
471e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
472e705c121SKalle Valo struct iwl_card_state_notif *card_state_notif = (void *)pkt->data;
473e705c121SKalle Valo u32 flags = le32_to_cpu(card_state_notif->flags);
474e705c121SKalle Valo unsigned long status = priv->status;
475e705c121SKalle Valo
476e705c121SKalle Valo IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",
477e705c121SKalle Valo (flags & HW_CARD_DISABLED) ? "Kill" : "On",
478e705c121SKalle Valo (flags & SW_CARD_DISABLED) ? "Kill" : "On",
479e705c121SKalle Valo (flags & CT_CARD_DISABLED) ?
480e705c121SKalle Valo "Reached" : "Not reached");
481e705c121SKalle Valo
482e705c121SKalle Valo if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |
483e705c121SKalle Valo CT_CARD_DISABLED)) {
484e705c121SKalle Valo
485e705c121SKalle Valo iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_SET,
486e705c121SKalle Valo CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
487e705c121SKalle Valo
488e705c121SKalle Valo iwl_write_direct32(priv->trans, HBUS_TARG_MBX_C,
489e705c121SKalle Valo HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
490e705c121SKalle Valo
491e705c121SKalle Valo if (!(flags & RXON_CARD_DISABLED)) {
492e705c121SKalle Valo iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
493e705c121SKalle Valo CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
494e705c121SKalle Valo iwl_write_direct32(priv->trans, HBUS_TARG_MBX_C,
495e705c121SKalle Valo HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
496e705c121SKalle Valo }
497e705c121SKalle Valo if (flags & CT_CARD_DISABLED)
498e705c121SKalle Valo iwl_tt_enter_ct_kill(priv);
499e705c121SKalle Valo }
500e705c121SKalle Valo if (!(flags & CT_CARD_DISABLED))
501e705c121SKalle Valo iwl_tt_exit_ct_kill(priv);
502e705c121SKalle Valo
503e705c121SKalle Valo if (flags & HW_CARD_DISABLED)
504e705c121SKalle Valo set_bit(STATUS_RF_KILL_HW, &priv->status);
505e705c121SKalle Valo else
506e705c121SKalle Valo clear_bit(STATUS_RF_KILL_HW, &priv->status);
507e705c121SKalle Valo
508e705c121SKalle Valo
509e705c121SKalle Valo if (!(flags & RXON_CARD_DISABLED))
510e705c121SKalle Valo iwl_scan_cancel(priv);
511e705c121SKalle Valo
512e705c121SKalle Valo if ((test_bit(STATUS_RF_KILL_HW, &status) !=
513e705c121SKalle Valo test_bit(STATUS_RF_KILL_HW, &priv->status)))
514e705c121SKalle Valo wiphy_rfkill_set_hw_state(priv->hw->wiphy,
515e705c121SKalle Valo test_bit(STATUS_RF_KILL_HW, &priv->status));
516e705c121SKalle Valo }
517e705c121SKalle Valo
iwlagn_rx_missed_beacon_notif(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)518e705c121SKalle Valo static void iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv,
519e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
520e705c121SKalle Valo
521e705c121SKalle Valo {
522e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
523e705c121SKalle Valo struct iwl_missed_beacon_notif *missed_beacon = (void *)pkt->data;
524e705c121SKalle Valo
525e705c121SKalle Valo if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) >
526e705c121SKalle Valo priv->missed_beacon_threshold) {
527e705c121SKalle Valo IWL_DEBUG_CALIB(priv,
528e705c121SKalle Valo "missed bcn cnsq %d totl %d rcd %d expctd %d\n",
529e705c121SKalle Valo le32_to_cpu(missed_beacon->consecutive_missed_beacons),
530e705c121SKalle Valo le32_to_cpu(missed_beacon->total_missed_becons),
531e705c121SKalle Valo le32_to_cpu(missed_beacon->num_recvd_beacons),
532e705c121SKalle Valo le32_to_cpu(missed_beacon->num_expected_beacons));
533e705c121SKalle Valo if (!test_bit(STATUS_SCANNING, &priv->status))
534e705c121SKalle Valo iwl_init_sensitivity(priv);
535e705c121SKalle Valo }
536e705c121SKalle Valo }
537e705c121SKalle Valo
538e705c121SKalle Valo /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
539e705c121SKalle Valo * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
iwlagn_rx_reply_rx_phy(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)540e705c121SKalle Valo static void iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,
541e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
542e705c121SKalle Valo {
543e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
544e705c121SKalle Valo
545e705c121SKalle Valo priv->last_phy_res_valid = true;
546e705c121SKalle Valo priv->ampdu_ref++;
547e705c121SKalle Valo memcpy(&priv->last_phy_res, pkt->data,
548e705c121SKalle Valo sizeof(struct iwl_rx_phy_res));
549e705c121SKalle Valo }
550e705c121SKalle Valo
551e705c121SKalle Valo /*
552e705c121SKalle Valo * returns non-zero if packet should be dropped
553e705c121SKalle Valo */
iwlagn_set_decrypted_flag(struct iwl_priv * priv,struct ieee80211_hdr * hdr,u32 decrypt_res,struct ieee80211_rx_status * stats)554e705c121SKalle Valo static int iwlagn_set_decrypted_flag(struct iwl_priv *priv,
555e705c121SKalle Valo struct ieee80211_hdr *hdr,
556e705c121SKalle Valo u32 decrypt_res,
557e705c121SKalle Valo struct ieee80211_rx_status *stats)
558e705c121SKalle Valo {
559e705c121SKalle Valo u16 fc = le16_to_cpu(hdr->frame_control);
560e705c121SKalle Valo
561e705c121SKalle Valo /*
562e705c121SKalle Valo * All contexts have the same setting here due to it being
563e705c121SKalle Valo * a module parameter, so OK to check any context.
564e705c121SKalle Valo */
565e705c121SKalle Valo if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags &
566e705c121SKalle Valo RXON_FILTER_DIS_DECRYPT_MSK)
567e705c121SKalle Valo return 0;
568e705c121SKalle Valo
569e705c121SKalle Valo if (!(fc & IEEE80211_FCTL_PROTECTED))
570e705c121SKalle Valo return 0;
571e705c121SKalle Valo
572e705c121SKalle Valo IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res);
573e705c121SKalle Valo switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) {
574e705c121SKalle Valo case RX_RES_STATUS_SEC_TYPE_TKIP:
575e705c121SKalle Valo /* The uCode has got a bad phase 1 Key, pushes the packet.
576e705c121SKalle Valo * Decryption will be done in SW. */
577e705c121SKalle Valo if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
578e705c121SKalle Valo RX_RES_STATUS_BAD_KEY_TTAK)
579e705c121SKalle Valo break;
580ff08b536SGustavo A. R. Silva fallthrough;
581e705c121SKalle Valo case RX_RES_STATUS_SEC_TYPE_WEP:
582e705c121SKalle Valo if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
583e705c121SKalle Valo RX_RES_STATUS_BAD_ICV_MIC) {
584e705c121SKalle Valo /* bad ICV, the packet is destroyed since the
585e705c121SKalle Valo * decryption is inplace, drop it */
586e705c121SKalle Valo IWL_DEBUG_RX(priv, "Packet destroyed\n");
587e705c121SKalle Valo return -1;
588e705c121SKalle Valo }
589ff08b536SGustavo A. R. Silva fallthrough;
590e705c121SKalle Valo case RX_RES_STATUS_SEC_TYPE_CCMP:
591e705c121SKalle Valo if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
592e705c121SKalle Valo RX_RES_STATUS_DECRYPT_OK) {
593e705c121SKalle Valo IWL_DEBUG_RX(priv, "hw decrypt successfully!!!\n");
594e705c121SKalle Valo stats->flag |= RX_FLAG_DECRYPTED;
595e705c121SKalle Valo }
596e705c121SKalle Valo break;
597e705c121SKalle Valo
598e705c121SKalle Valo default:
599e705c121SKalle Valo break;
600e705c121SKalle Valo }
601e705c121SKalle Valo return 0;
602e705c121SKalle Valo }
603e705c121SKalle Valo
iwlagn_pass_packet_to_mac80211(struct iwl_priv * priv,struct ieee80211_hdr * hdr,u16 len,u32 ampdu_status,struct iwl_rx_cmd_buffer * rxb,struct ieee80211_rx_status * stats)604e705c121SKalle Valo static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
605e705c121SKalle Valo struct ieee80211_hdr *hdr,
606e705c121SKalle Valo u16 len,
607e705c121SKalle Valo u32 ampdu_status,
608e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb,
609e705c121SKalle Valo struct ieee80211_rx_status *stats)
610e705c121SKalle Valo {
611e705c121SKalle Valo struct sk_buff *skb;
612e705c121SKalle Valo __le16 fc = hdr->frame_control;
613e705c121SKalle Valo struct iwl_rxon_context *ctx;
614e705c121SKalle Valo unsigned int hdrlen, fraglen;
615e705c121SKalle Valo
616e705c121SKalle Valo /* We only process data packets if the interface is open */
617e705c121SKalle Valo if (unlikely(!priv->is_open)) {
618e705c121SKalle Valo IWL_DEBUG_DROP_LIMIT(priv,
619e705c121SKalle Valo "Dropping packet while interface is not open.\n");
620e705c121SKalle Valo return;
621e705c121SKalle Valo }
622e705c121SKalle Valo
623e705c121SKalle Valo /* In case of HW accelerated crypto and bad decryption, drop */
6243b37f4c9SJohannes Berg if (!iwlwifi_mod_params.swcrypto &&
625e705c121SKalle Valo iwlagn_set_decrypted_flag(priv, hdr, ampdu_status, stats))
626e705c121SKalle Valo return;
627e705c121SKalle Valo
628e705c121SKalle Valo /* Dont use dev_alloc_skb(), we'll have enough headroom once
629e705c121SKalle Valo * ieee80211_hdr pulled.
630e705c121SKalle Valo */
631e705c121SKalle Valo skb = alloc_skb(128, GFP_ATOMIC);
632e705c121SKalle Valo if (!skb) {
633e705c121SKalle Valo IWL_ERR(priv, "alloc_skb failed\n");
634e705c121SKalle Valo return;
635e705c121SKalle Valo }
636e705c121SKalle Valo /* If frame is small enough to fit in skb->head, pull it completely.
637e705c121SKalle Valo * If not, only pull ieee80211_hdr so that splice() or TCP coalesce
638e705c121SKalle Valo * are more efficient.
639e705c121SKalle Valo */
640e705c121SKalle Valo hdrlen = (len <= skb_tailroom(skb)) ? len : sizeof(*hdr);
641e705c121SKalle Valo
64259ae1d12SJohannes Berg skb_put_data(skb, hdr, hdrlen);
643e705c121SKalle Valo fraglen = len - hdrlen;
644e705c121SKalle Valo
645e705c121SKalle Valo if (fraglen) {
646e705c121SKalle Valo int offset = (void *)hdr + hdrlen -
647e705c121SKalle Valo rxb_addr(rxb) + rxb_offset(rxb);
648e705c121SKalle Valo
649e705c121SKalle Valo skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset,
650e705c121SKalle Valo fraglen, rxb->truesize);
651e705c121SKalle Valo }
652e705c121SKalle Valo
653e705c121SKalle Valo /*
654e705c121SKalle Valo * Wake any queues that were stopped due to a passive channel tx
655e705c121SKalle Valo * failure. This can happen because the regulatory enforcement in
656e705c121SKalle Valo * the device waits for a beacon before allowing transmission,
657e705c121SKalle Valo * sometimes even after already having transmitted frames for the
658e705c121SKalle Valo * association because the new RXON may reset the information.
659e705c121SKalle Valo */
660e705c121SKalle Valo if (unlikely(ieee80211_is_beacon(fc) && priv->passive_no_rx)) {
661e705c121SKalle Valo for_each_context(priv, ctx) {
662e705c121SKalle Valo if (!ether_addr_equal(hdr->addr3,
663e705c121SKalle Valo ctx->active.bssid_addr))
664e705c121SKalle Valo continue;
665e705c121SKalle Valo iwlagn_lift_passive_no_rx(priv);
666e705c121SKalle Valo }
667e705c121SKalle Valo }
668e705c121SKalle Valo
669e705c121SKalle Valo memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
670e705c121SKalle Valo
671d63b548fSJohannes Berg ieee80211_rx_napi(priv->hw, NULL, skb, priv->napi);
672e705c121SKalle Valo }
673e705c121SKalle Valo
iwlagn_translate_rx_status(struct iwl_priv * priv,u32 decrypt_in)674e705c121SKalle Valo static u32 iwlagn_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
675e705c121SKalle Valo {
676e705c121SKalle Valo u32 decrypt_out = 0;
677e705c121SKalle Valo
678e705c121SKalle Valo if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) ==
679e705c121SKalle Valo RX_RES_STATUS_STATION_FOUND)
680e705c121SKalle Valo decrypt_out |= (RX_RES_STATUS_STATION_FOUND |
681e705c121SKalle Valo RX_RES_STATUS_NO_STATION_INFO_MISMATCH);
682e705c121SKalle Valo
683e705c121SKalle Valo decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK);
684e705c121SKalle Valo
685e705c121SKalle Valo /* packet was not encrypted */
686e705c121SKalle Valo if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
687e705c121SKalle Valo RX_RES_STATUS_SEC_TYPE_NONE)
688e705c121SKalle Valo return decrypt_out;
689e705c121SKalle Valo
690e705c121SKalle Valo /* packet was encrypted with unknown alg */
691e705c121SKalle Valo if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
692e705c121SKalle Valo RX_RES_STATUS_SEC_TYPE_ERR)
693e705c121SKalle Valo return decrypt_out;
694e705c121SKalle Valo
695e705c121SKalle Valo /* decryption was not done in HW */
696e705c121SKalle Valo if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) !=
697e705c121SKalle Valo RX_MPDU_RES_STATUS_DEC_DONE_MSK)
698e705c121SKalle Valo return decrypt_out;
699e705c121SKalle Valo
700e705c121SKalle Valo switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {
701e705c121SKalle Valo
702e705c121SKalle Valo case RX_RES_STATUS_SEC_TYPE_CCMP:
703e705c121SKalle Valo /* alg is CCM: check MIC only */
704e705c121SKalle Valo if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK))
705e705c121SKalle Valo /* Bad MIC */
706e705c121SKalle Valo decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
707e705c121SKalle Valo else
708e705c121SKalle Valo decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
709e705c121SKalle Valo
710e705c121SKalle Valo break;
711e705c121SKalle Valo
712e705c121SKalle Valo case RX_RES_STATUS_SEC_TYPE_TKIP:
713e705c121SKalle Valo if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) {
714e705c121SKalle Valo /* Bad TTAK */
715e705c121SKalle Valo decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;
716e705c121SKalle Valo break;
717e705c121SKalle Valo }
718ff08b536SGustavo A. R. Silva fallthrough;
719e705c121SKalle Valo default:
720e705c121SKalle Valo if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))
721e705c121SKalle Valo decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
722e705c121SKalle Valo else
723e705c121SKalle Valo decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
724e705c121SKalle Valo break;
725e705c121SKalle Valo }
726e705c121SKalle Valo
727e705c121SKalle Valo IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n",
728e705c121SKalle Valo decrypt_in, decrypt_out);
729e705c121SKalle Valo
730e705c121SKalle Valo return decrypt_out;
731e705c121SKalle Valo }
732e705c121SKalle Valo
733e705c121SKalle Valo /* Calc max signal level (dBm) among 3 possible receivers */
iwlagn_calc_rssi(struct iwl_priv * priv,struct iwl_rx_phy_res * rx_resp)734e705c121SKalle Valo static int iwlagn_calc_rssi(struct iwl_priv *priv,
735e705c121SKalle Valo struct iwl_rx_phy_res *rx_resp)
736e705c121SKalle Valo {
737e705c121SKalle Valo /* data from PHY/DSP regarding signal strength, etc.,
738e705c121SKalle Valo * contents are always there, not configurable by host
739e705c121SKalle Valo */
740e705c121SKalle Valo struct iwlagn_non_cfg_phy *ncphy =
741e705c121SKalle Valo (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
742e705c121SKalle Valo u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
743e705c121SKalle Valo u8 agc;
744e705c121SKalle Valo
745e705c121SKalle Valo val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]);
746e705c121SKalle Valo agc = (val & IWLAGN_OFDM_AGC_MSK) >> IWLAGN_OFDM_AGC_BIT_POS;
747e705c121SKalle Valo
748e705c121SKalle Valo /* Find max rssi among 3 possible receivers.
749e705c121SKalle Valo * These values are measured by the digital signal processor (DSP).
750e705c121SKalle Valo * They should stay fairly constant even as the signal strength varies,
751e705c121SKalle Valo * if the radio's automatic gain control (AGC) is working right.
752e705c121SKalle Valo * AGC value (see below) will provide the "interesting" info.
753e705c121SKalle Valo */
754e705c121SKalle Valo val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]);
755e705c121SKalle Valo rssi_a = (val & IWLAGN_OFDM_RSSI_INBAND_A_BITMSK) >>
756e705c121SKalle Valo IWLAGN_OFDM_RSSI_A_BIT_POS;
757e705c121SKalle Valo rssi_b = (val & IWLAGN_OFDM_RSSI_INBAND_B_BITMSK) >>
758e705c121SKalle Valo IWLAGN_OFDM_RSSI_B_BIT_POS;
759e705c121SKalle Valo val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]);
760e705c121SKalle Valo rssi_c = (val & IWLAGN_OFDM_RSSI_INBAND_C_BITMSK) >>
761e705c121SKalle Valo IWLAGN_OFDM_RSSI_C_BIT_POS;
762e705c121SKalle Valo
763e705c121SKalle Valo max_rssi = max_t(u32, rssi_a, rssi_b);
764e705c121SKalle Valo max_rssi = max_t(u32, max_rssi, rssi_c);
765e705c121SKalle Valo
766e705c121SKalle Valo IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
767e705c121SKalle Valo rssi_a, rssi_b, rssi_c, max_rssi, agc);
768e705c121SKalle Valo
769e705c121SKalle Valo /* dBm = max_rssi dB - agc dB - constant.
770e705c121SKalle Valo * Higher AGC (higher radio gain) means lower signal. */
771e705c121SKalle Valo return max_rssi - agc - IWLAGN_RSSI_OFFSET;
772e705c121SKalle Valo }
773e705c121SKalle Valo
774e705c121SKalle Valo /* Called for REPLY_RX_MPDU_CMD */
iwlagn_rx_reply_rx(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)775e705c121SKalle Valo static void iwlagn_rx_reply_rx(struct iwl_priv *priv,
776e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
777e705c121SKalle Valo {
778e705c121SKalle Valo struct ieee80211_hdr *header;
779e705c121SKalle Valo struct ieee80211_rx_status rx_status = {};
780e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
781e705c121SKalle Valo struct iwl_rx_phy_res *phy_res;
782e705c121SKalle Valo __le32 rx_pkt_status;
783e705c121SKalle Valo struct iwl_rx_mpdu_res_start *amsdu;
784efc0ec5aSJohannes Berg u32 len, pkt_len = iwl_rx_packet_len(pkt);
785e705c121SKalle Valo u32 ampdu_status;
786e705c121SKalle Valo u32 rate_n_flags;
787e705c121SKalle Valo
788e705c121SKalle Valo if (!priv->last_phy_res_valid) {
789e705c121SKalle Valo IWL_ERR(priv, "MPDU frame without cached PHY data\n");
790e705c121SKalle Valo return;
791e705c121SKalle Valo }
792b8aba27cSJohannes Berg
793b8aba27cSJohannes Berg if (unlikely(pkt_len < sizeof(*amsdu))) {
794b8aba27cSJohannes Berg IWL_DEBUG_DROP(priv, "Bad REPLY_RX_MPDU_CMD size\n");
795b8aba27cSJohannes Berg return;
796b8aba27cSJohannes Berg }
797b8aba27cSJohannes Berg
798e705c121SKalle Valo phy_res = &priv->last_phy_res;
799e705c121SKalle Valo amsdu = (struct iwl_rx_mpdu_res_start *)pkt->data;
800e705c121SKalle Valo header = (struct ieee80211_hdr *)(pkt->data + sizeof(*amsdu));
801e705c121SKalle Valo len = le16_to_cpu(amsdu->byte_count);
802efc0ec5aSJohannes Berg
803efc0ec5aSJohannes Berg if (unlikely(len + sizeof(*amsdu) + sizeof(__le32) > pkt_len)) {
804efc0ec5aSJohannes Berg IWL_DEBUG_DROP(priv, "FW lied about packet len\n");
805efc0ec5aSJohannes Berg return;
806efc0ec5aSJohannes Berg }
807efc0ec5aSJohannes Berg
808e705c121SKalle Valo rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*amsdu) + len);
809e705c121SKalle Valo ampdu_status = iwlagn_translate_rx_status(priv,
810e705c121SKalle Valo le32_to_cpu(rx_pkt_status));
811e705c121SKalle Valo
812e705c121SKalle Valo if ((unlikely(phy_res->cfg_phy_cnt > 20))) {
813e705c121SKalle Valo IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d\n",
814e705c121SKalle Valo phy_res->cfg_phy_cnt);
815e705c121SKalle Valo return;
816e705c121SKalle Valo }
817e705c121SKalle Valo
818e705c121SKalle Valo if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) ||
819e705c121SKalle Valo !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
820e705c121SKalle Valo IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n",
821e705c121SKalle Valo le32_to_cpu(rx_pkt_status));
822e705c121SKalle Valo return;
823e705c121SKalle Valo }
824e705c121SKalle Valo
825e705c121SKalle Valo /* This will be used in several places later */
826e705c121SKalle Valo rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);
827e705c121SKalle Valo
828e705c121SKalle Valo /* rx_status carries information about the packet to mac80211 */
829e705c121SKalle Valo rx_status.mactime = le64_to_cpu(phy_res->timestamp);
830e705c121SKalle Valo rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
83157fbcce3SJohannes Berg NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
832e705c121SKalle Valo rx_status.freq =
833e705c121SKalle Valo ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),
834e705c121SKalle Valo rx_status.band);
835e705c121SKalle Valo rx_status.rate_idx =
836e705c121SKalle Valo iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);
837e705c121SKalle Valo rx_status.flag = 0;
838e705c121SKalle Valo
839e705c121SKalle Valo /* TSF isn't reliable. In order to allow smooth user experience,
840e705c121SKalle Valo * this W/A doesn't propagate it to the mac80211 */
841e705c121SKalle Valo /*rx_status.flag |= RX_FLAG_MACTIME_START;*/
842e705c121SKalle Valo
843e705c121SKalle Valo priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);
844e705c121SKalle Valo
845e705c121SKalle Valo /* Find max signal strength (dBm) among 3 antenna/receiver chains */
846e705c121SKalle Valo rx_status.signal = iwlagn_calc_rssi(priv, phy_res);
847e705c121SKalle Valo
848e705c121SKalle Valo IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",
849e705c121SKalle Valo rx_status.signal, (unsigned long long)rx_status.mactime);
850e705c121SKalle Valo
851e705c121SKalle Valo /*
852e705c121SKalle Valo * "antenna number"
853e705c121SKalle Valo *
854e705c121SKalle Valo * It seems that the antenna field in the phy flags value
855e705c121SKalle Valo * is actually a bit field. This is undefined by radiotap,
856e705c121SKalle Valo * it wants an actual antenna number but I always get "7"
857e705c121SKalle Valo * for most legacy frames I receive indicating that the
858e705c121SKalle Valo * same frame was received on all three RX chains.
859e705c121SKalle Valo *
860e705c121SKalle Valo * I think this field should be removed in favor of a
861e705c121SKalle Valo * new 802.11n radiotap field "RX chains" that is defined
862e705c121SKalle Valo * as a bitmask.
863e705c121SKalle Valo */
864e705c121SKalle Valo rx_status.antenna =
865e705c121SKalle Valo (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK)
866e705c121SKalle Valo >> RX_RES_PHY_FLAGS_ANTENNA_POS;
867e705c121SKalle Valo
868e705c121SKalle Valo /* set the preamble flag if appropriate */
869e705c121SKalle Valo if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
8707fdd69c5SJohannes Berg rx_status.enc_flags |= RX_ENC_FLAG_SHORTPRE;
871e705c121SKalle Valo
872e705c121SKalle Valo if (phy_res->phy_flags & RX_RES_PHY_FLAGS_AGG_MSK) {
873e705c121SKalle Valo /*
874e705c121SKalle Valo * We know which subframes of an A-MPDU belong
875e705c121SKalle Valo * together since we get a single PHY response
876e705c121SKalle Valo * from the firmware for all of them
877e705c121SKalle Valo */
878e705c121SKalle Valo rx_status.flag |= RX_FLAG_AMPDU_DETAILS;
879e705c121SKalle Valo rx_status.ampdu_reference = priv->ampdu_ref;
880e705c121SKalle Valo }
881e705c121SKalle Valo
882e705c121SKalle Valo /* Set up the HT phy flags */
883e705c121SKalle Valo if (rate_n_flags & RATE_MCS_HT_MSK)
884da6a4352SJohannes Berg rx_status.encoding = RX_ENC_HT;
885e705c121SKalle Valo if (rate_n_flags & RATE_MCS_HT40_MSK)
8862f242bf4SJohannes Berg rx_status.bw = RATE_INFO_BW_40;
8872f242bf4SJohannes Berg else
8882f242bf4SJohannes Berg rx_status.bw = RATE_INFO_BW_20;
889e705c121SKalle Valo if (rate_n_flags & RATE_MCS_SGI_MSK)
8907fdd69c5SJohannes Berg rx_status.enc_flags |= RX_ENC_FLAG_SHORT_GI;
891e705c121SKalle Valo if (rate_n_flags & RATE_MCS_GF_MSK)
8927fdd69c5SJohannes Berg rx_status.enc_flags |= RX_ENC_FLAG_HT_GF;
893e705c121SKalle Valo
894e705c121SKalle Valo iwlagn_pass_packet_to_mac80211(priv, header, len, ampdu_status,
895e705c121SKalle Valo rxb, &rx_status);
896e705c121SKalle Valo }
897e705c121SKalle Valo
iwlagn_rx_noa_notification(struct iwl_priv * priv,struct iwl_rx_cmd_buffer * rxb)898e705c121SKalle Valo static void iwlagn_rx_noa_notification(struct iwl_priv *priv,
899e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
900e705c121SKalle Valo {
901e705c121SKalle Valo struct iwl_wipan_noa_data *new_data, *old_data;
902e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
903e705c121SKalle Valo struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->data;
904e705c121SKalle Valo
905e705c121SKalle Valo /* no condition -- we're in softirq */
906e705c121SKalle Valo old_data = rcu_dereference_protected(priv->noa_data, true);
907e705c121SKalle Valo
908e705c121SKalle Valo if (noa_notif->noa_active) {
909e705c121SKalle Valo u32 len = le16_to_cpu(noa_notif->noa_attribute.length);
910e705c121SKalle Valo u32 copylen = len;
911e705c121SKalle Valo
912e705c121SKalle Valo /* EID, len, OUI, subtype */
913e705c121SKalle Valo len += 1 + 1 + 3 + 1;
914e705c121SKalle Valo /* P2P id, P2P length */
915e705c121SKalle Valo len += 1 + 2;
916e705c121SKalle Valo copylen += 1 + 2;
917e705c121SKalle Valo
918*c7d0abfdSMinghao Chi (CGEL ZTE) new_data = kmalloc(struct_size(new_data, data, len), GFP_ATOMIC);
919e705c121SKalle Valo if (new_data) {
920e705c121SKalle Valo new_data->length = len;
921e705c121SKalle Valo new_data->data[0] = WLAN_EID_VENDOR_SPECIFIC;
922e705c121SKalle Valo new_data->data[1] = len - 2; /* not counting EID, len */
923e705c121SKalle Valo new_data->data[2] = (WLAN_OUI_WFA >> 16) & 0xff;
924e705c121SKalle Valo new_data->data[3] = (WLAN_OUI_WFA >> 8) & 0xff;
925e705c121SKalle Valo new_data->data[4] = (WLAN_OUI_WFA >> 0) & 0xff;
926e705c121SKalle Valo new_data->data[5] = WLAN_OUI_TYPE_WFA_P2P;
927e705c121SKalle Valo memcpy(&new_data->data[6], &noa_notif->noa_attribute,
928e705c121SKalle Valo copylen);
929e705c121SKalle Valo }
930e705c121SKalle Valo } else
931e705c121SKalle Valo new_data = NULL;
932e705c121SKalle Valo
933e705c121SKalle Valo rcu_assign_pointer(priv->noa_data, new_data);
934e705c121SKalle Valo
935e705c121SKalle Valo if (old_data)
936e705c121SKalle Valo kfree_rcu(old_data, rcu_head);
937e705c121SKalle Valo }
938e705c121SKalle Valo
939108285ecSLee Jones /*
940e705c121SKalle Valo * iwl_setup_rx_handlers - Initialize Rx handler callbacks
941e705c121SKalle Valo *
942e705c121SKalle Valo * Setup the RX handlers for each of the reply types sent from the uCode
943e705c121SKalle Valo * to the host.
944e705c121SKalle Valo */
iwl_setup_rx_handlers(struct iwl_priv * priv)945e705c121SKalle Valo void iwl_setup_rx_handlers(struct iwl_priv *priv)
946e705c121SKalle Valo {
947e705c121SKalle Valo void (**handlers)(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb);
948e705c121SKalle Valo
949e705c121SKalle Valo handlers = priv->rx_handlers;
950e705c121SKalle Valo
951e705c121SKalle Valo handlers[REPLY_ERROR] = iwlagn_rx_reply_error;
952e705c121SKalle Valo handlers[CHANNEL_SWITCH_NOTIFICATION] = iwlagn_rx_csa;
953e705c121SKalle Valo handlers[SPECTRUM_MEASURE_NOTIFICATION] =
954e705c121SKalle Valo iwlagn_rx_spectrum_measure_notif;
955e705c121SKalle Valo handlers[PM_SLEEP_NOTIFICATION] = iwlagn_rx_pm_sleep_notif;
956e705c121SKalle Valo handlers[PM_DEBUG_STATISTIC_NOTIFIC] =
957e705c121SKalle Valo iwlagn_rx_pm_debug_statistics_notif;
958e705c121SKalle Valo handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif;
959e705c121SKalle Valo handlers[REPLY_ADD_STA] = iwl_add_sta_callback;
960e705c121SKalle Valo
961e705c121SKalle Valo handlers[REPLY_WIPAN_NOA_NOTIFICATION] = iwlagn_rx_noa_notification;
962e705c121SKalle Valo
963e705c121SKalle Valo /*
964e705c121SKalle Valo * The same handler is used for both the REPLY to a discrete
965e705c121SKalle Valo * statistics request from the host as well as for the periodic
966e705c121SKalle Valo * statistics notifications (after received beacons) from the uCode.
967e705c121SKalle Valo */
968e705c121SKalle Valo handlers[REPLY_STATISTICS_CMD] = iwlagn_rx_reply_statistics;
969e705c121SKalle Valo handlers[STATISTICS_NOTIFICATION] = iwlagn_rx_statistics;
970e705c121SKalle Valo
971e705c121SKalle Valo iwl_setup_rx_scan_handlers(priv);
972e705c121SKalle Valo
973e705c121SKalle Valo handlers[CARD_STATE_NOTIFICATION] = iwlagn_rx_card_state_notif;
974e705c121SKalle Valo handlers[MISSED_BEACONS_NOTIFICATION] =
975e705c121SKalle Valo iwlagn_rx_missed_beacon_notif;
976e705c121SKalle Valo
977e705c121SKalle Valo /* Rx handlers */
978e705c121SKalle Valo handlers[REPLY_RX_PHY_CMD] = iwlagn_rx_reply_rx_phy;
979e705c121SKalle Valo handlers[REPLY_RX_MPDU_CMD] = iwlagn_rx_reply_rx;
980e705c121SKalle Valo
981e705c121SKalle Valo /* block ack */
982e705c121SKalle Valo handlers[REPLY_COMPRESSED_BA] =
983e705c121SKalle Valo iwlagn_rx_reply_compressed_ba;
984e705c121SKalle Valo
985e705c121SKalle Valo priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx;
986e705c121SKalle Valo
987e705c121SKalle Valo /* set up notification wait support */
988e705c121SKalle Valo iwl_notification_wait_init(&priv->notif_wait);
989e705c121SKalle Valo
990e705c121SKalle Valo /* Set up BT Rx handlers */
991e705c121SKalle Valo if (priv->lib->bt_params)
992e705c121SKalle Valo iwlagn_bt_rx_handler_setup(priv);
993e705c121SKalle Valo }
994e705c121SKalle Valo
iwl_rx_dispatch(struct iwl_op_mode * op_mode,struct napi_struct * napi,struct iwl_rx_cmd_buffer * rxb)995e705c121SKalle Valo void iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct napi_struct *napi,
996e705c121SKalle Valo struct iwl_rx_cmd_buffer *rxb)
997e705c121SKalle Valo {
998e705c121SKalle Valo struct iwl_rx_packet *pkt = rxb_addr(rxb);
999e705c121SKalle Valo struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
1000e705c121SKalle Valo
1001e705c121SKalle Valo /*
1002e705c121SKalle Valo * Do the notification wait before RX handlers so
1003e705c121SKalle Valo * even if the RX handler consumes the RXB we have
1004e705c121SKalle Valo * access to it in the notification wait entry.
1005e705c121SKalle Valo */
1006e705c121SKalle Valo iwl_notification_wait_notify(&priv->notif_wait, pkt);
1007e705c121SKalle Valo
1008e705c121SKalle Valo /* Based on type of command response or notification,
1009e705c121SKalle Valo * handle those that need handling via function in
1010e705c121SKalle Valo * rx_handlers table. See iwl_setup_rx_handlers() */
1011e705c121SKalle Valo if (priv->rx_handlers[pkt->hdr.cmd]) {
1012e705c121SKalle Valo priv->rx_handlers_stats[pkt->hdr.cmd]++;
1013e705c121SKalle Valo priv->rx_handlers[pkt->hdr.cmd](priv, rxb);
1014e705c121SKalle Valo } else {
1015e705c121SKalle Valo /* No handling needed */
1016e705c121SKalle Valo IWL_DEBUG_RX(priv, "No handler needed for %s, 0x%02x\n",
101739bdb17eSSharon Dvir iwl_get_cmd_string(priv->trans,
1018f0c86427SJohannes Berg WIDE_ID(0, pkt->hdr.cmd)),
1019e705c121SKalle Valo pkt->hdr.cmd);
1020e705c121SKalle Valo }
1021e705c121SKalle Valo }
1022