.. | .. |
---|
1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
---|
2 | 1 | /* |
---|
3 | 2 | * Linux cfgp2p driver |
---|
4 | 3 | * |
---|
5 | | - * Copyright (C) 1999-2019, Broadcom Corporation |
---|
6 | | - * |
---|
| 4 | + * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation |
---|
| 5 | + * |
---|
| 6 | + * Copyright (C) 1999-2017, Broadcom Corporation |
---|
| 7 | + * |
---|
7 | 8 | * Unless you and Broadcom execute a separate written software license |
---|
8 | 9 | * agreement governing use of this software, this software is licensed to you |
---|
9 | 10 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
---|
10 | 11 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
---|
11 | 12 | * following added to such license: |
---|
12 | | - * |
---|
| 13 | + * |
---|
13 | 14 | * As a special exception, the copyright holders of this software give you |
---|
14 | 15 | * permission to link this software with independent modules, and to copy and |
---|
15 | 16 | * distribute the resulting executable under terms of your choice, provided that |
---|
.. | .. |
---|
17 | 18 | * the license of that module. An independent module is a module which is not |
---|
18 | 19 | * derived from this software. The special exception does not apply to any |
---|
19 | 20 | * modifications of the software. |
---|
20 | | - * |
---|
| 21 | + * |
---|
21 | 22 | * Notwithstanding the above, under no circumstances may you combine this |
---|
22 | 23 | * software in any way with any other Broadcom software provided under a license |
---|
23 | 24 | * other than the GPL, without Broadcom's express prior written consent. |
---|
.. | .. |
---|
25 | 26 | * |
---|
26 | 27 | * <<Broadcom-WL-IPTag/Open:>> |
---|
27 | 28 | * |
---|
28 | | - * $Id: wl_cfgp2p.c 709309 2019-01-17 09:04:00Z $ |
---|
| 29 | + * $Id: wl_cfgp2p.c 815562 2019-04-18 02:33:27Z $ |
---|
29 | 30 | * |
---|
30 | 31 | */ |
---|
31 | 32 | #include <typedefs.h> |
---|
.. | .. |
---|
39 | 40 | #include <linux/string.h> |
---|
40 | 41 | #include <linux/timer.h> |
---|
41 | 42 | #include <linux/if_arp.h> |
---|
42 | | -#include <linux/uaccess.h> |
---|
| 43 | +#include <asm/uaccess.h> |
---|
43 | 44 | |
---|
44 | 45 | #include <bcmutils.h> |
---|
| 46 | +#include <bcmstdlib_s.h> |
---|
45 | 47 | #include <bcmendian.h> |
---|
46 | | -#include <proto/ethernet.h> |
---|
47 | | -#include <proto/802.11.h> |
---|
| 48 | +#include <ethernet.h> |
---|
| 49 | +#include <802.11.h> |
---|
48 | 50 | #include <net/rtnetlink.h> |
---|
49 | 51 | |
---|
50 | 52 | #include <wl_cfg80211.h> |
---|
51 | 53 | #include <wl_cfgp2p.h> |
---|
| 54 | +#include <wl_cfgscan.h> |
---|
52 | 55 | #include <wldev_common.h> |
---|
| 56 | +#ifdef OEM_ANDROID |
---|
53 | 57 | #include <wl_android.h> |
---|
| 58 | +#endif // endif |
---|
54 | 59 | #include <dngl_stats.h> |
---|
55 | 60 | #include <dhd.h> |
---|
56 | 61 | #include <dhd_linux.h> |
---|
57 | 62 | #include <dhdioctl.h> |
---|
58 | 63 | #include <wlioctl.h> |
---|
59 | 64 | #include <dhd_cfg80211.h> |
---|
| 65 | +#include <dhd_bus.h> |
---|
60 | 66 | |
---|
61 | 67 | static s8 scanparambuf[WLC_IOCTL_SMLEN]; |
---|
62 | | -static bool |
---|
63 | | -wl_cfgp2p_has_ie(u8 *ie, u8 **tlvs, u32 *tlvs_len, const u8 *oui, u32 oui_len, u8 type); |
---|
| 68 | +static bool wl_cfgp2p_has_ie(const bcm_tlv_t *ie, const u8 **tlvs, u32 *tlvs_len, |
---|
| 69 | + const u8 *oui, u32 oui_len, u8 type); |
---|
64 | 70 | |
---|
65 | 71 | static s32 wl_cfgp2p_cancel_listen(struct bcm_cfg80211 *cfg, struct net_device *ndev, |
---|
66 | 72 | struct wireless_dev *wdev, bool notify); |
---|
.. | .. |
---|
79 | 85 | }; |
---|
80 | 86 | #endif /* WL_ENABLE_P2P_IF */ |
---|
81 | 87 | |
---|
| 88 | +#if defined(WL_NEWCFG_PRIVCMD_SUPPORT) |
---|
| 89 | +static int wl_cfgp2p_start_xmit(struct sk_buff *skb, struct net_device *ndev); |
---|
| 90 | +static int wl_cfgp2p_do_ioctl(struct net_device *net, struct ifreq *ifr, int cmd); |
---|
| 91 | + |
---|
| 92 | +static int wl_cfgp2p_if_dummy(struct net_device *net) |
---|
| 93 | +{ |
---|
| 94 | + return 0; |
---|
| 95 | +} |
---|
| 96 | + |
---|
| 97 | +static const struct net_device_ops wl_cfgp2p_if_ops = { |
---|
| 98 | + .ndo_open = wl_cfgp2p_if_dummy, |
---|
| 99 | + .ndo_stop = wl_cfgp2p_if_dummy, |
---|
| 100 | + .ndo_do_ioctl = wl_cfgp2p_do_ioctl, |
---|
| 101 | + .ndo_start_xmit = wl_cfgp2p_start_xmit, |
---|
| 102 | +}; |
---|
| 103 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
82 | 104 | |
---|
83 | 105 | bool wl_cfgp2p_is_pub_action(void *frame, u32 frame_len) |
---|
84 | 106 | { |
---|
.. | .. |
---|
126 | 148 | |
---|
127 | 149 | bool wl_cfgp2p_find_gas_subtype(u8 subtype, u8* data, u32 len) |
---|
128 | 150 | { |
---|
129 | | - bcm_tlv_t *ie = (bcm_tlv_t *)data; |
---|
130 | | - u8 *frame = NULL; |
---|
| 151 | + const bcm_tlv_t *ie = (bcm_tlv_t *)data; |
---|
| 152 | + const u8 *frame = NULL; |
---|
131 | 153 | u16 id, flen; |
---|
132 | 154 | |
---|
133 | 155 | /* Skipped first ANQP Element, if frame has anqp elemnt */ |
---|
134 | | - ie = bcm_parse_tlvs(ie, (int)len, DOT11_MNG_ADVERTISEMENT_ID); |
---|
| 156 | + ie = bcm_parse_tlvs(ie, len, DOT11_MNG_ADVERTISEMENT_ID); |
---|
135 | 157 | |
---|
136 | 158 | if (ie == NULL) |
---|
137 | 159 | return false; |
---|
138 | 160 | |
---|
139 | | - frame = (uint8 *)ie + ie->len + TLV_HDR_LEN + GAS_RESP_LEN; |
---|
| 161 | + frame = (const uint8 *)ie + ie->len + TLV_HDR_LEN + GAS_RESP_LEN; |
---|
140 | 162 | id = ((u16) (((frame)[1] << 8) | (frame)[0])); |
---|
141 | 163 | flen = ((u16) (((frame)[3] << 8) | (frame)[2])); |
---|
142 | 164 | |
---|
.. | .. |
---|
314 | 336 | " channel=%d\n", (tx)? "TX" : "RX", channel)); |
---|
315 | 337 | } |
---|
316 | 338 | |
---|
317 | | - |
---|
318 | 339 | } |
---|
319 | 340 | } |
---|
320 | 341 | |
---|
.. | .. |
---|
325 | 346 | s32 |
---|
326 | 347 | wl_cfgp2p_init_priv(struct bcm_cfg80211 *cfg) |
---|
327 | 348 | { |
---|
328 | | - if (!(cfg->p2p = kzalloc(sizeof(struct p2p_info), GFP_KERNEL))) { |
---|
| 349 | + cfg->p2p = MALLOCZ(cfg->osh, sizeof(struct p2p_info)); |
---|
| 350 | + if (cfg->p2p == NULL) { |
---|
329 | 351 | CFGP2P_ERR(("struct p2p_info allocation failed\n")); |
---|
330 | 352 | return -ENOMEM; |
---|
331 | 353 | } |
---|
.. | .. |
---|
338 | 360 | wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_CONNECTION1) = -1; |
---|
339 | 361 | wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_CONNECTION2) = NULL; |
---|
340 | 362 | wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_CONNECTION2) = -1; |
---|
341 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) |
---|
342 | | - cfg->p2p->cfg = cfg; |
---|
343 | | -#endif |
---|
344 | 363 | return BCME_OK; |
---|
345 | 364 | |
---|
346 | 365 | } |
---|
.. | .. |
---|
351 | 370 | void |
---|
352 | 371 | wl_cfgp2p_deinit_priv(struct bcm_cfg80211 *cfg) |
---|
353 | 372 | { |
---|
354 | | - CFGP2P_ERR(("In\n")); |
---|
| 373 | + CFGP2P_INFO(("In\n")); |
---|
355 | 374 | if (cfg->p2p) { |
---|
356 | | - kfree(cfg->p2p); |
---|
| 375 | + MFREE(cfg->osh, cfg->p2p, sizeof(struct p2p_info)); |
---|
357 | 376 | cfg->p2p = NULL; |
---|
358 | 377 | } |
---|
359 | 378 | cfg->p2p_supported = 0; |
---|
.. | .. |
---|
376 | 395 | } |
---|
377 | 396 | if (val == 0) { |
---|
378 | 397 | val = 1; |
---|
379 | | - ret = wldev_ioctl(ndev, WLC_DOWN, &val, sizeof(s32), true); |
---|
| 398 | + ret = wldev_ioctl_set(ndev, WLC_DOWN, &val, sizeof(s32)); |
---|
380 | 399 | if (ret < 0) { |
---|
381 | 400 | CFGP2P_ERR(("WLC_DOWN error %d\n", ret)); |
---|
382 | 401 | return ret; |
---|
.. | .. |
---|
389 | 408 | return ret; |
---|
390 | 409 | } |
---|
391 | 410 | |
---|
392 | | - ret = wldev_ioctl(ndev, WLC_UP, &val, sizeof(s32), true); |
---|
| 411 | + ret = wldev_ioctl_set(ndev, WLC_UP, &val, sizeof(s32)); |
---|
393 | 412 | if (ret < 0) { |
---|
394 | 413 | CFGP2P_ERR(("WLC_UP error %d\n", ret)); |
---|
395 | 414 | return ret; |
---|
.. | .. |
---|
435 | 454 | { |
---|
436 | 455 | wl_p2p_if_t ifreq; |
---|
437 | 456 | s32 err; |
---|
438 | | - u32 scb_timeout = WL_SCB_TIMEOUT; |
---|
439 | 457 | struct net_device *ndev = bcmcfg_to_prmry_ndev(cfg); |
---|
440 | 458 | |
---|
441 | 459 | ifreq.type = if_type; |
---|
442 | 460 | ifreq.chspec = chspec; |
---|
443 | 461 | memcpy(ifreq.addr.octet, mac->octet, sizeof(ifreq.addr.octet)); |
---|
444 | 462 | |
---|
445 | | - CFGP2P_DBG(("---cfg p2p_ifadd "MACDBG" %s %u\n", |
---|
| 463 | + CFGP2P_ERR(("---cfg p2p_ifadd "MACDBG" %s %u\n", |
---|
446 | 464 | MAC2STRDBG(ifreq.addr.octet), |
---|
447 | 465 | (if_type == WL_P2P_IF_GO) ? "go" : "client", |
---|
448 | 466 | (chspec & WL_CHANSPEC_CHAN_MASK) >> WL_CHANSPEC_CHAN_SHIFT)); |
---|
449 | 467 | |
---|
450 | 468 | err = wldev_iovar_setbuf(ndev, "p2p_ifadd", &ifreq, sizeof(ifreq), |
---|
451 | 469 | cfg->ioctl_buf, WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
452 | | - |
---|
453 | | - if (unlikely(err < 0)) |
---|
| 470 | + if (unlikely(err < 0)) { |
---|
454 | 471 | printk("'cfg p2p_ifadd' error %d\n", err); |
---|
455 | | - else if (if_type == WL_P2P_IF_GO) { |
---|
456 | | - err = wldev_ioctl(ndev, WLC_SET_SCB_TIMEOUT, &scb_timeout, sizeof(u32), true); |
---|
457 | | - if (unlikely(err < 0)) |
---|
458 | | - printk("'cfg scb_timeout' error %d\n", err); |
---|
| 472 | + return err; |
---|
459 | 473 | } |
---|
460 | 474 | |
---|
461 | 475 | return err; |
---|
.. | .. |
---|
472 | 486 | s32 ret; |
---|
473 | 487 | struct net_device *netdev = bcmcfg_to_prmry_ndev(cfg); |
---|
474 | 488 | |
---|
475 | | - CFGP2P_INFO(("------primary idx %d : cfg p2p_ifdis "MACDBG"\n", |
---|
476 | | - netdev->ifindex, MAC2STRDBG(mac->octet))); |
---|
| 489 | + CFGP2P_INFO(("------ cfg p2p_ifdis "MACDBG" dev->ifindex:%d \n", |
---|
| 490 | + MAC2STRDBG(mac->octet), netdev->ifindex)); |
---|
477 | 491 | ret = wldev_iovar_setbuf(netdev, "p2p_ifdis", mac, sizeof(*mac), |
---|
478 | 492 | cfg->ioctl_buf, WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
479 | 493 | if (unlikely(ret < 0)) { |
---|
.. | .. |
---|
491 | 505 | wl_cfgp2p_ifdel(struct bcm_cfg80211 *cfg, struct ether_addr *mac) |
---|
492 | 506 | { |
---|
493 | 507 | s32 ret; |
---|
| 508 | +#ifdef WL_DISABLE_HE_P2P |
---|
| 509 | + s32 bssidx = 0; |
---|
| 510 | +#endif /* WL_DISABLE_HE_P2P */ |
---|
494 | 511 | struct net_device *netdev = bcmcfg_to_prmry_ndev(cfg); |
---|
495 | 512 | |
---|
496 | | - CFGP2P_INFO(("------primary idx %d : cfg p2p_ifdel "MACDBG"\n", |
---|
497 | | - netdev->ifindex, MAC2STRDBG(mac->octet))); |
---|
| 513 | + CFGP2P_ERR(("------ cfg p2p_ifdel "MACDBG" dev->ifindex:%d\n", |
---|
| 514 | + MAC2STRDBG(mac->octet), netdev->ifindex)); |
---|
498 | 515 | ret = wldev_iovar_setbuf(netdev, "p2p_ifdel", mac, sizeof(*mac), |
---|
499 | 516 | cfg->ioctl_buf, WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
500 | 517 | if (unlikely(ret < 0)) { |
---|
501 | 518 | printk("'cfg p2p_ifdel' error %d\n", ret); |
---|
502 | 519 | } |
---|
| 520 | +#ifdef WL_DISABLE_HE_P2P |
---|
| 521 | + if ((bssidx = wl_get_bssidx_by_wdev(cfg, netdev->ieee80211_ptr)) < 0) { |
---|
| 522 | + WL_ERR(("Find index failed\n")); |
---|
| 523 | + ret = BCME_ERROR; |
---|
| 524 | + return ret; |
---|
| 525 | + } |
---|
| 526 | + WL_DBG(("Enabling back HE for P2P\n")); |
---|
| 527 | + wl_cfg80211_set_he_mode(netdev, cfg, bssidx, WL_IF_TYPE_P2P_DISC, TRUE); |
---|
| 528 | + if (ret < 0) { |
---|
| 529 | + WL_ERR(("failed to set he features, error=%d\n", ret)); |
---|
| 530 | + } |
---|
| 531 | +#endif /* WL_DISABLE_HE_P2P */ |
---|
| 532 | + |
---|
503 | 533 | return ret; |
---|
504 | 534 | } |
---|
505 | 535 | |
---|
.. | .. |
---|
514 | 544 | { |
---|
515 | 545 | wl_p2p_if_t ifreq; |
---|
516 | 546 | s32 err; |
---|
517 | | - u32 scb_timeout = WL_SCB_TIMEOUT; |
---|
518 | 547 | |
---|
519 | 548 | struct net_device *netdev = wl_to_p2p_bss_ndev(cfg, conn_idx); |
---|
520 | 549 | |
---|
.. | .. |
---|
530 | 559 | |
---|
531 | 560 | err = wldev_iovar_setbuf(netdev, "p2p_ifupd", &ifreq, sizeof(ifreq), |
---|
532 | 561 | cfg->ioctl_buf, WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
533 | | - |
---|
534 | 562 | if (unlikely(err < 0)) { |
---|
535 | 563 | printk("'cfg p2p_ifupd' error %d\n", err); |
---|
536 | 564 | } else if (if_type == WL_P2P_IF_GO) { |
---|
537 | 565 | cfg->p2p->p2p_go_count++; |
---|
538 | | - err = wldev_ioctl(netdev, WLC_SET_SCB_TIMEOUT, &scb_timeout, sizeof(u32), true); |
---|
539 | | - if (unlikely(err < 0)) |
---|
540 | | - printk("'cfg scb_timeout' error %d\n", err); |
---|
541 | 566 | } |
---|
542 | 567 | return err; |
---|
543 | 568 | } |
---|
544 | | - |
---|
545 | 569 | |
---|
546 | 570 | /* Get the index of a created P2P BSS. |
---|
547 | 571 | * Parameters: |
---|
.. | .. |
---|
563 | 587 | |
---|
564 | 588 | if (ret == 0) { |
---|
565 | 589 | memcpy(index, getbuf, sizeof(s32)); |
---|
566 | | - CFGP2P_INFO(("---cfg p2p_if ==> %d\n", *index)); |
---|
| 590 | + CFGP2P_DBG(("---cfg p2p_if ==> %d\n", *index)); |
---|
567 | 591 | } |
---|
568 | 592 | |
---|
569 | 593 | return ret; |
---|
.. | .. |
---|
635 | 659 | |
---|
636 | 660 | /* Put the WL driver into P2P Listen Mode to respond to P2P probe reqs */ |
---|
637 | 661 | discovery_mode.state = mode; |
---|
638 | | - discovery_mode.chspec = wl_ch_host_to_driver(bssidx, channel); |
---|
| 662 | + discovery_mode.chspec = wl_ch_host_to_driver(channel); |
---|
639 | 663 | discovery_mode.dwell = listen_ms; |
---|
640 | 664 | ret = wldev_iovar_setbuf_bsscfg(dev, "p2p_state", &discovery_mode, |
---|
641 | 665 | sizeof(discovery_mode), cfg->ioctl_buf, WLC_IOCTL_MAXLEN, |
---|
.. | .. |
---|
675 | 699 | CFGP2P_ERR(("Multi p2p not supported")); |
---|
676 | 700 | return BCME_ERROR; |
---|
677 | 701 | } |
---|
678 | | - if ((connected_cnt = wl_get_drv_status_all(cfg, CONNECTED)) > 1) { |
---|
| 702 | + if ((connected_cnt = wl_get_drv_status_all(cfg, CONNECTED)) > 2) { |
---|
679 | 703 | CFGP2P_ERR(("Failed to create second p2p interface" |
---|
680 | 704 | "Already one connection exists")); |
---|
681 | 705 | return BCME_ERROR; |
---|
.. | .. |
---|
693 | 717 | |
---|
694 | 718 | s32 bssidx = 0; |
---|
695 | 719 | s32 ret = BCME_OK; |
---|
| 720 | + struct net_device *ndev = bcmcfg_to_prmry_ndev(cfg); |
---|
696 | 721 | |
---|
| 722 | + BCM_REFERENCE(ndev); |
---|
697 | 723 | CFGP2P_DBG(("enter\n")); |
---|
698 | 724 | |
---|
699 | 725 | if (wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE) > 0) { |
---|
700 | 726 | CFGP2P_ERR(("do nothing, already initialized\n")); |
---|
701 | | - return ret; |
---|
| 727 | + goto exit; |
---|
702 | 728 | } |
---|
703 | 729 | |
---|
704 | 730 | ret = wl_cfgp2p_set_discovery(cfg, 1); |
---|
705 | 731 | if (ret < 0) { |
---|
706 | 732 | CFGP2P_ERR(("set discover error\n")); |
---|
707 | | - return ret; |
---|
| 733 | + goto exit; |
---|
708 | 734 | } |
---|
709 | 735 | /* Enable P2P Discovery in the WL Driver */ |
---|
710 | 736 | ret = wl_cfgp2p_get_disc_idx(cfg, &bssidx); |
---|
711 | | - |
---|
712 | 737 | if (ret < 0) { |
---|
713 | | - return ret; |
---|
| 738 | + goto exit; |
---|
714 | 739 | } |
---|
| 740 | + |
---|
715 | 741 | /* In case of CFG80211 case, check if p2p_discovery interface has allocated p2p_wdev */ |
---|
716 | 742 | if (!cfg->p2p_wdev) { |
---|
717 | 743 | CFGP2P_ERR(("p2p_wdev is NULL.\n")); |
---|
718 | | - return BCME_NODEVICE; |
---|
| 744 | + ret = -ENODEV; |
---|
| 745 | + goto exit; |
---|
719 | 746 | } |
---|
720 | | - /* Make an entry in the netinfo */ |
---|
721 | | - wl_alloc_netinfo(cfg, NULL, cfg->p2p_wdev, WL_MODE_BSS, 0, bssidx); |
---|
722 | 747 | |
---|
| 748 | + /* Once p2p also starts using interface_create iovar, the ifidx may change. |
---|
| 749 | + * so that time, the ifidx returned in WLC_E_IF should be used for populating |
---|
| 750 | + * the netinfo |
---|
| 751 | + */ |
---|
| 752 | + ret = wl_alloc_netinfo(cfg, NULL, cfg->p2p_wdev, WL_IF_TYPE_STA, 0, bssidx, 0); |
---|
| 753 | + if (unlikely(ret)) { |
---|
| 754 | + goto exit; |
---|
| 755 | + } |
---|
723 | 756 | wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_DEVICE) = |
---|
724 | 757 | wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_PRIMARY); |
---|
725 | 758 | wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE) = bssidx; |
---|
.. | .. |
---|
733 | 766 | wl_cfgp2p_set_discovery(cfg, 0); |
---|
734 | 767 | wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE) = 0; |
---|
735 | 768 | wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_DEVICE) = NULL; |
---|
736 | | - return 0; |
---|
| 769 | + ret = 0; |
---|
| 770 | + goto exit; |
---|
| 771 | + } |
---|
| 772 | + |
---|
| 773 | + /* Clear our saved WPS and P2P IEs for the discovery BSS */ |
---|
| 774 | + wl_cfg80211_clear_p2p_disc_ies(cfg); |
---|
| 775 | +exit: |
---|
| 776 | + if (ret) { |
---|
| 777 | + wl_flush_fw_log_buffer(ndev, FW_LOGSET_MASK_ALL); |
---|
737 | 778 | } |
---|
738 | 779 | return ret; |
---|
739 | 780 | } |
---|
.. | .. |
---|
757 | 798 | } |
---|
758 | 799 | |
---|
759 | 800 | /* Clear our saved WPS and P2P IEs for the discovery BSS */ |
---|
760 | | - wl_cfg80211_clear_per_bss_ies(cfg, bssidx); |
---|
| 801 | + wl_cfg80211_clear_p2p_disc_ies(cfg); |
---|
761 | 802 | |
---|
762 | 803 | /* Set the discovery state to SCAN */ |
---|
763 | 804 | wl_cfgp2p_set_p2p_mode(cfg, WL_P2P_DISC_ST_SCAN, 0, 0, |
---|
.. | .. |
---|
787 | 828 | { |
---|
788 | 829 | s32 ret = BCME_OK; |
---|
789 | 830 | s32 bssidx; |
---|
| 831 | + bcm_struct_cfgdev *cfgdev; |
---|
790 | 832 | |
---|
791 | 833 | CFGP2P_DBG(("enter\n")); |
---|
| 834 | + mutex_lock(&cfg->if_sync); |
---|
| 835 | +#ifdef WL_IFACE_MGMT |
---|
| 836 | + if ((ret = wl_cfg80211_handle_if_role_conflict(cfg, WL_IF_TYPE_P2P_DISC)) != BCME_OK) { |
---|
| 837 | + WL_ERR(("secondary iface is active, p2p enable discovery is not supported\n")); |
---|
| 838 | + goto exit; |
---|
| 839 | + } |
---|
| 840 | +#endif /* WL_IFACE_MGMT */ |
---|
| 841 | + |
---|
792 | 842 | if (wl_get_p2p_status(cfg, DISCOVERY_ON)) { |
---|
793 | | - CFGP2P_INFO((" DISCOVERY is already initialized, we have nothing to do\n")); |
---|
| 843 | + CFGP2P_DBG((" DISCOVERY is already initialized, we have nothing to do\n")); |
---|
794 | 844 | goto set_ie; |
---|
795 | 845 | } |
---|
796 | 846 | |
---|
.. | .. |
---|
817 | 867 | bssidx = wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE); |
---|
818 | 868 | } else if ((bssidx = wl_get_bssidx_by_wdev(cfg, cfg->p2p_wdev)) < 0) { |
---|
819 | 869 | WL_ERR(("Find p2p index from wdev(%p) failed\n", cfg->p2p_wdev)); |
---|
820 | | - return BCME_ERROR; |
---|
| 870 | + ret = BCME_ERROR; |
---|
| 871 | + goto exit; |
---|
821 | 872 | } |
---|
822 | 873 | |
---|
823 | | - ret = wl_cfg80211_set_mgmt_vndr_ies(cfg, ndev_to_cfgdev(dev), |
---|
824 | | - bssidx, |
---|
825 | | - VNDR_IE_PRBREQ_FLAG, ie, ie_len); |
---|
826 | | - |
---|
| 874 | +#if defined(WL_CFG80211_P2P_DEV_IF) |
---|
| 875 | + /* For 3.8+ kernels, pass p2p discovery wdev */ |
---|
| 876 | + cfgdev = cfg->p2p_wdev; |
---|
| 877 | +#else |
---|
| 878 | + /* Prior to 3.8 kernel, there is no netless p2p, so pass p2p0 ndev */ |
---|
| 879 | + cfgdev = ndev_to_cfgdev(dev); |
---|
| 880 | +#endif /* WL_CFG80211_P2P_DEV_IF */ |
---|
| 881 | + ret = wl_cfg80211_set_mgmt_vndr_ies(cfg, cfgdev, |
---|
| 882 | + bssidx, VNDR_IE_PRBREQ_FLAG, ie, ie_len); |
---|
827 | 883 | if (unlikely(ret < 0)) { |
---|
828 | 884 | CFGP2P_ERR(("set probreq ie occurs error %d\n", ret)); |
---|
829 | 885 | goto exit; |
---|
830 | 886 | } |
---|
831 | 887 | } |
---|
832 | 888 | exit: |
---|
| 889 | + if (ret) { |
---|
| 890 | + wl_flush_fw_log_buffer(dev, FW_LOGSET_MASK_ALL); |
---|
| 891 | + } |
---|
| 892 | + mutex_unlock(&cfg->if_sync); |
---|
833 | 893 | return ret; |
---|
834 | 894 | } |
---|
835 | 895 | |
---|
.. | .. |
---|
843 | 903 | { |
---|
844 | 904 | s32 ret = BCME_OK; |
---|
845 | 905 | s32 bssidx; |
---|
| 906 | + |
---|
846 | 907 | CFGP2P_DBG((" enter\n")); |
---|
847 | 908 | wl_clr_p2p_status(cfg, DISCOVERY_ON); |
---|
848 | | - |
---|
849 | 909 | #ifdef DHD_IFDEBUG |
---|
850 | | - WL_ERR(("%s: (cfg)->p2p->bss[type].bssidx: %d\n", |
---|
| 910 | + WL_ERR(("%s: bssidx: %d\n", |
---|
851 | 911 | __FUNCTION__, (cfg)->p2p->bss[P2PAPI_BSSCFG_DEVICE].bssidx)); |
---|
852 | | -#endif |
---|
| 912 | +#endif // endif |
---|
853 | 913 | bssidx = wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE); |
---|
854 | 914 | if (bssidx <= 0) { |
---|
855 | 915 | CFGP2P_ERR((" do nothing, not initialized\n")); |
---|
856 | 916 | return 0; |
---|
857 | 917 | } |
---|
858 | 918 | |
---|
859 | | - ret = wl_cfgp2p_set_p2p_mode(cfg, WL_P2P_DISC_ST_SCAN, 0, 0, |
---|
860 | | - bssidx); |
---|
861 | | - |
---|
| 919 | + ret = wl_cfgp2p_set_p2p_mode(cfg, WL_P2P_DISC_ST_SCAN, 0, 0, bssidx); |
---|
862 | 920 | if (unlikely(ret < 0)) { |
---|
863 | | - |
---|
864 | 921 | CFGP2P_ERR(("unable to set WL_P2P_DISC_ST_SCAN\n")); |
---|
865 | 922 | } |
---|
866 | 923 | /* Do a scan abort to stop the driver's scan engine in case it is still |
---|
.. | .. |
---|
871 | 928 | return ret; |
---|
872 | 929 | } |
---|
873 | 930 | |
---|
| 931 | +/* Scan parameters */ |
---|
| 932 | +#define P2PAPI_SCAN_NPROBES 1 |
---|
| 933 | +#define P2PAPI_SCAN_DWELL_TIME_MS 80 |
---|
| 934 | +#define P2PAPI_SCAN_SOCIAL_DWELL_TIME_MS 40 |
---|
| 935 | +#define P2PAPI_SCAN_HOME_TIME_MS 60 |
---|
| 936 | +#define P2PAPI_SCAN_NPROBS_TIME_MS 30 |
---|
| 937 | +#define P2PAPI_SCAN_AF_SEARCH_DWELL_TIME_MS 100 |
---|
874 | 938 | s32 |
---|
875 | | -wl_cfgp2p_escan(struct bcm_cfg80211 *cfg, struct net_device *dev, u16 active, |
---|
| 939 | +wl_cfgp2p_escan(struct bcm_cfg80211 *cfg, struct net_device *dev, u16 active_scan, |
---|
876 | 940 | u32 num_chans, u16 *channels, |
---|
877 | 941 | s32 search_state, u16 action, u32 bssidx, struct ether_addr *tx_dst_addr, |
---|
878 | 942 | p2p_scan_purpose_t p2p_scan_purpose) |
---|
.. | .. |
---|
884 | 948 | s8 *memblk; |
---|
885 | 949 | wl_p2p_scan_t *p2p_params; |
---|
886 | 950 | wl_escan_params_t *eparams; |
---|
| 951 | + wl_escan_params_v2_t *eparams_v2; |
---|
887 | 952 | wlc_ssid_t ssid; |
---|
888 | | - /* Scan parameters */ |
---|
889 | | -#define P2PAPI_SCAN_NPROBES 1 |
---|
890 | | -#define P2PAPI_SCAN_DWELL_TIME_MS 80 |
---|
891 | | -#define P2PAPI_SCAN_SOCIAL_DWELL_TIME_MS 40 |
---|
892 | | -#define P2PAPI_SCAN_HOME_TIME_MS 60 |
---|
893 | | -#define P2PAPI_SCAN_NPROBS_TIME_MS 30 |
---|
894 | | -#define P2PAPI_SCAN_AF_SEARCH_DWELL_TIME_MS 100 |
---|
| 953 | + u32 sync_id = 0; |
---|
| 954 | + s32 nprobes = 0; |
---|
| 955 | + s32 active_time = 0; |
---|
| 956 | + const struct ether_addr *mac_addr = NULL; |
---|
| 957 | + u32 scan_type = 0; |
---|
| 958 | + struct net_device *pri_dev = NULL; |
---|
895 | 959 | |
---|
896 | | - struct net_device *pri_dev = wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_PRIMARY); |
---|
| 960 | + pri_dev = wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_PRIMARY); |
---|
897 | 961 | /* Allocate scan params which need space for 3 channels and 0 ssids */ |
---|
898 | | - eparams_size = (WL_SCAN_PARAMS_FIXED_SIZE + |
---|
899 | | - OFFSETOF(wl_escan_params_t, params)) + |
---|
900 | | - num_chans * sizeof(eparams->params.channel_list[0]); |
---|
| 962 | + if (cfg->scan_params_v2) { |
---|
| 963 | + eparams_size = (WL_SCAN_PARAMS_V2_FIXED_SIZE + |
---|
| 964 | + OFFSETOF(wl_escan_params_v2_t, params)) + |
---|
| 965 | + num_chans * sizeof(eparams->params.channel_list[0]); |
---|
| 966 | + } else { |
---|
| 967 | + eparams_size = (WL_SCAN_PARAMS_FIXED_SIZE + |
---|
| 968 | + OFFSETOF(wl_escan_params_t, params)) + |
---|
| 969 | + num_chans * sizeof(eparams->params.channel_list[0]); |
---|
| 970 | + } |
---|
901 | 971 | |
---|
902 | 972 | memsize = sizeof(wl_p2p_scan_t) + eparams_size; |
---|
903 | 973 | memblk = scanparambuf; |
---|
.. | .. |
---|
906 | 976 | memsize, sizeof(scanparambuf))); |
---|
907 | 977 | return -1; |
---|
908 | 978 | } |
---|
909 | | - memset(memblk, 0, memsize); |
---|
910 | | - memset(cfg->ioctl_buf, 0, WLC_IOCTL_MAXLEN); |
---|
| 979 | + bzero(memblk, memsize); |
---|
| 980 | + bzero(cfg->ioctl_buf, WLC_IOCTL_MAXLEN); |
---|
911 | 981 | if (search_state == WL_P2P_DISC_ST_SEARCH) { |
---|
912 | 982 | /* |
---|
913 | 983 | * If we in SEARCH STATE, we don't need to set SSID explictly |
---|
.. | .. |
---|
916 | 986 | wl_cfgp2p_set_p2p_mode(cfg, WL_P2P_DISC_ST_SEARCH, 0, 0, bssidx); |
---|
917 | 987 | /* use null ssid */ |
---|
918 | 988 | ssid.SSID_len = 0; |
---|
919 | | - memset(&ssid.SSID, 0, sizeof(ssid.SSID)); |
---|
| 989 | + bzero(&ssid.SSID, sizeof(ssid.SSID)); |
---|
920 | 990 | } else if (search_state == WL_P2P_DISC_ST_SCAN) { |
---|
921 | 991 | /* SCAN STATE 802.11 SCAN |
---|
922 | 992 | * WFD Supplicant has p2p_find command with (type=progressive, type= full) |
---|
.. | .. |
---|
927 | 997 | wl_cfgp2p_set_p2p_mode(cfg, WL_P2P_DISC_ST_SCAN, 0, 0, bssidx); |
---|
928 | 998 | /* use wild card ssid */ |
---|
929 | 999 | ssid.SSID_len = WL_P2P_WILDCARD_SSID_LEN; |
---|
930 | | - memset(&ssid.SSID, 0, sizeof(ssid.SSID)); |
---|
| 1000 | + bzero(&ssid.SSID, sizeof(ssid.SSID)); |
---|
931 | 1001 | memcpy(&ssid.SSID, WL_P2P_WILDCARD_SSID, WL_P2P_WILDCARD_SSID_LEN); |
---|
932 | 1002 | } else { |
---|
933 | 1003 | CFGP2P_ERR((" invalid search state %d\n", search_state)); |
---|
934 | 1004 | return -1; |
---|
935 | 1005 | } |
---|
936 | 1006 | |
---|
937 | | - |
---|
938 | 1007 | /* Fill in the P2P scan structure at the start of the iovar param block */ |
---|
939 | 1008 | p2p_params = (wl_p2p_scan_t*) memblk; |
---|
940 | 1009 | p2p_params->type = 'E'; |
---|
941 | | - /* Fill in the Scan structure that follows the P2P scan structure */ |
---|
942 | | - eparams = (wl_escan_params_t*) (p2p_params + 1); |
---|
943 | | - eparams->params.bss_type = DOT11_BSSTYPE_ANY; |
---|
944 | | - if (active) |
---|
945 | | - eparams->params.scan_type = DOT11_SCANTYPE_ACTIVE; |
---|
946 | | - else |
---|
947 | | - eparams->params.scan_type = DOT11_SCANTYPE_PASSIVE; |
---|
948 | 1010 | |
---|
949 | | - if (tx_dst_addr == NULL) |
---|
950 | | - memcpy(&eparams->params.bssid, ðer_bcast, ETHER_ADDR_LEN); |
---|
951 | | - else |
---|
952 | | - memcpy(&eparams->params.bssid, tx_dst_addr, ETHER_ADDR_LEN); |
---|
| 1011 | + if (!active_scan) { |
---|
| 1012 | + scan_type = WL_SCANFLAGS_PASSIVE; |
---|
| 1013 | + } |
---|
953 | 1014 | |
---|
954 | | - if (ssid.SSID_len) |
---|
955 | | - memcpy(&eparams->params.ssid, &ssid, sizeof(wlc_ssid_t)); |
---|
956 | | - |
---|
957 | | - eparams->params.home_time = htod32(P2PAPI_SCAN_HOME_TIME_MS); |
---|
| 1015 | + if (tx_dst_addr == NULL) { |
---|
| 1016 | + mac_addr = ðer_bcast; |
---|
| 1017 | + } else { |
---|
| 1018 | + mac_addr = tx_dst_addr; |
---|
| 1019 | + } |
---|
958 | 1020 | |
---|
959 | 1021 | switch (p2p_scan_purpose) { |
---|
960 | 1022 | case P2P_SCAN_SOCIAL_CHANNEL: |
---|
961 | | - eparams->params.active_time = htod32(P2PAPI_SCAN_SOCIAL_DWELL_TIME_MS); |
---|
| 1023 | + active_time = P2PAPI_SCAN_SOCIAL_DWELL_TIME_MS; |
---|
962 | 1024 | break; |
---|
963 | 1025 | case P2P_SCAN_AFX_PEER_NORMAL: |
---|
964 | 1026 | case P2P_SCAN_AFX_PEER_REDUCED: |
---|
965 | | - eparams->params.active_time = htod32(P2PAPI_SCAN_AF_SEARCH_DWELL_TIME_MS); |
---|
| 1027 | + active_time = P2PAPI_SCAN_AF_SEARCH_DWELL_TIME_MS; |
---|
966 | 1028 | break; |
---|
967 | 1029 | case P2P_SCAN_CONNECT_TRY: |
---|
968 | | - eparams->params.active_time = htod32(WL_SCAN_CONNECT_DWELL_TIME_MS); |
---|
| 1030 | + active_time = WL_SCAN_CONNECT_DWELL_TIME_MS; |
---|
969 | 1031 | break; |
---|
970 | | - default : |
---|
971 | | - if (wl_get_drv_status_all(cfg, CONNECTED)) |
---|
972 | | - eparams->params.active_time = -1; |
---|
973 | | - else |
---|
974 | | - eparams->params.active_time = htod32(P2PAPI_SCAN_DWELL_TIME_MS); |
---|
| 1032 | + default: |
---|
| 1033 | + active_time = wl_get_drv_status_all(cfg, CONNECTED) ? |
---|
| 1034 | + -1 : P2PAPI_SCAN_DWELL_TIME_MS; |
---|
975 | 1035 | break; |
---|
976 | 1036 | } |
---|
977 | 1037 | |
---|
978 | | - if (p2p_scan_purpose == P2P_SCAN_CONNECT_TRY) |
---|
979 | | - eparams->params.nprobes = htod32(eparams->params.active_time / |
---|
980 | | - WL_SCAN_JOIN_PROBE_INTERVAL_MS); |
---|
981 | | - else |
---|
982 | | - eparams->params.nprobes = htod32((eparams->params.active_time / |
---|
983 | | - P2PAPI_SCAN_NPROBS_TIME_MS)); |
---|
984 | | - |
---|
985 | | - |
---|
986 | | - if (eparams->params.nprobes <= 0) |
---|
987 | | - eparams->params.nprobes = 1; |
---|
988 | | - CFGP2P_DBG(("nprobes # %d, active_time %d\n", |
---|
989 | | - eparams->params.nprobes, eparams->params.active_time)); |
---|
990 | | - eparams->params.passive_time = htod32(-1); |
---|
991 | | - eparams->params.channel_num = htod32((0 << WL_SCAN_PARAMS_NSSID_SHIFT) | |
---|
992 | | - (num_chans & WL_SCAN_PARAMS_COUNT_MASK)); |
---|
993 | | - |
---|
994 | | - for (i = 0; i < num_chans; i++) { |
---|
995 | | - eparams->params.channel_list[i] = wl_ch_host_to_driver(bssidx, channels[i]); |
---|
| 1038 | + if (p2p_scan_purpose == P2P_SCAN_CONNECT_TRY) { |
---|
| 1039 | + nprobes = active_time / |
---|
| 1040 | + WL_SCAN_JOIN_PROBE_INTERVAL_MS; |
---|
| 1041 | + } else { |
---|
| 1042 | + nprobes = active_time / |
---|
| 1043 | + P2PAPI_SCAN_NPROBS_TIME_MS; |
---|
996 | 1044 | } |
---|
997 | | - eparams->version = htod32(ESCAN_REQ_VERSION); |
---|
998 | | - eparams->action = htod16(action); |
---|
999 | | - wl_escan_set_sync_id(eparams->sync_id, cfg); |
---|
| 1045 | + |
---|
| 1046 | + if (nprobes <= 0) { |
---|
| 1047 | + nprobes = 1; |
---|
| 1048 | + } |
---|
| 1049 | + |
---|
| 1050 | + wl_escan_set_sync_id(sync_id, cfg); |
---|
| 1051 | + /* Fill in the Scan structure that follows the P2P scan structure */ |
---|
| 1052 | + if (cfg->scan_params_v2) { |
---|
| 1053 | + eparams_v2 = (wl_escan_params_v2_t*) (p2p_params + 1); |
---|
| 1054 | + eparams_v2->version = htod16(ESCAN_REQ_VERSION_V2); |
---|
| 1055 | + eparams_v2->action = htod16(action); |
---|
| 1056 | + eparams_v2->params.version = htod16(WL_SCAN_PARAMS_VERSION_V2); |
---|
| 1057 | + eparams_v2->params.length = htod16(sizeof(wl_scan_params_v2_t)); |
---|
| 1058 | + eparams_v2->params.bss_type = DOT11_BSSTYPE_ANY; |
---|
| 1059 | + eparams_v2->params.scan_type = htod32(scan_type); |
---|
| 1060 | + (void)memcpy_s(&eparams_v2->params.bssid, ETHER_ADDR_LEN, mac_addr, ETHER_ADDR_LEN); |
---|
| 1061 | + eparams_v2->params.home_time = htod32(P2PAPI_SCAN_HOME_TIME_MS); |
---|
| 1062 | + eparams_v2->params.active_time = htod32(active_time); |
---|
| 1063 | + eparams_v2->params.nprobes = htod32(nprobes); |
---|
| 1064 | + eparams_v2->params.passive_time = htod32(-1); |
---|
| 1065 | + eparams_v2->sync_id = sync_id; |
---|
| 1066 | + for (i = 0; i < num_chans; i++) { |
---|
| 1067 | + eparams_v2->params.channel_list[i] = |
---|
| 1068 | + wl_ch_host_to_driver(channels[i]); |
---|
| 1069 | + } |
---|
| 1070 | + eparams_v2->params.channel_num = htod32((0 << WL_SCAN_PARAMS_NSSID_SHIFT) | |
---|
| 1071 | + (num_chans & WL_SCAN_PARAMS_COUNT_MASK)); |
---|
| 1072 | + if (ssid.SSID_len) |
---|
| 1073 | + (void)memcpy_s(&eparams_v2->params.ssid, |
---|
| 1074 | + sizeof(wlc_ssid_t), &ssid, sizeof(wlc_ssid_t)); |
---|
| 1075 | + sync_id = eparams_v2->sync_id; |
---|
| 1076 | + } else { |
---|
| 1077 | + eparams = (wl_escan_params_t*) (p2p_params + 1); |
---|
| 1078 | + eparams->version = htod32(ESCAN_REQ_VERSION); |
---|
| 1079 | + eparams->action = htod16(action); |
---|
| 1080 | + eparams->params.bss_type = DOT11_BSSTYPE_ANY; |
---|
| 1081 | + eparams->params.scan_type = htod32(scan_type); |
---|
| 1082 | + (void)memcpy_s(&eparams->params.bssid, ETHER_ADDR_LEN, mac_addr, ETHER_ADDR_LEN); |
---|
| 1083 | + eparams->params.home_time = htod32(P2PAPI_SCAN_HOME_TIME_MS); |
---|
| 1084 | + eparams->params.active_time = htod32(active_time); |
---|
| 1085 | + eparams->params.nprobes = htod32(nprobes); |
---|
| 1086 | + eparams->params.passive_time = htod32(-1); |
---|
| 1087 | + eparams->sync_id = sync_id; |
---|
| 1088 | + for (i = 0; i < num_chans; i++) { |
---|
| 1089 | + eparams->params.channel_list[i] = |
---|
| 1090 | + wl_ch_host_to_driver(channels[i]); |
---|
| 1091 | + } |
---|
| 1092 | + eparams->params.channel_num = htod32((0 << WL_SCAN_PARAMS_NSSID_SHIFT) | |
---|
| 1093 | + (num_chans & WL_SCAN_PARAMS_COUNT_MASK)); |
---|
| 1094 | + if (ssid.SSID_len) |
---|
| 1095 | + (void)memcpy_s(&eparams->params.ssid, |
---|
| 1096 | + sizeof(wlc_ssid_t), &ssid, sizeof(wlc_ssid_t)); |
---|
| 1097 | + sync_id = eparams->sync_id; |
---|
| 1098 | + } |
---|
| 1099 | + |
---|
1000 | 1100 | wl_escan_set_type(cfg, WL_SCANTYPE_P2P); |
---|
1001 | | - CFGP2P_INFO(("SCAN CHANNELS : ")); |
---|
1002 | 1101 | |
---|
1003 | | - for (i = 0; i < num_chans; i++) { |
---|
1004 | | - if (i == 0) CFGP2P_INFO(("%d", channels[i])); |
---|
1005 | | - else CFGP2P_INFO((",%d", channels[i])); |
---|
| 1102 | + CFGP2P_DBG(("nprobes:%d active_time:%d\n", nprobes, active_time)); |
---|
| 1103 | + CFGP2P_DBG(("SCAN CHANNELS : ")); |
---|
| 1104 | + CFGP2P_DBG(("%d", channels[0])); |
---|
| 1105 | + for (i = 1; i < num_chans; i++) { |
---|
| 1106 | + CFGP2P_DBG((",%d", channels[i])); |
---|
1006 | 1107 | } |
---|
1007 | | - |
---|
1008 | | - CFGP2P_INFO(("\n")); |
---|
| 1108 | + CFGP2P_DBG(("\n")); |
---|
1009 | 1109 | |
---|
1010 | 1110 | ret = wldev_iovar_setbuf_bsscfg(pri_dev, "p2p_scan", |
---|
1011 | 1111 | memblk, memsize, cfg->ioctl_buf, WLC_IOCTL_MAXLEN, bssidx, &cfg->ioctl_buf_sync); |
---|
1012 | | - WL_ERR(("P2P_SEARCH sync ID: %d, bssidx: %d\n", eparams->sync_id, bssidx)); |
---|
1013 | | - if (ret == BCME_OK) |
---|
| 1112 | + WL_INFORM(("P2P_SEARCH sync ID: %d, bssidx: %d\n", sync_id, bssidx)); |
---|
| 1113 | + if (ret == BCME_OK) { |
---|
1014 | 1114 | wl_set_p2p_status(cfg, SCANNING); |
---|
| 1115 | + } |
---|
1015 | 1116 | return ret; |
---|
1016 | 1117 | } |
---|
1017 | 1118 | |
---|
.. | .. |
---|
1039 | 1140 | chan_cnt = AF_PEER_SEARCH_CNT; |
---|
1040 | 1141 | else |
---|
1041 | 1142 | chan_cnt = SOCIAL_CHAN_CNT; |
---|
1042 | | - default_chan_list = kzalloc(chan_cnt * sizeof(*default_chan_list), GFP_KERNEL); |
---|
| 1143 | + |
---|
| 1144 | + if (cfg->afx_hdl->pending_tx_act_frm && cfg->afx_hdl->is_active) { |
---|
| 1145 | + wl_action_frame_t *action_frame; |
---|
| 1146 | + action_frame = &(cfg->afx_hdl->pending_tx_act_frm->action_frame); |
---|
| 1147 | + if (wl_cfgp2p_is_p2p_gas_action(action_frame->data, action_frame->len)) { |
---|
| 1148 | + chan_cnt = 1; |
---|
| 1149 | + p2p_scan_purpose = P2P_SCAN_AFX_PEER_REDUCED; |
---|
| 1150 | + } |
---|
| 1151 | + } |
---|
| 1152 | + |
---|
| 1153 | + default_chan_list = (u16 *)MALLOCZ(cfg->osh, chan_cnt * sizeof(*default_chan_list)); |
---|
1043 | 1154 | if (default_chan_list == NULL) { |
---|
1044 | 1155 | CFGP2P_ERR(("channel list allocation failed \n")); |
---|
1045 | 1156 | ret = -ENOMEM; |
---|
.. | .. |
---|
1059 | 1170 | ret = wl_cfgp2p_escan(cfg, ndev, true, chan_cnt, |
---|
1060 | 1171 | default_chan_list, WL_P2P_DISC_ST_SEARCH, |
---|
1061 | 1172 | WL_SCAN_ACTION_START, bssidx, NULL, p2p_scan_purpose); |
---|
1062 | | - kfree(default_chan_list); |
---|
| 1173 | + MFREE(cfg->osh, default_chan_list, chan_cnt * sizeof(*default_chan_list)); |
---|
1063 | 1174 | exit: |
---|
1064 | 1175 | return ret; |
---|
1065 | 1176 | } |
---|
.. | .. |
---|
1076 | 1187 | /* Check whether the given IE looks like WFA WFDisplay IE. */ |
---|
1077 | 1188 | #ifndef WFA_OUI_TYPE_WFD |
---|
1078 | 1189 | #define WFA_OUI_TYPE_WFD 0x0a /* WiFi Display OUI TYPE */ |
---|
1079 | | -#endif |
---|
| 1190 | +#endif // endif |
---|
1080 | 1191 | #define wl_cfgp2p_is_wfd_ie(ie, tlvs, len) wl_cfgp2p_has_ie(ie, tlvs, len, \ |
---|
1081 | 1192 | (const uint8 *)WFA_OUI, WFA_OUI_LEN, WFA_OUI_TYPE_WFD) |
---|
1082 | | - |
---|
1083 | 1193 | |
---|
1084 | 1194 | /* Is any of the tlvs the expected entry? If |
---|
1085 | 1195 | * not update the tlvs buffer pointer/length. |
---|
1086 | 1196 | */ |
---|
1087 | 1197 | static bool |
---|
1088 | | -wl_cfgp2p_has_ie(u8 *ie, u8 **tlvs, u32 *tlvs_len, const u8 *oui, u32 oui_len, u8 type) |
---|
| 1198 | +wl_cfgp2p_has_ie(const bcm_tlv_t *ie, const u8 **tlvs, u32 *tlvs_len, |
---|
| 1199 | + const u8 *oui, u32 oui_len, u8 type) |
---|
1089 | 1200 | { |
---|
1090 | 1201 | /* If the contents match the OUI and the type */ |
---|
1091 | | - if (ie[TLV_LEN_OFF] >= oui_len + 1 && |
---|
1092 | | - !bcmp(&ie[TLV_BODY_OFF], oui, oui_len) && |
---|
1093 | | - type == ie[TLV_BODY_OFF + oui_len]) { |
---|
| 1202 | + if (ie->len >= oui_len + 1 && |
---|
| 1203 | + !bcmp(ie->data, oui, oui_len) && |
---|
| 1204 | + type == ie->data[oui_len]) { |
---|
1094 | 1205 | return TRUE; |
---|
1095 | 1206 | } |
---|
1096 | 1207 | |
---|
1097 | | - if (tlvs == NULL) |
---|
1098 | | - return FALSE; |
---|
1099 | 1208 | /* point to the next ie */ |
---|
1100 | | - ie += ie[TLV_LEN_OFF] + TLV_HDR_LEN; |
---|
1101 | | - /* calculate the length of the rest of the buffer */ |
---|
1102 | | - *tlvs_len -= (int)(ie - *tlvs); |
---|
1103 | | - /* update the pointer to the start of the buffer */ |
---|
1104 | | - *tlvs = ie; |
---|
| 1209 | + if (tlvs != NULL) { |
---|
| 1210 | + bcm_tlv_buffer_advance_past(ie, tlvs, tlvs_len); |
---|
| 1211 | + } |
---|
1105 | 1212 | |
---|
1106 | 1213 | return FALSE; |
---|
1107 | 1214 | } |
---|
1108 | 1215 | |
---|
1109 | | -wpa_ie_fixed_t * |
---|
1110 | | -wl_cfgp2p_find_wpaie(u8 *parse, u32 len) |
---|
| 1216 | +const wpa_ie_fixed_t * |
---|
| 1217 | +wl_cfgp2p_find_wpaie(const u8 *parse, u32 len) |
---|
1111 | 1218 | { |
---|
1112 | | - bcm_tlv_t *ie; |
---|
| 1219 | + const bcm_tlv_t *ie; |
---|
1113 | 1220 | |
---|
1114 | | - while ((ie = bcm_parse_tlvs(parse, (u32)len, DOT11_MNG_VS_ID))) { |
---|
1115 | | - if (wl_cfgp2p_is_wpa_ie((u8*)ie, &parse, &len)) { |
---|
1116 | | - return (wpa_ie_fixed_t *)ie; |
---|
| 1221 | + while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) { |
---|
| 1222 | + if (wl_cfgp2p_is_wpa_ie(ie, &parse, &len)) { |
---|
| 1223 | + return (const wpa_ie_fixed_t *)ie; |
---|
1117 | 1224 | } |
---|
1118 | 1225 | } |
---|
1119 | 1226 | return NULL; |
---|
1120 | 1227 | } |
---|
1121 | 1228 | |
---|
1122 | | -wpa_ie_fixed_t * |
---|
1123 | | -wl_cfgp2p_find_wpsie(u8 *parse, u32 len) |
---|
| 1229 | +const wpa_ie_fixed_t * |
---|
| 1230 | +wl_cfgp2p_find_wpsie(const u8 *parse, u32 len) |
---|
1124 | 1231 | { |
---|
1125 | | - bcm_tlv_t *ie; |
---|
| 1232 | + const bcm_tlv_t *ie; |
---|
1126 | 1233 | |
---|
1127 | | - while ((ie = bcm_parse_tlvs(parse, (u32)len, DOT11_MNG_VS_ID))) { |
---|
1128 | | - if (wl_cfgp2p_is_wps_ie((u8*)ie, &parse, &len)) { |
---|
1129 | | - return (wpa_ie_fixed_t *)ie; |
---|
| 1234 | + while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) { |
---|
| 1235 | + if (wl_cfgp2p_is_wps_ie(ie, &parse, &len)) { |
---|
| 1236 | + return (const wpa_ie_fixed_t *)ie; |
---|
1130 | 1237 | } |
---|
1131 | 1238 | } |
---|
1132 | 1239 | return NULL; |
---|
1133 | 1240 | } |
---|
1134 | 1241 | |
---|
1135 | 1242 | wifi_p2p_ie_t * |
---|
1136 | | -wl_cfgp2p_find_p2pie(u8 *parse, u32 len) |
---|
| 1243 | +wl_cfgp2p_find_p2pie(const u8 *parse, u32 len) |
---|
1137 | 1244 | { |
---|
1138 | 1245 | bcm_tlv_t *ie; |
---|
1139 | 1246 | |
---|
1140 | | - while ((ie = bcm_parse_tlvs(parse, (int)len, DOT11_MNG_VS_ID))) { |
---|
1141 | | - if (wl_cfgp2p_is_p2p_ie((uint8*)ie, &parse, &len)) { |
---|
| 1247 | + while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) { |
---|
| 1248 | + if (wl_cfgp2p_is_p2p_ie(ie, &parse, &len)) { |
---|
1142 | 1249 | return (wifi_p2p_ie_t *)ie; |
---|
1143 | 1250 | } |
---|
1144 | 1251 | } |
---|
1145 | 1252 | return NULL; |
---|
1146 | 1253 | } |
---|
1147 | 1254 | |
---|
1148 | | -wifi_wfd_ie_t * |
---|
1149 | | -wl_cfgp2p_find_wfdie(u8 *parse, u32 len) |
---|
| 1255 | +const wifi_wfd_ie_t * |
---|
| 1256 | +wl_cfgp2p_find_wfdie(const u8 *parse, u32 len) |
---|
1150 | 1257 | { |
---|
1151 | | - bcm_tlv_t *ie; |
---|
| 1258 | + const bcm_tlv_t *ie; |
---|
1152 | 1259 | |
---|
1153 | | - while ((ie = bcm_parse_tlvs(parse, (int)len, DOT11_MNG_VS_ID))) { |
---|
1154 | | - if (wl_cfgp2p_is_wfd_ie((uint8*)ie, &parse, &len)) { |
---|
1155 | | - return (wifi_wfd_ie_t *)ie; |
---|
| 1260 | + while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) { |
---|
| 1261 | + if (wl_cfgp2p_is_wfd_ie(ie, &parse, &len)) { |
---|
| 1262 | + return (const wifi_wfd_ie_t *)ie; |
---|
1156 | 1263 | } |
---|
1157 | 1264 | } |
---|
1158 | 1265 | return NULL; |
---|
1159 | 1266 | } |
---|
| 1267 | + |
---|
1160 | 1268 | u32 |
---|
1161 | 1269 | wl_cfgp2p_vndr_ie(struct bcm_cfg80211 *cfg, u8 *iebuf, s32 pktflag, |
---|
1162 | | - s8 *oui, s32 ie_id, s8 *data, s32 datalen, const s8* add_del_cmd) |
---|
| 1270 | + s8 *oui, s32 ie_id, const s8 *data, s32 datalen, const s8* add_del_cmd) |
---|
1163 | 1271 | { |
---|
1164 | 1272 | vndr_ie_setbuf_t hdr; /* aligned temporary vndr_ie buffer header */ |
---|
1165 | 1273 | s32 iecount; |
---|
.. | .. |
---|
1168 | 1276 | /* Validate the pktflag parameter */ |
---|
1169 | 1277 | if ((pktflag & ~(VNDR_IE_BEACON_FLAG | VNDR_IE_PRBRSP_FLAG | |
---|
1170 | 1278 | VNDR_IE_ASSOCRSP_FLAG | VNDR_IE_AUTHRSP_FLAG | |
---|
1171 | | - VNDR_IE_PRBREQ_FLAG | VNDR_IE_ASSOCREQ_FLAG))) { |
---|
| 1279 | + VNDR_IE_PRBREQ_FLAG | VNDR_IE_ASSOCREQ_FLAG | |
---|
| 1280 | + VNDR_IE_DISASSOC_FLAG))) { |
---|
1172 | 1281 | CFGP2P_ERR(("p2pwl_vndr_ie: Invalid packet flag 0x%x\n", pktflag)); |
---|
1173 | 1282 | return -1; |
---|
1174 | 1283 | } |
---|
1175 | 1284 | |
---|
1176 | 1285 | /* Copy the vndr_ie SET command ("add"/"del") to the buffer */ |
---|
1177 | | - strncpy(hdr.cmd, add_del_cmd, VNDR_IE_CMD_LEN - 1); |
---|
1178 | | - hdr.cmd[VNDR_IE_CMD_LEN - 1] = '\0'; |
---|
| 1286 | + strlcpy(hdr.cmd, add_del_cmd, sizeof(hdr.cmd)); |
---|
1179 | 1287 | |
---|
1180 | 1288 | /* Set the IE count - the buffer contains only 1 IE */ |
---|
1181 | 1289 | iecount = htod32(1); |
---|
1182 | 1290 | memcpy((void *)&hdr.vndr_ie_buffer.iecount, &iecount, sizeof(s32)); |
---|
| 1291 | + |
---|
| 1292 | + /* For vendor ID DOT11_MNG_ID_EXT_ID, need to set pkt flag to VNDR_IE_CUSTOM_FLAG */ |
---|
| 1293 | + if (ie_id == DOT11_MNG_ID_EXT_ID) { |
---|
| 1294 | + pktflag = pktflag | VNDR_IE_CUSTOM_FLAG; |
---|
| 1295 | + } |
---|
1183 | 1296 | |
---|
1184 | 1297 | /* Copy packet flags that indicate which packets will contain this IE */ |
---|
1185 | 1298 | pktflag = htod32(pktflag); |
---|
.. | .. |
---|
1249 | 1362 | CFGP2P_ERR((" argument is invalid\n")); |
---|
1250 | 1363 | goto exit; |
---|
1251 | 1364 | } |
---|
1252 | | - |
---|
| 1365 | + if (!cfg->p2p) { |
---|
| 1366 | + CFGP2P_ERR(("p2p if does not exist\n")); |
---|
| 1367 | + goto exit; |
---|
| 1368 | + } |
---|
1253 | 1369 | for (i = 0; i < P2PAPI_BSSCFG_MAX; i++) { |
---|
1254 | 1370 | if (bssidx == wl_to_p2p_bss_bssidx(cfg, i)) { |
---|
1255 | 1371 | *type = i; |
---|
.. | .. |
---|
1276 | 1392 | |
---|
1277 | 1393 | CFGP2P_DBG((" Enter\n")); |
---|
1278 | 1394 | #ifdef DHD_IFDEBUG |
---|
1279 | | - WL_ERR(("%s: cfg: %p, cfgdev: %p, cfg->wdev: %p, cfg->p2p_wdev: %p\n", |
---|
1280 | | - __FUNCTION__, cfg, cfgdev, cfg->wdev, cfg->p2p_wdev)); |
---|
1281 | | -#endif |
---|
| 1395 | + PRINT_WDEV_INFO(cfgdev); |
---|
| 1396 | +#endif /* DHD_IFDEBUG */ |
---|
| 1397 | + |
---|
1282 | 1398 | ndev = cfgdev_to_wlc_ndev(cfgdev, cfg); |
---|
| 1399 | + |
---|
| 1400 | +#ifdef P2P_LISTEN_OFFLOADING |
---|
| 1401 | + if (wl_get_p2p_status(cfg, DISC_IN_PROGRESS)) { |
---|
| 1402 | + wl_clr_p2p_status(cfg, DISC_IN_PROGRESS); |
---|
| 1403 | + CFGP2P_ERR(("DISC_IN_PROGRESS cleared\n")); |
---|
| 1404 | + if (ndev && (ndev->ieee80211_ptr != NULL)) { |
---|
| 1405 | +#if defined(WL_CFG80211_P2P_DEV_IF) |
---|
| 1406 | + if (cfgdev && ((struct wireless_dev *)cfgdev)->wiphy) { |
---|
| 1407 | + cfg80211_remain_on_channel_expired(cfgdev, cfg->last_roc_id, |
---|
| 1408 | + &cfg->remain_on_chan, GFP_KERNEL); |
---|
| 1409 | + } else { |
---|
| 1410 | + CFGP2P_ERR(("Invalid cfgdev. Dropping the" |
---|
| 1411 | + "remain_on_channel_expired event.\n")); |
---|
| 1412 | + } |
---|
| 1413 | +#else |
---|
| 1414 | + cfg80211_remain_on_channel_expired(cfgdev, cfg->last_roc_id, |
---|
| 1415 | + &cfg->remain_on_chan, cfg->remain_on_chan_type, GFP_KERNEL); |
---|
| 1416 | +#endif /* WL_CFG80211_P2P_DEV_IF */ |
---|
| 1417 | + } |
---|
| 1418 | + } |
---|
| 1419 | +#endif /* P2P_LISTEN_OFFLOADING */ |
---|
1283 | 1420 | |
---|
1284 | 1421 | if (wl_get_p2p_status(cfg, LISTEN_EXPIRED) == 0) { |
---|
1285 | 1422 | wl_set_p2p_status(cfg, LISTEN_EXPIRED); |
---|
.. | .. |
---|
1318 | 1455 | #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */ |
---|
1319 | 1456 | if (ndev && (ndev->ieee80211_ptr != NULL)) { |
---|
1320 | 1457 | #if defined(WL_CFG80211_P2P_DEV_IF) |
---|
1321 | | - if (cfgdev && ((struct wireless_dev *)cfgdev)->wiphy) { |
---|
| 1458 | + if (cfgdev && ((struct wireless_dev *)cfgdev)->wiphy && |
---|
| 1459 | + bcmcfg_to_p2p_wdev(cfg)) { |
---|
1322 | 1460 | /* |
---|
1323 | 1461 | * To prevent kernel panic, |
---|
1324 | 1462 | * if cfgdev->wiphy may be invalid, adding explicit check |
---|
1325 | 1463 | */ |
---|
1326 | | - cfg80211_remain_on_channel_expired(cfgdev, cfg->last_roc_id, |
---|
1327 | | - &cfg->remain_on_chan, GFP_KERNEL); |
---|
1328 | | - } else { |
---|
| 1464 | + struct wireless_dev *wdev_dpp_listen = NULL; |
---|
| 1465 | + wdev_dpp_listen = wl_get_wdev_by_dpp_listen(cfg); |
---|
| 1466 | + /* |
---|
| 1467 | + * check if dpp listen was trigerred |
---|
| 1468 | + * if so, clear dpp disten flag and route the event for listen |
---|
| 1469 | + * complete on the interface on which listen was reqeusted. |
---|
| 1470 | + */ |
---|
| 1471 | + if (wdev_dpp_listen) { |
---|
| 1472 | + wl_set_dpp_listen_by_netdev(cfg, wdev_dpp_listen->netdev, 0); |
---|
| 1473 | + cfg80211_remain_on_channel_expired(wdev_dpp_listen, |
---|
| 1474 | + cfg->last_roc_id, &cfg->remain_on_chan, GFP_KERNEL); |
---|
| 1475 | + } else { |
---|
| 1476 | + cfg80211_remain_on_channel_expired(bcmcfg_to_p2p_wdev(cfg), |
---|
| 1477 | + cfg->last_roc_id, &cfg->remain_on_chan, GFP_KERNEL); |
---|
| 1478 | + } |
---|
| 1479 | + |
---|
| 1480 | + } else |
---|
1329 | 1481 | CFGP2P_ERR(("Invalid cfgdev. Dropping the" |
---|
1330 | 1482 | "remain_on_channel_expired event.\n")); |
---|
1331 | | - } |
---|
1332 | 1483 | #else |
---|
1333 | | - cfg80211_remain_on_channel_expired(cfgdev, cfg->last_roc_id, |
---|
1334 | | - &cfg->remain_on_chan, cfg->remain_on_chan_type, GFP_KERNEL); |
---|
| 1484 | + if (cfgdev && ((struct wireless_dev *)cfgdev)->wiphy) |
---|
| 1485 | + cfg80211_remain_on_channel_expired(cfgdev, |
---|
| 1486 | + cfg->last_roc_id, &cfg->remain_on_chan, |
---|
| 1487 | + cfg->remain_on_chan_type, GFP_KERNEL); |
---|
1335 | 1488 | #endif /* WL_CFG80211_P2P_DEV_IF */ |
---|
1336 | 1489 | } |
---|
1337 | 1490 | } |
---|
.. | .. |
---|
1351 | 1504 | * We can't report cfg80211_remain_on_channel_expired from Timer ISR context, |
---|
1352 | 1505 | * so lets do it from thread context. |
---|
1353 | 1506 | */ |
---|
1354 | | - |
---|
1355 | 1507 | void |
---|
1356 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) |
---|
1357 | | -wl_cfgp2p_listen_expired(struct timer_list *t) |
---|
1358 | | -{ |
---|
1359 | | - struct p2p_info *p2p = from_timer(p2p, t, listen_timer); |
---|
1360 | | - struct bcm_cfg80211 *cfg = p2p->cfg; |
---|
1361 | | -#else |
---|
1362 | 1508 | wl_cfgp2p_listen_expired(unsigned long data) |
---|
1363 | 1509 | { |
---|
1364 | | - struct bcm_cfg80211 *cfg = (struct bcm_cfg80211 *) data; |
---|
1365 | | -#endif |
---|
1366 | 1510 | wl_event_msg_t msg; |
---|
| 1511 | + struct bcm_cfg80211 *cfg = (struct bcm_cfg80211 *) data; |
---|
| 1512 | + struct net_device *ndev; |
---|
1367 | 1513 | CFGP2P_DBG((" Enter\n")); |
---|
| 1514 | + |
---|
| 1515 | + if (!cfg) { |
---|
| 1516 | + CFGP2P_ERR((" No cfg\n")); |
---|
| 1517 | + return; |
---|
| 1518 | + } |
---|
1368 | 1519 | bzero(&msg, sizeof(wl_event_msg_t)); |
---|
1369 | 1520 | msg.event_type = hton32(WLC_E_P2P_DISC_LISTEN_COMPLETE); |
---|
1370 | 1521 | msg.bsscfgidx = wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE); |
---|
1371 | 1522 | #if defined(WL_ENABLE_P2P_IF) |
---|
1372 | | - wl_cfg80211_event(cfg->p2p_net ? cfg->p2p_net : |
---|
1373 | | - wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_DEVICE), &msg, NULL); |
---|
| 1523 | + ndev = cfg->p2p_net ? cfg->p2p_net : |
---|
| 1524 | + wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_DEVICE); |
---|
1374 | 1525 | #else |
---|
1375 | | - wl_cfg80211_event(wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_DEVICE), &msg, |
---|
1376 | | - NULL); |
---|
| 1526 | + ndev = wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_DEVICE); |
---|
1377 | 1527 | #endif /* WL_ENABLE_P2P_IF */ |
---|
| 1528 | + if (!ndev) { |
---|
| 1529 | + CFGP2P_ERR((" No ndev\n")); |
---|
| 1530 | + return; |
---|
| 1531 | + } |
---|
| 1532 | + wl_cfg80211_event(ndev, &msg, NULL); |
---|
1378 | 1533 | } |
---|
1379 | 1534 | /* |
---|
1380 | 1535 | * Routine for cancelling the P2P LISTEN |
---|
.. | .. |
---|
1391 | 1546 | del_timer_sync(&cfg->p2p->listen_timer); |
---|
1392 | 1547 | if (notify) { |
---|
1393 | 1548 | #if defined(WL_CFG80211_P2P_DEV_IF) |
---|
1394 | | - if (wdev) |
---|
| 1549 | + if (bcmcfg_to_p2p_wdev(cfg)) |
---|
1395 | 1550 | cfg80211_remain_on_channel_expired(wdev, cfg->last_roc_id, |
---|
1396 | 1551 | &cfg->remain_on_chan, GFP_KERNEL); |
---|
1397 | 1552 | #else |
---|
.. | .. |
---|
1419 | 1574 | { |
---|
1420 | 1575 | #define EXTRA_DELAY_TIME 100 |
---|
1421 | 1576 | s32 ret = BCME_OK; |
---|
1422 | | - struct timer_list *_timer; |
---|
| 1577 | + timer_list_compat_t *_timer; |
---|
1423 | 1578 | s32 extra_delay; |
---|
1424 | 1579 | struct net_device *netdev = bcmcfg_to_prmry_ndev(cfg); |
---|
1425 | 1580 | |
---|
.. | .. |
---|
1469 | 1624 | return ret; |
---|
1470 | 1625 | } |
---|
1471 | 1626 | |
---|
1472 | | - |
---|
1473 | 1627 | s32 |
---|
1474 | 1628 | wl_cfgp2p_discover_enable_search(struct bcm_cfg80211 *cfg, u8 enable) |
---|
1475 | 1629 | { |
---|
.. | .. |
---|
1509 | 1663 | u32 event_type = ntoh32(e->event_type); |
---|
1510 | 1664 | u32 status = ntoh32(e->status); |
---|
1511 | 1665 | struct net_device *ndev = NULL; |
---|
| 1666 | + u8 bsscfgidx = e->bsscfgidx; |
---|
| 1667 | + |
---|
1512 | 1668 | CFGP2P_DBG((" Enter\n")); |
---|
1513 | 1669 | |
---|
1514 | 1670 | ndev = cfgdev_to_wlc_ndev(cfgdev, cfg); |
---|
.. | .. |
---|
1516 | 1672 | if (wl_get_drv_status_all(cfg, SENDING_ACT_FRM)) { |
---|
1517 | 1673 | if (event_type == WLC_E_ACTION_FRAME_COMPLETE) { |
---|
1518 | 1674 | |
---|
1519 | | - CFGP2P_INFO((" WLC_E_ACTION_FRAME_COMPLETE is received : %d\n", status)); |
---|
| 1675 | + CFGP2P_DBG((" WLC_E_ACTION_FRAME_COMPLETE is received : %d\n", status)); |
---|
1520 | 1676 | if (status == WLC_E_STATUS_SUCCESS) { |
---|
1521 | 1677 | wl_set_p2p_status(cfg, ACTION_TX_COMPLETED); |
---|
1522 | | - CFGP2P_DBG(("WLC_E_ACTION_FRAME_COMPLETE : ACK\n")); |
---|
| 1678 | + CFGP2P_ACTION(("TX actfrm : ACK\n")); |
---|
1523 | 1679 | if (!cfg->need_wait_afrx && cfg->af_sent_channel) { |
---|
1524 | 1680 | CFGP2P_DBG(("no need to wait next AF.\n")); |
---|
1525 | | - wl_stop_wait_next_action_frame(cfg, ndev); |
---|
| 1681 | + wl_stop_wait_next_action_frame(cfg, ndev, bsscfgidx); |
---|
1526 | 1682 | } |
---|
1527 | 1683 | } |
---|
1528 | 1684 | else if (!wl_get_p2p_status(cfg, ACTION_TX_COMPLETED)) { |
---|
1529 | 1685 | wl_set_p2p_status(cfg, ACTION_TX_NOACK); |
---|
1530 | | - CFGP2P_INFO(("WLC_E_ACTION_FRAME_COMPLETE : NO ACK\n")); |
---|
1531 | | - wl_stop_wait_next_action_frame(cfg, ndev); |
---|
| 1686 | + if (status == WLC_E_STATUS_SUPPRESS) { |
---|
| 1687 | + CFGP2P_ACTION(("TX actfrm : SUPPRES\n")); |
---|
| 1688 | + } else { |
---|
| 1689 | + CFGP2P_ACTION(("TX actfrm : NO ACK\n")); |
---|
| 1690 | + } |
---|
| 1691 | + wl_stop_wait_next_action_frame(cfg, ndev, bsscfgidx); |
---|
1532 | 1692 | } |
---|
1533 | 1693 | } else { |
---|
1534 | | - CFGP2P_INFO((" WLC_E_ACTION_FRAME_OFFCHAN_COMPLETE is received," |
---|
| 1694 | + CFGP2P_DBG((" WLC_E_ACTION_FRAME_OFFCHAN_COMPLETE is received," |
---|
1535 | 1695 | "status : %d\n", status)); |
---|
1536 | 1696 | |
---|
1537 | 1697 | if (wl_get_drv_status_all(cfg, SENDING_ACT_FRM)) |
---|
.. | .. |
---|
1557 | 1717 | s32 timeout = 0; |
---|
1558 | 1718 | wl_eventmsg_buf_t buf; |
---|
1559 | 1719 | |
---|
1560 | | - |
---|
1561 | | - CFGP2P_INFO(("\n")); |
---|
1562 | | - CFGP2P_INFO(("channel : %u , dwell time : %u\n", |
---|
| 1720 | + CFGP2P_DBG(("\n")); |
---|
| 1721 | + CFGP2P_DBG(("channel : %u , dwell time : %u\n", |
---|
1563 | 1722 | af_params->channel, af_params->dwell_time)); |
---|
1564 | 1723 | |
---|
1565 | 1724 | wl_clr_p2p_status(cfg, ACTION_TX_COMPLETED); |
---|
.. | .. |
---|
1580 | 1739 | cfg->ioctl_buf, WLC_IOCTL_MAXLEN, bssidx, &cfg->ioctl_buf_sync); |
---|
1581 | 1740 | |
---|
1582 | 1741 | if (ret < 0) { |
---|
1583 | | - CFGP2P_ERR((" sending action frame is failed\n")); |
---|
| 1742 | + CFGP2P_ACTION(("TX actfrm : ERROR\n")); |
---|
1584 | 1743 | goto exit; |
---|
1585 | 1744 | } |
---|
1586 | 1745 | |
---|
.. | .. |
---|
1588 | 1747 | msecs_to_jiffies(af_params->dwell_time + WL_AF_TX_EXTRA_TIME_MAX)); |
---|
1589 | 1748 | |
---|
1590 | 1749 | if (timeout >= 0 && wl_get_p2p_status(cfg, ACTION_TX_COMPLETED)) { |
---|
1591 | | - CFGP2P_INFO(("tx action frame operation is completed\n")); |
---|
| 1750 | + CFGP2P_DBG(("tx action frame operation is completed\n")); |
---|
1592 | 1751 | ret = BCME_OK; |
---|
1593 | 1752 | } else if (ETHER_ISBCAST(&cfg->afx_hdl->tx_dst_addr)) { |
---|
1594 | | - CFGP2P_INFO(("bcast tx action frame operation is completed\n")); |
---|
| 1753 | + CFGP2P_DBG(("bcast tx action frame operation is completed\n")); |
---|
1595 | 1754 | ret = BCME_OK; |
---|
1596 | 1755 | } else { |
---|
1597 | 1756 | ret = BCME_ERROR; |
---|
1598 | | - CFGP2P_INFO(("tx action frame operation is failed\n")); |
---|
| 1757 | + CFGP2P_DBG(("tx action frame operation is failed\n")); |
---|
1599 | 1758 | } |
---|
1600 | 1759 | /* clear status bit for action tx */ |
---|
1601 | 1760 | wl_clr_p2p_status(cfg, ACTION_TX_COMPLETED); |
---|
1602 | 1761 | wl_clr_p2p_status(cfg, ACTION_TX_NOACK); |
---|
1603 | 1762 | |
---|
1604 | 1763 | exit: |
---|
1605 | | - CFGP2P_INFO((" via act frame iovar : status = %d\n", ret)); |
---|
| 1764 | + CFGP2P_DBG((" via act frame iovar : status = %d\n", ret)); |
---|
1606 | 1765 | |
---|
1607 | 1766 | bzero(&buf, sizeof(wl_eventmsg_buf_t)); |
---|
1608 | 1767 | wl_cfg80211_add_to_eventbuffer(&buf, WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE, false); |
---|
.. | .. |
---|
1688 | 1847 | subel += subelt_len; |
---|
1689 | 1848 | } |
---|
1690 | 1849 | } |
---|
1691 | | -/* |
---|
1692 | | - * Check if a BSS is up. |
---|
1693 | | - * This is a common implementation called by most OSL implementations of |
---|
1694 | | - * p2posl_bss_isup(). DO NOT call this function directly from the |
---|
1695 | | - * common code -- call p2posl_bss_isup() instead to allow the OSL to |
---|
1696 | | - * override the common implementation if necessary. |
---|
1697 | | - */ |
---|
1698 | | -bool |
---|
1699 | | -wl_cfgp2p_bss_isup(struct net_device *ndev, int bsscfg_idx) |
---|
1700 | | -{ |
---|
1701 | | - s32 result, val; |
---|
1702 | | - bool isup = false; |
---|
1703 | | - s8 getbuf[64]; |
---|
1704 | 1850 | |
---|
1705 | | - /* Check if the BSS is up */ |
---|
1706 | | - *(int*)getbuf = -1; |
---|
1707 | | - result = wldev_iovar_getbuf_bsscfg(ndev, "bss", &bsscfg_idx, |
---|
1708 | | - sizeof(bsscfg_idx), getbuf, sizeof(getbuf), 0, NULL); |
---|
1709 | | - if (result != 0) { |
---|
1710 | | - CFGP2P_ERR(("'cfg bss -C %d' failed: %d\n", bsscfg_idx, result)); |
---|
1711 | | - CFGP2P_ERR(("NOTE: this ioctl error is normal " |
---|
1712 | | - "when the BSS has not been created yet.\n")); |
---|
1713 | | - } else { |
---|
1714 | | - val = *(int*)getbuf; |
---|
1715 | | - val = dtoh32(val); |
---|
1716 | | - CFGP2P_INFO(("---cfg bss -C %d ==> %d\n", bsscfg_idx, val)); |
---|
1717 | | - isup = (val ? TRUE : FALSE); |
---|
1718 | | - } |
---|
1719 | | - return isup; |
---|
1720 | | -} |
---|
1721 | | - |
---|
1722 | | - |
---|
1723 | | -/* Bring up or down a BSS */ |
---|
1724 | | -s32 |
---|
1725 | | -wl_cfgp2p_bss(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 bsscfg_idx, s32 is_up) |
---|
1726 | | -{ |
---|
1727 | | - s32 ret = BCME_OK; |
---|
1728 | | - s32 val = is_up ? 1 : 0; |
---|
1729 | | - |
---|
1730 | | - struct { |
---|
1731 | | - s32 cfg; |
---|
1732 | | - s32 val; |
---|
1733 | | - } bss_setbuf; |
---|
1734 | | - |
---|
1735 | | - bss_setbuf.cfg = htod32(bsscfg_idx); |
---|
1736 | | - bss_setbuf.val = htod32(val); |
---|
1737 | | - CFGP2P_INFO(("---cfg bss -C %d %s\n", bsscfg_idx, is_up ? "up" : "down")); |
---|
1738 | | - ret = wldev_iovar_setbuf(ndev, "bss", &bss_setbuf, sizeof(bss_setbuf), |
---|
1739 | | - cfg->ioctl_buf, WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
1740 | | - |
---|
1741 | | - if (ret != 0) { |
---|
1742 | | - CFGP2P_ERR(("'bss %d' failed with %d\n", is_up, ret)); |
---|
1743 | | - } |
---|
1744 | | - |
---|
1745 | | - return ret; |
---|
1746 | | -} |
---|
1747 | | - |
---|
1748 | | -/* Check if 'p2p' is supported in the driver */ |
---|
1749 | 1851 | s32 |
---|
1750 | 1852 | wl_cfgp2p_supported(struct bcm_cfg80211 *cfg, struct net_device *ndev) |
---|
1751 | 1853 | { |
---|
.. | .. |
---|
1776 | 1878 | { |
---|
1777 | 1879 | struct net_device *ndev = NULL; |
---|
1778 | 1880 | struct wireless_dev *wdev = NULL; |
---|
1779 | | - s32 i = 0, index = -1; |
---|
1780 | 1881 | |
---|
1781 | 1882 | #if defined(WL_CFG80211_P2P_DEV_IF) |
---|
1782 | 1883 | ndev = bcmcfg_to_prmry_ndev(cfg); |
---|
.. | .. |
---|
1788 | 1889 | |
---|
1789 | 1890 | wl_cfgp2p_cancel_listen(cfg, ndev, wdev, TRUE); |
---|
1790 | 1891 | wl_cfgp2p_disable_discovery(cfg); |
---|
1791 | | -#if defined(WL_CFG80211_P2P_DEV_IF) |
---|
| 1892 | + |
---|
| 1893 | +#if defined(WL_CFG80211_P2P_DEV_IF) && !defined(KEEP_WIFION_OPTION) |
---|
| 1894 | +/* |
---|
| 1895 | + * In CUSTOMER_HW4 implementation "ifconfig wlan0 down" can get |
---|
| 1896 | + * called during phone suspend and customer requires the p2p |
---|
| 1897 | + * discovery interface to be left untouched so that the user |
---|
| 1898 | + * space can resume without any problem. |
---|
| 1899 | + */ |
---|
1792 | 1900 | if (cfg->p2p_wdev) { |
---|
1793 | 1901 | /* If p2p wdev is left out, clean it up */ |
---|
1794 | 1902 | WL_ERR(("Clean up the p2p discovery IF\n")); |
---|
1795 | 1903 | wl_cfgp2p_del_p2p_disc_if(cfg->p2p_wdev, cfg); |
---|
1796 | 1904 | } |
---|
1797 | | -#endif /* WL_CFG80211_P2P_DEV_IF */ |
---|
1798 | | - for (i = 0; i < P2PAPI_BSSCFG_MAX; i++) { |
---|
1799 | | - index = wl_to_p2p_bss_bssidx(cfg, i); |
---|
1800 | | - if (index != WL_INVALID) |
---|
1801 | | - wl_cfg80211_clear_per_bss_ies(cfg, index); |
---|
1802 | | - } |
---|
| 1905 | +#endif /* WL_CFG80211_P2P_DEV_IF !defined(KEEP_WIFION_OPTION) */ |
---|
| 1906 | + |
---|
1803 | 1907 | wl_cfgp2p_deinit_priv(cfg); |
---|
1804 | 1908 | return 0; |
---|
1805 | 1909 | } |
---|
.. | .. |
---|
1821 | 1925 | int count, start, duration; |
---|
1822 | 1926 | wl_p2p_sched_t dongle_noa; |
---|
1823 | 1927 | s32 bssidx, type; |
---|
| 1928 | + int iovar_len = sizeof(dongle_noa); |
---|
1824 | 1929 | CFGP2P_DBG((" Enter\n")); |
---|
1825 | 1930 | |
---|
1826 | | - memset(&dongle_noa, 0, sizeof(dongle_noa)); |
---|
| 1931 | + bzero(&dongle_noa, sizeof(dongle_noa)); |
---|
1827 | 1932 | |
---|
1828 | 1933 | if (wl_cfgp2p_vif_created(cfg)) { |
---|
1829 | 1934 | cfg->p2p->noa.desc[0].start = 0; |
---|
.. | .. |
---|
1882 | 1987 | if (wl_cfgp2p_find_type(cfg, bssidx, &type) != BCME_OK) |
---|
1883 | 1988 | return BCME_ERROR; |
---|
1884 | 1989 | |
---|
| 1990 | + if (dongle_noa.action == WL_P2P_SCHED_ACTION_RESET) { |
---|
| 1991 | + iovar_len -= sizeof(wl_p2p_sched_desc_t); |
---|
| 1992 | + } |
---|
| 1993 | + |
---|
1885 | 1994 | ret = wldev_iovar_setbuf(wl_to_p2p_bss_ndev(cfg, type), |
---|
1886 | | - "p2p_noa", &dongle_noa, sizeof(dongle_noa), cfg->ioctl_buf, |
---|
| 1995 | + "p2p_noa", &dongle_noa, iovar_len, cfg->ioctl_buf, |
---|
1887 | 1996 | WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
1888 | 1997 | |
---|
1889 | 1998 | if (ret < 0) { |
---|
.. | .. |
---|
1972 | 2081 | } |
---|
1973 | 2082 | |
---|
1974 | 2083 | if ((legacy_ps != -1) && ((legacy_ps == PM_MAX) || (legacy_ps == PM_OFF))) { |
---|
1975 | | - ret = wldev_ioctl(dev, |
---|
1976 | | - WLC_SET_PM, &legacy_ps, sizeof(legacy_ps), true); |
---|
| 2084 | + ret = wldev_ioctl_set(dev, |
---|
| 2085 | + WLC_SET_PM, &legacy_ps, sizeof(legacy_ps)); |
---|
1977 | 2086 | if (unlikely(ret)) |
---|
1978 | 2087 | CFGP2P_ERR(("error (%d)\n", ret)); |
---|
1979 | 2088 | wl_cfg80211_update_power_mode(dev); |
---|
.. | .. |
---|
2015 | 2124 | return BCME_ERROR; |
---|
2016 | 2125 | } |
---|
2017 | 2126 | |
---|
| 2127 | + memset_s(&csa_arg, sizeof(csa_arg), 0, sizeof(csa_arg)); |
---|
2018 | 2128 | csa_arg.mode = DOT11_CSA_MODE_ADVISORY; |
---|
2019 | 2129 | csa_arg.count = P2P_ECSA_CNT; |
---|
2020 | 2130 | csa_arg.reg = 0; |
---|
2021 | 2131 | |
---|
2022 | | - sprintf(buf, "%d/%d", ch, bw); |
---|
| 2132 | + snprintf(buf, len, "%d/%d", ch, bw); |
---|
2023 | 2133 | chnsp = wf_chspec_aton(buf); |
---|
2024 | 2134 | if (chnsp == 0) { |
---|
2025 | 2135 | CFGP2P_ERR(("%s:chsp is not correct\n", __FUNCTION__)); |
---|
.. | .. |
---|
2041 | 2151 | return BCME_OK; |
---|
2042 | 2152 | } |
---|
2043 | 2153 | |
---|
2044 | | -u8 * |
---|
2045 | | -wl_cfgp2p_retreive_p2pattrib(void *buf, u8 element_id) |
---|
| 2154 | +s32 |
---|
| 2155 | +wl_cfgp2p_increase_p2p_bw(struct bcm_cfg80211 *cfg, struct net_device *ndev, char* buf, int len) |
---|
2046 | 2156 | { |
---|
2047 | | - wifi_p2p_ie_t *ie = NULL; |
---|
| 2157 | + int algo; |
---|
| 2158 | + int bw; |
---|
| 2159 | + int ret = BCME_OK; |
---|
| 2160 | + |
---|
| 2161 | + sscanf(buf, "%3d", &bw); |
---|
| 2162 | + if (bw == 0) { |
---|
| 2163 | + algo = 0; |
---|
| 2164 | + ret = wldev_iovar_setbuf(ndev, "mchan_algo", &algo, sizeof(algo), cfg->ioctl_buf, |
---|
| 2165 | + WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
| 2166 | + if (ret < 0) { |
---|
| 2167 | + CFGP2P_ERR(("fw set mchan_algo failed %d\n", ret)); |
---|
| 2168 | + return BCME_ERROR; |
---|
| 2169 | + } |
---|
| 2170 | + } else { |
---|
| 2171 | + algo = 1; |
---|
| 2172 | + ret = wldev_iovar_setbuf(ndev, "mchan_algo", &algo, sizeof(algo), cfg->ioctl_buf, |
---|
| 2173 | + WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
| 2174 | + if (ret < 0) { |
---|
| 2175 | + CFGP2P_ERR(("fw set mchan_algo failed %d\n", ret)); |
---|
| 2176 | + return BCME_ERROR; |
---|
| 2177 | + } |
---|
| 2178 | + ret = wldev_iovar_setbuf(ndev, "mchan_bw", &bw, sizeof(algo), cfg->ioctl_buf, |
---|
| 2179 | + WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); |
---|
| 2180 | + if (ret < 0) { |
---|
| 2181 | + CFGP2P_ERR(("fw set mchan_bw failed %d\n", ret)); |
---|
| 2182 | + return BCME_ERROR; |
---|
| 2183 | + } |
---|
| 2184 | + } |
---|
| 2185 | + return BCME_OK; |
---|
| 2186 | +} |
---|
| 2187 | + |
---|
| 2188 | +const u8 * |
---|
| 2189 | +wl_cfgp2p_retreive_p2pattrib(const void *buf, u8 element_id) |
---|
| 2190 | +{ |
---|
| 2191 | + const wifi_p2p_ie_t *ie = NULL; |
---|
2048 | 2192 | u16 len = 0; |
---|
2049 | | - u8 *subel; |
---|
| 2193 | + const u8 *subel; |
---|
2050 | 2194 | u8 subelt_id; |
---|
2051 | 2195 | u16 subelt_len; |
---|
2052 | 2196 | |
---|
.. | .. |
---|
2055 | 2199 | return 0; |
---|
2056 | 2200 | } |
---|
2057 | 2201 | |
---|
2058 | | - ie = (wifi_p2p_ie_t*) buf; |
---|
| 2202 | + ie = (const wifi_p2p_ie_t*) buf; |
---|
2059 | 2203 | len = ie->len; |
---|
2060 | 2204 | |
---|
2061 | 2205 | /* Point subel to the P2P IE's subelt field. |
---|
.. | .. |
---|
2094 | 2238 | |
---|
2095 | 2239 | #define P2P_GROUP_CAPAB_GO_BIT 0x01 |
---|
2096 | 2240 | |
---|
2097 | | -u8* |
---|
2098 | | -wl_cfgp2p_find_attrib_in_all_p2p_Ies(u8 *parse, u32 len, u32 attrib) |
---|
| 2241 | +const u8* |
---|
| 2242 | +wl_cfgp2p_find_attrib_in_all_p2p_Ies(const u8 *parse, u32 len, u32 attrib) |
---|
2099 | 2243 | { |
---|
2100 | 2244 | bcm_tlv_t *ie; |
---|
2101 | | - u8* pAttrib; |
---|
| 2245 | + const u8* pAttrib; |
---|
| 2246 | + uint ie_len; |
---|
2102 | 2247 | |
---|
2103 | | - CFGP2P_INFO(("Starting parsing parse %p attrib %d remaining len %d ", parse, attrib, len)); |
---|
2104 | | - while ((ie = bcm_parse_tlvs(parse, (int)len, DOT11_MNG_VS_ID))) { |
---|
2105 | | - if (wl_cfgp2p_is_p2p_ie((uint8*)ie, &parse, &len) == TRUE) { |
---|
| 2248 | + CFGP2P_DBG(("Starting parsing parse %p attrib %d remaining len %d ", parse, attrib, len)); |
---|
| 2249 | + ie_len = len; |
---|
| 2250 | + while ((ie = bcm_parse_tlvs(parse, ie_len, DOT11_MNG_VS_ID))) { |
---|
| 2251 | + if (wl_cfgp2p_is_p2p_ie(ie, &parse, &ie_len) == TRUE) { |
---|
2106 | 2252 | /* Have the P2p ie. Now check for attribute */ |
---|
2107 | | - if ((pAttrib = wl_cfgp2p_retreive_p2pattrib(parse, attrib)) != NULL) { |
---|
2108 | | - CFGP2P_INFO(("P2P attribute %d was found at parse %p", |
---|
| 2253 | + if ((pAttrib = wl_cfgp2p_retreive_p2pattrib(ie, attrib)) != NULL) { |
---|
| 2254 | + CFGP2P_DBG(("P2P attribute %d was found at parse %p", |
---|
2109 | 2255 | attrib, parse)); |
---|
2110 | 2256 | return pAttrib; |
---|
2111 | 2257 | } |
---|
2112 | 2258 | else { |
---|
2113 | | - parse += (ie->len + TLV_HDR_LEN); |
---|
2114 | | - len -= (ie->len + TLV_HDR_LEN); |
---|
| 2259 | + /* move to next IE */ |
---|
| 2260 | + bcm_tlv_buffer_advance_past(ie, &parse, &ie_len); |
---|
| 2261 | + |
---|
2115 | 2262 | CFGP2P_INFO(("P2P Attribute %d not found Moving parse" |
---|
2116 | | - " to %p len to %d", attrib, parse, len)); |
---|
| 2263 | + " to %p len to %d", attrib, parse, ie_len)); |
---|
2117 | 2264 | } |
---|
2118 | 2265 | } |
---|
2119 | 2266 | else { |
---|
2120 | 2267 | /* It was not p2p IE. parse will get updated automatically to next TLV */ |
---|
2121 | | - CFGP2P_INFO(("IT was NOT P2P IE parse %p len %d", parse, len)); |
---|
| 2268 | + CFGP2P_INFO(("IT was NOT P2P IE parse %p len %d", parse, ie_len)); |
---|
2122 | 2269 | } |
---|
2123 | 2270 | } |
---|
2124 | 2271 | CFGP2P_ERR(("P2P attribute %d was NOT found", attrib)); |
---|
2125 | 2272 | return NULL; |
---|
2126 | 2273 | } |
---|
2127 | 2274 | |
---|
2128 | | -u8 * |
---|
| 2275 | +const u8 * |
---|
2129 | 2276 | wl_cfgp2p_retreive_p2p_dev_addr(wl_bss_info_t *bi, u32 bi_length) |
---|
2130 | 2277 | { |
---|
2131 | | - u8 *capability = NULL; |
---|
| 2278 | + const u8 *capability = NULL; |
---|
2132 | 2279 | bool p2p_go = 0; |
---|
2133 | | - u8 *ptr = NULL; |
---|
| 2280 | + const u8 *ptr = NULL; |
---|
| 2281 | + |
---|
| 2282 | + if (bi->length != bi->ie_offset + bi->ie_length) { |
---|
| 2283 | + return NULL; |
---|
| 2284 | + } |
---|
2134 | 2285 | |
---|
2135 | 2286 | if ((capability = wl_cfgp2p_find_attrib_in_all_p2p_Ies(((u8 *) bi) + bi->ie_offset, |
---|
2136 | 2287 | bi->ie_length, P2P_SEID_P2P_INFO)) == NULL) { |
---|
.. | .. |
---|
2173 | 2324 | }; |
---|
2174 | 2325 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) */ |
---|
2175 | 2326 | |
---|
2176 | | -#if defined(WL_ENABLE_P2P_IF) |
---|
| 2327 | +#if defined(WL_ENABLE_P2P_IF) || defined(WL_NEWCFG_PRIVCMD_SUPPORT) |
---|
2177 | 2328 | s32 |
---|
2178 | 2329 | wl_cfgp2p_register_ndev(struct bcm_cfg80211 *cfg) |
---|
2179 | 2330 | { |
---|
2180 | 2331 | int ret = 0; |
---|
2181 | 2332 | struct net_device* net = NULL; |
---|
| 2333 | +#ifndef WL_NEWCFG_PRIVCMD_SUPPORT |
---|
2182 | 2334 | struct wireless_dev *wdev = NULL; |
---|
| 2335 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2183 | 2336 | uint8 temp_addr[ETHER_ADDR_LEN] = { 0x00, 0x90, 0x4c, 0x33, 0x22, 0x11 }; |
---|
2184 | 2337 | |
---|
2185 | 2338 | if (cfg->p2p_net) { |
---|
.. | .. |
---|
2193 | 2346 | return -ENODEV; |
---|
2194 | 2347 | } |
---|
2195 | 2348 | |
---|
2196 | | - wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); |
---|
| 2349 | +#ifndef WL_NEWCFG_PRIVCMD_SUPPORT |
---|
| 2350 | + wdev = (struct wireless_dev *)MALLOCZ(cfg->osh, sizeof(*wdev)); |
---|
2197 | 2351 | if (unlikely(!wdev)) { |
---|
2198 | 2352 | WL_ERR(("Could not allocate wireless device\n")); |
---|
2199 | 2353 | free_netdev(net); |
---|
2200 | 2354 | return -ENOMEM; |
---|
2201 | 2355 | } |
---|
| 2356 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2202 | 2357 | |
---|
2203 | | - strncpy(net->name, "p2p%d", sizeof(net->name) - 1); |
---|
2204 | | - net->name[IFNAMSIZ - 1] = '\0'; |
---|
| 2358 | + strlcpy(net->name, "p2p%d", sizeof(net->name)); |
---|
2205 | 2359 | |
---|
2206 | 2360 | /* Copy the reference to bcm_cfg80211 */ |
---|
2207 | 2361 | memcpy((void *)netdev_priv(net), &cfg, sizeof(struct bcm_cfg80211 *)); |
---|
.. | .. |
---|
2215 | 2369 | #else |
---|
2216 | 2370 | ASSERT(!net->netdev_ops); |
---|
2217 | 2371 | net->netdev_ops = &wl_cfgp2p_if_ops; |
---|
2218 | | -#endif |
---|
| 2372 | +#endif // endif |
---|
2219 | 2373 | |
---|
2220 | 2374 | /* Register with a dummy MAC addr */ |
---|
2221 | 2375 | memcpy(net->dev_addr, temp_addr, ETHER_ADDR_LEN); |
---|
2222 | 2376 | |
---|
| 2377 | +#ifndef WL_NEWCFG_PRIVCMD_SUPPORT |
---|
2223 | 2378 | wdev->wiphy = cfg->wdev->wiphy; |
---|
2224 | 2379 | |
---|
2225 | 2380 | wdev->iftype = wl_mode_to_nl80211_iftype(WL_MODE_BSS); |
---|
2226 | 2381 | |
---|
2227 | 2382 | net->ieee80211_ptr = wdev; |
---|
| 2383 | +#else |
---|
| 2384 | + net->ieee80211_ptr = NULL; |
---|
| 2385 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2228 | 2386 | |
---|
2229 | 2387 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
---|
2230 | 2388 | net->ethtool_ops = &cfgp2p_ethtool_ops; |
---|
2231 | 2389 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) */ |
---|
2232 | 2390 | |
---|
| 2391 | +#ifndef WL_NEWCFG_PRIVCMD_SUPPORT |
---|
2233 | 2392 | SET_NETDEV_DEV(net, wiphy_dev(wdev->wiphy)); |
---|
2234 | 2393 | |
---|
2235 | 2394 | /* Associate p2p0 network interface with new wdev */ |
---|
2236 | 2395 | wdev->netdev = net; |
---|
| 2396 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2237 | 2397 | |
---|
2238 | 2398 | ret = register_netdev(net); |
---|
2239 | 2399 | if (ret) { |
---|
2240 | 2400 | CFGP2P_ERR((" register_netdevice failed (%d)\n", ret)); |
---|
2241 | 2401 | free_netdev(net); |
---|
2242 | | - kfree(wdev); |
---|
| 2402 | +#ifndef WL_NEWCFG_PRIVCMD_SUPPORT |
---|
| 2403 | + MFREE(cfg->osh, wdev, sizeof(*wdev)); |
---|
| 2404 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2243 | 2405 | return -ENODEV; |
---|
2244 | 2406 | } |
---|
2245 | 2407 | |
---|
2246 | 2408 | /* store p2p net ptr for further reference. Note that iflist won't have this |
---|
2247 | 2409 | * entry as there corresponding firmware interface is a "Hidden" interface. |
---|
2248 | 2410 | */ |
---|
| 2411 | +#ifndef WL_NEWCFG_PRIVCMD_SUPPORT |
---|
2249 | 2412 | cfg->p2p_wdev = wdev; |
---|
| 2413 | +#else |
---|
| 2414 | + cfg->p2p_wdev = NULL; |
---|
| 2415 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2250 | 2416 | cfg->p2p_net = net; |
---|
2251 | 2417 | |
---|
2252 | 2418 | printk("%s: P2P Interface Registered\n", net->name); |
---|
.. | .. |
---|
2292 | 2458 | * For Android PRIV CMD handling map it to primary I/F |
---|
2293 | 2459 | */ |
---|
2294 | 2460 | if (cmd == SIOCDEVPRIVATE+1) { |
---|
2295 | | - ret = wl_android_priv_cmd(ndev, ifr, cmd); |
---|
| 2461 | +#if defined(OEM_ANDROID) |
---|
| 2462 | + ret = wl_android_priv_cmd(ndev, ifr); |
---|
| 2463 | +#else |
---|
| 2464 | + (void)ndev; |
---|
| 2465 | +#endif // endif |
---|
2296 | 2466 | |
---|
2297 | 2467 | } else { |
---|
2298 | 2468 | CFGP2P_ERR(("%s: IOCTL req 0x%x on p2p0 I/F. Ignoring. \n", |
---|
.. | .. |
---|
2302 | 2472 | |
---|
2303 | 2473 | return ret; |
---|
2304 | 2474 | } |
---|
2305 | | -#endif |
---|
| 2475 | +#endif /* WL_ENABLE_P2P_IF || WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2306 | 2476 | |
---|
2307 | 2477 | #if defined(WL_ENABLE_P2P_IF) |
---|
2308 | 2478 | static int wl_cfgp2p_if_open(struct net_device *net) |
---|
2309 | 2479 | { |
---|
2310 | 2480 | struct wireless_dev *wdev = net->ieee80211_ptr; |
---|
2311 | 2481 | |
---|
2312 | | - if (!wdev || !wl_cfg80211_is_p2p_active()) |
---|
| 2482 | + if (!wdev || !wl_cfg80211_is_p2p_active(net)) |
---|
2313 | 2483 | return -EINVAL; |
---|
2314 | 2484 | WL_TRACE(("Enter\n")); |
---|
2315 | 2485 | #if !defined(WL_IFACE_COMB_NUM_CHANNELS) |
---|
.. | .. |
---|
2330 | 2500 | static int wl_cfgp2p_if_stop(struct net_device *net) |
---|
2331 | 2501 | { |
---|
2332 | 2502 | struct wireless_dev *wdev = net->ieee80211_ptr; |
---|
| 2503 | + struct bcm_cfg80211 *cfg = wl_get_cfg(net); |
---|
2333 | 2504 | |
---|
2334 | 2505 | if (!wdev) |
---|
2335 | 2506 | return -EINVAL; |
---|
2336 | 2507 | |
---|
2337 | | - wl_cfg80211_scan_stop(net); |
---|
| 2508 | + wl_cfg80211_scan_stop(cfg, net); |
---|
2338 | 2509 | |
---|
2339 | 2510 | #if !defined(WL_IFACE_COMB_NUM_CHANNELS) |
---|
2340 | 2511 | wdev->wiphy->interface_modes = (wdev->wiphy->interface_modes) |
---|
.. | .. |
---|
2363 | 2534 | WL_TRACE(("Enter\n")); |
---|
2364 | 2535 | |
---|
2365 | 2536 | if (cfg->p2p_wdev) { |
---|
2366 | | - /* |
---|
2367 | | - * This is not expected. This can happen due to |
---|
2368 | | - * supplicant crash/unclean de-initialization which |
---|
2369 | | - * didn't free the p2p discovery interface. Indicate |
---|
2370 | | - * driver hang to user space so that the framework |
---|
2371 | | - * can rei-init the Wi-Fi. |
---|
2372 | | - */ |
---|
| 2537 | +#ifndef EXPLICIT_DISCIF_CLEANUP |
---|
| 2538 | + dhd_pub_t *dhd = (dhd_pub_t *)(cfg->pub); |
---|
| 2539 | +#endif /* EXPLICIT_DISCIF_CLEANUP */ |
---|
| 2540 | + /* |
---|
| 2541 | + * This is not expected. This can happen due to |
---|
| 2542 | + * supplicant crash/unclean de-initialization which |
---|
| 2543 | + * didn't free the p2p discovery interface. Indicate |
---|
| 2544 | + * driver hang to user space so that the framework |
---|
| 2545 | + * can rei-init the Wi-Fi. |
---|
| 2546 | + */ |
---|
2373 | 2547 | CFGP2P_ERR(("p2p_wdev defined already.\n")); |
---|
2374 | 2548 | wl_probe_wdev_all(cfg); |
---|
2375 | | - |
---|
| 2549 | +#ifdef EXPLICIT_DISCIF_CLEANUP |
---|
| 2550 | + /* |
---|
| 2551 | + * CUSTOMER_HW4 design doesn't delete the p2p discovery |
---|
| 2552 | + * interface on ifconfig wlan0 down context which comes |
---|
| 2553 | + * without a preceeding NL80211_CMD_DEL_INTERFACE for p2p |
---|
| 2554 | + * discovery. But during supplicant crash the DEL_IFACE |
---|
| 2555 | + * command will not happen and will cause a left over iface |
---|
| 2556 | + * even after ifconfig wlan0 down. So delete the iface |
---|
| 2557 | + * first and then indicate the HANG event |
---|
| 2558 | + */ |
---|
| 2559 | + wl_cfgp2p_del_p2p_disc_if(cfg->p2p_wdev, cfg); |
---|
| 2560 | +#else |
---|
| 2561 | + dhd->hang_reason = HANG_REASON_IFACE_DEL_FAILURE; |
---|
| 2562 | +#ifdef OEM_ANDROID |
---|
| 2563 | +#if defined(BCMPCIE) && defined(DHD_FW_COREDUMP) |
---|
| 2564 | + if (dhd->memdump_enabled) { |
---|
| 2565 | + /* Load the dongle side dump to host |
---|
| 2566 | + * memory and then BUG_ON() |
---|
| 2567 | + */ |
---|
| 2568 | + dhd->memdump_type = DUMP_TYPE_IFACE_OP_FAILURE; |
---|
| 2569 | + dhd_bus_mem_dump(dhd); |
---|
| 2570 | + } |
---|
| 2571 | +#endif /* BCMPCIE && DHD_FW_COREDUMP */ |
---|
2376 | 2572 | net_os_send_hang_message(bcmcfg_to_prmry_ndev(cfg)); |
---|
| 2573 | +#endif /* OEM_ANDROID */ |
---|
2377 | 2574 | return ERR_PTR(-ENODEV); |
---|
| 2575 | +#endif /* EXPLICIT_DISCIF_CLEANUP */ |
---|
2378 | 2576 | } |
---|
2379 | 2577 | |
---|
2380 | | - wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); |
---|
| 2578 | + wdev = (struct wireless_dev *)MALLOCZ(cfg->osh, sizeof(*wdev)); |
---|
2381 | 2579 | if (unlikely(!wdev)) { |
---|
2382 | 2580 | WL_ERR(("Could not allocate wireless device\n")); |
---|
2383 | 2581 | return ERR_PTR(-ENOMEM); |
---|
2384 | 2582 | } |
---|
2385 | 2583 | |
---|
2386 | | - memset(&primary_mac, 0, sizeof(primary_mac)); |
---|
| 2584 | + bzero(&primary_mac, sizeof(primary_mac)); |
---|
2387 | 2585 | get_primary_mac(cfg, &primary_mac); |
---|
2388 | 2586 | wl_cfgp2p_generate_bss_mac(cfg, &primary_mac); |
---|
2389 | 2587 | |
---|
.. | .. |
---|
2391 | 2589 | wdev->iftype = NL80211_IFTYPE_P2P_DEVICE; |
---|
2392 | 2590 | memcpy(wdev->address, wl_to_p2p_bss_macaddr(cfg, P2PAPI_BSSCFG_DEVICE), ETHER_ADDR_LEN); |
---|
2393 | 2591 | |
---|
| 2592 | +#if defined(WL_NEWCFG_PRIVCMD_SUPPORT) |
---|
| 2593 | + if (cfg->p2p_net) |
---|
| 2594 | + memcpy(cfg->p2p_net->dev_addr, wl_to_p2p_bss_macaddr(cfg, P2PAPI_BSSCFG_DEVICE), |
---|
| 2595 | + ETHER_ADDR_LEN); |
---|
| 2596 | +#endif /* WL_NEWCFG_PRIVCMD_SUPPORT */ |
---|
2394 | 2597 | |
---|
2395 | 2598 | /* store p2p wdev ptr for further reference. */ |
---|
2396 | 2599 | cfg->p2p_wdev = wdev; |
---|
2397 | 2600 | |
---|
2398 | 2601 | CFGP2P_ERR(("P2P interface registered\n")); |
---|
2399 | | - |
---|
2400 | 2602 | return wdev; |
---|
2401 | 2603 | } |
---|
2402 | 2604 | |
---|
.. | .. |
---|
2426 | 2628 | p2p_on(cfg) = true; |
---|
2427 | 2629 | #if defined(P2P_IE_MISSING_FIX) |
---|
2428 | 2630 | cfg->p2p_prb_noti = false; |
---|
2429 | | -#endif |
---|
| 2631 | +#endif // endif |
---|
2430 | 2632 | |
---|
2431 | 2633 | CFGP2P_DBG(("P2P interface started\n")); |
---|
2432 | 2634 | |
---|
.. | .. |
---|
2438 | 2640 | wl_cfgp2p_stop_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev) |
---|
2439 | 2641 | { |
---|
2440 | 2642 | int ret = 0; |
---|
| 2643 | + struct net_device *ndev = NULL; |
---|
2441 | 2644 | struct bcm_cfg80211 *cfg = wiphy_priv(wiphy); |
---|
2442 | 2645 | |
---|
2443 | 2646 | if (!cfg) |
---|
.. | .. |
---|
2445 | 2648 | |
---|
2446 | 2649 | CFGP2P_DBG(("Enter\n")); |
---|
2447 | 2650 | |
---|
2448 | | - ret = wl_cfg80211_scan_stop(wdev); |
---|
| 2651 | + /* Check if cfg80211 interface is already down */ |
---|
| 2652 | + ndev = bcmcfg_to_prmry_ndev(cfg); |
---|
| 2653 | + if (!wl_get_drv_status(cfg, READY, ndev)) { |
---|
| 2654 | + WL_DBG(("cfg80211 interface is already down\n")); |
---|
| 2655 | + return; /* it is even not ready */ |
---|
| 2656 | + } |
---|
| 2657 | + |
---|
| 2658 | + ret = wl_cfg80211_scan_stop(cfg, wdev); |
---|
2449 | 2659 | if (unlikely(ret < 0)) { |
---|
2450 | 2660 | CFGP2P_ERR(("P2P scan stop failed, ret=%d\n", ret)); |
---|
2451 | 2661 | } |
---|
2452 | 2662 | |
---|
2453 | | - if (!cfg->p2p) |
---|
| 2663 | + if (!p2p_is_on(cfg)) { |
---|
2454 | 2664 | return; |
---|
| 2665 | + } |
---|
| 2666 | + |
---|
| 2667 | +#ifdef P2P_LISTEN_OFFLOADING |
---|
| 2668 | + wl_cfg80211_p2plo_deinit(cfg); |
---|
| 2669 | +#endif /* P2P_LISTEN_OFFLOADING */ |
---|
| 2670 | + |
---|
| 2671 | + /* Cancel any on-going listen */ |
---|
| 2672 | + wl_cfgp2p_cancel_listen(cfg, bcmcfg_to_prmry_ndev(cfg), wdev, TRUE); |
---|
2455 | 2673 | |
---|
2456 | 2674 | ret = wl_cfgp2p_disable_discovery(cfg); |
---|
2457 | 2675 | if (unlikely(ret < 0)) { |
---|
.. | .. |
---|
2470 | 2688 | { |
---|
2471 | 2689 | bool rollback_lock = false; |
---|
2472 | 2690 | |
---|
2473 | | - if (!wdev) |
---|
| 2691 | + if (!wdev || !cfg) { |
---|
| 2692 | + WL_ERR(("null ptr. wdev:%p cfg:%p\n", wdev, cfg)); |
---|
2474 | 2693 | return -EINVAL; |
---|
| 2694 | + } |
---|
2475 | 2695 | |
---|
2476 | | - WL_TRACE(("Enter\n")); |
---|
| 2696 | + WL_INFORM(("Enter\n")); |
---|
2477 | 2697 | |
---|
2478 | 2698 | if (!rtnl_is_locked()) { |
---|
2479 | 2699 | rtnl_lock(); |
---|
.. | .. |
---|
2487 | 2707 | |
---|
2488 | 2708 | synchronize_rcu(); |
---|
2489 | 2709 | |
---|
2490 | | - kfree(wdev); |
---|
| 2710 | + MFREE(cfg->osh, wdev, sizeof(*wdev)); |
---|
2491 | 2711 | |
---|
2492 | | - if (cfg) |
---|
2493 | | - cfg->p2p_wdev = NULL; |
---|
| 2712 | + cfg->p2p_wdev = NULL; |
---|
2494 | 2713 | |
---|
2495 | 2714 | CFGP2P_ERR(("P2P interface unregistered\n")); |
---|
2496 | 2715 | |
---|