Revert eccc068e8e84c8fe997115629925e0422a98e4de which causes txpower
to be stuck at 0.
Recent OpenWRT has txpower stuck at 0 for at least rt28xx, and I
found this commit as the root cause:
http://git.kernel.org/?p=linux/kernel/git/linville/wireless-next.git;a=commitdiff;h=eccc068e8e84c8fe997115629925e0422a98e4de
Before reverting this "iw phy phy0 info" would show "0.0 dBm" as
maximum transmit power for all frequencies.
After reverting this (and with regdomain set to CH) it is back to
the expected 20 dBm.
Signed-off-by: Tobias Diedrich <[email protected]>
Index: package/mac80211/patches/900-revert-txpower-stuck-at-zero-bad-commit.patch
===================================================================
--- package/mac80211/patches/900-revert-txpower-stuck-at-zero-bad-commit.patch (revision 0)
+++ package/mac80211/patches/900-revert-txpower-stuck-at-zero-bad-commit.patch (revision 0)
@@ -0,0 +1,30 @@
+Index: compat-wireless-2012-04-26/net/wireless/reg.c
+===================================================================
+--- compat-wireless-2012-04-26.orig/net/wireless/reg.c 2012-05-06 16:39:36.314688959 +0200
++++ compat-wireless-2012-04-26/net/wireless/reg.c 2012-05-06 16:54:11.199571334 +0200
+@@ -892,8 +892,23 @@
+ chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags);
+ chan->max_antenna_gain = min(chan->orig_mag,
+ (int) MBI_TO_DBI(power_rule->max_antenna_gain));
+- chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp);
+- chan->max_power = min(chan->max_power, chan->max_reg_power);
++ if (chan->orig_mpwr) {
++ /*
++ * Devices that have their own custom regulatory domain
++ * but also use WIPHY_FLAG_STRICT_REGULATORY will follow the
++ * passed country IE power settings.
++ */
++ if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
++ wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY &&
++ wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) {
++ chan->max_power =
++ MBM_TO_DBM(power_rule->max_eirp);
++ } else {
++ chan->max_power = min(chan->orig_mpwr,
++ (int) MBM_TO_DBM(power_rule->max_eirp));
++ }
++ } else
++ chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp);
+ }
+
+ static void handle_band(struct wiphy *wiphy,
Helmut Schaa wrote:
> On Sun, May 6, 2012 at 5:38 PM, Tobias Diedrich
> > Before reverting this "iw phy phy0 info" would show "0.0 dBm" as
> > maximum transmit power for all frequencies.
> >
> > After reverting this (and with regdomain set to CH) it is back to
> > the expected 20 dBm.
>
> Ok, the problem seems to come from the fact that rt2800 doesn't
> register a per channel
> max power to mac80211.
BTW I have a secondary issue that I've today bisected down to some
change between compat-wireless-2012-04-11 and
compat-wireless-2012-04-12, but I still need to narrow it down
further and verify it.
Even with the max_power issue fixed associating with an rt28xx AP
running compat-wireless-2012-04-12 or higher doesn't work (IIRC AP
claims wpa auth succeeded, but STA claims it timed out).
STA mode worked fine though (But only tested it once on Sunday).
--
Tobias PGP: http://8ef7ddba.uguu.de
Helmut Schaa wrote:
> Luis, with rt2800 we are not really able to provide an accurate max tx power :(
> so, can we restore the previous behavior in reg.c? Or maybe do something like
>
> if (chan->max_reg_power)
> chan->max_power = min(chan->max_power, chan->max_reg_power);
>
> Tobias, does that work for you as well?
Nope, the problem is that chan->max_power is 0, so this will work:
if (chan->max_power == 0)
chan->max_power = chan->max_reg_power;
else
chan->max_power = min(chan->max_power, chan->max_reg_power);
Also, in the if-branch above that chan->max_reg_power is never set, I
wonder if that should be
chan->max_power = chan->orig_mpwr = chan->max_reg_power =
(int) MBM_TO_DBM(power_rule->max_eirp);
instead of
chan->max_power = chan->orig_mpwr =
(int) MBM_TO_DBM(power_rule->max_eirp);
(But I don't seem to hit that if-block juding from some printks I added)
--
Tobias PGP: http://8ef7ddba.uguu.de
Hello Tobias,
Tobias Diedrich wrote:
> Revert eccc068e8e84c8fe997115629925e0422a98e4de which causes txpower
> to be stuck at 0.
>
> Recent OpenWRT has txpower stuck at 0 for at least rt28xx, and I
> found this commit as the root cause:
> http://git.kernel.org/?p=linux/kernel/git/linville/wireless-next.git;a=commitdiff;h=eccc068e8e84c8fe997115629925e0422a98e4de
>
> Before reverting this "iw phy phy0 info" would show "0.0 dBm" as
> maximum transmit power for all frequencies.
>
> After reverting this (and with regdomain set to CH) it is back to
> the expected 20 dBm.
I can confirm this, too (rt2800pci|usb).
Thanks,
kind regards,
Andreas
Tobias Diedrich wrote:
> Helmut Schaa wrote:
> > On Sun, May 6, 2012 at 5:38 PM, Tobias Diedrich
> > > Before reverting this "iw phy phy0 info" would show "0.0 dBm" as
> > > maximum transmit power for all frequencies.
> > >
> > > After reverting this (and with regdomain set to CH) it is back to
> > > the expected 20 dBm.
> >
> > Ok, the problem seems to come from the fact that rt2800 doesn't
> > register a per channel
> > max power to mac80211.
>
> BTW I have a secondary issue that I've today bisected down to some
> change between compat-wireless-2012-04-11 and
> compat-wireless-2012-04-12, but I still need to narrow it down
> further and verify it.
> Even with the max_power issue fixed associating with an rt28xx AP
> running compat-wireless-2012-04-12 or higher doesn't work (IIRC AP
> claims wpa auth succeeded, but STA claims it timed out).
> STA mode worked fine though (But only tested it once on Sunday).
I've bisected it down to commit 3edaf3e61fda3aa9ff8d38445bf92f2bec23bf63:
"mac80211: manage AP netdev carrier state"
I verified it against compat-wireless-2012-04-17 (latest OpenWRT
mac80211 package) and after reverting this on top of the other patch
AP mode works again for my rt305x-based APs.
So these are my patches now (The net/wireless/reg.c patch still has
two debug printks in it):
Index: compat-wireless-2012-02-06/net/wireless/reg.c
===================================================================
--- compat-wireless-2012-02-06.orig/net/wireless/reg.c 2012-05-07 19:27:35.966242549 +0200
+++ compat-wireless-2012-02-06/net/wireless/reg.c 2012-05-07 19:42:57.883440781 +0200
@@ -874,7 +874,8 @@
map_regdom_flags(reg_rule->flags) | bw_flags;
chan->max_antenna_gain = chan->orig_mag =
(int) MBI_TO_DBI(power_rule->max_antenna_gain);
- chan->max_power = chan->orig_mpwr =
+ chan->max_power = chan->orig_mpwr = chan->max_reg_power =
(int) MBM_TO_DBM(power_rule->max_eirp);
+ printk(KERN_INFO "max_power = max_reg_power = %d\n", chan->max_power);
return;
}
@@ -884,7 +884,11 @@
chan->max_antenna_gain = min(chan->orig_mag,
(int) MBI_TO_DBI(power_rule->max_antenna_gain));
chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp);
+ printk(KERN_INFO "max_power = %d, max_reg_power = %d\n", chan->max_power, chan->max_reg_power);
- chan->max_power = min(chan->max_power, chan->max_reg_power);
+ if (chan->max_power == 0)
+ chan->max_power = chan->max_reg_power;
+ else
+ chan->max_power = min(chan->max_power, chan->max_reg_power);
}
static void handle_band(struct wiphy *wiphy,
Index: compat-wireless-2012-04-17/net/mac80211/cfg.c
===================================================================
--- compat-wireless-2012-04-17.orig/net/mac80211/cfg.c 2012-05-09 01:00:39.247974053 +0200
+++ compat-wireless-2012-04-17/net/mac80211/cfg.c 2012-05-09 01:02:32.514918371 +0200
@@ -656,10 +656,6 @@
ieee80211_bss_info_change_notify(sdata, changed);
- netif_carrier_on(dev);
- list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
- netif_carrier_on(vlan->dev);
-
return 0;
}
@@ -685,7 +681,7 @@
static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
{
- struct ieee80211_sub_if_data *sdata, *vlan;
+ struct ieee80211_sub_if_data *sdata;
struct beacon_data *old;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -694,10 +690,6 @@
if (!old)
return -ENOENT;
- list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
- netif_carrier_off(vlan->dev);
- netif_carrier_off(dev);
-
RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
kfree_rcu(old, rcu_head);
Index: compat-wireless-2012-04-17/net/mac80211/iface.c
===================================================================
--- compat-wireless-2012-04-17.orig/net/mac80211/iface.c 2012-05-09 01:00:39.197975402 +0200
+++ compat-wireless-2012-04-17/net/mac80211/iface.c 2012-05-09 01:02:32.514918371 +0200
@@ -356,11 +356,7 @@
switch (sdata->vif.type) {
case NL80211_IFTYPE_AP_VLAN:
- /* no need to tell driver, but set carrier */
- if (rtnl_dereference(sdata->bss->beacon))
- netif_carrier_on(dev);
- else
- netif_carrier_off(dev);
+ /* no need to tell driver */
break;
case NL80211_IFTYPE_MONITOR:
if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
@@ -411,8 +407,7 @@
ieee80211_bss_info_change_notify(sdata, changed);
if (sdata->vif.type == NL80211_IFTYPE_STATION ||
- sdata->vif.type == NL80211_IFTYPE_ADHOC ||
- sdata->vif.type == NL80211_IFTYPE_AP)
+ sdata->vif.type == NL80211_IFTYPE_ADHOC)
netif_carrier_off(dev);
else
netif_carrier_on(dev);
On Sun, May 6, 2012 at 5:38 PM, Tobias Diedrich
<[email protected]> wrote:
> Revert eccc068e8e84c8fe997115629925e0422a98e4de which causes txpower
> to be stuck at 0.
>
> Recent OpenWRT has txpower stuck at 0 for at least rt28xx, and I
> found this commit as the root cause:
> http://git.kernel.org/?p=linux/kernel/git/linville/wireless-next.git;a=commitdiff;h=eccc068e8e84c8fe997115629925e0422a98e4de
>
> Before reverting this "iw phy phy0 info" would show "0.0 dBm" as
> maximum transmit power for all frequencies.
>
> After reverting this (and with regdomain set to CH) it is back to
> the expected 20 dBm.
>
>
> Signed-off-by: Tobias Diedrich <[email protected]>
Ok, the problem seems to come from the fact that rt2800 doesn't
register a per channel
max power to mac80211.
Luis, with rt2800 we are not really able to provide an accurate max tx power :(
so, can we restore the previous behavior in reg.c? Or maybe do something like
if (chan->max_reg_power)
chan->max_power = min(chan->max_power, chan->max_reg_power);
Tobias, does that work for you as well?
Thanks,
Helmut