* [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs
@ 2007-08-06 20:55 Larry Finger
2007-08-06 21:07 ` Michael Buesch
0 siblings, 1 reply; 5+ messages in thread
From: Larry Finger @ 2007-08-06 20:55 UTC (permalink / raw)
To: Michael Buesch; +Cc: Bcm43xx-dev, linux-wireless
For testing purposes, this patch adds a file named "power_level" to the
debugfs for bcm43xx-mac80211. If this file is read, it returns the current
setting for the "Desired power level". Writing a number between 5 and 18
will set that value as the new value for the desired power setting.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
Michael,
The error before is fixed in this version.
Larry
Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
===================================================================
--- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
+++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
@@ -151,6 +151,74 @@ out_unlock_bb:
return res;
}
+static ssize_t power_read_file(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct bcm43xx_wldev *dev = file->private_data;
+ const size_t len = ARRAY_SIZE(big_buffer);
+ char *buf = big_buffer;
+ size_t pos = 0;
+ ssize_t res;
+ unsigned long flags;
+
+ mutex_lock(&big_buffer_mutex);
+ mutex_lock(&dev->wl->mutex);
+ spin_lock_irqsave(&dev->wl->irq_lock, flags);
+ if (bcm43xx_status(dev) < BCM43xx_STAT_STARTED) {
+ fappend("Board not initialized.\n");
+ goto out;
+ }
+ fappend("%d dBm\n",dev->phy.power_level);
+
+out:
+ spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
+ mutex_unlock(&dev->wl->mutex);
+ res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+ mutex_unlock(&big_buffer_mutex);
+
+ return res;
+}
+
+static ssize_t power_write_file(struct file *file, const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct bcm43xx_wldev *dev = file->private_data;
+ char *buf = big_buffer;
+ ssize_t buf_size;
+ ssize_t res;
+ unsigned long flags;
+ int power;
+
+ mutex_lock(&big_buffer_mutex);
+ buf_size = min(count, ARRAY_SIZE(big_buffer) - 1);
+ if (copy_from_user(buf, user_buf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock_bb;
+ }
+ mutex_lock(&dev->wl->mutex);
+ spin_lock_irqsave(&dev->wl->irq_lock, flags);
+ if (bcm43xx_status(dev) < BCM43xx_STAT_STARTED) {
+ bcmerr(dev->wl, "debugfs: Board not initialized.\n");
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ if ((sscanf(buf, "%d", &power) != 1) || (power > 18 || power < 5)) {
+ bcmerr(dev->wl, "debugfs: Invalid values for power level\n");
+ res = -EINVAL;
+ goto out_unlock;
+ }
+ dev->phy.power_level = power;
+ res = buf_size;
+
+out_unlock:
+ spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
+ mutex_unlock(&dev->wl->mutex);
+out_unlock_bb:
+ mutex_unlock(&big_buffer_mutex);
+
+ return res;
+}
+
static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos)
{
@@ -405,6 +473,12 @@ static struct file_operations restart_fo
.open = open_file_generic,
};
+static struct file_operations power_fops = {
+ .read = power_read_file,
+ .write = power_write_file,
+ .open = open_file_generic,
+};
+
int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
{
@@ -495,6 +569,11 @@ void bcm43xx_debugfs_add_device(struct b
if (IS_ERR(e->dentry_restart))
e->dentry_restart = NULL;
+ e->dentry_power = debugfs_create_file("power_level", 0600, e->subdir,
+ dev, &power_fops);
+ if (IS_ERR(e->dentry_power))
+ e->dentry_power = NULL;
+
bcm43xx_add_dynamic_debug(dev);
}
@@ -512,6 +591,7 @@ void bcm43xx_debugfs_remove_device(struc
debugfs_remove(e->dentry_txstat);
debugfs_remove(e->dentry_restart);
debugfs_remove(e->dentry_txpower_g);
+ debugfs_remove(e->dentry_power);
debugfs_remove(e->subdir);
kfree(e->txstatlog.log);
kfree(e);
Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
===================================================================
--- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
+++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
@@ -35,6 +35,7 @@ struct bcm43xx_dfsentry {
struct dentry *dentry_txstat;
struct dentry *dentry_txpower_g;
struct dentry *dentry_restart;
+ struct dentry *dentry_power;
struct bcm43xx_wldev *dev;
Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
===================================================================
--- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
+++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
@@ -2763,7 +2763,8 @@ static int bcm43xx_dev_config(struct iee
/* Adjust the desired TX power level. */
if (conf->power_level != 0) {
- if (conf->power_level != phy->power_level) {
+ if (conf->power_level != phy->power_level &&
+ phy->power_level == 0) {
phy->power_level = conf->power_level;
bcm43xx_phy_xmitpower(dev);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 20:55 [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs Larry Finger
@ 2007-08-06 21:07 ` Michael Buesch
2007-08-06 21:26 ` Larry Finger
0 siblings, 1 reply; 5+ messages in thread
From: Michael Buesch @ 2007-08-06 21:07 UTC (permalink / raw)
To: bcm43xx-dev; +Cc: Larry Finger, linux-wireless
On Monday 06 August 2007 22:55:30 Larry Finger wrote:
> For testing purposes, this patch adds a file named "power_level" to the
> debugfs for bcm43xx-mac80211. If this file is read, it returns the current
> setting for the "Desired power level". Writing a number between 5 and 18
> will set that value as the new value for the desired power setting.
>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> ---
>
> Michael,
>
> The error before is fixed in this version.
>
> Larry
>
> Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
> ===================================================================
> --- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
> +++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
> @@ -151,6 +151,74 @@ out_unlock_bb:
> return res;
> }
>
> +static ssize_t power_read_file(struct file *file, char __user *userbuf,
> + size_t count, loff_t *ppos)
> +{
> + struct bcm43xx_wldev *dev = file->private_data;
> + const size_t len = ARRAY_SIZE(big_buffer);
> + char *buf = big_buffer;
> + size_t pos = 0;
> + ssize_t res;
> + unsigned long flags;
> +
> + mutex_lock(&big_buffer_mutex);
> + mutex_lock(&dev->wl->mutex);
> + spin_lock_irqsave(&dev->wl->irq_lock, flags);
> + if (bcm43xx_status(dev) < BCM43xx_STAT_STARTED) {
> + fappend("Board not initialized.\n");
> + goto out;
> + }
> + fappend("%d dBm\n",dev->phy.power_level);
> +
> +out:
> + spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
> + mutex_unlock(&dev->wl->mutex);
> + res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
> + mutex_unlock(&big_buffer_mutex);
> +
> + return res;
> +}
> +
> +static ssize_t power_write_file(struct file *file, const char __user *user_buf,
> + size_t count, loff_t *ppos)
> +{
> + struct bcm43xx_wldev *dev = file->private_data;
> + char *buf = big_buffer;
> + ssize_t buf_size;
> + ssize_t res;
> + unsigned long flags;
> + int power;
> +
> + mutex_lock(&big_buffer_mutex);
> + buf_size = min(count, ARRAY_SIZE(big_buffer) - 1);
> + if (copy_from_user(buf, user_buf, buf_size)) {
> + res = -EFAULT;
> + goto out_unlock_bb;
> + }
> + mutex_lock(&dev->wl->mutex);
> + spin_lock_irqsave(&dev->wl->irq_lock, flags);
> + if (bcm43xx_status(dev) < BCM43xx_STAT_STARTED) {
> + bcmerr(dev->wl, "debugfs: Board not initialized.\n");
> + res = -EFAULT;
> + goto out_unlock;
> + }
> + if ((sscanf(buf, "%d", &power) != 1) || (power > 18 || power < 5)) {
> + bcmerr(dev->wl, "debugfs: Invalid values for power level\n");
> + res = -EINVAL;
> + goto out_unlock;
> + }
> + dev->phy.power_level = power;
> + res = buf_size;
> +
> +out_unlock:
> + spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
> + mutex_unlock(&dev->wl->mutex);
> +out_unlock_bb:
> + mutex_unlock(&big_buffer_mutex);
> +
> + return res;
> +}
> +
> static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
> size_t count, loff_t *ppos)
> {
> @@ -405,6 +473,12 @@ static struct file_operations restart_fo
> .open = open_file_generic,
> };
>
> +static struct file_operations power_fops = {
> + .read = power_read_file,
> + .write = power_write_file,
> + .open = open_file_generic,
> +};
> +
>
> int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
> {
> @@ -495,6 +569,11 @@ void bcm43xx_debugfs_add_device(struct b
> if (IS_ERR(e->dentry_restart))
> e->dentry_restart = NULL;
>
> + e->dentry_power = debugfs_create_file("power_level", 0600, e->subdir,
> + dev, &power_fops);
> + if (IS_ERR(e->dentry_power))
> + e->dentry_power = NULL;
> +
> bcm43xx_add_dynamic_debug(dev);
> }
>
> @@ -512,6 +591,7 @@ void bcm43xx_debugfs_remove_device(struc
> debugfs_remove(e->dentry_txstat);
> debugfs_remove(e->dentry_restart);
> debugfs_remove(e->dentry_txpower_g);
> + debugfs_remove(e->dentry_power);
> debugfs_remove(e->subdir);
> kfree(e->txstatlog.log);
> kfree(e);
> Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
> ===================================================================
> --- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
> +++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
> @@ -35,6 +35,7 @@ struct bcm43xx_dfsentry {
> struct dentry *dentry_txstat;
> struct dentry *dentry_txpower_g;
> struct dentry *dentry_restart;
> + struct dentry *dentry_power;
>
> struct bcm43xx_wldev *dev;
>
> Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
> ===================================================================
> --- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
> +++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
> @@ -2763,7 +2763,8 @@ static int bcm43xx_dev_config(struct iee
>
> /* Adjust the desired TX power level. */
> if (conf->power_level != 0) {
> - if (conf->power_level != phy->power_level) {
> + if (conf->power_level != phy->power_level &&
> + phy->power_level == 0) {
> phy->power_level = conf->power_level;
> bcm43xx_phy_xmitpower(dev);
> }
No, why do you poke with this at all.
This completely breaks power adjustment from mac80211.
Simply don't touch bcm43xx_dev_config :)
--
Greetings Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 21:07 ` Michael Buesch
@ 2007-08-06 21:26 ` Larry Finger
2007-08-06 21:35 ` Michael Buesch
0 siblings, 1 reply; 5+ messages in thread
From: Larry Finger @ 2007-08-06 21:26 UTC (permalink / raw)
To: Michael Buesch; +Cc: bcm43xx-dev, linux-wireless
Michael Buesch wrote:
>
> No, why do you poke with this at all.
> This completely breaks power adjustment from mac80211.
> Simply don't touch bcm43xx_dev_config :)
>
The problem is that mac80211 never seems to do any power adjustment. The funny 0x1b value for power
level that I wondered about earlier is coming from a value of 27 dBm that is set in
net/mac80211/regdomain.c, and conf->power_level doesn't get any information from anywhere else that
I see.
Do you know how to get mac80211 to change what it is sending to us?
Larry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 21:26 ` Larry Finger
@ 2007-08-06 21:35 ` Michael Buesch
2007-08-07 0:37 ` Tomas Winkler
0 siblings, 1 reply; 5+ messages in thread
From: Michael Buesch @ 2007-08-06 21:35 UTC (permalink / raw)
To: bcm43xx-dev; +Cc: Larry Finger, linux-wireless
On Monday 06 August 2007 23:26:07 Larry Finger wrote:
> Michael Buesch wrote:
> >
> > No, why do you poke with this at all.
> > This completely breaks power adjustment from mac80211.
> > Simply don't touch bcm43xx_dev_config :)
> >
>
> The problem is that mac80211 never seems to do any power adjustment. The funny 0x1b value for power
> level that I wondered about earlier is coming from a value of 27 dBm that is set in
> net/mac80211/regdomain.c, and conf->power_level doesn't get any information from anywhere else that
> I see.
>
> Do you know how to get mac80211 to change what it is sending to us?
I think we have an ioctl.
But it's probably the task of the rc algorithm to adjust power.
--
Greetings Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 21:35 ` Michael Buesch
@ 2007-08-07 0:37 ` Tomas Winkler
0 siblings, 0 replies; 5+ messages in thread
From: Tomas Winkler @ 2007-08-07 0:37 UTC (permalink / raw)
To: Michael Buesch; +Cc: bcm43xx-dev, Larry Finger, linux-wireless
On 8/7/07, Michael Buesch <mb@bu3sch.de> wrote:
> On Monday 06 August 2007 23:26:07 Larry Finger wrote:
> > Michael Buesch wrote:
> > >
> > > No, why do you poke with this at all.
> > > This completely breaks power adjustment from mac80211.
> > > Simply don't touch bcm43xx_dev_config :)
> > >
> >
> > The problem is that mac80211 never seems to do any power adjustment. The funny 0x1b value for power
> > level that I wondered about earlier is coming from a value of 27 dBm that is set in
> > net/mac80211/regdomain.c, and conf->power_level doesn't get any information from anywhere else that
> > I see.
> >
> > Do you know how to get mac80211 to change what it is sending to us?
>
> I think we have an ioctl.
> But it's probably the task of the rc algorithm to adjust power.
>
11k and 11h have TPC features in as well.
Even though tx power affects link quality it is not usually part of
rate scaling.
> --
> Greetings Michael.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-08-07 0:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06 20:55 [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs Larry Finger
2007-08-06 21:07 ` Michael Buesch
2007-08-06 21:26 ` Larry Finger
2007-08-06 21:35 ` Michael Buesch
2007-08-07 0:37 ` Tomas Winkler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).