~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include <linux/kernel.h>
18
18
#include <linux/if_arp.h>
19
 
#include <osl.h>
20
19
 
21
20
#include <bcmutils.h>
22
 
#include <bcmendian.h>
23
 
#include <proto/ethernet.h>
24
21
 
25
22
#include <asm/uaccess.h>
26
23
 
42
39
#include <linux/firmware.h>
43
40
#include <wl_cfg80211.h>
44
41
 
 
42
void sdioh_sdio_set_host_pm_flags(int flag);
 
43
 
45
44
static struct sdio_func *cfg80211_sdio_func;
46
45
static struct wl_dev *wl_cfg80211_dev;
 
46
static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
47
47
 
48
 
u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO;
 
48
u32 wl_dbg_level = WL_DBG_ERR;
49
49
 
50
50
#define WL_4329_FW_FILE "brcm/bcm4329-fullmac-4.bin"
51
51
#define WL_4329_NVRAM_FILE "brcm/bcm4329-fullmac-4.txt"
87
87
                                      s32 dbm);
88
88
static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm);
89
89
static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy,
90
 
                                            struct net_device *dev,
91
 
                                            u8 key_idx);
 
90
                                          struct net_device *dev, u8 key_idx,
 
91
                                          bool unicast, bool multicast);
92
92
static s32 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
93
93
                                 u8 key_idx, bool pairwise, const u8 *mac_addr,
94
94
                                 struct key_params *params);
182
182
** cfg80211 connect utilites
183
183
*/
184
184
static s32 wl_set_wpa_version(struct net_device *dev,
185
 
                                struct cfg80211_connect_params *sme);
 
185
                        struct cfg80211_connect_params *sme);
186
186
static s32 wl_set_auth_type(struct net_device *dev,
187
 
                              struct cfg80211_connect_params *sme);
 
187
                        struct cfg80211_connect_params *sme);
188
188
static s32 wl_set_set_cipher(struct net_device *dev,
189
 
                               struct cfg80211_connect_params *sme);
 
189
                        struct cfg80211_connect_params *sme);
190
190
static s32 wl_set_key_mgmt(struct net_device *dev,
191
 
                             struct cfg80211_connect_params *sme);
 
191
                        struct cfg80211_connect_params *sme);
192
192
static s32 wl_set_set_sharedkey(struct net_device *dev,
193
 
                                  struct cfg80211_connect_params *sme);
 
193
                        struct cfg80211_connect_params *sme);
194
194
static s32 wl_get_assoc_ies(struct wl_priv *wl);
 
195
static void wl_clear_assoc_ies(struct wl_priv *wl);
195
196
static void wl_ch_to_chanspec(int ch,
196
197
        struct wl_join_params *join_params, size_t *join_params_size);
197
198
 
198
199
/*
199
200
** information element utilities
200
201
*/
201
 
static void wl_rst_ie(struct wl_priv *wl);
202
202
static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v);
203
 
static s32 wl_mrg_ie(struct wl_priv *wl, u8 *ie_stream, u16 ie_size);
204
 
static s32 wl_cp_ie(struct wl_priv *wl, u8 *dst, u16 dst_size);
205
 
static u32 wl_get_ielen(struct wl_priv *wl);
206
 
 
207
203
static s32 wl_mode_to_nl80211_iftype(s32 mode);
208
 
 
209
204
static struct wireless_dev *wl_alloc_wdev(s32 sizeof_iface,
210
 
                                          struct device *dev);
 
205
                        struct device *dev);
211
206
static void wl_free_wdev(struct wl_priv *wl);
212
 
 
213
207
static s32 wl_inform_bss(struct wl_priv *wl);
214
208
static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi);
215
209
static s32 wl_update_bss_info(struct wl_priv *wl);
216
 
 
217
210
static s32 wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
218
 
                           u8 key_idx, const u8 *mac_addr,
219
 
                           struct key_params *params);
 
211
                        u8 key_idx, const u8 *mac_addr,
 
212
                        struct key_params *params);
220
213
 
221
214
/*
222
215
** key indianess swap utilities
242
235
** ibss mode utilities
243
236
*/
244
237
static bool wl_is_ibssmode(struct wl_priv *wl);
245
 
static bool wl_is_ibssstarter(struct wl_priv *wl);
246
238
 
247
239
/*
248
240
** dongle up/down , default configuration utilities
250
242
static bool wl_is_linkdown(struct wl_priv *wl, const wl_event_msg_t *e);
251
243
static bool wl_is_linkup(struct wl_priv *wl, const wl_event_msg_t *e);
252
244
static bool wl_is_nonetwork(struct wl_priv *wl, const wl_event_msg_t *e);
253
 
static void wl_link_up(struct wl_priv *wl);
254
245
static void wl_link_down(struct wl_priv *wl);
255
246
static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype);
256
247
static s32 __wl_cfg80211_up(struct wl_priv *wl);
268
259
static s32 wl_dongle_power(struct net_device *ndev, u32 power_mode);
269
260
static s32 wl_dongle_glom(struct net_device *ndev, u32 glom,
270
261
                            u32 dongle_align);
271
 
static s32 wl_dongle_roam(struct net_device *ndev, u32 roamvar,
272
 
                            u32 bcn_timeout);
273
 
static s32 wl_dongle_eventmsg(struct net_device *ndev);
274
 
static s32 wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
275
 
                                s32 scan_unassoc_time);
276
262
static s32 wl_dongle_offload(struct net_device *ndev, s32 arpoe,
277
263
                               s32 arp_ol);
278
264
static s32 wl_pattern_atoh(s8 *src, s8 *dst);
279
265
static s32 wl_dongle_filter(struct net_device *ndev, u32 filter_mode);
280
266
static s32 wl_update_wiphybands(struct wl_priv *wl);
281
267
#endif                          /* !EMBEDDED_PLATFORM */
 
268
 
 
269
static s32 wl_dongle_eventmsg(struct net_device *ndev);
 
270
static s32 wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
 
271
                                s32 scan_unassoc_time, s32 scan_passive_time);
282
272
static s32 wl_config_dongle(struct wl_priv *wl, bool need_lock);
 
273
static s32 wl_dongle_roam(struct net_device *ndev, u32 roamvar,
 
274
                            u32 bcn_timeout);
283
275
 
284
276
/*
285
277
** iscan handler
354
346
} while (0)
355
347
 
356
348
extern int dhd_wait_pend8021x(struct net_device *dev);
357
 
 
358
 
#if (WL_DBG_LEVEL > 0)
359
 
#define WL_DBG_ESTR_MAX 32
360
 
static s8 wl_dbg_estr[][WL_DBG_ESTR_MAX] = {
361
 
        "SET_SSID", "JOIN", "START", "AUTH", "AUTH_IND",
362
 
        "DEAUTH", "DEAUTH_IND", "ASSOC", "ASSOC_IND", "REASSOC",
363
 
        "REASSOC_IND", "DISASSOC", "DISASSOC_IND", "QUIET_START", "QUIET_END",
364
 
        "BEACON_RX", "LINK", "MIC_ERROR", "NDIS_LINK", "ROAM",
365
 
        "TXFAIL", "PMKID_CACHE", "RETROGRADE_TSF", "PRUNE", "AUTOAUTH",
366
 
        "EAPOL_MSG", "SCAN_COMPLETE", "ADDTS_IND", "DELTS_IND", "BCNSENT_IND",
367
 
        "BCNRX_MSG", "BCNLOST_MSG", "ROAM_PREP", "PFN_NET_FOUND",
368
 
        "PFN_NET_LOST",
369
 
        "RESET_COMPLETE", "JOIN_START", "ROAM_START", "ASSOC_START",
370
 
        "IBSS_ASSOC",
371
 
        "RADIO", "PSM_WATCHDOG",
372
 
        "PROBREQ_MSG",
373
 
        "SCAN_CONFIRM_IND", "PSK_SUP", "COUNTRY_CODE_CHANGED",
374
 
        "EXCEEDED_MEDIUM_TIME", "ICV_ERROR",
375
 
        "UNICAST_DECODE_ERROR", "MULTICAST_DECODE_ERROR", "TRACE",
376
 
        "IF",
377
 
        "RSSI", "PFN_SCAN_COMPLETE", "ACTION_FRAME", "ACTION_FRAME_COMPLETE",
378
 
};
379
 
#endif                          /* WL_DBG_LEVEL */
380
 
 
381
349
#define CHAN2G(_channel, _freq, _flags) {                       \
382
350
        .band                   = IEEE80211_BAND_2GHZ,          \
383
351
        .center_freq            = (_freq),                      \
555
523
 
556
524
static void swap_key_from_BE(struct wl_wsec_key *key)
557
525
{
558
 
        key->index = htod32(key->index);
559
 
        key->len = htod32(key->len);
560
 
        key->algo = htod32(key->algo);
561
 
        key->flags = htod32(key->flags);
562
 
        key->rxiv.hi = htod32(key->rxiv.hi);
563
 
        key->rxiv.lo = htod16(key->rxiv.lo);
564
 
        key->iv_initialized = htod32(key->iv_initialized);
 
526
        key->index = cpu_to_le32(key->index);
 
527
        key->len = cpu_to_le32(key->len);
 
528
        key->algo = cpu_to_le32(key->algo);
 
529
        key->flags = cpu_to_le32(key->flags);
 
530
        key->rxiv.hi = cpu_to_le32(key->rxiv.hi);
 
531
        key->rxiv.lo = cpu_to_le16(key->rxiv.lo);
 
532
        key->iv_initialized = cpu_to_le32(key->iv_initialized);
565
533
}
566
534
 
567
535
static void swap_key_to_BE(struct wl_wsec_key *key)
568
536
{
569
 
        key->index = dtoh32(key->index);
570
 
        key->len = dtoh32(key->len);
571
 
        key->algo = dtoh32(key->algo);
572
 
        key->flags = dtoh32(key->flags);
573
 
        key->rxiv.hi = dtoh32(key->rxiv.hi);
574
 
        key->rxiv.lo = dtoh16(key->rxiv.lo);
575
 
        key->iv_initialized = dtoh32(key->iv_initialized);
 
537
        key->index = le32_to_cpu(key->index);
 
538
        key->len = le32_to_cpu(key->len);
 
539
        key->algo = le32_to_cpu(key->algo);
 
540
        key->flags = le32_to_cpu(key->flags);
 
541
        key->rxiv.hi = le32_to_cpu(key->rxiv.hi);
 
542
        key->rxiv.lo = le16_to_cpu(key->rxiv.lo);
 
543
        key->iv_initialized = le32_to_cpu(key->iv_initialized);
576
544
}
577
545
 
578
546
static s32
606
574
        struct wl_priv *wl = wiphy_to_wl(wiphy);
607
575
        struct wireless_dev *wdev;
608
576
        s32 infra = 0;
609
 
        s32 ap = 0;
610
577
        s32 err = 0;
611
578
 
 
579
        WL_TRACE("Enter\n");
612
580
        CHECK_SYS_UP();
 
581
 
613
582
        switch (type) {
614
583
        case NL80211_IFTYPE_MONITOR:
615
584
        case NL80211_IFTYPE_WDS:
618
587
                return -EOPNOTSUPP;
619
588
        case NL80211_IFTYPE_ADHOC:
620
589
                wl->conf->mode = WL_MODE_IBSS;
 
590
                infra = 0;
621
591
                break;
622
592
        case NL80211_IFTYPE_STATION:
623
593
                wl->conf->mode = WL_MODE_BSS;
624
594
                infra = 1;
625
595
                break;
626
596
        default:
627
 
                return -EINVAL;
 
597
                err = -EINVAL;
 
598
                goto done;
628
599
        }
629
 
        infra = htod32(infra);
630
 
        ap = htod32(ap);
631
 
        wdev = ndev->ieee80211_ptr;
632
 
        wdev->iftype = type;
633
 
        WL_DBG("%s : ap (%d), infra (%d)\n", ndev->name, ap, infra);
 
600
 
 
601
        infra = cpu_to_le32(infra);
634
602
        err = wl_dev_ioctl(ndev, WLC_SET_INFRA, &infra, sizeof(infra));
635
603
        if (unlikely(err)) {
636
604
                WL_ERR("WLC_SET_INFRA error (%d)\n", err);
637
 
                return err;
638
 
        }
639
 
        err = wl_dev_ioctl(ndev, WLC_SET_AP, &ap, sizeof(ap));
640
 
        if (unlikely(err)) {
641
 
                WL_ERR("WLC_SET_AP error (%d)\n", err);
642
 
                return err;
643
 
        }
644
 
 
645
 
        /* -EINPROGRESS: Call commit handler */
646
 
        return -EINPROGRESS;
 
605
                err = -EAGAIN;
 
606
        } else {
 
607
                wdev = ndev->ieee80211_ptr;
 
608
                wdev->iftype = type;
 
609
        }
 
610
 
 
611
        WL_INFO("IF Type = %s\n",
 
612
                (wl->conf->mode == WL_MODE_IBSS) ? "Adhoc" : "Infra");
 
613
 
 
614
done:
 
615
        WL_TRACE("Exit\n");
 
616
 
 
617
        return err;
647
618
}
648
619
 
649
620
static void wl_iscan_prep(struct wl_scan_params *params, struct wlc_ssid *ssid)
650
621
{
651
 
        memcpy(&params->bssid, &ether_bcast, ETH_ALEN);
 
622
        memcpy(params->bssid, ether_bcast, ETH_ALEN);
652
623
        params->bss_type = DOT11_BSSTYPE_ANY;
653
624
        params->scan_type = 0;
654
625
        params->nprobes = -1;
657
628
        params->home_time = -1;
658
629
        params->channel_num = 0;
659
630
 
660
 
        params->nprobes = htod32(params->nprobes);
661
 
        params->active_time = htod32(params->active_time);
662
 
        params->passive_time = htod32(params->passive_time);
663
 
        params->home_time = htod32(params->home_time);
 
631
        params->nprobes = cpu_to_le32(params->nprobes);
 
632
        params->active_time = cpu_to_le32(params->active_time);
 
633
        params->passive_time = cpu_to_le32(params->passive_time);
 
634
        params->home_time = cpu_to_le32(params->home_time);
664
635
        if (ssid && ssid->SSID_len)
665
636
                memcpy(&params->ssid, ssid, sizeof(wlc_ssid_t));
666
637
 
673
644
        s32 iolen;
674
645
 
675
646
        iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
676
 
        BUG_ON(unlikely(!iolen));
 
647
        BUG_ON(!iolen);
677
648
 
678
649
        return wl_dev_ioctl(dev, WLC_SET_VAR, bufptr, iolen);
679
650
}
685
656
        s32 iolen;
686
657
 
687
658
        iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
688
 
        BUG_ON(unlikely(!iolen));
 
659
        BUG_ON(!iolen);
689
660
 
690
661
        return wl_dev_ioctl(dev, WLC_GET_VAR, bufptr, buflen);
691
662
}
703
674
        params = kzalloc(params_size, GFP_KERNEL);
704
675
        if (unlikely(!params))
705
676
                return -ENOMEM;
706
 
        memset(params, 0, params_size);
707
 
        BUG_ON(unlikely(params_size >= WLC_IOCTL_SMLEN));
 
677
        BUG_ON(params_size >= WLC_IOCTL_SMLEN);
708
678
 
709
679
        wl_iscan_prep(&params->params, ssid);
710
680
 
711
 
        params->version = htod32(ISCAN_REQ_VERSION);
712
 
        params->action = htod16(action);
713
 
        params->scan_duration = htod16(0);
 
681
        params->version = cpu_to_le32(ISCAN_REQ_VERSION);
 
682
        params->action = cpu_to_le16(action);
 
683
        params->scan_duration = cpu_to_le16(0);
714
684
 
715
685
        /* params_size += offsetof(wl_iscan_params_t, params); */
716
686
        err = wl_dev_iovar_setbuf(iscan->dev, "iscan", params, params_size,
743
713
        err = wl_dev_ioctl(wl_to_ndev(wl), WLC_SET_PASSIVE_SCAN,
744
714
                        &passive_scan, sizeof(passive_scan));
745
715
        if (unlikely(err)) {
746
 
                WL_DBG("error (%d)\n", err);
 
716
                WL_ERR("error (%d)\n", err);
747
717
                return err;
748
718
        }
749
719
        wl_set_mpc(ndev, 0);
777
747
                       (int)wl->status);
778
748
                return -EAGAIN;
779
749
        }
 
750
        if (test_bit(WL_STATUS_CONNECTING, &wl->status)) {
 
751
                WL_ERR("Connecting : status (%d)\n",
 
752
                       (int)wl->status);
 
753
                return -EAGAIN;
 
754
        }
780
755
 
781
756
        iscan_req = false;
782
757
        spec_scan = false;
