1 // SPDX-License-Identifier: GPL-2.0+ 2 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */ 3 4 #include <linux/kernel.h> 5 #include <linux/etherdevice.h> 6 #include <linux/vmalloc.h> 7 #include <linux/ieee80211.h> 8 #include <net/cfg80211.h> 9 #include <net/netlink.h> 10 11 #include "cfg80211.h" 12 #include "commands.h" 13 #include "core.h" 14 #include "util.h" 15 #include "bus.h" 16 17 /* Supported rates to be advertised to the cfg80211 */ 18 static struct ieee80211_rate qtnf_rates_2g[] = { 19 {.bitrate = 10, .hw_value = 2, }, 20 {.bitrate = 20, .hw_value = 4, }, 21 {.bitrate = 55, .hw_value = 11, }, 22 {.bitrate = 110, .hw_value = 22, }, 23 {.bitrate = 60, .hw_value = 12, }, 24 {.bitrate = 90, .hw_value = 18, }, 25 {.bitrate = 120, .hw_value = 24, }, 26 {.bitrate = 180, .hw_value = 36, }, 27 {.bitrate = 240, .hw_value = 48, }, 28 {.bitrate = 360, .hw_value = 72, }, 29 {.bitrate = 480, .hw_value = 96, }, 30 {.bitrate = 540, .hw_value = 108, }, 31 }; 32 33 /* Supported rates to be advertised to the cfg80211 */ 34 static struct ieee80211_rate qtnf_rates_5g[] = { 35 {.bitrate = 60, .hw_value = 12, }, 36 {.bitrate = 90, .hw_value = 18, }, 37 {.bitrate = 120, .hw_value = 24, }, 38 {.bitrate = 180, .hw_value = 36, }, 39 {.bitrate = 240, .hw_value = 48, }, 40 {.bitrate = 360, .hw_value = 72, }, 41 {.bitrate = 480, .hw_value = 96, }, 42 {.bitrate = 540, .hw_value = 108, }, 43 }; 44 45 /* Supported crypto cipher suits to be advertised to cfg80211 */ 46 static const u32 qtnf_cipher_suites[] = { 47 WLAN_CIPHER_SUITE_TKIP, 48 WLAN_CIPHER_SUITE_CCMP, 49 WLAN_CIPHER_SUITE_AES_CMAC, 50 }; 51 52 /* Supported mgmt frame types to be advertised to cfg80211 */ 53 static const struct ieee80211_txrx_stypes 54 qtnf_mgmt_stypes[NUM_NL80211_IFTYPES] = { 55 [NL80211_IFTYPE_STATION] = { 56 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | 57 BIT(IEEE80211_STYPE_AUTH >> 4), 58 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 59 BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | 60 BIT(IEEE80211_STYPE_AUTH >> 4), 61 }, 62 [NL80211_IFTYPE_AP] = { 63 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | 64 BIT(IEEE80211_STYPE_AUTH >> 4), 65 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 66 BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | 67 BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | 68 BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | 69 BIT(IEEE80211_STYPE_AUTH >> 4), 70 }, 71 }; 72 73 static int 74 qtnf_validate_iface_combinations(struct wiphy *wiphy, 75 struct qtnf_vif *change_vif, 76 enum nl80211_iftype new_type) 77 { 78 struct qtnf_wmac *mac; 79 struct qtnf_vif *vif; 80 int i; 81 int ret = 0; 82 struct iface_combination_params params = { 83 .num_different_channels = 1, 84 }; 85 86 mac = wiphy_priv(wiphy); 87 if (!mac) 88 return -EFAULT; 89 90 for (i = 0; i < QTNF_MAX_INTF; i++) { 91 vif = &mac->iflist[i]; 92 if (vif->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED) 93 params.iftype_num[vif->wdev.iftype]++; 94 } 95 96 if (change_vif) { 97 params.iftype_num[new_type]++; 98 params.iftype_num[change_vif->wdev.iftype]--; 99 } else { 100 params.iftype_num[new_type]++; 101 } 102 103 ret = cfg80211_check_combinations(wiphy, ¶ms); 104 105 if (ret) 106 return ret; 107 108 /* Check repeater interface combination: primary VIF should be STA only. 109 * STA (primary) + AP (secondary) is OK. 110 * AP (primary) + STA (secondary) is not supported. 111 */ 112 vif = qtnf_mac_get_base_vif(mac); 113 if (vif && vif->wdev.iftype == NL80211_IFTYPE_AP && 114 vif != change_vif && new_type == NL80211_IFTYPE_STATION) { 115 ret = -EINVAL; 116 pr_err("MAC%u invalid combination: AP as primary repeater interface is not supported\n", 117 mac->macid); 118 } 119 120 return ret; 121 } 122 123 static int 124 qtnf_change_virtual_intf(struct wiphy *wiphy, 125 struct net_device *dev, 126 enum nl80211_iftype type, 127 struct vif_params *params) 128 { 129 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 130 u8 *mac_addr = NULL; 131 int use4addr = 0; 132 int ret; 133 134 ret = qtnf_validate_iface_combinations(wiphy, vif, type); 135 if (ret) { 136 pr_err("VIF%u.%u combination check: failed to set type %d\n", 137 vif->mac->macid, vif->vifid, type); 138 return ret; 139 } 140 141 if (params) { 142 mac_addr = params->macaddr; 143 use4addr = params->use_4addr; 144 } 145 146 qtnf_scan_done(vif->mac, true); 147 148 ret = qtnf_cmd_send_change_intf_type(vif, type, use4addr, mac_addr); 149 if (ret) { 150 pr_err("VIF%u.%u: failed to change type to %d\n", 151 vif->mac->macid, vif->vifid, type); 152 return ret; 153 } 154 155 vif->wdev.iftype = type; 156 return 0; 157 } 158 159 int qtnf_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) 160 { 161 struct net_device *netdev = wdev->netdev; 162 struct qtnf_vif *vif; 163 struct sk_buff *skb; 164 165 if (WARN_ON(!netdev)) 166 return -EFAULT; 167 168 vif = qtnf_netdev_get_priv(wdev->netdev); 169 170 qtnf_scan_done(vif->mac, true); 171 172 /* Stop data */ 173 netif_tx_stop_all_queues(netdev); 174 if (netif_carrier_ok(netdev)) 175 netif_carrier_off(netdev); 176 177 while ((skb = skb_dequeue(&vif->high_pri_tx_queue))) 178 dev_kfree_skb_any(skb); 179 180 cancel_work_sync(&vif->high_pri_tx_work); 181 182 if (netdev->reg_state == NETREG_REGISTERED) 183 unregister_netdevice(netdev); 184 185 if (qtnf_cmd_send_del_intf(vif)) 186 pr_err("VIF%u.%u: failed to delete VIF\n", vif->mac->macid, 187 vif->vifid); 188 189 vif->netdev->ieee80211_ptr = NULL; 190 vif->netdev = NULL; 191 vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; 192 193 return 0; 194 } 195 196 static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy, 197 const char *name, 198 unsigned char name_assign_t, 199 enum nl80211_iftype type, 200 struct vif_params *params) 201 { 202 struct qtnf_wmac *mac; 203 struct qtnf_vif *vif; 204 u8 *mac_addr = NULL; 205 int use4addr = 0; 206 int ret; 207 208 mac = wiphy_priv(wiphy); 209 210 if (!mac) 211 return ERR_PTR(-EFAULT); 212 213 ret = qtnf_validate_iface_combinations(wiphy, NULL, type); 214 if (ret) { 215 pr_err("MAC%u invalid combination: failed to add type %d\n", 216 mac->macid, type); 217 return ERR_PTR(ret); 218 } 219 220 switch (type) { 221 case NL80211_IFTYPE_STATION: 222 case NL80211_IFTYPE_AP: 223 vif = qtnf_mac_get_free_vif(mac); 224 if (!vif) { 225 pr_err("MAC%u: no free VIF available\n", mac->macid); 226 return ERR_PTR(-EFAULT); 227 } 228 229 eth_zero_addr(vif->mac_addr); 230 eth_zero_addr(vif->bssid); 231 vif->bss_priority = QTNF_DEF_BSS_PRIORITY; 232 memset(&vif->wdev, 0, sizeof(vif->wdev)); 233 vif->wdev.wiphy = wiphy; 234 vif->wdev.iftype = type; 235 break; 236 default: 237 pr_err("MAC%u: unsupported IF type %d\n", mac->macid, type); 238 return ERR_PTR(-ENOTSUPP); 239 } 240 241 if (params) { 242 mac_addr = params->macaddr; 243 use4addr = params->use_4addr; 244 } 245 246 ret = qtnf_cmd_send_add_intf(vif, type, use4addr, mac_addr); 247 if (ret) { 248 pr_err("VIF%u.%u: failed to add VIF %pM\n", 249 mac->macid, vif->vifid, mac_addr); 250 goto err_cmd; 251 } 252 253 if (!is_valid_ether_addr(vif->mac_addr)) { 254 pr_err("VIF%u.%u: FW reported bad MAC: %pM\n", 255 mac->macid, vif->vifid, vif->mac_addr); 256 ret = -EINVAL; 257 goto error_del_vif; 258 } 259 260 ret = qtnf_core_net_attach(mac, vif, name, name_assign_t); 261 if (ret) { 262 pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid, 263 vif->vifid); 264 goto error_del_vif; 265 } 266 267 if (qtnf_hwcap_is_set(&mac->bus->hw_info, QLINK_HW_CAPAB_HW_BRIDGE)) { 268 ret = qtnf_cmd_netdev_changeupper(vif, vif->netdev->ifindex); 269 if (ret) { 270 unregister_netdevice(vif->netdev); 271 vif->netdev = NULL; 272 goto error_del_vif; 273 } 274 } 275 276 vif->wdev.netdev = vif->netdev; 277 return &vif->wdev; 278 279 error_del_vif: 280 qtnf_cmd_send_del_intf(vif); 281 err_cmd: 282 vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; 283 284 return ERR_PTR(ret); 285 } 286 287 static int qtnf_mgmt_set_appie(struct qtnf_vif *vif, 288 const struct cfg80211_beacon_data *info) 289 { 290 int ret = 0; 291 292 if (!info->beacon_ies || !info->beacon_ies_len) { 293 ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_IE_SET_BEACON_IES, 294 NULL, 0); 295 } else { 296 ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_IE_SET_BEACON_IES, 297 info->beacon_ies, 298 info->beacon_ies_len); 299 } 300 301 if (ret) 302 goto out; 303 304 if (!info->proberesp_ies || !info->proberesp_ies_len) { 305 ret = qtnf_cmd_send_mgmt_set_appie(vif, 306 QLINK_IE_SET_PROBE_RESP_IES, 307 NULL, 0); 308 } else { 309 ret = qtnf_cmd_send_mgmt_set_appie(vif, 310 QLINK_IE_SET_PROBE_RESP_IES, 311 info->proberesp_ies, 312 info->proberesp_ies_len); 313 } 314 315 if (ret) 316 goto out; 317 318 if (!info->assocresp_ies || !info->assocresp_ies_len) { 319 ret = qtnf_cmd_send_mgmt_set_appie(vif, 320 QLINK_IE_SET_ASSOC_RESP, 321 NULL, 0); 322 } else { 323 ret = qtnf_cmd_send_mgmt_set_appie(vif, 324 QLINK_IE_SET_ASSOC_RESP, 325 info->assocresp_ies, 326 info->assocresp_ies_len); 327 } 328 329 out: 330 return ret; 331 } 332 333 static int qtnf_change_beacon(struct wiphy *wiphy, struct net_device *dev, 334 struct cfg80211_beacon_data *info) 335 { 336 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 337 338 return qtnf_mgmt_set_appie(vif, info); 339 } 340 341 static int qtnf_start_ap(struct wiphy *wiphy, struct net_device *dev, 342 struct cfg80211_ap_settings *settings) 343 { 344 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 345 int ret; 346 347 ret = qtnf_cmd_send_start_ap(vif, settings); 348 if (ret) 349 pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid, 350 vif->vifid); 351 352 return ret; 353 } 354 355 static int qtnf_stop_ap(struct wiphy *wiphy, struct net_device *dev) 356 { 357 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 358 int ret; 359 360 qtnf_scan_done(vif->mac, true); 361 362 ret = qtnf_cmd_send_stop_ap(vif); 363 if (ret) 364 pr_err("VIF%u.%u: failed to stop AP operation in FW\n", 365 vif->mac->macid, vif->vifid); 366 367 netif_carrier_off(vif->netdev); 368 369 return ret; 370 } 371 372 static int qtnf_set_wiphy_params(struct wiphy *wiphy, u32 changed) 373 { 374 struct qtnf_wmac *mac = wiphy_priv(wiphy); 375 struct qtnf_vif *vif; 376 int ret; 377 378 vif = qtnf_mac_get_base_vif(mac); 379 if (!vif) { 380 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 381 return -EFAULT; 382 } 383 384 ret = qtnf_cmd_send_update_phy_params(mac, changed); 385 if (ret) 386 pr_err("MAC%u: failed to update PHY params\n", mac->macid); 387 388 return ret; 389 } 390 391 static void 392 qtnf_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, 393 u16 frame_type, bool reg) 394 { 395 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev); 396 u16 mgmt_type; 397 u16 new_mask; 398 u16 qlink_frame_type = 0; 399 400 mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4; 401 402 if (reg) 403 new_mask = vif->mgmt_frames_bitmask | BIT(mgmt_type); 404 else 405 new_mask = vif->mgmt_frames_bitmask & ~BIT(mgmt_type); 406 407 if (new_mask == vif->mgmt_frames_bitmask) 408 return; 409 410 switch (frame_type & IEEE80211_FCTL_STYPE) { 411 case IEEE80211_STYPE_REASSOC_REQ: 412 case IEEE80211_STYPE_ASSOC_REQ: 413 qlink_frame_type = QLINK_MGMT_FRAME_ASSOC_REQ; 414 break; 415 case IEEE80211_STYPE_AUTH: 416 qlink_frame_type = QLINK_MGMT_FRAME_AUTH; 417 break; 418 case IEEE80211_STYPE_PROBE_REQ: 419 qlink_frame_type = QLINK_MGMT_FRAME_PROBE_REQ; 420 break; 421 case IEEE80211_STYPE_ACTION: 422 qlink_frame_type = QLINK_MGMT_FRAME_ACTION; 423 break; 424 default: 425 pr_warn("VIF%u.%u: unsupported frame type: %X\n", 426 vif->mac->macid, vif->vifid, 427 (frame_type & IEEE80211_FCTL_STYPE) >> 4); 428 return; 429 } 430 431 if (qtnf_cmd_send_register_mgmt(vif, qlink_frame_type, reg)) { 432 pr_warn("VIF%u.%u: failed to %sregister mgmt frame type 0x%x\n", 433 vif->mac->macid, vif->vifid, reg ? "" : "un", 434 frame_type); 435 return; 436 } 437 438 vif->mgmt_frames_bitmask = new_mask; 439 pr_debug("VIF%u.%u: %sregistered mgmt frame type 0x%x\n", 440 vif->mac->macid, vif->vifid, reg ? "" : "un", frame_type); 441 } 442 443 static int 444 qtnf_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 445 struct cfg80211_mgmt_tx_params *params, u64 *cookie) 446 { 447 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev); 448 const struct ieee80211_mgmt *mgmt_frame = (void *)params->buf; 449 u32 short_cookie = prandom_u32(); 450 u16 flags = 0; 451 u16 freq; 452 453 *cookie = short_cookie; 454 455 if (params->offchan) 456 flags |= QLINK_FRAME_TX_FLAG_OFFCHAN; 457 458 if (params->no_cck) 459 flags |= QLINK_FRAME_TX_FLAG_NO_CCK; 460 461 if (params->dont_wait_for_ack) 462 flags |= QLINK_FRAME_TX_FLAG_ACK_NOWAIT; 463 464 /* If channel is not specified, pass "freq = 0" to tell device 465 * firmware to use current channel. 466 */ 467 if (params->chan) 468 freq = params->chan->center_freq; 469 else 470 freq = 0; 471 472 pr_debug("%s freq:%u; FC:%.4X; DA:%pM; len:%zu; C:%.8X; FL:%.4X\n", 473 wdev->netdev->name, freq, 474 le16_to_cpu(mgmt_frame->frame_control), mgmt_frame->da, 475 params->len, short_cookie, flags); 476 477 return qtnf_cmd_send_frame(vif, short_cookie, flags, 478 freq, params->buf, params->len); 479 } 480 481 static int 482 qtnf_get_station(struct wiphy *wiphy, struct net_device *dev, 483 const u8 *mac, struct station_info *sinfo) 484 { 485 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 486 487 sinfo->generation = vif->generation; 488 return qtnf_cmd_get_sta_info(vif, mac, sinfo); 489 } 490 491 static int 492 qtnf_dump_station(struct wiphy *wiphy, struct net_device *dev, 493 int idx, u8 *mac, struct station_info *sinfo) 494 { 495 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 496 const struct qtnf_sta_node *sta_node; 497 int ret; 498 499 switch (vif->wdev.iftype) { 500 case NL80211_IFTYPE_STATION: 501 if (idx != 0 || !vif->wdev.current_bss) 502 return -ENOENT; 503 504 ether_addr_copy(mac, vif->bssid); 505 break; 506 case NL80211_IFTYPE_AP: 507 sta_node = qtnf_sta_list_lookup_index(&vif->sta_list, idx); 508 if (unlikely(!sta_node)) 509 return -ENOENT; 510 511 ether_addr_copy(mac, sta_node->mac_addr); 512 break; 513 default: 514 return -ENOTSUPP; 515 } 516 517 ret = qtnf_cmd_get_sta_info(vif, mac, sinfo); 518 519 if (vif->wdev.iftype == NL80211_IFTYPE_AP) { 520 if (ret == -ENOENT) { 521 cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL); 522 sinfo->filled = 0; 523 } 524 } 525 526 sinfo->generation = vif->generation; 527 528 return ret; 529 } 530 531 static int qtnf_add_key(struct wiphy *wiphy, struct net_device *dev, 532 u8 key_index, bool pairwise, const u8 *mac_addr, 533 struct key_params *params) 534 { 535 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 536 int ret; 537 538 ret = qtnf_cmd_send_add_key(vif, key_index, pairwise, mac_addr, params); 539 if (ret) 540 pr_err("VIF%u.%u: failed to add key: cipher=%x idx=%u pw=%u\n", 541 vif->mac->macid, vif->vifid, params->cipher, key_index, 542 pairwise); 543 544 return ret; 545 } 546 547 static int qtnf_del_key(struct wiphy *wiphy, struct net_device *dev, 548 u8 key_index, bool pairwise, const u8 *mac_addr) 549 { 550 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 551 int ret; 552 553 ret = qtnf_cmd_send_del_key(vif, key_index, pairwise, mac_addr); 554 if (ret) { 555 if (ret == -ENOENT) { 556 pr_debug("VIF%u.%u: key index %d out of bounds\n", 557 vif->mac->macid, vif->vifid, key_index); 558 } else { 559 pr_err("VIF%u.%u: failed to delete key: idx=%u pw=%u\n", 560 vif->mac->macid, vif->vifid, 561 key_index, pairwise); 562 } 563 } 564 565 return ret; 566 } 567 568 static int qtnf_set_default_key(struct wiphy *wiphy, struct net_device *dev, 569 u8 key_index, bool unicast, bool multicast) 570 { 571 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 572 int ret; 573 574 ret = qtnf_cmd_send_set_default_key(vif, key_index, unicast, multicast); 575 if (ret) 576 pr_err("VIF%u.%u: failed to set dflt key: idx=%u uc=%u mc=%u\n", 577 vif->mac->macid, vif->vifid, key_index, unicast, 578 multicast); 579 580 return ret; 581 } 582 583 static int 584 qtnf_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *dev, 585 u8 key_index) 586 { 587 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 588 int ret; 589 590 ret = qtnf_cmd_send_set_default_mgmt_key(vif, key_index); 591 if (ret) 592 pr_err("VIF%u.%u: failed to set default MGMT key: idx=%u\n", 593 vif->mac->macid, vif->vifid, key_index); 594 595 return ret; 596 } 597 598 static int 599 qtnf_change_station(struct wiphy *wiphy, struct net_device *dev, 600 const u8 *mac, struct station_parameters *params) 601 { 602 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 603 int ret; 604 605 ret = qtnf_cmd_send_change_sta(vif, mac, params); 606 if (ret) 607 pr_err("VIF%u.%u: failed to change STA %pM\n", 608 vif->mac->macid, vif->vifid, mac); 609 610 return ret; 611 } 612 613 static int 614 qtnf_del_station(struct wiphy *wiphy, struct net_device *dev, 615 struct station_del_parameters *params) 616 { 617 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 618 int ret; 619 620 if (params->mac && 621 (vif->wdev.iftype == NL80211_IFTYPE_AP) && 622 !is_broadcast_ether_addr(params->mac) && 623 !qtnf_sta_list_lookup(&vif->sta_list, params->mac)) 624 return 0; 625 626 ret = qtnf_cmd_send_del_sta(vif, params); 627 if (ret) 628 pr_err("VIF%u.%u: failed to delete STA %pM\n", 629 vif->mac->macid, vif->vifid, params->mac); 630 631 return ret; 632 } 633 634 static int 635 qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) 636 { 637 struct qtnf_wmac *mac = wiphy_priv(wiphy); 638 int ret; 639 640 cancel_delayed_work_sync(&mac->scan_timeout); 641 642 mac->scan_req = request; 643 644 ret = qtnf_cmd_send_scan(mac); 645 if (ret) { 646 pr_err("MAC%u: failed to start scan\n", mac->macid); 647 mac->scan_req = NULL; 648 goto out; 649 } 650 651 pr_debug("MAC%u: scan started\n", mac->macid); 652 queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout, 653 QTNF_SCAN_TIMEOUT_SEC * HZ); 654 655 out: 656 return ret; 657 } 658 659 static int 660 qtnf_connect(struct wiphy *wiphy, struct net_device *dev, 661 struct cfg80211_connect_params *sme) 662 { 663 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 664 int ret; 665 666 if (vif->wdev.iftype != NL80211_IFTYPE_STATION) 667 return -EOPNOTSUPP; 668 669 if (sme->auth_type == NL80211_AUTHTYPE_SAE && 670 !(sme->flags & CONNECT_REQ_EXTERNAL_AUTH_SUPPORT)) { 671 pr_err("can not offload authentication to userspace\n"); 672 return -EOPNOTSUPP; 673 } 674 675 if (sme->bssid) 676 ether_addr_copy(vif->bssid, sme->bssid); 677 else 678 eth_zero_addr(vif->bssid); 679 680 ret = qtnf_cmd_send_connect(vif, sme); 681 if (ret) { 682 pr_err("VIF%u.%u: failed to connect\n", 683 vif->mac->macid, vif->vifid); 684 goto out; 685 } 686 687 out: 688 return ret; 689 } 690 691 static int 692 qtnf_external_auth(struct wiphy *wiphy, struct net_device *dev, 693 struct cfg80211_external_auth_params *auth) 694 { 695 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 696 int ret; 697 698 if (vif->wdev.iftype == NL80211_IFTYPE_STATION && 699 !ether_addr_equal(vif->bssid, auth->bssid)) 700 pr_warn("unexpected bssid: %pM", auth->bssid); 701 702 ret = qtnf_cmd_send_external_auth(vif, auth); 703 if (ret) { 704 pr_err("VIF%u.%u: failed to report external auth\n", 705 vif->mac->macid, vif->vifid); 706 goto out; 707 } 708 709 out: 710 return ret; 711 } 712 713 static int 714 qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev, 715 u16 reason_code) 716 { 717 struct qtnf_wmac *mac = wiphy_priv(wiphy); 718 struct qtnf_vif *vif; 719 int ret = 0; 720 721 vif = qtnf_mac_get_base_vif(mac); 722 if (!vif) { 723 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 724 return -EFAULT; 725 } 726 727 if (vif->wdev.iftype != NL80211_IFTYPE_STATION) { 728 ret = -EOPNOTSUPP; 729 goto out; 730 } 731 732 ret = qtnf_cmd_send_disconnect(vif, reason_code); 733 if (ret) 734 pr_err("VIF%u.%u: failed to disconnect\n", 735 mac->macid, vif->vifid); 736 737 if (vif->wdev.current_bss) { 738 netif_carrier_off(vif->netdev); 739 cfg80211_disconnected(vif->netdev, reason_code, 740 NULL, 0, true, GFP_KERNEL); 741 } 742 743 out: 744 return ret; 745 } 746 747 static int 748 qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev, 749 int idx, struct survey_info *survey) 750 { 751 struct qtnf_wmac *mac = wiphy_priv(wiphy); 752 struct wireless_dev *wdev = dev->ieee80211_ptr; 753 struct ieee80211_supported_band *sband; 754 const struct cfg80211_chan_def *chandef = &wdev->chandef; 755 struct ieee80211_channel *chan; 756 int ret; 757 758 sband = wiphy->bands[NL80211_BAND_2GHZ]; 759 if (sband && idx >= sband->n_channels) { 760 idx -= sband->n_channels; 761 sband = NULL; 762 } 763 764 if (!sband) 765 sband = wiphy->bands[NL80211_BAND_5GHZ]; 766 767 if (!sband || idx >= sband->n_channels) 768 return -ENOENT; 769 770 chan = &sband->channels[idx]; 771 survey->channel = chan; 772 survey->filled = 0x0; 773 774 if (chan == chandef->chan) 775 survey->filled = SURVEY_INFO_IN_USE; 776 777 ret = qtnf_cmd_get_chan_stats(mac, chan->center_freq, survey); 778 if (ret) 779 pr_debug("failed to get chan(%d) stats from card\n", 780 chan->hw_value); 781 782 return ret; 783 } 784 785 static int 786 qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, 787 struct cfg80211_chan_def *chandef) 788 { 789 struct net_device *ndev = wdev->netdev; 790 struct qtnf_vif *vif; 791 int ret; 792 793 if (!ndev) 794 return -ENODEV; 795 796 vif = qtnf_netdev_get_priv(wdev->netdev); 797 798 ret = qtnf_cmd_get_channel(vif, chandef); 799 if (ret) { 800 pr_err("%s: failed to get channel: %d\n", ndev->name, ret); 801 ret = -ENODATA; 802 goto out; 803 } 804 805 if (!cfg80211_chandef_valid(chandef)) { 806 pr_err("%s: bad channel freq=%u cf1=%u cf2=%u bw=%u\n", 807 ndev->name, chandef->chan->center_freq, 808 chandef->center_freq1, chandef->center_freq2, 809 chandef->width); 810 ret = -ENODATA; 811 goto out; 812 } 813 814 out: 815 return ret; 816 } 817 818 static int qtnf_channel_switch(struct wiphy *wiphy, struct net_device *dev, 819 struct cfg80211_csa_settings *params) 820 { 821 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 822 int ret; 823 824 pr_debug("%s: chan(%u) count(%u) radar(%u) block_tx(%u)\n", dev->name, 825 params->chandef.chan->hw_value, params->count, 826 params->radar_required, params->block_tx); 827 828 if (!cfg80211_chandef_valid(¶ms->chandef)) { 829 pr_err("%s: invalid channel\n", dev->name); 830 return -EINVAL; 831 } 832 833 ret = qtnf_cmd_send_chan_switch(vif, params); 834 if (ret) 835 pr_warn("%s: failed to switch to channel (%u)\n", 836 dev->name, params->chandef.chan->hw_value); 837 838 return ret; 839 } 840 841 static int qtnf_start_radar_detection(struct wiphy *wiphy, 842 struct net_device *ndev, 843 struct cfg80211_chan_def *chandef, 844 u32 cac_time_ms) 845 { 846 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 847 int ret; 848 849 if (wiphy_ext_feature_isset(wiphy, NL80211_EXT_FEATURE_DFS_OFFLOAD)) 850 return -ENOTSUPP; 851 852 ret = qtnf_cmd_start_cac(vif, chandef, cac_time_ms); 853 if (ret) 854 pr_err("%s: failed to start CAC ret=%d\n", ndev->name, ret); 855 856 return ret; 857 } 858 859 static int qtnf_set_mac_acl(struct wiphy *wiphy, 860 struct net_device *dev, 861 const struct cfg80211_acl_data *params) 862 { 863 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 864 int ret; 865 866 ret = qtnf_cmd_set_mac_acl(vif, params); 867 if (ret) 868 pr_err("%s: failed to set mac ACL ret=%d\n", dev->name, ret); 869 870 return ret; 871 } 872 873 static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, 874 bool enabled, int timeout) 875 { 876 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 877 int ret; 878 879 ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY : 880 QLINK_PM_OFF, timeout); 881 if (ret) 882 pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret); 883 884 return ret; 885 } 886 887 static int qtnf_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, 888 int *dbm) 889 { 890 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev); 891 int ret; 892 893 ret = qtnf_cmd_get_tx_power(vif, dbm); 894 if (ret) 895 pr_err("MAC%u: failed to get Tx power\n", vif->mac->macid); 896 897 return ret; 898 } 899 900 static int qtnf_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, 901 enum nl80211_tx_power_setting type, int mbm) 902 { 903 struct qtnf_vif *vif; 904 int ret; 905 906 if (wdev) { 907 vif = qtnf_netdev_get_priv(wdev->netdev); 908 } else { 909 struct qtnf_wmac *mac = wiphy_priv(wiphy); 910 911 vif = qtnf_mac_get_base_vif(mac); 912 if (!vif) { 913 pr_err("MAC%u: primary VIF is not configured\n", 914 mac->macid); 915 return -EFAULT; 916 } 917 } 918 919 ret = qtnf_cmd_set_tx_power(vif, type, mbm); 920 if (ret) 921 pr_err("MAC%u: failed to set Tx power\n", vif->mac->macid); 922 923 return ret; 924 } 925 926 static int qtnf_update_owe_info(struct wiphy *wiphy, struct net_device *dev, 927 struct cfg80211_update_owe_info *owe_info) 928 { 929 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 930 int ret; 931 932 if (vif->wdev.iftype != NL80211_IFTYPE_AP) 933 return -EOPNOTSUPP; 934 935 ret = qtnf_cmd_send_update_owe(vif, owe_info); 936 if (ret) { 937 pr_err("VIF%u.%u: failed to update owe info\n", 938 vif->mac->macid, vif->vifid); 939 goto out; 940 } 941 942 out: 943 return ret; 944 } 945 946 #ifdef CONFIG_PM 947 static int qtnf_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wowlan) 948 { 949 struct qtnf_wmac *mac = wiphy_priv(wiphy); 950 struct qtnf_vif *vif; 951 int ret = 0; 952 953 vif = qtnf_mac_get_base_vif(mac); 954 if (!vif) { 955 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 956 ret = -EFAULT; 957 goto exit; 958 } 959 960 if (!wowlan) { 961 pr_debug("WoWLAN triggers are not enabled\n"); 962 qtnf_virtual_intf_cleanup(vif->netdev); 963 goto exit; 964 } 965 966 qtnf_scan_done(vif->mac, true); 967 968 ret = qtnf_cmd_send_wowlan_set(vif, wowlan); 969 if (ret) { 970 pr_err("MAC%u: failed to set WoWLAN triggers\n", 971 mac->macid); 972 goto exit; 973 } 974 975 exit: 976 return ret; 977 } 978 979 static int qtnf_resume(struct wiphy *wiphy) 980 { 981 struct qtnf_wmac *mac = wiphy_priv(wiphy); 982 struct qtnf_vif *vif; 983 int ret = 0; 984 985 vif = qtnf_mac_get_base_vif(mac); 986 if (!vif) { 987 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 988 ret = -EFAULT; 989 goto exit; 990 } 991 992 ret = qtnf_cmd_send_wowlan_set(vif, NULL); 993 if (ret) { 994 pr_err("MAC%u: failed to reset WoWLAN triggers\n", 995 mac->macid); 996 goto exit; 997 } 998 999 exit: 1000 return ret; 1001 } 1002 1003 static void qtnf_set_wakeup(struct wiphy *wiphy, bool enabled) 1004 { 1005 struct qtnf_wmac *mac = wiphy_priv(wiphy); 1006 struct qtnf_bus *bus = mac->bus; 1007 1008 device_set_wakeup_enable(bus->dev, enabled); 1009 } 1010 #endif 1011 1012 static struct cfg80211_ops qtn_cfg80211_ops = { 1013 .add_virtual_intf = qtnf_add_virtual_intf, 1014 .change_virtual_intf = qtnf_change_virtual_intf, 1015 .del_virtual_intf = qtnf_del_virtual_intf, 1016 .start_ap = qtnf_start_ap, 1017 .change_beacon = qtnf_change_beacon, 1018 .stop_ap = qtnf_stop_ap, 1019 .set_wiphy_params = qtnf_set_wiphy_params, 1020 .mgmt_frame_register = qtnf_mgmt_frame_register, 1021 .mgmt_tx = qtnf_mgmt_tx, 1022 .change_station = qtnf_change_station, 1023 .del_station = qtnf_del_station, 1024 .get_station = qtnf_get_station, 1025 .dump_station = qtnf_dump_station, 1026 .add_key = qtnf_add_key, 1027 .del_key = qtnf_del_key, 1028 .set_default_key = qtnf_set_default_key, 1029 .set_default_mgmt_key = qtnf_set_default_mgmt_key, 1030 .scan = qtnf_scan, 1031 .connect = qtnf_connect, 1032 .external_auth = qtnf_external_auth, 1033 .disconnect = qtnf_disconnect, 1034 .dump_survey = qtnf_dump_survey, 1035 .get_channel = qtnf_get_channel, 1036 .channel_switch = qtnf_channel_switch, 1037 .start_radar_detection = qtnf_start_radar_detection, 1038 .set_mac_acl = qtnf_set_mac_acl, 1039 .set_power_mgmt = qtnf_set_power_mgmt, 1040 .get_tx_power = qtnf_get_tx_power, 1041 .set_tx_power = qtnf_set_tx_power, 1042 .update_owe_info = qtnf_update_owe_info, 1043 #ifdef CONFIG_PM 1044 .suspend = qtnf_suspend, 1045 .resume = qtnf_resume, 1046 .set_wakeup = qtnf_set_wakeup, 1047 #endif 1048 }; 1049 1050 static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy, 1051 struct regulatory_request *req) 1052 { 1053 struct qtnf_wmac *mac = wiphy_priv(wiphy); 1054 enum nl80211_band band; 1055 int ret; 1056 1057 pr_debug("MAC%u: initiator=%d alpha=%c%c\n", mac->macid, req->initiator, 1058 req->alpha2[0], req->alpha2[1]); 1059 1060 ret = qtnf_cmd_reg_notify(mac, req, qtnf_slave_radar_get(), 1061 qtnf_dfs_offload_get()); 1062 if (ret) { 1063 pr_err("MAC%u: failed to update region to %c%c: %d\n", 1064 mac->macid, req->alpha2[0], req->alpha2[1], ret); 1065 return; 1066 } 1067 1068 for (band = 0; band < NUM_NL80211_BANDS; ++band) { 1069 if (!wiphy->bands[band]) 1070 continue; 1071 1072 ret = qtnf_cmd_band_info_get(mac, wiphy->bands[band]); 1073 if (ret) 1074 pr_err("MAC%u: failed to update band %u\n", 1075 mac->macid, band); 1076 } 1077 } 1078 1079 struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus, 1080 struct platform_device *pdev) 1081 { 1082 struct wiphy *wiphy; 1083 1084 if (qtnf_dfs_offload_get() && 1085 qtnf_hwcap_is_set(&bus->hw_info, QLINK_HW_CAPAB_DFS_OFFLOAD)) 1086 qtn_cfg80211_ops.start_radar_detection = NULL; 1087 1088 if (!qtnf_hwcap_is_set(&bus->hw_info, QLINK_HW_CAPAB_PWR_MGMT)) 1089 qtn_cfg80211_ops.set_power_mgmt = NULL; 1090 1091 wiphy = wiphy_new(&qtn_cfg80211_ops, sizeof(struct qtnf_wmac)); 1092 if (!wiphy) 1093 return NULL; 1094 1095 if (pdev) 1096 set_wiphy_dev(wiphy, &pdev->dev); 1097 else 1098 set_wiphy_dev(wiphy, bus->dev); 1099 1100 return wiphy; 1101 } 1102 1103 static int 1104 qtnf_wiphy_setup_if_comb(struct wiphy *wiphy, struct qtnf_mac_info *mac_info) 1105 { 1106 struct ieee80211_iface_combination *if_comb; 1107 size_t n_if_comb; 1108 u16 interface_modes = 0; 1109 size_t i, j; 1110 1111 if_comb = mac_info->if_comb; 1112 n_if_comb = mac_info->n_if_comb; 1113 1114 if (!if_comb || !n_if_comb) 1115 return -ENOENT; 1116 1117 for (i = 0; i < n_if_comb; i++) { 1118 if_comb[i].radar_detect_widths = mac_info->radar_detect_widths; 1119 1120 for (j = 0; j < if_comb[i].n_limits; j++) 1121 interface_modes |= if_comb[i].limits[j].types; 1122 } 1123 1124 wiphy->iface_combinations = if_comb; 1125 wiphy->n_iface_combinations = n_if_comb; 1126 wiphy->interface_modes = interface_modes; 1127 1128 return 0; 1129 } 1130 1131 int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) 1132 { 1133 struct wiphy *wiphy = priv_to_wiphy(mac); 1134 struct qtnf_mac_info *macinfo = &mac->macinfo; 1135 int ret; 1136 bool regdomain_is_known; 1137 1138 if (!wiphy) { 1139 pr_err("invalid wiphy pointer\n"); 1140 return -EFAULT; 1141 } 1142 1143 wiphy->frag_threshold = macinfo->frag_thr; 1144 wiphy->rts_threshold = macinfo->rts_thr; 1145 wiphy->retry_short = macinfo->sretry_limit; 1146 wiphy->retry_long = macinfo->lretry_limit; 1147 wiphy->coverage_class = macinfo->coverage_class; 1148 1149 wiphy->max_scan_ssids = 1150 (macinfo->max_scan_ssids) ? macinfo->max_scan_ssids : 1; 1151 wiphy->max_scan_ie_len = QTNF_MAX_VSIE_LEN; 1152 wiphy->mgmt_stypes = qtnf_mgmt_stypes; 1153 wiphy->max_remain_on_channel_duration = 5000; 1154 wiphy->max_acl_mac_addrs = macinfo->max_acl_mac_addrs; 1155 wiphy->max_num_csa_counters = 2; 1156 1157 ret = qtnf_wiphy_setup_if_comb(wiphy, macinfo); 1158 if (ret) 1159 goto out; 1160 1161 /* Initialize cipher suits */ 1162 wiphy->cipher_suites = qtnf_cipher_suites; 1163 wiphy->n_cipher_suites = ARRAY_SIZE(qtnf_cipher_suites); 1164 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; 1165 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | 1166 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD | 1167 WIPHY_FLAG_AP_UAPSD | 1168 WIPHY_FLAG_HAS_CHANNEL_SWITCH | 1169 WIPHY_FLAG_4ADDR_STATION | 1170 WIPHY_FLAG_NETNS_OK; 1171 wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 1172 1173 if (qtnf_dfs_offload_get() && 1174 qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_DFS_OFFLOAD)) 1175 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_DFS_OFFLOAD); 1176 1177 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SCAN_DWELL)) 1178 wiphy_ext_feature_set(wiphy, 1179 NL80211_EXT_FEATURE_SET_SCAN_DWELL); 1180 1181 wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | 1182 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2; 1183 1184 wiphy->available_antennas_tx = macinfo->num_tx_chain; 1185 wiphy->available_antennas_rx = macinfo->num_rx_chain; 1186 1187 wiphy->max_ap_assoc_sta = macinfo->max_ap_assoc_sta; 1188 wiphy->ht_capa_mod_mask = &macinfo->ht_cap_mod_mask; 1189 wiphy->vht_capa_mod_mask = &macinfo->vht_cap_mod_mask; 1190 1191 ether_addr_copy(wiphy->perm_addr, mac->macaddr); 1192 1193 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_STA_INACT_TIMEOUT)) 1194 wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; 1195 1196 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR)) 1197 wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; 1198 1199 if (!qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_OBSS_SCAN)) 1200 wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; 1201 1202 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SAE)) 1203 wiphy->features |= NL80211_FEATURE_SAE; 1204 1205 #ifdef CONFIG_PM 1206 if (macinfo->wowlan) 1207 wiphy->wowlan = macinfo->wowlan; 1208 #endif 1209 1210 regdomain_is_known = isalpha(mac->rd->alpha2[0]) && 1211 isalpha(mac->rd->alpha2[1]); 1212 1213 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_REG_UPDATE)) { 1214 wiphy->reg_notifier = qtnf_cfg80211_reg_notifier; 1215 1216 if (mac->rd->alpha2[0] == '9' && mac->rd->alpha2[1] == '9') { 1217 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | 1218 REGULATORY_STRICT_REG; 1219 wiphy_apply_custom_regulatory(wiphy, mac->rd); 1220 } else if (regdomain_is_known) { 1221 wiphy->regulatory_flags |= REGULATORY_STRICT_REG; 1222 } 1223 } else { 1224 wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; 1225 } 1226 1227 if (mac->macinfo.extended_capabilities_len) { 1228 wiphy->extended_capabilities = 1229 mac->macinfo.extended_capabilities; 1230 wiphy->extended_capabilities_mask = 1231 mac->macinfo.extended_capabilities_mask; 1232 wiphy->extended_capabilities_len = 1233 mac->macinfo.extended_capabilities_len; 1234 } 1235 1236 strlcpy(wiphy->fw_version, hw_info->fw_version, 1237 sizeof(wiphy->fw_version)); 1238 wiphy->hw_version = hw_info->hw_version; 1239 1240 ret = wiphy_register(wiphy); 1241 if (ret < 0) 1242 goto out; 1243 1244 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) 1245 ret = regulatory_set_wiphy_regd(wiphy, mac->rd); 1246 else if (regdomain_is_known) 1247 ret = regulatory_hint(wiphy, mac->rd->alpha2); 1248 1249 out: 1250 return ret; 1251 } 1252 1253 void qtnf_netdev_updown(struct net_device *ndev, bool up) 1254 { 1255 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 1256 1257 if (qtnf_cmd_send_updown_intf(vif, up)) 1258 pr_err("failed to send %s command to VIF%u.%u\n", 1259 up ? "UP" : "DOWN", vif->mac->macid, vif->vifid); 1260 } 1261 1262 void qtnf_virtual_intf_cleanup(struct net_device *ndev) 1263 { 1264 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 1265 struct qtnf_wmac *mac = wiphy_priv(vif->wdev.wiphy); 1266 1267 if (vif->wdev.iftype == NL80211_IFTYPE_STATION) 1268 qtnf_disconnect(vif->wdev.wiphy, ndev, 1269 WLAN_REASON_DEAUTH_LEAVING); 1270 1271 qtnf_scan_done(mac, true); 1272 } 1273 1274 void qtnf_cfg80211_vif_reset(struct qtnf_vif *vif) 1275 { 1276 if (vif->wdev.iftype == NL80211_IFTYPE_STATION) 1277 cfg80211_disconnected(vif->netdev, WLAN_REASON_DEAUTH_LEAVING, 1278 NULL, 0, 1, GFP_KERNEL); 1279 1280 cfg80211_shutdown_all_interfaces(vif->wdev.wiphy); 1281 } 1282 1283 void qtnf_band_init_rates(struct ieee80211_supported_band *band) 1284 { 1285 switch (band->band) { 1286 case NL80211_BAND_2GHZ: 1287 band->bitrates = qtnf_rates_2g; 1288 band->n_bitrates = ARRAY_SIZE(qtnf_rates_2g); 1289 break; 1290 case NL80211_BAND_5GHZ: 1291 band->bitrates = qtnf_rates_5g; 1292 band->n_bitrates = ARRAY_SIZE(qtnf_rates_5g); 1293 break; 1294 default: 1295 band->bitrates = NULL; 1296 band->n_bitrates = 0; 1297 break; 1298 } 1299 } 1300