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 cfg80211_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 cfg80211_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 unsigned int link_id) 357 { 358 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 359 int ret; 360 361 qtnf_scan_done(vif->mac, true); 362 363 ret = qtnf_cmd_send_stop_ap(vif); 364 if (ret) 365 pr_err("VIF%u.%u: failed to stop AP operation in FW\n", 366 vif->mac->macid, vif->vifid); 367 368 netif_carrier_off(vif->netdev); 369 370 return ret; 371 } 372 373 static int qtnf_set_wiphy_params(struct wiphy *wiphy, u32 changed) 374 { 375 struct qtnf_wmac *mac = wiphy_priv(wiphy); 376 struct qtnf_vif *vif; 377 int ret; 378 379 vif = qtnf_mac_get_base_vif(mac); 380 if (!vif) { 381 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 382 return -EFAULT; 383 } 384 385 ret = qtnf_cmd_send_update_phy_params(mac, changed); 386 if (ret) 387 pr_err("MAC%u: failed to update PHY params\n", mac->macid); 388 389 return ret; 390 } 391 392 static void 393 qtnf_update_mgmt_frame_registrations(struct wiphy *wiphy, 394 struct wireless_dev *wdev, 395 struct mgmt_frame_regs *upd) 396 { 397 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev); 398 u16 new_mask = upd->interface_stypes; 399 u16 old_mask = vif->mgmt_frames_bitmask; 400 static const struct { 401 u16 mask, qlink_type; 402 } updates[] = { 403 { 404 .mask = BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | 405 BIT(IEEE80211_STYPE_ASSOC_REQ >> 4), 406 .qlink_type = QLINK_MGMT_FRAME_ASSOC_REQ, 407 }, 408 { 409 .mask = BIT(IEEE80211_STYPE_AUTH >> 4), 410 .qlink_type = QLINK_MGMT_FRAME_AUTH, 411 }, 412 { 413 .mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4), 414 .qlink_type = QLINK_MGMT_FRAME_PROBE_REQ, 415 }, 416 { 417 .mask = BIT(IEEE80211_STYPE_ACTION >> 4), 418 .qlink_type = QLINK_MGMT_FRAME_ACTION, 419 }, 420 }; 421 unsigned int i; 422 423 if (new_mask == old_mask) 424 return; 425 426 for (i = 0; i < ARRAY_SIZE(updates); i++) { 427 u16 mask = updates[i].mask; 428 u16 qlink_frame_type = updates[i].qlink_type; 429 bool reg; 430 431 /* the ! are here due to the assoc/reassoc merge */ 432 if (!(new_mask & mask) == !(old_mask & mask)) 433 continue; 434 435 reg = new_mask & mask; 436 437 if (qtnf_cmd_send_register_mgmt(vif, qlink_frame_type, reg)) 438 pr_warn("VIF%u.%u: failed to %sregister qlink frame type 0x%x\n", 439 vif->mac->macid, vif->vifid, reg ? "" : "un", 440 qlink_frame_type); 441 } 442 443 vif->mgmt_frames_bitmask = new_mask; 444 } 445 446 static int 447 qtnf_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 448 struct cfg80211_mgmt_tx_params *params, u64 *cookie) 449 { 450 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev); 451 const struct ieee80211_mgmt *mgmt_frame = (void *)params->buf; 452 u32 short_cookie = prandom_u32(); 453 u16 flags = 0; 454 u16 freq; 455 456 *cookie = short_cookie; 457 458 if (params->offchan) 459 flags |= QLINK_FRAME_TX_FLAG_OFFCHAN; 460 461 if (params->no_cck) 462 flags |= QLINK_FRAME_TX_FLAG_NO_CCK; 463 464 if (params->dont_wait_for_ack) 465 flags |= QLINK_FRAME_TX_FLAG_ACK_NOWAIT; 466 467 /* If channel is not specified, pass "freq = 0" to tell device 468 * firmware to use current channel. 469 */ 470 if (params->chan) 471 freq = params->chan->center_freq; 472 else 473 freq = 0; 474 475 pr_debug("%s freq:%u; FC:%.4X; DA:%pM; len:%zu; C:%.8X; FL:%.4X\n", 476 wdev->netdev->name, freq, 477 le16_to_cpu(mgmt_frame->frame_control), mgmt_frame->da, 478 params->len, short_cookie, flags); 479 480 return qtnf_cmd_send_frame(vif, short_cookie, flags, 481 freq, params->buf, params->len); 482 } 483 484 static int 485 qtnf_get_station(struct wiphy *wiphy, struct net_device *dev, 486 const u8 *mac, struct station_info *sinfo) 487 { 488 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 489 490 sinfo->generation = vif->generation; 491 return qtnf_cmd_get_sta_info(vif, mac, sinfo); 492 } 493 494 static int 495 qtnf_dump_station(struct wiphy *wiphy, struct net_device *dev, 496 int idx, u8 *mac, struct station_info *sinfo) 497 { 498 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 499 const struct qtnf_sta_node *sta_node; 500 int ret; 501 502 switch (vif->wdev.iftype) { 503 case NL80211_IFTYPE_STATION: 504 if (idx != 0 || !vif->wdev.connected) 505 return -ENOENT; 506 507 ether_addr_copy(mac, vif->bssid); 508 break; 509 case NL80211_IFTYPE_AP: 510 sta_node = qtnf_sta_list_lookup_index(&vif->sta_list, idx); 511 if (unlikely(!sta_node)) 512 return -ENOENT; 513 514 ether_addr_copy(mac, sta_node->mac_addr); 515 break; 516 default: 517 return -ENOTSUPP; 518 } 519 520 ret = qtnf_cmd_get_sta_info(vif, mac, sinfo); 521 522 if (vif->wdev.iftype == NL80211_IFTYPE_AP) { 523 if (ret == -ENOENT) { 524 cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL); 525 sinfo->filled = 0; 526 } 527 } 528 529 sinfo->generation = vif->generation; 530 531 return ret; 532 } 533 534 static int qtnf_add_key(struct wiphy *wiphy, struct net_device *dev, 535 u8 key_index, bool pairwise, const u8 *mac_addr, 536 struct key_params *params) 537 { 538 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 539 int ret; 540 541 ret = qtnf_cmd_send_add_key(vif, key_index, pairwise, mac_addr, params); 542 if (ret) 543 pr_err("VIF%u.%u: failed to add key: cipher=%x idx=%u pw=%u\n", 544 vif->mac->macid, vif->vifid, params->cipher, key_index, 545 pairwise); 546 547 return ret; 548 } 549 550 static int qtnf_del_key(struct wiphy *wiphy, struct net_device *dev, 551 u8 key_index, bool pairwise, const u8 *mac_addr) 552 { 553 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 554 int ret; 555 556 ret = qtnf_cmd_send_del_key(vif, key_index, pairwise, mac_addr); 557 if (ret) { 558 if (ret == -ENOENT) { 559 pr_debug("VIF%u.%u: key index %d out of bounds\n", 560 vif->mac->macid, vif->vifid, key_index); 561 } else { 562 pr_err("VIF%u.%u: failed to delete key: idx=%u pw=%u\n", 563 vif->mac->macid, vif->vifid, 564 key_index, pairwise); 565 } 566 } 567 568 return ret; 569 } 570 571 static int qtnf_set_default_key(struct wiphy *wiphy, struct net_device *dev, 572 u8 key_index, bool unicast, bool multicast) 573 { 574 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 575 int ret; 576 577 ret = qtnf_cmd_send_set_default_key(vif, key_index, unicast, multicast); 578 if (ret) 579 pr_err("VIF%u.%u: failed to set dflt key: idx=%u uc=%u mc=%u\n", 580 vif->mac->macid, vif->vifid, key_index, unicast, 581 multicast); 582 583 return ret; 584 } 585 586 static int 587 qtnf_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *dev, 588 u8 key_index) 589 { 590 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 591 int ret; 592 593 ret = qtnf_cmd_send_set_default_mgmt_key(vif, key_index); 594 if (ret) 595 pr_err("VIF%u.%u: failed to set default MGMT key: idx=%u\n", 596 vif->mac->macid, vif->vifid, key_index); 597 598 return ret; 599 } 600 601 static int 602 qtnf_change_station(struct wiphy *wiphy, struct net_device *dev, 603 const u8 *mac, struct station_parameters *params) 604 { 605 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 606 int ret; 607 608 ret = qtnf_cmd_send_change_sta(vif, mac, params); 609 if (ret) 610 pr_err("VIF%u.%u: failed to change STA %pM\n", 611 vif->mac->macid, vif->vifid, mac); 612 613 return ret; 614 } 615 616 static int 617 qtnf_del_station(struct wiphy *wiphy, struct net_device *dev, 618 struct station_del_parameters *params) 619 { 620 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 621 int ret; 622 623 if (params->mac && 624 (vif->wdev.iftype == NL80211_IFTYPE_AP) && 625 !is_broadcast_ether_addr(params->mac) && 626 !qtnf_sta_list_lookup(&vif->sta_list, params->mac)) 627 return 0; 628 629 ret = qtnf_cmd_send_del_sta(vif, params); 630 if (ret) 631 pr_err("VIF%u.%u: failed to delete STA %pM\n", 632 vif->mac->macid, vif->vifid, params->mac); 633 634 return ret; 635 } 636 637 static int 638 qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) 639 { 640 struct qtnf_wmac *mac = wiphy_priv(wiphy); 641 int ret; 642 643 cancel_delayed_work_sync(&mac->scan_timeout); 644 645 mac->scan_req = request; 646 647 ret = qtnf_cmd_send_scan(mac); 648 if (ret) { 649 pr_err("MAC%u: failed to start scan\n", mac->macid); 650 mac->scan_req = NULL; 651 goto out; 652 } 653 654 pr_debug("MAC%u: scan started\n", mac->macid); 655 queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout, 656 QTNF_SCAN_TIMEOUT_SEC * HZ); 657 658 out: 659 return ret; 660 } 661 662 static int 663 qtnf_connect(struct wiphy *wiphy, struct net_device *dev, 664 struct cfg80211_connect_params *sme) 665 { 666 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 667 int ret; 668 669 if (vif->wdev.iftype != NL80211_IFTYPE_STATION) 670 return -EOPNOTSUPP; 671 672 if (sme->auth_type == NL80211_AUTHTYPE_SAE && 673 !(sme->flags & CONNECT_REQ_EXTERNAL_AUTH_SUPPORT)) { 674 pr_err("can not offload authentication to userspace\n"); 675 return -EOPNOTSUPP; 676 } 677 678 if (sme->bssid) 679 ether_addr_copy(vif->bssid, sme->bssid); 680 else 681 eth_zero_addr(vif->bssid); 682 683 ret = qtnf_cmd_send_connect(vif, sme); 684 if (ret) 685 pr_err("VIF%u.%u: failed to connect\n", 686 vif->mac->macid, vif->vifid); 687 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 707 return ret; 708 } 709 710 static int 711 qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev, 712 u16 reason_code) 713 { 714 struct qtnf_wmac *mac = wiphy_priv(wiphy); 715 struct qtnf_vif *vif; 716 int ret = 0; 717 718 vif = qtnf_mac_get_base_vif(mac); 719 if (!vif) { 720 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 721 return -EFAULT; 722 } 723 724 if (vif->wdev.iftype != NL80211_IFTYPE_STATION) 725 return -EOPNOTSUPP; 726 727 ret = qtnf_cmd_send_disconnect(vif, reason_code); 728 if (ret) 729 pr_err("VIF%u.%u: failed to disconnect\n", 730 mac->macid, vif->vifid); 731 732 if (vif->wdev.connected) { 733 netif_carrier_off(vif->netdev); 734 cfg80211_disconnected(vif->netdev, reason_code, 735 NULL, 0, true, GFP_KERNEL); 736 } 737 738 return ret; 739 } 740 741 static int 742 qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev, 743 int idx, struct survey_info *survey) 744 { 745 struct qtnf_wmac *mac = wiphy_priv(wiphy); 746 struct wireless_dev *wdev = dev->ieee80211_ptr; 747 struct ieee80211_supported_band *sband; 748 const struct cfg80211_chan_def *chandef = wdev_chandef(wdev, 0); 749 struct ieee80211_channel *chan; 750 int ret; 751 752 sband = wiphy->bands[NL80211_BAND_2GHZ]; 753 if (sband && idx >= sband->n_channels) { 754 idx -= sband->n_channels; 755 sband = NULL; 756 } 757 758 if (!sband) 759 sband = wiphy->bands[NL80211_BAND_5GHZ]; 760 761 if (!sband || idx >= sband->n_channels) 762 return -ENOENT; 763 764 chan = &sband->channels[idx]; 765 survey->channel = chan; 766 survey->filled = 0x0; 767 768 if (chandef && chan == chandef->chan) 769 survey->filled = SURVEY_INFO_IN_USE; 770 771 ret = qtnf_cmd_get_chan_stats(mac, chan->center_freq, survey); 772 if (ret) 773 pr_debug("failed to get chan(%d) stats from card\n", 774 chan->hw_value); 775 776 return ret; 777 } 778 779 static int 780 qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, 781 unsigned int link_id, struct cfg80211_chan_def *chandef) 782 { 783 struct net_device *ndev = wdev->netdev; 784 struct qtnf_vif *vif; 785 int ret; 786 787 if (!ndev) 788 return -ENODEV; 789 790 vif = qtnf_netdev_get_priv(wdev->netdev); 791 792 ret = qtnf_cmd_get_channel(vif, chandef); 793 if (ret) { 794 pr_err("%s: failed to get channel: %d\n", ndev->name, ret); 795 ret = -ENODATA; 796 goto out; 797 } 798 799 if (!cfg80211_chandef_valid(chandef)) { 800 pr_err("%s: bad channel freq=%u cf1=%u cf2=%u bw=%u\n", 801 ndev->name, chandef->chan->center_freq, 802 chandef->center_freq1, chandef->center_freq2, 803 chandef->width); 804 ret = -ENODATA; 805 goto out; 806 } 807 808 out: 809 return ret; 810 } 811 812 static int qtnf_channel_switch(struct wiphy *wiphy, struct net_device *dev, 813 struct cfg80211_csa_settings *params) 814 { 815 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 816 int ret; 817 818 pr_debug("%s: chan(%u) count(%u) radar(%u) block_tx(%u)\n", dev->name, 819 params->chandef.chan->hw_value, params->count, 820 params->radar_required, params->block_tx); 821 822 if (!cfg80211_chandef_valid(¶ms->chandef)) { 823 pr_err("%s: invalid channel\n", dev->name); 824 return -EINVAL; 825 } 826 827 ret = qtnf_cmd_send_chan_switch(vif, params); 828 if (ret) 829 pr_warn("%s: failed to switch to channel (%u)\n", 830 dev->name, params->chandef.chan->hw_value); 831 832 return ret; 833 } 834 835 static int qtnf_start_radar_detection(struct wiphy *wiphy, 836 struct net_device *ndev, 837 struct cfg80211_chan_def *chandef, 838 u32 cac_time_ms) 839 { 840 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 841 int ret; 842 843 if (wiphy_ext_feature_isset(wiphy, NL80211_EXT_FEATURE_DFS_OFFLOAD)) 844 return -ENOTSUPP; 845 846 ret = qtnf_cmd_start_cac(vif, chandef, cac_time_ms); 847 if (ret) 848 pr_err("%s: failed to start CAC ret=%d\n", ndev->name, ret); 849 850 return ret; 851 } 852 853 static int qtnf_set_mac_acl(struct wiphy *wiphy, 854 struct net_device *dev, 855 const struct cfg80211_acl_data *params) 856 { 857 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 858 int ret; 859 860 ret = qtnf_cmd_set_mac_acl(vif, params); 861 if (ret) 862 pr_err("%s: failed to set mac ACL ret=%d\n", dev->name, ret); 863 864 return ret; 865 } 866 867 static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, 868 bool enabled, int timeout) 869 { 870 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 871 int ret; 872 873 ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY : 874 QLINK_PM_OFF, timeout); 875 if (ret) 876 pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret); 877 878 return ret; 879 } 880 881 static int qtnf_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, 882 int *dbm) 883 { 884 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev); 885 int ret; 886 887 ret = qtnf_cmd_get_tx_power(vif, dbm); 888 if (ret) 889 pr_err("MAC%u: failed to get Tx power\n", vif->mac->macid); 890 891 return ret; 892 } 893 894 static int qtnf_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, 895 enum nl80211_tx_power_setting type, int mbm) 896 { 897 struct qtnf_vif *vif; 898 int ret; 899 900 if (wdev) { 901 vif = qtnf_netdev_get_priv(wdev->netdev); 902 } else { 903 struct qtnf_wmac *mac = wiphy_priv(wiphy); 904 905 vif = qtnf_mac_get_base_vif(mac); 906 if (!vif) { 907 pr_err("MAC%u: primary VIF is not configured\n", 908 mac->macid); 909 return -EFAULT; 910 } 911 } 912 913 ret = qtnf_cmd_set_tx_power(vif, type, mbm); 914 if (ret) 915 pr_err("MAC%u: failed to set Tx power\n", vif->mac->macid); 916 917 return ret; 918 } 919 920 static int qtnf_update_owe_info(struct wiphy *wiphy, struct net_device *dev, 921 struct cfg80211_update_owe_info *owe_info) 922 { 923 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 924 int ret; 925 926 if (vif->wdev.iftype != NL80211_IFTYPE_AP) 927 return -EOPNOTSUPP; 928 929 ret = qtnf_cmd_send_update_owe(vif, owe_info); 930 if (ret) 931 pr_err("VIF%u.%u: failed to update owe info\n", 932 vif->mac->macid, vif->vifid); 933 934 return ret; 935 } 936 937 #ifdef CONFIG_PM 938 static int qtnf_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wowlan) 939 { 940 struct qtnf_wmac *mac = wiphy_priv(wiphy); 941 struct qtnf_vif *vif; 942 int ret = 0; 943 944 vif = qtnf_mac_get_base_vif(mac); 945 if (!vif) { 946 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 947 ret = -EFAULT; 948 goto exit; 949 } 950 951 if (!wowlan) { 952 pr_debug("WoWLAN triggers are not enabled\n"); 953 qtnf_virtual_intf_cleanup(vif->netdev); 954 goto exit; 955 } 956 957 qtnf_scan_done(vif->mac, true); 958 959 ret = qtnf_cmd_send_wowlan_set(vif, wowlan); 960 if (ret) { 961 pr_err("MAC%u: failed to set WoWLAN triggers\n", 962 mac->macid); 963 goto exit; 964 } 965 966 exit: 967 return ret; 968 } 969 970 static int qtnf_resume(struct wiphy *wiphy) 971 { 972 struct qtnf_wmac *mac = wiphy_priv(wiphy); 973 struct qtnf_vif *vif; 974 int ret = 0; 975 976 vif = qtnf_mac_get_base_vif(mac); 977 if (!vif) { 978 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 979 return -EFAULT; 980 } 981 982 ret = qtnf_cmd_send_wowlan_set(vif, NULL); 983 if (ret) 984 pr_err("MAC%u: failed to reset WoWLAN triggers\n", 985 mac->macid); 986 987 return ret; 988 } 989 990 static void qtnf_set_wakeup(struct wiphy *wiphy, bool enabled) 991 { 992 struct qtnf_wmac *mac = wiphy_priv(wiphy); 993 struct qtnf_bus *bus = mac->bus; 994 995 device_set_wakeup_enable(bus->dev, enabled); 996 } 997 #endif 998 999 static struct cfg80211_ops qtn_cfg80211_ops = { 1000 .add_virtual_intf = qtnf_add_virtual_intf, 1001 .change_virtual_intf = qtnf_change_virtual_intf, 1002 .del_virtual_intf = qtnf_del_virtual_intf, 1003 .start_ap = qtnf_start_ap, 1004 .change_beacon = qtnf_change_beacon, 1005 .stop_ap = qtnf_stop_ap, 1006 .set_wiphy_params = qtnf_set_wiphy_params, 1007 .update_mgmt_frame_registrations = 1008 qtnf_update_mgmt_frame_registrations, 1009 .mgmt_tx = qtnf_mgmt_tx, 1010 .change_station = qtnf_change_station, 1011 .del_station = qtnf_del_station, 1012 .get_station = qtnf_get_station, 1013 .dump_station = qtnf_dump_station, 1014 .add_key = qtnf_add_key, 1015 .del_key = qtnf_del_key, 1016 .set_default_key = qtnf_set_default_key, 1017 .set_default_mgmt_key = qtnf_set_default_mgmt_key, 1018 .scan = qtnf_scan, 1019 .connect = qtnf_connect, 1020 .external_auth = qtnf_external_auth, 1021 .disconnect = qtnf_disconnect, 1022 .dump_survey = qtnf_dump_survey, 1023 .get_channel = qtnf_get_channel, 1024 .channel_switch = qtnf_channel_switch, 1025 .start_radar_detection = qtnf_start_radar_detection, 1026 .set_mac_acl = qtnf_set_mac_acl, 1027 .set_power_mgmt = qtnf_set_power_mgmt, 1028 .get_tx_power = qtnf_get_tx_power, 1029 .set_tx_power = qtnf_set_tx_power, 1030 .update_owe_info = qtnf_update_owe_info, 1031 #ifdef CONFIG_PM 1032 .suspend = qtnf_suspend, 1033 .resume = qtnf_resume, 1034 .set_wakeup = qtnf_set_wakeup, 1035 #endif 1036 }; 1037 1038 static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy, 1039 struct regulatory_request *req) 1040 { 1041 struct qtnf_wmac *mac = wiphy_priv(wiphy); 1042 enum nl80211_band band; 1043 int ret; 1044 1045 pr_debug("MAC%u: initiator=%d alpha=%c%c\n", mac->macid, req->initiator, 1046 req->alpha2[0], req->alpha2[1]); 1047 1048 ret = qtnf_cmd_reg_notify(mac, req, qtnf_slave_radar_get(), 1049 qtnf_dfs_offload_get()); 1050 if (ret) { 1051 pr_err("MAC%u: failed to update region to %c%c: %d\n", 1052 mac->macid, req->alpha2[0], req->alpha2[1], ret); 1053 return; 1054 } 1055 1056 for (band = 0; band < NUM_NL80211_BANDS; ++band) { 1057 if (!wiphy->bands[band]) 1058 continue; 1059 1060 ret = qtnf_cmd_band_info_get(mac, wiphy->bands[band]); 1061 if (ret) 1062 pr_err("MAC%u: failed to update band %u\n", 1063 mac->macid, band); 1064 } 1065 } 1066 1067 struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus, 1068 struct platform_device *pdev) 1069 { 1070 struct wiphy *wiphy; 1071 1072 if (qtnf_dfs_offload_get() && 1073 qtnf_hwcap_is_set(&bus->hw_info, QLINK_HW_CAPAB_DFS_OFFLOAD)) 1074 qtn_cfg80211_ops.start_radar_detection = NULL; 1075 1076 if (!qtnf_hwcap_is_set(&bus->hw_info, QLINK_HW_CAPAB_PWR_MGMT)) 1077 qtn_cfg80211_ops.set_power_mgmt = NULL; 1078 1079 wiphy = wiphy_new(&qtn_cfg80211_ops, sizeof(struct qtnf_wmac)); 1080 if (!wiphy) 1081 return NULL; 1082 1083 if (pdev) 1084 set_wiphy_dev(wiphy, &pdev->dev); 1085 else 1086 set_wiphy_dev(wiphy, bus->dev); 1087 1088 return wiphy; 1089 } 1090 1091 static int 1092 qtnf_wiphy_setup_if_comb(struct wiphy *wiphy, struct qtnf_mac_info *mac_info) 1093 { 1094 struct ieee80211_iface_combination *if_comb; 1095 size_t n_if_comb; 1096 u16 interface_modes = 0; 1097 size_t i, j; 1098 1099 if_comb = mac_info->if_comb; 1100 n_if_comb = mac_info->n_if_comb; 1101 1102 if (!if_comb || !n_if_comb) 1103 return -ENOENT; 1104 1105 for (i = 0; i < n_if_comb; i++) { 1106 if_comb[i].radar_detect_widths = mac_info->radar_detect_widths; 1107 1108 for (j = 0; j < if_comb[i].n_limits; j++) 1109 interface_modes |= if_comb[i].limits[j].types; 1110 } 1111 1112 wiphy->iface_combinations = if_comb; 1113 wiphy->n_iface_combinations = n_if_comb; 1114 wiphy->interface_modes = interface_modes; 1115 1116 return 0; 1117 } 1118 1119 int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) 1120 { 1121 struct wiphy *wiphy = priv_to_wiphy(mac); 1122 struct qtnf_mac_info *macinfo = &mac->macinfo; 1123 int ret; 1124 bool regdomain_is_known; 1125 1126 if (!wiphy) { 1127 pr_err("invalid wiphy pointer\n"); 1128 return -EFAULT; 1129 } 1130 1131 wiphy->frag_threshold = macinfo->frag_thr; 1132 wiphy->rts_threshold = macinfo->rts_thr; 1133 wiphy->retry_short = macinfo->sretry_limit; 1134 wiphy->retry_long = macinfo->lretry_limit; 1135 wiphy->coverage_class = macinfo->coverage_class; 1136 1137 wiphy->max_scan_ssids = 1138 (macinfo->max_scan_ssids) ? macinfo->max_scan_ssids : 1; 1139 wiphy->max_scan_ie_len = QTNF_MAX_VSIE_LEN; 1140 wiphy->mgmt_stypes = qtnf_mgmt_stypes; 1141 wiphy->max_remain_on_channel_duration = 5000; 1142 wiphy->max_acl_mac_addrs = macinfo->max_acl_mac_addrs; 1143 wiphy->max_num_csa_counters = 2; 1144 1145 ret = qtnf_wiphy_setup_if_comb(wiphy, macinfo); 1146 if (ret) 1147 goto out; 1148 1149 /* Initialize cipher suits */ 1150 wiphy->cipher_suites = qtnf_cipher_suites; 1151 wiphy->n_cipher_suites = ARRAY_SIZE(qtnf_cipher_suites); 1152 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; 1153 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | 1154 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD | 1155 WIPHY_FLAG_AP_UAPSD | 1156 WIPHY_FLAG_HAS_CHANNEL_SWITCH | 1157 WIPHY_FLAG_4ADDR_STATION | 1158 WIPHY_FLAG_NETNS_OK; 1159 wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 1160 1161 if (qtnf_dfs_offload_get() && 1162 qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_DFS_OFFLOAD)) 1163 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_DFS_OFFLOAD); 1164 1165 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SCAN_DWELL)) 1166 wiphy_ext_feature_set(wiphy, 1167 NL80211_EXT_FEATURE_SET_SCAN_DWELL); 1168 1169 wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | 1170 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2; 1171 1172 wiphy->available_antennas_tx = macinfo->num_tx_chain; 1173 wiphy->available_antennas_rx = macinfo->num_rx_chain; 1174 1175 wiphy->max_ap_assoc_sta = macinfo->max_ap_assoc_sta; 1176 wiphy->ht_capa_mod_mask = &macinfo->ht_cap_mod_mask; 1177 wiphy->vht_capa_mod_mask = &macinfo->vht_cap_mod_mask; 1178 1179 ether_addr_copy(wiphy->perm_addr, mac->macaddr); 1180 1181 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_STA_INACT_TIMEOUT)) 1182 wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; 1183 1184 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR)) 1185 wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; 1186 1187 if (!qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_OBSS_SCAN)) 1188 wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; 1189 1190 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SAE)) 1191 wiphy->features |= NL80211_FEATURE_SAE; 1192 1193 #ifdef CONFIG_PM 1194 if (macinfo->wowlan) 1195 wiphy->wowlan = macinfo->wowlan; 1196 #endif 1197 1198 regdomain_is_known = isalpha(mac->rd->alpha2[0]) && 1199 isalpha(mac->rd->alpha2[1]); 1200 1201 if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_REG_UPDATE)) { 1202 wiphy->reg_notifier = qtnf_cfg80211_reg_notifier; 1203 1204 if (mac->rd->alpha2[0] == '9' && mac->rd->alpha2[1] == '9') { 1205 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | 1206 REGULATORY_STRICT_REG; 1207 wiphy_apply_custom_regulatory(wiphy, mac->rd); 1208 } else if (regdomain_is_known) { 1209 wiphy->regulatory_flags |= REGULATORY_STRICT_REG; 1210 } 1211 } else { 1212 wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; 1213 } 1214 1215 if (mac->macinfo.extended_capabilities_len) { 1216 wiphy->extended_capabilities = 1217 mac->macinfo.extended_capabilities; 1218 wiphy->extended_capabilities_mask = 1219 mac->macinfo.extended_capabilities_mask; 1220 wiphy->extended_capabilities_len = 1221 mac->macinfo.extended_capabilities_len; 1222 } 1223 1224 strlcpy(wiphy->fw_version, hw_info->fw_version, 1225 sizeof(wiphy->fw_version)); 1226 wiphy->hw_version = hw_info->hw_version; 1227 1228 ret = wiphy_register(wiphy); 1229 if (ret < 0) 1230 goto out; 1231 1232 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) 1233 ret = regulatory_set_wiphy_regd(wiphy, mac->rd); 1234 else if (regdomain_is_known) 1235 ret = regulatory_hint(wiphy, mac->rd->alpha2); 1236 1237 out: 1238 return ret; 1239 } 1240 1241 void qtnf_netdev_updown(struct net_device *ndev, bool up) 1242 { 1243 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 1244 1245 if (qtnf_cmd_send_updown_intf(vif, up)) 1246 pr_err("failed to send %s command to VIF%u.%u\n", 1247 up ? "UP" : "DOWN", vif->mac->macid, vif->vifid); 1248 } 1249 1250 void qtnf_virtual_intf_cleanup(struct net_device *ndev) 1251 { 1252 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 1253 struct qtnf_wmac *mac = wiphy_priv(vif->wdev.wiphy); 1254 1255 if (vif->wdev.iftype == NL80211_IFTYPE_STATION) 1256 qtnf_disconnect(vif->wdev.wiphy, ndev, 1257 WLAN_REASON_DEAUTH_LEAVING); 1258 1259 qtnf_scan_done(mac, true); 1260 } 1261 1262 void qtnf_cfg80211_vif_reset(struct qtnf_vif *vif) 1263 { 1264 if (vif->wdev.iftype == NL80211_IFTYPE_STATION) 1265 cfg80211_disconnected(vif->netdev, WLAN_REASON_DEAUTH_LEAVING, 1266 NULL, 0, 1, GFP_KERNEL); 1267 1268 cfg80211_shutdown_all_interfaces(vif->wdev.wiphy); 1269 } 1270 1271 void qtnf_band_init_rates(struct ieee80211_supported_band *band) 1272 { 1273 switch (band->band) { 1274 case NL80211_BAND_2GHZ: 1275 band->bitrates = qtnf_rates_2g; 1276 band->n_bitrates = ARRAY_SIZE(qtnf_rates_2g); 1277 break; 1278 case NL80211_BAND_5GHZ: 1279 band->bitrates = qtnf_rates_5g; 1280 band->n_bitrates = ARRAY_SIZE(qtnf_rates_5g); 1281 break; 1282 default: 1283 band->bitrates = NULL; 1284 band->n_bitrates = 0; 1285 break; 1286 } 1287 } 1288