783
 
        if (request) {          /* scan bss */
 
758
        if (request) {
 
759
                /* scan bss */
784
760
                ssids = request->ssids;
785
 
                if (wl->iscan_on && (!ssids || !ssids->ssid_len)) {     /* for
786
 
                                                         * specific scan,
787
 
                                                         * ssids->ssid_len has
788
 
                                                         * non-zero(ssid string)
789
 
                                                         * length.
790
 
                                                         * Otherwise this is 0.
791
 
                                                         * we do not iscan for
792
 
                                                         * specific scan request
793
 
                                                         */
 
761
                if (wl->iscan_on && (!ssids || !ssids->ssid_len))
794
762
                        iscan_req = true;
795
 
                }
796
 
        } else {                /* scan in ibss */
 
763
        } else {
 
764
                /* scan in ibss */
797
765
                /* we don't do iscan in ibss */
798
766
                ssids = this_ssid;
799
767
        }
 
768
 
800
769
        wl->scan_request = request;
801
770
        set_bit(WL_STATUS_SCANNING, &wl->status);
802
771
        if (iscan_req) {
806
775
                else
807
776
                        goto scan_out;
808
777
        } else {
809
 
                WL_DBG("ssid \"%s\", ssid_len (%d)\n",
 
778
                WL_SCAN("ssid \"%s\", ssid_len (%d)\n",
810
779
                       ssids->ssid, ssids->ssid_len);
811
780
                memset(&sr->ssid, 0, sizeof(sr->ssid));
812
781
                sr->ssid.SSID_len =
813
782
                            min_t(u8, sizeof(sr->ssid.SSID), ssids->ssid_len);
814
783
                if (sr->ssid.SSID_len) {
815
784
                        memcpy(sr->ssid.SSID, ssids->ssid, sr->ssid.SSID_len);
816
 
                        sr->ssid.SSID_len = htod32(sr->ssid.SSID_len);
817
 
                        WL_DBG("Specific scan ssid=\"%s\" len=%d\n",
818
 
                               sr->ssid.SSID, sr->ssid.SSID_len);
 
785
                        sr->ssid.SSID_len = cpu_to_le32(sr->ssid.SSID_len);
819
786
                        spec_scan = true;
820
787
                } else {
821
 
                        WL_DBG("Broadcast scan\n");
 
788
                        WL_SCAN("Broadcast scan\n");
822
789
                }
823
 
                WL_DBG("sr->ssid.SSID_len (%d)\n", sr->ssid.SSID_len);
 
790
 
824
791
                passive_scan = wl->active_scan ? 0 : 1;
825
792
                err = wl_dev_ioctl(ndev, WLC_SET_PASSIVE_SCAN,
826
793
                                &passive_scan, sizeof(passive_scan));
857
824
{
858
825
        s32 err = 0;
859
826
 
 
827
        WL_TRACE("Enter\n");
 
828
 
860
829
        CHECK_SYS_UP();
 
830
 
861
831
        err = __wl_cfg80211_scan(wiphy, ndev, request, NULL);
862
 
        if (unlikely(err)) {
863
 
                WL_DBG("scan error (%d)\n", err);
864
 
                return err;
865
 
        }
 
832
        if (unlikely(err))
 
833
                WL_ERR("scan error (%d)\n", err);
866
834
 
 
835
        WL_TRACE("Exit\n");
867
836
        return err;
868
837
}
869
838
 
873
842
        u32 len;
874
843
        s32 err = 0;
875
844
 
876
 
        val = htod32(val);
 
845
        val = cpu_to_le32(val);
877
846
        len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf));
878
 
        BUG_ON(unlikely(!len));
 
847
        BUG_ON(!len);
879
848
 
880
849
        err = wl_dev_ioctl(dev, WLC_SET_VAR, buf, len);
881
 
        if (unlikely(err)) {
 
850
        if (unlikely(err))
882
851
                WL_ERR("error (%d)\n", err);
883
 
        }
884
852
 
885
853
        return err;
886
854
}
899
867
        len =
900
868
            bcm_mkiovar(name, (char *)(&data_null), 0, (char *)(&var),
901
869
                        sizeof(var.buf));
902
 
        BUG_ON(unlikely(!len));
 
870
        BUG_ON(!len);
903
871
        err = wl_dev_ioctl(dev, WLC_GET_VAR, &var, len);
904
 
        if (unlikely(err)) {
 
872
        if (unlikely(err))
905
873
                WL_ERR("error (%d)\n", err);
906
 
        }
907
 
        *retval = dtoh32(var.val);
 
874
 
 
875
        *retval = le32_to_cpu(var.val);
908
876
 
909
877
        return err;
910
878
}
914
882
        s32 err = 0;
915
883
 
916
884
        err = wl_dev_intvar_set(dev, "rtsthresh", rts_threshold);
917
 
        if (unlikely(err)) {
 
885
        if (unlikely(err))
918
886
                WL_ERR("Error (%d)\n", err);
919
 
                return err;
920
 
        }
 
887
 
921
888
        return err;
922
889
}
923
890
 
926
893
        s32 err = 0;
927
894
 
928
895
        err = wl_dev_intvar_set(dev, "fragthresh", frag_threshold);
929
 
        if (unlikely(err)) {
 
896
        if (unlikely(err))
930
897
                WL_ERR("Error (%d)\n", err);
931
 
                return err;
932
 
        }
 
898
 
933
899
        return err;
934
900
}
935
901
 
938
904
        s32 err = 0;
939
905
        u32 cmd = (l ? WLC_SET_LRL : WLC_SET_SRL);
940
906
 
941
 
        retry = htod32(retry);
 
907
        retry = cpu_to_le32(retry);
942
908
        err = wl_dev_ioctl(dev, cmd, &retry, sizeof(retry));
943
909
        if (unlikely(err)) {
944
910
                WL_ERR("cmd (%d) , error (%d)\n", cmd, err);
953
919
        struct net_device *ndev = wl_to_ndev(wl);
954
920
        s32 err = 0;
955
921
 
 
922
        WL_TRACE("Enter\n");
956
923
        CHECK_SYS_UP();
 
924
 
957
925
        if (changed & WIPHY_PARAM_RTS_THRESHOLD &&
958
926
            (wl->conf->rts_threshold != wiphy->rts_threshold)) {
959
927
                wl->conf->rts_threshold = wiphy->rts_threshold;
960
928
                err = wl_set_rts(ndev, wl->conf->rts_threshold);
961
929
                if (!err)
962
 
                        return err;
 
930
                        goto done;
963
931
        }
964
932
        if (changed & WIPHY_PARAM_FRAG_THRESHOLD &&
965
933
            (wl->conf->frag_threshold != wiphy->frag_threshold)) {
966
934
                wl->conf->frag_threshold = wiphy->frag_threshold;
967
935
                err = wl_set_frag(ndev, wl->conf->frag_threshold);
968
936
                if (!err)
969
 
                        return err;
 
937
                        goto done;
970
938
        }
971
939
        if (changed & WIPHY_PARAM_RETRY_LONG
972
940
            && (wl->conf->retry_long != wiphy->retry_long)) {
973
941
                wl->conf->retry_long = wiphy->retry_long;
974
942
                err = wl_set_retry(ndev, wl->conf->retry_long, true);
975
943
                if (!err)
976
 
                        return err;
 
944
                        goto done;
977
945
        }
978
946
        if (changed & WIPHY_PARAM_RETRY_SHORT
979
947
            && (wl->conf->retry_short != wiphy->retry_short)) {
980
948
                wl->conf->retry_short = wiphy->retry_short;
981
949
                err = wl_set_retry(ndev, wl->conf->retry_short, false);
982
 
                if (!err) {
983
 
                        return err;
984
 
                }
 
950
                if (!err)
 
951
                        goto done;
985
952
        }
986
953
 
 
954
done:
 
955
        WL_TRACE("Exit\n");
987
956
        return err;
988
957
}
989
958
 
992
961
                      struct cfg80211_ibss_params *params)
993
962
{
994
963
        struct wl_priv *wl = wiphy_to_wl(wiphy);
995
 
        struct cfg80211_bss *bss;
996
 
        struct ieee80211_channel *chan;
997
964
        struct wl_join_params join_params;
998
 
        struct cfg80211_ssid ssid;
999
 
        s32 scan_retry = 0;
 
965
        size_t join_params_size = 0;
1000
966
        s32 err = 0;
 
967
        s32 wsec = 0;
 
968
        s32 bcnprd;
1001
969
 
 
970
        WL_TRACE("Enter\n");
1002
971
        CHECK_SYS_UP();
 
972
 
 
973
        if (params->ssid)
 
974
                WL_CONN("SSID: %s\n", params->ssid);
 
975
        else {
 
976
                WL_CONN("SSID: NULL, Not supported\n");
 
977
                return -EOPNOTSUPP;
 
978
        }
 
979
 
 
980
        if (params->bssid)
 
981
                WL_CONN("BSSID: %02X %02X %02X %02X %02X %02X\n",
 
982
                params->bssid[0], params->bssid[1], params->bssid[2],
 
983
                params->bssid[3], params->bssid[4], params->bssid[5]);
 
984
        else
 
985
                WL_CONN("No BSSID specified\n");
 
986
 
 
987
        if (params->channel)
 
988
                WL_CONN("channel: %d\n", params->channel->center_freq);
 
989
        else
 
990
                WL_CONN("no channel specified\n");
 
991
 
 
992
        if (params->channel_fixed)
 
993
                WL_CONN("fixed channel required\n");
 
994
        else
 
995
                WL_CONN("no fixed channel required\n");
 
996
 
 
997
        if (params->ie && params->ie_len)
 
998
                WL_CONN("ie len: %d\n", params->ie_len);
 
999
        else
 
1000
                WL_CONN("no ie specified\n");
 
1001
 
 
1002
        if (params->beacon_interval)
 
1003
                WL_CONN("beacon interval: %d\n", params->beacon_interval);
 
1004
        else
 
1005
                WL_CONN("no beacon interval specified\n");
 
1006
 
 
1007
        if (params->basic_rates)
 
1008
                WL_CONN("basic rates: %08X\n", params->basic_rates);
 
1009
        else
 
1010
                WL_CONN("no basic rates specified\n");
 
1011
 
 
1012
        if (params->privacy)
 
1013
                WL_CONN("privacy required\n");
 
1014
        else
 
1015
                WL_CONN("no privacy required\n");
 
1016
 
 
1017
        /* Configure Privacy for starter */
 
1018
        if (params->privacy)
 
1019
                wsec |= WEP_ENABLED;
 
1020
 
 
1021
        err = wl_dev_intvar_set(dev, "wsec", wsec);
 
1022
        if (unlikely(err)) {
 
1023
                WL_ERR("wsec failed (%d)\n", err);
 
1024
                goto done;
 
1025
        }
 
1026
 
 
1027
        /* Configure Beacon Interval for starter */
 
1028
        if (params->beacon_interval)
 
1029
                bcnprd = cpu_to_le32(params->beacon_interval);
 
1030
        else
 
1031
                bcnprd = cpu_to_le32(100);
 
1032
 
 
1033
        err = wl_dev_ioctl(dev, WLC_SET_BCNPRD, &bcnprd, sizeof(bcnprd));
 
1034
        if (unlikely(err)) {
 
1035
                WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err);
 
1036
                goto done;
 
1037
        }
 
1038
 
 
1039
        /* Configure required join parameter */
 
1040
        memset(&join_params, 0, sizeof(wl_join_params_t));
 
1041
 
 
1042
        /* SSID */
 
1043
        join_params.ssid.SSID_len =
 
1044
                        (params->ssid_len > 32) ? 32 : params->ssid_len;
 
1045
        memcpy(join_params.ssid.SSID, params->ssid, join_params.ssid.SSID_len);
 
1046
        join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len);
 
1047
        join_params_size = sizeof(join_params.ssid);
 
1048
        wl_update_prof(wl, NULL, &join_params.ssid, WL_PROF_SSID);
 
1049
 
 
1050
        /* BSSID */
1003
1051
        if (params->bssid) {
1004
 
                WL_ERR("Invalid bssid\n");
1005
 
                return -EOPNOTSUPP;
1006
 
        }
1007
 
        bss = cfg80211_get_ibss(wiphy, NULL, params->ssid, params->ssid_len);
1008
 
        if (!bss) {
1009
 
                memcpy(ssid.ssid, params->ssid, params->ssid_len);
1010
 
                ssid.ssid_len = params->ssid_len;
1011
 
                do {
1012
 
                        if (unlikely
1013
 
                            (__wl_cfg80211_scan(wiphy, dev, NULL, &ssid) ==
1014
 
                             -EBUSY)) {
1015
 
                                wl_delay(150);
1016
 
                        } else {
1017
 
                                break;
1018
 
                        }
1019
 
                } while (++scan_retry < WL_SCAN_RETRY_MAX);
1020
 
                rtnl_unlock();  /* to allow scan_inform to paropagate
1021
 
                                         to cfg80211 plane */
1022
 
                schedule_timeout_interruptible(4 * HZ); /* wait 4 secons
1023
 
                                                 till scan done.... */
1024
 
                rtnl_lock();
1025
 
                bss = cfg80211_get_ibss(wiphy, NULL,
1026
 
                                        params->ssid, params->ssid_len);
1027
 
        }
1028
 
        if (bss) {
1029
 
                wl->ibss_starter = false;
1030
 
                WL_DBG("Found IBSS\n");
 
1052
                memcpy(join_params.params.bssid, params->bssid, ETH_ALEN);
 
1053
                join_params_size =
 
1054
                        sizeof(join_params.ssid) + WL_ASSOC_PARAMS_FIXED_SIZE;
1031
1055
        } else {
1032
 
                wl->ibss_starter = true;
 
1056
                memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
1033
1057
        }
1034
 
        chan = params->channel;
1035
 
        if (chan)
1036
 
                wl->channel = ieee80211_frequency_to_channel(chan->center_freq);
1037
 
        /*
1038
 
         ** Join with specific BSSID and cached SSID
1039
 
         ** If SSID is zero join based on BSSID only
1040
 
         */
1041
 
        memset(&join_params, 0, sizeof(join_params));
1042
 
        memcpy((void *)join_params.ssid.SSID, (void *)params->ssid,
1043
 
               params->ssid_len);
1044
 
        join_params.ssid.SSID_len = htod32(params->ssid_len);
1045
 
        if (params->bssid)
1046
 
                memcpy(&join_params.params.bssid, params->bssid,
1047
 
                       ETH_ALEN);
1048
 
        else
1049
 
                memset(&join_params.params.bssid, 0, ETH_ALEN);
1050
 
 
1051
 
        err = wl_dev_ioctl(dev, WLC_SET_SSID, &join_params,
1052
 
                        sizeof(join_params));
 
1058
        wl_update_prof(wl, NULL, &join_params.params.bssid, WL_PROF_BSSID);
 
1059
 
 
1060
        /* Channel */
 
1061
        if (params->channel) {
 
1062
                u32 target_channel;
 
1063
 
 
1064
                wl->channel =
 
1065
                        ieee80211_frequency_to_channel(
 
1066
                                params->channel->center_freq);
 
1067
                if (params->channel_fixed) {
 
1068
                        /* adding chanspec */
 
1069
                        wl_ch_to_chanspec(wl->channel,
 
1070
                                &join_params, &join_params_size);
 
1071
                }
 
1072
 
 
1073
                /* set channel for starter */
 
1074
                target_channel = cpu_to_le32(wl->channel);
 
1075
                err = wl_dev_ioctl(dev, WLC_SET_CHANNEL,
 
1076
                        &target_channel, sizeof(target_channel));
 
1077
                if (unlikely(err)) {
 
1078
                        WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err);
 
1079
                        goto done;
 
1080
                }
 
1081
        } else
 
1082
                wl->channel = 0;
 
1083
 
 
1084
        wl->ibss_starter = false;
 
1085
 
 
1086
 
 
1087
        err = wl_dev_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size);
1053
1088
        if (unlikely(err)) {
1054
 
                WL_ERR("Error (%d)\n", err);
1055
 
                return err;
 
1089
                WL_ERR("WLC_SET_SSID failed (%d)\n", err);
 
1090
                goto done;
1056
1091
        }
 
1092
 
 
1093
        set_bit(WL_STATUS_CONNECTING, &wl->status);
 
1094
 
 
1095
done:
 
1096
        WL_TRACE("Exit\n");
1057
1097
        return err;
1058
1098
}
1059
1099
 
1062
1102
        struct wl_priv *wl = wiphy_to_wl(wiphy);
1063
1103
        s32 err = 0;
1064
1104
 
 
1105
        WL_TRACE("Enter\n");
1065
1106
        CHECK_SYS_UP();
 
1107
 
1066
1108
        wl_link_down(wl);
1067
1109
 
 
1110
        WL_TRACE("Exit\n");
 
1111
 
1068
1112
        return err;
1069
1113
}
1070
1114
 
1082
1126
                val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED;
1083
1127
        else
1084
1128
                val = WPA_AUTH_DISABLED;
1085
 
        WL_DBG("setting wpa_auth to 0x%0x\n", val);
 
1129
        WL_CONN("setting wpa_auth to 0x%0x\n", val);
1086
1130
        err = wl_dev_intvar_set(dev, "wpa_auth", val);
1087
1131
        if (unlikely(err)) {
1088
1132
                WL_ERR("set wpa_auth failed (%d)\n", err);
1104
1148
        switch (sme->auth_type) {
1105
1149
        case NL80211_AUTHTYPE_OPEN_SYSTEM:
1106
1150
                val = 0;
1107
 
                WL_DBG("open system\n");
 
1151
                WL_CONN("open system\n");
1108
1152
                break;
1109
1153
        case NL80211_AUTHTYPE_SHARED_KEY:
1110
1154
                val = 1;
1111
 
                WL_DBG("shared key\n");
 
1155
                WL_CONN("shared key\n");
1112
1156
                break;
1113
1157
        case NL80211_AUTHTYPE_AUTOMATIC:
1114
1158
                val = 2;
1115
 
                WL_DBG("automatic\n");
 
1159
                WL_CONN("automatic\n");
1116
1160
                break;
1117
1161
        case NL80211_AUTHTYPE_NETWORK_EAP:
1118
 
                WL_DBG("network eap\n");
 
1162
                WL_CONN("network eap\n");
1119
1163
        default:
1120
1164
                val = 2;
1121
1165
                WL_ERR("invalid auth type (%d)\n", sme->auth_type);
1184
1228
                }
1185
1229
        }
1186
1230
 
1187
 
        WL_DBG("pval (%d) gval (%d)\n", pval, gval);
 
1231
        WL_CONN("pval (%d) gval (%d)\n", pval, gval);
1188
1232
        err = wl_dev_intvar_set(dev, "wsec", pval | gval);
1189
1233
        if (unlikely(err)) {
1190
1234
                WL_ERR("error (%d)\n", err);
1240
1284
                        }
1241
1285
                }
1242
1286
 
1243
 
                WL_DBG("setting wpa_auth to %d\n", val);
 
1287
                WL_CONN("setting wpa_auth to %d\n", val);
1244
1288
                err = wl_dev_intvar_set(dev, "wpa_auth", val);
