diff options
author | Juuso Oikarinen <juuso.oikarinen@nokia.com> | 2010-06-23 05:12:37 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-06-24 15:42:33 -0400 |
commit | fa61cf70a6ae1089e459e4b59b2e8d8e90d8535e (patch) | |
tree | 1bd81709faaa15fb207de7db4df1ceed96374208 | |
parent | a185045c8da1ec6627236b4ade0d949b15da43b3 (diff) |
cfg80211/mac80211: Update set_tx_power to use mBm instead of dBm units
In preparation for a TX power setting interface in the nl80211, change the
.set_tx_power function to use mBm units instead of dBm for greater accuracy and
smaller power levels.
Also, already in advance move the tx_power_setting enumeration to nl80211.
This change affects the .tx_set_power function prototype. As a result, the
corresponding changes are needed to modules using it. These are mac80211,
iwmc3200wifi and rndis_wlan.
Cc: Samuel Ortiz <samuel.ortiz@intel.com>
Cc: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Acked-by: Samuel Ortiz <samuel.ortiz@intel.com>
Acked-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/cfg80211.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/rndis_wlan.c | 20 | ||||
-rw-r--r-- | include/linux/nl80211.h | 13 | ||||
-rw-r--r-- | include/net/cfg80211.h | 15 | ||||
-rw-r--r-- | net/mac80211/cfg.c | 22 | ||||
-rw-r--r-- | net/wireless/wext-compat.c | 10 |
6 files changed, 51 insertions, 41 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index 902e95f70f6e..60619678f4ec 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c | |||
@@ -670,20 +670,24 @@ static int iwm_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, | |||
670 | } | 670 | } |
671 | 671 | ||
672 | static int iwm_cfg80211_set_txpower(struct wiphy *wiphy, | 672 | static int iwm_cfg80211_set_txpower(struct wiphy *wiphy, |
673 | enum tx_power_setting type, int dbm) | 673 | enum nl80211_tx_power_setting type, int mbm) |
674 | { | 674 | { |
675 | struct iwm_priv *iwm = wiphy_to_iwm(wiphy); | 675 | struct iwm_priv *iwm = wiphy_to_iwm(wiphy); |
676 | int ret; | 676 | int ret; |
677 | 677 | ||
678 | switch (type) { | 678 | switch (type) { |
679 | case TX_POWER_AUTOMATIC: | 679 | case NL80211_TX_POWER_AUTOMATIC: |
680 | return 0; | 680 | return 0; |
681 | case TX_POWER_FIXED: | 681 | case NL80211_TX_POWER_FIXED: |
682 | if (mbm < 0 || (mbm % 100)) | ||
683 | return -EOPNOTSUPP; | ||
684 | |||
682 | if (!test_bit(IWM_STATUS_READY, &iwm->status)) | 685 | if (!test_bit(IWM_STATUS_READY, &iwm->status)) |
683 | return 0; | 686 | return 0; |
684 | 687 | ||
685 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, | 688 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, |
686 | CFG_TX_PWR_LIMIT_USR, dbm * 2); | 689 | CFG_TX_PWR_LIMIT_USR, |
690 | MBM_TO_DBM(mbm) * 2); | ||
687 | if (ret < 0) | 691 | if (ret < 0) |
688 | return ret; | 692 | return ret; |
689 | 693 | ||
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 4102cca54882..5e26edb57d82 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -520,8 +520,9 @@ static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, | |||
520 | 520 | ||
521 | static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed); | 521 | static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed); |
522 | 522 | ||
523 | static int rndis_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, | 523 | static int rndis_set_tx_power(struct wiphy *wiphy, |
524 | int dbm); | 524 | enum nl80211_tx_power_setting type, |
525 | int mbm); | ||
525 | static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm); | 526 | static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm); |
526 | 527 | ||
527 | static int rndis_connect(struct wiphy *wiphy, struct net_device *dev, | 528 | static int rndis_connect(struct wiphy *wiphy, struct net_device *dev, |
@@ -1856,20 +1857,25 @@ static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed) | |||
1856 | return 0; | 1857 | return 0; |
1857 | } | 1858 | } |
1858 | 1859 | ||
1859 | static int rndis_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, | 1860 | static int rndis_set_tx_power(struct wiphy *wiphy, |
1860 | int dbm) | 1861 | enum nl80211_tx_power_setting type, |
1862 | int mbm) | ||
1861 | { | 1863 | { |
1862 | struct rndis_wlan_private *priv = wiphy_priv(wiphy); | 1864 | struct rndis_wlan_private *priv = wiphy_priv(wiphy); |
1863 | struct usbnet *usbdev = priv->usbdev; | 1865 | struct usbnet *usbdev = priv->usbdev; |
1864 | 1866 | ||
1865 | netdev_dbg(usbdev->net, "%s(): type:0x%x dbm:%i\n", | 1867 | netdev_dbg(usbdev->net, "%s(): type:0x%x mbm:%i\n", |
1866 | __func__, type, dbm); | 1868 | __func__, type, mbm); |
1869 | |||
1870 | if (mbm < 0 || (mbm % 100)) | ||
1871 | return -ENOTSUPP; | ||
1867 | 1872 | ||
1868 | /* Device doesn't support changing txpower after initialization, only | 1873 | /* Device doesn't support changing txpower after initialization, only |
1869 | * turn off/on radio. Support 'auto' mode and setting same dBm that is | 1874 | * turn off/on radio. Support 'auto' mode and setting same dBm that is |
1870 | * currently used. | 1875 | * currently used. |
1871 | */ | 1876 | */ |
1872 | if (type == TX_POWER_AUTOMATIC || dbm == get_bcm4320_power_dbm(priv)) { | 1877 | if (type == NL80211_TX_POWER_AUTOMATIC || |
1878 | MBM_TO_DBM(mbm) == get_bcm4320_power_dbm(priv)) { | ||
1873 | if (!priv->radio_on) | 1879 | if (!priv->radio_on) |
1874 | disassociate(usbdev, true); /* turn on radio */ | 1880 | disassociate(usbdev, true); /* turn on radio */ |
1875 | 1881 | ||
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 64fb32b93a28..07aa04693f94 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h | |||
@@ -1659,4 +1659,17 @@ enum nl80211_cqm_rssi_threshold_event { | |||
1659 | NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH, | 1659 | NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH, |
1660 | }; | 1660 | }; |
1661 | 1661 | ||
1662 | |||
1663 | /** | ||
1664 | * enum nl80211_tx_power_setting - TX power adjustment | ||
1665 | * @NL80211_TX_POWER_AUTOMATIC: automatically determine transmit power | ||
1666 | * @NL80211_TX_POWER_LIMITED: limit TX power by the mBm parameter | ||
1667 | * @NL80211_TX_POWER_FIXED: fix TX power to the mBm parameter | ||
1668 | */ | ||
1669 | enum nl80211_tx_power_setting { | ||
1670 | NL80211_TX_POWER_AUTOMATIC, | ||
1671 | NL80211_TX_POWER_LIMITED, | ||
1672 | NL80211_TX_POWER_FIXED, | ||
1673 | }; | ||
1674 | |||
1662 | #endif /* __LINUX_NL80211_H */ | 1675 | #endif /* __LINUX_NL80211_H */ |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 64374f4cb7c6..9b8b3f486ec8 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -875,19 +875,6 @@ enum wiphy_params_flags { | |||
875 | WIPHY_PARAM_COVERAGE_CLASS = 1 << 4, | 875 | WIPHY_PARAM_COVERAGE_CLASS = 1 << 4, |
876 | }; | 876 | }; |
877 | 877 | ||
878 | /** | ||
879 | * enum tx_power_setting - TX power adjustment | ||
880 | * | ||
881 | * @TX_POWER_AUTOMATIC: the dbm parameter is ignored | ||
882 | * @TX_POWER_LIMITED: limit TX power by the dbm parameter | ||
883 | * @TX_POWER_FIXED: fix TX power to the dbm parameter | ||
884 | */ | ||
885 | enum tx_power_setting { | ||
886 | TX_POWER_AUTOMATIC, | ||
887 | TX_POWER_LIMITED, | ||
888 | TX_POWER_FIXED, | ||
889 | }; | ||
890 | |||
891 | /* | 878 | /* |
892 | * cfg80211_bitrate_mask - masks for bitrate control | 879 | * cfg80211_bitrate_mask - masks for bitrate control |
893 | */ | 880 | */ |
@@ -1149,7 +1136,7 @@ struct cfg80211_ops { | |||
1149 | int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed); | 1136 | int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed); |
1150 | 1137 | ||
1151 | int (*set_tx_power)(struct wiphy *wiphy, | 1138 | int (*set_tx_power)(struct wiphy *wiphy, |
1152 | enum tx_power_setting type, int dbm); | 1139 | enum nl80211_tx_power_setting type, int mbm); |
1153 | int (*get_tx_power)(struct wiphy *wiphy, int *dbm); | 1140 | int (*get_tx_power)(struct wiphy *wiphy, int *dbm); |
1154 | 1141 | ||
1155 | int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, | 1142 | int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 003b6addf5fa..f4efbfa4f237 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -1329,28 +1329,28 @@ static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) | |||
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | static int ieee80211_set_tx_power(struct wiphy *wiphy, | 1331 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
1332 | enum tx_power_setting type, int dbm) | 1332 | enum nl80211_tx_power_setting type, int mbm) |
1333 | { | 1333 | { |
1334 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1334 | struct ieee80211_local *local = wiphy_priv(wiphy); |
1335 | struct ieee80211_channel *chan = local->hw.conf.channel; | 1335 | struct ieee80211_channel *chan = local->hw.conf.channel; |
1336 | u32 changes = 0; | 1336 | u32 changes = 0; |
1337 | 1337 | ||
1338 | switch (type) { | 1338 | switch (type) { |
1339 | case TX_POWER_AUTOMATIC: | 1339 | case NL80211_TX_POWER_AUTOMATIC: |
1340 | local->user_power_level = -1; | 1340 | local->user_power_level = -1; |
1341 | break; | 1341 | break; |
1342 | case TX_POWER_LIMITED: | 1342 | case NL80211_TX_POWER_LIMITED: |
1343 | if (dbm < 0) | 1343 | if (mbm < 0 || (mbm % 100)) |
1344 | return -EINVAL; | 1344 | return -EOPNOTSUPP; |
1345 | local->user_power_level = dbm; | 1345 | local->user_power_level = MBM_TO_DBM(mbm); |
1346 | break; | 1346 | break; |
1347 | case TX_POWER_FIXED: | 1347 | case NL80211_TX_POWER_FIXED: |
1348 | if (dbm < 0) | 1348 | if (mbm < 0 || (mbm % 100)) |
1349 | return -EINVAL; | 1349 | return -EOPNOTSUPP; |
1350 | /* TODO: move to cfg80211 when it knows the channel */ | 1350 | /* TODO: move to cfg80211 when it knows the channel */ |
1351 | if (dbm > chan->max_power) | 1351 | if (MBM_TO_DBM(mbm) > chan->max_power) |
1352 | return -EINVAL; | 1352 | return -EINVAL; |
1353 | local->user_power_level = dbm; | 1353 | local->user_power_level = MBM_TO_DBM(mbm); |
1354 | break; | 1354 | break; |
1355 | } | 1355 | } |
1356 | 1356 | ||
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 96342993cf93..1ff1e9f49136 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -829,7 +829,7 @@ int cfg80211_wext_siwtxpower(struct net_device *dev, | |||
829 | { | 829 | { |
830 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 830 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
831 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 831 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
832 | enum tx_power_setting type; | 832 | enum nl80211_tx_power_setting type; |
833 | int dbm = 0; | 833 | int dbm = 0; |
834 | 834 | ||
835 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) | 835 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) |
@@ -852,7 +852,7 @@ int cfg80211_wext_siwtxpower(struct net_device *dev, | |||
852 | if (data->txpower.value < 0) | 852 | if (data->txpower.value < 0) |
853 | return -EINVAL; | 853 | return -EINVAL; |
854 | dbm = data->txpower.value; | 854 | dbm = data->txpower.value; |
855 | type = TX_POWER_FIXED; | 855 | type = NL80211_TX_POWER_FIXED; |
856 | /* TODO: do regulatory check! */ | 856 | /* TODO: do regulatory check! */ |
857 | } else { | 857 | } else { |
858 | /* | 858 | /* |
@@ -860,10 +860,10 @@ int cfg80211_wext_siwtxpower(struct net_device *dev, | |||
860 | * passed in from userland. | 860 | * passed in from userland. |
861 | */ | 861 | */ |
862 | if (data->txpower.value < 0) { | 862 | if (data->txpower.value < 0) { |
863 | type = TX_POWER_AUTOMATIC; | 863 | type = NL80211_TX_POWER_AUTOMATIC; |
864 | } else { | 864 | } else { |
865 | dbm = data->txpower.value; | 865 | dbm = data->txpower.value; |
866 | type = TX_POWER_LIMITED; | 866 | type = NL80211_TX_POWER_LIMITED; |
867 | } | 867 | } |
868 | } | 868 | } |
869 | } else { | 869 | } else { |
@@ -872,7 +872,7 @@ int cfg80211_wext_siwtxpower(struct net_device *dev, | |||
872 | return 0; | 872 | return 0; |
873 | } | 873 | } |
874 | 874 | ||
875 | return rdev->ops->set_tx_power(wdev->wiphy, type, dbm); | 875 | return rdev->ops->set_tx_power(wdev->wiphy, type, DBM_TO_MBM(dbm)); |
876 | } | 876 | } |
877 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower); | 877 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower); |
878 | 878 | ||