Lines Matching +full:non +full:- +full:secure +full:- +full:otp
1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
4 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
24 " 0 - use default; < 0 - don't auto-establish");
29 " 60G device led enablement. Set the led ID (0-2) to enable");
35 * DOC: WMI event receiving - theory of operations
42 * event list @wil->pending_wmi_ev. Then, work queue @wil->wmi_wq wakes up
47 * if WMI event handling involves another WMI command flow, this 2-nd flow
52 * DOC: Addressing - theory of operations
57 * - MAC CPU (ucode)
58 * - User CPU (firmware)
59 * - AHB (host)
96 /* UCODE areas - accessible by debugfs blobs but not by
105 /* sparrow_d0_mac_rgf_ext - mac_rgf_ext section for Sparrow D0
139 /* OTP 4k */
140 {0x8a0000, 0x8a1000, 0x8a0000, "otp", true, false},
145 /* UCODE areas - accessible by debugfs blobs but not by
154 /* talyn_mb_fw_mapping provides memory remapping table for Talyn-MB
187 /* OTP 4k */
188 {0x8a0000, 0x8a1000, 0x8a0000, "otp", true, false},
199 /* UCODE areas - accessible by debugfs blobs but not by
227 * wmi_addr_remap - return AHB address for given firmware internal (linker) address
238 return x + fw_mapping[i].host - fw_mapping[i].from; in wmi_addr_remap()
245 * wil_find_fw_mapping - find fw_mapping entry by section name
263 * wmi_buffer_block - Check address validity for WMI buffer; remap if needed
266 * @size: if non zero, validate the block does not
287 if (off > wil->bar_size - 4) in wmi_buffer_block()
289 if (size && ((off + size > wil->bar_size) || (off + size < off))) in wmi_buffer_block()
292 return wil->csr + off; in wmi_buffer_block()
312 if (off > wil->bar_size - 4) in wmi_addr()
315 return wil->csr + off; in wmi_addr()
324 return -EINVAL; in wmi_read_hdr()
650 struct wil6210_mbox_ring *r = &wil->mbox_ctl.tx; in __wmi_send()
654 void __iomem *head = wmi_addr(wil, r->head); in __wmi_send()
658 if (len > r->entry_size - sizeof(cmd)) { in __wmi_send()
660 (int)(sizeof(cmd) + len), r->entry_size); in __wmi_send()
661 return -ERANGE; in __wmi_send()
666 if (!test_bit(wil_status_fwready, wil->status)) { in __wmi_send()
668 return -EAGAIN; in __wmi_send()
672 if ((test_bit(wil_status_suspending, wil->status) || in __wmi_send()
673 test_bit(wil_status_suspended, wil->status) || in __wmi_send()
674 test_bit(wil_status_resuming, wil->status)) && in __wmi_send()
678 return -EINVAL; in __wmi_send()
682 wil_err(wil, "WMI head is garbage: 0x%08x\n", r->head); in __wmi_send()
683 return -EINVAL; in __wmi_send()
689 for (retry = 5; retry > 0; retry--) { in __wmi_send()
697 rc = -EBUSY; in __wmi_send()
701 next_head = r->base + ((r->head - r->base + sizeof(d_head)) % r->size); in __wmi_send()
702 wil_dbg_wmi(wil, "Head 0x%08x -> 0x%08x\n", r->head, next_head); in __wmi_send()
704 for (retry = 5; retry > 0; retry--) { in __wmi_send()
705 if (!test_bit(wil_status_fwready, wil->status)) { in __wmi_send()
707 rc = -EAGAIN; in __wmi_send()
710 r->tail = wil_r(wil, RGF_MBOX + in __wmi_send()
712 if (next_head != r->tail) in __wmi_send()
716 if (next_head == r->tail) { in __wmi_send()
718 rc = -EBUSY; in __wmi_send()
725 rc = -EAGAIN; in __wmi_send()
728 cmd.hdr.seq = cpu_to_le16(++wil->wmi_seq); in __wmi_send()
739 wil_w(wil, r->head + offsetof(struct wil6210_mbox_ring_desc, sync), 1); in __wmi_send()
742 r->head = next_head); in __wmi_send()
759 mutex_lock(&wil->wmi_mutex); in wmi_send()
761 mutex_unlock(&wil->wmi_mutex); in wmi_send()
775 wil->fw_version, le32_to_cpu(evt->sw_version), in wmi_evt_ready()
776 evt->mac, evt->numof_additional_mids); in wmi_evt_ready()
777 if (evt->numof_additional_mids + 1 < wil->max_vifs) { in wmi_evt_ready()
779 wil->max_vifs - 1); in wmi_evt_ready()
783 strscpy(wiphy->fw_version, wil->fw_version, sizeof(wiphy->fw_version)); in wmi_evt_ready()
787 evt->rfc_read_calib_result); in wmi_evt_ready()
788 wil->fw_calib_result = evt->rfc_read_calib_result; in wmi_evt_ready()
793 evt->max_assoc_sta > 0) { in wmi_evt_ready()
794 fw_max_assoc_sta = evt->max_assoc_sta; in wmi_evt_ready()
806 wil->max_assoc_sta = min_t(uint, max_assoc_sta, fw_max_assoc_sta); in wmi_evt_ready()
807 wil_dbg_wmi(wil, "setting max assoc sta to %d\n", wil->max_assoc_sta); in wmi_evt_ready()
810 set_bit(wil_status_fwready, wil->status); in wmi_evt_ready()
812 complete(&wil->wmi_ready); in wmi_evt_ready()
821 (struct ieee80211_mgmt *)data->payload; in wmi_evt_rx_mgmt()
822 int flen = len - offsetof(struct wmi_rx_mgmt_packet_event, payload); in wmi_evt_rx_mgmt()
836 d_len = le32_to_cpu(data->info.len); in wmi_evt_rx_mgmt()
844 ch_no = data->info.channel + 1; in wmi_evt_rx_mgmt()
847 if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities)) in wmi_evt_rx_mgmt()
848 signal = 100 * data->info.rssi; in wmi_evt_rx_mgmt()
850 signal = data->info.sqi; in wmi_evt_rx_mgmt()
851 d_status = le16_to_cpu(data->info.status); in wmi_evt_rx_mgmt()
852 fc = rx_mgmt_frame->frame_control; in wmi_evt_rx_mgmt()
855 data->info.channel, WIL_EXTENDED_MCS_CHECK(data->info.mcs), in wmi_evt_rx_mgmt()
856 data->info.rssi, data->info.sqi); in wmi_evt_rx_mgmt()
860 data->info.qid, data->info.mid, data->info.cid); in wmi_evt_rx_mgmt()
877 u64 tsf = le64_to_cpu(rx_mgmt_frame->u.beacon.timestamp); in wmi_evt_rx_mgmt()
878 u16 cap = le16_to_cpu(rx_mgmt_frame->u.beacon.capab_info); in wmi_evt_rx_mgmt()
879 u16 bi = le16_to_cpu(rx_mgmt_frame->u.beacon.beacon_int); in wmi_evt_rx_mgmt()
880 const u8 *ie_buf = rx_mgmt_frame->u.beacon.variable; in wmi_evt_rx_mgmt()
881 size_t ie_len = d_len - offsetof(struct ieee80211_mgmt, in wmi_evt_rx_mgmt()
896 rx_mgmt_frame->bssid); in wmi_evt_rx_mgmt()
902 mutex_lock(&wil->vif_mutex); in wmi_evt_rx_mgmt()
905 mutex_unlock(&wil->vif_mutex); in wmi_evt_rx_mgmt()
913 (struct ieee80211_mgmt *)data->payload; in wmi_evt_tx_mgmt()
914 int flen = len - offsetof(struct wmi_tx_mgmt_packet_event, payload); in wmi_evt_tx_mgmt()
925 mutex_lock(&wil->vif_mutex); in wmi_evt_scan_complete()
926 if (vif->scan_request) { in wmi_evt_scan_complete()
928 int status = le32_to_cpu(data->status); in wmi_evt_scan_complete()
936 vif->scan_request, info.aborted); in wmi_evt_scan_complete()
937 del_timer_sync(&vif->scan_timer); in wmi_evt_scan_complete()
938 cfg80211_scan_done(vif->scan_request, &info); in wmi_evt_scan_complete()
939 if (vif->mid == 0) in wmi_evt_scan_complete()
940 wil->radio_wdev = wil->main_ndev->ieee80211_ptr; in wmi_evt_scan_complete()
941 vif->scan_request = NULL; in wmi_evt_scan_complete()
942 wake_up_interruptible(&wil->wq); in wmi_evt_scan_complete()
943 if (vif->p2p.pending_listen_wdev) { in wmi_evt_scan_complete()
945 schedule_work(&vif->p2p.delayed_listen_work); in wmi_evt_scan_complete()
950 mutex_unlock(&wil->vif_mutex); in wmi_evt_scan_complete()
973 if (len != sizeof(*evt) + evt->beacon_ie_len + evt->assoc_req_len + in wmi_evt_connect()
974 evt->assoc_resp_len) { in wmi_evt_connect()
977 len, (int)sizeof(*evt), evt->beacon_ie_len, in wmi_evt_connect()
978 evt->assoc_req_len, evt->assoc_resp_len); in wmi_evt_connect()
981 if (evt->cid >= wil->max_assoc_sta) { in wmi_evt_connect()
982 wil_err(wil, "Connect CID invalid : %d\n", evt->cid); in wmi_evt_connect()
986 ch = evt->channel + 1; in wmi_evt_connect()
988 evt->bssid, ch, evt->cid, evt->aid); in wmi_evt_connect()
990 evt->assoc_info, len - sizeof(*evt), true); in wmi_evt_connect()
993 assoc_req_ie = &evt->assoc_info[evt->beacon_ie_len + in wmi_evt_connect()
995 assoc_req_ielen = evt->assoc_req_len - assoc_req_ie_offset; in wmi_evt_connect()
996 if (evt->assoc_req_len <= assoc_req_ie_offset) { in wmi_evt_connect()
1001 assoc_resp_ie = &evt->assoc_info[evt->beacon_ie_len + in wmi_evt_connect()
1002 evt->assoc_req_len + in wmi_evt_connect()
1004 assoc_resp_ielen = evt->assoc_resp_len - assoc_resp_ie_offset; in wmi_evt_connect()
1005 if (evt->assoc_resp_len <= assoc_resp_ie_offset) { in wmi_evt_connect()
1010 if (test_bit(wil_status_resetting, wil->status) || in wmi_evt_connect()
1011 !test_bit(wil_status_fwready, wil->status)) { in wmi_evt_connect()
1013 evt->cid); in wmi_evt_connect()
1018 mutex_lock(&wil->mutex); in wmi_evt_connect()
1020 if ((wdev->iftype == NL80211_IFTYPE_STATION) || in wmi_evt_connect()
1021 (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)) { in wmi_evt_connect()
1022 if (!test_bit(wil_vif_fwconnecting, vif->status)) { in wmi_evt_connect()
1024 mutex_unlock(&wil->mutex); in wmi_evt_connect()
1027 del_timer_sync(&vif->connect_timer); in wmi_evt_connect()
1028 } else if ((wdev->iftype == NL80211_IFTYPE_AP) || in wmi_evt_connect()
1029 (wdev->iftype == NL80211_IFTYPE_P2P_GO)) { in wmi_evt_connect()
1030 if (wil->sta[evt->cid].status != wil_sta_unused) { in wmi_evt_connect()
1032 wil->sta[evt->cid].status, evt->cid); in wmi_evt_connect()
1033 mutex_unlock(&wil->mutex); in wmi_evt_connect()
1038 ether_addr_copy(wil->sta[evt->cid].addr, evt->bssid); in wmi_evt_connect()
1039 wil->sta[evt->cid].mid = vif->mid; in wmi_evt_connect()
1040 wil->sta[evt->cid].status = wil_sta_conn_pending; in wmi_evt_connect()
1042 rc = wil_ring_init_tx(vif, evt->cid); in wmi_evt_connect()
1045 evt->cid, rc); in wmi_evt_connect()
1046 wmi_disconnect_sta(vif, wil->sta[evt->cid].addr, in wmi_evt_connect()
1049 wil_info(wil, "successful connection to CID %d\n", evt->cid); in wmi_evt_connect()
1052 if ((wdev->iftype == NL80211_IFTYPE_STATION) || in wmi_evt_connect()
1053 (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)) { in wmi_evt_connect()
1058 cfg80211_connect_result(ndev, evt->bssid, NULL, 0, in wmi_evt_connect()
1066 cfg80211_ref_bss(wiphy, vif->bss); in wmi_evt_connect()
1067 cfg80211_connect_bss(ndev, evt->bssid, vif->bss, in wmi_evt_connect()
1073 vif->bss = NULL; in wmi_evt_connect()
1074 } else if ((wdev->iftype == NL80211_IFTYPE_AP) || in wmi_evt_connect()
1075 (wdev->iftype == NL80211_IFTYPE_P2P_GO)) { in wmi_evt_connect()
1080 cfg80211_del_sta(ndev, evt->bssid, GFP_KERNEL); in wmi_evt_connect()
1086 rc = -ENOMEM; in wmi_evt_connect()
1090 sinfo->generation = wil->sinfo_gen++; in wmi_evt_connect()
1093 sinfo->assoc_req_ies = assoc_req_ie; in wmi_evt_connect()
1094 sinfo->assoc_req_ies_len = assoc_req_ielen; in wmi_evt_connect()
1097 cfg80211_new_sta(ndev, evt->bssid, sinfo, GFP_KERNEL); in wmi_evt_connect()
1101 wil_err(wil, "unhandled iftype %d for CID %d\n", wdev->iftype, in wmi_evt_connect()
1102 evt->cid); in wmi_evt_connect()
1106 wil->sta[evt->cid].status = wil_sta_connected; in wmi_evt_connect()
1107 wil->sta[evt->cid].aid = evt->aid; in wmi_evt_connect()
1108 if (!test_and_set_bit(wil_vif_fwconnected, vif->status)) in wmi_evt_connect()
1109 atomic_inc(&wil->connected_vifs); in wmi_evt_connect()
1114 wil->sta[evt->cid].status = wil_sta_unused; in wmi_evt_connect()
1115 wil->sta[evt->cid].mid = U8_MAX; in wmi_evt_connect()
1117 clear_bit(wil_vif_fwconnecting, vif->status); in wmi_evt_connect()
1118 mutex_unlock(&wil->mutex); in wmi_evt_connect()
1126 u16 reason_code = le16_to_cpu(evt->protocol_reason_status); in wmi_evt_disconnect()
1129 evt->bssid, reason_code, evt->disconnect_reason); in wmi_evt_disconnect()
1131 wil->sinfo_gen++; in wmi_evt_disconnect()
1133 if (test_bit(wil_status_resetting, wil->status) || in wmi_evt_disconnect()
1134 !test_bit(wil_status_fwready, wil->status)) { in wmi_evt_disconnect()
1140 mutex_lock(&wil->mutex); in wmi_evt_disconnect()
1141 wil6210_disconnect_complete(vif, evt->bssid, reason_code); in wmi_evt_disconnect()
1147 switch (wdev->iftype) { in wmi_evt_disconnect()
1148 /* AP-like interface */ in wmi_evt_disconnect()
1152 cfg80211_cqm_pktloss_notify(ndev, evt->bssid, 0, in wmi_evt_disconnect()
1159 mutex_unlock(&wil->mutex); in wmi_evt_disconnect()
1171 u16 eapol_len = le16_to_cpu(evt->eapol_len); in wmi_evt_eapol_rx()
1179 evt->src_mac, vif->mid); in wmi_evt_eapol_rx()
1181 cid = wil_find_cid(wil, vif->mid, evt->src_mac); in wmi_evt_eapol_rx()
1183 stats = &wil->sta[cid].stats; in wmi_evt_eapol_rx()
1197 ether_addr_copy(eth->h_dest, ndev->dev_addr); in wmi_evt_eapol_rx()
1198 ether_addr_copy(eth->h_source, evt->src_mac); in wmi_evt_eapol_rx()
1199 eth->h_proto = cpu_to_be16(ETH_P_PAE); in wmi_evt_eapol_rx()
1200 skb_put_data(skb, evt->eapol, eapol_len); in wmi_evt_eapol_rx()
1201 skb->protocol = eth_type_trans(skb, ndev); in wmi_evt_eapol_rx()
1203 ndev->stats.rx_packets++; in wmi_evt_eapol_rx()
1204 ndev->stats.rx_bytes += sz; in wmi_evt_eapol_rx()
1206 stats->rx_packets++; in wmi_evt_eapol_rx()
1207 stats->rx_bytes += sz; in wmi_evt_eapol_rx()
1210 ndev->stats.rx_dropped++; in wmi_evt_eapol_rx()
1212 stats->rx_dropped++; in wmi_evt_eapol_rx()
1220 u8 vri = evt->ring_index; in wmi_evt_ring_en()
1226 wil_dbg_wmi(wil, "Enable vring %d MID %d\n", vri, vif->mid); in wmi_evt_ring_en()
1228 if (vri >= ARRAY_SIZE(wil->ring_tx)) { in wmi_evt_ring_en()
1233 if (wdev->iftype != NL80211_IFTYPE_AP || !disable_ap_sme || in wmi_evt_ring_en()
1234 test_bit(wil_vif_ft_roam, vif->status)) in wmi_evt_ring_en()
1238 wil->ring_tx_data[vri].dot1x_open = true; in wmi_evt_ring_en()
1239 if (vri == vif->bcast_ring) /* no BA for bcast */ in wmi_evt_ring_en()
1242 cid = wil->ring2cid_tid[vri][0]; in wmi_evt_ring_en()
1252 sta = &wil->sta[cid]; in wmi_evt_ring_en()
1253 if (test_bit(wil_vif_ft_roam, vif->status)) { in wmi_evt_ring_en()
1256 if (wdev->iftype != NL80211_IFTYPE_AP) in wmi_evt_ring_en()
1257 clear_bit(wil_vif_ft_roam, vif->status); in wmi_evt_ring_en()
1272 evt->ringid, in wmi_evt_ba_status()
1273 evt->status == WMI_BA_AGREED ? "OK" : "N/A", in wmi_evt_ba_status()
1274 evt->agg_wsize, __le16_to_cpu(evt->ba_timeout), in wmi_evt_ba_status()
1275 evt->amsdu ? "+" : "-"); in wmi_evt_ba_status()
1277 if (evt->ringid >= WIL6210_MAX_TX_RINGS) { in wmi_evt_ba_status()
1278 wil_err(wil, "invalid ring id %d\n", evt->ringid); in wmi_evt_ba_status()
1282 if (evt->status != WMI_BA_AGREED) { in wmi_evt_ba_status()
1283 evt->ba_timeout = 0; in wmi_evt_ba_status()
1284 evt->agg_wsize = 0; in wmi_evt_ba_status()
1285 evt->amsdu = 0; in wmi_evt_ba_status()
1288 txdata = &wil->ring_tx_data[evt->ringid]; in wmi_evt_ba_status()
1290 txdata->agg_timeout = le16_to_cpu(evt->ba_timeout); in wmi_evt_ba_status()
1291 txdata->agg_wsize = evt->agg_wsize; in wmi_evt_ba_status()
1292 txdata->agg_amsdu = evt->amsdu; in wmi_evt_ba_status()
1293 txdata->addba_in_progress = false; in wmi_evt_ba_status()
1303 if (evt->cidxtid != CIDXTID_EXTENDED_CID_TID) { in wmi_evt_addba_rx_req()
1304 parse_cidxtid(evt->cidxtid, &cid, &tid); in wmi_evt_addba_rx_req()
1306 cid = evt->cid; in wmi_evt_addba_rx_req()
1307 tid = evt->tid; in wmi_evt_addba_rx_req()
1309 wil_addba_rx_request(wil, vif->mid, cid, tid, evt->dialog_token, in wmi_evt_addba_rx_req()
1310 evt->ba_param_set, evt->ba_timeout, in wmi_evt_addba_rx_req()
1311 evt->ba_seq_ctrl); in wmi_evt_addba_rx_req()
1315 __acquires(&sta->tid_rx_lock) __releases(&sta->tid_rx_lock) in wmi_evt_delba()
1320 u16 reason = __le16_to_cpu(evt->reason); in wmi_evt_delba()
1326 if (evt->cidxtid != CIDXTID_EXTENDED_CID_TID) { in wmi_evt_delba()
1327 parse_cidxtid(evt->cidxtid, &cid, &tid); in wmi_evt_delba()
1329 cid = evt->cid; in wmi_evt_delba()
1330 tid = evt->tid; in wmi_evt_delba()
1339 vif->mid, cid, tid, in wmi_evt_delba()
1340 evt->from_initiator ? "originator" : "recipient", in wmi_evt_delba()
1342 if (!evt->from_initiator) { in wmi_evt_delba()
1345 for (i = 0; i < ARRAY_SIZE(wil->ring2cid_tid); i++) { in wmi_evt_delba()
1346 if (wil->ring2cid_tid[i][0] == cid && in wmi_evt_delba()
1347 wil->ring2cid_tid[i][1] == tid) { in wmi_evt_delba()
1349 &wil->ring_tx_data[i]; in wmi_evt_delba()
1352 txdata->agg_timeout = 0; in wmi_evt_delba()
1353 txdata->agg_wsize = 0; in wmi_evt_delba()
1354 txdata->addba_in_progress = false; in wmi_evt_delba()
1359 if (i >= ARRAY_SIZE(wil->ring2cid_tid)) in wmi_evt_delba()
1364 sta = &wil->sta[cid]; in wmi_evt_delba()
1366 spin_lock_bh(&sta->tid_rx_lock); in wmi_evt_delba()
1368 r = sta->tid_rx[tid]; in wmi_evt_delba()
1369 sta->tid_rx[tid] = NULL; in wmi_evt_delba()
1372 spin_unlock_bh(&sta->tid_rx_lock); in wmi_evt_delba()
1382 (struct ieee80211_mgmt *)data->payload; in wmi_evt_sched_scan_result()
1383 int flen = len - offsetof(struct wmi_sched_scan_result_event, payload); in wmi_evt_sched_scan_result()
1402 d_len = le32_to_cpu(data->info.len); in wmi_evt_sched_scan_result()
1410 fc = rx_mgmt_frame->frame_control; in wmi_evt_sched_scan_result()
1417 ch_no = data->info.channel + 1; in wmi_evt_sched_scan_result()
1420 if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities)) in wmi_evt_sched_scan_result()
1421 signal = 100 * data->info.rssi; in wmi_evt_sched_scan_result()
1423 signal = data->info.sqi; in wmi_evt_sched_scan_result()
1426 data->info.channel, WIL_EXTENDED_MCS_CHECK(data->info.mcs), in wmi_evt_sched_scan_result()
1427 data->info.rssi); in wmi_evt_sched_scan_result()
1429 d_len, data->info.qid, data->info.mid, data->info.cid); in wmi_evt_sched_scan_result()
1443 wil_dbg_wmi(wil, "Added BSS %pM\n", rx_mgmt_frame->bssid); in wmi_evt_sched_scan_result()
1456 u8 cid = basic->cid; in wil_link_stats_store_basic()
1459 if (cid >= wil->max_assoc_sta) { in wil_link_stats_store_basic()
1464 sta = &wil->sta[cid]; in wil_link_stats_store_basic()
1465 sta->fw_stats_basic = *basic; in wil_link_stats_store_basic()
1473 wil->fw_stats_global.stats = *global; in wil_link_stats_store_global()
1492 stats_size = le16_to_cpu(hdr->record_size); in wmi_link_stats_parse()
1501 switch (hdr->record_type_id) { in wmi_link_stats_parse()
1509 if (vif->fw_stats_ready) { in wmi_link_stats_parse()
1511 vif->fw_stats_tsf = 0; in wmi_link_stats_parse()
1512 vif->fw_stats_ready = false; in wmi_link_stats_parse()
1518 vif->fw_stats_tsf = tsf; in wmi_link_stats_parse()
1519 vif->fw_stats_ready = true; in wmi_link_stats_parse()
1531 if (wil->fw_stats_global.ready) { in wmi_link_stats_parse()
1533 wil->fw_stats_global.tsf = 0; in wmi_link_stats_parse()
1534 wil->fw_stats_global.ready = false; in wmi_link_stats_parse()
1540 wil->fw_stats_global.tsf = tsf; in wmi_link_stats_parse()
1541 wil->fw_stats_global.ready = true; in wmi_link_stats_parse()
1551 payload_size -= record_size; in wmi_link_stats_parse()
1566 payload_size = le16_to_cpu(evt->payload_size); in wmi_evt_link_stats()
1572 wmi_link_stats_parse(vif, le64_to_cpu(evt->tsf), evt->has_next, in wmi_evt_link_stats()
1573 evt->payload, payload_size); in wmi_evt_link_stats()
1591 if (!(vif->wdev.iftype == NL80211_IFTYPE_STATION || in wil_find_cid_ringid_sta()
1592 vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT)) { in wil_find_cid_ringid_sta()
1593 wil_err(wil, "invalid interface type %d\n", vif->wdev.iftype); in wil_find_cid_ringid_sta()
1594 return -EINVAL; in wil_find_cid_ringid_sta()
1602 ring = &wil->ring_tx[i]; in wil_find_cid_ringid_sta()
1603 txdata = &wil->ring_tx_data[i]; in wil_find_cid_ringid_sta()
1604 if (!ring->va || !txdata->enabled || txdata->mid != vif->mid) in wil_find_cid_ringid_sta()
1607 lcid = wil->ring2cid_tid[i][0]; in wil_find_cid_ringid_sta()
1608 if (lcid >= wil->max_assoc_sta) /* skip BCAST */ in wil_find_cid_ringid_sta()
1611 wil_dbg_wmi(wil, "find sta -> ringid %d cid %d\n", i, lcid); in wil_find_cid_ringid_sta()
1619 return -ENOENT; in wil_find_cid_ringid_sta()
1628 int ie_len = len - offsetof(struct wmi_ft_auth_status_event, ie_info); in wmi_evt_auth_status()
1634 struct auth_no_hdr *auth = (struct auth_no_hdr *)data->ie_info; in wmi_evt_auth_status()
1637 if (ie_len >= 0 && data->status != WMI_FW_STATUS_SUCCESS) { in wmi_evt_auth_status()
1638 wil_err(wil, "FT: auth failed. status %d\n", data->status); in wmi_evt_auth_status()
1647 d_len = le16_to_cpu(data->ie_len); in wmi_evt_auth_status()
1655 if (!test_bit(wil_vif_ft_roam, wil->status)) { in wmi_evt_auth_status()
1660 if (le16_to_cpu(auth->auth_transaction) != 2) { in wmi_evt_auth_status()
1662 le16_to_cpu(auth->auth_transaction)); in wmi_evt_auth_status()
1666 if (le16_to_cpu(auth->auth_alg) != WLAN_AUTH_FT) { in wmi_evt_auth_status()
1668 le16_to_cpu(auth->auth_alg)); in wmi_evt_auth_status()
1672 wil_dbg_wmi(wil, "FT: Auth to %pM successfully\n", data->mac_addr); in wmi_evt_auth_status()
1674 data->ie_info, d_len, true); in wmi_evt_auth_status()
1683 if (vif->privacy) { in wmi_evt_auth_status()
1684 /* For secure assoc, remove old keys */ in wmi_evt_auth_status()
1685 rc = wmi_del_cipher_key(vif, 0, wil->sta[cid].addr, in wmi_evt_auth_status()
1691 rc = wmi_del_cipher_key(vif, 0, wil->sta[cid].addr, in wmi_evt_auth_status()
1700 ft.ies = data->ie_info + auth_ie_offset; in wmi_evt_auth_status()
1701 ft.ies_len = d_len - auth_ie_offset; in wmi_evt_auth_status()
1702 ft.target_ap = data->mac_addr; in wmi_evt_auth_status()
1718 int ies_len = len - offsetof(struct wmi_ft_reassoc_status_event, in wmi_evt_reassoc_status()
1720 int rc = -ENOENT, cid = 0, ringid = 0; in wmi_evt_reassoc_status()
1738 data->status, data->aid); in wmi_evt_reassoc_status()
1740 data->mac_addr, data->beacon_ie_len); in wmi_evt_reassoc_status()
1742 le16_to_cpu(data->reassoc_req_ie_len), in wmi_evt_reassoc_status()
1743 le16_to_cpu(data->reassoc_resp_ie_len)); in wmi_evt_reassoc_status()
1745 d_len = le16_to_cpu(data->beacon_ie_len) + in wmi_evt_reassoc_status()
1746 le16_to_cpu(data->reassoc_req_ie_len) + in wmi_evt_reassoc_status()
1747 le16_to_cpu(data->reassoc_resp_ie_len); in wmi_evt_reassoc_status()
1756 if (data->status != WMI_FW_STATUS_SUCCESS) { in wmi_evt_reassoc_status()
1757 wil_err(wil, "ft reassoc failed. status %d\n", data->status); in wmi_evt_reassoc_status()
1768 ch = data->channel + 1; in wmi_evt_reassoc_status()
1770 data->mac_addr, ch, cid, data->aid); in wmi_evt_reassoc_status()
1773 data->ie_info, len - sizeof(*data), true); in wmi_evt_reassoc_status()
1776 if (le16_to_cpu(data->reassoc_req_ie_len) > assoc_req_ie_offset) { in wmi_evt_reassoc_status()
1777 assoc_req_ie = &data->ie_info[assoc_req_ie_offset]; in wmi_evt_reassoc_status()
1778 assoc_req_ie_len = le16_to_cpu(data->reassoc_req_ie_len) - in wmi_evt_reassoc_status()
1781 if (le16_to_cpu(data->reassoc_resp_ie_len) <= assoc_resp_ie_offset) { in wmi_evt_reassoc_status()
1783 le16_to_cpu(data->reassoc_resp_ie_len)); in wmi_evt_reassoc_status()
1787 assoc_resp_ie = &data->ie_info[le16_to_cpu(data->reassoc_req_ie_len) + in wmi_evt_reassoc_status()
1789 assoc_resp_ie_len = le16_to_cpu(data->reassoc_resp_ie_len) - in wmi_evt_reassoc_status()
1792 if (test_bit(wil_status_resetting, wil->status) || in wmi_evt_reassoc_status()
1793 !test_bit(wil_status_fwready, wil->status)) { in wmi_evt_reassoc_status()
1799 mutex_lock(&wil->mutex); in wmi_evt_reassoc_status()
1806 rc = wil->txrx_ops.tx_ring_modify(vif, ringid, cid, 0); in wmi_evt_reassoc_status()
1809 cid, vif->mid, ringid, rc); in wmi_evt_reassoc_status()
1810 mutex_unlock(&wil->mutex); in wmi_evt_reassoc_status()
1815 wil->sta[cid].aid = data->aid; in wmi_evt_reassoc_status()
1816 wil->sta[cid].stats.ft_roams++; in wmi_evt_reassoc_status()
1817 ether_addr_copy(wil->sta[cid].addr, vif->bss->bssid); in wmi_evt_reassoc_status()
1818 mutex_unlock(&wil->mutex); in wmi_evt_reassoc_status()
1819 del_timer_sync(&vif->connect_timer); in wmi_evt_reassoc_status()
1821 cfg80211_ref_bss(wiphy, vif->bss); in wmi_evt_reassoc_status()
1826 info.links[0].bss = vif->bss; in wmi_evt_reassoc_status()
1832 vif->bss = NULL; in wmi_evt_reassoc_status()
1854 evt->type, evt->rssi_level, wil->cqm_rssi_thold); in wmi_evt_link_monitor()
1856 if (evt->type != WMI_LINK_MONITOR_NOTIF_RSSI_THRESHOLD_EVT) in wmi_evt_link_monitor()
1860 event_type = (evt->rssi_level > wil->cqm_rssi_thold ? in wmi_evt_link_monitor()
1863 cfg80211_cqm_rssi_notify(ndev, event_type, evt->rssi_level, GFP_KERNEL); in wmi_evt_link_monitor()
1903 * Extract WMI command from mailbox. Queue it to the @wil->pending_wmi_ev
1911 struct wil6210_mbox_ring *r = &wil->mbox_ctl.rx; in wmi_recv_cmd()
1919 if (!test_bit(wil_status_mbox_ready, wil->status)) { in wmi_recv_cmd()
1924 if (test_bit(wil_status_suspended, wil->status)) { in wmi_recv_cmd()
1934 r->head = wil_r(wil, RGF_MBOX + in wmi_recv_cmd()
1936 if (r->tail == r->head) in wmi_recv_cmd()
1940 r->head, r->tail); in wmi_recv_cmd()
1942 wil_memcpy_fromio_32(&d_tail, wil->csr + HOSTADDR(r->tail), in wmi_recv_cmd()
1969 evt->event.hdr = hdr; in wmi_recv_cmd()
1970 cmd = (void *)&evt->event.wmi; in wmi_recv_cmd()
1973 wil_w(wil, r->tail + in wmi_recv_cmd()
1978 struct wmi_cmd_hdr *wmi = &evt->event.wmi; in wmi_recv_cmd()
1979 u16 id = le16_to_cpu(wmi->command_id); in wmi_recv_cmd()
1980 u8 mid = wmi->mid; in wmi_recv_cmd()
1981 u32 tstamp = le32_to_cpu(wmi->fw_timestamp); in wmi_recv_cmd()
1982 if (test_bit(wil_status_resuming, wil->status)) { in wmi_recv_cmd()
1985 wil->status); in wmi_recv_cmd()
1991 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in wmi_recv_cmd()
1992 if (wil->reply_id && wil->reply_id == id && in wmi_recv_cmd()
1993 wil->reply_mid == mid) { in wmi_recv_cmd()
1994 if (wil->reply_buf) { in wmi_recv_cmd()
1995 memcpy(wil->reply_buf, wmi, in wmi_recv_cmd()
1996 min(len, wil->reply_size)); in wmi_recv_cmd()
2002 wil->suspend_resp_rcvd = true; in wmi_recv_cmd()
2005 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in wmi_recv_cmd()
2008 eventid2name(id), id, wmi->mid, tstamp); in wmi_recv_cmd()
2010 len - sizeof(*wmi)); in wmi_recv_cmd()
2013 &evt->event.hdr, sizeof(hdr) + len, true); in wmi_recv_cmd()
2016 r->tail = r->base + ((r->tail - r->base + in wmi_recv_cmd()
2017 sizeof(struct wil6210_mbox_ring_desc)) % r->size); in wmi_recv_cmd()
2019 offsetof(struct wil6210_mbox_ctl, rx.tail), r->tail); in wmi_recv_cmd()
2023 wil->reply_id); in wmi_recv_cmd()
2026 complete(&wil->wmi_call); in wmi_recv_cmd()
2029 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in wmi_recv_cmd()
2030 list_add_tail(&evt->list, &wil->pending_wmi_ev); in wmi_recv_cmd()
2031 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in wmi_recv_cmd()
2032 q = queue_work(wil->wmi_wq, &wil->wmi_event_worker); in wmi_recv_cmd()
2033 wil_dbg_wmi(wil, "queue_work -> %d\n", q); in wmi_recv_cmd()
2037 wil_dbg_wmi(wil, "recv_cmd: -> %d events queued, %d completed\n", in wmi_recv_cmd()
2038 n - num_immed_reply, num_immed_reply); in wmi_recv_cmd()
2048 mutex_lock(&wil->wmi_mutex); in wmi_call()
2050 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in wmi_call()
2051 wil->reply_id = reply_id; in wmi_call()
2052 wil->reply_mid = mid; in wmi_call()
2053 wil->reply_buf = reply; in wmi_call()
2054 wil->reply_size = reply_size; in wmi_call()
2055 reinit_completion(&wil->wmi_call); in wmi_call()
2056 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in wmi_call()
2062 remain = wait_for_completion_timeout(&wil->wmi_call, in wmi_call()
2065 wil_err(wil, "wmi_call(0x%04x->0x%04x) timeout %d msec\n", in wmi_call()
2067 rc = -ETIME; in wmi_call()
2070 "wmi_call(0x%04x->0x%04x) completed in %d msec\n", in wmi_call()
2072 to_msec - jiffies_to_msecs(remain)); in wmi_call()
2076 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in wmi_call()
2077 wil->reply_id = 0; in wmi_call()
2078 wil->reply_mid = U8_MAX; in wmi_call()
2079 wil->reply_buf = NULL; in wmi_call()
2080 wil->reply_size = 0; in wmi_call()
2081 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in wmi_call()
2083 mutex_unlock(&wil->wmi_mutex); in wmi_call()
2090 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_echo()
2095 return wmi_call(wil, WMI_ECHO_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_echo()
2102 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_set_mac_address()
2109 return wmi_send(wil, WMI_SET_MAC_ADDRESS_CMDID, vif->mid, in wmi_set_mac_address()
2115 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_led_cfg()
2146 rc = -EINVAL; in wmi_led_cfg()
2154 rc = wmi_call(wil, WMI_LED_CFG_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_led_cfg()
2163 rc = -EINVAL; in wmi_led_cfg()
2172 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_rbufcap_cfg()
2186 rc = wmi_call(wil, WMI_RBUFCAP_CFG_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_rbufcap_cfg()
2195 rc = -EINVAL; in wmi_rbufcap_cfg()
2211 .channel = chan - 1, in wmi_pcp_start()
2213 .pcp_max_assoc_sta = wil->max_assoc_sta, in wmi_pcp_start()
2219 .abft_len = wil->abft_len, in wmi_pcp_start()
2228 if (!vif->privacy) in wmi_pcp_start()
2235 return -EOPNOTSUPP; in wmi_pcp_start()
2240 wil->fw_capabilities)) { in wmi_pcp_start()
2242 return -EOPNOTSUPP; in wmi_pcp_start()
2246 * Processing time may be huge, in case of secure AP it takes about in wmi_pcp_start()
2249 rc = wmi_call(wil, WMI_PCP_START_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_pcp_start()
2255 rc = -EINVAL; in wmi_pcp_start()
2273 return wmi_call(wil, WMI_PCP_STOP_CMDID, vif->mid, NULL, 0, in wmi_pcp_stop()
2286 return -EINVAL; in wmi_set_ssid()
2290 return wmi_send(wil, WMI_SET_SSID_CMDID, vif->mid, &cmd, sizeof(cmd)); in wmi_set_ssid()
2305 rc = wmi_call(wil, WMI_GET_SSID_CMDID, vif->mid, NULL, 0, in wmi_get_ssid()
2313 return -EINVAL; in wmi_get_ssid()
2323 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_set_channel()
2325 .channel = channel - 1, in wmi_set_channel()
2328 return wmi_send(wil, WMI_SET_PCP_CHANNEL_CMDID, vif->mid, in wmi_set_channel()
2334 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_get_channel()
2343 rc = wmi_call(wil, WMI_GET_PCP_CHANNEL_CMDID, vif->mid, NULL, 0, in wmi_get_channel()
2350 return -EINVAL; in wmi_get_channel()
2364 .channel = channel - 1, in wmi_p2p_cfg()
2375 rc = wmi_call(wil, WMI_P2P_CFG_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_p2p_cfg()
2379 rc = -EINVAL; in wmi_p2p_cfg()
2398 rc = wmi_call(wil, WMI_START_LISTEN_CMDID, vif->mid, NULL, 0, in wmi_start_listen()
2403 rc = -EINVAL; in wmi_start_listen()
2422 rc = wmi_call(wil, WMI_START_SEARCH_CMDID, vif->mid, NULL, 0, in wmi_start_search()
2427 rc = -EINVAL; in wmi_start_search()
2440 rc = wmi_call(wil, WMI_DISCOVERY_STOP_CMDID, vif->mid, NULL, 0, in wmi_stop_discovery()
2461 return wmi_send(wil, WMI_DELETE_CIPHER_KEY_CMDID, vif->mid, in wmi_del_cipher_key()
2477 return -EINVAL; in wmi_add_cipher_key()
2482 return -EINVAL; in wmi_add_cipher_key()
2490 return wmi_send(wil, WMI_ADD_CIPHER_KEY_CMDID, vif->mid, in wmi_add_cipher_key()
2509 rc = -EINVAL; in wmi_set_ie()
2515 rc = -ENOMEM; in wmi_set_ie()
2521 cmd->mgmt_frm_type = type; in wmi_set_ie()
2523 cmd->ie_len = cpu_to_le16(ie_len); in wmi_set_ie()
2525 memcpy(cmd->ie_info, ie, ie_len); in wmi_set_ie()
2526 rc = wmi_send(wil, WMI_SET_APPIE_CMDID, vif->mid, cmd, len); in wmi_set_ie()
2551 return -EINVAL; in wmi_update_ft_ies()
2556 rc = -ENOMEM; in wmi_update_ft_ies()
2560 cmd->ie_len = cpu_to_le16(ie_len); in wmi_update_ft_ies()
2562 memcpy(cmd->ie_info, ie, ie_len); in wmi_update_ft_ies()
2563 rc = wmi_send(wil, WMI_UPDATE_FT_IES_CMDID, vif->mid, cmd, len); in wmi_update_ft_ies()
2574 * wmi_rxon - turn radio on/off
2579 * No timeout for rxon - radio turned on forever unless some other call
2584 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_rxon()
2596 rc = wmi_call(wil, WMI_START_LISTEN_CMDID, vif->mid, NULL, 0, in wmi_rxon()
2601 rc = -EINVAL; in wmi_rxon()
2603 rc = wmi_call(wil, WMI_DISCOVERY_STOP_CMDID, vif->mid, NULL, 0, in wmi_rxon()
2613 struct net_device *ndev = wil->main_ndev; in wmi_rx_chain_add()
2614 struct wireless_dev *wdev = ndev->ieee80211_ptr; in wmi_rx_chain_add()
2620 wil_mtu2macbuf(wil->rx_buf_len)), in wmi_rx_chain_add()
2621 .ring_mem_base = cpu_to_le64(vring->pa), in wmi_rx_chain_add()
2622 .ring_size = cpu_to_le16(vring->size), in wmi_rx_chain_add()
2624 .mid = 0, /* TODO - what is it? */ in wmi_rx_chain_add()
2637 if (wdev->iftype == NL80211_IFTYPE_MONITOR) { in wmi_rx_chain_add()
2638 struct ieee80211_channel *ch = wil->monitor_chandef.chan; in wmi_rx_chain_add()
2642 cmd.sniffer_cfg.channel = ch->hw_value - 1; in wmi_rx_chain_add()
2646 cpu_to_le32((wil->monitor_flags & MONITOR_FLAG_CONTROL) in wmi_rx_chain_add()
2649 /* Initialize offload (in non-sniffer mode). in wmi_rx_chain_add()
2660 /* typical time for secure PCP is 840ms */ in wmi_rx_chain_add()
2661 rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_rx_chain_add()
2667 rc = -EINVAL; in wmi_rx_chain_add()
2669 vring->hwtail = le32_to_cpu(evt.evt.rx_ring_tail_ptr); in wmi_rx_chain_add()
2672 le32_to_cpu(evt.evt.status), vring->hwtail); in wmi_rx_chain_add()
2679 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_get_temperature()
2693 rc = wmi_call(wil, WMI_TEMP_SENSE_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_get_temperature()
2711 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_get_all_temperatures()
2725 return -EINVAL; in wmi_get_all_temperatures()
2730 rc = wmi_call(wil, WMI_TEMP_SENSE_ALL_CMDID, vif->mid, &cmd, in wmi_get_all_temperatures()
2738 return -EINVAL; in wmi_get_all_temperatures()
2764 vif->locally_generated_disc = true; in wmi_disconnect_sta()
2767 rc = wmi_call(wil, WMI_DEL_STA_CMDID, vif->mid, &del_sta_cmd, in wmi_disconnect_sta()
2772 rc = wmi_call(wil, WMI_DISCONNECT_STA_CMDID, vif->mid, in wmi_disconnect_sta()
2782 wil->sinfo_gen++; in wmi_disconnect_sta()
2790 u8 amsdu = wil->use_enhanced_dma_hw && wil->use_rx_hw_reordering && in wmi_addba()
2791 test_bit(WMI_FW_CAPABILITY_AMSDU, wil->fw_capabilities) && in wmi_addba()
2792 wil->amsdu_en; in wmi_addba()
2846 /* bit 0: A-MSDU supported in wmi_addba_rx_resp()
2873 timeout, status, amsdu ? "+" : "-"); in wmi_addba_rx_resp()
2884 rc = -EINVAL; in wmi_addba_rx_resp()
2900 /* bit 0: A-MSDU supported in wmi_addba_rx_resp_edma()
2920 cid, tid, agg_wsize, timeout, status, amsdu ? "+" : "-", in wmi_addba_rx_resp_edma()
2932 rc = -EINVAL; in wmi_addba_rx_resp_edma()
2941 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_ps_dev_profile_cfg()
2956 rc = wmi_call(wil, WMI_PS_DEV_PROFILE_CFG_CMDID, vif->mid, in wmi_ps_dev_profile_cfg()
2968 rc = -EINVAL; in wmi_ps_dev_profile_cfg()
2976 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_set_mgmt_retry()
2990 if (!test_bit(WMI_FW_CAPABILITY_MGMT_RETRY_LIMIT, wil->fw_capabilities)) in wmi_set_mgmt_retry()
2991 return -ENOTSUPP; in wmi_set_mgmt_retry()
2993 rc = wmi_call(wil, WMI_SET_MGMT_RETRY_LIMIT_CMDID, vif->mid, in wmi_set_mgmt_retry()
3003 rc = -EINVAL; in wmi_set_mgmt_retry()
3011 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_get_mgmt_retry()
3020 if (!test_bit(WMI_FW_CAPABILITY_MGMT_RETRY_LIMIT, wil->fw_capabilities)) in wmi_get_mgmt_retry()
3021 return -ENOTSUPP; in wmi_get_mgmt_retry()
3024 rc = wmi_call(wil, WMI_GET_MGMT_RETRY_LIMIT_CMDID, vif->mid, NULL, 0, in wmi_get_mgmt_retry()
3043 rc = wmi_send(wil, WMI_ABORT_SCAN_CMDID, vif->mid, NULL, 0); in wmi_abort_scan()
3062 rc = wmi_send(wil, WMI_NEW_STA_CMDID, vif->mid, &cmd, sizeof(cmd)); in wmi_new_sta()
3076 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in wmi_event_flush()
3078 list_for_each_entry_safe(evt, t, &wil->pending_wmi_ev, list) { in wmi_event_flush()
3079 list_del(&evt->list); in wmi_event_flush()
3083 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in wmi_event_flush()
3102 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_suspend()
3105 .wakeup_trigger = wil->wakeup_trigger, in wmi_suspend()
3116 wil->suspend_resp_rcvd = false; in wmi_suspend()
3117 wil->suspend_resp_comp = false; in wmi_suspend()
3119 rc = wmi_call(wil, WMI_TRAFFIC_SUSPEND_CMDID, vif->mid, in wmi_suspend()
3125 if (rc == -ETIME) in wmi_suspend()
3127 wil->suspend_stats.rejected_by_device++; in wmi_suspend()
3129 wil->suspend_stats.rejected_by_host++; in wmi_suspend()
3135 rc = wait_event_interruptible_timeout(wil->wq, in wmi_suspend()
3136 wil->suspend_resp_comp, in wmi_suspend()
3140 if (wil->suspend_resp_rcvd) in wmi_suspend()
3142 wil->suspend_stats.rejected_by_host++; in wmi_suspend()
3144 wil->suspend_stats.rejected_by_device++; in wmi_suspend()
3145 rc = -EBUSY; in wmi_suspend()
3153 wil->suspend_stats.rejected_by_device++; in wmi_suspend()
3158 wil->suspend_resp_rcvd = false; in wmi_suspend()
3159 wil->suspend_resp_comp = false; in wmi_suspend()
3191 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_resume()
3203 rc = wmi_call(wil, WMI_TRAFFIC_RESUME_CMDID, vif->mid, NULL, 0, in wmi_resume()
3251 return -EINVAL; in wmi_port_allocate()
3265 return -EINVAL; in wmi_port_allocate()
3297 return -EINVAL; in wmi_port_delete()
3321 u16 len = le16_to_cpu(hdr->len); in wmi_event_handle()
3324 if ((hdr->type == WIL_MBOX_HDR_TYPE_WMI) && in wmi_event_handle()
3328 u16 id = le16_to_cpu(wmi->command_id); in wmi_event_handle()
3329 u8 mid = wmi->mid; in wmi_event_handle()
3332 eventid2name(id), id, wil->reply_id, in wmi_event_handle()
3333 wil->reply_mid); in wmi_event_handle()
3342 vif = wil->vifs[mid]; in wmi_event_handle()
3350 if (wil->reply_id && wil->reply_id == id && in wmi_event_handle()
3351 wil->reply_mid == mid) { in wmi_event_handle()
3352 if (wil->reply_buf) { in wmi_event_handle()
3366 len - sizeof(*wmi)); in wmi_event_handle()
3369 complete(&wil->wmi_call); in wmi_event_handle()
3375 len - sizeof(*wmi))) { in wmi_event_handle()
3393 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in next_wmi_ev()
3395 if (!list_empty(&wil->pending_wmi_ev)) { in next_wmi_ev()
3396 ret = wil->pending_wmi_ev.next; in next_wmi_ev()
3400 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in next_wmi_ev()
3418 wmi_event_handle(wil, &evt->event.hdr); in wmi_event_worker()
3427 struct wil6210_mbox_ring *r = &wil->mbox_ctl.rx; in wil_is_wmi_idle()
3430 spin_lock_irqsave(&wil->wmi_ev_lock, flags); in wil_is_wmi_idle()
3433 if (!list_empty(&wil->pending_wmi_ev)) { in wil_is_wmi_idle()
3439 if (wil->reply_id) { in wil_is_wmi_idle()
3445 r->head = wil_r(wil, RGF_MBOX + in wil_is_wmi_idle()
3447 if (r->tail != r->head) in wil_is_wmi_idle()
3453 spin_unlock_irqrestore(&wil->wmi_ev_lock, flags); in wil_is_wmi_idle()
3471 cmd->num_of_ssids = n_match_sets; in wmi_sched_scan_set_ssids()
3475 &cmd->ssid_for_match[i]; in wmi_sched_scan_set_ssids()
3479 wmi_match->ssid_len = cfg_match->ssid.ssid_len; in wmi_sched_scan_set_ssids()
3480 memcpy(wmi_match->ssid, cfg_match->ssid.ssid, in wmi_sched_scan_set_ssids()
3481 min_t(u8, wmi_match->ssid_len, WMI_MAX_SSID_LEN)); in wmi_sched_scan_set_ssids()
3482 wmi_match->rssi_threshold = S8_MIN; in wmi_sched_scan_set_ssids()
3483 if (cfg_match->rssi_thold >= S8_MIN && in wmi_sched_scan_set_ssids()
3484 cfg_match->rssi_thold <= S8_MAX) in wmi_sched_scan_set_ssids()
3485 wmi_match->rssi_threshold = cfg_match->rssi_thold; in wmi_sched_scan_set_ssids()
3488 if (wmi_match->ssid_len == ssids[j].ssid_len && in wmi_sched_scan_set_ssids()
3489 memcmp(wmi_match->ssid, ssids[j].ssid, in wmi_sched_scan_set_ssids()
3490 wmi_match->ssid_len) == 0) in wmi_sched_scan_set_ssids()
3491 wmi_match->add_ssid_to_probe = true; in wmi_sched_scan_set_ssids()
3508 cmd->num_of_channels = n_channels; in wmi_sched_scan_set_channels()
3513 cmd->channel_list[i] = cfg_chan->hw_value - 1; in wmi_sched_scan_set_channels()
3534 cmd->scan_plans[i].interval_sec = in wmi_sched_scan_set_plans()
3535 cpu_to_le16(cfg_plan->interval); in wmi_sched_scan_set_plans()
3536 cmd->scan_plans[i].num_of_iterations = in wmi_sched_scan_set_plans()
3537 cpu_to_le16(cfg_plan->iterations); in wmi_sched_scan_set_plans()
3544 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_start_sched_scan()
3548 .initial_delay_sec = cpu_to_le16(request->delay), in wmi_start_sched_scan()
3557 if (!test_bit(WMI_FW_CAPABILITY_PNO, wil->fw_capabilities)) in wmi_start_sched_scan()
3558 return -ENOTSUPP; in wmi_start_sched_scan()
3560 if (request->min_rssi_thold >= S8_MIN && in wmi_start_sched_scan()
3561 request->min_rssi_thold <= S8_MAX) in wmi_start_sched_scan()
3562 cmd.min_rssi_threshold = request->min_rssi_thold; in wmi_start_sched_scan()
3564 wmi_sched_scan_set_ssids(wil, &cmd, request->ssids, request->n_ssids, in wmi_start_sched_scan()
3565 request->match_sets, request->n_match_sets); in wmi_start_sched_scan()
3567 request->n_channels, request->channels); in wmi_start_sched_scan()
3569 request->scan_plans, request->n_scan_plans); in wmi_start_sched_scan()
3571 rc = wmi_call(wil, WMI_START_SCHED_SCAN_CMDID, vif->mid, in wmi_start_sched_scan()
3581 return -EINVAL; in wmi_start_sched_scan()
3589 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wmi_stop_sched_scan()
3598 if (!test_bit(WMI_FW_CAPABILITY_PNO, wil->fw_capabilities)) in wmi_stop_sched_scan()
3599 return -ENOTSUPP; in wmi_stop_sched_scan()
3601 rc = wmi_call(wil, WMI_STOP_SCHED_SCAN_CMDID, vif->mid, NULL, 0, in wmi_stop_sched_scan()
3610 return -EINVAL; in wmi_stop_sched_scan()
3630 wil_dbg_misc(wil, "mgmt_tx mid %d\n", vif->mid); in wmi_mgmt_tx()
3635 return -EINVAL; in wmi_mgmt_tx()
3640 return -EINVAL; in wmi_mgmt_tx()
3645 return -ENOMEM; in wmi_mgmt_tx()
3647 memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN); in wmi_mgmt_tx()
3648 cmd->len = cpu_to_le16(len); in wmi_mgmt_tx()
3649 memcpy(cmd->payload, buf, len); in wmi_mgmt_tx()
3651 rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, vif->mid, cmd, total, in wmi_mgmt_tx()
3656 rc = -EAGAIN; in wmi_mgmt_tx()
3680 vif->mid, channel, duration_ms); in wmi_mgmt_tx_ext()
3686 return -EINVAL; in wmi_mgmt_tx_ext()
3692 return -EINVAL; in wmi_mgmt_tx_ext()
3697 return -ENOMEM; in wmi_mgmt_tx_ext()
3699 memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN); in wmi_mgmt_tx_ext()
3700 cmd->len = cpu_to_le16(len); in wmi_mgmt_tx_ext()
3701 memcpy(cmd->payload, buf, len); in wmi_mgmt_tx_ext()
3702 cmd->channel = channel - 1; in wmi_mgmt_tx_ext()
3703 cmd->duration_ms = cpu_to_le16(duration_ms); in wmi_mgmt_tx_ext()
3705 rc = wmi_call(wil, WMI_SW_TX_REQ_EXT_CMDID, vif->mid, cmd, total, in wmi_mgmt_tx_ext()
3710 rc = -EAGAIN; in wmi_mgmt_tx_ext()
3721 struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev); in wil_wmi_tx_sring_cfg()
3722 struct wil_status_ring *sring = &wil->srings[ring_id]; in wil_wmi_tx_sring_cfg()
3725 .ring_size = cpu_to_le16(sring->size), in wil_wmi_tx_sring_cfg()
3738 cmd.ring_cfg.ring_mem_base = cpu_to_le64(sring->pa); in wil_wmi_tx_sring_cfg()
3739 rc = wmi_call(wil, WMI_TX_STATUS_RING_ADD_CMDID, vif->mid, &cmd, in wil_wmi_tx_sring_cfg()
3750 return -EINVAL; in wil_wmi_tx_sring_cfg()
3753 sring->hwtail = le32_to_cpu(reply.evt.ring_tail_ptr); in wil_wmi_tx_sring_cfg()
3760 struct net_device *ndev = wil->main_ndev; in wil_wmi_cfg_def_rx_offload()
3777 rc = wmi_call(wil, WMI_CFG_DEF_RX_OFFLOAD_CMDID, vif->mid, &cmd, in wil_wmi_cfg_def_rx_offload()
3788 return -EINVAL; in wil_wmi_cfg_def_rx_offload()
3796 struct net_device *ndev = wil->main_ndev; in wil_wmi_rx_sring_add()
3798 struct wil_status_ring *sring = &wil->srings[ring_id]; in wil_wmi_rx_sring_add()
3802 .ring_size = cpu_to_le16(sring->size), in wil_wmi_rx_sring_add()
3805 .rx_msg_type = wil->use_compressed_rx_status ? in wil_wmi_rx_sring_add()
3817 cmd.ring_cfg.ring_mem_base = cpu_to_le64(sring->pa); in wil_wmi_rx_sring_add()
3818 rc = wmi_call(wil, WMI_RX_STATUS_RING_ADD_CMDID, vif->mid, &cmd, in wil_wmi_rx_sring_add()
3829 return -EINVAL; in wil_wmi_rx_sring_add()
3832 sring->hwtail = le32_to_cpu(reply.evt.ring_tail_ptr); in wil_wmi_rx_sring_add()
3839 struct net_device *ndev = wil->main_ndev; in wil_wmi_rx_desc_ring_add()
3841 struct wil_ring *ring = &wil->ring_rx; in wil_wmi_rx_desc_ring_add()
3845 .ring_size = cpu_to_le16(ring->size), in wil_wmi_rx_desc_ring_add()
3858 cmd.ring_cfg.ring_mem_base = cpu_to_le64(ring->pa); in wil_wmi_rx_desc_ring_add()
3859 cmd.sw_tail_host_addr = cpu_to_le64(ring->edma_rx_swtail.pa); in wil_wmi_rx_desc_ring_add()
3860 rc = wmi_call(wil, WMI_RX_DESC_RING_ADD_CMDID, vif->mid, &cmd, in wil_wmi_rx_desc_ring_add()
3871 return -EINVAL; in wil_wmi_rx_desc_ring_add()
3874 ring->hwtail = le32_to_cpu(reply.evt.ring_tail_ptr); in wil_wmi_rx_desc_ring_add()
3883 int sring_id = wil->tx_sring_idx; /* there is only one TX sring */ in wil_wmi_tx_desc_ring_add()
3885 struct wil_ring *ring = &wil->ring_tx[ring_id]; in wil_wmi_tx_desc_ring_add()
3886 struct wil_ring_tx_data *txdata = &wil->ring_tx_data[ring_id]; in wil_wmi_tx_desc_ring_add()
3889 .ring_size = cpu_to_le16(ring->size), in wil_wmi_tx_desc_ring_add()
3909 cmd.ring_cfg.ring_mem_base = cpu_to_le64(ring->pa); in wil_wmi_tx_desc_ring_add()
3910 rc = wmi_call(wil, WMI_TX_DESC_RING_ADD_CMDID, vif->mid, &cmd, in wil_wmi_tx_desc_ring_add()
3921 return -EINVAL; in wil_wmi_tx_desc_ring_add()
3924 spin_lock_bh(&txdata->lock); in wil_wmi_tx_desc_ring_add()
3925 ring->hwtail = le32_to_cpu(reply.evt.ring_tail_ptr); in wil_wmi_tx_desc_ring_add()
3926 txdata->mid = vif->mid; in wil_wmi_tx_desc_ring_add()
3927 txdata->enabled = 1; in wil_wmi_tx_desc_ring_add()
3928 spin_unlock_bh(&txdata->lock); in wil_wmi_tx_desc_ring_add()
3936 struct wil_ring *ring = &wil->ring_tx[ring_id]; in wil_wmi_bcast_desc_ring_add()
3940 .ring_size = cpu_to_le16(ring->size), in wil_wmi_bcast_desc_ring_add()
3944 .status_ring_id = wil->tx_sring_idx, in wil_wmi_bcast_desc_ring_add()
3953 struct wil_ring_tx_data *txdata = &wil->ring_tx_data[ring_id]; in wil_wmi_bcast_desc_ring_add()
3955 cmd.ring_cfg.ring_mem_base = cpu_to_le64(ring->pa); in wil_wmi_bcast_desc_ring_add()
3956 rc = wmi_call(wil, WMI_BCAST_DESC_RING_ADD_CMDID, vif->mid, &cmd, in wil_wmi_bcast_desc_ring_add()
3967 return -EINVAL; in wil_wmi_bcast_desc_ring_add()
3970 spin_lock_bh(&txdata->lock); in wil_wmi_bcast_desc_ring_add()
3971 ring->hwtail = le32_to_cpu(reply.evt.ring_tail_ptr); in wil_wmi_bcast_desc_ring_add()
3972 txdata->mid = vif->mid; in wil_wmi_bcast_desc_ring_add()
3973 txdata->enabled = 1; in wil_wmi_bcast_desc_ring_add()
3974 spin_unlock_bh(&txdata->lock); in wil_wmi_bcast_desc_ring_add()
3996 rc = wmi_call(wil, WMI_LINK_STATS_CMDID, vif->mid, &cmd, sizeof(cmd), in wmi_link_stats_cfg()
4007 return -EINVAL; in wmi_link_stats_cfg()
4016 struct net_device *ndev = wil->main_ndev; in wmi_set_cqm_rssi_config()
4037 return -EINVAL; in wmi_set_cqm_rssi_config()
4039 rc = wmi_call(wil, WMI_SET_LINK_MONITOR_CMDID, vif->mid, &cmd, in wmi_set_cqm_rssi_config()
4050 return -EINVAL; in wmi_set_cqm_rssi_config()