1245
1289
                if (unlikely(err)) {
1246
1290
                        WL_ERR("could not set wpa_auth (%d)\n", err);
1263
1307
        s32 val;
1264
1308
        s32 err = 0;
1265
1309
 
1266
 
        WL_DBG("key len (%d)\n", sme->key_len);
 
1310
        WL_CONN("key len (%d)\n", sme->key_len);
1267
1311
        if (sme->key_len) {
1268
1312
                sec = wl_read_prof(wl, WL_PROF_SEC);
1269
 
                WL_DBG("wpa_versions 0x%x cipher_pairwise 0x%x\n",
 
1313
                WL_CONN("wpa_versions 0x%x cipher_pairwise 0x%x\n",
1270
1314
                       sec->wpa_versions, sec->cipher_pairwise);
1271
1315
                if (!
1272
1316
                    (sec->wpa_versions & (NL80211_WPA_VERSION_1 |
1295
1339
                                return -EINVAL;
1296
1340
                        }
1297
1341
                        /* Set the new key/index */
1298
 
                        WL_DBG("key length (%d) key index (%d) algo (%d)\n",
 
1342
                        WL_CONN("key length (%d) key index (%d) algo (%d)\n",
1299
1343
                               key.len, key.index, key.algo);
1300
 
                        WL_DBG("key \"%s\"\n", key.data);
 
1344
                        WL_CONN("key \"%s\"\n", key.data);
1301
1345
                        swap_key_from_BE(&key);
1302
1346
                        err = wl_dev_ioctl(dev, WLC_SET_KEY, &key,
1303
1347
                                        sizeof(key));
1306
1350
                                return err;
1307
1351
                        }
1308
1352
                        if (sec->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) {
1309
 
                                WL_DBG("set auth_type to shared key\n");
 
1353
                                WL_CONN("set auth_type to shared key\n");
1310
1354
                                val = 1;        /* shared key */
1311
1355
                                err = wl_dev_intvar_set(dev, "auth", val);
1312
1356
                                if (unlikely(err)) {
1330
1374
 
1331
1375
        s32 err = 0;
1332
1376
 
 
1377
        WL_TRACE("Enter\n");
1333
1378
        CHECK_SYS_UP();
 
1379
 
1334
1380
        if (unlikely(!sme->ssid)) {
1335
1381
                WL_ERR("Invalid ssid\n");
1336
1382
                return -EOPNOTSUPP;
1337
1383
        }
 
1384
 
1338
1385
        if (chan) {
1339
 
                wl->channel = ieee80211_frequency_to_channel(chan->center_freq);
1340
 
                WL_DBG("channel (%d), center_req (%d)\n",
1341
 
                       wl->channel, chan->center_freq);
1342
 
        }
1343
 
        WL_DBG("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len);
 
1386
                wl->channel =
 
1387
                        ieee80211_frequency_to_channel(chan->center_freq);
 
1388
                WL_CONN("channel (%d), center_req (%d)\n",
 
1389
                        wl->channel, chan->center_freq);
 
1390
        } else
 
1391
                wl->channel = 0;
 
1392
 
 
1393
        WL_INFO("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len);
 
1394
 
1344
1395
        err = wl_set_wpa_version(dev, sme);
1345
1396
        if (unlikely(err))
1346
1397
                return err;
1371
1422
 
1372
1423
        join_params.ssid.SSID_len = min(sizeof(join_params.ssid.SSID), sme->ssid_len);
1373
1424
        memcpy(&join_params.ssid.SSID, sme->ssid, join_params.ssid.SSID_len);
1374
 
        join_params.ssid.SSID_len = htod32(join_params.ssid.SSID_len);
 
1425
        join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len);
1375
1426
        wl_update_prof(wl, NULL, &join_params.ssid, WL_PROF_SSID);
1376
 
        memcpy(&join_params.params.bssid, &ether_bcast, ETH_ALEN);
1377
1427
 
1378
 
        wl_ch_to_chanspec(wl->channel, &join_params, &join_params_size);
1379
 
        WL_DBG("join_param_size %d\n", join_params_size);
 
1428
        if (sme->bssid)
 
1429
                memcpy(join_params.params.bssid, sme->bssid, ETH_ALEN);
 
1430
        else
 
1431
                memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
1380
1432
 
1381
1433
        if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) {
1382
 
                WL_DBG("ssid \"%s\", len (%d)\n",
 
1434
                WL_CONN("ssid \"%s\", len (%d)\n",
1383
1435
                       join_params.ssid.SSID, join_params.ssid.SSID_len);
1384
1436
        }
 
1437
 
 
1438
        wl_ch_to_chanspec(wl->channel, &join_params, &join_params_size);
1385
1439
        err = wl_dev_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size);
1386
1440
        if (unlikely(err)) {
1387
1441
                WL_ERR("error (%d)\n", err);
1389
1443
        }
1390
1444
        set_bit(WL_STATUS_CONNECTING, &wl->status);
1391
1445
 
 
1446
        WL_TRACE("Exit\n");
1392
1447
        return err;
1393
1448
}
1394
1449
 
1398
1453
{
1399
1454
        struct wl_priv *wl = wiphy_to_wl(wiphy);
1400
1455
        scb_val_t scbval;
1401
 
        bool act = false;
1402
1456
        s32 err = 0;
1403
1457
 
1404
 
        WL_DBG("Reason %d\n", reason_code);
 
1458
        WL_TRACE("Enter. Reason code = %d\n", reason_code);
1405
1459
        CHECK_SYS_UP();
1406
 
        act = *(bool *) wl_read_prof(wl, WL_PROF_ACT);
1407
 
        if (likely(act)) {
1408
 
                scbval.val = reason_code;
1409
 
                memcpy(&scbval.ea, &wl->bssid, ETH_ALEN);
1410
 
                scbval.val = htod32(scbval.val);
1411
 
                err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval,
1412
 
                                sizeof(scb_val_t));
1413
 
                if (unlikely(err)) {
1414
 
                        WL_ERR("error (%d)\n", err);
1415
 
                        return err;
1416
 
                }
1417
 
        }
1418
 
 
 
1460
 
 
1461
        clear_bit(WL_STATUS_CONNECTED, &wl->status);
 
1462
 
 
1463
        scbval.val = reason_code;
 
1464
        memcpy(&scbval.ea, wl_read_prof(wl, WL_PROF_BSSID), ETH_ALEN);
 
1465
        scbval.val = cpu_to_le32(scbval.val);
 
1466
        err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval,
 
1467
                        sizeof(scb_val_t));
 
1468
        if (unlikely(err))
 
1469
                WL_ERR("error (%d)\n", err);
 
1470
 
 
1471
        wl->link_up = false;
 
1472
 
 
1473
        WL_TRACE("Exit\n");
1419
1474
        return err;
1420
1475
}
1421
1476
 
1430
1485
        s32 err = 0;
1431
1486
        s32 disable = 0;
1432
1487
 
 
1488
        WL_TRACE("Enter\n");
1433
1489
        CHECK_SYS_UP();
 
1490
 
1434
1491
        switch (type) {
1435
1492
        case NL80211_TX_POWER_AUTOMATIC:
1436
1493
                break;
1437
1494
        case NL80211_TX_POWER_LIMITED:
1438
1495
                if (dbm < 0) {
1439
1496
                        WL_ERR("TX_POWER_LIMITED - dbm is negative\n");
1440
 
                        return -EINVAL;
 
1497
                        err = -EINVAL;
 
1498
                        goto done;
1441
1499
                }
1442
1500
                break;
1443
1501
        case NL80211_TX_POWER_FIXED:
1444
1502
                if (dbm < 0) {
1445
1503
                        WL_ERR("TX_POWER_FIXED - dbm is negative\n");
1446
 
                        return -EINVAL;
 
1504
                        err = -EINVAL;
 
1505
                        goto done;
1447
1506
                }
1448
1507
                break;
1449
1508
        }
1450
1509
        /* Make sure radio is off or on as far as software is concerned */
1451
1510
        disable = WL_RADIO_SW_DISABLE << 16;
1452
 
        disable = htod32(disable);
 
1511
        disable = cpu_to_le32(disable);
1453
1512
        err = wl_dev_ioctl(ndev, WLC_SET_RADIO, &disable, sizeof(disable));
1454
 
        if (unlikely(err)) {
 
1513
        if (unlikely(err))
1455
1514
                WL_ERR("WLC_SET_RADIO error (%d)\n", err);
1456
 
                return err;
1457
 
        }
1458
1515
 
1459
1516
        if (dbm > 0xffff)
1460
1517
                txpwrmw = 0xffff;
1462
1519
                txpwrmw = (u16) dbm;
1463
1520
        err = wl_dev_intvar_set(ndev, "qtxpower",
1464
1521
                        (s32) (bcm_mw_to_qdbm(txpwrmw)));
1465
 
        if (unlikely(err)) {
 
1522
        if (unlikely(err))
1466
1523
                WL_ERR("qtxpower error (%d)\n", err);
1467
 
                return err;
1468
 
        }
1469
1524
        wl->conf->tx_power = dbm;
1470
1525
 
 
1526
done:
 
1527
        WL_TRACE("Exit\n");
1471
1528
        return err;
1472
1529
}
1473
1530
 
1479
1536
        u8 result;
1480
1537
        s32 err = 0;
1481
1538
 
 
1539
        WL_TRACE("Enter\n");
1482
1540
        CHECK_SYS_UP();
 
1541
 
1483
1542
        err = wl_dev_intvar_get(ndev, "qtxpower", &txpwrdbm);
1484
1543
        if (unlikely(err)) {
1485
1544
                WL_ERR("error (%d)\n", err);
1486
 
                return err;
 
1545
                goto done;
1487
1546
        }
 
1547
 
1488
1548
        result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE);
1489
1549
        *dbm = (s32) bcm_qdbm_to_mw(result);
1490
1550
 
 
1551
done:
 
1552
        WL_TRACE("Exit\n");
1491
1553
        return err;
1492
1554
}
1493
1555
 
1494
1556
static s32
1495
1557
wl_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev,
1496
 
                               u8 key_idx)
 
1558
                               u8 key_idx, bool unicast, bool multicast)
1497
1559
{
1498
1560
        u32 index;
1499
1561
        s32 wsec;
1500
1562
        s32 err = 0;
1501
1563
 
1502
 
        WL_DBG("key index (%d)\n", key_idx);
 
1564
        WL_TRACE("Enter\n");
 
1565
        WL_CONN("key index (%d)\n", key_idx);
1503
1566
        CHECK_SYS_UP();
1504
1567
 
1505
1568
        err = wl_dev_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec));
1506
1569
        if (unlikely(err)) {
1507
1570
                WL_ERR("WLC_GET_WSEC error (%d)\n", err);
1508
 
                return err;
 
1571
                goto done;
1509
1572
        }
1510
 
        wsec = dtoh32(wsec);
 
1573
 
 
1574
        wsec = le32_to_cpu(wsec);
1511
1575
        if (wsec & WEP_ENABLED) {
1512
1576
                /* Just select a new current key */
1513
1577
                index = (u32) key_idx;
1514
 
                index = htod32(index);
 
1578
                index = cpu_to_le32(index);
1515
1579
                err = wl_dev_ioctl(dev, WLC_SET_KEY_PRIMARY, &index,
1516
1580
                                sizeof(index));
1517
 
                if (unlikely(err)) {
 
1581
                if (unlikely(err))
1518
1582
                        WL_ERR("error (%d)\n", err);
1519
 
                }
1520
1583
        }
 
1584
done:
 
1585
        WL_TRACE("Exit\n");
1521
1586
        return err;
1522
1587
}
1523
1588
 
1550
1615
                        return -EINVAL;
1551
1616
                }
1552
1617
 
1553
 
                WL_DBG("Setting the key index %d\n", key.index);
 
1618
                WL_CONN("Setting the key index %d\n", key.index);
1554
1619
                memcpy(key.data, params->key, key.len);
1555
1620
 
1556
1621
                if (params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1574
1639
                switch (params->cipher) {
1575
1640
                case WLAN_CIPHER_SUITE_WEP40:
1576
1641
                        key.algo = CRYPTO_ALGO_WEP1;
1577
 
                        WL_DBG("WLAN_CIPHER_SUITE_WEP40\n");
 
1642
                        WL_CONN("WLAN_CIPHER_SUITE_WEP40\n");
1578
1643
                        break;
1579
1644
                case WLAN_CIPHER_SUITE_WEP104:
1580
1645
                        key.algo = CRYPTO_ALGO_WEP128;
1581
 
                        WL_DBG("WLAN_CIPHER_SUITE_WEP104\n");
 
1646
                        WL_CONN("WLAN_CIPHER_SUITE_WEP104\n");
1582
1647
                        break;
1583
1648
                case WLAN_CIPHER_SUITE_TKIP:
1584
1649
                        key.algo = CRYPTO_ALGO_TKIP;
1585
 
                        WL_DBG("WLAN_CIPHER_SUITE_TKIP\n");
 
1650
                        WL_CONN("WLAN_CIPHER_SUITE_TKIP\n");
1586
1651
                        break;
1587
1652
                case WLAN_CIPHER_SUITE_AES_CMAC:
1588
1653
                        key.algo = CRYPTO_ALGO_AES_CCM;
1589
 
                        WL_DBG("WLAN_CIPHER_SUITE_AES_CMAC\n");
 
1654
                        WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n");
1590
1655
                        break;
1591
1656
                case WLAN_CIPHER_SUITE_CCMP:
1592
1657
                        key.algo = CRYPTO_ALGO_AES_CCM;
1593
 
                        WL_DBG("WLAN_CIPHER_SUITE_CCMP\n");
 
1658
                        WL_CONN("WLAN_CIPHER_SUITE_CCMP\n");
1594
1659
                        break;
1595
1660
                default:
1596
1661
                        WL_ERR("Invalid cipher (0x%x)\n", params->cipher);
1617
1682
        s32 val;
1618
1683
        s32 wsec;
1619
1684
        s32 err = 0;
 
1685
        u8 keybuf[8];
1620
1686
 
1621
 
        WL_DBG("key index (%d)\n", key_idx);
 
1687
        WL_TRACE("Enter\n");
 
1688
        WL_CONN("key index (%d)\n", key_idx);
1622
1689
        CHECK_SYS_UP();
1623
1690
 
1624
 
        if (mac_addr)
 
1691
        if (mac_addr) {
 
1692
                WL_TRACE("Exit");
1625
1693
                return wl_add_keyext(wiphy, dev, key_idx, mac_addr, params);
 
1694
        }
1626
1695
        memset(&key, 0, sizeof(key));
1627
1696
 
1628
1697
        key.len = (u32) params->key_len;
1630
1699
 
1631
1700
        if (unlikely(key.len > sizeof(key.data))) {
1632
1701
                WL_ERR("Too long key length (%u)\n", key.len);
1633
 
                return -EINVAL;
 
1702
                err = -EINVAL;
 
1703
                goto done;
1634
1704
        }
1635
1705
        memcpy(key.data, params->key, key.len);
1636
1706
 
1638
1708
        switch (params->cipher) {
1639
1709
        case WLAN_CIPHER_SUITE_WEP40:
1640
1710
                key.algo = CRYPTO_ALGO_WEP1;
1641
 
                WL_DBG("WLAN_CIPHER_SUITE_WEP40\n");
 
1711
                WL_CONN("WLAN_CIPHER_SUITE_WEP40\n");
1642
1712
                break;
1643
1713
        case WLAN_CIPHER_SUITE_WEP104:
1644
1714
                key.algo = CRYPTO_ALGO_WEP128;
1645
 
                WL_DBG("WLAN_CIPHER_SUITE_WEP104\n");
 
1715
                WL_CONN("WLAN_CIPHER_SUITE_WEP104\n");
1646
1716
                break;
1647
1717
        case WLAN_CIPHER_SUITE_TKIP:
 
1718
                memcpy(keybuf, &key.data[24], sizeof(keybuf));
 
1719
                memcpy(&key.data[24], &key.data[16], sizeof(keybuf));
 
1720
                memcpy(&key.data[16], keybuf, sizeof(keybuf));
1648
1721
                key.algo = CRYPTO_ALGO_TKIP;
1649
 
                WL_DBG("WLAN_CIPHER_SUITE_TKIP\n");
 
1722
                WL_CONN("WLAN_CIPHER_SUITE_TKIP\n");
1650
1723
                break;
1651
1724
        case WLAN_CIPHER_SUITE_AES_CMAC:
1652
1725
                key.algo = CRYPTO_ALGO_AES_CCM;
1653
 
                WL_DBG("WLAN_CIPHER_SUITE_AES_CMAC\n");
 
1726
                WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n");
1654
1727
                break;
1655
1728
        case WLAN_CIPHER_SUITE_CCMP:
1656
1729
                key.algo = CRYPTO_ALGO_AES_CCM;
1657
 
                WL_DBG("WLAN_CIPHER_SUITE_CCMP\n");
 
1730
                WL_CONN("WLAN_CIPHER_SUITE_CCMP\n");
1658
1731
                break;
1659
1732
        default:
1660
1733
                WL_ERR("Invalid cipher (0x%x)\n", params->cipher);
1661
 
                return -EINVAL;
 
1734
                err = -EINVAL;
 
1735
                goto done;
1662
1736
        }
1663
1737
 
1664
1738
        /* Set the new key/index */
1666
1740
        err = wl_dev_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
1667
1741
        if (unlikely(err)) {
1668
1742
                WL_ERR("WLC_SET_KEY error (%d)\n", err);
1669
 
                return err;
 
1743
                goto done;
1670
1744
        }
1671
1745
 
1672
1746
        val = WEP_ENABLED;
1673
1747
        err = wl_dev_intvar_get(dev, "wsec", &wsec);
1674
1748
        if (unlikely(err)) {
1675
1749
                WL_ERR("get wsec error (%d)\n", err);
1676
 
                return err;
 
1750
                goto done;
1677
1751
        }
1678
1752
        wsec &= ~(WEP_ENABLED);
1679
1753
        wsec |= val;
1680
1754
        err = wl_dev_intvar_set(dev, "wsec", wsec);
1681
1755
        if (unlikely(err)) {
1682
1756
                WL_ERR("set wsec error (%d)\n", err);
1683
 
                return err;
 
1757
                goto done;
1684
1758
        }
1685
1759
 
1686
1760
        val = 1;                /* assume shared key. otherwise 0 */
1687
 
        val = htod32(val);
 
1761
        val = cpu_to_le32(val);
1688
1762
        err = wl_dev_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val));
1689
 
        if (unlikely(err)) {
 
1763
        if (unlikely(err))
1690
1764
                WL_ERR("WLC_SET_AUTH error (%d)\n", err);
1691
 
                return err;
1692
 
        }
 
1765
done:
 
1766
        WL_TRACE("Exit\n");
1693
1767
        return err;
1694
1768
}
1695
1769
 
1702
1776
        s32 val;
1703
1777
        s32 wsec;
1704
1778
 
 
1779
        WL_TRACE("Enter\n");
1705
1780
        CHECK_SYS_UP();
1706
1781
        memset(&key, 0, sizeof(key));
1707
1782
 
1709
1784
        key.flags = WL_PRIMARY_KEY;
1710
1785
        key.algo = CRYPTO_ALGO_OFF;
1711
1786
 
1712
 
        WL_DBG("key index (%d)\n", key_idx);
 
1787
        WL_CONN("key index (%d)\n", key_idx);
1713
1788
        /* Set the new key/index */
1714
1789
        swap_key_from_BE(&key);
1715
1790
        err = wl_dev_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
