* [RFC] bcm43xx-mac80211: Add TX power set file to debugfs
@ 2007-08-06 20:22 Larry Finger
2007-08-06 20:25 ` Michael Buesch
0 siblings, 1 reply; 4+ messages in thread
From: Larry Finger @ 2007-08-06 20:22 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>
---
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
@@ -2762,12 +2762,11 @@ 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) {
- phy->power_level = conf->power_level;
- bcm43xx_phy_xmitpower(dev);
- }
- }
+ if (conf->power_level != 0 && phy->power_level == 0) {
+ phy->power_level = conf->power_level;
+ } else
+ phy->power_level = 10;
+ bcm43xx_phy_xmitpower(dev);
/* Hide/Show the SSID (AP mode only). */
if (conf->flags & IEEE80211_CONF_SSID_HIDDEN) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 20:22 [RFC] bcm43xx-mac80211: Add TX power set file to debugfs Larry Finger
@ 2007-08-06 20:25 ` Michael Buesch
2007-08-06 20:36 ` Larry Finger
0 siblings, 1 reply; 4+ messages in thread
From: Michael Buesch @ 2007-08-06 20:25 UTC (permalink / raw)
To: Larry Finger; +Cc: Bcm43xx-dev, linux-wireless
On Monday 06 August 2007 22:22:14 Larry Finger wrote:
> 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
> @@ -2762,12 +2762,11 @@ 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) {
> - phy->power_level = conf->power_level;
> - bcm43xx_phy_xmitpower(dev);
> - }
> - }
> + if (conf->power_level != 0 && phy->power_level == 0) {
> + phy->power_level = conf->power_level;
> + } else
> + phy->power_level = 10;
> + bcm43xx_phy_xmitpower(dev);
No, what's that? I disagree with that.
This breaks power adjustment.
>
> /* Hide/Show the SSID (AP mode only). */
> if (conf->flags & IEEE80211_CONF_SSID_HIDDEN) {
>
>
--
Greetings Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 20:25 ` Michael Buesch
@ 2007-08-06 20:36 ` Larry Finger
2007-08-06 20:45 ` Michael Buesch
0 siblings, 1 reply; 4+ messages in thread
From: Larry Finger @ 2007-08-06 20:36 UTC (permalink / raw)
To: Michael Buesch; +Cc: Bcm43xx-dev, linux-wireless
Michael Buesch wrote:
> On Monday 06 August 2007 22:22:14 Larry Finger wrote:
>> 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
>> @@ -2762,12 +2762,11 @@ 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) {
>> - phy->power_level = conf->power_level;
>> - bcm43xx_phy_xmitpower(dev);
>> - }
>> - }
>> + if (conf->power_level != 0 && phy->power_level == 0) {
>> + phy->power_level = conf->power_level;
>> + } else
>> + phy->power_level = 10;
>> + bcm43xx_phy_xmitpower(dev);
>
> No, what's that? I disagree with that.
> This breaks power adjustment.
>
I just discovered that it fails. When I find the problem, I'll resubmit. Is the debugfs part right?
Larry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] bcm43xx-mac80211: Add TX power set file to debugfs
2007-08-06 20:36 ` Larry Finger
@ 2007-08-06 20:45 ` Michael Buesch
0 siblings, 0 replies; 4+ messages in thread
From: Michael Buesch @ 2007-08-06 20:45 UTC (permalink / raw)
To: Larry Finger; +Cc: Bcm43xx-dev, linux-wireless
On Monday 06 August 2007 22:36:49 Larry Finger wrote:
> Michael Buesch wrote:
> > On Monday 06 August 2007 22:22:14 Larry Finger wrote:
> >> 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
> >> @@ -2762,12 +2762,11 @@ 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) {
> >> - phy->power_level = conf->power_level;
> >> - bcm43xx_phy_xmitpower(dev);
> >> - }
> >> - }
> >> + if (conf->power_level != 0 && phy->power_level == 0) {
> >> + phy->power_level = conf->power_level;
> >> + } else
> >> + phy->power_level = 10;
> >> + bcm43xx_phy_xmitpower(dev);
> >
> > No, what's that? I disagree with that.
> > This breaks power adjustment.
> >
>
> I just discovered that it fails. When I find the problem, I'll resubmit. Is the debugfs part right?
I think so.
Although, (I think you know that), it does not immediately
reconfigure the power, but waits for the next pwork with enough
tssi information.
--
Greetings Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-06 20:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06 20:22 [RFC] bcm43xx-mac80211: Add TX power set file to debugfs Larry Finger
2007-08-06 20:25 ` Michael Buesch
2007-08-06 20:36 ` Larry Finger
2007-08-06 20:45 ` Michael Buesch
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).