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