diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2009-08-28 06:27:53 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-28 14:40:58 -0400 |
commit | 5554adbe0d366f6a5096e6f74b48dcad5698c528 (patch) | |
tree | f67439cbd4570eda61e5cf48aae26e5e7bff12f1 /drivers/net/wireless | |
parent | 5c52323e8c44a06183052986dbd028ce15622166 (diff) |
rndis_wlan: add cfg80211 set_channel
Add cfg80211 set_channel and convert wext to use it.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/rndis_wlan.c | 105 |
1 files changed, 15 insertions, 90 deletions
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index c2af5be35d39..ffb195dcf4f8 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -517,6 +517,9 @@ static int rndis_join_ibss(struct wiphy *wiphy, struct net_device *dev, | |||
517 | 517 | ||
518 | static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev); | 518 | static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev); |
519 | 519 | ||
520 | static int rndis_set_channel(struct wiphy *wiphy, | ||
521 | struct ieee80211_channel *chan, enum nl80211_channel_type channel_type); | ||
522 | |||
520 | static struct cfg80211_ops rndis_config_ops = { | 523 | static struct cfg80211_ops rndis_config_ops = { |
521 | .change_virtual_intf = rndis_change_virtual_intf, | 524 | .change_virtual_intf = rndis_change_virtual_intf, |
522 | .scan = rndis_scan, | 525 | .scan = rndis_scan, |
@@ -527,6 +530,7 @@ static struct cfg80211_ops rndis_config_ops = { | |||
527 | .disconnect = rndis_disconnect, | 530 | .disconnect = rndis_disconnect, |
528 | .join_ibss = rndis_join_ibss, | 531 | .join_ibss = rndis_join_ibss, |
529 | .leave_ibss = rndis_leave_ibss, | 532 | .leave_ibss = rndis_leave_ibss, |
533 | .set_channel = rndis_set_channel, | ||
530 | }; | 534 | }; |
531 | 535 | ||
532 | static void *rndis_wiphy_privid = &rndis_wiphy_privid; | 536 | static void *rndis_wiphy_privid = &rndis_wiphy_privid; |
@@ -924,46 +928,6 @@ static int level_to_qual(int level) | |||
924 | } | 928 | } |
925 | 929 | ||
926 | 930 | ||
927 | static void dsconfig_to_freq(unsigned int dsconfig, struct iw_freq *freq) | ||
928 | { | ||
929 | freq->e = 0; | ||
930 | freq->i = 0; | ||
931 | freq->flags = 0; | ||
932 | |||
933 | /* see comment in wireless.h above the "struct iw_freq" | ||
934 | * definition for an explanation of this if | ||
935 | * NOTE: 1000000 is due to the kHz | ||
936 | */ | ||
937 | if (dsconfig > 1000000) { | ||
938 | freq->m = dsconfig / 10; | ||
939 | freq->e = 1; | ||
940 | } else | ||
941 | freq->m = dsconfig; | ||
942 | |||
943 | /* convert from kHz to Hz */ | ||
944 | freq->e += 3; | ||
945 | } | ||
946 | |||
947 | |||
948 | static int freq_to_dsconfig(struct iw_freq *freq, unsigned int *dsconfig) | ||
949 | { | ||
950 | if (freq->m < 1000 && freq->e == 0) { | ||
951 | if (freq->m >= 1 && freq->m <= 14) | ||
952 | *dsconfig = ieee80211_dsss_chan_to_freq(freq->m) * 1000; | ||
953 | else | ||
954 | return -1; | ||
955 | } else { | ||
956 | int i; | ||
957 | *dsconfig = freq->m; | ||
958 | for (i = freq->e; i > 0; i--) | ||
959 | *dsconfig *= 10; | ||
960 | *dsconfig /= 1000; | ||
961 | } | ||
962 | |||
963 | return 0; | ||
964 | } | ||
965 | |||
966 | |||
967 | /* | 931 | /* |
968 | * common functions | 932 | * common functions |
969 | */ | 933 | */ |
@@ -2067,6 +2031,15 @@ static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev) | |||
2067 | return deauthenticate(usbdev); | 2031 | return deauthenticate(usbdev); |
2068 | } | 2032 | } |
2069 | 2033 | ||
2034 | static int rndis_set_channel(struct wiphy *wiphy, | ||
2035 | struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) | ||
2036 | { | ||
2037 | struct rndis_wlan_private *priv = wiphy_priv(wiphy); | ||
2038 | struct usbnet *usbdev = priv->usbdev; | ||
2039 | |||
2040 | return set_channel(usbdev, | ||
2041 | ieee80211_frequency_to_channel(chan->center_freq)); | ||
2042 | } | ||
2070 | 2043 | ||
2071 | /* | 2044 | /* |
2072 | * wireless extension handlers | 2045 | * wireless extension handlers |
@@ -2416,54 +2389,6 @@ static int rndis_iw_set_encode_ext(struct net_device *dev, | |||
2416 | } | 2389 | } |
2417 | 2390 | ||
2418 | 2391 | ||
2419 | static int rndis_iw_set_freq(struct net_device *dev, | ||
2420 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
2421 | { | ||
2422 | struct usbnet *usbdev = netdev_priv(dev); | ||
2423 | struct ndis_80211_conf config; | ||
2424 | unsigned int dsconfig; | ||
2425 | int len, ret; | ||
2426 | |||
2427 | /* this OID is valid only when not associated */ | ||
2428 | if (is_associated(usbdev)) | ||
2429 | return 0; | ||
2430 | |||
2431 | dsconfig = 0; | ||
2432 | if (freq_to_dsconfig(&wrqu->freq, &dsconfig)) | ||
2433 | return -EINVAL; | ||
2434 | |||
2435 | len = sizeof(config); | ||
2436 | ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len); | ||
2437 | if (ret != 0) { | ||
2438 | devdbg(usbdev, "SIOCSIWFREQ: querying configuration failed"); | ||
2439 | return 0; | ||
2440 | } | ||
2441 | |||
2442 | config.ds_config = cpu_to_le32(dsconfig); | ||
2443 | |||
2444 | devdbg(usbdev, "SIOCSIWFREQ: %d * 10^%d", wrqu->freq.m, wrqu->freq.e); | ||
2445 | return rndis_set_oid(usbdev, OID_802_11_CONFIGURATION, &config, | ||
2446 | sizeof(config)); | ||
2447 | } | ||
2448 | |||
2449 | |||
2450 | static int rndis_iw_get_freq(struct net_device *dev, | ||
2451 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
2452 | { | ||
2453 | struct usbnet *usbdev = netdev_priv(dev); | ||
2454 | struct ndis_80211_conf config; | ||
2455 | int len, ret; | ||
2456 | |||
2457 | len = sizeof(config); | ||
2458 | ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len); | ||
2459 | if (ret == 0) | ||
2460 | dsconfig_to_freq(le32_to_cpu(config.ds_config), &wrqu->freq); | ||
2461 | |||
2462 | devdbg(usbdev, "SIOCGIWFREQ: %d", wrqu->freq.m); | ||
2463 | return ret; | ||
2464 | } | ||
2465 | |||
2466 | |||
2467 | static int rndis_iw_get_rate(struct net_device *dev, | 2392 | static int rndis_iw_get_rate(struct net_device *dev, |
2468 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | 2393 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) |
2469 | { | 2394 | { |
@@ -2501,8 +2426,8 @@ static const iw_handler rndis_iw_handler[] = | |||
2501 | { | 2426 | { |
2502 | IW_IOCTL(SIOCSIWCOMMIT) = rndis_iw_commit, | 2427 | IW_IOCTL(SIOCSIWCOMMIT) = rndis_iw_commit, |
2503 | IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname, | 2428 | IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname, |
2504 | IW_IOCTL(SIOCSIWFREQ) = rndis_iw_set_freq, | 2429 | IW_IOCTL(SIOCSIWFREQ) = (iw_handler) cfg80211_wext_siwfreq, |
2505 | IW_IOCTL(SIOCGIWFREQ) = rndis_iw_get_freq, | 2430 | IW_IOCTL(SIOCGIWFREQ) = (iw_handler) cfg80211_wext_giwfreq, |
2506 | IW_IOCTL(SIOCSIWMODE) = (iw_handler) cfg80211_wext_siwmode, | 2431 | IW_IOCTL(SIOCSIWMODE) = (iw_handler) cfg80211_wext_siwmode, |
2507 | IW_IOCTL(SIOCGIWMODE) = (iw_handler) cfg80211_wext_giwmode, | 2432 | IW_IOCTL(SIOCGIWMODE) = (iw_handler) cfg80211_wext_giwmode, |
2508 | IW_IOCTL(SIOCGIWRANGE) = (iw_handler) cfg80211_wext_giwrange, | 2433 | IW_IOCTL(SIOCGIWRANGE) = (iw_handler) cfg80211_wext_giwrange, |