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