On Fri, Mar 5, 2010 at 11:11 AM, Xingang Zhang <zhang.xing...@gmail.com> wrote:
> "Kornelius Dridger" <kdrid...@mail.uni-paderborn.de> writes:
>
>
>> Hi guys,
>>
>> according to [1] the card transmits on some standard power levels.
>>
>> Can you tell me more about these power levels and how to set them?
>>
>
>  To me, I can adjust the TX power with the help of iwconfig (change
>  wlan0 to whatever you used for your wireless interface):
>
>  sudo iwconfig wlan0 txpower auto  (this is the default)
>
>  sudo iwconfig wlan0 txpower fixed (if you would like the TX power to a
>  fixed value)
>
>  sudo iwconfig wlan0 txpower 10 (set your txpower to 10dBm)
>
>  I am not sure how to get those level with iw command. But you can check
>  your current TX power setting with:
>

txpower is the only command left to add to iw to be able to tell
people to drop iwconfig completely. I was going to do it but have
other things to take care of right now. If someone can take over
that'd be nice. Attached is what I had left.

You'll have to distinguish between fixed power or not, some cards do
cannot support actually setting the txpower at a specific level and
guarantee that it will be used, so it would only use it as a max
power. I think intel cards have this restriction.

  Luis
From 0dff69caefb630d41af7e4cdef1a0d21394813b5 Mon Sep 17 00:00:00 2001
From: Luis R. Rodriguez <lrodrig...@atheros.com>
Date: Fri, 19 Feb 2010 14:14:44 -0800
Subject: [PATCH] cfg80211: add TX power settings command

You can use this to configure the output power used by
your the radio on your 802.11 device. By default the
regulatory maximum output power is used. Some cards
support keeping the output power fixed at all times,
but some other cards do not and can only allow you to
set the maximum output power the card will use.

Signed-off-by: Luis R. Rodriguez <lrodrig...@atheros.com>
---
 include/linux/nl80211.h    |    8 +++++++-
 include/net/cfg80211.h     |    2 ++
 net/wireless/nl80211.c     |   10 ++++++++++
 net/wireless/wext-compat.c |    1 -
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 28ba20f..da3eae7 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -51,7 +51,7 @@
  *	%NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ,
  *	%NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT,
  *	%NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
- *	and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ *	and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD, %NL80211_ATTR_WIPHY_TXPOWER.
  * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
  *	or rename notification. Has attributes %NL80211_ATTR_WIPHY and
  *	%NL80211_ATTR_WIPHY_NAME.
@@ -691,6 +691,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
  *	acknowledged by the recipient.
  *
+ * @NL80211_ATTR_WIPHY_TXPOWER: Target output power, specified in mBm ((100 * dBm) as
+ *	some hardware allows finer granular power control than 1 dBm steps.
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -842,6 +845,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_PS_STATE,
 
+	NL80211_ATTR_WIPHY_TXPOWER,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -875,6 +880,7 @@ enum nl80211_attrs {
 #define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
 #define NL80211_ATTR_KEY NL80211_ATTR_KEY
 #define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
+#define NL80211_ATTR_WIPHY_TXPOWER NL80211_ATTR_WIPHY_TXPOWER
 
 #define NL80211_MAX_SUPP_RATES			32
 #define NL80211_MAX_SUPP_REG_RULES		32
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 3d134a1..ef98d05 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -841,6 +841,7 @@ struct cfg80211_connect_params {
  * WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
  * WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  * WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
+ * WIPHY_PARAM_TXPOWER: wiphy->txpower has changed
  */
 enum wiphy_params_flags {
 	WIPHY_PARAM_RETRY_SHORT		= 1 << 0,
@@ -848,6 +849,7 @@ enum wiphy_params_flags {
 	WIPHY_PARAM_FRAG_THRESHOLD	= 1 << 2,
 	WIPHY_PARAM_RTS_THRESHOLD	= 1 << 3,
 	WIPHY_PARAM_COVERAGE_CLASS	= 1 << 4,
+	WIPHY_PARAM_TXPOWER		= 1 << 5,
 };
 
 /**
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b0495a1..8f86744 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -823,6 +823,12 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 		changed |= WIPHY_PARAM_COVERAGE_CLASS;
 	}
 
+	if (info->attrs[NL80211_ATTR_WIPHY_TXPOWER]) {
+		txpower = nla_get_u32(
+			info->attrs[NL80211_ATTR_WIPHY_TXPOWER]);
+		changed |= WIPHY_PARAM_TXPOWER;
+	}
+
 	if (changed) {
 		u8 old_retry_short, old_retry_long;
 		u32 old_frag_threshold, old_rts_threshold;
@@ -838,6 +844,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 		old_frag_threshold = rdev->wiphy.frag_threshold;
 		old_rts_threshold = rdev->wiphy.rts_threshold;
 		old_coverage_class = rdev->wiphy.coverage_class;
+		old_txpower = rdev->wiphy.txpower;
 
 		if (changed & WIPHY_PARAM_RETRY_SHORT)
 			rdev->wiphy.retry_short = retry_short;
@@ -849,6 +856,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 			rdev->wiphy.rts_threshold = rts_threshold;
 		if (changed & WIPHY_PARAM_COVERAGE_CLASS)
 			rdev->wiphy.coverage_class = coverage_class;
+		if (changed & WIPHY_PARAM_TXPOWER)
+			rdev->wiphy.txpower = txpower;
 
 		result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed);
 		if (result) {
@@ -857,6 +866,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 			rdev->wiphy.frag_threshold = old_frag_threshold;
 			rdev->wiphy.rts_threshold = old_rts_threshold;
 			rdev->wiphy.coverage_class = old_coverage_class;
+			rdev->wiphy.txpower = old_txpower;
 		}
 	}
 
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 9ab5183..5fa50d2 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -847,7 +847,6 @@ int cfg80211_wext_siwtxpower(struct net_device *dev,
 				return -EINVAL;
 			dbm = data->txpower.value;
 			type = TX_POWER_FIXED;
-			/* TODO: do regulatory check! */
 		} else {
 			/*
 			 * Automatic power level setting, max being the value
-- 
1.6.3.3

_______________________________________________
ath5k-devel mailing list
ath5k-devel@lists.ath5k.org
https://lists.ath5k.org/mailman/listinfo/ath5k-devel

Reply via email to