1716
1791
        if (unlikely(err)) {
1717
1792
                if (err == -EINVAL) {
1718
 
                        if (key.index >= DOT11_MAX_DEFAULT_KEYS) {
 
1793
                        if (key.index >= DOT11_MAX_DEFAULT_KEYS)
1719
1794
                                /* we ignore this key index in this case */
1720
 
                                WL_DBG("invalid key index (%d)\n", key_idx);
1721
 
                        }
1722
 
                } else {
 
1795
                                WL_ERR("invalid key index (%d)\n", key_idx);
 
1796
                } else
1723
1797
                        WL_ERR("WLC_SET_KEY error (%d)\n", err);
1724
 
                }
1725
 
                return err;
 
1798
 
 
1799
                /* Ignore this error, may happen during DISASSOC */
 
1800
                err = -EAGAIN;
 
1801
                goto done;
1726
1802
        }
1727
1803
 
1728
1804
        val = 0;
1729
1805
        err = wl_dev_intvar_get(dev, "wsec", &wsec);
1730
1806
        if (unlikely(err)) {
1731
1807
                WL_ERR("get wsec error (%d)\n", err);
1732
 
                return err;
 
1808
                /* Ignore this error, may happen during DISASSOC */
 
1809
                err = -EAGAIN;
 
1810
                goto done;
1733
1811
        }
1734
1812
        wsec &= ~(WEP_ENABLED);
1735
1813
        wsec |= val;
1736
1814
        err = wl_dev_intvar_set(dev, "wsec", wsec);
1737
1815
        if (unlikely(err)) {
1738
1816
                WL_ERR("set wsec error (%d)\n", err);
1739
 
                return err;
 
1817
                /* Ignore this error, may happen during DISASSOC */
 
1818
                err = -EAGAIN;
 
1819
                goto done;
1740
1820
        }
1741
1821
 
1742
1822
        val = 0;                /* assume open key. otherwise 1 */
1743
 
        val = htod32(val);
 
1823
        val = cpu_to_le32(val);
1744
1824
        err = wl_dev_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val));
1745
1825
        if (unlikely(err)) {
1746
1826
                WL_ERR("WLC_SET_AUTH error (%d)\n", err);
1747
 
                return err;
 
1827
                /* Ignore this error, may happen during DISASSOC */
 
1828
                err = -EAGAIN;
1748
1829
        }
 
1830
done:
 
1831
        WL_TRACE("Exit\n");
1749
1832
        return err;
1750
1833
}
1751
1834
 
1761
1844
        s32 wsec;
1762
1845
        s32 err = 0;
1763
1846
 
1764
 
        WL_DBG("key index (%d)\n", key_idx);
 
1847
        WL_TRACE("Enter\n");
 
1848
        WL_CONN("key index (%d)\n", key_idx);
1765
1849
        CHECK_SYS_UP();
1766
1850
 
1767
1851
        memset(&key, 0, sizeof(key));
1768
1852
        key.index = key_idx;
1769
1853
        swap_key_to_BE(&key);
1770
1854
        memset(&params, 0, sizeof(params));
1771
 
        params.key_len = (u8) min_t(u8, DOT11_MAX_KEY_SIZE, key.len);
 
1855
        params.key_len = (u8) min_t(u8, WLAN_MAX_KEY_LEN, key.len);
1772
1856
        memcpy(params.key, key.data, params.key_len);
1773
1857
 
1774
1858
        err = wl_dev_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec));
1775
1859
        if (unlikely(err)) {
1776
1860
                WL_ERR("WLC_GET_WSEC error (%d)\n", err);
1777
 
                return err;
 
1861
                /* Ignore this error, may happen during DISASSOC */
 
1862
                err = -EAGAIN;
 
1863
                goto done;
1778
1864
        }
1779
 
        wsec = dtoh32(wsec);
 
1865
        wsec = le32_to_cpu(wsec);
1780
1866
        switch (wsec) {
1781
1867
        case WEP_ENABLED:
1782
1868
                sec = wl_read_prof(wl, WL_PROF_SEC);
1783
1869
                if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP40) {
1784
1870
                        params.cipher = WLAN_CIPHER_SUITE_WEP40;
1785
 
                        WL_DBG("WLAN_CIPHER_SUITE_WEP40\n");
 
1871
                        WL_CONN("WLAN_CIPHER_SUITE_WEP40\n");
1786
1872
                } else if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP104) {
1787
1873
                        params.cipher = WLAN_CIPHER_SUITE_WEP104;
1788
 
                        WL_DBG("WLAN_CIPHER_SUITE_WEP104\n");
 
1874
                        WL_CONN("WLAN_CIPHER_SUITE_WEP104\n");
1789
1875
                }
1790
1876
                break;
1791
1877
        case TKIP_ENABLED:
1792
1878
                params.cipher = WLAN_CIPHER_SUITE_TKIP;
1793
 
                WL_DBG("WLAN_CIPHER_SUITE_TKIP\n");
 
1879
                WL_CONN("WLAN_CIPHER_SUITE_TKIP\n");
1794
1880
                break;
1795
1881
        case AES_ENABLED:
1796
1882
                params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
1797
 
                WL_DBG("WLAN_CIPHER_SUITE_AES_CMAC\n");
 
1883
                WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n");
1798
1884
                break;
1799
1885
        default:
1800
1886
                WL_ERR("Invalid algo (0x%x)\n", wsec);
1801
 
                return -EINVAL;
 
1887
                err = -EINVAL;
 
1888
                goto done;
1802
1889
        }
1803
 
 
1804
1890
        callback(cookie, &params);
 
1891
 
 
1892
done:
 
1893
        WL_TRACE("Exit\n");
1805
1894
        return err;
1806
1895
}
1807
1896
 
1810
1899
                                    struct net_device *dev, u8 key_idx)
1811
1900
{
1812
1901
        WL_INFO("Not supported\n");
 
1902
 
1813
1903
        CHECK_SYS_UP();
1814
1904
        return -EOPNOTSUPP;
1815
1905
}
1823
1913
        int rssi;
1824
1914
        s32 rate;
1825
1915
        s32 err = 0;
 
1916
        u8 *bssid = wl_read_prof(wl, WL_PROF_BSSID);
1826
1917
 
 
1918
        WL_TRACE("Enter\n");
1827
1919
        CHECK_SYS_UP();
 
1920
 
1828
1921
        if (unlikely
1829
 
            (memcmp(mac, wl_read_prof(wl, WL_PROF_BSSID), ETH_ALEN))) {
1830
 
                WL_ERR("Wrong Mac address\n");
1831
 
                return -ENOENT;
 
1922
            (memcmp(mac, bssid, ETH_ALEN))) {
 
1923
                WL_ERR("Wrong Mac address cfg_mac-%X:%X:%X:%X:%X:%X"
 
1924
                        "wl_bssid-%X:%X:%X:%X:%X:%X\n",
 
1925
                        mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
 
1926
                        bssid[0], bssid[1], bssid[2], bssid[3],
 
1927
                        bssid[4], bssid[5]);
 
1928
                err = -ENOENT;
 
1929
                goto done;
1832
1930
        }
1833
1931
 
1834
1932
        /* Report the current tx rate */
1836
1934
        if (err) {
1837
1935
                WL_ERR("Could not get rate (%d)\n", err);
1838
1936
        } else {
1839
 
                rate = dtoh32(rate);
 
1937
                rate = le32_to_cpu(rate);
1840
1938
                sinfo->filled |= STATION_INFO_TX_BITRATE;
1841
1939
                sinfo->txrate.legacy = rate * 5;
1842
 
                WL_DBG("Rate %d Mbps\n", rate / 2);
 
1940
                WL_CONN("Rate %d Mbps\n", rate / 2);
1843
1941
        }
1844
1942
 
1845
1943
        if (test_bit(WL_STATUS_CONNECTED, &wl->status)) {
1848
1946
                                sizeof(scb_val_t));
1849
1947
                if (unlikely(err)) {
1850
1948
                        WL_ERR("Could not get rssi (%d)\n", err);
1851
 
                        return err;
1852
1949
                }
1853
 
                rssi = dtoh32(scb_val.val);
 
1950
                rssi = le32_to_cpu(scb_val.val);
1854
1951
                sinfo->filled |= STATION_INFO_SIGNAL;
1855
1952
                sinfo->signal = rssi;
1856
 
                WL_DBG("RSSI %d dBm\n", rssi);
 
1953
                WL_CONN("RSSI %d dBm\n", rssi);
1857
1954
        }
1858
1955
 
 
1956
done:
 
1957
        WL_TRACE("Exit\n");
1859
1958
        return err;
1860
1959
}
1861
1960
 
1866
1965
        s32 pm;
1867
1966
        s32 err = 0;
1868
1967
 
 
1968
        WL_TRACE("Enter\n");
1869
1969
        CHECK_SYS_UP();
 
1970
 
1870
1971
        pm = enabled ? PM_FAST : PM_OFF;
1871
 
        pm = htod32(pm);
1872
 
        WL_DBG("power save %s\n", (pm ? "enabled" : "disabled"));
 
1972
        pm = cpu_to_le32(pm);
 
1973
        WL_INFO("power save %s\n", (pm ? "enabled" : "disabled"));
 
1974
 
1873
1975
        err = wl_dev_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
1874
1976
        if (unlikely(err)) {
1875
1977
                if (err == -ENODEV)
1876
 
                        WL_DBG("net_device is not ready yet\n");
 
1978
                        WL_ERR("net_device is not ready yet\n");
1877
1979
                else
1878
1980
                        WL_ERR("error (%d)\n", err);
1879
 
                return err;
1880
1981
        }
 
1982
        WL_TRACE("Exit\n");
1881
1983
        return err;
1882
1984
}
1883
1985
 
1921
2023
        u32 legacy;
1922
2024
        s32 err = 0;
1923
2025
 
 
2026
        WL_TRACE("Enter\n");
1924
2027
        CHECK_SYS_UP();
 
2028
 
1925
2029
        /* addr param is always NULL. ignore it */
1926
2030
        /* Get current rateset */
1927
2031
        err = wl_dev_ioctl(dev, WLC_GET_CURR_RATESET, &rateset,
1928
2032
                        sizeof(rateset));
1929
2033
        if (unlikely(err)) {
1930
2034
                WL_ERR("could not get current rateset (%d)\n", err);
1931
 
                return err;
 
2035
                goto done;
1932
2036
        }
1933
2037
 
1934
 
        rateset.count = dtoh32(rateset.count);
 
2038
        rateset.count = le32_to_cpu(rateset.count);
1935
2039
 
1936
2040
        legacy = wl_find_msb(mask->control[IEEE80211_BAND_2GHZ].legacy);
1937
2041
        if (!legacy)
1939
2043
 
1940
2044
        val = wl_g_rates[legacy - 1].bitrate * 100000;
1941
2045
 
1942
 
        if (val < rateset.count) {
 
2046
        if (val < rateset.count)
1943
2047
                /* Select rate by rateset index */
1944
2048
                rate = rateset.rates[val] & 0x7f;
1945
 
        } else {
 
2049
        else
1946
2050
                /* Specified rate in bps */
1947
2051
                rate = val / 500000;
1948
 
        }
1949
2052
 
1950
 
        WL_DBG("rate %d mbps\n", rate / 2);
 
2053
        WL_CONN("rate %d mbps\n", rate / 2);
1951
2054
 
1952
2055
        /*
1953
2056
         *
1958
2061
        err_a = wl_dev_intvar_set(dev, "a_rate", rate);
1959
2062
        if (unlikely(err_bg && err_a)) {
1960
2063
                WL_ERR("could not set fixed rate (%d) (%d)\n", err_bg, err_a);
1961
 
                return err_bg | err_a;
 
2064
                err = err_bg | err_a;
1962
2065
        }
1963
2066
 
 
2067
done:
 
2068
        WL_TRACE("Exit\n");
1964
2069
        return err;
1965
2070
}
1966
2071
 
1967
2072
static s32 wl_cfg80211_resume(struct wiphy *wiphy)
1968
2073
{
1969
 
        s32 err = 0;
1970
 
 
1971
 
        CHECK_SYS_UP();
1972
 
        wl_invoke_iscan(wiphy_to_wl(wiphy));
1973
 
 
1974
 
        return err;
 
2074
        struct wl_priv *wl = wiphy_to_wl(wiphy);
 
2075
        struct net_device *ndev = wl_to_ndev(wl);
 
2076
 
 
2077
        /*
 
2078
         * Check for WL_STATUS_READY before any function call which
 
2079
         * could result is bus access. Don't block the resume for
 
2080
         * any driver error conditions
 
2081
         */
 
2082
        WL_TRACE("Enter\n");
 
2083
 
 
2084
#if defined(CONFIG_PM_SLEEP)
 
2085
        atomic_set(&dhd_mmc_suspend, false);
 
2086
#endif  /*  defined(CONFIG_PM_SLEEP) */
 
2087
 
 
2088
        if (test_bit(WL_STATUS_READY, &wl->status)) {
 
2089
                /* Turn on Watchdog timer */
 
2090
                wl_os_wd_timer(ndev, dhd_watchdog_ms);
 
2091
                wl_invoke_iscan(wiphy_to_wl(wiphy));
 
2092
        }
 
2093
 
 
2094
        WL_TRACE("Exit\n");
 
2095
        return 0;
1975
2096
}
1976
2097
 
1977
2098
static s32 wl_cfg80211_suspend(struct wiphy *wiphy)
1978
2099
{
1979
2100
        struct wl_priv *wl = wiphy_to_wl(wiphy);
1980
2101
        struct net_device *ndev = wl_to_ndev(wl);
1981
 
        s32 err = 0;
1982
 
 
1983
 
        CHECK_SYS_UP();
 
2102
 
 
2103
        WL_TRACE("Enter\n");
 
2104
 
 
2105
        /*
 
2106
         * Check for WL_STATUS_READY before any function call which
 
2107
         * could result is bus access. Don't block the suspend for
 
2108
         * any driver error conditions
 
2109
         */
 
2110
 
 
2111
        /*
 
2112
         * While going to suspend if associated with AP disassociate
 
2113
         * from AP to save power while system is in suspended state
 
2114
         */
 
2115
        if (test_bit(WL_STATUS_CONNECTED, &wl->status) &&
 
2116
                test_bit(WL_STATUS_READY, &wl->status)) {
 
2117
                WL_INFO("Disassociating from AP"
 
2118
                        " while entering suspend state\n");
 
2119
                wl_link_down(wl);
 
2120
 
 
2121
                /*
 
2122
                 * Make sure WPA_Supplicant receives all the event
 
2123
                 * generated due to DISASSOC call to the fw to keep
 
2124
                 * the state fw and WPA_Supplicant state consistent
 
2125
                 */
 
2126
                rtnl_unlock();
 
2127
                wl_delay(500);
 
2128
                rtnl_lock();
 
2129
        }
1984
2130
 
1985
2131
        set_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
1986
 
        wl_term_iscan(wl);
 
2132
        if (test_bit(WL_STATUS_READY, &wl->status))
 
2133
                wl_term_iscan(wl);
 
2134
 
1987
2135
        if (wl->scan_request) {
1988
 
                cfg80211_scan_done(wl->scan_request, true);     /* true means
1989
 
                                                                 abort */
1990
 
                wl_set_mpc(ndev, 1);
 
2136
                /* Indidate scan abort to cfg80211 layer */
 
2137
                WL_INFO("Terminating scan in progress\n");
 
2138
                cfg80211_scan_done(wl->scan_request, true);
1991
2139
                wl->scan_request = NULL;
1992
2140
        }
1993
2141
        clear_bit(WL_STATUS_SCANNING, &wl->status);
1994
2142
        clear_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
1995
 
 
1996
 
        return err;
 
2143
        clear_bit(WL_STATUS_CONNECTING, &wl->status);
 
2144
        clear_bit(WL_STATUS_CONNECTED, &wl->status);
 
2145
 
 
2146
        /* Inform SDIO stack not to switch off power to the chip */
 
2147
        sdioh_sdio_set_host_pm_flags(MMC_PM_KEEP_POWER);
 
2148
 
 
2149
        /* Turn off watchdog timer */
 
2150
        if (test_bit(WL_STATUS_READY, &wl->status)) {
 
2151
                WL_INFO("Terminate watchdog timer and enable MPC\n");
 
2152
                wl_set_mpc(ndev, 1);
 
2153
                wl_os_wd_timer(ndev, 0);
 
2154
        }
 
2155
 
 
2156
#if defined(CONFIG_PM_SLEEP)
 
2157
        atomic_set(&dhd_mmc_suspend, true);
 
2158
#endif  /*  defined(CONFIG_PM_SLEEP) */
 
2159
 
 
2160
        WL_TRACE("Exit\n");
 
2161
 
 
2162
        return 0;
1997
2163
}
1998
2164
 
1999
2165
static __used s32
2002
2168
{
2003
2169
        int i, j;
2004
2170
 
2005
 
        WL_DBG("No of elements %d\n", pmk_list->pmkids.npmkid);
 
2171
        WL_CONN("No of elements %d\n", pmk_list->pmkids.npmkid);
2006
2172
        for (i = 0; i < pmk_list->pmkids.npmkid; i++) {
2007
 
                WL_DBG("PMKID[%d]: %pM =\n", i,
2008
 
                       &pmk_list->pmkids.pmkid[i].BSSID);
2009
 
                for (j = 0; j < WPA2_PMKID_LEN; j++) {
2010
 
                        WL_DBG("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]);
2011
 
                }
 
2173
                WL_CONN("PMKID[%d]: %pM =\n", i,
 
2174
                        &pmk_list->pmkids.pmkid[i].BSSID);
 
2175
                for (j = 0; j < WLAN_PMKID_LEN; j++)
 
2176
                        WL_CONN("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]);
2012
2177
        }
2013
 
        if (likely(!err)) {
2014
 
                err = wl_dev_bufvar_set(dev, "pmkid_info", (char *)pmk_list,
 
2178
 
 
2179
        if (likely(!err))
 
2180
                wl_dev_bufvar_set(dev, "pmkid_info", (char *)pmk_list,
2015
2181
                                        sizeof(*pmk_list));
2016
 
        }
2017
2182
 
2018
2183
        return err;
2019
2184
}
2026
2191
        s32 err = 0;
2027
2192
        int i;
2028
2193
 
 
2194
        WL_TRACE("Enter\n");
2029
2195
        CHECK_SYS_UP();
 
2196
 
2030
2197
        for (i = 0; i < wl->pmk_list->pmkids.npmkid; i++)
2031
2198
                if (!memcmp(pmksa->bssid, &wl->pmk_list->pmkids.pmkid[i].BSSID,
2032
2199
                            ETH_ALEN))
2035
2202
                memcpy(&wl->pmk_list->pmkids.pmkid[i].BSSID, pmksa->bssid,
2036
2203
                       ETH_ALEN);
2037
2204
                memcpy(&wl->pmk_list->pmkids.pmkid[i].PMKID, pmksa->pmkid,
2038
 
                       WPA2_PMKID_LEN);
 
2205
                       WLAN_PMKID_LEN);
2039
2206
                if (i == wl->pmk_list->pmkids.npmkid)
2040
2207
                        wl->pmk_list->pmkids.npmkid++;
2041
 
        } else {
 
2208
        } else
2042
2209
                err = -EINVAL;
2043
 
        }
