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