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