2044
 
        WL_DBG("set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n",
 
2210
 
 
2211
        WL_CONN("set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n",
2045
2212
               &wl->pmk_list->pmkids.pmkid[wl->pmk_list->pmkids.npmkid].BSSID);
2046
 
        for (i = 0; i < WPA2_PMKID_LEN; i++) {
2047
 
                WL_DBG("%02x\n",
 
2213
        for (i = 0; i < WLAN_PMKID_LEN; i++)
 
2214
                WL_CONN("%02x\n",
2048
2215
                       wl->pmk_list->pmkids.pmkid[wl->pmk_list->pmkids.npmkid].
2049
2216
                       PMKID[i]);
2050
 
        }
2051
2217
 
2052
2218
        err = wl_update_pmklist(dev, wl->pmk_list, err);
2053
2219
 
 
2220
        WL_TRACE("Exit\n");
2054
2221
        return err;
2055
2222
}
2056
2223
 
2063
2230
        s32 err = 0;
2064
2231
        int i;
2065
2232
 
 
2233
        WL_TRACE("Enter\n");
2066
2234
        CHECK_SYS_UP();
2067
2235
        memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN);
2068
 
        memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WPA2_PMKID_LEN);
 
2236
        memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN);
2069
2237
 
2070
 
        WL_DBG("del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n",
 
2238
        WL_CONN("del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n",
2071
2239
               &pmkid.pmkid[0].BSSID);
2072
 
        for (i = 0; i < WPA2_PMKID_LEN; i++) {
2073
 
                WL_DBG("%02x\n", pmkid.pmkid[0].PMKID[i]);
2074
 
        }
 
2240
        for (i = 0; i < WLAN_PMKID_LEN; i++)
 
2241
                WL_CONN("%02x\n", pmkid.pmkid[0].PMKID[i]);
2075
2242
 
2076
2243
        for (i = 0; i < wl->pmk_list->pmkids.npmkid; i++)
2077
2244
                if (!memcmp
2088
2255
                               ETH_ALEN);
2089
2256
                        memcpy(&wl->pmk_list->pmkids.pmkid[i].PMKID,
2090
2257
                               &wl->pmk_list->pmkids.pmkid[i + 1].PMKID,
2091
 
                               WPA2_PMKID_LEN);
 
2258
                               WLAN_PMKID_LEN);
2092
2259
                }
2093
2260
                wl->pmk_list->pmkids.npmkid--;
2094
 
        } else {
 
2261
        } else
2095
2262
                err = -EINVAL;
2096
 
        }
2097
2263
 
2098
2264
        err = wl_update_pmklist(dev, wl->pmk_list, err);
2099
2265
 
 
2266
        WL_TRACE("Exit\n");
2100
2267
        return err;
2101
2268
 
2102
2269
}
2107
2274
        struct wl_priv *wl = wiphy_to_wl(wiphy);
2108
2275
        s32 err = 0;
2109
2276
 
 
2277
        WL_TRACE("Enter\n");
2110
2278
        CHECK_SYS_UP();
 
2279
 
2111
2280
        memset(wl->pmk_list, 0, sizeof(*wl->pmk_list));
2112
2281
        err = wl_update_pmklist(dev, wl->pmk_list, err);
 
2282
 
 
2283
        WL_TRACE("Exit\n");
2113
2284
        return err;
2114
2285
 
2115
2286
}
2240
2411
                       bss_list->version);
2241
2412
                return -EOPNOTSUPP;
2242
2413
        }
2243
 
        WL_DBG("scanned AP count (%d)\n", bss_list->count);
 
2414
        WL_SCAN("scanned AP count (%d)\n", bss_list->count);
2244
2415
        bi = next_bss(bss_list, bi);
2245
2416
        for_each_bss(bss_list, bi, i) {
2246
2417
                err = wl_inform_single_bss(wl, bi);
2250
2421
        return err;
2251
2422
}
2252
2423
 
 
2424
 
2253
2425
static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi)
2254
2426
{
2255
2427
        struct wiphy *wiphy = wl_to_wiphy(wl);
2256
 
        struct ieee80211_mgmt *mgmt;
2257
 
        struct ieee80211_channel *channel;
 
2428
        struct ieee80211_channel *notify_channel;
 
2429
        struct cfg80211_bss *bss;
2258
2430
        struct ieee80211_supported_band *band;
2259
 
        struct wl_cfg80211_bss_info *notif_bss_info;
2260
 
        struct wl_scan_req *sr = wl_to_sr(wl);
2261
 
        struct beacon_proberesp *beacon_proberesp;
2262
 
        s32 mgmt_type;
2263
 
        u32 signal;
 
2431
        s32 err = 0;
 
2432
        u16 channel;
2264
2433
        u32 freq;
2265
 
        s32 err = 0;
2266
 
 
2267
 
        if (unlikely(dtoh32(bi->length) > WL_BSS_INFO_MAX)) {
2268
 
                WL_DBG("Beacon is larger than buffer. Discarding\n");
2269
 
                return err;
2270
 
        }
2271
 
        notif_bss_info =
2272
 
            kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
2273
 
                    WL_BSS_INFO_MAX, GFP_KERNEL);
2274
 
        if (unlikely(!notif_bss_info)) {
2275
 
                WL_ERR("notif_bss_info alloc failed\n");
2276
 
                return -ENOMEM;
2277
 
        }
2278
 
        mgmt = (struct ieee80211_mgmt *)notif_bss_info->frame_buf;
2279
 
        notif_bss_info->channel =
2280
 
                bi->ctl_ch ? bi->ctl_ch : CHSPEC_CHANNEL(bi->chanspec);
2281
 
 
2282
 
        if (notif_bss_info->channel <= CH_MAX_2G_CHANNEL)
 
2434
        u64 notify_timestamp;
 
2435
        u16 notify_capability;
 
2436
        u16 notify_interval;
 
2437
        u8 *notify_ie;
 
2438
        size_t notify_ielen;
 
2439
        s32 notify_signal;
 
2440
 
 
2441
        if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) {
 
2442
                WL_ERR("Bss info is larger than buffer. Discarding\n");
 
2443
                return 0;
 
2444
        }
 
2445
 
 
2446
        channel = bi->ctl_ch ? bi->ctl_ch :
 
2447
                                CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec));
 
2448
 
 
2449
        if (channel <= CH_MAX_2G_CHANNEL)
2283
2450
                band = wiphy->bands[IEEE80211_BAND_2GHZ];
2284
2451
        else
2285
2452
                band = wiphy->bands[IEEE80211_BAND_5GHZ];
2286
 
        notif_bss_info->rssi = bi->RSSI;
2287
 
        memcpy(mgmt->bssid, &bi->BSSID, ETH_ALEN);
2288
 
        mgmt_type = wl->active_scan ?
2289
 
                IEEE80211_STYPE_PROBE_RESP : IEEE80211_STYPE_BEACON;
2290
 
        if (!memcmp(bi->SSID, sr->ssid.SSID, bi->SSID_len)) {
2291
 
                mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2292
 
                                                        mgmt_type);
2293
 
        }
2294
 
        beacon_proberesp = wl->active_scan ?
2295
 
                (struct beacon_proberesp *)&mgmt->u.probe_resp :
2296
 
                (struct beacon_proberesp *)&mgmt->u.beacon;
2297
 
        beacon_proberesp->timestamp = 0;
2298
 
        beacon_proberesp->beacon_int = cpu_to_le16(bi->beacon_period);
2299
 
        beacon_proberesp->capab_info = cpu_to_le16(bi->capability);
2300
 
        wl_rst_ie(wl);
2301
 
        /*
2302
 
        * wl_add_ie is not necessary because it can only add duplicated
2303
 
        * SSID, rate information to frame_buf
2304
 
        */
2305
 
        /*
2306
 
        * wl_add_ie(wl, WLAN_EID_SSID, bi->SSID_len, bi->SSID);
2307
 
        * wl_add_ie(wl, WLAN_EID_SUPP_RATES, bi->rateset.count,
2308
 
        * bi->rateset.rates);
2309
 
        */
2310
 
        wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
2311
 
        wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
2312
 
                 offsetof(struct wl_cfg80211_bss_info, frame_buf));
2313
 
        notif_bss_info->frame_len =
2314
 
            offsetof(struct ieee80211_mgmt,
2315
 
                     u.beacon.variable) + wl_get_ielen(wl);
2316
 
        freq = ieee80211_channel_to_frequency(notif_bss_info->channel);
2317
 
        channel = ieee80211_get_channel(wiphy, freq);
2318
 
 
2319
 
        WL_DBG("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
2320
 
               bi->SSID,
2321
 
               notif_bss_info->rssi, notif_bss_info->channel,
2322
 
               mgmt->u.beacon.capab_info, &bi->BSSID);
2323
 
 
2324
 
        signal = notif_bss_info->rssi * 100;
2325
 
        if (unlikely(!cfg80211_inform_bss_frame(wiphy, channel, mgmt,
2326
 
                                                le16_to_cpu
2327
 
                                                (notif_bss_info->frame_len),
2328
 
                                                signal, GFP_KERNEL))) {
 
2453
 
 
2454
        freq = ieee80211_channel_to_frequency(channel, band->band);
 
2455
        notify_channel = ieee80211_get_channel(wiphy, freq);
 
2456
 
 
2457
        notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */
 
2458
        notify_capability = le16_to_cpu(bi->capability);
 
2459
        notify_interval = le16_to_cpu(bi->beacon_period);
 
2460
        notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
 
2461
        notify_ielen = le16_to_cpu(bi->ie_length);
 
2462
        notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100;
 
2463
 
 
2464
        WL_CONN("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
 
2465
                        bi->BSSID[0], bi->BSSID[1], bi->BSSID[2],
 
2466
                        bi->BSSID[3], bi->BSSID[4], bi->BSSID[5]);
 
2467
        WL_CONN("Channel: %d(%d)\n", channel, freq);
 
2468
        WL_CONN("Capability: %X\n", notify_capability);
 
2469
        WL_CONN("Beacon interval: %d\n", notify_interval);
 
2470
        WL_CONN("Signal: %d\n", notify_signal);
 
2471
        WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp);
 
2472
 
 
2473
        bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID,
 
2474
                notify_timestamp, notify_capability, notify_interval, notify_ie,
 
2475
                notify_ielen, notify_signal, GFP_KERNEL);
 
2476
 
 
2477
        if (unlikely(!bss)) {
2329
2478
                WL_ERR("cfg80211_inform_bss_frame error\n");
2330
 
                kfree(notif_bss_info);
2331
2479
                return -EINVAL;
2332
2480
        }
2333
 
        kfree(notif_bss_info);
 
2481
 
 
2482
        return err;
 
2483
}
 
2484
 
 
2485
static s32
 
2486
wl_inform_ibss(struct wl_priv *wl, struct net_device *dev, const u8 *bssid)
 
2487
{
 
2488
        struct wiphy *wiphy = wl_to_wiphy(wl);
 
2489
        struct ieee80211_channel *notify_channel;
 
2490
        struct wl_bss_info *bi = NULL;
 
2491
        struct ieee80211_supported_band *band;
 
2492
        u8 *buf = NULL;
 
2493
        s32 err = 0;
 
2494
        u16 channel;
 
2495
        u32 freq;
 
2496
        u64 notify_timestamp;
 
2497
        u16 notify_capability;
 
2498
        u16 notify_interval;
 
2499
        u8 *notify_ie;
 
2500
        size_t notify_ielen;
 
2501
        s32 notify_signal;
 
2502
 
 
2503
        WL_TRACE("Enter\n");
 
2504
 
 
2505
        buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL);
 
2506
        if (buf == NULL) {
 
2507
                WL_ERR("kzalloc() failed\n");
 
2508
                err = -ENOMEM;
 
2509
                goto CleanUp;
 
2510
        }
 
2511
 
 
2512
        *(u32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX);
 
2513
 
 
2514
        err = wl_dev_ioctl(dev, WLC_GET_BSS_INFO, buf, WL_BSS_INFO_MAX);
 
2515
        if (unlikely(err)) {
 
2516
                WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err);
 
2517
                goto CleanUp;
 
2518
        }
 
2519
 
 
2520
        bi = (wl_bss_info_t *)(buf + 4);
 
2521
 
 
2522
        channel = bi->ctl_ch ? bi->ctl_ch :
 
2523
                                CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec));
 
2524
 
 
2525
        if (channel <= CH_MAX_2G_CHANNEL)
 
2526
                band = wiphy->bands[IEEE80211_BAND_2GHZ];
 
2527
        else
 
2528
                band = wiphy->bands[IEEE80211_BAND_5GHZ];
 
2529
 
 
2530
        freq = ieee80211_channel_to_frequency(channel, band->band);
 
2531
        notify_channel = ieee80211_get_channel(wiphy, freq);
 
2532
 
 
2533
        notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */
 
2534
        notify_capability = le16_to_cpu(bi->capability);
 
2535
        notify_interval = le16_to_cpu(bi->beacon_period);
 
2536
        notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
 
2537
        notify_ielen = le16_to_cpu(bi->ie_length);
 
2538
        notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100;
 
2539
 
 
2540
        WL_CONN("channel: %d(%d)\n", channel, freq);
 
2541
        WL_CONN("capability: %X\n", notify_capability);
 
2542
        WL_CONN("beacon interval: %d\n", notify_interval);
 
2543
        WL_CONN("signal: %d\n", notify_signal);
 
2544
        WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp);
 
2545
 
 
2546
        cfg80211_inform_bss(wiphy, notify_channel, bssid,
 
2547
                notify_timestamp, notify_capability, notify_interval,
 
2548
                notify_ie, notify_ielen, notify_signal, GFP_KERNEL);
 
2549
 
 
2550
CleanUp:
 
2551
 
 
2552
        kfree(buf);
 
2553
 
 
2554
        WL_TRACE("Exit\n");
2334
2555
 
2335
2556
        return err;
2336
2557
}
2337
2558
 
