diff options
author | Samuel Ortiz <samuel.ortiz@intel.com> | 2009-07-16 05:34:10 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-24 15:05:20 -0400 |
commit | 9967d46aa5ba065650d3352ab5d906f56ba17648 (patch) | |
tree | 7dc84d916453ae803a545bb720de9fd8ed016aa2 /drivers/net/wireless/iwmc3200wifi/cfg80211.c | |
parent | 4fdd81f5f2e6fc55b67938f09b3495d679428cd7 (diff) |
iwmc3200wifi: cfg80211 managed mode port
This patch ports iwmc3200wifi to the cfg80211 managed mode API.
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwmc3200wifi/cfg80211.c')
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/cfg80211.c | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index 0aa389564c71..ee4031764389 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c | |||
@@ -305,6 +305,25 @@ static int iwm_cfg80211_set_default_key(struct wiphy *wiphy, | |||
305 | return iwm_reset_profile(iwm); | 305 | return iwm_reset_profile(iwm); |
306 | } | 306 | } |
307 | 307 | ||
308 | int iwm_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, | ||
309 | u8 *mac, struct station_info *sinfo) | ||
310 | { | ||
311 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | ||
312 | |||
313 | if (memcmp(mac, iwm->bssid, ETH_ALEN)) | ||
314 | return -ENOENT; | ||
315 | |||
316 | sinfo->filled |= STATION_INFO_TX_BITRATE; | ||
317 | sinfo->txrate.legacy = iwm->rate * 10; | ||
318 | |||
319 | if (test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)) { | ||
320 | sinfo->filled |= STATION_INFO_SIGNAL; | ||
321 | sinfo->signal = iwm->wstats.qual.level; | ||
322 | } | ||
323 | |||
324 | return 0; | ||
325 | } | ||
326 | |||
308 | 327 | ||
309 | int iwm_cfg80211_inform_bss(struct iwm_priv *iwm) | 328 | int iwm_cfg80211_inform_bss(struct iwm_priv *iwm) |
310 | { | 329 | { |
@@ -500,6 +519,179 @@ static int iwm_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) | |||
500 | return 0; | 519 | return 0; |
501 | } | 520 | } |
502 | 521 | ||
522 | static int iwm_set_auth_type(struct iwm_priv *iwm, | ||
523 | enum nl80211_auth_type sme_auth_type) | ||
524 | { | ||
525 | u8 *auth_type = &iwm->umac_profile->sec.auth_type; | ||
526 | |||
527 | switch (sme_auth_type) { | ||
528 | case NL80211_AUTHTYPE_AUTOMATIC: | ||
529 | case NL80211_AUTHTYPE_OPEN_SYSTEM: | ||
530 | IWM_DBG_WEXT(iwm, DBG, "OPEN auth\n"); | ||
531 | *auth_type = UMAC_AUTH_TYPE_OPEN; | ||
532 | break; | ||
533 | case NL80211_AUTHTYPE_SHARED_KEY: | ||
534 | if (iwm->umac_profile->sec.flags & | ||
535 | (UMAC_SEC_FLG_WPA_ON_MSK | UMAC_SEC_FLG_RSNA_ON_MSK)) { | ||
536 | IWM_DBG_WEXT(iwm, DBG, "WPA auth alg\n"); | ||
537 | *auth_type = UMAC_AUTH_TYPE_RSNA_PSK; | ||
538 | } else { | ||
539 | IWM_DBG_WEXT(iwm, DBG, "WEP shared key auth alg\n"); | ||
540 | *auth_type = UMAC_AUTH_TYPE_LEGACY_PSK; | ||
541 | } | ||
542 | |||
543 | break; | ||
544 | default: | ||
545 | IWM_ERR(iwm, "Unsupported auth alg: 0x%x\n", sme_auth_type); | ||
546 | return -ENOTSUPP; | ||
547 | } | ||
548 | |||
549 | return 0; | ||
550 | } | ||
551 | |||
552 | static int iwm_set_wpa_version(struct iwm_priv *iwm, u32 wpa_version) | ||
553 | { | ||
554 | if (!wpa_version) { | ||
555 | iwm->umac_profile->sec.flags = UMAC_SEC_FLG_LEGACY_PROFILE; | ||
556 | return 0; | ||
557 | } | ||
558 | |||
559 | if (wpa_version & NL80211_WPA_VERSION_2) | ||
560 | iwm->umac_profile->sec.flags = UMAC_SEC_FLG_RSNA_ON_MSK; | ||
561 | |||
562 | if (wpa_version & NL80211_WPA_VERSION_1) | ||
563 | iwm->umac_profile->sec.flags |= UMAC_SEC_FLG_WPA_ON_MSK; | ||
564 | |||
565 | return 0; | ||
566 | } | ||
567 | |||
568 | static int iwm_set_cipher(struct iwm_priv *iwm, u32 cipher, bool ucast) | ||
569 | { | ||
570 | u8 *profile_cipher = ucast ? &iwm->umac_profile->sec.ucast_cipher : | ||
571 | &iwm->umac_profile->sec.mcast_cipher; | ||
572 | |||
573 | if (!cipher) { | ||
574 | *profile_cipher = UMAC_CIPHER_TYPE_NONE; | ||
575 | return 0; | ||
576 | } | ||
577 | |||
578 | switch (cipher) { | ||
579 | case IW_AUTH_CIPHER_NONE: | ||
580 | *profile_cipher = UMAC_CIPHER_TYPE_NONE; | ||
581 | break; | ||
582 | case WLAN_CIPHER_SUITE_WEP40: | ||
583 | *profile_cipher = UMAC_CIPHER_TYPE_WEP_40; | ||
584 | break; | ||
585 | case WLAN_CIPHER_SUITE_WEP104: | ||
586 | *profile_cipher = UMAC_CIPHER_TYPE_WEP_104; | ||
587 | break; | ||
588 | case WLAN_CIPHER_SUITE_TKIP: | ||
589 | *profile_cipher = UMAC_CIPHER_TYPE_TKIP; | ||
590 | break; | ||
591 | case WLAN_CIPHER_SUITE_CCMP: | ||
592 | *profile_cipher = UMAC_CIPHER_TYPE_CCMP; | ||
593 | break; | ||
594 | default: | ||
595 | IWM_ERR(iwm, "Unsupported cipher: 0x%x\n", cipher); | ||
596 | return -ENOTSUPP; | ||
597 | } | ||
598 | |||
599 | return 0; | ||
600 | } | ||
601 | |||
602 | static int iwm_set_key_mgt(struct iwm_priv *iwm, u32 key_mgt) | ||
603 | { | ||
604 | u8 *auth_type = &iwm->umac_profile->sec.auth_type; | ||
605 | |||
606 | IWM_DBG_WEXT(iwm, DBG, "key_mgt: 0x%x\n", key_mgt); | ||
607 | |||
608 | if (key_mgt == WLAN_AKM_SUITE_8021X) | ||
609 | *auth_type = UMAC_AUTH_TYPE_8021X; | ||
610 | else if (key_mgt == WLAN_AKM_SUITE_PSK) { | ||
611 | if (iwm->umac_profile->sec.flags & | ||
612 | (UMAC_SEC_FLG_WPA_ON_MSK | UMAC_SEC_FLG_RSNA_ON_MSK)) | ||
613 | *auth_type = UMAC_AUTH_TYPE_RSNA_PSK; | ||
614 | else | ||
615 | *auth_type = UMAC_AUTH_TYPE_LEGACY_PSK; | ||
616 | } else { | ||
617 | IWM_ERR(iwm, "Invalid key mgt: 0x%x\n", key_mgt); | ||
618 | return -EINVAL; | ||
619 | } | ||
620 | |||
621 | return 0; | ||
622 | } | ||
623 | |||
624 | |||
625 | static int iwm_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, | ||
626 | struct cfg80211_connect_params *sme) | ||
627 | { | ||
628 | struct iwm_priv *iwm = wiphy_to_iwm(wiphy); | ||
629 | struct ieee80211_channel *chan = sme->channel; | ||
630 | int ret; | ||
631 | |||
632 | if (!test_bit(IWM_STATUS_READY, &iwm->status)) | ||
633 | return -EIO; | ||
634 | |||
635 | if (!sme->ssid) | ||
636 | return -EINVAL; | ||
637 | |||
638 | if (chan) | ||
639 | iwm->channel = | ||
640 | ieee80211_frequency_to_channel(chan->center_freq); | ||
641 | |||
642 | iwm->umac_profile->ssid.ssid_len = sme->ssid_len; | ||
643 | memcpy(iwm->umac_profile->ssid.ssid, sme->ssid, sme->ssid_len); | ||
644 | |||
645 | if (sme->bssid) { | ||
646 | IWM_DBG_WEXT(iwm, DBG, "BSSID: %pM\n", sme->bssid); | ||
647 | memcpy(&iwm->umac_profile->bssid[0], sme->bssid, ETH_ALEN); | ||
648 | iwm->umac_profile->bss_num = 1; | ||
649 | } else { | ||
650 | memset(&iwm->umac_profile->bssid[0], 0, ETH_ALEN); | ||
651 | iwm->umac_profile->bss_num = 0; | ||
652 | } | ||
653 | |||
654 | ret = iwm_set_auth_type(iwm, sme->auth_type); | ||
655 | if (ret < 0) | ||
656 | return ret; | ||
657 | |||
658 | ret = iwm_set_wpa_version(iwm, sme->crypto.wpa_versions); | ||
659 | if (ret < 0) | ||
660 | return ret; | ||
661 | |||
662 | if (sme->crypto.n_ciphers_pairwise) { | ||
663 | ret = iwm_set_cipher(iwm, sme->crypto.ciphers_pairwise[0], | ||
664 | true); | ||
665 | if (ret < 0) | ||
666 | return ret; | ||
667 | } | ||
668 | |||
669 | ret = iwm_set_cipher(iwm, sme->crypto.cipher_group, false); | ||
670 | if (ret < 0) | ||
671 | return ret; | ||
672 | |||
673 | if (sme->crypto.n_akm_suites) { | ||
674 | ret = iwm_set_key_mgt(iwm, sme->crypto.akm_suites[0]); | ||
675 | if (ret < 0) | ||
676 | return ret; | ||
677 | } | ||
678 | |||
679 | return iwm_send_mlme_profile(iwm); | ||
680 | } | ||
681 | |||
682 | static int iwm_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, | ||
683 | u16 reason_code) | ||
684 | { | ||
685 | struct iwm_priv *iwm = wiphy_to_iwm(wiphy); | ||
686 | |||
687 | IWM_DBG_WEXT(iwm, DBG, "Active: %d\n", iwm->umac_profile_active); | ||
688 | |||
689 | if (iwm->umac_profile_active) | ||
690 | return iwm_invalidate_mlme_profile(iwm); | ||
691 | |||
692 | return 0; | ||
693 | } | ||
694 | |||
503 | static int iwm_cfg80211_set_txpower(struct wiphy *wiphy, | 695 | static int iwm_cfg80211_set_txpower(struct wiphy *wiphy, |
504 | enum tx_power_setting type, int dbm) | 696 | enum tx_power_setting type, int dbm) |
505 | { | 697 | { |
@@ -549,8 +741,11 @@ static struct cfg80211_ops iwm_cfg80211_ops = { | |||
549 | .get_key = iwm_cfg80211_get_key, | 741 | .get_key = iwm_cfg80211_get_key, |
550 | .del_key = iwm_cfg80211_del_key, | 742 | .del_key = iwm_cfg80211_del_key, |
551 | .set_default_key = iwm_cfg80211_set_default_key, | 743 | .set_default_key = iwm_cfg80211_set_default_key, |
744 | .get_station = iwm_cfg80211_get_station, | ||
552 | .scan = iwm_cfg80211_scan, | 745 | .scan = iwm_cfg80211_scan, |
553 | .set_wiphy_params = iwm_cfg80211_set_wiphy_params, | 746 | .set_wiphy_params = iwm_cfg80211_set_wiphy_params, |
747 | .connect = iwm_cfg80211_connect, | ||
748 | .disconnect = iwm_cfg80211_disconnect, | ||
554 | .join_ibss = iwm_cfg80211_join_ibss, | 749 | .join_ibss = iwm_cfg80211_join_ibss, |
555 | .leave_ibss = iwm_cfg80211_leave_ibss, | 750 | .leave_ibss = iwm_cfg80211_leave_ibss, |
556 | .set_tx_power = iwm_cfg80211_set_txpower, | 751 | .set_tx_power = iwm_cfg80211_set_txpower, |