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