2338
2559
static bool wl_is_linkup(struct wl_priv *wl, const wl_event_msg_t *e)
2339
2560
{
2340
 
        u32 event = ntoh32(e->event_type);
2341
 
        u16 flags = ntoh16(e->flags);
 
2561
        u32 event = be32_to_cpu(e->event_type);
 
2562
        u32 status = be32_to_cpu(e->status);
2342
2563
 
2343
 
        if (event == WLC_E_LINK) {
2344
 
                if (flags & WLC_EVENT_MSG_LINK) {
2345
 
                        if (wl_is_ibssmode(wl)) {
2346
 
                                if (wl_is_ibssstarter(wl)) {
2347
 
                                }
2348
 
                        } else {
2349
 
                                return true;
2350
 
                        }
2351
 
                }
 
2564
        if (event == WLC_E_SET_SSID && status == WLC_E_STATUS_SUCCESS) {
 
2565
                WL_CONN("Processing set ssid\n");
 
2566
                wl->link_up = true;
 
2567
                return true;
2352
2568
        }
2353
2569
 
2354
2570
        return false;
2356
2572
 
2357
2573
static bool wl_is_linkdown(struct wl_priv *wl, const wl_event_msg_t *e)
2358
2574
{
2359
 
        u32 event = ntoh32(e->event_type);
2360
 
        u16 flags = ntoh16(e->flags);
 
2575
        u32 event = be32_to_cpu(e->event_type);
 
2576
        u16 flags = be16_to_cpu(e->flags);
2361
2577
 
2362
 
        if (event == WLC_E_DEAUTH_IND || event == WLC_E_DISASSOC_IND) {
 
2578
        if (event == WLC_E_LINK && (!(flags & WLC_EVENT_MSG_LINK))) {
 
2579
                WL_CONN("Processing link down\n");
2363
2580
                return true;
2364
 
        } else if (event == WLC_E_LINK) {
2365
 
                if (!(flags & WLC_EVENT_MSG_LINK))
2366
 
                        return true;
2367
2581
        }
2368
 
 
2369
2582
        return false;
2370
2583
}
2371
2584
 
2372
2585
static bool wl_is_nonetwork(struct wl_priv *wl, const wl_event_msg_t *e)
2373
2586
{
2374
 
        u32 event = ntoh32(e->event_type);
2375
 
        u32 status = ntoh32(e->status);
2376
 
 
2377
 
        if (event == WLC_E_SET_SSID || event == WLC_E_LINK) {
2378
 
                if (status == WLC_E_STATUS_NO_NETWORKS)
2379
 
                        return true;
 
2587
        u32 event = be32_to_cpu(e->event_type);
 
2588
        u32 status = be32_to_cpu(e->status);
 
2589
        u16 flags = be16_to_cpu(e->flags);
 
2590
 
 
2591
        if (event == WLC_E_LINK && status == WLC_E_STATUS_NO_NETWORKS) {
 
2592
                WL_CONN("Processing Link %s & no network found\n",
 
2593
                                flags & WLC_EVENT_MSG_LINK ? "up" : "down");
 
2594
                return true;
 
2595
        }
 
2596
 
 
2597
        if (event == WLC_E_SET_SSID && status != WLC_E_STATUS_SUCCESS) {
 
2598
                WL_CONN("Processing connecting & no network found\n");
 
2599
                return true;
2380
2600
        }
2381
2601
 
2382
2602
        return false;
2386
2606
wl_notify_connect_status(struct wl_priv *wl, struct net_device *ndev,
2387
2607
                         const wl_event_msg_t *e, void *data)
2388
2608
{
2389
 
        bool act;
2390
2609
        s32 err = 0;
2391
2610
 
2392
2611
        if (wl_is_linkup(wl, e)) {
2393
 
                wl_link_up(wl);
 
2612
                WL_CONN("Linkup\n");
2394
2613
                if (wl_is_ibssmode(wl)) {
2395
 
                        cfg80211_ibss_joined(ndev, (s8 *)&e->addr,
2396
 
                                             GFP_KERNEL);
2397
 
                        WL_DBG("joined in IBSS network\n");
2398
 
                } else {
 
2614
                        wl_update_prof(wl, NULL, (void *)e->addr,
 
2615
                                WL_PROF_BSSID);
 
2616
                        wl_inform_ibss(wl, ndev, e->addr);
 
2617
                        cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL);
 
2618
                        clear_bit(WL_STATUS_CONNECTING, &wl->status);
 
2619
                        set_bit(WL_STATUS_CONNECTED, &wl->status);
 
2620
                } else
2399
2621
                        wl_bss_connect_done(wl, ndev, e, data, true);
2400
 
                        WL_DBG("joined in BSS network \"%s\"\n",
2401
 
                               ((struct wlc_ssid *)
2402
 
                                wl_read_prof(wl, WL_PROF_SSID))->SSID);
2403
 
                }
2404
 
                act = true;
2405
 
                wl_update_prof(wl, e, &act, WL_PROF_ACT);
2406
2622
        } else if (wl_is_linkdown(wl, e)) {
2407
 
                cfg80211_disconnected(ndev, 0, NULL, 0, GFP_KERNEL);
2408
 
                clear_bit(WL_STATUS_CONNECTED, &wl->status);
2409
 
                wl_link_down(wl);
 
2623
                WL_CONN("Linkdown\n");
 
2624
                if (wl_is_ibssmode(wl)) {
 
2625
                        if (test_and_clear_bit(WL_STATUS_CONNECTED,
 
2626
                                &wl->status))
 
2627
                                wl_link_down(wl);
 
2628
                } else {
 
2629
                        if (test_and_clear_bit(WL_STATUS_CONNECTED,
 
2630
                                &wl->status)) {
 
2631
                                cfg80211_disconnected(ndev, 0, NULL, 0,
 
2632
                                        GFP_KERNEL);
 
2633
                                wl_link_down(wl);
 
2634
                        }
 
2635
                }
2410
2636
                wl_init_prof(wl->profile);
2411
2637
        } else if (wl_is_nonetwork(wl, e)) {
2412
 
                wl_bss_connect_done(wl, ndev, e, data, false);
 
2638
                if (wl_is_ibssmode(wl))
 
2639
                        clear_bit(WL_STATUS_CONNECTING, &wl->status);
 
2640
                else
 
2641
                        wl_bss_connect_done(wl, ndev, e, data, false);
2413
2642
        }
2414
2643
 
2415
2644
        return err;
2419
2648
wl_notify_roaming_status(struct wl_priv *wl, struct net_device *ndev,
2420
2649
                         const wl_event_msg_t *e, void *data)
2421
2650
{
2422
 
        bool act;
2423
2651
        s32 err = 0;
 
2652
        u32 event = be32_to_cpu(e->event_type);
 
2653
        u32 status = be32_to_cpu(e->status);
2424
2654
 
2425
 
        wl_bss_roaming_done(wl, ndev, e, data);
2426
 
        act = true;
2427
 
        wl_update_prof(wl, e, &act, WL_PROF_ACT);
 
2655
        if (event == WLC_E_ROAM && status == WLC_E_STATUS_SUCCESS) {
 
2656
                if (test_bit(WL_STATUS_CONNECTED, &wl->status))
 
2657
                        wl_bss_roaming_done(wl, ndev, e, data);
 
2658
                else
 
2659
                        wl_bss_connect_done(wl, ndev, e, data, true);
 
2660
        }
2428
2661
 
2429
2662
        return err;
2430
2663
}
2436
2669
        u32 buflen;
2437
2670
 
2438
2671
        buflen = bcm_mkiovar(name, buf, len, wl->ioctl_buf, WL_IOCTL_LEN_MAX);
2439
 
        BUG_ON(unlikely(!buflen));
 
2672
        BUG_ON(!buflen);
2440
2673
 
2441
2674
        return wl_dev_ioctl(dev, WLC_SET_VAR, wl->ioctl_buf, buflen);
2442
2675
}
2450
2683
        s32 err = 0;
2451
2684
 
2452
2685
        len = bcm_mkiovar(name, NULL, 0, wl->ioctl_buf, WL_IOCTL_LEN_MAX);
2453
 
        BUG_ON(unlikely(!len));
 
2686
        BUG_ON(!len);
2454
2687
        err = wl_dev_ioctl(dev, WLC_GET_VAR, (void *)wl->ioctl_buf,
2455
2688
                        WL_IOCTL_LEN_MAX);
2456
2689
        if (unlikely(err)) {
2471
2704
        u32 resp_len;
2472
2705
        s32 err = 0;
2473
2706
 
 
2707
        wl_clear_assoc_ies(wl);
 
2708
 
2474
2709
        err = wl_dev_bufvar_get(ndev, "assoc_info", wl->extra_buf,
2475
2710
                                WL_ASSOC_INFO_MAX);
2476
2711
        if (unlikely(err)) {
2508
2743
                conn_info->resp_ie_len = 0;
2509
2744
                conn_info->resp_ie = NULL;
2510
2745
        }
2511
 
        WL_DBG("req len (%d) resp len (%d)\n",
 
2746
        WL_CONN("req len (%d) resp len (%d)\n",
2512
2747
               conn_info->req_ie_len, conn_info->resp_ie_len);
2513
2748
 
2514
2749
        return err;
2515
2750
}
2516
2751
 
 
2752
static void wl_clear_assoc_ies(struct wl_priv *wl)
 
2753
{
 
2754
        struct wl_connect_info *conn_info = wl_to_conn(wl);
 
2755
 
 
2756
        kfree(conn_info->req_ie);
 
2757
        conn_info->req_ie = NULL;
 
2758
        conn_info->req_ie_len = 0;
 
2759
        kfree(conn_info->resp_ie);
 
2760
        conn_info->resp_ie = NULL;
 
2761
        conn_info->resp_ie_len = 0;
 
2762
}
 
2763
 
 
2764
 
2517
2765
static void wl_ch_to_chanspec(int ch, struct wl_join_params *join_params,
2518
2766
        size_t *join_params_size)
2519
2767
{
2523
2771
                join_params->params.chanspec_num = 1;
2524
2772
                join_params->params.chanspec_list[0] = ch;
2525
2773
 
2526
 
                if (join_params->params.chanspec_list[0])
 
2774
                if (join_params->params.chanspec_list[0] <= CH_MAX_2G_CHANNEL)
2527
2775
                        chanspec |= WL_CHANSPEC_BAND_2G;
2528
2776
                else
2529
2777
                        chanspec |= WL_CHANSPEC_BAND_5G;
2537
2785
                join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK;
2538
2786
                join_params->params.chanspec_list[0] |= chanspec;
2539
2787
                join_params->params.chanspec_list[0] =
2540
 
                htodchanspec(join_params->params.chanspec_list[0]);
 
2788
                cpu_to_le16(join_params->params.chanspec_list[0]);
2541
2789
 
2542
2790
                join_params->params.chanspec_num =
2543
 
                        htod32(join_params->params.chanspec_num);
 
2791
                        cpu_to_le32(join_params->params.chanspec_num);
2544
2792
 
2545
 
                WL_DBG("join_params->params.chanspec_list[0]= %#X, channel %d, chanspec %#X\n",
 
2793
                WL_CONN("join_params->params.chanspec_list[0]= %#X,"
 
2794
                        "channel %d, chanspec %#X\n",
2546
2795
                       join_params->params.chanspec_list[0], ch, chanspec);
2547
2796
        }
2548
2797
}
2549
2798
 
2550
2799
static s32 wl_update_bss_info(struct wl_priv *wl)
2551
2800
{
2552
 
        struct cfg80211_bss *bss;
2553
2801
        struct wl_bss_info *bi;
2554
2802
        struct wlc_ssid *ssid;
2555
2803
        struct bcm_tlv *tim;
2559
2807
        u8 *ie;
2560
2808
        s32 err = 0;
2561
2809
 
 
2810
        WL_TRACE("Enter\n");
2562
2811
        if (wl_is_ibssmode(wl))
2563
2812
                return err;
2564
2813
 
2565
2814
        ssid = (struct wlc_ssid *)wl_read_prof(wl, WL_PROF_SSID);
2566
 
        bss =
2567
 
            cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
2568
 
                             ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS,
2569
 
                             WLAN_CAPABILITY_ESS);
2570
 
 
2571
 
        rtnl_lock();
2572
 
        if (unlikely(!bss)) {
2573
 
                WL_DBG("Could not find the AP\n");
2574
 
                *(u32 *) wl->extra_buf = htod32(WL_EXTRA_BUF_MAX);
2575
 
                err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_BSS_INFO,
2576
 
                                wl->extra_buf, WL_EXTRA_BUF_MAX);
2577
 
                if (unlikely(err)) {
2578
 
                        WL_ERR("Could not get bss info %d\n", err);
2579
 
                        goto update_bss_info_out;
2580
 
                }
2581
 
                bi = (struct wl_bss_info *)(wl->extra_buf + 4);
2582
 
                if (unlikely(memcmp(&bi->BSSID, &wl->bssid, ETH_ALEN))) {
2583
 
                        err = -EIO;
2584
 
                        goto update_bss_info_out;
2585
 
                }
2586
 
                err = wl_inform_single_bss(wl, bi);
2587
 
                if (unlikely(err))
2588
 
                        goto update_bss_info_out;
2589
 
 
2590
 
                ie = ((u8 *)bi) + bi->ie_offset;
2591
 
                ie_len = bi->ie_length;
2592
 
                beacon_interval = cpu_to_le16(bi->beacon_period);
2593
 
        } else {
2594
 
                WL_DBG("Found the AP in the list - BSSID %pM\n", bss->bssid);
2595
 
                ie = bss->information_elements;
2596
 
                ie_len = bss->len_information_elements;
2597
 
                beacon_interval = bss->beacon_interval;
2598
 
                cfg80211_put_bss(bss);
 
2815
 
 
2816
        *(u32 *)wl->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX);
 
2817
        err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_BSS_INFO,
 
2818
                        wl->extra_buf, WL_EXTRA_BUF_MAX);
 
2819
        if (unlikely(err)) {
 
2820
                WL_ERR("Could not get bss info %d\n", err);
 
2821
                goto update_bss_info_out;
2599
2822
        }
2600
2823
 
 
2824
        bi = (struct wl_bss_info *)(wl->extra_buf + 4);
 
2825
        err = wl_inform_single_bss(wl, bi);
 
2826
        if (unlikely(err))
 
2827
                goto update_bss_info_out;
 
2828
 
 
2829
        ie = ((u8 *)bi) + bi->ie_offset;
 
2830
        ie_len = bi->ie_length;
 
2831
        beacon_interval = cpu_to_le16(bi->beacon_period);
 
2832
 
2601
2833
        tim = bcm_parse_tlvs(ie, ie_len, WLAN_EID_TIM);
2602
 
        if (tim) {
 
2834
        if (tim)
2603
2835
                dtim_period = tim->data[1];
2604
 
        } else {
 
2836
        else {
2605
2837
                /*
2606
2838
                * active scan was done so we could not get dtim
2607
2839
                * information out of probe response.
2608
2840
                * so we speficially query dtim information to dongle.
2609
2841
                */
2610
 
                err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_DTIMPRD,
2611
 
                        &dtim_period, sizeof(dtim_period));
 
2842
                u32 var;
 
2843
                err = wl_dev_intvar_get(wl_to_ndev(wl), "dtim_assoc", &var);
2612
2844
                if (unlikely(err)) {
2613
 
                        WL_ERR("WLC_GET_DTIMPRD error (%d)\n", err);
 
2845
                        WL_ERR("wl dtim_assoc failed (%d)\n", err);
2614
2846
                        goto update_bss_info_out;
2615
2847
                }
 
2848
                dtim_period = (u8)var;
2616
2849
        }
2617
2850
 
2618
2851
        wl_update_prof(wl, NULL, &beacon_interval, WL_PROF_BEACONINT);
2619
2852
        wl_update_prof(wl, NULL, &dtim_period, WL_PROF_DTIMPERIOD);
2620
2853
 
2621
2854
update_bss_info_out:
2622
 
        rtnl_unlock();
 
2855
        WL_TRACE("Exit");
2623
2856
        return err;
2624
2857
}
2625
2858
 
2630
2863
        struct wl_connect_info *conn_info = wl_to_conn(wl);
2631
2864
        s32 err = 0;
2632
2865
 
 
2866
        WL_TRACE("Enter\n");
 
2867
 
2633
2868
        wl_get_assoc_ies(wl);
2634
 
        memcpy(&wl->bssid, &e->addr, ETH_ALEN);
 
2869
        wl_update_prof(wl, NULL, &e->addr, WL_PROF_BSSID);
2635
2870
        wl_update_bss_info(wl);
2636
 
        cfg80211_roamed(ndev,
2637
 
                        (u8 *)&wl->bssid,
 
2871
 
 
2872
        cfg80211_roamed(ndev, NULL,
 
2873
                        (u8 *)wl_read_prof(wl, WL_PROF_BSSID),
2638
2874
                        conn_info->req_ie, conn_info->req_ie_len,
2639
2875
                        conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
2640
 
        WL_DBG("Report roaming result\n");
 
2876
        WL_CONN("Report roaming result\n");
2641
2877
 
2642
2878
        set_bit(WL_STATUS_CONNECTED, &wl->status);
2643
 
 
 
2879
        WL_TRACE("Exit\n");
2644
2880
        return err;
2645
2881
}
2646
2882
 
2651
2887
        struct wl_connect_info *conn_info = wl_to_conn(wl);
2652
2888
        s32 err = 0;
2653
2889
 
2654
 
        wl_get_assoc_ies(wl);
2655
 
        memcpy(&wl->bssid, &e->addr, ETH_ALEN);
2656
 
        wl_update_bss_info(wl);
 
2890
        WL_TRACE("Enter\n");
 
2891
 
2657
2892
        if (test_and_clear_bit(WL_STATUS_CONNECTING, &wl->status)) {
 
2893
                if (completed) {
 
2894
                        wl_get_assoc_ies(wl);
 
2895
                        wl_update_prof(wl, NULL, &e->addr, WL_PROF_BSSID);
 
2896
                        wl_update_bss_info(wl);
 
2897
                }
2658
2898
                cfg80211_connect_result(ndev,
2659
 
                                        (u8 *)&wl->bssid,
 
2899
                                        (u8 *)wl_read_prof(wl, WL_PROF_BSSID),
2660
2900
                                        conn_info->req_ie,
2661
2901
                                        conn_info->req_ie_len,
2662
2902
                                        conn_info->resp_ie,
2663
2903
                                        conn_info->resp_ie_len,
2664
2904
                                        completed ? WLAN_STATUS_SUCCESS : WLAN_STATUS_AUTH_TIMEOUT,
2665
2905
                                        GFP_KERNEL);
2666
 
                WL_DBG("Report connect result - connection %s\n",
2667
 
                       completed ? "succeeded" : "failed");
2668
 
        } else {
2669
 
                cfg80211_roamed(ndev,
2670
 
                                (u8 *)&wl->bssid,
2671
 
                                conn_info->req_ie, conn_info->req_ie_len,
2672
 
                                conn_info->resp_ie, conn_info->resp_ie_len,
2673
 
                                GFP_KERNEL);
2674
 
                WL_DBG("Report roaming result\n");
 
2906
                if (completed)
 
2907
                        set_bit(WL_STATUS_CONNECTED, &wl->status);
 
2908
                WL_CONN("Report connect result - connection %s\n",
 
2909
                                completed ? "succeeded" : "failed");
2675
2910
        }
2676
 
        set_bit(WL_STATUS_CONNECTED, &wl->status);
2677
 
 
 
2911
        WL_TRACE("Exit\n");
2678
2912
        return err;
2679
2913
}
2680
2914
 
2682
2916
wl_notify_mic_status(struct wl_priv *wl, struct net_device *ndev,
2683
2917
                     const wl_event_msg_t *e, void *data)
2684
2918
{
2685
 
        u16 flags = ntoh16(e->flags);
 
2919
        u16 flags = be16_to_cpu(e->flags);
2686
2920
        enum nl80211_key_type key_type;
2687
2921
 
2688
2922
        rtnl_lock();
2706
2940
        struct wl_scan_results *bss_list;
2707
2941
        u32 len = WL_SCAN_BUF_MAX;
2708
2942
        s32 err = 0;
2709
 
 
2710
 
        if (wl->iscan_on && wl->iscan_kickstart)
 
2943
        bool scan_abort = false;
 
2944
 
 
2945
        WL_TRACE("Enter\n");
 
2946
 
 
2947
        if (wl->iscan_on && wl->iscan_kickstart) {
 
2948
                WL_TRACE("Exit\n");
2711
2949
                return wl_wakeup_iscan(wl_to_iscan(wl));
 
2950
        }
2712
2951
 
2713
2952
        if (unlikely(!test_and_clear_bit(WL_STATUS_SCANNING, &wl->status))) {
2714
2953
                WL_ERR("Scan complete while device not scanning\n");
2715
 
                return -EINVAL;
2716
 
        }
2717
 
        if (unlikely(!wl->scan_request)) {
2718
 
        }
2719
 
        rtnl_lock();
 
2954
                scan_abort = true;
 
2955
                err = -EINVAL;
 
2956
                goto scan_done_out;
 
2957
        }
 
2958
 
2720
2959
        err = wl_dev_ioctl(ndev, WLC_GET_CHANNEL, &channel_inform,
2721
2960
                        sizeof(channel_inform));
2722
2961
        if (unlikely(err)) {
2723
2962
                WL_ERR("scan busy (%d)\n", err);
 
2963
                scan_abort = true;
2724
2964
                goto scan_done_out;
2725
2965
        }
2726
 
        channel_inform.scan_channel = dtoh32(channel_inform.scan_channel);
 
2966
        channel_inform.scan_channel = le32_to_cpu(channel_inform.scan_channel);
2727
2967
        if (unlikely(channel_inform.scan_channel)) {
2728
2968
 
2729
 
                WL_DBG("channel_inform.scan_channel (%d)\n",
 
2969
                WL_CONN("channel_inform.scan_channel (%d)\n",
2730
2970
                       channel_inform.scan_channel);
2731
2971
        }
2732
2972
        wl->bss_list = wl->scan_results;
2733
2973
        bss_list = wl->bss_list;
2734
2974
        memset(bss_list, 0, len);
2735
 
        bss_list->buflen = htod32(len);
 
2975
        bss_list->buflen = cpu_to_le32(len);
 
2976
 
2736
2977
        err = wl_dev_ioctl(ndev, WLC_SCAN_RESULTS, bss_list, len);
2737
2978
        if (unlikely(err)) {
2738
2979
                WL_ERR("%s Scan_results error (%d)\n", ndev->name, err);
2739
2980
                err = -EINVAL;
 
2981
                scan_abort = true;
2740
2982
                goto scan_done_out;
2741
2983
        }
2742
 
        bss_list->buflen = dtoh32(bss_list->buflen);
2743
 
        bss_list->version = dtoh32(bss_list->version);
2744
 
        bss_list->count = dtoh32(bss_list->count);
 
2984
        bss_list->buflen = le32_to_cpu(bss_list->buflen);
 
2985
        bss_list->version = le32_to_cpu(bss_list->version);
 
2986
        bss_list->count = le32_to_cpu(bss_list->count);
2745
2987
 
2746
2988
        err = wl_inform_bss(wl);
2747
 
        if (err)
 
2989
        if (err) {
 
2990
                scan_abort = true;
2748
2991
                goto scan_done_out;
 
2992
        }
2749
2993
 
2750
2994
scan_done_out:
2751
2995
        if (wl->scan_request) {
2752
 
                cfg80211_scan_done(wl->scan_request, false);
 
2996
                WL_SCAN("calling cfg80211_scan_done\n");
 
2997
                cfg80211_scan_done(wl->scan_request, scan_abort);
2753
2998
                wl_set_mpc(ndev, 1);
2754
2999
                wl->scan_request = NULL;
2755
3000
        }
2756
 
        rtnl_unlock();
 
3001
 
 
3002
        WL_TRACE("Exit\n");
 
3003
 
2757
3004
        return err;
2758
3005
}
2759
3006
 
2776
3023
{
2777
3024
        memset(el, 0, sizeof(*el));
2778
3025
        el->handler[WLC_E_SCAN_COMPLETE] = wl_notify_scan_status;
2779
 
        el->handler[WLC_E_JOIN] = wl_notify_connect_status;
2780
3026
        el->handler[WLC_E_LINK] = wl_notify_connect_status;
2781
 
        el->handler[WLC_E_DEAUTH_IND] = wl_notify_connect_status;
2782
 
        el->handler[WLC_E_DISASSOC_IND] = wl_notify_connect_status;
2783
 
        el->handler[WLC_E_ASSOC_IND] = wl_notify_connect_status;
2784
 
        el->handler[WLC_E_REASSOC_IND] = wl_notify_connect_status;
2785
3027
        el->handler[WLC_E_ROAM] = wl_notify_roaming_status;
2786
3028
        el->handler[WLC_E_MIC_ERROR] = wl_notify_mic_status;
2787
3029
        el->handler[WLC_E_SET_SSID] = wl_notify_connect_status;
2915
3157
                return;
2916
3158
        }
2917
3159
        if (likely(wl->scan_request)) {
 
3160
                WL_SCAN("ISCAN Completed scan: %s\n",
 
3161
                                aborted ? "Aborted" : "Done");
2918
3162
                cfg80211_scan_done(wl->scan_request, aborted);
2919
3163
                wl_set_mpc(ndev, 1);
2920
3164
                wl->scan_request = NULL;
2925
3169
static s32 wl_wakeup_iscan(struct wl_iscan_ctrl *iscan)
2926
3170
{
2927
3171
        if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) {
2928
 
                WL_DBG("wake up iscan\n");
 
3172
                WL_SCAN("wake up iscan\n");
2929
3173
                up(&iscan->sync);
2930
3174
                return 0;
2931
3175
        }
2950
3194
        results->count = 0;
2951
3195
 
2952
3196
        memset(&list, 0, sizeof(list));
2953
 
        list.results.buflen = htod32(WL_ISCAN_BUF_MAX);
 
3197
        list.results.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX);
2954
3198
        err = wl_dev_iovar_getbuf(iscan->dev, "iscanresults", &list,
2955
3199
                                WL_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf,
2956
3200
                                WL_ISCAN_BUF_MAX);
2958
3202
                WL_ERR("error (%d)\n", err);
2959
3203
                return err;
2960
3204
        }
