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