1 // SPDX-License-Identifier: ISC 2 /* 3 * Copyright (c) 2005-2011 Atheros Communications Inc. 4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc. 5 * Copyright (c) 2018, The Linux Foundation. All rights reserved. 6 */ 7 #include "core.h" 8 #include "debug.h" 9 #include "mac.h" 10 #include "hw.h" 11 #include "wmi.h" 12 #include "wmi-ops.h" 13 #include "wmi-tlv.h" 14 #include "p2p.h" 15 #include "testmode.h" 16 #include <linux/bitfield.h> 17 18 /***************/ 19 /* TLV helpers */ 20 /**************/ 21 22 struct wmi_tlv_policy { 23 size_t min_len; 24 }; 25 26 static const struct wmi_tlv_policy wmi_tlv_policies[] = { 27 [WMI_TLV_TAG_ARRAY_BYTE] 28 = { .min_len = 0 }, 29 [WMI_TLV_TAG_ARRAY_UINT32] 30 = { .min_len = 0 }, 31 [WMI_TLV_TAG_STRUCT_SCAN_EVENT] 32 = { .min_len = sizeof(struct wmi_scan_event) }, 33 [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR] 34 = { .min_len = sizeof(struct wmi_tlv_mgmt_rx_ev) }, 35 [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT] 36 = { .min_len = sizeof(struct wmi_chan_info_event) }, 37 [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT] 38 = { .min_len = sizeof(struct wmi_vdev_start_response_event) }, 39 [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT] 40 = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) }, 41 [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT] 42 = { .min_len = sizeof(struct wmi_host_swba_event) }, 43 [WMI_TLV_TAG_STRUCT_TIM_INFO] 44 = { .min_len = sizeof(struct wmi_tim_info) }, 45 [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO] 46 = { .min_len = sizeof(struct wmi_p2p_noa_info) }, 47 [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT] 48 = { .min_len = sizeof(struct wmi_tlv_svc_rdy_ev) }, 49 [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES] 50 = { .min_len = sizeof(struct hal_reg_capabilities) }, 51 [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ] 52 = { .min_len = sizeof(struct wlan_host_mem_req) }, 53 [WMI_TLV_TAG_STRUCT_READY_EVENT] 54 = { .min_len = sizeof(struct wmi_tlv_rdy_ev) }, 55 [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT] 56 = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) }, 57 [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT] 58 = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) }, 59 [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT] 60 = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) }, 61 [WMI_TLV_TAG_STRUCT_ROAM_EVENT] 62 = { .min_len = sizeof(struct wmi_tlv_roam_ev) }, 63 [WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO] 64 = { .min_len = sizeof(struct wmi_tlv_wow_event_info) }, 65 [WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT] 66 = { .min_len = sizeof(struct wmi_tlv_tx_pause_ev) }, 67 }; 68 69 static int 70 ath10k_wmi_tlv_iter(struct ath10k *ar, const void *ptr, size_t len, 71 int (*iter)(struct ath10k *ar, u16 tag, u16 len, 72 const void *ptr, void *data), 73 void *data) 74 { 75 const void *begin = ptr; 76 const struct wmi_tlv *tlv; 77 u16 tlv_tag, tlv_len; 78 int ret; 79 80 while (len > 0) { 81 if (len < sizeof(*tlv)) { 82 ath10k_dbg(ar, ATH10K_DBG_WMI, 83 "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n", 84 ptr - begin, len, sizeof(*tlv)); 85 return -EINVAL; 86 } 87 88 tlv = ptr; 89 tlv_tag = __le16_to_cpu(tlv->tag); 90 tlv_len = __le16_to_cpu(tlv->len); 91 ptr += sizeof(*tlv); 92 len -= sizeof(*tlv); 93 94 if (tlv_len > len) { 95 ath10k_dbg(ar, ATH10K_DBG_WMI, 96 "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n", 97 tlv_tag, ptr - begin, len, tlv_len); 98 return -EINVAL; 99 } 100 101 if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) && 102 wmi_tlv_policies[tlv_tag].min_len && 103 wmi_tlv_policies[tlv_tag].min_len > tlv_len) { 104 ath10k_dbg(ar, ATH10K_DBG_WMI, 105 "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n", 106 tlv_tag, ptr - begin, tlv_len, 107 wmi_tlv_policies[tlv_tag].min_len); 108 return -EINVAL; 109 } 110 111 ret = iter(ar, tlv_tag, tlv_len, ptr, data); 112 if (ret) 113 return ret; 114 115 ptr += tlv_len; 116 len -= tlv_len; 117 } 118 119 return 0; 120 } 121 122 static int ath10k_wmi_tlv_iter_parse(struct ath10k *ar, u16 tag, u16 len, 123 const void *ptr, void *data) 124 { 125 const void **tb = data; 126 127 if (tag < WMI_TLV_TAG_MAX) 128 tb[tag] = ptr; 129 130 return 0; 131 } 132 133 static int ath10k_wmi_tlv_parse(struct ath10k *ar, const void **tb, 134 const void *ptr, size_t len) 135 { 136 return ath10k_wmi_tlv_iter(ar, ptr, len, ath10k_wmi_tlv_iter_parse, 137 (void *)tb); 138 } 139 140 static const void ** 141 ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr, 142 size_t len, gfp_t gfp) 143 { 144 const void **tb; 145 int ret; 146 147 tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp); 148 if (!tb) 149 return ERR_PTR(-ENOMEM); 150 151 ret = ath10k_wmi_tlv_parse(ar, tb, ptr, len); 152 if (ret) { 153 kfree(tb); 154 return ERR_PTR(ret); 155 } 156 157 return tb; 158 } 159 160 static u16 ath10k_wmi_tlv_len(const void *ptr) 161 { 162 return __le16_to_cpu((((const struct wmi_tlv *)ptr) - 1)->len); 163 } 164 165 /**************/ 166 /* TLV events */ 167 /**************/ 168 static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k *ar, 169 struct sk_buff *skb) 170 { 171 const void **tb; 172 const struct wmi_tlv_bcn_tx_status_ev *ev; 173 struct ath10k_vif *arvif; 174 u32 vdev_id, tx_status; 175 int ret; 176 177 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 178 if (IS_ERR(tb)) { 179 ret = PTR_ERR(tb); 180 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 181 return ret; 182 } 183 184 ev = tb[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT]; 185 if (!ev) { 186 kfree(tb); 187 return -EPROTO; 188 } 189 190 tx_status = __le32_to_cpu(ev->tx_status); 191 vdev_id = __le32_to_cpu(ev->vdev_id); 192 193 switch (tx_status) { 194 case WMI_TLV_BCN_TX_STATUS_OK: 195 break; 196 case WMI_TLV_BCN_TX_STATUS_XRETRY: 197 case WMI_TLV_BCN_TX_STATUS_DROP: 198 case WMI_TLV_BCN_TX_STATUS_FILTERED: 199 /* FIXME: It's probably worth telling mac80211 to stop the 200 * interface as it is crippled. 201 */ 202 ath10k_warn(ar, "received bcn tmpl tx status on vdev %i: %d", 203 vdev_id, tx_status); 204 break; 205 } 206 207 arvif = ath10k_get_arvif(ar, vdev_id); 208 if (arvif && arvif->is_up && arvif->vif->csa_active) 209 ieee80211_queue_work(ar->hw, &arvif->ap_csa_work); 210 211 kfree(tb); 212 return 0; 213 } 214 215 static int ath10k_wmi_tlv_event_diag_data(struct ath10k *ar, 216 struct sk_buff *skb) 217 { 218 const void **tb; 219 const struct wmi_tlv_diag_data_ev *ev; 220 const struct wmi_tlv_diag_item *item; 221 const void *data; 222 int ret, num_items, len; 223 224 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 225 if (IS_ERR(tb)) { 226 ret = PTR_ERR(tb); 227 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 228 return ret; 229 } 230 231 ev = tb[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]; 232 data = tb[WMI_TLV_TAG_ARRAY_BYTE]; 233 if (!ev || !data) { 234 kfree(tb); 235 return -EPROTO; 236 } 237 238 num_items = __le32_to_cpu(ev->num_items); 239 len = ath10k_wmi_tlv_len(data); 240 241 while (num_items--) { 242 if (len == 0) 243 break; 244 if (len < sizeof(*item)) { 245 ath10k_warn(ar, "failed to parse diag data: can't fit item header\n"); 246 break; 247 } 248 249 item = data; 250 251 if (len < sizeof(*item) + __le16_to_cpu(item->len)) { 252 ath10k_warn(ar, "failed to parse diag data: item is too long\n"); 253 break; 254 } 255 256 trace_ath10k_wmi_diag_container(ar, 257 item->type, 258 __le32_to_cpu(item->timestamp), 259 __le32_to_cpu(item->code), 260 __le16_to_cpu(item->len), 261 item->payload); 262 263 len -= sizeof(*item); 264 len -= roundup(__le16_to_cpu(item->len), 4); 265 266 data += sizeof(*item); 267 data += roundup(__le16_to_cpu(item->len), 4); 268 } 269 270 if (num_items != -1 || len != 0) 271 ath10k_warn(ar, "failed to parse diag data event: num_items %d len %d\n", 272 num_items, len); 273 274 kfree(tb); 275 return 0; 276 } 277 278 static int ath10k_wmi_tlv_event_diag(struct ath10k *ar, 279 struct sk_buff *skb) 280 { 281 const void **tb; 282 const void *data; 283 int ret, len; 284 285 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 286 if (IS_ERR(tb)) { 287 ret = PTR_ERR(tb); 288 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 289 return ret; 290 } 291 292 data = tb[WMI_TLV_TAG_ARRAY_BYTE]; 293 if (!data) { 294 kfree(tb); 295 return -EPROTO; 296 } 297 len = ath10k_wmi_tlv_len(data); 298 299 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv diag event len %d\n", len); 300 trace_ath10k_wmi_diag(ar, data, len); 301 302 kfree(tb); 303 return 0; 304 } 305 306 static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar, 307 struct sk_buff *skb) 308 { 309 const void **tb; 310 const struct wmi_tlv_p2p_noa_ev *ev; 311 const struct wmi_p2p_noa_info *noa; 312 int ret, vdev_id; 313 314 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 315 if (IS_ERR(tb)) { 316 ret = PTR_ERR(tb); 317 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 318 return ret; 319 } 320 321 ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]; 322 noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO]; 323 324 if (!ev || !noa) { 325 kfree(tb); 326 return -EPROTO; 327 } 328 329 vdev_id = __le32_to_cpu(ev->vdev_id); 330 331 ath10k_dbg(ar, ATH10K_DBG_WMI, 332 "wmi tlv p2p noa vdev_id %i descriptors %hhu\n", 333 vdev_id, noa->num_descriptors); 334 335 ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa); 336 kfree(tb); 337 return 0; 338 } 339 340 static int ath10k_wmi_tlv_event_tx_pause(struct ath10k *ar, 341 struct sk_buff *skb) 342 { 343 const void **tb; 344 const struct wmi_tlv_tx_pause_ev *ev; 345 int ret, vdev_id; 346 u32 pause_id, action, vdev_map, peer_id, tid_map; 347 348 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 349 if (IS_ERR(tb)) { 350 ret = PTR_ERR(tb); 351 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 352 return ret; 353 } 354 355 ev = tb[WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT]; 356 if (!ev) { 357 kfree(tb); 358 return -EPROTO; 359 } 360 361 pause_id = __le32_to_cpu(ev->pause_id); 362 action = __le32_to_cpu(ev->action); 363 vdev_map = __le32_to_cpu(ev->vdev_map); 364 peer_id = __le32_to_cpu(ev->peer_id); 365 tid_map = __le32_to_cpu(ev->tid_map); 366 367 ath10k_dbg(ar, ATH10K_DBG_WMI, 368 "wmi tlv tx pause pause_id %u action %u vdev_map 0x%08x peer_id %u tid_map 0x%08x\n", 369 pause_id, action, vdev_map, peer_id, tid_map); 370 371 switch (pause_id) { 372 case WMI_TLV_TX_PAUSE_ID_MCC: 373 case WMI_TLV_TX_PAUSE_ID_P2P_CLI_NOA: 374 case WMI_TLV_TX_PAUSE_ID_P2P_GO_PS: 375 case WMI_TLV_TX_PAUSE_ID_AP_PS: 376 case WMI_TLV_TX_PAUSE_ID_IBSS_PS: 377 for (vdev_id = 0; vdev_map; vdev_id++) { 378 if (!(vdev_map & BIT(vdev_id))) 379 continue; 380 381 vdev_map &= ~BIT(vdev_id); 382 ath10k_mac_handle_tx_pause_vdev(ar, vdev_id, pause_id, 383 action); 384 } 385 break; 386 case WMI_TLV_TX_PAUSE_ID_AP_PEER_PS: 387 case WMI_TLV_TX_PAUSE_ID_AP_PEER_UAPSD: 388 case WMI_TLV_TX_PAUSE_ID_STA_ADD_BA: 389 case WMI_TLV_TX_PAUSE_ID_HOST: 390 ath10k_dbg(ar, ATH10K_DBG_MAC, 391 "mac ignoring unsupported tx pause id %d\n", 392 pause_id); 393 break; 394 default: 395 ath10k_dbg(ar, ATH10K_DBG_MAC, 396 "mac ignoring unknown tx pause vdev %d\n", 397 pause_id); 398 break; 399 } 400 401 kfree(tb); 402 return 0; 403 } 404 405 static int ath10k_wmi_tlv_event_temperature(struct ath10k *ar, 406 struct sk_buff *skb) 407 { 408 const struct wmi_tlv_pdev_temperature_event *ev; 409 410 ev = (struct wmi_tlv_pdev_temperature_event *)skb->data; 411 if (WARN_ON(skb->len < sizeof(*ev))) 412 return -EPROTO; 413 414 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature)); 415 return 0; 416 } 417 418 static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb) 419 { 420 struct ieee80211_sta *station; 421 const struct wmi_tlv_tdls_peer_event *ev; 422 const void **tb; 423 struct ath10k_vif *arvif; 424 425 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 426 if (IS_ERR(tb)) { 427 ath10k_warn(ar, "tdls peer failed to parse tlv"); 428 return; 429 } 430 ev = tb[WMI_TLV_TAG_STRUCT_TDLS_PEER_EVENT]; 431 if (!ev) { 432 kfree(tb); 433 ath10k_warn(ar, "tdls peer NULL event"); 434 return; 435 } 436 437 switch (__le32_to_cpu(ev->peer_reason)) { 438 case WMI_TDLS_TEARDOWN_REASON_TX: 439 case WMI_TDLS_TEARDOWN_REASON_RSSI: 440 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT: 441 station = ieee80211_find_sta_by_ifaddr(ar->hw, 442 ev->peer_macaddr.addr, 443 NULL); 444 if (!station) { 445 ath10k_warn(ar, "did not find station from tdls peer event"); 446 kfree(tb); 447 return; 448 } 449 arvif = ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id)); 450 ieee80211_tdls_oper_request( 451 arvif->vif, station->addr, 452 NL80211_TDLS_TEARDOWN, 453 WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE, 454 GFP_ATOMIC 455 ); 456 break; 457 } 458 kfree(tb); 459 } 460 461 /***********/ 462 /* TLV ops */ 463 /***********/ 464 465 static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb) 466 { 467 struct wmi_cmd_hdr *cmd_hdr; 468 enum wmi_tlv_event_id id; 469 bool consumed; 470 471 cmd_hdr = (struct wmi_cmd_hdr *)skb->data; 472 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); 473 474 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) 475 goto out; 476 477 trace_ath10k_wmi_event(ar, id, skb->data, skb->len); 478 479 consumed = ath10k_tm_event_wmi(ar, id, skb); 480 481 /* Ready event must be handled normally also in UTF mode so that we 482 * know the UTF firmware has booted, others we are just bypass WMI 483 * events to testmode. 484 */ 485 if (consumed && id != WMI_TLV_READY_EVENTID) { 486 ath10k_dbg(ar, ATH10K_DBG_WMI, 487 "wmi tlv testmode consumed 0x%x\n", id); 488 goto out; 489 } 490 491 switch (id) { 492 case WMI_TLV_MGMT_RX_EVENTID: 493 ath10k_wmi_event_mgmt_rx(ar, skb); 494 /* mgmt_rx() owns the skb now! */ 495 return; 496 case WMI_TLV_SCAN_EVENTID: 497 ath10k_wmi_event_scan(ar, skb); 498 break; 499 case WMI_TLV_CHAN_INFO_EVENTID: 500 ath10k_wmi_event_chan_info(ar, skb); 501 break; 502 case WMI_TLV_ECHO_EVENTID: 503 ath10k_wmi_event_echo(ar, skb); 504 break; 505 case WMI_TLV_DEBUG_MESG_EVENTID: 506 ath10k_wmi_event_debug_mesg(ar, skb); 507 break; 508 case WMI_TLV_UPDATE_STATS_EVENTID: 509 ath10k_wmi_event_update_stats(ar, skb); 510 break; 511 case WMI_TLV_VDEV_START_RESP_EVENTID: 512 ath10k_wmi_event_vdev_start_resp(ar, skb); 513 break; 514 case WMI_TLV_VDEV_STOPPED_EVENTID: 515 ath10k_wmi_event_vdev_stopped(ar, skb); 516 break; 517 case WMI_TLV_PEER_STA_KICKOUT_EVENTID: 518 ath10k_wmi_event_peer_sta_kickout(ar, skb); 519 break; 520 case WMI_TLV_HOST_SWBA_EVENTID: 521 ath10k_wmi_event_host_swba(ar, skb); 522 break; 523 case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID: 524 ath10k_wmi_event_tbttoffset_update(ar, skb); 525 break; 526 case WMI_TLV_PHYERR_EVENTID: 527 ath10k_wmi_event_phyerr(ar, skb); 528 break; 529 case WMI_TLV_ROAM_EVENTID: 530 ath10k_wmi_event_roam(ar, skb); 531 break; 532 case WMI_TLV_PROFILE_MATCH: 533 ath10k_wmi_event_profile_match(ar, skb); 534 break; 535 case WMI_TLV_DEBUG_PRINT_EVENTID: 536 ath10k_wmi_event_debug_print(ar, skb); 537 break; 538 case WMI_TLV_PDEV_QVIT_EVENTID: 539 ath10k_wmi_event_pdev_qvit(ar, skb); 540 break; 541 case WMI_TLV_WLAN_PROFILE_DATA_EVENTID: 542 ath10k_wmi_event_wlan_profile_data(ar, skb); 543 break; 544 case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID: 545 ath10k_wmi_event_rtt_measurement_report(ar, skb); 546 break; 547 case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID: 548 ath10k_wmi_event_tsf_measurement_report(ar, skb); 549 break; 550 case WMI_TLV_RTT_ERROR_REPORT_EVENTID: 551 ath10k_wmi_event_rtt_error_report(ar, skb); 552 break; 553 case WMI_TLV_WOW_WAKEUP_HOST_EVENTID: 554 ath10k_wmi_event_wow_wakeup_host(ar, skb); 555 break; 556 case WMI_TLV_DCS_INTERFERENCE_EVENTID: 557 ath10k_wmi_event_dcs_interference(ar, skb); 558 break; 559 case WMI_TLV_PDEV_TPC_CONFIG_EVENTID: 560 ath10k_wmi_event_pdev_tpc_config(ar, skb); 561 break; 562 case WMI_TLV_PDEV_FTM_INTG_EVENTID: 563 ath10k_wmi_event_pdev_ftm_intg(ar, skb); 564 break; 565 case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID: 566 ath10k_wmi_event_gtk_offload_status(ar, skb); 567 break; 568 case WMI_TLV_GTK_REKEY_FAIL_EVENTID: 569 ath10k_wmi_event_gtk_rekey_fail(ar, skb); 570 break; 571 case WMI_TLV_TX_DELBA_COMPLETE_EVENTID: 572 ath10k_wmi_event_delba_complete(ar, skb); 573 break; 574 case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID: 575 ath10k_wmi_event_addba_complete(ar, skb); 576 break; 577 case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID: 578 ath10k_wmi_event_vdev_install_key_complete(ar, skb); 579 break; 580 case WMI_TLV_SERVICE_READY_EVENTID: 581 ath10k_wmi_event_service_ready(ar, skb); 582 return; 583 case WMI_TLV_READY_EVENTID: 584 ath10k_wmi_event_ready(ar, skb); 585 break; 586 case WMI_TLV_SERVICE_AVAILABLE_EVENTID: 587 ath10k_wmi_event_service_available(ar, skb); 588 break; 589 case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID: 590 ath10k_wmi_tlv_event_bcn_tx_status(ar, skb); 591 break; 592 case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID: 593 ath10k_wmi_tlv_event_diag_data(ar, skb); 594 break; 595 case WMI_TLV_DIAG_EVENTID: 596 ath10k_wmi_tlv_event_diag(ar, skb); 597 break; 598 case WMI_TLV_P2P_NOA_EVENTID: 599 ath10k_wmi_tlv_event_p2p_noa(ar, skb); 600 break; 601 case WMI_TLV_TX_PAUSE_EVENTID: 602 ath10k_wmi_tlv_event_tx_pause(ar, skb); 603 break; 604 case WMI_TLV_PDEV_TEMPERATURE_EVENTID: 605 ath10k_wmi_tlv_event_temperature(ar, skb); 606 break; 607 case WMI_TLV_TDLS_PEER_EVENTID: 608 ath10k_wmi_event_tdls_peer(ar, skb); 609 break; 610 case WMI_TLV_MGMT_TX_COMPLETION_EVENTID: 611 ath10k_wmi_event_mgmt_tx_compl(ar, skb); 612 break; 613 case WMI_TLV_MGMT_TX_BUNDLE_COMPLETION_EVENTID: 614 ath10k_wmi_event_mgmt_tx_bundle_compl(ar, skb); 615 break; 616 default: 617 ath10k_dbg(ar, ATH10K_DBG_WMI, "Unknown eventid: %d\n", id); 618 break; 619 } 620 621 out: 622 dev_kfree_skb(skb); 623 } 624 625 static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k *ar, 626 struct sk_buff *skb, 627 struct wmi_scan_ev_arg *arg) 628 { 629 const void **tb; 630 const struct wmi_scan_event *ev; 631 int ret; 632 633 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 634 if (IS_ERR(tb)) { 635 ret = PTR_ERR(tb); 636 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 637 return ret; 638 } 639 640 ev = tb[WMI_TLV_TAG_STRUCT_SCAN_EVENT]; 641 if (!ev) { 642 kfree(tb); 643 return -EPROTO; 644 } 645 646 arg->event_type = ev->event_type; 647 arg->reason = ev->reason; 648 arg->channel_freq = ev->channel_freq; 649 arg->scan_req_id = ev->scan_req_id; 650 arg->scan_id = ev->scan_id; 651 arg->vdev_id = ev->vdev_id; 652 653 kfree(tb); 654 return 0; 655 } 656 657 static int 658 ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev(struct ath10k *ar, struct sk_buff *skb, 659 struct wmi_tlv_mgmt_tx_compl_ev_arg *arg) 660 { 661 const void **tb; 662 const struct wmi_tlv_mgmt_tx_compl_ev *ev; 663 int ret; 664 665 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 666 if (IS_ERR(tb)) { 667 ret = PTR_ERR(tb); 668 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 669 return ret; 670 } 671 672 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_EVENT]; 673 674 arg->desc_id = ev->desc_id; 675 arg->status = ev->status; 676 arg->pdev_id = ev->pdev_id; 677 arg->ppdu_id = ev->ppdu_id; 678 679 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map)) 680 arg->ack_rssi = ev->ack_rssi; 681 682 kfree(tb); 683 return 0; 684 } 685 686 struct wmi_tlv_tx_bundle_compl_parse { 687 const __le32 *num_reports; 688 const __le32 *desc_ids; 689 const __le32 *status; 690 const __le32 *ppdu_ids; 691 const __le32 *ack_rssi; 692 bool desc_ids_done; 693 bool status_done; 694 bool ppdu_ids_done; 695 bool ack_rssi_done; 696 }; 697 698 static int 699 ath10k_wmi_tlv_mgmt_tx_bundle_compl_parse(struct ath10k *ar, u16 tag, u16 len, 700 const void *ptr, void *data) 701 { 702 struct wmi_tlv_tx_bundle_compl_parse *bundle_tx_compl = data; 703 704 switch (tag) { 705 case WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_BUNDLE_EVENT: 706 bundle_tx_compl->num_reports = ptr; 707 break; 708 case WMI_TLV_TAG_ARRAY_UINT32: 709 if (!bundle_tx_compl->desc_ids_done) { 710 bundle_tx_compl->desc_ids_done = true; 711 bundle_tx_compl->desc_ids = ptr; 712 } else if (!bundle_tx_compl->status_done) { 713 bundle_tx_compl->status_done = true; 714 bundle_tx_compl->status = ptr; 715 } else if (!bundle_tx_compl->ppdu_ids_done) { 716 bundle_tx_compl->ppdu_ids_done = true; 717 bundle_tx_compl->ppdu_ids = ptr; 718 } else if (!bundle_tx_compl->ack_rssi_done) { 719 bundle_tx_compl->ack_rssi_done = true; 720 bundle_tx_compl->ack_rssi = ptr; 721 } 722 break; 723 default: 724 break; 725 } 726 return 0; 727 } 728 729 static int ath10k_wmi_tlv_op_pull_mgmt_tx_bundle_compl_ev( 730 struct ath10k *ar, struct sk_buff *skb, 731 struct wmi_tlv_mgmt_tx_bundle_compl_ev_arg *arg) 732 { 733 struct wmi_tlv_tx_bundle_compl_parse bundle_tx_compl = { }; 734 int ret; 735 736 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len, 737 ath10k_wmi_tlv_mgmt_tx_bundle_compl_parse, 738 &bundle_tx_compl); 739 if (ret) { 740 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 741 return ret; 742 } 743 744 if (!bundle_tx_compl.num_reports || !bundle_tx_compl.desc_ids || 745 !bundle_tx_compl.status) 746 return -EPROTO; 747 748 arg->num_reports = *bundle_tx_compl.num_reports; 749 arg->desc_ids = bundle_tx_compl.desc_ids; 750 arg->status = bundle_tx_compl.status; 751 arg->ppdu_ids = bundle_tx_compl.ppdu_ids; 752 753 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map)) 754 arg->ack_rssi = bundle_tx_compl.ack_rssi; 755 756 return 0; 757 } 758 759 static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k *ar, 760 struct sk_buff *skb, 761 struct wmi_mgmt_rx_ev_arg *arg) 762 { 763 const void **tb; 764 const struct wmi_tlv_mgmt_rx_ev *ev; 765 const u8 *frame; 766 u32 msdu_len; 767 int ret; 768 769 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 770 if (IS_ERR(tb)) { 771 ret = PTR_ERR(tb); 772 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 773 return ret; 774 } 775 776 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]; 777 frame = tb[WMI_TLV_TAG_ARRAY_BYTE]; 778 779 if (!ev || !frame) { 780 kfree(tb); 781 return -EPROTO; 782 } 783 784 arg->channel = ev->channel; 785 arg->buf_len = ev->buf_len; 786 arg->status = ev->status; 787 arg->snr = ev->snr; 788 arg->phy_mode = ev->phy_mode; 789 arg->rate = ev->rate; 790 791 msdu_len = __le32_to_cpu(arg->buf_len); 792 793 if (skb->len < (frame - skb->data) + msdu_len) { 794 kfree(tb); 795 return -EPROTO; 796 } 797 798 /* shift the sk_buff to point to `frame` */ 799 skb_trim(skb, 0); 800 skb_put(skb, frame - skb->data); 801 skb_pull(skb, frame - skb->data); 802 skb_put(skb, msdu_len); 803 804 kfree(tb); 805 return 0; 806 } 807 808 static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k *ar, 809 struct sk_buff *skb, 810 struct wmi_ch_info_ev_arg *arg) 811 { 812 const void **tb; 813 const struct wmi_chan_info_event *ev; 814 int ret; 815 816 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 817 if (IS_ERR(tb)) { 818 ret = PTR_ERR(tb); 819 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 820 return ret; 821 } 822 823 ev = tb[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT]; 824 if (!ev) { 825 kfree(tb); 826 return -EPROTO; 827 } 828 829 arg->err_code = ev->err_code; 830 arg->freq = ev->freq; 831 arg->cmd_flags = ev->cmd_flags; 832 arg->noise_floor = ev->noise_floor; 833 arg->rx_clear_count = ev->rx_clear_count; 834 arg->cycle_count = ev->cycle_count; 835 if (test_bit(ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL, 836 ar->running_fw->fw_file.fw_features)) 837 arg->mac_clk_mhz = ev->mac_clk_mhz; 838 839 kfree(tb); 840 return 0; 841 } 842 843 static int 844 ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb, 845 struct wmi_vdev_start_ev_arg *arg) 846 { 847 const void **tb; 848 const struct wmi_vdev_start_response_event *ev; 849 int ret; 850 851 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 852 if (IS_ERR(tb)) { 853 ret = PTR_ERR(tb); 854 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 855 return ret; 856 } 857 858 ev = tb[WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT]; 859 if (!ev) { 860 kfree(tb); 861 return -EPROTO; 862 } 863 864 skb_pull(skb, sizeof(*ev)); 865 arg->vdev_id = ev->vdev_id; 866 arg->req_id = ev->req_id; 867 arg->resp_type = ev->resp_type; 868 arg->status = ev->status; 869 870 kfree(tb); 871 return 0; 872 } 873 874 static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k *ar, 875 struct sk_buff *skb, 876 struct wmi_peer_kick_ev_arg *arg) 877 { 878 const void **tb; 879 const struct wmi_peer_sta_kickout_event *ev; 880 int ret; 881 882 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 883 if (IS_ERR(tb)) { 884 ret = PTR_ERR(tb); 885 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 886 return ret; 887 } 888 889 ev = tb[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT]; 890 if (!ev) { 891 kfree(tb); 892 return -EPROTO; 893 } 894 895 arg->mac_addr = ev->peer_macaddr.addr; 896 897 kfree(tb); 898 return 0; 899 } 900 901 struct wmi_tlv_swba_parse { 902 const struct wmi_host_swba_event *ev; 903 bool tim_done; 904 bool noa_done; 905 size_t n_tim; 906 size_t n_noa; 907 struct wmi_swba_ev_arg *arg; 908 }; 909 910 static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k *ar, u16 tag, u16 len, 911 const void *ptr, void *data) 912 { 913 struct wmi_tlv_swba_parse *swba = data; 914 struct wmi_tim_info_arg *tim_info_arg; 915 const struct wmi_tim_info *tim_info_ev = ptr; 916 917 if (tag != WMI_TLV_TAG_STRUCT_TIM_INFO) 918 return -EPROTO; 919 920 if (swba->n_tim >= ARRAY_SIZE(swba->arg->tim_info)) 921 return -ENOBUFS; 922 923 if (__le32_to_cpu(tim_info_ev->tim_len) > 924 sizeof(tim_info_ev->tim_bitmap)) { 925 ath10k_warn(ar, "refusing to parse invalid swba structure\n"); 926 return -EPROTO; 927 } 928 929 tim_info_arg = &swba->arg->tim_info[swba->n_tim]; 930 tim_info_arg->tim_len = tim_info_ev->tim_len; 931 tim_info_arg->tim_mcast = tim_info_ev->tim_mcast; 932 tim_info_arg->tim_bitmap = tim_info_ev->tim_bitmap; 933 tim_info_arg->tim_changed = tim_info_ev->tim_changed; 934 tim_info_arg->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending; 935 936 swba->n_tim++; 937 938 return 0; 939 } 940 941 static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k *ar, u16 tag, u16 len, 942 const void *ptr, void *data) 943 { 944 struct wmi_tlv_swba_parse *swba = data; 945 946 if (tag != WMI_TLV_TAG_STRUCT_P2P_NOA_INFO) 947 return -EPROTO; 948 949 if (swba->n_noa >= ARRAY_SIZE(swba->arg->noa_info)) 950 return -ENOBUFS; 951 952 swba->arg->noa_info[swba->n_noa++] = ptr; 953 return 0; 954 } 955 956 static int ath10k_wmi_tlv_swba_parse(struct ath10k *ar, u16 tag, u16 len, 957 const void *ptr, void *data) 958 { 959 struct wmi_tlv_swba_parse *swba = data; 960 int ret; 961 962 switch (tag) { 963 case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT: 964 swba->ev = ptr; 965 break; 966 case WMI_TLV_TAG_ARRAY_STRUCT: 967 if (!swba->tim_done) { 968 swba->tim_done = true; 969 ret = ath10k_wmi_tlv_iter(ar, ptr, len, 970 ath10k_wmi_tlv_swba_tim_parse, 971 swba); 972 if (ret) 973 return ret; 974 } else if (!swba->noa_done) { 975 swba->noa_done = true; 976 ret = ath10k_wmi_tlv_iter(ar, ptr, len, 977 ath10k_wmi_tlv_swba_noa_parse, 978 swba); 979 if (ret) 980 return ret; 981 } 982 break; 983 default: 984 break; 985 } 986 return 0; 987 } 988 989 static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k *ar, 990 struct sk_buff *skb, 991 struct wmi_swba_ev_arg *arg) 992 { 993 struct wmi_tlv_swba_parse swba = { .arg = arg }; 994 u32 map; 995 size_t n_vdevs; 996 int ret; 997 998 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len, 999 ath10k_wmi_tlv_swba_parse, &swba); 1000 if (ret) { 1001 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1002 return ret; 1003 } 1004 1005 if (!swba.ev) 1006 return -EPROTO; 1007 1008 arg->vdev_map = swba.ev->vdev_map; 1009 1010 for (map = __le32_to_cpu(arg->vdev_map), n_vdevs = 0; map; map >>= 1) 1011 if (map & BIT(0)) 1012 n_vdevs++; 1013 1014 if (n_vdevs != swba.n_tim || 1015 n_vdevs != swba.n_noa) 1016 return -EPROTO; 1017 1018 return 0; 1019 } 1020 1021 static int ath10k_wmi_tlv_op_pull_phyerr_ev_hdr(struct ath10k *ar, 1022 struct sk_buff *skb, 1023 struct wmi_phyerr_hdr_arg *arg) 1024 { 1025 const void **tb; 1026 const struct wmi_tlv_phyerr_ev *ev; 1027 const void *phyerrs; 1028 int ret; 1029 1030 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 1031 if (IS_ERR(tb)) { 1032 ret = PTR_ERR(tb); 1033 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1034 return ret; 1035 } 1036 1037 ev = tb[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR]; 1038 phyerrs = tb[WMI_TLV_TAG_ARRAY_BYTE]; 1039 1040 if (!ev || !phyerrs) { 1041 kfree(tb); 1042 return -EPROTO; 1043 } 1044 1045 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs); 1046 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32); 1047 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32); 1048 arg->buf_len = __le32_to_cpu(ev->buf_len); 1049 arg->phyerrs = phyerrs; 1050 1051 kfree(tb); 1052 return 0; 1053 } 1054 1055 #define WMI_TLV_ABI_VER_NS0 0x5F414351 1056 #define WMI_TLV_ABI_VER_NS1 0x00004C4D 1057 #define WMI_TLV_ABI_VER_NS2 0x00000000 1058 #define WMI_TLV_ABI_VER_NS3 0x00000000 1059 1060 #define WMI_TLV_ABI_VER0_MAJOR 1 1061 #define WMI_TLV_ABI_VER0_MINOR 0 1062 #define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \ 1063 (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF)) 1064 #define WMI_TLV_ABI_VER1 53 1065 1066 static int 1067 ath10k_wmi_tlv_parse_mem_reqs(struct ath10k *ar, u16 tag, u16 len, 1068 const void *ptr, void *data) 1069 { 1070 struct wmi_svc_rdy_ev_arg *arg = data; 1071 int i; 1072 1073 if (tag != WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ) 1074 return -EPROTO; 1075 1076 for (i = 0; i < ARRAY_SIZE(arg->mem_reqs); i++) { 1077 if (!arg->mem_reqs[i]) { 1078 arg->mem_reqs[i] = ptr; 1079 return 0; 1080 } 1081 } 1082 1083 return -ENOMEM; 1084 } 1085 1086 struct wmi_tlv_svc_rdy_parse { 1087 const struct hal_reg_capabilities *reg; 1088 const struct wmi_tlv_svc_rdy_ev *ev; 1089 const __le32 *svc_bmap; 1090 const struct wlan_host_mem_req *mem_reqs; 1091 bool svc_bmap_done; 1092 bool dbs_hw_mode_done; 1093 }; 1094 1095 static int ath10k_wmi_tlv_svc_rdy_parse(struct ath10k *ar, u16 tag, u16 len, 1096 const void *ptr, void *data) 1097 { 1098 struct wmi_tlv_svc_rdy_parse *svc_rdy = data; 1099 1100 switch (tag) { 1101 case WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT: 1102 svc_rdy->ev = ptr; 1103 break; 1104 case WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES: 1105 svc_rdy->reg = ptr; 1106 break; 1107 case WMI_TLV_TAG_ARRAY_STRUCT: 1108 svc_rdy->mem_reqs = ptr; 1109 break; 1110 case WMI_TLV_TAG_ARRAY_UINT32: 1111 if (!svc_rdy->svc_bmap_done) { 1112 svc_rdy->svc_bmap_done = true; 1113 svc_rdy->svc_bmap = ptr; 1114 } else if (!svc_rdy->dbs_hw_mode_done) { 1115 svc_rdy->dbs_hw_mode_done = true; 1116 } 1117 break; 1118 default: 1119 break; 1120 } 1121 return 0; 1122 } 1123 1124 static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k *ar, 1125 struct sk_buff *skb, 1126 struct wmi_svc_rdy_ev_arg *arg) 1127 { 1128 const struct hal_reg_capabilities *reg; 1129 const struct wmi_tlv_svc_rdy_ev *ev; 1130 const __le32 *svc_bmap; 1131 const struct wlan_host_mem_req *mem_reqs; 1132 struct wmi_tlv_svc_rdy_parse svc_rdy = { }; 1133 int ret; 1134 1135 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len, 1136 ath10k_wmi_tlv_svc_rdy_parse, &svc_rdy); 1137 if (ret) { 1138 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1139 return ret; 1140 } 1141 1142 ev = svc_rdy.ev; 1143 reg = svc_rdy.reg; 1144 svc_bmap = svc_rdy.svc_bmap; 1145 mem_reqs = svc_rdy.mem_reqs; 1146 1147 if (!ev || !reg || !svc_bmap || !mem_reqs) 1148 return -EPROTO; 1149 1150 /* This is an internal ABI compatibility check for WMI TLV so check it 1151 * here instead of the generic WMI code. 1152 */ 1153 ath10k_dbg(ar, ATH10K_DBG_WMI, 1154 "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n", 1155 __le32_to_cpu(ev->abi.abi_ver0), WMI_TLV_ABI_VER0, 1156 __le32_to_cpu(ev->abi.abi_ver_ns0), WMI_TLV_ABI_VER_NS0, 1157 __le32_to_cpu(ev->abi.abi_ver_ns1), WMI_TLV_ABI_VER_NS1, 1158 __le32_to_cpu(ev->abi.abi_ver_ns2), WMI_TLV_ABI_VER_NS2, 1159 __le32_to_cpu(ev->abi.abi_ver_ns3), WMI_TLV_ABI_VER_NS3); 1160 1161 if (__le32_to_cpu(ev->abi.abi_ver0) != WMI_TLV_ABI_VER0 || 1162 __le32_to_cpu(ev->abi.abi_ver_ns0) != WMI_TLV_ABI_VER_NS0 || 1163 __le32_to_cpu(ev->abi.abi_ver_ns1) != WMI_TLV_ABI_VER_NS1 || 1164 __le32_to_cpu(ev->abi.abi_ver_ns2) != WMI_TLV_ABI_VER_NS2 || 1165 __le32_to_cpu(ev->abi.abi_ver_ns3) != WMI_TLV_ABI_VER_NS3) { 1166 return -ENOTSUPP; 1167 } 1168 1169 arg->min_tx_power = ev->hw_min_tx_power; 1170 arg->max_tx_power = ev->hw_max_tx_power; 1171 arg->ht_cap = ev->ht_cap_info; 1172 arg->vht_cap = ev->vht_cap_info; 1173 arg->sw_ver0 = ev->abi.abi_ver0; 1174 arg->sw_ver1 = ev->abi.abi_ver1; 1175 arg->fw_build = ev->fw_build_vers; 1176 arg->phy_capab = ev->phy_capability; 1177 arg->num_rf_chains = ev->num_rf_chains; 1178 arg->eeprom_rd = reg->eeprom_rd; 1179 arg->low_5ghz_chan = reg->low_5ghz_chan; 1180 arg->high_5ghz_chan = reg->high_5ghz_chan; 1181 arg->num_mem_reqs = ev->num_mem_reqs; 1182 arg->service_map = svc_bmap; 1183 arg->service_map_len = ath10k_wmi_tlv_len(svc_bmap); 1184 1185 ret = ath10k_wmi_tlv_iter(ar, mem_reqs, ath10k_wmi_tlv_len(mem_reqs), 1186 ath10k_wmi_tlv_parse_mem_reqs, arg); 1187 if (ret) { 1188 ath10k_warn(ar, "failed to parse mem_reqs tlv: %d\n", ret); 1189 return ret; 1190 } 1191 1192 return 0; 1193 } 1194 1195 static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k *ar, 1196 struct sk_buff *skb, 1197 struct wmi_rdy_ev_arg *arg) 1198 { 1199 const void **tb; 1200 const struct wmi_tlv_rdy_ev *ev; 1201 int ret; 1202 1203 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 1204 if (IS_ERR(tb)) { 1205 ret = PTR_ERR(tb); 1206 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1207 return ret; 1208 } 1209 1210 ev = tb[WMI_TLV_TAG_STRUCT_READY_EVENT]; 1211 if (!ev) { 1212 kfree(tb); 1213 return -EPROTO; 1214 } 1215 1216 arg->sw_version = ev->abi.abi_ver0; 1217 arg->abi_version = ev->abi.abi_ver1; 1218 arg->status = ev->status; 1219 arg->mac_addr = ev->mac_addr.addr; 1220 1221 kfree(tb); 1222 return 0; 1223 } 1224 1225 static int ath10k_wmi_tlv_svc_avail_parse(struct ath10k *ar, u16 tag, u16 len, 1226 const void *ptr, void *data) 1227 { 1228 struct wmi_svc_avail_ev_arg *arg = data; 1229 1230 switch (tag) { 1231 case WMI_TLV_TAG_STRUCT_SERVICE_AVAILABLE_EVENT: 1232 arg->service_map_ext_len = *(__le32 *)ptr; 1233 arg->service_map_ext = ptr + sizeof(__le32); 1234 return 0; 1235 default: 1236 break; 1237 } 1238 return -EPROTO; 1239 } 1240 1241 static int ath10k_wmi_tlv_op_pull_svc_avail(struct ath10k *ar, 1242 struct sk_buff *skb, 1243 struct wmi_svc_avail_ev_arg *arg) 1244 { 1245 int ret; 1246 1247 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len, 1248 ath10k_wmi_tlv_svc_avail_parse, arg); 1249 1250 if (ret) { 1251 ath10k_warn(ar, "failed to parse svc_avail tlv: %d\n", ret); 1252 return ret; 1253 } 1254 1255 return 0; 1256 } 1257 1258 static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats *src, 1259 struct ath10k_fw_stats_vdev *dst) 1260 { 1261 int i; 1262 1263 dst->vdev_id = __le32_to_cpu(src->vdev_id); 1264 dst->beacon_snr = __le32_to_cpu(src->beacon_snr); 1265 dst->data_snr = __le32_to_cpu(src->data_snr); 1266 dst->num_rx_frames = __le32_to_cpu(src->num_rx_frames); 1267 dst->num_rts_fail = __le32_to_cpu(src->num_rts_fail); 1268 dst->num_rts_success = __le32_to_cpu(src->num_rts_success); 1269 dst->num_rx_err = __le32_to_cpu(src->num_rx_err); 1270 dst->num_rx_discard = __le32_to_cpu(src->num_rx_discard); 1271 dst->num_tx_not_acked = __le32_to_cpu(src->num_tx_not_acked); 1272 1273 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++) 1274 dst->num_tx_frames[i] = 1275 __le32_to_cpu(src->num_tx_frames[i]); 1276 1277 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++) 1278 dst->num_tx_frames_retries[i] = 1279 __le32_to_cpu(src->num_tx_frames_retries[i]); 1280 1281 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++) 1282 dst->num_tx_frames_failures[i] = 1283 __le32_to_cpu(src->num_tx_frames_failures[i]); 1284 1285 for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++) 1286 dst->tx_rate_history[i] = 1287 __le32_to_cpu(src->tx_rate_history[i]); 1288 1289 for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++) 1290 dst->beacon_rssi_history[i] = 1291 __le32_to_cpu(src->beacon_rssi_history[i]); 1292 } 1293 1294 static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar, 1295 struct sk_buff *skb, 1296 struct ath10k_fw_stats *stats) 1297 { 1298 const void **tb; 1299 const struct wmi_tlv_stats_ev *ev; 1300 u32 num_peer_stats_extd; 1301 const void *data; 1302 u32 num_pdev_stats; 1303 u32 num_vdev_stats; 1304 u32 num_peer_stats; 1305 u32 num_bcnflt_stats; 1306 u32 num_chan_stats; 1307 size_t data_len; 1308 u32 stats_id; 1309 int ret; 1310 int i; 1311 1312 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 1313 if (IS_ERR(tb)) { 1314 ret = PTR_ERR(tb); 1315 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1316 return ret; 1317 } 1318 1319 ev = tb[WMI_TLV_TAG_STRUCT_STATS_EVENT]; 1320 data = tb[WMI_TLV_TAG_ARRAY_BYTE]; 1321 1322 if (!ev || !data) { 1323 kfree(tb); 1324 return -EPROTO; 1325 } 1326 1327 data_len = ath10k_wmi_tlv_len(data); 1328 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats); 1329 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats); 1330 num_peer_stats = __le32_to_cpu(ev->num_peer_stats); 1331 num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats); 1332 num_chan_stats = __le32_to_cpu(ev->num_chan_stats); 1333 stats_id = __le32_to_cpu(ev->stats_id); 1334 num_peer_stats_extd = __le32_to_cpu(ev->num_peer_stats_extd); 1335 1336 ath10k_dbg(ar, ATH10K_DBG_WMI, 1337 "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i peer_extd %i\n", 1338 num_pdev_stats, num_vdev_stats, num_peer_stats, 1339 num_bcnflt_stats, num_chan_stats, num_peer_stats_extd); 1340 1341 for (i = 0; i < num_pdev_stats; i++) { 1342 const struct wmi_pdev_stats *src; 1343 struct ath10k_fw_stats_pdev *dst; 1344 1345 src = data; 1346 if (data_len < sizeof(*src)) { 1347 kfree(tb); 1348 return -EPROTO; 1349 } 1350 1351 data += sizeof(*src); 1352 data_len -= sizeof(*src); 1353 1354 dst = kzalloc(sizeof(*dst), GFP_ATOMIC); 1355 if (!dst) 1356 continue; 1357 1358 ath10k_wmi_pull_pdev_stats_base(&src->base, dst); 1359 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst); 1360 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst); 1361 list_add_tail(&dst->list, &stats->pdevs); 1362 } 1363 1364 for (i = 0; i < num_vdev_stats; i++) { 1365 const struct wmi_tlv_vdev_stats *src; 1366 struct ath10k_fw_stats_vdev *dst; 1367 1368 src = data; 1369 if (data_len < sizeof(*src)) { 1370 kfree(tb); 1371 return -EPROTO; 1372 } 1373 1374 data += sizeof(*src); 1375 data_len -= sizeof(*src); 1376 1377 dst = kzalloc(sizeof(*dst), GFP_ATOMIC); 1378 if (!dst) 1379 continue; 1380 1381 ath10k_wmi_tlv_pull_vdev_stats(src, dst); 1382 list_add_tail(&dst->list, &stats->vdevs); 1383 } 1384 1385 for (i = 0; i < num_peer_stats; i++) { 1386 const struct wmi_10x_peer_stats *src; 1387 struct ath10k_fw_stats_peer *dst; 1388 1389 src = data; 1390 if (data_len < sizeof(*src)) { 1391 kfree(tb); 1392 return -EPROTO; 1393 } 1394 1395 data += sizeof(*src); 1396 data_len -= sizeof(*src); 1397 1398 dst = kzalloc(sizeof(*dst), GFP_ATOMIC); 1399 if (!dst) 1400 continue; 1401 1402 ath10k_wmi_pull_peer_stats(&src->old, dst); 1403 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate); 1404 1405 if (stats_id & WMI_TLV_STAT_PEER_EXTD) { 1406 const struct wmi_tlv_peer_stats_extd *extd; 1407 unsigned long rx_duration_high; 1408 1409 extd = data + sizeof(*src) * (num_peer_stats - i - 1) 1410 + sizeof(*extd) * i; 1411 1412 dst->rx_duration = __le32_to_cpu(extd->rx_duration); 1413 rx_duration_high = __le32_to_cpu 1414 (extd->rx_duration_high); 1415 1416 if (test_bit(WMI_TLV_PEER_RX_DURATION_HIGH_VALID_BIT, 1417 &rx_duration_high)) { 1418 rx_duration_high = 1419 FIELD_GET(WMI_TLV_PEER_RX_DURATION_HIGH_MASK, 1420 rx_duration_high); 1421 dst->rx_duration |= (u64)rx_duration_high << 1422 WMI_TLV_PEER_RX_DURATION_SHIFT; 1423 } 1424 } 1425 1426 list_add_tail(&dst->list, &stats->peers); 1427 } 1428 1429 kfree(tb); 1430 return 0; 1431 } 1432 1433 static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k *ar, 1434 struct sk_buff *skb, 1435 struct wmi_roam_ev_arg *arg) 1436 { 1437 const void **tb; 1438 const struct wmi_tlv_roam_ev *ev; 1439 int ret; 1440 1441 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 1442 if (IS_ERR(tb)) { 1443 ret = PTR_ERR(tb); 1444 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1445 return ret; 1446 } 1447 1448 ev = tb[WMI_TLV_TAG_STRUCT_ROAM_EVENT]; 1449 if (!ev) { 1450 kfree(tb); 1451 return -EPROTO; 1452 } 1453 1454 arg->vdev_id = ev->vdev_id; 1455 arg->reason = ev->reason; 1456 arg->rssi = ev->rssi; 1457 1458 kfree(tb); 1459 return 0; 1460 } 1461 1462 static int 1463 ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k *ar, struct sk_buff *skb, 1464 struct wmi_wow_ev_arg *arg) 1465 { 1466 const void **tb; 1467 const struct wmi_tlv_wow_event_info *ev; 1468 int ret; 1469 1470 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 1471 if (IS_ERR(tb)) { 1472 ret = PTR_ERR(tb); 1473 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1474 return ret; 1475 } 1476 1477 ev = tb[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO]; 1478 if (!ev) { 1479 kfree(tb); 1480 return -EPROTO; 1481 } 1482 1483 arg->vdev_id = __le32_to_cpu(ev->vdev_id); 1484 arg->flag = __le32_to_cpu(ev->flag); 1485 arg->wake_reason = __le32_to_cpu(ev->wake_reason); 1486 arg->data_len = __le32_to_cpu(ev->data_len); 1487 1488 kfree(tb); 1489 return 0; 1490 } 1491 1492 static int ath10k_wmi_tlv_op_pull_echo_ev(struct ath10k *ar, 1493 struct sk_buff *skb, 1494 struct wmi_echo_ev_arg *arg) 1495 { 1496 const void **tb; 1497 const struct wmi_echo_event *ev; 1498 int ret; 1499 1500 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC); 1501 if (IS_ERR(tb)) { 1502 ret = PTR_ERR(tb); 1503 ath10k_warn(ar, "failed to parse tlv: %d\n", ret); 1504 return ret; 1505 } 1506 1507 ev = tb[WMI_TLV_TAG_STRUCT_ECHO_EVENT]; 1508 if (!ev) { 1509 kfree(tb); 1510 return -EPROTO; 1511 } 1512 1513 arg->value = ev->value; 1514 1515 kfree(tb); 1516 return 0; 1517 } 1518 1519 static struct sk_buff * 1520 ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt) 1521 { 1522 struct wmi_tlv_pdev_suspend *cmd; 1523 struct wmi_tlv *tlv; 1524 struct sk_buff *skb; 1525 1526 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1527 if (!skb) 1528 return ERR_PTR(-ENOMEM); 1529 1530 tlv = (void *)skb->data; 1531 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD); 1532 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1533 cmd = (void *)tlv->value; 1534 cmd->opt = __cpu_to_le32(opt); 1535 1536 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev suspend\n"); 1537 return skb; 1538 } 1539 1540 static struct sk_buff * 1541 ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k *ar) 1542 { 1543 struct wmi_tlv_resume_cmd *cmd; 1544 struct wmi_tlv *tlv; 1545 struct sk_buff *skb; 1546 1547 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1548 if (!skb) 1549 return ERR_PTR(-ENOMEM); 1550 1551 tlv = (void *)skb->data; 1552 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD); 1553 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1554 cmd = (void *)tlv->value; 1555 cmd->reserved = __cpu_to_le32(0); 1556 1557 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev resume\n"); 1558 return skb; 1559 } 1560 1561 static struct sk_buff * 1562 ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k *ar, 1563 u16 rd, u16 rd2g, u16 rd5g, 1564 u16 ctl2g, u16 ctl5g, 1565 enum wmi_dfs_region dfs_reg) 1566 { 1567 struct wmi_tlv_pdev_set_rd_cmd *cmd; 1568 struct wmi_tlv *tlv; 1569 struct sk_buff *skb; 1570 1571 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1572 if (!skb) 1573 return ERR_PTR(-ENOMEM); 1574 1575 tlv = (void *)skb->data; 1576 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD); 1577 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1578 cmd = (void *)tlv->value; 1579 cmd->regd = __cpu_to_le32(rd); 1580 cmd->regd_2ghz = __cpu_to_le32(rd2g); 1581 cmd->regd_5ghz = __cpu_to_le32(rd5g); 1582 cmd->conform_limit_2ghz = __cpu_to_le32(ctl2g); 1583 cmd->conform_limit_5ghz = __cpu_to_le32(ctl5g); 1584 1585 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set rd\n"); 1586 return skb; 1587 } 1588 1589 static enum wmi_txbf_conf ath10k_wmi_tlv_txbf_conf_scheme(struct ath10k *ar) 1590 { 1591 return WMI_TXBF_CONF_AFTER_ASSOC; 1592 } 1593 1594 static struct sk_buff * 1595 ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k *ar, u32 param_id, 1596 u32 param_value) 1597 { 1598 struct wmi_tlv_pdev_set_param_cmd *cmd; 1599 struct wmi_tlv *tlv; 1600 struct sk_buff *skb; 1601 1602 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1603 if (!skb) 1604 return ERR_PTR(-ENOMEM); 1605 1606 tlv = (void *)skb->data; 1607 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD); 1608 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1609 cmd = (void *)tlv->value; 1610 cmd->param_id = __cpu_to_le32(param_id); 1611 cmd->param_value = __cpu_to_le32(param_value); 1612 1613 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set param %d value 0x%x\n", 1614 param_id, param_value); 1615 return skb; 1616 } 1617 1618 static void 1619 ath10k_wmi_tlv_put_host_mem_chunks(struct ath10k *ar, void *host_mem_chunks) 1620 { 1621 struct host_memory_chunk *chunk; 1622 struct wmi_tlv *tlv; 1623 int i; 1624 __le16 tlv_len, tlv_tag; 1625 1626 tlv_tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WLAN_HOST_MEMORY_CHUNK); 1627 tlv_len = __cpu_to_le16(sizeof(*chunk)); 1628 for (i = 0; i < ar->wmi.num_mem_chunks; i++) { 1629 tlv = host_mem_chunks; 1630 tlv->tag = tlv_tag; 1631 tlv->len = tlv_len; 1632 chunk = (void *)tlv->value; 1633 1634 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); 1635 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len); 1636 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); 1637 1638 ath10k_dbg(ar, ATH10K_DBG_WMI, 1639 "wmi-tlv chunk %d len %d, addr 0x%llx, id 0x%x\n", 1640 i, 1641 ar->wmi.mem_chunks[i].len, 1642 (unsigned long long)ar->wmi.mem_chunks[i].paddr, 1643 ar->wmi.mem_chunks[i].req_id); 1644 1645 host_mem_chunks += sizeof(*tlv); 1646 host_mem_chunks += sizeof(*chunk); 1647 } 1648 } 1649 1650 static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar) 1651 { 1652 struct sk_buff *skb; 1653 struct wmi_tlv *tlv; 1654 struct wmi_tlv_init_cmd *cmd; 1655 struct wmi_tlv_resource_config *cfg; 1656 void *chunks; 1657 size_t len, chunks_len; 1658 void *ptr; 1659 1660 chunks_len = ar->wmi.num_mem_chunks * 1661 (sizeof(struct host_memory_chunk) + sizeof(*tlv)); 1662 len = (sizeof(*tlv) + sizeof(*cmd)) + 1663 (sizeof(*tlv) + sizeof(*cfg)) + 1664 (sizeof(*tlv) + chunks_len); 1665 1666 skb = ath10k_wmi_alloc_skb(ar, len); 1667 if (!skb) 1668 return ERR_PTR(-ENOMEM); 1669 1670 ptr = skb->data; 1671 1672 tlv = ptr; 1673 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD); 1674 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1675 cmd = (void *)tlv->value; 1676 ptr += sizeof(*tlv); 1677 ptr += sizeof(*cmd); 1678 1679 tlv = ptr; 1680 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG); 1681 tlv->len = __cpu_to_le16(sizeof(*cfg)); 1682 cfg = (void *)tlv->value; 1683 ptr += sizeof(*tlv); 1684 ptr += sizeof(*cfg); 1685 1686 tlv = ptr; 1687 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 1688 tlv->len = __cpu_to_le16(chunks_len); 1689 chunks = (void *)tlv->value; 1690 1691 ptr += sizeof(*tlv); 1692 ptr += chunks_len; 1693 1694 cmd->abi.abi_ver0 = __cpu_to_le32(WMI_TLV_ABI_VER0); 1695 cmd->abi.abi_ver1 = __cpu_to_le32(WMI_TLV_ABI_VER1); 1696 cmd->abi.abi_ver_ns0 = __cpu_to_le32(WMI_TLV_ABI_VER_NS0); 1697 cmd->abi.abi_ver_ns1 = __cpu_to_le32(WMI_TLV_ABI_VER_NS1); 1698 cmd->abi.abi_ver_ns2 = __cpu_to_le32(WMI_TLV_ABI_VER_NS2); 1699 cmd->abi.abi_ver_ns3 = __cpu_to_le32(WMI_TLV_ABI_VER_NS3); 1700 cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks); 1701 1702 cfg->num_vdevs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS); 1703 1704 if (ar->hw_params.num_peers) 1705 cfg->num_peers = __cpu_to_le32(ar->hw_params.num_peers); 1706 else 1707 cfg->num_peers = __cpu_to_le32(TARGET_TLV_NUM_PEERS); 1708 cfg->ast_skid_limit = __cpu_to_le32(ar->hw_params.ast_skid_limit); 1709 cfg->num_wds_entries = __cpu_to_le32(ar->hw_params.num_wds_entries); 1710 1711 if (test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)) { 1712 cfg->num_offload_peers = __cpu_to_le32(TARGET_TLV_NUM_VDEVS); 1713 cfg->num_offload_reorder_bufs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS); 1714 } else { 1715 cfg->num_offload_peers = __cpu_to_le32(0); 1716 cfg->num_offload_reorder_bufs = __cpu_to_le32(0); 1717 } 1718 1719 cfg->num_peer_keys = __cpu_to_le32(2); 1720 if (ar->hw_params.num_peers) 1721 cfg->num_tids = __cpu_to_le32(ar->hw_params.num_peers * 2); 1722 else 1723 cfg->num_tids = __cpu_to_le32(TARGET_TLV_NUM_TIDS); 1724 cfg->tx_chain_mask = __cpu_to_le32(0x7); 1725 cfg->rx_chain_mask = __cpu_to_le32(0x7); 1726 cfg->rx_timeout_pri[0] = __cpu_to_le32(0x64); 1727 cfg->rx_timeout_pri[1] = __cpu_to_le32(0x64); 1728 cfg->rx_timeout_pri[2] = __cpu_to_le32(0x64); 1729 cfg->rx_timeout_pri[3] = __cpu_to_le32(0x28); 1730 cfg->rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode); 1731 cfg->scan_max_pending_reqs = __cpu_to_le32(4); 1732 cfg->bmiss_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS); 1733 cfg->roam_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS); 1734 cfg->roam_offload_max_ap_profiles = __cpu_to_le32(8); 1735 cfg->num_mcast_groups = __cpu_to_le32(0); 1736 cfg->num_mcast_table_elems = __cpu_to_le32(0); 1737 cfg->mcast2ucast_mode = __cpu_to_le32(0); 1738 cfg->tx_dbg_log_size = __cpu_to_le32(0x400); 1739 cfg->dma_burst_size = __cpu_to_le32(0); 1740 cfg->mac_aggr_delim = __cpu_to_le32(0); 1741 cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0); 1742 cfg->vow_config = __cpu_to_le32(0); 1743 cfg->gtk_offload_max_vdev = __cpu_to_le32(2); 1744 cfg->num_msdu_desc = __cpu_to_le32(ar->htt.max_num_pending_tx); 1745 cfg->max_frag_entries = __cpu_to_le32(2); 1746 cfg->num_tdls_vdevs = __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS); 1747 cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20); 1748 cfg->beacon_tx_offload_max_vdev = __cpu_to_le32(2); 1749 cfg->num_multicast_filter_entries = __cpu_to_le32(5); 1750 cfg->num_wow_filters = __cpu_to_le32(ar->wow.max_num_patterns); 1751 cfg->num_keep_alive_pattern = __cpu_to_le32(6); 1752 cfg->keep_alive_pattern_size = __cpu_to_le32(0); 1753 cfg->max_tdls_concurrent_sleep_sta = __cpu_to_le32(1); 1754 cfg->max_tdls_concurrent_buffer_sta = __cpu_to_le32(1); 1755 cfg->wmi_send_separate = __cpu_to_le32(0); 1756 cfg->num_ocb_vdevs = __cpu_to_le32(0); 1757 cfg->num_ocb_channels = __cpu_to_le32(0); 1758 cfg->num_ocb_schedules = __cpu_to_le32(0); 1759 cfg->host_capab = __cpu_to_le32(WMI_TLV_FLAG_MGMT_BUNDLE_TX_COMPL); 1760 1761 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map)) 1762 cfg->host_capab |= __cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_ACK_RSSI); 1763 1764 ath10k_wmi_tlv_put_host_mem_chunks(ar, chunks); 1765 1766 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n"); 1767 return skb; 1768 } 1769 1770 static struct sk_buff * 1771 ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar, 1772 const struct wmi_start_scan_arg *arg) 1773 { 1774 struct wmi_tlv_start_scan_cmd *cmd; 1775 struct wmi_tlv *tlv; 1776 struct sk_buff *skb; 1777 size_t len, chan_len, ssid_len, bssid_len, ie_len; 1778 __le32 *chans; 1779 struct wmi_ssid *ssids; 1780 struct wmi_mac_addr *addrs; 1781 void *ptr; 1782 int i, ret; 1783 1784 ret = ath10k_wmi_start_scan_verify(arg); 1785 if (ret) 1786 return ERR_PTR(ret); 1787 1788 chan_len = arg->n_channels * sizeof(__le32); 1789 ssid_len = arg->n_ssids * sizeof(struct wmi_ssid); 1790 bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr); 1791 ie_len = roundup(arg->ie_len, 4); 1792 len = (sizeof(*tlv) + sizeof(*cmd)) + 1793 sizeof(*tlv) + chan_len + 1794 sizeof(*tlv) + ssid_len + 1795 sizeof(*tlv) + bssid_len + 1796 sizeof(*tlv) + ie_len; 1797 1798 skb = ath10k_wmi_alloc_skb(ar, len); 1799 if (!skb) 1800 return ERR_PTR(-ENOMEM); 1801 1802 ptr = (void *)skb->data; 1803 tlv = ptr; 1804 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD); 1805 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1806 cmd = (void *)tlv->value; 1807 1808 ath10k_wmi_put_start_scan_common(&cmd->common, arg); 1809 cmd->burst_duration_ms = __cpu_to_le32(arg->burst_duration_ms); 1810 cmd->num_channels = __cpu_to_le32(arg->n_channels); 1811 cmd->num_ssids = __cpu_to_le32(arg->n_ssids); 1812 cmd->num_bssids = __cpu_to_le32(arg->n_bssids); 1813 cmd->ie_len = __cpu_to_le32(arg->ie_len); 1814 cmd->num_probes = __cpu_to_le32(3); 1815 ether_addr_copy(cmd->mac_addr.addr, arg->mac_addr.addr); 1816 ether_addr_copy(cmd->mac_mask.addr, arg->mac_mask.addr); 1817 1818 /* FIXME: There are some scan flag inconsistencies across firmwares, 1819 * e.g. WMI-TLV inverts the logic behind the following flag. 1820 */ 1821 cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ); 1822 1823 ptr += sizeof(*tlv); 1824 ptr += sizeof(*cmd); 1825 1826 tlv = ptr; 1827 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32); 1828 tlv->len = __cpu_to_le16(chan_len); 1829 chans = (void *)tlv->value; 1830 for (i = 0; i < arg->n_channels; i++) 1831 chans[i] = __cpu_to_le32(arg->channels[i]); 1832 1833 ptr += sizeof(*tlv); 1834 ptr += chan_len; 1835 1836 tlv = ptr; 1837 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT); 1838 tlv->len = __cpu_to_le16(ssid_len); 1839 ssids = (void *)tlv->value; 1840 for (i = 0; i < arg->n_ssids; i++) { 1841 ssids[i].ssid_len = __cpu_to_le32(arg->ssids[i].len); 1842 memcpy(ssids[i].ssid, arg->ssids[i].ssid, arg->ssids[i].len); 1843 } 1844 1845 ptr += sizeof(*tlv); 1846 ptr += ssid_len; 1847 1848 tlv = ptr; 1849 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT); 1850 tlv->len = __cpu_to_le16(bssid_len); 1851 addrs = (void *)tlv->value; 1852 for (i = 0; i < arg->n_bssids; i++) 1853 ether_addr_copy(addrs[i].addr, arg->bssids[i].bssid); 1854 1855 ptr += sizeof(*tlv); 1856 ptr += bssid_len; 1857 1858 tlv = ptr; 1859 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 1860 tlv->len = __cpu_to_le16(ie_len); 1861 memcpy(tlv->value, arg->ie, arg->ie_len); 1862 1863 ptr += sizeof(*tlv); 1864 ptr += ie_len; 1865 1866 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n"); 1867 return skb; 1868 } 1869 1870 static struct sk_buff * 1871 ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k *ar, 1872 const struct wmi_stop_scan_arg *arg) 1873 { 1874 struct wmi_stop_scan_cmd *cmd; 1875 struct wmi_tlv *tlv; 1876 struct sk_buff *skb; 1877 u32 scan_id; 1878 u32 req_id; 1879 1880 if (arg->req_id > 0xFFF) 1881 return ERR_PTR(-EINVAL); 1882 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF) 1883 return ERR_PTR(-EINVAL); 1884 1885 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1886 if (!skb) 1887 return ERR_PTR(-ENOMEM); 1888 1889 scan_id = arg->u.scan_id; 1890 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX; 1891 1892 req_id = arg->req_id; 1893 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; 1894 1895 tlv = (void *)skb->data; 1896 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD); 1897 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1898 cmd = (void *)tlv->value; 1899 cmd->req_type = __cpu_to_le32(arg->req_type); 1900 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id); 1901 cmd->scan_id = __cpu_to_le32(scan_id); 1902 cmd->scan_req_id = __cpu_to_le32(req_id); 1903 1904 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop scan\n"); 1905 return skb; 1906 } 1907 1908 static struct sk_buff * 1909 ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k *ar, 1910 u32 vdev_id, 1911 enum wmi_vdev_type vdev_type, 1912 enum wmi_vdev_subtype vdev_subtype, 1913 const u8 mac_addr[ETH_ALEN]) 1914 { 1915 struct wmi_vdev_create_cmd *cmd; 1916 struct wmi_tlv *tlv; 1917 struct sk_buff *skb; 1918 1919 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1920 if (!skb) 1921 return ERR_PTR(-ENOMEM); 1922 1923 tlv = (void *)skb->data; 1924 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD); 1925 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1926 cmd = (void *)tlv->value; 1927 cmd->vdev_id = __cpu_to_le32(vdev_id); 1928 cmd->vdev_type = __cpu_to_le32(vdev_type); 1929 cmd->vdev_subtype = __cpu_to_le32(vdev_subtype); 1930 ether_addr_copy(cmd->vdev_macaddr.addr, mac_addr); 1931 1932 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev create\n"); 1933 return skb; 1934 } 1935 1936 static struct sk_buff * 1937 ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id) 1938 { 1939 struct wmi_vdev_delete_cmd *cmd; 1940 struct wmi_tlv *tlv; 1941 struct sk_buff *skb; 1942 1943 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 1944 if (!skb) 1945 return ERR_PTR(-ENOMEM); 1946 1947 tlv = (void *)skb->data; 1948 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD); 1949 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1950 cmd = (void *)tlv->value; 1951 cmd->vdev_id = __cpu_to_le32(vdev_id); 1952 1953 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev delete\n"); 1954 return skb; 1955 } 1956 1957 static struct sk_buff * 1958 ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar, 1959 const struct wmi_vdev_start_request_arg *arg, 1960 bool restart) 1961 { 1962 struct wmi_tlv_vdev_start_cmd *cmd; 1963 struct wmi_channel *ch; 1964 struct wmi_tlv *tlv; 1965 struct sk_buff *skb; 1966 size_t len; 1967 void *ptr; 1968 u32 flags = 0; 1969 1970 if (WARN_ON(arg->hidden_ssid && !arg->ssid)) 1971 return ERR_PTR(-EINVAL); 1972 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid))) 1973 return ERR_PTR(-EINVAL); 1974 1975 len = (sizeof(*tlv) + sizeof(*cmd)) + 1976 (sizeof(*tlv) + sizeof(*ch)) + 1977 (sizeof(*tlv) + 0); 1978 skb = ath10k_wmi_alloc_skb(ar, len); 1979 if (!skb) 1980 return ERR_PTR(-ENOMEM); 1981 1982 if (arg->hidden_ssid) 1983 flags |= WMI_VDEV_START_HIDDEN_SSID; 1984 if (arg->pmf_enabled) 1985 flags |= WMI_VDEV_START_PMF_ENABLED; 1986 1987 ptr = (void *)skb->data; 1988 1989 tlv = ptr; 1990 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD); 1991 tlv->len = __cpu_to_le16(sizeof(*cmd)); 1992 cmd = (void *)tlv->value; 1993 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 1994 cmd->bcn_intval = __cpu_to_le32(arg->bcn_intval); 1995 cmd->dtim_period = __cpu_to_le32(arg->dtim_period); 1996 cmd->flags = __cpu_to_le32(flags); 1997 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate); 1998 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power); 1999 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack); 2000 2001 if (arg->ssid) { 2002 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len); 2003 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len); 2004 } 2005 2006 ptr += sizeof(*tlv); 2007 ptr += sizeof(*cmd); 2008 2009 tlv = ptr; 2010 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL); 2011 tlv->len = __cpu_to_le16(sizeof(*ch)); 2012 ch = (void *)tlv->value; 2013 ath10k_wmi_put_wmi_channel(ch, &arg->channel); 2014 2015 ptr += sizeof(*tlv); 2016 ptr += sizeof(*ch); 2017 2018 tlv = ptr; 2019 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 2020 tlv->len = 0; 2021 2022 /* Note: This is a nested TLV containing: 2023 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv].. 2024 */ 2025 2026 ptr += sizeof(*tlv); 2027 ptr += 0; 2028 2029 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev start\n"); 2030 return skb; 2031 } 2032 2033 static struct sk_buff * 2034 ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id) 2035 { 2036 struct wmi_vdev_stop_cmd *cmd; 2037 struct wmi_tlv *tlv; 2038 struct sk_buff *skb; 2039 2040 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2041 if (!skb) 2042 return ERR_PTR(-ENOMEM); 2043 2044 tlv = (void *)skb->data; 2045 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD); 2046 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2047 cmd = (void *)tlv->value; 2048 cmd->vdev_id = __cpu_to_le32(vdev_id); 2049 2050 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev stop\n"); 2051 return skb; 2052 } 2053 2054 static struct sk_buff * 2055 ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, 2056 const u8 *bssid) 2057 2058 { 2059 struct wmi_vdev_up_cmd *cmd; 2060 struct wmi_tlv *tlv; 2061 struct sk_buff *skb; 2062 2063 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2064 if (!skb) 2065 return ERR_PTR(-ENOMEM); 2066 2067 tlv = (void *)skb->data; 2068 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD); 2069 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2070 cmd = (void *)tlv->value; 2071 cmd->vdev_id = __cpu_to_le32(vdev_id); 2072 cmd->vdev_assoc_id = __cpu_to_le32(aid); 2073 ether_addr_copy(cmd->vdev_bssid.addr, bssid); 2074 2075 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev up\n"); 2076 return skb; 2077 } 2078 2079 static struct sk_buff * 2080 ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id) 2081 { 2082 struct wmi_vdev_down_cmd *cmd; 2083 struct wmi_tlv *tlv; 2084 struct sk_buff *skb; 2085 2086 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2087 if (!skb) 2088 return ERR_PTR(-ENOMEM); 2089 2090 tlv = (void *)skb->data; 2091 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD); 2092 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2093 cmd = (void *)tlv->value; 2094 cmd->vdev_id = __cpu_to_le32(vdev_id); 2095 2096 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev down\n"); 2097 return skb; 2098 } 2099 2100 static struct sk_buff * 2101 ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id, 2102 u32 param_id, u32 param_value) 2103 { 2104 struct wmi_vdev_set_param_cmd *cmd; 2105 struct wmi_tlv *tlv; 2106 struct sk_buff *skb; 2107 2108 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2109 if (!skb) 2110 return ERR_PTR(-ENOMEM); 2111 2112 tlv = (void *)skb->data; 2113 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD); 2114 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2115 cmd = (void *)tlv->value; 2116 cmd->vdev_id = __cpu_to_le32(vdev_id); 2117 cmd->param_id = __cpu_to_le32(param_id); 2118 cmd->param_value = __cpu_to_le32(param_value); 2119 2120 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev %d set param %d value 0x%x\n", 2121 vdev_id, param_id, param_value); 2122 return skb; 2123 } 2124 2125 static struct sk_buff * 2126 ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k *ar, 2127 const struct wmi_vdev_install_key_arg *arg) 2128 { 2129 struct wmi_vdev_install_key_cmd *cmd; 2130 struct wmi_tlv *tlv; 2131 struct sk_buff *skb; 2132 size_t len; 2133 void *ptr; 2134 2135 if (arg->key_cipher == ar->wmi_key_cipher[WMI_CIPHER_NONE] && 2136 arg->key_data) 2137 return ERR_PTR(-EINVAL); 2138 if (arg->key_cipher != ar->wmi_key_cipher[WMI_CIPHER_NONE] && 2139 !arg->key_data) 2140 return ERR_PTR(-EINVAL); 2141 2142 len = sizeof(*tlv) + sizeof(*cmd) + 2143 sizeof(*tlv) + roundup(arg->key_len, sizeof(__le32)); 2144 skb = ath10k_wmi_alloc_skb(ar, len); 2145 if (!skb) 2146 return ERR_PTR(-ENOMEM); 2147 2148 ptr = (void *)skb->data; 2149 tlv = ptr; 2150 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD); 2151 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2152 cmd = (void *)tlv->value; 2153 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 2154 cmd->key_idx = __cpu_to_le32(arg->key_idx); 2155 cmd->key_flags = __cpu_to_le32(arg->key_flags); 2156 cmd->key_cipher = __cpu_to_le32(arg->key_cipher); 2157 cmd->key_len = __cpu_to_le32(arg->key_len); 2158 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len); 2159 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len); 2160 2161 if (arg->macaddr) 2162 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr); 2163 2164 ptr += sizeof(*tlv); 2165 ptr += sizeof(*cmd); 2166 2167 tlv = ptr; 2168 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 2169 tlv->len = __cpu_to_le16(roundup(arg->key_len, sizeof(__le32))); 2170 if (arg->key_data) 2171 memcpy(tlv->value, arg->key_data, arg->key_len); 2172 2173 ptr += sizeof(*tlv); 2174 ptr += roundup(arg->key_len, sizeof(__le32)); 2175 2176 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev install key\n"); 2177 return skb; 2178 } 2179 2180 static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k *ar, void *ptr, 2181 const struct wmi_sta_uapsd_auto_trig_arg *arg) 2182 { 2183 struct wmi_sta_uapsd_auto_trig_param *ac; 2184 struct wmi_tlv *tlv; 2185 2186 tlv = ptr; 2187 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM); 2188 tlv->len = __cpu_to_le16(sizeof(*ac)); 2189 ac = (void *)tlv->value; 2190 2191 ac->wmm_ac = __cpu_to_le32(arg->wmm_ac); 2192 ac->user_priority = __cpu_to_le32(arg->user_priority); 2193 ac->service_interval = __cpu_to_le32(arg->service_interval); 2194 ac->suspend_interval = __cpu_to_le32(arg->suspend_interval); 2195 ac->delay_interval = __cpu_to_le32(arg->delay_interval); 2196 2197 ath10k_dbg(ar, ATH10K_DBG_WMI, 2198 "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n", 2199 ac->wmm_ac, ac->user_priority, ac->service_interval, 2200 ac->suspend_interval, ac->delay_interval); 2201 2202 return ptr + sizeof(*tlv) + sizeof(*ac); 2203 } 2204 2205 static struct sk_buff * 2206 ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id, 2207 const u8 peer_addr[ETH_ALEN], 2208 const struct wmi_sta_uapsd_auto_trig_arg *args, 2209 u32 num_ac) 2210 { 2211 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd; 2212 struct wmi_sta_uapsd_auto_trig_param *ac; 2213 struct wmi_tlv *tlv; 2214 struct sk_buff *skb; 2215 size_t len; 2216 size_t ac_tlv_len; 2217 void *ptr; 2218 int i; 2219 2220 ac_tlv_len = num_ac * (sizeof(*tlv) + sizeof(*ac)); 2221 len = sizeof(*tlv) + sizeof(*cmd) + 2222 sizeof(*tlv) + ac_tlv_len; 2223 skb = ath10k_wmi_alloc_skb(ar, len); 2224 if (!skb) 2225 return ERR_PTR(-ENOMEM); 2226 2227 ptr = (void *)skb->data; 2228 tlv = ptr; 2229 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD); 2230 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2231 cmd = (void *)tlv->value; 2232 cmd->vdev_id = __cpu_to_le32(vdev_id); 2233 cmd->num_ac = __cpu_to_le32(num_ac); 2234 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 2235 2236 ptr += sizeof(*tlv); 2237 ptr += sizeof(*cmd); 2238 2239 tlv = ptr; 2240 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 2241 tlv->len = __cpu_to_le16(ac_tlv_len); 2242 ac = (void *)tlv->value; 2243 2244 ptr += sizeof(*tlv); 2245 for (i = 0; i < num_ac; i++) 2246 ptr = ath10k_wmi_tlv_put_uapsd_ac(ar, ptr, &args[i]); 2247 2248 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev sta uapsd auto trigger\n"); 2249 return skb; 2250 } 2251 2252 static void *ath10k_wmi_tlv_put_wmm(void *ptr, 2253 const struct wmi_wmm_params_arg *arg) 2254 { 2255 struct wmi_wmm_params *wmm; 2256 struct wmi_tlv *tlv; 2257 2258 tlv = ptr; 2259 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS); 2260 tlv->len = __cpu_to_le16(sizeof(*wmm)); 2261 wmm = (void *)tlv->value; 2262 ath10k_wmi_set_wmm_param(wmm, arg); 2263 2264 return ptr + sizeof(*tlv) + sizeof(*wmm); 2265 } 2266 2267 static struct sk_buff * 2268 ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id, 2269 const struct wmi_wmm_params_all_arg *arg) 2270 { 2271 struct wmi_tlv_vdev_set_wmm_cmd *cmd; 2272 struct wmi_tlv *tlv; 2273 struct sk_buff *skb; 2274 size_t len; 2275 void *ptr; 2276 2277 len = sizeof(*tlv) + sizeof(*cmd); 2278 skb = ath10k_wmi_alloc_skb(ar, len); 2279 if (!skb) 2280 return ERR_PTR(-ENOMEM); 2281 2282 ptr = (void *)skb->data; 2283 tlv = ptr; 2284 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD); 2285 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2286 cmd = (void *)tlv->value; 2287 cmd->vdev_id = __cpu_to_le32(vdev_id); 2288 2289 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[0].params, &arg->ac_be); 2290 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[1].params, &arg->ac_bk); 2291 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[2].params, &arg->ac_vi); 2292 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[3].params, &arg->ac_vo); 2293 2294 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev wmm conf\n"); 2295 return skb; 2296 } 2297 2298 static struct sk_buff * 2299 ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar, 2300 const struct wmi_sta_keepalive_arg *arg) 2301 { 2302 struct wmi_tlv_sta_keepalive_cmd *cmd; 2303 struct wmi_sta_keepalive_arp_resp *arp; 2304 struct sk_buff *skb; 2305 struct wmi_tlv *tlv; 2306 void *ptr; 2307 size_t len; 2308 2309 len = sizeof(*tlv) + sizeof(*cmd) + 2310 sizeof(*tlv) + sizeof(*arp); 2311 skb = ath10k_wmi_alloc_skb(ar, len); 2312 if (!skb) 2313 return ERR_PTR(-ENOMEM); 2314 2315 ptr = (void *)skb->data; 2316 tlv = ptr; 2317 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD); 2318 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2319 cmd = (void *)tlv->value; 2320 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 2321 cmd->enabled = __cpu_to_le32(arg->enabled); 2322 cmd->method = __cpu_to_le32(arg->method); 2323 cmd->interval = __cpu_to_le32(arg->interval); 2324 2325 ptr += sizeof(*tlv); 2326 ptr += sizeof(*cmd); 2327 2328 tlv = ptr; 2329 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE); 2330 tlv->len = __cpu_to_le16(sizeof(*arp)); 2331 arp = (void *)tlv->value; 2332 2333 arp->src_ip4_addr = arg->src_ip4_addr; 2334 arp->dest_ip4_addr = arg->dest_ip4_addr; 2335 ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr); 2336 2337 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled %d method %d interval %d\n", 2338 arg->vdev_id, arg->enabled, arg->method, arg->interval); 2339 return skb; 2340 } 2341 2342 static struct sk_buff * 2343 ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id, 2344 const u8 peer_addr[ETH_ALEN], 2345 enum wmi_peer_type peer_type) 2346 { 2347 struct wmi_tlv_peer_create_cmd *cmd; 2348 struct wmi_tlv *tlv; 2349 struct sk_buff *skb; 2350 2351 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2352 if (!skb) 2353 return ERR_PTR(-ENOMEM); 2354 2355 tlv = (void *)skb->data; 2356 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD); 2357 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2358 cmd = (void *)tlv->value; 2359 cmd->vdev_id = __cpu_to_le32(vdev_id); 2360 cmd->peer_type = __cpu_to_le32(peer_type); 2361 ether_addr_copy(cmd->peer_addr.addr, peer_addr); 2362 2363 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer create\n"); 2364 return skb; 2365 } 2366 2367 static struct sk_buff * 2368 ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id, 2369 const u8 peer_addr[ETH_ALEN]) 2370 { 2371 struct wmi_peer_delete_cmd *cmd; 2372 struct wmi_tlv *tlv; 2373 struct sk_buff *skb; 2374 2375 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2376 if (!skb) 2377 return ERR_PTR(-ENOMEM); 2378 2379 tlv = (void *)skb->data; 2380 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD); 2381 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2382 cmd = (void *)tlv->value; 2383 cmd->vdev_id = __cpu_to_le32(vdev_id); 2384 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 2385 2386 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete\n"); 2387 return skb; 2388 } 2389 2390 static struct sk_buff * 2391 ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id, 2392 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap) 2393 { 2394 struct wmi_peer_flush_tids_cmd *cmd; 2395 struct wmi_tlv *tlv; 2396 struct sk_buff *skb; 2397 2398 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2399 if (!skb) 2400 return ERR_PTR(-ENOMEM); 2401 2402 tlv = (void *)skb->data; 2403 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD); 2404 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2405 cmd = (void *)tlv->value; 2406 cmd->vdev_id = __cpu_to_le32(vdev_id); 2407 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap); 2408 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 2409 2410 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer flush\n"); 2411 return skb; 2412 } 2413 2414 static struct sk_buff * 2415 ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id, 2416 const u8 *peer_addr, 2417 enum wmi_peer_param param_id, 2418 u32 param_value) 2419 { 2420 struct wmi_peer_set_param_cmd *cmd; 2421 struct wmi_tlv *tlv; 2422 struct sk_buff *skb; 2423 2424 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2425 if (!skb) 2426 return ERR_PTR(-ENOMEM); 2427 2428 tlv = (void *)skb->data; 2429 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD); 2430 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2431 cmd = (void *)tlv->value; 2432 cmd->vdev_id = __cpu_to_le32(vdev_id); 2433 cmd->param_id = __cpu_to_le32(param_id); 2434 cmd->param_value = __cpu_to_le32(param_value); 2435 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 2436 2437 ath10k_dbg(ar, ATH10K_DBG_WMI, 2438 "wmi tlv vdev %d peer %pM set param %d value 0x%x\n", 2439 vdev_id, peer_addr, param_id, param_value); 2440 return skb; 2441 } 2442 2443 static struct sk_buff * 2444 ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k *ar, 2445 const struct wmi_peer_assoc_complete_arg *arg) 2446 { 2447 struct wmi_tlv_peer_assoc_cmd *cmd; 2448 struct wmi_vht_rate_set *vht_rate; 2449 struct wmi_tlv *tlv; 2450 struct sk_buff *skb; 2451 size_t len, legacy_rate_len, ht_rate_len; 2452 void *ptr; 2453 2454 if (arg->peer_mpdu_density > 16) 2455 return ERR_PTR(-EINVAL); 2456 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES) 2457 return ERR_PTR(-EINVAL); 2458 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES) 2459 return ERR_PTR(-EINVAL); 2460 2461 legacy_rate_len = roundup(arg->peer_legacy_rates.num_rates, 2462 sizeof(__le32)); 2463 ht_rate_len = roundup(arg->peer_ht_rates.num_rates, sizeof(__le32)); 2464 len = (sizeof(*tlv) + sizeof(*cmd)) + 2465 (sizeof(*tlv) + legacy_rate_len) + 2466 (sizeof(*tlv) + ht_rate_len) + 2467 (sizeof(*tlv) + sizeof(*vht_rate)); 2468 skb = ath10k_wmi_alloc_skb(ar, len); 2469 if (!skb) 2470 return ERR_PTR(-ENOMEM); 2471 2472 ptr = (void *)skb->data; 2473 tlv = ptr; 2474 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD); 2475 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2476 cmd = (void *)tlv->value; 2477 2478 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 2479 cmd->new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1); 2480 cmd->assoc_id = __cpu_to_le32(arg->peer_aid); 2481 cmd->flags = __cpu_to_le32(arg->peer_flags); 2482 cmd->caps = __cpu_to_le32(arg->peer_caps); 2483 cmd->listen_intval = __cpu_to_le32(arg->peer_listen_intval); 2484 cmd->ht_caps = __cpu_to_le32(arg->peer_ht_caps); 2485 cmd->max_mpdu = __cpu_to_le32(arg->peer_max_mpdu); 2486 cmd->mpdu_density = __cpu_to_le32(arg->peer_mpdu_density); 2487 cmd->rate_caps = __cpu_to_le32(arg->peer_rate_caps); 2488 cmd->nss = __cpu_to_le32(arg->peer_num_spatial_streams); 2489 cmd->vht_caps = __cpu_to_le32(arg->peer_vht_caps); 2490 cmd->phy_mode = __cpu_to_le32(arg->peer_phymode); 2491 cmd->num_legacy_rates = __cpu_to_le32(arg->peer_legacy_rates.num_rates); 2492 cmd->num_ht_rates = __cpu_to_le32(arg->peer_ht_rates.num_rates); 2493 ether_addr_copy(cmd->mac_addr.addr, arg->addr); 2494 2495 ptr += sizeof(*tlv); 2496 ptr += sizeof(*cmd); 2497 2498 tlv = ptr; 2499 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 2500 tlv->len = __cpu_to_le16(legacy_rate_len); 2501 memcpy(tlv->value, arg->peer_legacy_rates.rates, 2502 arg->peer_legacy_rates.num_rates); 2503 2504 ptr += sizeof(*tlv); 2505 ptr += legacy_rate_len; 2506 2507 tlv = ptr; 2508 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 2509 tlv->len = __cpu_to_le16(ht_rate_len); 2510 memcpy(tlv->value, arg->peer_ht_rates.rates, 2511 arg->peer_ht_rates.num_rates); 2512 2513 ptr += sizeof(*tlv); 2514 ptr += ht_rate_len; 2515 2516 tlv = ptr; 2517 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET); 2518 tlv->len = __cpu_to_le16(sizeof(*vht_rate)); 2519 vht_rate = (void *)tlv->value; 2520 2521 vht_rate->rx_max_rate = __cpu_to_le32(arg->peer_vht_rates.rx_max_rate); 2522 vht_rate->rx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set); 2523 vht_rate->tx_max_rate = __cpu_to_le32(arg->peer_vht_rates.tx_max_rate); 2524 vht_rate->tx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); 2525 2526 ptr += sizeof(*tlv); 2527 ptr += sizeof(*vht_rate); 2528 2529 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer assoc\n"); 2530 return skb; 2531 } 2532 2533 static struct sk_buff * 2534 ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id, 2535 enum wmi_sta_ps_mode psmode) 2536 { 2537 struct wmi_sta_powersave_mode_cmd *cmd; 2538 struct wmi_tlv *tlv; 2539 struct sk_buff *skb; 2540 2541 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2542 if (!skb) 2543 return ERR_PTR(-ENOMEM); 2544 2545 tlv = (void *)skb->data; 2546 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD); 2547 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2548 cmd = (void *)tlv->value; 2549 cmd->vdev_id = __cpu_to_le32(vdev_id); 2550 cmd->sta_ps_mode = __cpu_to_le32(psmode); 2551 2552 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set psmode\n"); 2553 return skb; 2554 } 2555 2556 static struct sk_buff * 2557 ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id, 2558 enum wmi_sta_powersave_param param_id, 2559 u32 param_value) 2560 { 2561 struct wmi_sta_powersave_param_cmd *cmd; 2562 struct wmi_tlv *tlv; 2563 struct sk_buff *skb; 2564 2565 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2566 if (!skb) 2567 return ERR_PTR(-ENOMEM); 2568 2569 tlv = (void *)skb->data; 2570 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD); 2571 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2572 cmd = (void *)tlv->value; 2573 cmd->vdev_id = __cpu_to_le32(vdev_id); 2574 cmd->param_id = __cpu_to_le32(param_id); 2575 cmd->param_value = __cpu_to_le32(param_value); 2576 2577 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set sta ps\n"); 2578 return skb; 2579 } 2580 2581 static struct sk_buff * 2582 ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac, 2583 enum wmi_ap_ps_peer_param param_id, u32 value) 2584 { 2585 struct wmi_ap_ps_peer_cmd *cmd; 2586 struct wmi_tlv *tlv; 2587 struct sk_buff *skb; 2588 2589 if (!mac) 2590 return ERR_PTR(-EINVAL); 2591 2592 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2593 if (!skb) 2594 return ERR_PTR(-ENOMEM); 2595 2596 tlv = (void *)skb->data; 2597 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD); 2598 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2599 cmd = (void *)tlv->value; 2600 cmd->vdev_id = __cpu_to_le32(vdev_id); 2601 cmd->param_id = __cpu_to_le32(param_id); 2602 cmd->param_value = __cpu_to_le32(value); 2603 ether_addr_copy(cmd->peer_macaddr.addr, mac); 2604 2605 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv ap ps param\n"); 2606 return skb; 2607 } 2608 2609 static struct sk_buff * 2610 ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k *ar, 2611 const struct wmi_scan_chan_list_arg *arg) 2612 { 2613 struct wmi_tlv_scan_chan_list_cmd *cmd; 2614 struct wmi_channel *ci; 2615 struct wmi_channel_arg *ch; 2616 struct wmi_tlv *tlv; 2617 struct sk_buff *skb; 2618 size_t chans_len, len; 2619 int i; 2620 void *ptr, *chans; 2621 2622 chans_len = arg->n_channels * (sizeof(*tlv) + sizeof(*ci)); 2623 len = (sizeof(*tlv) + sizeof(*cmd)) + 2624 (sizeof(*tlv) + chans_len); 2625 2626 skb = ath10k_wmi_alloc_skb(ar, len); 2627 if (!skb) 2628 return ERR_PTR(-ENOMEM); 2629 2630 ptr = (void *)skb->data; 2631 tlv = ptr; 2632 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD); 2633 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2634 cmd = (void *)tlv->value; 2635 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels); 2636 2637 ptr += sizeof(*tlv); 2638 ptr += sizeof(*cmd); 2639 2640 tlv = ptr; 2641 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 2642 tlv->len = __cpu_to_le16(chans_len); 2643 chans = (void *)tlv->value; 2644 2645 for (i = 0; i < arg->n_channels; i++) { 2646 ch = &arg->channels[i]; 2647 2648 tlv = chans; 2649 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL); 2650 tlv->len = __cpu_to_le16(sizeof(*ci)); 2651 ci = (void *)tlv->value; 2652 2653 ath10k_wmi_put_wmi_channel(ci, ch); 2654 2655 chans += sizeof(*tlv); 2656 chans += sizeof(*ci); 2657 } 2658 2659 ptr += sizeof(*tlv); 2660 ptr += chans_len; 2661 2662 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan chan list\n"); 2663 return skb; 2664 } 2665 2666 static struct sk_buff * 2667 ath10k_wmi_tlv_op_gen_scan_prob_req_oui(struct ath10k *ar, u32 prob_req_oui) 2668 { 2669 struct wmi_scan_prob_req_oui_cmd *cmd; 2670 struct wmi_tlv *tlv; 2671 struct sk_buff *skb; 2672 2673 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2674 if (!skb) 2675 return ERR_PTR(-ENOMEM); 2676 2677 tlv = (void *)skb->data; 2678 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_PROB_REQ_OUI_CMD); 2679 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2680 cmd = (void *)tlv->value; 2681 cmd->prob_req_oui = __cpu_to_le32(prob_req_oui); 2682 2683 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan prob req oui\n"); 2684 return skb; 2685 } 2686 2687 static struct sk_buff * 2688 ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, 2689 const void *bcn, size_t bcn_len, 2690 u32 bcn_paddr, bool dtim_zero, 2691 bool deliver_cab) 2692 2693 { 2694 struct wmi_bcn_tx_ref_cmd *cmd; 2695 struct wmi_tlv *tlv; 2696 struct sk_buff *skb; 2697 struct ieee80211_hdr *hdr; 2698 u16 fc; 2699 2700 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2701 if (!skb) 2702 return ERR_PTR(-ENOMEM); 2703 2704 hdr = (struct ieee80211_hdr *)bcn; 2705 fc = le16_to_cpu(hdr->frame_control); 2706 2707 tlv = (void *)skb->data; 2708 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD); 2709 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2710 cmd = (void *)tlv->value; 2711 cmd->vdev_id = __cpu_to_le32(vdev_id); 2712 cmd->data_len = __cpu_to_le32(bcn_len); 2713 cmd->data_ptr = __cpu_to_le32(bcn_paddr); 2714 cmd->msdu_id = 0; 2715 cmd->frame_control = __cpu_to_le32(fc); 2716 cmd->flags = 0; 2717 2718 if (dtim_zero) 2719 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO); 2720 2721 if (deliver_cab) 2722 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB); 2723 2724 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv beacon dma\n"); 2725 return skb; 2726 } 2727 2728 static struct sk_buff * 2729 ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k *ar, 2730 const struct wmi_wmm_params_all_arg *arg) 2731 { 2732 struct wmi_tlv_pdev_set_wmm_cmd *cmd; 2733 struct wmi_wmm_params *wmm; 2734 struct wmi_tlv *tlv; 2735 struct sk_buff *skb; 2736 size_t len; 2737 void *ptr; 2738 2739 len = (sizeof(*tlv) + sizeof(*cmd)) + 2740 (4 * (sizeof(*tlv) + sizeof(*wmm))); 2741 skb = ath10k_wmi_alloc_skb(ar, len); 2742 if (!skb) 2743 return ERR_PTR(-ENOMEM); 2744 2745 ptr = (void *)skb->data; 2746 2747 tlv = ptr; 2748 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD); 2749 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2750 cmd = (void *)tlv->value; 2751 2752 /* nothing to set here */ 2753 2754 ptr += sizeof(*tlv); 2755 ptr += sizeof(*cmd); 2756 2757 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_be); 2758 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_bk); 2759 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vi); 2760 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vo); 2761 2762 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set wmm\n"); 2763 return skb; 2764 } 2765 2766 static struct sk_buff * 2767 ath10k_wmi_tlv_op_gen_request_stats(struct ath10k *ar, u32 stats_mask) 2768 { 2769 struct wmi_request_stats_cmd *cmd; 2770 struct wmi_tlv *tlv; 2771 struct sk_buff *skb; 2772 2773 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2774 if (!skb) 2775 return ERR_PTR(-ENOMEM); 2776 2777 tlv = (void *)skb->data; 2778 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD); 2779 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2780 cmd = (void *)tlv->value; 2781 cmd->stats_id = __cpu_to_le32(stats_mask); 2782 2783 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request stats\n"); 2784 return skb; 2785 } 2786 2787 static int 2788 ath10k_wmi_mgmt_tx_alloc_msdu_id(struct ath10k *ar, struct sk_buff *skb, 2789 dma_addr_t paddr) 2790 { 2791 struct ath10k_wmi *wmi = &ar->wmi; 2792 struct ath10k_mgmt_tx_pkt_addr *pkt_addr; 2793 int ret; 2794 2795 pkt_addr = kmalloc(sizeof(*pkt_addr), GFP_ATOMIC); 2796 if (!pkt_addr) 2797 return -ENOMEM; 2798 2799 pkt_addr->vaddr = skb; 2800 pkt_addr->paddr = paddr; 2801 2802 spin_lock_bh(&ar->data_lock); 2803 ret = idr_alloc(&wmi->mgmt_pending_tx, pkt_addr, 0, 2804 wmi->mgmt_max_num_pending_tx, GFP_ATOMIC); 2805 spin_unlock_bh(&ar->data_lock); 2806 2807 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx alloc msdu_id ret %d\n", ret); 2808 return ret; 2809 } 2810 2811 static struct sk_buff * 2812 ath10k_wmi_tlv_op_gen_mgmt_tx_send(struct ath10k *ar, struct sk_buff *msdu, 2813 dma_addr_t paddr) 2814 { 2815 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(msdu); 2816 struct wmi_tlv_mgmt_tx_cmd *cmd; 2817 struct ieee80211_hdr *hdr; 2818 struct ath10k_vif *arvif; 2819 u32 buf_len = msdu->len; 2820 struct wmi_tlv *tlv; 2821 struct sk_buff *skb; 2822 int len, desc_id; 2823 u32 vdev_id; 2824 void *ptr; 2825 2826 if (!cb->vif) 2827 return ERR_PTR(-EINVAL); 2828 2829 hdr = (struct ieee80211_hdr *)msdu->data; 2830 arvif = (void *)cb->vif->drv_priv; 2831 vdev_id = arvif->vdev_id; 2832 2833 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control) && 2834 (!(ieee80211_is_nullfunc(hdr->frame_control) || 2835 ieee80211_is_qos_nullfunc(hdr->frame_control))))) 2836 return ERR_PTR(-EINVAL); 2837 2838 len = sizeof(*cmd) + 2 * sizeof(*tlv); 2839 2840 if ((ieee80211_is_action(hdr->frame_control) || 2841 ieee80211_is_deauth(hdr->frame_control) || 2842 ieee80211_is_disassoc(hdr->frame_control)) && 2843 ieee80211_has_protected(hdr->frame_control)) 2844 buf_len += IEEE80211_CCMP_MIC_LEN; 2845 2846 buf_len = min_t(u32, buf_len, WMI_TLV_MGMT_TX_FRAME_MAX_LEN); 2847 buf_len = round_up(buf_len, 4); 2848 2849 len += buf_len; 2850 len = round_up(len, 4); 2851 skb = ath10k_wmi_alloc_skb(ar, len); 2852 if (!skb) 2853 return ERR_PTR(-ENOMEM); 2854 2855 desc_id = ath10k_wmi_mgmt_tx_alloc_msdu_id(ar, msdu, paddr); 2856 if (desc_id < 0) 2857 goto err_free_skb; 2858 2859 ptr = (void *)skb->data; 2860 tlv = ptr; 2861 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_MGMT_TX_CMD); 2862 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2863 cmd = (void *)tlv->value; 2864 cmd->vdev_id = __cpu_to_le32(vdev_id); 2865 cmd->desc_id = __cpu_to_le32(desc_id); 2866 cmd->chanfreq = 0; 2867 cmd->buf_len = __cpu_to_le32(buf_len); 2868 cmd->frame_len = __cpu_to_le32(msdu->len); 2869 cmd->paddr = __cpu_to_le64(paddr); 2870 2871 ptr += sizeof(*tlv); 2872 ptr += sizeof(*cmd); 2873 2874 tlv = ptr; 2875 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 2876 tlv->len = __cpu_to_le16(buf_len); 2877 2878 ptr += sizeof(*tlv); 2879 memcpy(ptr, msdu->data, buf_len); 2880 2881 return skb; 2882 2883 err_free_skb: 2884 dev_kfree_skb(skb); 2885 return ERR_PTR(desc_id); 2886 } 2887 2888 static struct sk_buff * 2889 ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k *ar, 2890 enum wmi_force_fw_hang_type type, 2891 u32 delay_ms) 2892 { 2893 struct wmi_force_fw_hang_cmd *cmd; 2894 struct wmi_tlv *tlv; 2895 struct sk_buff *skb; 2896 2897 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 2898 if (!skb) 2899 return ERR_PTR(-ENOMEM); 2900 2901 tlv = (void *)skb->data; 2902 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD); 2903 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2904 cmd = (void *)tlv->value; 2905 cmd->type = __cpu_to_le32(type); 2906 cmd->delay_ms = __cpu_to_le32(delay_ms); 2907 2908 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv force fw hang\n"); 2909 return skb; 2910 } 2911 2912 static struct sk_buff * 2913 ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k *ar, u64 module_enable, 2914 u32 log_level) 2915 { 2916 struct wmi_tlv_dbglog_cmd *cmd; 2917 struct wmi_tlv *tlv; 2918 struct sk_buff *skb; 2919 size_t len, bmap_len; 2920 u32 value; 2921 void *ptr; 2922 2923 if (module_enable) { 2924 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE( 2925 module_enable, 2926 WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE); 2927 } else { 2928 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE( 2929 WMI_TLV_DBGLOG_ALL_MODULES, 2930 WMI_TLV_DBGLOG_LOG_LEVEL_WARN); 2931 } 2932 2933 bmap_len = 0; 2934 len = sizeof(*tlv) + sizeof(*cmd) + sizeof(*tlv) + bmap_len; 2935 skb = ath10k_wmi_alloc_skb(ar, len); 2936 if (!skb) 2937 return ERR_PTR(-ENOMEM); 2938 2939 ptr = (void *)skb->data; 2940 2941 tlv = ptr; 2942 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD); 2943 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2944 cmd = (void *)tlv->value; 2945 cmd->param = __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL); 2946 cmd->value = __cpu_to_le32(value); 2947 2948 ptr += sizeof(*tlv); 2949 ptr += sizeof(*cmd); 2950 2951 tlv = ptr; 2952 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32); 2953 tlv->len = __cpu_to_le16(bmap_len); 2954 2955 /* nothing to do here */ 2956 2957 ptr += sizeof(*tlv); 2958 ptr += sizeof(bmap_len); 2959 2960 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv dbglog value 0x%08x\n", value); 2961 return skb; 2962 } 2963 2964 static struct sk_buff * 2965 ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k *ar, u32 filter) 2966 { 2967 struct wmi_tlv_pktlog_enable *cmd; 2968 struct wmi_tlv *tlv; 2969 struct sk_buff *skb; 2970 void *ptr; 2971 size_t len; 2972 2973 len = sizeof(*tlv) + sizeof(*cmd); 2974 skb = ath10k_wmi_alloc_skb(ar, len); 2975 if (!skb) 2976 return ERR_PTR(-ENOMEM); 2977 2978 ptr = (void *)skb->data; 2979 tlv = ptr; 2980 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD); 2981 tlv->len = __cpu_to_le16(sizeof(*cmd)); 2982 cmd = (void *)tlv->value; 2983 cmd->filter = __cpu_to_le32(filter); 2984 2985 ptr += sizeof(*tlv); 2986 ptr += sizeof(*cmd); 2987 2988 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog enable filter 0x%08x\n", 2989 filter); 2990 return skb; 2991 } 2992 2993 static struct sk_buff * 2994 ath10k_wmi_tlv_op_gen_pdev_get_temperature(struct ath10k *ar) 2995 { 2996 struct wmi_tlv_pdev_get_temp_cmd *cmd; 2997 struct wmi_tlv *tlv; 2998 struct sk_buff *skb; 2999 3000 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 3001 if (!skb) 3002 return ERR_PTR(-ENOMEM); 3003 3004 tlv = (void *)skb->data; 3005 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_GET_TEMPERATURE_CMD); 3006 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3007 cmd = (void *)tlv->value; 3008 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature tlv\n"); 3009 return skb; 3010 } 3011 3012 static struct sk_buff * 3013 ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k *ar) 3014 { 3015 struct wmi_tlv_pktlog_disable *cmd; 3016 struct wmi_tlv *tlv; 3017 struct sk_buff *skb; 3018 void *ptr; 3019 size_t len; 3020 3021 len = sizeof(*tlv) + sizeof(*cmd); 3022 skb = ath10k_wmi_alloc_skb(ar, len); 3023 if (!skb) 3024 return ERR_PTR(-ENOMEM); 3025 3026 ptr = (void *)skb->data; 3027 tlv = ptr; 3028 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD); 3029 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3030 cmd = (void *)tlv->value; 3031 3032 ptr += sizeof(*tlv); 3033 ptr += sizeof(*cmd); 3034 3035 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog disable\n"); 3036 return skb; 3037 } 3038 3039 static struct sk_buff * 3040 ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k *ar, u32 vdev_id, 3041 u32 tim_ie_offset, struct sk_buff *bcn, 3042 u32 prb_caps, u32 prb_erp, void *prb_ies, 3043 size_t prb_ies_len) 3044 { 3045 struct wmi_tlv_bcn_tmpl_cmd *cmd; 3046 struct wmi_tlv_bcn_prb_info *info; 3047 struct wmi_tlv *tlv; 3048 struct sk_buff *skb; 3049 void *ptr; 3050 size_t len; 3051 3052 if (WARN_ON(prb_ies_len > 0 && !prb_ies)) 3053 return ERR_PTR(-EINVAL); 3054 3055 len = sizeof(*tlv) + sizeof(*cmd) + 3056 sizeof(*tlv) + sizeof(*info) + prb_ies_len + 3057 sizeof(*tlv) + roundup(bcn->len, 4); 3058 skb = ath10k_wmi_alloc_skb(ar, len); 3059 if (!skb) 3060 return ERR_PTR(-ENOMEM); 3061 3062 ptr = (void *)skb->data; 3063 tlv = ptr; 3064 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD); 3065 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3066 cmd = (void *)tlv->value; 3067 cmd->vdev_id = __cpu_to_le32(vdev_id); 3068 cmd->tim_ie_offset = __cpu_to_le32(tim_ie_offset); 3069 cmd->buf_len = __cpu_to_le32(bcn->len); 3070 3071 ptr += sizeof(*tlv); 3072 ptr += sizeof(*cmd); 3073 3074 /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but 3075 * then it is then impossible to pass original ie len. 3076 * This chunk is not used yet so if setting probe resp template yields 3077 * problems with beaconing or crashes firmware look here. 3078 */ 3079 tlv = ptr; 3080 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO); 3081 tlv->len = __cpu_to_le16(sizeof(*info) + prb_ies_len); 3082 info = (void *)tlv->value; 3083 info->caps = __cpu_to_le32(prb_caps); 3084 info->erp = __cpu_to_le32(prb_erp); 3085 memcpy(info->ies, prb_ies, prb_ies_len); 3086 3087 ptr += sizeof(*tlv); 3088 ptr += sizeof(*info); 3089 ptr += prb_ies_len; 3090 3091 tlv = ptr; 3092 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 3093 tlv->len = __cpu_to_le16(roundup(bcn->len, 4)); 3094 memcpy(tlv->value, bcn->data, bcn->len); 3095 3096 /* FIXME: Adjust TSF? */ 3097 3098 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv bcn tmpl vdev_id %i\n", 3099 vdev_id); 3100 return skb; 3101 } 3102 3103 static struct sk_buff * 3104 ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k *ar, u32 vdev_id, 3105 struct sk_buff *prb) 3106 { 3107 struct wmi_tlv_prb_tmpl_cmd *cmd; 3108 struct wmi_tlv_bcn_prb_info *info; 3109 struct wmi_tlv *tlv; 3110 struct sk_buff *skb; 3111 void *ptr; 3112 size_t len; 3113 3114 len = sizeof(*tlv) + sizeof(*cmd) + 3115 sizeof(*tlv) + sizeof(*info) + 3116 sizeof(*tlv) + roundup(prb->len, 4); 3117 skb = ath10k_wmi_alloc_skb(ar, len); 3118 if (!skb) 3119 return ERR_PTR(-ENOMEM); 3120 3121 ptr = (void *)skb->data; 3122 tlv = ptr; 3123 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD); 3124 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3125 cmd = (void *)tlv->value; 3126 cmd->vdev_id = __cpu_to_le32(vdev_id); 3127 cmd->buf_len = __cpu_to_le32(prb->len); 3128 3129 ptr += sizeof(*tlv); 3130 ptr += sizeof(*cmd); 3131 3132 tlv = ptr; 3133 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO); 3134 tlv->len = __cpu_to_le16(sizeof(*info)); 3135 info = (void *)tlv->value; 3136 info->caps = 0; 3137 info->erp = 0; 3138 3139 ptr += sizeof(*tlv); 3140 ptr += sizeof(*info); 3141 3142 tlv = ptr; 3143 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 3144 tlv->len = __cpu_to_le16(roundup(prb->len, 4)); 3145 memcpy(tlv->value, prb->data, prb->len); 3146 3147 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv prb tmpl vdev_id %i\n", 3148 vdev_id); 3149 return skb; 3150 } 3151 3152 static struct sk_buff * 3153 ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id, 3154 const u8 *p2p_ie) 3155 { 3156 struct wmi_tlv_p2p_go_bcn_ie *cmd; 3157 struct wmi_tlv *tlv; 3158 struct sk_buff *skb; 3159 void *ptr; 3160 size_t len; 3161 3162 len = sizeof(*tlv) + sizeof(*cmd) + 3163 sizeof(*tlv) + roundup(p2p_ie[1] + 2, 4); 3164 skb = ath10k_wmi_alloc_skb(ar, len); 3165 if (!skb) 3166 return ERR_PTR(-ENOMEM); 3167 3168 ptr = (void *)skb->data; 3169 tlv = ptr; 3170 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE); 3171 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3172 cmd = (void *)tlv->value; 3173 cmd->vdev_id = __cpu_to_le32(vdev_id); 3174 cmd->ie_len = __cpu_to_le32(p2p_ie[1] + 2); 3175 3176 ptr += sizeof(*tlv); 3177 ptr += sizeof(*cmd); 3178 3179 tlv = ptr; 3180 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 3181 tlv->len = __cpu_to_le16(roundup(p2p_ie[1] + 2, 4)); 3182 memcpy(tlv->value, p2p_ie, p2p_ie[1] + 2); 3183 3184 ptr += sizeof(*tlv); 3185 ptr += roundup(p2p_ie[1] + 2, 4); 3186 3187 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv p2p go bcn ie for vdev %i\n", 3188 vdev_id); 3189 return skb; 3190 } 3191 3192 static struct sk_buff * 3193 ath10k_wmi_tlv_op_gen_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id, 3194 enum wmi_tdls_state state) 3195 { 3196 struct wmi_tdls_set_state_cmd *cmd; 3197 struct wmi_tlv *tlv; 3198 struct sk_buff *skb; 3199 void *ptr; 3200 size_t len; 3201 /* Set to options from wmi_tlv_tdls_options, 3202 * for now none of them are enabled. 3203 */ 3204 u32 options = 0; 3205 3206 if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA, ar->wmi.svc_map)) 3207 options |= WMI_TLV_TDLS_BUFFER_STA_EN; 3208 3209 /* WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL means firm will handle TDLS 3210 * link inactivity detecting logic. 3211 */ 3212 if (state == WMI_TDLS_ENABLE_ACTIVE) 3213 state = WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL; 3214 3215 len = sizeof(*tlv) + sizeof(*cmd); 3216 skb = ath10k_wmi_alloc_skb(ar, len); 3217 if (!skb) 3218 return ERR_PTR(-ENOMEM); 3219 3220 ptr = (void *)skb->data; 3221 tlv = ptr; 3222 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_SET_STATE_CMD); 3223 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3224 3225 cmd = (void *)tlv->value; 3226 cmd->vdev_id = __cpu_to_le32(vdev_id); 3227 cmd->state = __cpu_to_le32(state); 3228 cmd->notification_interval_ms = __cpu_to_le32(5000); 3229 cmd->tx_discovery_threshold = __cpu_to_le32(100); 3230 cmd->tx_teardown_threshold = __cpu_to_le32(5); 3231 cmd->rssi_teardown_threshold = __cpu_to_le32(-75); 3232 cmd->rssi_delta = __cpu_to_le32(-20); 3233 cmd->tdls_options = __cpu_to_le32(options); 3234 cmd->tdls_peer_traffic_ind_window = __cpu_to_le32(2); 3235 cmd->tdls_peer_traffic_response_timeout_ms = __cpu_to_le32(5000); 3236 cmd->tdls_puapsd_mask = __cpu_to_le32(0xf); 3237 cmd->tdls_puapsd_inactivity_time_ms = __cpu_to_le32(0); 3238 cmd->tdls_puapsd_rx_frame_threshold = __cpu_to_le32(10); 3239 3240 ptr += sizeof(*tlv); 3241 ptr += sizeof(*cmd); 3242 3243 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv update fw tdls state %d for vdev %i\n", 3244 state, vdev_id); 3245 return skb; 3246 } 3247 3248 static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp) 3249 { 3250 u32 peer_qos = 0; 3251 3252 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) 3253 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VO; 3254 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) 3255 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VI; 3256 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) 3257 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BK; 3258 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) 3259 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BE; 3260 3261 peer_qos |= SM(sp, WMI_TLV_TDLS_PEER_SP); 3262 3263 return peer_qos; 3264 } 3265 3266 static struct sk_buff * 3267 ath10k_wmi_tlv_op_gen_tdls_peer_update(struct ath10k *ar, 3268 const struct wmi_tdls_peer_update_cmd_arg *arg, 3269 const struct wmi_tdls_peer_capab_arg *cap, 3270 const struct wmi_channel_arg *chan_arg) 3271 { 3272 struct wmi_tdls_peer_update_cmd *cmd; 3273 struct wmi_tdls_peer_capab *peer_cap; 3274 struct wmi_channel *chan; 3275 struct wmi_tlv *tlv; 3276 struct sk_buff *skb; 3277 u32 peer_qos; 3278 void *ptr; 3279 int len; 3280 int i; 3281 3282 len = sizeof(*tlv) + sizeof(*cmd) + 3283 sizeof(*tlv) + sizeof(*peer_cap) + 3284 sizeof(*tlv) + cap->peer_chan_len * sizeof(*chan); 3285 3286 skb = ath10k_wmi_alloc_skb(ar, len); 3287 if (!skb) 3288 return ERR_PTR(-ENOMEM); 3289 3290 ptr = (void *)skb->data; 3291 tlv = ptr; 3292 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_UPDATE_CMD); 3293 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3294 3295 cmd = (void *)tlv->value; 3296 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 3297 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr); 3298 cmd->peer_state = __cpu_to_le32(arg->peer_state); 3299 3300 ptr += sizeof(*tlv); 3301 ptr += sizeof(*cmd); 3302 3303 tlv = ptr; 3304 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_CAPABILITIES); 3305 tlv->len = __cpu_to_le16(sizeof(*peer_cap)); 3306 peer_cap = (void *)tlv->value; 3307 peer_qos = ath10k_wmi_tlv_prepare_peer_qos(cap->peer_uapsd_queues, 3308 cap->peer_max_sp); 3309 peer_cap->peer_qos = __cpu_to_le32(peer_qos); 3310 peer_cap->buff_sta_support = __cpu_to_le32(cap->buff_sta_support); 3311 peer_cap->off_chan_support = __cpu_to_le32(cap->off_chan_support); 3312 peer_cap->peer_curr_operclass = __cpu_to_le32(cap->peer_curr_operclass); 3313 peer_cap->self_curr_operclass = __cpu_to_le32(cap->self_curr_operclass); 3314 peer_cap->peer_chan_len = __cpu_to_le32(cap->peer_chan_len); 3315 peer_cap->peer_operclass_len = __cpu_to_le32(cap->peer_operclass_len); 3316 3317 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) 3318 peer_cap->peer_operclass[i] = cap->peer_operclass[i]; 3319 3320 peer_cap->is_peer_responder = __cpu_to_le32(cap->is_peer_responder); 3321 peer_cap->pref_offchan_num = __cpu_to_le32(cap->pref_offchan_num); 3322 peer_cap->pref_offchan_bw = __cpu_to_le32(cap->pref_offchan_bw); 3323 3324 ptr += sizeof(*tlv); 3325 ptr += sizeof(*peer_cap); 3326 3327 tlv = ptr; 3328 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3329 tlv->len = __cpu_to_le16(cap->peer_chan_len * sizeof(*chan)); 3330 3331 ptr += sizeof(*tlv); 3332 3333 for (i = 0; i < cap->peer_chan_len; i++) { 3334 tlv = ptr; 3335 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL); 3336 tlv->len = __cpu_to_le16(sizeof(*chan)); 3337 chan = (void *)tlv->value; 3338 ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]); 3339 3340 ptr += sizeof(*tlv); 3341 ptr += sizeof(*chan); 3342 } 3343 3344 ath10k_dbg(ar, ATH10K_DBG_WMI, 3345 "wmi tlv tdls peer update vdev %i state %d n_chans %u\n", 3346 arg->vdev_id, arg->peer_state, cap->peer_chan_len); 3347 return skb; 3348 } 3349 3350 static struct sk_buff * 3351 ath10k_wmi_tlv_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period, 3352 u32 duration, u32 next_offset, 3353 u32 enabled) 3354 { 3355 struct wmi_tlv_set_quiet_cmd *cmd; 3356 struct wmi_tlv *tlv; 3357 struct sk_buff *skb; 3358 3359 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd)); 3360 if (!skb) 3361 return ERR_PTR(-ENOMEM); 3362 3363 tlv = (void *)skb->data; 3364 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_QUIET_CMD); 3365 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3366 cmd = (void *)tlv->value; 3367 3368 /* vdev_id is not in use, set to 0 */ 3369 cmd->vdev_id = __cpu_to_le32(0); 3370 cmd->period = __cpu_to_le32(period); 3371 cmd->duration = __cpu_to_le32(duration); 3372 cmd->next_start = __cpu_to_le32(next_offset); 3373 cmd->enabled = __cpu_to_le32(enabled); 3374 3375 ath10k_dbg(ar, ATH10K_DBG_WMI, 3376 "wmi tlv quiet param: period %u duration %u enabled %d\n", 3377 period, duration, enabled); 3378 return skb; 3379 } 3380 3381 static struct sk_buff * 3382 ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k *ar) 3383 { 3384 struct wmi_tlv_wow_enable_cmd *cmd; 3385 struct wmi_tlv *tlv; 3386 struct sk_buff *skb; 3387 size_t len; 3388 3389 len = sizeof(*tlv) + sizeof(*cmd); 3390 skb = ath10k_wmi_alloc_skb(ar, len); 3391 if (!skb) 3392 return ERR_PTR(-ENOMEM); 3393 3394 tlv = (struct wmi_tlv *)skb->data; 3395 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD); 3396 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3397 cmd = (void *)tlv->value; 3398 3399 cmd->enable = __cpu_to_le32(1); 3400 if (!ar->bus_param.link_can_suspend) 3401 cmd->pause_iface_config = __cpu_to_le32(WOW_IFACE_PAUSE_DISABLED); 3402 3403 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow enable\n"); 3404 return skb; 3405 } 3406 3407 static struct sk_buff * 3408 ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar, 3409 u32 vdev_id, 3410 enum wmi_wow_wakeup_event event, 3411 u32 enable) 3412 { 3413 struct wmi_tlv_wow_add_del_event_cmd *cmd; 3414 struct wmi_tlv *tlv; 3415 struct sk_buff *skb; 3416 size_t len; 3417 3418 len = sizeof(*tlv) + sizeof(*cmd); 3419 skb = ath10k_wmi_alloc_skb(ar, len); 3420 if (!skb) 3421 return ERR_PTR(-ENOMEM); 3422 3423 tlv = (struct wmi_tlv *)skb->data; 3424 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD); 3425 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3426 cmd = (void *)tlv->value; 3427 3428 cmd->vdev_id = __cpu_to_le32(vdev_id); 3429 cmd->is_add = __cpu_to_le32(enable); 3430 cmd->event_bitmap = __cpu_to_le32(1 << event); 3431 3432 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n", 3433 wow_wakeup_event(event), enable, vdev_id); 3434 return skb; 3435 } 3436 3437 static struct sk_buff * 3438 ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k *ar) 3439 { 3440 struct wmi_tlv_wow_host_wakeup_ind *cmd; 3441 struct wmi_tlv *tlv; 3442 struct sk_buff *skb; 3443 size_t len; 3444 3445 len = sizeof(*tlv) + sizeof(*cmd); 3446 skb = ath10k_wmi_alloc_skb(ar, len); 3447 if (!skb) 3448 return ERR_PTR(-ENOMEM); 3449 3450 tlv = (struct wmi_tlv *)skb->data; 3451 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD); 3452 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3453 cmd = (void *)tlv->value; 3454 3455 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n"); 3456 return skb; 3457 } 3458 3459 static struct sk_buff * 3460 ath10k_wmi_tlv_op_gen_wow_add_pattern(struct ath10k *ar, u32 vdev_id, 3461 u32 pattern_id, const u8 *pattern, 3462 const u8 *bitmask, int pattern_len, 3463 int pattern_offset) 3464 { 3465 struct wmi_tlv_wow_add_pattern_cmd *cmd; 3466 struct wmi_tlv_wow_bitmap_pattern *bitmap; 3467 struct wmi_tlv *tlv; 3468 struct sk_buff *skb; 3469 void *ptr; 3470 size_t len; 3471 3472 len = sizeof(*tlv) + sizeof(*cmd) + 3473 sizeof(*tlv) + /* array struct */ 3474 sizeof(*tlv) + sizeof(*bitmap) + /* bitmap */ 3475 sizeof(*tlv) + /* empty ipv4 sync */ 3476 sizeof(*tlv) + /* empty ipv6 sync */ 3477 sizeof(*tlv) + /* empty magic */ 3478 sizeof(*tlv) + /* empty info timeout */ 3479 sizeof(*tlv) + sizeof(u32); /* ratelimit interval */ 3480 3481 skb = ath10k_wmi_alloc_skb(ar, len); 3482 if (!skb) 3483 return ERR_PTR(-ENOMEM); 3484 3485 /* cmd */ 3486 ptr = (void *)skb->data; 3487 tlv = ptr; 3488 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_PATTERN_CMD); 3489 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3490 cmd = (void *)tlv->value; 3491 3492 cmd->vdev_id = __cpu_to_le32(vdev_id); 3493 cmd->pattern_id = __cpu_to_le32(pattern_id); 3494 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN); 3495 3496 ptr += sizeof(*tlv); 3497 ptr += sizeof(*cmd); 3498 3499 /* bitmap */ 3500 tlv = ptr; 3501 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3502 tlv->len = __cpu_to_le16(sizeof(*tlv) + sizeof(*bitmap)); 3503 3504 ptr += sizeof(*tlv); 3505 3506 tlv = ptr; 3507 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_BITMAP_PATTERN_T); 3508 tlv->len = __cpu_to_le16(sizeof(*bitmap)); 3509 bitmap = (void *)tlv->value; 3510 3511 memcpy(bitmap->patternbuf, pattern, pattern_len); 3512 memcpy(bitmap->bitmaskbuf, bitmask, pattern_len); 3513 bitmap->pattern_offset = __cpu_to_le32(pattern_offset); 3514 bitmap->pattern_len = __cpu_to_le32(pattern_len); 3515 bitmap->bitmask_len = __cpu_to_le32(pattern_len); 3516 bitmap->pattern_id = __cpu_to_le32(pattern_id); 3517 3518 ptr += sizeof(*tlv); 3519 ptr += sizeof(*bitmap); 3520 3521 /* ipv4 sync */ 3522 tlv = ptr; 3523 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3524 tlv->len = __cpu_to_le16(0); 3525 3526 ptr += sizeof(*tlv); 3527 3528 /* ipv6 sync */ 3529 tlv = ptr; 3530 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3531 tlv->len = __cpu_to_le16(0); 3532 3533 ptr += sizeof(*tlv); 3534 3535 /* magic */ 3536 tlv = ptr; 3537 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3538 tlv->len = __cpu_to_le16(0); 3539 3540 ptr += sizeof(*tlv); 3541 3542 /* pattern info timeout */ 3543 tlv = ptr; 3544 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32); 3545 tlv->len = __cpu_to_le16(0); 3546 3547 ptr += sizeof(*tlv); 3548 3549 /* ratelimit interval */ 3550 tlv = ptr; 3551 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32); 3552 tlv->len = __cpu_to_le16(sizeof(u32)); 3553 3554 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add pattern vdev_id %d pattern_id %d, pattern_offset %d\n", 3555 vdev_id, pattern_id, pattern_offset); 3556 return skb; 3557 } 3558 3559 static struct sk_buff * 3560 ath10k_wmi_tlv_op_gen_wow_del_pattern(struct ath10k *ar, u32 vdev_id, 3561 u32 pattern_id) 3562 { 3563 struct wmi_tlv_wow_del_pattern_cmd *cmd; 3564 struct wmi_tlv *tlv; 3565 struct sk_buff *skb; 3566 size_t len; 3567 3568 len = sizeof(*tlv) + sizeof(*cmd); 3569 skb = ath10k_wmi_alloc_skb(ar, len); 3570 if (!skb) 3571 return ERR_PTR(-ENOMEM); 3572 3573 tlv = (struct wmi_tlv *)skb->data; 3574 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_DEL_PATTERN_CMD); 3575 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3576 cmd = (void *)tlv->value; 3577 3578 cmd->vdev_id = __cpu_to_le32(vdev_id); 3579 cmd->pattern_id = __cpu_to_le32(pattern_id); 3580 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN); 3581 3582 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow del pattern vdev_id %d pattern_id %d\n", 3583 vdev_id, pattern_id); 3584 return skb; 3585 } 3586 3587 /* Request FW to start PNO operation */ 3588 static struct sk_buff * 3589 ath10k_wmi_tlv_op_gen_config_pno_start(struct ath10k *ar, 3590 u32 vdev_id, 3591 struct wmi_pno_scan_req *pno) 3592 { 3593 struct nlo_configured_parameters *nlo_list; 3594 struct wmi_tlv_wow_nlo_config_cmd *cmd; 3595 struct wmi_tlv *tlv; 3596 struct sk_buff *skb; 3597 __le32 *channel_list; 3598 size_t len; 3599 void *ptr; 3600 u32 i; 3601 3602 len = sizeof(*tlv) + sizeof(*cmd) + 3603 sizeof(*tlv) + 3604 /* TLV place holder for array of structures 3605 * nlo_configured_parameters(nlo_list) 3606 */ 3607 sizeof(*tlv); 3608 /* TLV place holder for array of uint32 channel_list */ 3609 3610 len += sizeof(u32) * min_t(u8, pno->a_networks[0].channel_count, 3611 WMI_NLO_MAX_CHAN); 3612 len += sizeof(struct nlo_configured_parameters) * 3613 min_t(u8, pno->uc_networks_count, WMI_NLO_MAX_SSIDS); 3614 3615 skb = ath10k_wmi_alloc_skb(ar, len); 3616 if (!skb) 3617 return ERR_PTR(-ENOMEM); 3618 3619 ptr = (void *)skb->data; 3620 tlv = ptr; 3621 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD); 3622 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3623 cmd = (void *)tlv->value; 3624 3625 /* wmi_tlv_wow_nlo_config_cmd parameters*/ 3626 cmd->vdev_id = __cpu_to_le32(pno->vdev_id); 3627 cmd->flags = __cpu_to_le32(WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN); 3628 3629 /* current FW does not support min-max range for dwell time */ 3630 cmd->active_dwell_time = __cpu_to_le32(pno->active_max_time); 3631 cmd->passive_dwell_time = __cpu_to_le32(pno->passive_max_time); 3632 3633 if (pno->do_passive_scan) 3634 cmd->flags |= __cpu_to_le32(WMI_NLO_CONFIG_SCAN_PASSIVE); 3635 3636 /* copy scan interval */ 3637 cmd->fast_scan_period = __cpu_to_le32(pno->fast_scan_period); 3638 cmd->slow_scan_period = __cpu_to_le32(pno->slow_scan_period); 3639 cmd->fast_scan_max_cycles = __cpu_to_le32(pno->fast_scan_max_cycles); 3640 cmd->delay_start_time = __cpu_to_le32(pno->delay_start_time); 3641 3642 if (pno->enable_pno_scan_randomization) { 3643 cmd->flags |= __cpu_to_le32(WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ | 3644 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ); 3645 ether_addr_copy(cmd->mac_addr.addr, pno->mac_addr); 3646 ether_addr_copy(cmd->mac_mask.addr, pno->mac_addr_mask); 3647 } 3648 3649 ptr += sizeof(*tlv); 3650 ptr += sizeof(*cmd); 3651 3652 /* nlo_configured_parameters(nlo_list) */ 3653 cmd->no_of_ssids = __cpu_to_le32(min_t(u8, pno->uc_networks_count, 3654 WMI_NLO_MAX_SSIDS)); 3655 3656 tlv = ptr; 3657 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3658 tlv->len = __cpu_to_le16(len); 3659 3660 ptr += sizeof(*tlv); 3661 nlo_list = ptr; 3662 for (i = 0; i < __le32_to_cpu(cmd->no_of_ssids); i++) { 3663 tlv = (struct wmi_tlv *)(&nlo_list[i].tlv_header); 3664 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE); 3665 tlv->len = __cpu_to_le16(sizeof(struct nlo_configured_parameters) - 3666 sizeof(*tlv)); 3667 3668 /* copy ssid and it's length */ 3669 nlo_list[i].ssid.valid = __cpu_to_le32(true); 3670 nlo_list[i].ssid.ssid.ssid_len = pno->a_networks[i].ssid.ssid_len; 3671 memcpy(nlo_list[i].ssid.ssid.ssid, 3672 pno->a_networks[i].ssid.ssid, 3673 __le32_to_cpu(nlo_list[i].ssid.ssid.ssid_len)); 3674 3675 /* copy rssi threshold */ 3676 if (pno->a_networks[i].rssi_threshold && 3677 pno->a_networks[i].rssi_threshold > -300) { 3678 nlo_list[i].rssi_cond.valid = __cpu_to_le32(true); 3679 nlo_list[i].rssi_cond.rssi = 3680 __cpu_to_le32(pno->a_networks[i].rssi_threshold); 3681 } 3682 3683 nlo_list[i].bcast_nw_type.valid = __cpu_to_le32(true); 3684 nlo_list[i].bcast_nw_type.bcast_nw_type = 3685 __cpu_to_le32(pno->a_networks[i].bcast_nw_type); 3686 } 3687 3688 ptr += __le32_to_cpu(cmd->no_of_ssids) * sizeof(struct nlo_configured_parameters); 3689 3690 /* copy channel info */ 3691 cmd->num_of_channels = __cpu_to_le32(min_t(u8, 3692 pno->a_networks[0].channel_count, 3693 WMI_NLO_MAX_CHAN)); 3694 3695 tlv = ptr; 3696 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32); 3697 tlv->len = __cpu_to_le16(__le32_to_cpu(cmd->num_of_channels) * 3698 sizeof(u_int32_t)); 3699 ptr += sizeof(*tlv); 3700 3701 channel_list = (__le32 *)ptr; 3702 for (i = 0; i < __le32_to_cpu(cmd->num_of_channels); i++) 3703 channel_list[i] = __cpu_to_le32(pno->a_networks[0].channels[i]); 3704 3705 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start pno config vdev_id %d\n", 3706 vdev_id); 3707 3708 return skb; 3709 } 3710 3711 /* Request FW to stop ongoing PNO operation */ 3712 static struct sk_buff *ath10k_wmi_tlv_op_gen_config_pno_stop(struct ath10k *ar, 3713 u32 vdev_id) 3714 { 3715 struct wmi_tlv_wow_nlo_config_cmd *cmd; 3716 struct wmi_tlv *tlv; 3717 struct sk_buff *skb; 3718 void *ptr; 3719 size_t len; 3720 3721 len = sizeof(*tlv) + sizeof(*cmd) + 3722 sizeof(*tlv) + 3723 /* TLV place holder for array of structures 3724 * nlo_configured_parameters(nlo_list) 3725 */ 3726 sizeof(*tlv); 3727 /* TLV place holder for array of uint32 channel_list */ 3728 skb = ath10k_wmi_alloc_skb(ar, len); 3729 if (!skb) 3730 return ERR_PTR(-ENOMEM); 3731 3732 ptr = (void *)skb->data; 3733 tlv = ptr; 3734 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD); 3735 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3736 cmd = (void *)tlv->value; 3737 3738 cmd->vdev_id = __cpu_to_le32(vdev_id); 3739 cmd->flags = __cpu_to_le32(WMI_NLO_CONFIG_STOP); 3740 3741 ptr += sizeof(*tlv); 3742 ptr += sizeof(*cmd); 3743 3744 /* nlo_configured_parameters(nlo_list) */ 3745 tlv = ptr; 3746 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT); 3747 tlv->len = __cpu_to_le16(0); 3748 3749 ptr += sizeof(*tlv); 3750 3751 /* channel list */ 3752 tlv = ptr; 3753 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32); 3754 tlv->len = __cpu_to_le16(0); 3755 3756 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop pno config vdev_id %d\n", vdev_id); 3757 return skb; 3758 } 3759 3760 static struct sk_buff * 3761 ath10k_wmi_tlv_op_gen_config_pno(struct ath10k *ar, u32 vdev_id, 3762 struct wmi_pno_scan_req *pno_scan) 3763 { 3764 if (pno_scan->enable) 3765 return ath10k_wmi_tlv_op_gen_config_pno_start(ar, vdev_id, pno_scan); 3766 else 3767 return ath10k_wmi_tlv_op_gen_config_pno_stop(ar, vdev_id); 3768 } 3769 3770 static struct sk_buff * 3771 ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k *ar, bool enable) 3772 { 3773 struct wmi_tlv_adaptive_qcs *cmd; 3774 struct wmi_tlv *tlv; 3775 struct sk_buff *skb; 3776 void *ptr; 3777 size_t len; 3778 3779 len = sizeof(*tlv) + sizeof(*cmd); 3780 skb = ath10k_wmi_alloc_skb(ar, len); 3781 if (!skb) 3782 return ERR_PTR(-ENOMEM); 3783 3784 ptr = (void *)skb->data; 3785 tlv = ptr; 3786 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESMGR_ADAPTIVE_OCS_CMD); 3787 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3788 cmd = (void *)tlv->value; 3789 cmd->enable = __cpu_to_le32(enable ? 1 : 0); 3790 3791 ptr += sizeof(*tlv); 3792 ptr += sizeof(*cmd); 3793 3794 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv adaptive qcs %d\n", enable); 3795 return skb; 3796 } 3797 3798 static struct sk_buff * 3799 ath10k_wmi_tlv_op_gen_echo(struct ath10k *ar, u32 value) 3800 { 3801 struct wmi_echo_cmd *cmd; 3802 struct wmi_tlv *tlv; 3803 struct sk_buff *skb; 3804 void *ptr; 3805 size_t len; 3806 3807 len = sizeof(*tlv) + sizeof(*cmd); 3808 skb = ath10k_wmi_alloc_skb(ar, len); 3809 if (!skb) 3810 return ERR_PTR(-ENOMEM); 3811 3812 ptr = (void *)skb->data; 3813 tlv = ptr; 3814 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_ECHO_CMD); 3815 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3816 cmd = (void *)tlv->value; 3817 cmd->value = cpu_to_le32(value); 3818 3819 ptr += sizeof(*tlv); 3820 ptr += sizeof(*cmd); 3821 3822 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv echo value 0x%08x\n", value); 3823 return skb; 3824 } 3825 3826 static struct sk_buff * 3827 ath10k_wmi_tlv_op_gen_vdev_spectral_conf(struct ath10k *ar, 3828 const struct wmi_vdev_spectral_conf_arg *arg) 3829 { 3830 struct wmi_vdev_spectral_conf_cmd *cmd; 3831 struct sk_buff *skb; 3832 struct wmi_tlv *tlv; 3833 void *ptr; 3834 size_t len; 3835 3836 len = sizeof(*tlv) + sizeof(*cmd); 3837 skb = ath10k_wmi_alloc_skb(ar, len); 3838 if (!skb) 3839 return ERR_PTR(-ENOMEM); 3840 3841 ptr = (void *)skb->data; 3842 tlv = ptr; 3843 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SPECTRAL_CONFIGURE_CMD); 3844 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3845 cmd = (void *)tlv->value; 3846 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 3847 cmd->scan_count = __cpu_to_le32(arg->scan_count); 3848 cmd->scan_period = __cpu_to_le32(arg->scan_period); 3849 cmd->scan_priority = __cpu_to_le32(arg->scan_priority); 3850 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size); 3851 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena); 3852 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena); 3853 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref); 3854 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay); 3855 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr); 3856 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr); 3857 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode); 3858 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode); 3859 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr); 3860 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format); 3861 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode); 3862 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale); 3863 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj); 3864 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask); 3865 3866 return skb; 3867 } 3868 3869 static struct sk_buff * 3870 ath10k_wmi_tlv_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, 3871 u32 trigger, u32 enable) 3872 { 3873 struct wmi_vdev_spectral_enable_cmd *cmd; 3874 struct sk_buff *skb; 3875 struct wmi_tlv *tlv; 3876 void *ptr; 3877 size_t len; 3878 3879 len = sizeof(*tlv) + sizeof(*cmd); 3880 skb = ath10k_wmi_alloc_skb(ar, len); 3881 if (!skb) 3882 return ERR_PTR(-ENOMEM); 3883 3884 ptr = (void *)skb->data; 3885 tlv = ptr; 3886 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SPECTRAL_ENABLE_CMD); 3887 tlv->len = __cpu_to_le16(sizeof(*cmd)); 3888 cmd = (void *)tlv->value; 3889 cmd->vdev_id = __cpu_to_le32(vdev_id); 3890 cmd->trigger_cmd = __cpu_to_le32(trigger); 3891 cmd->enable_cmd = __cpu_to_le32(enable); 3892 3893 return skb; 3894 } 3895 3896 /****************/ 3897 /* TLV mappings */ 3898 /****************/ 3899 3900 static struct wmi_cmd_map wmi_tlv_cmd_map = { 3901 .init_cmdid = WMI_TLV_INIT_CMDID, 3902 .start_scan_cmdid = WMI_TLV_START_SCAN_CMDID, 3903 .stop_scan_cmdid = WMI_TLV_STOP_SCAN_CMDID, 3904 .scan_chan_list_cmdid = WMI_TLV_SCAN_CHAN_LIST_CMDID, 3905 .scan_sch_prio_tbl_cmdid = WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID, 3906 .scan_prob_req_oui_cmdid = WMI_TLV_SCAN_PROB_REQ_OUI_CMDID, 3907 .pdev_set_regdomain_cmdid = WMI_TLV_PDEV_SET_REGDOMAIN_CMDID, 3908 .pdev_set_channel_cmdid = WMI_TLV_PDEV_SET_CHANNEL_CMDID, 3909 .pdev_set_param_cmdid = WMI_TLV_PDEV_SET_PARAM_CMDID, 3910 .pdev_pktlog_enable_cmdid = WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID, 3911 .pdev_pktlog_disable_cmdid = WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID, 3912 .pdev_set_wmm_params_cmdid = WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID, 3913 .pdev_set_ht_cap_ie_cmdid = WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID, 3914 .pdev_set_vht_cap_ie_cmdid = WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID, 3915 .pdev_set_dscp_tid_map_cmdid = WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID, 3916 .pdev_set_quiet_mode_cmdid = WMI_TLV_PDEV_SET_QUIET_MODE_CMDID, 3917 .pdev_green_ap_ps_enable_cmdid = WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID, 3918 .pdev_get_tpc_config_cmdid = WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID, 3919 .pdev_set_base_macaddr_cmdid = WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID, 3920 .vdev_create_cmdid = WMI_TLV_VDEV_CREATE_CMDID, 3921 .vdev_delete_cmdid = WMI_TLV_VDEV_DELETE_CMDID, 3922 .vdev_start_request_cmdid = WMI_TLV_VDEV_START_REQUEST_CMDID, 3923 .vdev_restart_request_cmdid = WMI_TLV_VDEV_RESTART_REQUEST_CMDID, 3924 .vdev_up_cmdid = WMI_TLV_VDEV_UP_CMDID, 3925 .vdev_stop_cmdid = WMI_TLV_VDEV_STOP_CMDID, 3926 .vdev_down_cmdid = WMI_TLV_VDEV_DOWN_CMDID, 3927 .vdev_set_param_cmdid = WMI_TLV_VDEV_SET_PARAM_CMDID, 3928 .vdev_install_key_cmdid = WMI_TLV_VDEV_INSTALL_KEY_CMDID, 3929 .peer_create_cmdid = WMI_TLV_PEER_CREATE_CMDID, 3930 .peer_delete_cmdid = WMI_TLV_PEER_DELETE_CMDID, 3931 .peer_flush_tids_cmdid = WMI_TLV_PEER_FLUSH_TIDS_CMDID, 3932 .peer_set_param_cmdid = WMI_TLV_PEER_SET_PARAM_CMDID, 3933 .peer_assoc_cmdid = WMI_TLV_PEER_ASSOC_CMDID, 3934 .peer_add_wds_entry_cmdid = WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID, 3935 .peer_remove_wds_entry_cmdid = WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID, 3936 .peer_mcast_group_cmdid = WMI_TLV_PEER_MCAST_GROUP_CMDID, 3937 .bcn_tx_cmdid = WMI_TLV_BCN_TX_CMDID, 3938 .pdev_send_bcn_cmdid = WMI_TLV_PDEV_SEND_BCN_CMDID, 3939 .bcn_tmpl_cmdid = WMI_TLV_BCN_TMPL_CMDID, 3940 .bcn_filter_rx_cmdid = WMI_TLV_BCN_FILTER_RX_CMDID, 3941 .prb_req_filter_rx_cmdid = WMI_TLV_PRB_REQ_FILTER_RX_CMDID, 3942 .mgmt_tx_cmdid = WMI_TLV_MGMT_TX_CMDID, 3943 .mgmt_tx_send_cmdid = WMI_TLV_MGMT_TX_SEND_CMD, 3944 .prb_tmpl_cmdid = WMI_TLV_PRB_TMPL_CMDID, 3945 .addba_clear_resp_cmdid = WMI_TLV_ADDBA_CLEAR_RESP_CMDID, 3946 .addba_send_cmdid = WMI_TLV_ADDBA_SEND_CMDID, 3947 .addba_status_cmdid = WMI_TLV_ADDBA_STATUS_CMDID, 3948 .delba_send_cmdid = WMI_TLV_DELBA_SEND_CMDID, 3949 .addba_set_resp_cmdid = WMI_TLV_ADDBA_SET_RESP_CMDID, 3950 .send_singleamsdu_cmdid = WMI_TLV_SEND_SINGLEAMSDU_CMDID, 3951 .sta_powersave_mode_cmdid = WMI_TLV_STA_POWERSAVE_MODE_CMDID, 3952 .sta_powersave_param_cmdid = WMI_TLV_STA_POWERSAVE_PARAM_CMDID, 3953 .sta_mimo_ps_mode_cmdid = WMI_TLV_STA_MIMO_PS_MODE_CMDID, 3954 .pdev_dfs_enable_cmdid = WMI_TLV_PDEV_DFS_ENABLE_CMDID, 3955 .pdev_dfs_disable_cmdid = WMI_TLV_PDEV_DFS_DISABLE_CMDID, 3956 .roam_scan_mode = WMI_TLV_ROAM_SCAN_MODE, 3957 .roam_scan_rssi_threshold = WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD, 3958 .roam_scan_period = WMI_TLV_ROAM_SCAN_PERIOD, 3959 .roam_scan_rssi_change_threshold = 3960 WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, 3961 .roam_ap_profile = WMI_TLV_ROAM_AP_PROFILE, 3962 .ofl_scan_add_ap_profile = WMI_TLV_ROAM_AP_PROFILE, 3963 .ofl_scan_remove_ap_profile = WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE, 3964 .ofl_scan_period = WMI_TLV_OFL_SCAN_PERIOD, 3965 .p2p_dev_set_device_info = WMI_TLV_P2P_DEV_SET_DEVICE_INFO, 3966 .p2p_dev_set_discoverability = WMI_TLV_P2P_DEV_SET_DISCOVERABILITY, 3967 .p2p_go_set_beacon_ie = WMI_TLV_P2P_GO_SET_BEACON_IE, 3968 .p2p_go_set_probe_resp_ie = WMI_TLV_P2P_GO_SET_PROBE_RESP_IE, 3969 .p2p_set_vendor_ie_data_cmdid = WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID, 3970 .ap_ps_peer_param_cmdid = WMI_TLV_AP_PS_PEER_PARAM_CMDID, 3971 .ap_ps_peer_uapsd_coex_cmdid = WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID, 3972 .peer_rate_retry_sched_cmdid = WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID, 3973 .wlan_profile_trigger_cmdid = WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID, 3974 .wlan_profile_set_hist_intvl_cmdid = 3975 WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID, 3976 .wlan_profile_get_profile_data_cmdid = 3977 WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID, 3978 .wlan_profile_enable_profile_id_cmdid = 3979 WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID, 3980 .wlan_profile_list_profile_id_cmdid = 3981 WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID, 3982 .pdev_suspend_cmdid = WMI_TLV_PDEV_SUSPEND_CMDID, 3983 .pdev_resume_cmdid = WMI_TLV_PDEV_RESUME_CMDID, 3984 .add_bcn_filter_cmdid = WMI_TLV_ADD_BCN_FILTER_CMDID, 3985 .rmv_bcn_filter_cmdid = WMI_TLV_RMV_BCN_FILTER_CMDID, 3986 .wow_add_wake_pattern_cmdid = WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID, 3987 .wow_del_wake_pattern_cmdid = WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID, 3988 .wow_enable_disable_wake_event_cmdid = 3989 WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, 3990 .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID, 3991 .wow_hostwakeup_from_sleep_cmdid = 3992 WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, 3993 .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID, 3994 .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID, 3995 .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID, 3996 .vdev_spectral_scan_enable_cmdid = WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID, 3997 .request_stats_cmdid = WMI_TLV_REQUEST_STATS_CMDID, 3998 .set_arp_ns_offload_cmdid = WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID, 3999 .network_list_offload_config_cmdid = 4000 WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, 4001 .gtk_offload_cmdid = WMI_TLV_GTK_OFFLOAD_CMDID, 4002 .csa_offload_enable_cmdid = WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID, 4003 .csa_offload_chanswitch_cmdid = WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID, 4004 .chatter_set_mode_cmdid = WMI_TLV_CHATTER_SET_MODE_CMDID, 4005 .peer_tid_addba_cmdid = WMI_TLV_PEER_TID_ADDBA_CMDID, 4006 .peer_tid_delba_cmdid = WMI_TLV_PEER_TID_DELBA_CMDID, 4007 .sta_dtim_ps_method_cmdid = WMI_TLV_STA_DTIM_PS_METHOD_CMDID, 4008 .sta_uapsd_auto_trig_cmdid = WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID, 4009 .sta_keepalive_cmd = WMI_TLV_STA_KEEPALIVE_CMDID, 4010 .echo_cmdid = WMI_TLV_ECHO_CMDID, 4011 .pdev_utf_cmdid = WMI_TLV_PDEV_UTF_CMDID, 4012 .dbglog_cfg_cmdid = WMI_TLV_DBGLOG_CFG_CMDID, 4013 .pdev_qvit_cmdid = WMI_TLV_PDEV_QVIT_CMDID, 4014 .pdev_ftm_intg_cmdid = WMI_TLV_PDEV_FTM_INTG_CMDID, 4015 .vdev_set_keepalive_cmdid = WMI_TLV_VDEV_SET_KEEPALIVE_CMDID, 4016 .vdev_get_keepalive_cmdid = WMI_TLV_VDEV_GET_KEEPALIVE_CMDID, 4017 .force_fw_hang_cmdid = WMI_TLV_FORCE_FW_HANG_CMDID, 4018 .gpio_config_cmdid = WMI_TLV_GPIO_CONFIG_CMDID, 4019 .gpio_output_cmdid = WMI_TLV_GPIO_OUTPUT_CMDID, 4020 .pdev_get_temperature_cmdid = WMI_TLV_PDEV_GET_TEMPERATURE_CMDID, 4021 .vdev_set_wmm_params_cmdid = WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID, 4022 .tdls_set_state_cmdid = WMI_TLV_TDLS_SET_STATE_CMDID, 4023 .tdls_peer_update_cmdid = WMI_TLV_TDLS_PEER_UPDATE_CMDID, 4024 .adaptive_qcs_cmdid = WMI_TLV_RESMGR_ADAPTIVE_OCS_CMDID, 4025 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED, 4026 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED, 4027 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED, 4028 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED, 4029 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED, 4030 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED, 4031 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED, 4032 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED, 4033 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED, 4034 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED, 4035 .oem_req_cmdid = WMI_CMD_UNSUPPORTED, 4036 .nan_cmdid = WMI_CMD_UNSUPPORTED, 4037 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED, 4038 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED, 4039 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED, 4040 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED, 4041 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED, 4042 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED, 4043 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED, 4044 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED, 4045 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED, 4046 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED, 4047 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED, 4048 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED, 4049 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED, 4050 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED, 4051 .fwtest_cmdid = WMI_CMD_UNSUPPORTED, 4052 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED, 4053 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED, 4054 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED, 4055 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED, 4056 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED, 4057 }; 4058 4059 static struct wmi_pdev_param_map wmi_tlv_pdev_param_map = { 4060 .tx_chain_mask = WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK, 4061 .rx_chain_mask = WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK, 4062 .txpower_limit2g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G, 4063 .txpower_limit5g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G, 4064 .txpower_scale = WMI_TLV_PDEV_PARAM_TXPOWER_SCALE, 4065 .beacon_gen_mode = WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE, 4066 .beacon_tx_mode = WMI_TLV_PDEV_PARAM_BEACON_TX_MODE, 4067 .resmgr_offchan_mode = WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE, 4068 .protection_mode = WMI_TLV_PDEV_PARAM_PROTECTION_MODE, 4069 .dynamic_bw = WMI_TLV_PDEV_PARAM_DYNAMIC_BW, 4070 .non_agg_sw_retry_th = WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH, 4071 .agg_sw_retry_th = WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH, 4072 .sta_kickout_th = WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH, 4073 .ac_aggrsize_scaling = WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING, 4074 .ltr_enable = WMI_TLV_PDEV_PARAM_LTR_ENABLE, 4075 .ltr_ac_latency_be = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE, 4076 .ltr_ac_latency_bk = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK, 4077 .ltr_ac_latency_vi = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI, 4078 .ltr_ac_latency_vo = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO, 4079 .ltr_ac_latency_timeout = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT, 4080 .ltr_sleep_override = WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE, 4081 .ltr_rx_override = WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE, 4082 .ltr_tx_activity_timeout = WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT, 4083 .l1ss_enable = WMI_TLV_PDEV_PARAM_L1SS_ENABLE, 4084 .dsleep_enable = WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE, 4085 .pcielp_txbuf_flush = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH, 4086 .pcielp_txbuf_watermark = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN, 4087 .pcielp_txbuf_tmo_en = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN, 4088 .pcielp_txbuf_tmo_value = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE, 4089 .pdev_stats_update_period = WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD, 4090 .vdev_stats_update_period = WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD, 4091 .peer_stats_update_period = WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD, 4092 .bcnflt_stats_update_period = 4093 WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD, 4094 .pmf_qos = WMI_TLV_PDEV_PARAM_PMF_QOS, 4095 .arp_ac_override = WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE, 4096 .dcs = WMI_TLV_PDEV_PARAM_DCS, 4097 .ani_enable = WMI_TLV_PDEV_PARAM_ANI_ENABLE, 4098 .ani_poll_period = WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD, 4099 .ani_listen_period = WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD, 4100 .ani_ofdm_level = WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL, 4101 .ani_cck_level = WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL, 4102 .dyntxchain = WMI_TLV_PDEV_PARAM_DYNTXCHAIN, 4103 .proxy_sta = WMI_TLV_PDEV_PARAM_PROXY_STA, 4104 .idle_ps_config = WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG, 4105 .power_gating_sleep = WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP, 4106 .fast_channel_reset = WMI_TLV_PDEV_PARAM_UNSUPPORTED, 4107 .burst_dur = WMI_TLV_PDEV_PARAM_BURST_DUR, 4108 .burst_enable = WMI_TLV_PDEV_PARAM_BURST_ENABLE, 4109 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED, 4110 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED, 4111 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED, 4112 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED, 4113 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED, 4114 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED, 4115 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED, 4116 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED, 4117 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED, 4118 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED, 4119 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED, 4120 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED, 4121 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED, 4122 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED, 4123 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED, 4124 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED, 4125 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED, 4126 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED, 4127 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED, 4128 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED, 4129 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED, 4130 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED, 4131 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED, 4132 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED, 4133 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED, 4134 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED, 4135 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED, 4136 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED, 4137 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED, 4138 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED, 4139 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED, 4140 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED, 4141 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED, 4142 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED, 4143 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED, 4144 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED, 4145 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED, 4146 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED, 4147 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED, 4148 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED, 4149 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED, 4150 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED, 4151 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED, 4152 }; 4153 4154 static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = { 4155 .rts_threshold = WMI_TLV_VDEV_PARAM_RTS_THRESHOLD, 4156 .fragmentation_threshold = WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD, 4157 .beacon_interval = WMI_TLV_VDEV_PARAM_BEACON_INTERVAL, 4158 .listen_interval = WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL, 4159 .multicast_rate = WMI_TLV_VDEV_PARAM_MULTICAST_RATE, 4160 .mgmt_tx_rate = WMI_TLV_VDEV_PARAM_MGMT_TX_RATE, 4161 .slot_time = WMI_TLV_VDEV_PARAM_SLOT_TIME, 4162 .preamble = WMI_TLV_VDEV_PARAM_PREAMBLE, 4163 .swba_time = WMI_TLV_VDEV_PARAM_SWBA_TIME, 4164 .wmi_vdev_stats_update_period = WMI_TLV_VDEV_STATS_UPDATE_PERIOD, 4165 .wmi_vdev_pwrsave_ageout_time = WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME, 4166 .wmi_vdev_host_swba_interval = WMI_TLV_VDEV_HOST_SWBA_INTERVAL, 4167 .dtim_period = WMI_TLV_VDEV_PARAM_DTIM_PERIOD, 4168 .wmi_vdev_oc_scheduler_air_time_limit = 4169 WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT, 4170 .wds = WMI_TLV_VDEV_PARAM_WDS, 4171 .atim_window = WMI_TLV_VDEV_PARAM_ATIM_WINDOW, 4172 .bmiss_count_max = WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX, 4173 .bmiss_first_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT, 4174 .bmiss_final_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT, 4175 .feature_wmm = WMI_TLV_VDEV_PARAM_FEATURE_WMM, 4176 .chwidth = WMI_TLV_VDEV_PARAM_CHWIDTH, 4177 .chextoffset = WMI_TLV_VDEV_PARAM_CHEXTOFFSET, 4178 .disable_htprotection = WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION, 4179 .sta_quickkickout = WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT, 4180 .mgmt_rate = WMI_TLV_VDEV_PARAM_MGMT_RATE, 4181 .protection_mode = WMI_TLV_VDEV_PARAM_PROTECTION_MODE, 4182 .fixed_rate = WMI_TLV_VDEV_PARAM_FIXED_RATE, 4183 .sgi = WMI_TLV_VDEV_PARAM_SGI, 4184 .ldpc = WMI_TLV_VDEV_PARAM_LDPC, 4185 .tx_stbc = WMI_TLV_VDEV_PARAM_TX_STBC, 4186 .rx_stbc = WMI_TLV_VDEV_PARAM_RX_STBC, 4187 .intra_bss_fwd = WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD, 4188 .def_keyid = WMI_TLV_VDEV_PARAM_DEF_KEYID, 4189 .nss = WMI_TLV_VDEV_PARAM_NSS, 4190 .bcast_data_rate = WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE, 4191 .mcast_data_rate = WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE, 4192 .mcast_indicate = WMI_TLV_VDEV_PARAM_MCAST_INDICATE, 4193 .dhcp_indicate = WMI_TLV_VDEV_PARAM_DHCP_INDICATE, 4194 .unknown_dest_indicate = WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE, 4195 .ap_keepalive_min_idle_inactive_time_secs = 4196 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS, 4197 .ap_keepalive_max_idle_inactive_time_secs = 4198 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS, 4199 .ap_keepalive_max_unresponsive_time_secs = 4200 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS, 4201 .ap_enable_nawds = WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS, 4202 .mcast2ucast_set = WMI_TLV_VDEV_PARAM_UNSUPPORTED, 4203 .enable_rtscts = WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS, 4204 .txbf = WMI_TLV_VDEV_PARAM_TXBF, 4205 .packet_powersave = WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE, 4206 .drop_unencry = WMI_TLV_VDEV_PARAM_DROP_UNENCRY, 4207 .tx_encap_type = WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE, 4208 .ap_detect_out_of_sync_sleeping_sta_time_secs = 4209 WMI_TLV_VDEV_PARAM_UNSUPPORTED, 4210 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED, 4211 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED, 4212 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED, 4213 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED, 4214 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED, 4215 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, 4216 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED, 4217 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED, 4218 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED, 4219 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED, 4220 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED, 4221 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED, 4222 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED, 4223 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, 4224 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, 4225 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, 4226 }; 4227 4228 static const struct wmi_ops wmi_tlv_ops = { 4229 .rx = ath10k_wmi_tlv_op_rx, 4230 .map_svc = wmi_tlv_svc_map, 4231 .map_svc_ext = wmi_tlv_svc_map_ext, 4232 4233 .pull_scan = ath10k_wmi_tlv_op_pull_scan_ev, 4234 .pull_mgmt_rx = ath10k_wmi_tlv_op_pull_mgmt_rx_ev, 4235 .pull_mgmt_tx_compl = ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev, 4236 .pull_mgmt_tx_bundle_compl = ath10k_wmi_tlv_op_pull_mgmt_tx_bundle_compl_ev, 4237 .pull_ch_info = ath10k_wmi_tlv_op_pull_ch_info_ev, 4238 .pull_vdev_start = ath10k_wmi_tlv_op_pull_vdev_start_ev, 4239 .pull_peer_kick = ath10k_wmi_tlv_op_pull_peer_kick_ev, 4240 .pull_swba = ath10k_wmi_tlv_op_pull_swba_ev, 4241 .pull_phyerr_hdr = ath10k_wmi_tlv_op_pull_phyerr_ev_hdr, 4242 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev, 4243 .pull_svc_rdy = ath10k_wmi_tlv_op_pull_svc_rdy_ev, 4244 .pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev, 4245 .pull_svc_avail = ath10k_wmi_tlv_op_pull_svc_avail, 4246 .pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats, 4247 .pull_roam_ev = ath10k_wmi_tlv_op_pull_roam_ev, 4248 .pull_wow_event = ath10k_wmi_tlv_op_pull_wow_ev, 4249 .pull_echo_ev = ath10k_wmi_tlv_op_pull_echo_ev, 4250 .get_txbf_conf_scheme = ath10k_wmi_tlv_txbf_conf_scheme, 4251 4252 .gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend, 4253 .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume, 4254 .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd, 4255 .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param, 4256 .gen_init = ath10k_wmi_tlv_op_gen_init, 4257 .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan, 4258 .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan, 4259 .gen_vdev_create = ath10k_wmi_tlv_op_gen_vdev_create, 4260 .gen_vdev_delete = ath10k_wmi_tlv_op_gen_vdev_delete, 4261 .gen_vdev_start = ath10k_wmi_tlv_op_gen_vdev_start, 4262 .gen_vdev_stop = ath10k_wmi_tlv_op_gen_vdev_stop, 4263 .gen_vdev_up = ath10k_wmi_tlv_op_gen_vdev_up, 4264 .gen_vdev_down = ath10k_wmi_tlv_op_gen_vdev_down, 4265 .gen_vdev_set_param = ath10k_wmi_tlv_op_gen_vdev_set_param, 4266 .gen_vdev_install_key = ath10k_wmi_tlv_op_gen_vdev_install_key, 4267 .gen_vdev_wmm_conf = ath10k_wmi_tlv_op_gen_vdev_wmm_conf, 4268 .gen_peer_create = ath10k_wmi_tlv_op_gen_peer_create, 4269 .gen_peer_delete = ath10k_wmi_tlv_op_gen_peer_delete, 4270 .gen_peer_flush = ath10k_wmi_tlv_op_gen_peer_flush, 4271 .gen_peer_set_param = ath10k_wmi_tlv_op_gen_peer_set_param, 4272 .gen_peer_assoc = ath10k_wmi_tlv_op_gen_peer_assoc, 4273 .gen_set_psmode = ath10k_wmi_tlv_op_gen_set_psmode, 4274 .gen_set_sta_ps = ath10k_wmi_tlv_op_gen_set_sta_ps, 4275 .gen_set_ap_ps = ath10k_wmi_tlv_op_gen_set_ap_ps, 4276 .gen_scan_chan_list = ath10k_wmi_tlv_op_gen_scan_chan_list, 4277 .gen_scan_prob_req_oui = ath10k_wmi_tlv_op_gen_scan_prob_req_oui, 4278 .gen_beacon_dma = ath10k_wmi_tlv_op_gen_beacon_dma, 4279 .gen_pdev_set_wmm = ath10k_wmi_tlv_op_gen_pdev_set_wmm, 4280 .gen_request_stats = ath10k_wmi_tlv_op_gen_request_stats, 4281 .gen_force_fw_hang = ath10k_wmi_tlv_op_gen_force_fw_hang, 4282 /* .gen_mgmt_tx = not implemented; HTT is used */ 4283 .gen_mgmt_tx_send = ath10k_wmi_tlv_op_gen_mgmt_tx_send, 4284 .gen_dbglog_cfg = ath10k_wmi_tlv_op_gen_dbglog_cfg, 4285 .gen_pktlog_enable = ath10k_wmi_tlv_op_gen_pktlog_enable, 4286 .gen_pktlog_disable = ath10k_wmi_tlv_op_gen_pktlog_disable, 4287 .gen_pdev_set_quiet_mode = ath10k_wmi_tlv_op_gen_pdev_set_quiet_mode, 4288 .gen_pdev_get_temperature = ath10k_wmi_tlv_op_gen_pdev_get_temperature, 4289 /* .gen_addba_clear_resp not implemented */ 4290 /* .gen_addba_send not implemented */ 4291 /* .gen_addba_set_resp not implemented */ 4292 /* .gen_delba_send not implemented */ 4293 .gen_bcn_tmpl = ath10k_wmi_tlv_op_gen_bcn_tmpl, 4294 .gen_prb_tmpl = ath10k_wmi_tlv_op_gen_prb_tmpl, 4295 .gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie, 4296 .gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd, 4297 .gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive, 4298 .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable, 4299 .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event, 4300 .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind, 4301 .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern, 4302 .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern, 4303 .gen_wow_config_pno = ath10k_wmi_tlv_op_gen_config_pno, 4304 .gen_update_fw_tdls_state = ath10k_wmi_tlv_op_gen_update_fw_tdls_state, 4305 .gen_tdls_peer_update = ath10k_wmi_tlv_op_gen_tdls_peer_update, 4306 .gen_adaptive_qcs = ath10k_wmi_tlv_op_gen_adaptive_qcs, 4307 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill, 4308 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype, 4309 .gen_echo = ath10k_wmi_tlv_op_gen_echo, 4310 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf, 4311 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable, 4312 }; 4313 4314 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = { 4315 .auth = WMI_TLV_PEER_AUTH, 4316 .qos = WMI_TLV_PEER_QOS, 4317 .need_ptk_4_way = WMI_TLV_PEER_NEED_PTK_4_WAY, 4318 .need_gtk_2_way = WMI_TLV_PEER_NEED_GTK_2_WAY, 4319 .apsd = WMI_TLV_PEER_APSD, 4320 .ht = WMI_TLV_PEER_HT, 4321 .bw40 = WMI_TLV_PEER_40MHZ, 4322 .stbc = WMI_TLV_PEER_STBC, 4323 .ldbc = WMI_TLV_PEER_LDPC, 4324 .dyn_mimops = WMI_TLV_PEER_DYN_MIMOPS, 4325 .static_mimops = WMI_TLV_PEER_STATIC_MIMOPS, 4326 .spatial_mux = WMI_TLV_PEER_SPATIAL_MUX, 4327 .vht = WMI_TLV_PEER_VHT, 4328 .bw80 = WMI_TLV_PEER_80MHZ, 4329 .pmf = WMI_TLV_PEER_PMF, 4330 .bw160 = WMI_TLV_PEER_160MHZ, 4331 }; 4332 4333 /************/ 4334 /* TLV init */ 4335 /************/ 4336 4337 void ath10k_wmi_tlv_attach(struct ath10k *ar) 4338 { 4339 ar->wmi.cmd = &wmi_tlv_cmd_map; 4340 ar->wmi.vdev_param = &wmi_tlv_vdev_param_map; 4341 ar->wmi.pdev_param = &wmi_tlv_pdev_param_map; 4342 ar->wmi.ops = &wmi_tlv_ops; 4343 ar->wmi.peer_flags = &wmi_tlv_peer_flags_map; 4344 } 4345