2961
 
        results->buflen = dtoh32(results->buflen);
2962
 
        results->version = dtoh32(results->version);
2963
 
        results->count = dtoh32(results->count);
2964
 
        WL_DBG("results->count = %d\n", results->count);
2965
 
        WL_DBG("results->buflen = %d\n", results->buflen);
2966
 
        *status = dtoh32(list_buf->status);
 
3205
        results->buflen = le32_to_cpu(results->buflen);
 
3206
        results->version = le32_to_cpu(results->version);
 
3207
        results->count = le32_to_cpu(results->count);
 
3208
        WL_SCAN("results->count = %d\n", results->count);
 
3209
        WL_SCAN("results->buflen = %d\n", results->buflen);
 
3210
        *status = le32_to_cpu(list_buf->status);
2967
3211
        *bss_list = results;
2968
3212
 
2969
3213
        return err;
3056
3300
                del_timer_sync(&iscan->timer);
3057
3301
                iscan->timer_on = 0;
3058
3302
        }
3059
 
        WL_DBG("%s was terminated\n", __func__);
 
3303
        WL_SCAN("ISCAN thread terminated\n");
3060
3304
 
3061
3305
        return 0;
3062
3306
}
3067
3311
 
3068
3312
        if (iscan) {
3069
3313
                iscan->timer_on = 0;
3070
 
                WL_DBG("timer expired\n");
 
3314
                WL_SCAN("timer expired\n");
3071
3315
                wl_wakeup_iscan(iscan);
3072
3316
        }
3073
3317
}
3194
3438
                WL_ERR("wl_cfg80211_dev is invalid\n");
3195
3439
                return -ENOMEM;
3196
3440
        }
3197
 
        WL_DBG("func %p\n", wl_cfg80211_get_sdio_func());
 
3441
        WL_INFO("func %p\n", wl_cfg80211_get_sdio_func());
3198
3442
        wdev = wl_alloc_wdev(sizeof(struct wl_iface), &wl_cfg80211_get_sdio_func()->dev);
3199
3443
        if (IS_ERR(wdev))
3200
3444
                return -ENOMEM;
3214
3458
                goto cfg80211_attach_out;
3215
3459
        }
3216
3460
        wl_set_drvdata(wl_cfg80211_dev, ci);
3217
 
        set_bit(WL_STATUS_READY, &wl->status);
3218
3461
 
3219
3462
        return err;
3220
3463
 
3258
3501
                        WL_ERR("event queue empty...\n");
3259
3502
                        BUG();
3260
3503
                }
3261
 
                WL_DBG("event type (%d)\n", e->etype);
 
3504
                WL_INFO("event type (%d)\n", e->etype);
3262
3505
                if (wl->el.handler[e->etype]) {
3263
3506
                        wl->el.handler[e->etype] (wl, wl_to_ndev(wl), &e->emsg,
3264
3507
                                                  e->edata);
3265
3508
                } else {
3266
 
                        WL_DBG("Unknown Event (%d): ignoring\n", e->etype);
 
3509
                        WL_INFO("Unknown Event (%d): ignoring\n", e->etype);
3267
3510
                }
3268
3511
                wl_put_event(e);
3269
3512
        }
3270
 
        WL_DBG("%s was terminated\n", __func__);
 
3513
        WL_INFO("was terminated\n");
3271
3514
        return 0;
3272
3515
}
3273
3516
 
3274
3517
void
3275
3518
wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t * e, void *data)
3276
3519
{
3277
 
        u32 event_type = ntoh32(e->event_type);
 
3520
        u32 event_type = be32_to_cpu(e->event_type);
3278
3521
        struct wl_priv *wl = ndev_to_wl(ndev);
3279
 
#if (WL_DBG_LEVEL > 0)
3280
 
        s8 *estr = (event_type <= sizeof(wl_dbg_estr) / WL_DBG_ESTR_MAX - 1) ?
3281
 
            wl_dbg_estr[event_type] : (s8 *) "Unknown";
3282
 
#endif                          /* (WL_DBG_LEVEL > 0) */
3283
 
        WL_DBG("event_type (%d):" "WLC_E_" "%s\n", event_type, estr);
 
3522
 
3284
3523
        if (likely(!wl_enq_event(wl, event_type, e, data)))
3285
3524
                wl_wakeup_event(wl);
3286
3525
}
3373
3612
static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype)
3374
3613
{
3375
3614
        s32 infra = 0;
3376
 
        s32 ap = 0;
3377
3615
        s32 err = 0;
3378
3616
 
3379
3617
        switch (iftype) {
3384
3622
                err = -EINVAL;
3385
3623
                return err;
3386
3624
        case NL80211_IFTYPE_ADHOC:
 
3625
                infra = 0;
3387
3626
                break;
3388
3627
        case NL80211_IFTYPE_STATION:
3389
3628
                infra = 1;
3393
3632
                WL_ERR("invalid type (%d)\n", iftype);
3394
3633
                return err;
3395
3634
        }
3396
 
        infra = htod32(infra);
3397
 
        ap = htod32(ap);
3398
 
        WL_DBG("%s ap (%d), infra (%d)\n", ndev->name, ap, infra);
 
3635
        infra = cpu_to_le32(infra);
3399
3636
        err = wl_dev_ioctl(ndev, WLC_SET_INFRA, &infra, sizeof(infra));
3400
3637
        if (unlikely(err)) {
3401
3638
                WL_ERR("WLC_SET_INFRA error (%d)\n", err);
3402
3639
                return err;
3403
3640
        }
3404
 
        err = wl_dev_ioctl(ndev, WLC_SET_AP, &ap, sizeof(ap));
3405
 
        if (unlikely(err)) {
3406
 
                WL_ERR("WLC_SET_AP error (%d)\n", err);
3407
 
                return err;
3408
 
        }
3409
3641
 
3410
 
        return -EINPROGRESS;
 
3642
        return 0;
3411
3643
}
3412
3644
 
3413
3645
#ifndef EMBEDDED_PLATFORM
3468
3700
}
3469
3701
 
3470
3702
static s32
3471
 
wl_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout)
3472
 
{
3473
 
        s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
3474
 
                                                 '\0' + bitvec  */
3475
 
        s32 err = 0;
3476
 
 
3477
 
        /* Setup timeout if Beacons are lost and roam is
3478
 
                 off to report link down */
3479
 
        if (roamvar) {
3480
 
                bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf,
3481
 
                            sizeof(iovbuf));
3482
 
                err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
3483
 
                if (unlikely(err)) {
3484
 
                        WL_ERR("bcn_timeout error (%d)\n", err);
3485
 
                        goto dongle_rom_out;
3486
 
                }
3487
 
        }
3488
 
        /* Enable/Disable built-in roaming to allow supplicant
3489
 
                 to take care of roaming */
3490
 
        bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf, sizeof(iovbuf));
3491
 
        err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
3492
 
        if (unlikely(err)) {
3493
 
                WL_ERR("roam_off error (%d)\n", err);
3494
 
                goto dongle_rom_out;
3495
 
        }
3496
 
dongle_rom_out:
3497
 
        return err;
3498
 
}
3499
 
 
3500
 
static s32 wl_dongle_eventmsg(struct net_device *ndev)
3501
 
{
3502
 
 
3503
 
        s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
3504
 
                                                 '\0' + bitvec  */
3505
 
        s8 eventmask[WL_EVENTING_MASK_LEN];
3506
 
        s32 err = 0;
3507
 
 
3508
 
        /* Setup event_msgs */
3509
 
        bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
3510
 
                    sizeof(iovbuf));
3511
 
        err = wl_dev_ioctl(ndev, WLC_GET_VAR, iovbuf, sizeof(iovbuf));
3512
 
        if (unlikely(err)) {
3513
 
                WL_ERR("Get event_msgs error (%d)\n", err);
3514
 
                goto dongle_eventmsg_out;
3515
 
        }
3516
 
        memcpy(eventmask, iovbuf, WL_EVENTING_MASK_LEN);
3517
 
 
3518
 
        setbit(eventmask, WLC_E_SET_SSID);
3519
 
        setbit(eventmask, WLC_E_PRUNE);
3520
 
        setbit(eventmask, WLC_E_AUTH);
3521
 
        setbit(eventmask, WLC_E_REASSOC);
3522
 
        setbit(eventmask, WLC_E_REASSOC_IND);
3523
 
        setbit(eventmask, WLC_E_DEAUTH_IND);
3524
 
        setbit(eventmask, WLC_E_DISASSOC_IND);
3525
 
        setbit(eventmask, WLC_E_DISASSOC);
3526
 
        setbit(eventmask, WLC_E_JOIN);
3527
 
        setbit(eventmask, WLC_E_ASSOC_IND);
3528
 
        setbit(eventmask, WLC_E_PSK_SUP);
3529
 
        setbit(eventmask, WLC_E_LINK);
3530
 
        setbit(eventmask, WLC_E_NDIS_LINK);
3531
 
        setbit(eventmask, WLC_E_MIC_ERROR);
3532
 
        setbit(eventmask, WLC_E_PMKID_CACHE);
3533
 
        setbit(eventmask, WLC_E_TXFAIL);
3534
 
        setbit(eventmask, WLC_E_JOIN_START);
3535
 
        setbit(eventmask, WLC_E_SCAN_COMPLETE);
3536
 
 
3537
 
        bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
3538
 
                    sizeof(iovbuf));
3539
 
        err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
3540
 
        if (unlikely(err)) {
3541
 
                WL_ERR("Set event_msgs error (%d)\n", err);
3542
 
                goto dongle_eventmsg_out;
3543
 
        }
3544
 
 
3545
 
dongle_eventmsg_out:
3546
 
        return err;
3547
 
}
3548
 
 
3549
 
static s32
3550
 
wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
3551
 
                   s32 scan_unassoc_time)
3552
 
{
3553
 
        s32 err = 0;
3554
 
 
3555
 
        err = wl_dev_ioctl(ndev, WLC_SET_SCAN_CHANNEL_TIME, &scan_assoc_time,
3556
 
                        sizeof(scan_assoc_time));
3557
 
        if (err) {
3558
 
                if (err == -EOPNOTSUPP) {
3559
 
                        WL_INFO("Scan assoc time is not supported\n");
3560
 
                } else {
3561
 
                        WL_ERR("Scan assoc time error (%d)\n", err);
3562
 
                }
3563
 
                goto dongle_scantime_out;
3564
 
        }
3565
 
        err = wl_dev_ioctl(ndev, WLC_SET_SCAN_UNASSOC_TIME, &scan_unassoc_time,
3566
 
                        sizeof(scan_unassoc_time));
3567
 
        if (err) {
3568
 
                if (err == -EOPNOTSUPP) {
3569
 
                        WL_INFO("Scan unassoc time is not supported\n");
3570
 
                } else {
3571
 
                        WL_ERR("Scan unassoc time error (%d)\n", err);
3572
 
                }
3573
 
                goto dongle_scantime_out;
3574
 
        }
3575
 
 
3576
 
dongle_scantime_out:
3577
 
        return err;
3578
 
}
3579
 
 
3580
 
static s32
3581
3703
wl_dongle_offload(struct net_device *ndev, s32 arpoe, s32 arp_ol)
3582
3704
{
3583
3705
        s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
3656
3778
        pkt_filterp = (struct wl_pkt_filter *)(buf + str_len + 1);
3657
3779
 
3658
3780
        /* Parse packet filter id. */
3659
 
        pkt_filter.id = htod32(100);
 
3781
        pkt_filter.id = cpu_to_le32(100);
3660
3782
 
3661
3783
        /* Parse filter polarity. */
3662
 
        pkt_filter.negate_match = htod32(0);
 
3784
        pkt_filter.negate_match = cpu_to_le32(0);
3663
3785
 
3664
3786
        /* Parse filter type. */
3665
 
        pkt_filter.type = htod32(0);
 
3787
        pkt_filter.type = cpu_to_le32(0);
3666
3788
 
3667
3789
        /* Parse pattern filter offset. */
3668
 
        pkt_filter.u.pattern.offset = htod32(0);
 
3790
        pkt_filter.u.pattern.offset = cpu_to_le32(0);
3669
3791
 
3670
3792
        /* Parse pattern filter mask. */
3671
 
        mask_size = htod32(wl_pattern_atoh("0xff",
3672
 
                                           (char *)pkt_filterp->u.pattern.
3673
 
                                           mask_and_pattern));
 
3793
        mask_size = cpu_to_le32(wl_pattern_atoh("0xff",
 
3794
                                                (char *)pkt_filterp->u.pattern.
 
3795
                                                mask_and_pattern));
3674
3796
 
3675
3797
        /* Parse pattern filter pattern. */
3676
 
        pattern_size = htod32(wl_pattern_atoh("0x00",
3677
 
                                              (char *)&pkt_filterp->u.pattern.
3678
 
                                              mask_and_pattern[mask_size]));
 
3798
        pattern_size = cpu_to_le32(wl_pattern_atoh("0x00",
 
3799
                                                   (char *)&pkt_filterp->u.
 
3800
                                                   pattern.
 
3801
                                                   mask_and_pattern
 
3802
                                                   [mask_size]));
3679
3803
 
3680
3804
        if (mask_size != pattern_size) {
3681
3805
                WL_ERR("Mask and pattern not the same size\n");
3723
3847
}
3724
3848
#endif                          /* !EMBEDDED_PLATFORM */
3725
3849
 
 
3850
static s32 wl_dongle_eventmsg(struct net_device *ndev)
 
3851
{
 
3852
        s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
 
3853
                                                 '\0' + bitvec  */
 
3854
        s8 eventmask[WL_EVENTING_MASK_LEN];
 
3855
        s32 err = 0;
 
3856
 
 
3857
        WL_TRACE("Enter\n");
 
3858
 
 
3859
        /* Setup event_msgs */
 
3860
        bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
 
3861
                    sizeof(iovbuf));
 
3862
        err = wl_dev_ioctl(ndev, WLC_GET_VAR, iovbuf, sizeof(iovbuf));
 
3863
        if (unlikely(err)) {
 
3864
                WL_ERR("Get event_msgs error (%d)\n", err);
 
3865
                goto dongle_eventmsg_out;
 
3866
        }
 
3867
        memcpy(eventmask, iovbuf, WL_EVENTING_MASK_LEN);
 
3868
 
 
3869
        setbit(eventmask, WLC_E_SET_SSID);
 
3870
        setbit(eventmask, WLC_E_ROAM);
 
3871
        setbit(eventmask, WLC_E_PRUNE);
 
3872
        setbit(eventmask, WLC_E_AUTH);
 
3873
        setbit(eventmask, WLC_E_REASSOC);
 
3874
        setbit(eventmask, WLC_E_REASSOC_IND);
 
3875
        setbit(eventmask, WLC_E_DEAUTH_IND);
 
3876
        setbit(eventmask, WLC_E_DISASSOC_IND);
 
3877
        setbit(eventmask, WLC_E_DISASSOC);
 
3878
        setbit(eventmask, WLC_E_JOIN);
 
3879
        setbit(eventmask, WLC_E_ASSOC_IND);
 
3880
        setbit(eventmask, WLC_E_PSK_SUP);
 
3881
        setbit(eventmask, WLC_E_LINK);
 
3882
        setbit(eventmask, WLC_E_NDIS_LINK);
 
3883
        setbit(eventmask, WLC_E_MIC_ERROR);
 
3884
        setbit(eventmask, WLC_E_PMKID_CACHE);
 
3885
        setbit(eventmask, WLC_E_TXFAIL);
 
3886
        setbit(eventmask, WLC_E_JOIN_START);
 
3887
        setbit(eventmask, WLC_E_SCAN_COMPLETE);
 
3888
 
 
3889
        bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
 
3890
                    sizeof(iovbuf));
 
3891
        err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 
3892
        if (unlikely(err)) {
 
3893
                WL_ERR("Set event_msgs error (%d)\n", err);
 
3894
                goto dongle_eventmsg_out;
 
3895
        }
 
3896
 
 
3897
dongle_eventmsg_out:
 
3898
        WL_TRACE("Exit\n");
 
3899
        return err;
 
3900
}
 
3901
 
 
3902
static s32
 
3903
wl_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout)
 
3904
{
 
3905
        s8 iovbuf[32];
 
3906
        s32 roamtrigger[2];
 
3907
        s32 roam_delta[2];
 
3908
        s32 err = 0;
 
3909
 
 
3910
        /*
 
3911
         * Setup timeout if Beacons are lost and roam is
 
3912
         * off to report link down
 
3913
         */
 
3914
        if (roamvar) {
 
3915
                bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout,
 
3916
                        sizeof(bcn_timeout), iovbuf, sizeof(iovbuf));
 
3917
                err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 
3918
                if (unlikely(err)) {
 
3919
                        WL_ERR("bcn_timeout error (%d)\n", err);
 
3920
                        goto dongle_rom_out;
 
3921
                }
 
3922
        }
 
3923
 
 
3924
        /*
 
3925
         * Enable/Disable built-in roaming to allow supplicant
 
3926
         * to take care of roaming
 
3927
         */
 
3928
        WL_INFO("Internal Roaming = %s\n", roamvar ? "Off" : "On");
 
3929
        bcm_mkiovar("roam_off", (char *)&roamvar,
 
3930
                                sizeof(roamvar), iovbuf, sizeof(iovbuf));
 
3931
        err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 
3932
        if (unlikely(err)) {
 
3933
                WL_ERR("roam_off error (%d)\n", err);
 
3934
                goto dongle_rom_out;
 
3935
        }
 
3936
 
 
3937
        roamtrigger[0] = WL_ROAM_TRIGGER_LEVEL;
 
3938
        roamtrigger[1] = WLC_BAND_ALL;
 
3939
        err = wl_dev_ioctl(ndev, WLC_SET_ROAM_TRIGGER,
 
3940
                        (void *)roamtrigger, sizeof(roamtrigger));
 
3941
        if (unlikely(err)) {
 
3942
                WL_ERR("WLC_SET_ROAM_TRIGGER error (%d)\n", err);
 
3943
                goto dongle_rom_out;
 
3944
        }
 
3945
 
 
3946
        roam_delta[0] = WL_ROAM_DELTA;
 
3947
        roam_delta[1] = WLC_BAND_ALL;
 
3948
        err = wl_dev_ioctl(ndev, WLC_SET_ROAM_DELTA,
 
3949
                                (void *)roam_delta, sizeof(roam_delta));
 
3950
        if (unlikely(err)) {
 
3951
                WL_ERR("WLC_SET_ROAM_DELTA error (%d)\n", err);
 
3952
                goto dongle_rom_out;
 
3953
        }
 
3954
 
 
3955
dongle_rom_out:
 
3956
        return err;
 
3957
}
 
3958
 
 
3959
static s32
 
3960
wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
 
3961
                s32 scan_unassoc_time, s32 scan_passive_time)
 
3962
{
 
3963
        s32 err = 0;
 
3964
 
 
3965
        err = wl_dev_ioctl(ndev, WLC_SET_SCAN_CHANNEL_TIME, &scan_assoc_time,
 
3966
                        sizeof(scan_assoc_time));
 
3967
        if (err) {
 
3968
                if (err == -EOPNOTSUPP)
 
3969
                        WL_INFO("Scan assoc time is not supported\n");
 
3970
                else
 
3971
                        WL_ERR("Scan assoc time error (%d)\n", err);
 
3972
                goto dongle_scantime_out;
 
3973
        }
 
3974
        err = wl_dev_ioctl(ndev, WLC_SET_SCAN_UNASSOC_TIME, &scan_unassoc_time,
 
3975
                        sizeof(scan_unassoc_time));
 
3976
        if (err) {
 
3977
                if (err == -EOPNOTSUPP)
 
3978
                        WL_INFO("Scan unassoc time is not supported\n");
 
3979
                else
 
3980
                        WL_ERR("Scan unassoc time error (%d)\n", err);
 
3981
                goto dongle_scantime_out;
 
3982
        }
 
3983
 
 
3984
        err = wl_dev_ioctl(ndev, WLC_SET_SCAN_PASSIVE_TIME, &scan_passive_time,
 
3985
                        sizeof(scan_passive_time));
 
3986
        if (err) {
 
3987
                if (err == -EOPNOTSUPP)
 
3988
                        WL_INFO("Scan passive time is not supported\n");
 
3989
                else
 
3990
                        WL_ERR("Scan passive time error (%d)\n", err);
 
3991
                goto dongle_scantime_out;
 
3992
        }
 
3993
 
 
3994
dongle_scantime_out:
 
3995
        return err;
 
3996
}
 
3997
 
3726
3998
s32 wl_config_dongle(struct wl_priv *wl, bool need_lock)
3727
3999
{
3728
4000
#ifndef DHD_SDALIGN
3753
4025
        err = wl_dongle_glom(ndev, 0, DHD_SDALIGN);
3754
4026
        if (unlikely(err))
3755
4027
                goto default_conf_out;
3756
 
        err = wl_dongle_roam(ndev, (wl->roam_on ? 0 : 1), 3);
3757
 
        if (unlikely(err))
3758
 
                goto default_conf_out;
3759
 
        err = wl_dongle_eventmsg(ndev);
3760
 
        if (unlikely(err))
3761
 
                goto default_conf_out;
3762
4028
 
3763
 
        wl_dongle_scantime(ndev, 40, 80);
3764
4029
        wl_dongle_offload(ndev, 1, 0xf);
3765
4030
        wl_dongle_filter(ndev, 1);
3766
 
#endif                          /* !EMBEDDED_PLATFORM */
3767
 
 
 
4031
#endif /* !EMBEDDED_PLATFORM */
 
4032
 
 
4033
        wl_dongle_scantime(ndev, WL_SCAN_CHANNEL_TIME,
 
4034
                        WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME);
 
4035
 
 
4036
        err = wl_dongle_eventmsg(ndev);
 
4037
        if (unlikely(err))
 
4038
                goto default_conf_out;
 
4039
        err = wl_dongle_roam(ndev, (wl->roam_on ? 0 : 1), WL_BEACON_TIMEOUT);
 
4040
        if (unlikely(err))
 
4041
                goto default_conf_out;
3768
4042
        err = wl_dongle_mode(ndev, wdev->iftype);
3769
4043
        if (unlikely(err && err != -EINPROGRESS))
3770
4044
                goto default_conf_out;
3799
4073
        }
3800
4074
 
3801
4075
        phy = ((char *)&phy_list)[1];
3802
 
        WL_DBG("%c phy\n", phy);
 
4076
        WL_INFO("%c phy\n", phy);
3803
4077
        if (phy == 'n' || phy == 'a') {
3804
4078
                wiphy = wl_to_wiphy(wl);
3805
4079
                wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
3812
4086
{
3813
4087
        s32 err = 0;
3814
4088
 
 
4089
        set_bit(WL_STATUS_READY, &wl->status);
 
4090
 
3815
4091
        wl_debugfs_add_netdev_params(wl);
3816
4092
 
3817
4093
        err = wl_config_dongle(wl, false);
3819
4095
                return err;
3820
4096
 
3821
4097
        wl_invoke_iscan(wl);
3822
 
        set_bit(WL_STATUS_READY, &wl->status);
 
4098
 
3823
4099
        return err;
3824
4100
}
3825
4101
 
3826
4102
static s32 __wl_cfg80211_down(struct wl_priv *wl)
3827
4103
{
3828
 
        s32 err = 0;
3829
 
 
3830
 
        /* Check if cfg80211 interface is already down */
3831
 
        if (!test_bit(WL_STATUS_READY, &wl->status))
3832
 
                return err;     /* it is even not ready */
3833
 
 
3834
4104
        set_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
3835
4105
        wl_term_iscan(wl);
3836
4106
        if (wl->scan_request) {
3837
 
                cfg80211_scan_done(wl->scan_request, true);     /* true
3838
 
                                                                 means abort */
3839
 
                /* wl_set_mpc(wl_to_ndev(wl), 1); */    /* BUG
3840
 
                                                * this operation cannot help
3841
 
                                                * but here because sdio
3842
 
                                                * is already down through
3843
 
                                                * rmmod process.
3844
 
                                                * Need to figure out how to
3845
 
                                                * address this issue
3846
 
                                                */
 
4107
                cfg80211_scan_done(wl->scan_request, true);
 
4108
                /* May need to perform this to cover rmmod */
 
4109
                /* wl_set_mpc(wl_to_ndev(wl), 1); */
3847
4110
                wl->scan_request = NULL;
3848
4111
        }
3849
4112
        clear_bit(WL_STATUS_READY, &wl->status);
3850
4113
        clear_bit(WL_STATUS_SCANNING, &wl->status);
3851
4114
        clear_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
 
4115
        clear_bit(WL_STATUS_CONNECTING, &wl->status);
3852
4116
        clear_bit(WL_STATUS_CONNECTED, &wl->status);
3853
4117
 
3854
4118
        wl_debugfs_remove_netdev(wl);
3855
4119
 
3856
 
        return err;
 
4120
        return 0;
3857
4121
}
3858
4122
 
3859
4123
s32 wl_cfg80211_up(void)
3898
4162
        switch (item) {
3899
4163
        case WL_PROF_SEC:
3900
4164
                return &wl->profile->sec;
3901
 
        case WL_PROF_ACT:
3902
 
                return &wl->profile->active;
3903
4165
        case WL_PROF_BSSID:
3904
4166
                return &wl->profile->bssid;
3905
4167
        case WL_PROF_SSID:
3933
4195
        case WL_PROF_SEC:
3934
4196
                memcpy(&wl->profile->sec, data, sizeof(wl->profile->sec));
3935
4197
                break;
3936
 
        case WL_PROF_ACT:
3937
 
                wl->profile->active = *(bool *)data;
3938
 
                break;
3939
4198
        case WL_PROF_BEACONINT:
3940
4199
                wl->profile->beacon_interval = *(u16 *)data;
3941
4200
                break;
3951
4210
        return err;
3952
4211
}
3953
4212
 
3954
 
void wl_cfg80211_dbg_level(u32 level)
3955
 
{
3956
 
        /*
3957
 
        * prohibit to change debug level
3958
 
        * by insmod parameter.
3959
 
        * eventually debug level will be configured
3960
 
        * in compile time by using CONFIG_XXX
3961
 
        */
3962
 
        /* wl_dbg_level = level; */
3963
 
}
3964
 
 
3965
4213
static bool wl_is_ibssmode(struct wl_priv *wl)
3966
4214
{
3967
4215
        return wl->conf->mode == WL_MODE_IBSS;
3968
4216
}
3969
4217
 
3970
 
static bool wl_is_ibssstarter(struct wl_priv *wl)
3971
 
{
3972
 
        return wl->ibss_starter;
3973
 
}
3974
 
 
3975
 
static void wl_rst_ie(struct wl_priv *wl)
3976
 
{
3977
 
        struct wl_ie *ie = wl_to_ie(wl);
3978
 
 
3979
 
        ie->offset = 0;
3980
 
}
3981
 
 
3982
4218
static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v)
3983
4219
{
3984
4220
        struct wl_ie *ie = wl_to_ie(wl);
3996
4232
        return err;
3997
4233
}
3998
4234
 
3999
 
static s32 wl_mrg_ie(struct wl_priv *wl, u8 *ie_stream, u16 ie_size)
4000
 
{
4001
 
        struct wl_ie *ie = wl_to_ie(wl);
4002
 
        s32 err = 0;
4003
 
 
4004
 
        if (unlikely(ie->offset + ie_size > WL_TLV_INFO_MAX)) {
4005
 
                WL_ERR("ei_stream crosses buffer boundary\n");
4006
 
                return -ENOSPC;
4007
 
        }
4008
 
        memcpy(&ie->buf[ie->offset], ie_stream, ie_size);
4009
 
        ie->offset += ie_size;
4010
 
 
4011
 
        return err;
4012
 
}
4013
 
 
4014
 
static s32 wl_cp_ie(struct wl_priv *wl, u8 *dst, u16 dst_size)
4015
 
{
4016
 
        struct wl_ie *ie = wl_to_ie(wl);
4017
 
        s32 err = 0;
4018
 
 
4019
 
        if (unlikely(ie->offset > dst_size)) {
4020
 
                WL_ERR("dst_size is not enough\n");
4021
 
                return -ENOSPC;
4022
 
        }
4023
 
        memcpy(dst, &ie->buf[0], ie->offset);
4024
 
 
4025
 
        return err;
4026
 
}
4027
 
 
4028
 
static u32 wl_get_ielen(struct wl_priv *wl)
4029
 
{
4030
 
        struct wl_ie *ie = wl_to_ie(wl);
4031
 
 
4032
 
        return ie->offset;
4033
 
}
4034
 
 
4035
 
static void wl_link_up(struct wl_priv *wl)
4036
 
{
4037
 
        wl->link_up = true;
4038
 
}
4039
4235
 
4040
4236
static void wl_link_down(struct wl_priv *wl)
4041
4237
{
4042
 
        struct wl_connect_info *conn_info = wl_to_conn(wl);
4043
 
 
4044
 
        wl->link_up = false;
4045
 
        kfree(conn_info->req_ie);
4046
 
        conn_info->req_ie = NULL;
4047
 
        conn_info->req_ie_len = 0;
4048
 
        kfree(conn_info->resp_ie);
4049
 
        conn_info->resp_ie = NULL;
4050
 
        conn_info->resp_ie_len = 0;
 
4238
        struct net_device *dev = NULL;
 
4239
        s32 err = 0;
 
4240
 
 
4241
        WL_TRACE("Enter\n");
 
4242
        clear_bit(WL_STATUS_CONNECTED, &wl->status);
 
4243
 
 
4244
        if (wl->link_up) {
 
4245
                dev = wl_to_ndev(wl);
 
4246
                WL_INFO("Call WLC_DISASSOC to stop excess roaming\n ");
 
4247
                err = wl_dev_ioctl(dev, WLC_DISASSOC, NULL, 0);
 
4248
                if (unlikely(err))
 
4249
                        WL_ERR("WLC_DISASSOC failed (%d)\n", err);
 
4250
                wl->link_up = false;
 
4251
        }
 
4252
        WL_TRACE("Exit\n");
4051
4253
}
4052
4254
 
4053
4255
static void wl_lock_eq(struct wl_priv *wl)
4117
4319
        const struct firmware *fw_entry = NULL;
4118
4320
        s32 err = 0;
4119
4321
 
4120
 
        WL_DBG("file name : \"%s\"\n", file_name);
 
4322
        WL_INFO("file name : \"%s\"\n", file_name);
4121
4323
        wl = WL_PRIV_GET();
4122
4324
 
4123
4325
        if (!test_bit(WL_FW_LOADING_DONE, &wl->fw->status)) {
4130
4332
                set_bit(WL_FW_LOADING_DONE, &wl->fw->status);
4131
4333
                fw_entry = wl->fw->fw_entry;
4132
4334
                if (fw_entry) {
4133
 
                        WL_DBG("fw size (%zd), data (%p)\n",
 
4335
                        WL_INFO("fw size (%zd), data (%p)\n",
4134
4336
                               fw_entry->size, fw_entry->data);
4135
4337
                }
4136
4338
        } else if (!test_bit(WL_NVRAM_LOADING_DONE, &wl->fw->status)) {
4143
4345
                set_bit(WL_NVRAM_LOADING_DONE, &wl->fw->status);
4144
4346
                fw_entry = wl->fw->fw_entry;
4145
4347
                if (fw_entry) {
4146
 
                        WL_DBG("nvram size (%zd), data (%p)\n",
 
4348
                        WL_INFO("nvram size (%zd), data (%p)\n",
4147
4349
                               fw_entry->size, fw_entry->data);
4148
4350
                }
4149
4351
        } else {
4150
 
                WL_DBG("Downloading already done. Nothing to do more\n");
 
4352
                WL_INFO("Downloading already done. Nothing to do more\n");
4151
4353
                err = -EPERM;
4152
4354
        }
4153
4355
 
4180
4382
static void wl_set_mpc(struct net_device *ndev, int mpc)
4181
4383
{
4182
4384
        s32 err = 0;
 
4385
        struct wl_priv *wl = ndev_to_wl(ndev);
4183
4386
 
4184
 
        err = wl_dev_intvar_set(ndev, "mpc", mpc);
4185
 
        if (unlikely(err)) {
4186
 
                WL_ERR("fail to set mpc\n");
4187
 
                return;
 
4387
        if (test_bit(WL_STATUS_READY, &wl->status)) {
 
4388
                err = wl_dev_intvar_set(ndev, "mpc", mpc);
 
4389
                if (unlikely(err)) {
 
4390
                        WL_ERR("fail to set mpc\n");
 
4391
                        return;
 
4392
                }
 
4393
                WL_INFO("MPC : %d\n", mpc);
4188
4394
        }
4189
 
        WL_DBG("MPC : %d\n", mpc);
4190
4395
}
4191
4396
 
4192
4397
static int wl_debugfs_add_netdev_params(struct wl_priv *wl)