cfg80211: fix antenna gain handling
PATCH 1/2 cfg80211: fix antenna gain handling
When not intersecting, orig->chan_mag is initialized to zero. Because of that, the regulatory antenna gain limit never gets set.
--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/wireless/reg.c +1 -2
@@ -915,8 +915,7 @@ static void handle_channel(struct wiphy *wiphy, chan->beacon_found = false; 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_antenna_gain = (int )MBI_TO_DBI (power_rule->max_antenna_gain); chan->max_reg_power = (int )MBM_TO_DBM (power_rule->max_eirp);if (chan->orig_mpwr) {/*
Signature · 1 line
1.7.9.6 (Apple Git-31.1)
PATCH 2/2 cfg80211: fix initialization of chan->max_reg_power
A few places touch chan->max_power based on updated tx power rules, but forget to do the same to chan->max_reg_power.
--- net/wireless/reg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/wireless/reg.c +3 -2
@@ -908,7 +908,7 @@ static void handle_channel(struct wiphy *wiphy,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_reg_power = chan->max_power = chan->orig_mpwr = (int )MBM_TO_DBM (power_rule->max_eirp);return ; }
@@ -1330,7 +1330,8 @@ static void handle_channel_custom(struct wiphy *wiphy, chan->flags |=map_regdom_flags (reg_rule->flags) | bw_flags; chan->max_antenna_gain = (int )MBI_TO_DBI (power_rule->max_antenna_gain); - chan->max_power = (int )MBM_TO_DBM (power_rule->max_eirp); + chan->max_reg_power = chan->max_power = + (int )MBM_TO_DBM (power_rule->max_eirp); } static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band,
Signature · 1 line
1.7.9.6 (Apple Git-31.1)
Re: [PATCH 3.7 2/2] cfg80211: fix initialization of chan->max_reg_power
Same here -- anyone object? I suspect that Johannes may be a little more busy/distracted than usual for the next few days/weeks...
John
Quoted 36 lines · Felix Fietkau
A few places touch
chan->max_powerbased on updated tx power rules, but forget to do the same tochan->max_reg_power.Signed-off-by Felix Fietkau <[email protected]>--- net/wireless/reg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)net/wireless/reg.c +3
-2@@ -908,7 +908,7 @@ static void handle_channel(struct wiphy *wiphy,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_reg_power = chan->max_power = chan->orig_mpwr = (int )MBM_TO_DBM (power_rule->max_eirp);return ; }@@ -1330,7 +1330,8 @@ static void handle_channel_custom(struct wiphy *wiphy, chan->flags |=map_regdom_flags (reg_rule->flags) | bw_flags; chan->max_antenna_gain = (int )MBI_TO_DBI (power_rule->max_antenna_gain); - chan->max_power = (int )MBM_TO_DBM (power_rule->max_eirp); + chan->max_reg_power = chan->max_power = + (int )MBM_TO_DBM (power_rule->max_eirp); } static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band,Signature · 1 line
1.7.9.6 (Apple Git-31.1)
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Anyone object? I suspect that Johannes may be a little more busy/distracted than usual for the next few days/weeks...
John
Quoted 27 lines · Felix Fietkau
When not intersecting,
orig->chan_magis initialized to zero. Because of that, the regulatory antenna gain limit never gets set.Signed-off-by Felix Fietkau <[email protected]>--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/wireless/reg.c +1
-2@@ -915,8 +915,7 @@ static void handle_channel(struct wiphy *wiphy, chan->beacon_found = false; 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_antenna_gain = (int )MBI_TO_DBI (power_rule->max_antenna_gain); chan->max_reg_power = (int )MBM_TO_DBM (power_rule->max_eirp);if (chan->orig_mpwr) {/* Signature · 1 line
1.7.9.6 (Apple Git-31.1)
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 21 lines · John W. Linville
Anyone object? I suspect that Johannes may be a little more busy/distracted than usual for the next few days/weeks...
John
Quoted 15 lines · Felix Fietkau
When not intersecting,
orig->chan_magis initialized to zero. Because of that, the regulatory antenna gain limit never gets set.Signed-off-by Felix Fietkau <[email protected]>--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/wireless/reg.c +0
-0@@ -915,8 +915,7 @@ static void handle_channel(struct wiphy *wiphy,
Quoted 4 lines
net/wireless/reg.c static void handle_channel(struct wiphy *wiphy, · line 919
Quoted 4 lines
net/wireless/reg.c +0
-2chan->beacon_found = false; 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));
Just reading the commit message, I would think it better to initialize chan->orig_mag to INT_MAX. Just my 0.02$
Gr. AvS
Quoted 9 lines
Quoted 8 lines
net/wireless/reg.c +1
-1+ chan->max_antenna_gain = (int )MBI_TO_DBI (power_rule->max_antenna_gain); chan->max_reg_power = (int )MBM_TO_DBM (power_rule->max_eirp);if (chan->orig_mpwr) {/* -- 1.7.9.6 (Apple Git-31.1)
Quoted 22 lines · Arend van Spriel
Quoted 21 lines · John W. Linville
Anyone object? I suspect that Johannes may be a little more busy/distracted than usual for the next few days/weeks...
John
Quoted 15 lines · Felix Fietkau
When not intersecting,
orig->chan_magis initialized to zero. Because of that, the regulatory antenna gain limit never gets set.Signed-off-by Felix Fietkau <[email protected]>--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/wireless/reg.c +0
-0@@ -915,8 +915,7 @@ static void handle_channel(struct wiphy *wiphy,
Quoted 7 lines
Quoted 4 lines
net/wireless/reg.c static void handle_channel(struct wiphy *wiphy, · line 919
Quoted 4 lines
net/wireless/reg.c +0
-2chan->beacon_found = false; 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));Just reading the commit message, I would think it better to initialize
chan->orig_magtoINT_MAX. Just my 0.02$
I'm not sure it's useful for the driver to be able to add initial max antenna gain restrictions that way (which IMHO is the only point to using chan->orig_mag).
I think it's better (and more predictable) to just stick to the power rules from the regulatory information.
- Felix
Quoted 30 lines · Felix Fietkau
Quoted 22 lines · Arend van Spriel
Quoted 21 lines · John W. Linville
Anyone object? I suspect that Johannes may be a little more busy/distracted than usual for the next few days/weeks...
John
Quoted 15 lines · Felix Fietkau
When not intersecting,
orig->chan_magis initialized to zero. Because of that, the regulatory antenna gain limit never gets set.Signed-off-by Felix Fietkau <[email protected]>--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/wireless/reg.c +0
-0@@ -915,8 +915,7 @@ static void handle_channel(struct wiphy *wiphy,Quoted 7 lines
Quoted 4 lines
net/wireless/reg.c static void handle_channel(struct wiphy *wiphy, · line 919
Quoted 4 lines
net/wireless/reg.c +0
-2chan->beacon_found = false; 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));Just reading the commit message, I would think it better to initialize
chan->orig_magtoINT_MAX. Just my 0.02$
Quoted 8 lines
I'm not sure it's useful for the driver to be able to add initial max antenna gain restrictions that way (which IMHO is the only point to using
chan->orig_mag).
I think it's better (and more predictable) to just stick to the power rules from the regulatory information.- Felix
Ok,
I was not understanding the usage scenario here. Your patch will ignore any driver initialized max antenna gain, which does not sound right to me. What if chan->orig_mag is a sensible (non-zero) value, which is lower than the value in regulatory power rule? Just seems that the patch changes more than the commit message it saying.
Gr. AvS
Quoted 40 lines · Arend van Spriel
Quoted 30 lines · Felix Fietkau
Quoted 22 lines · Arend van Spriel
Quoted 21 lines · John W. Linville
Anyone object? I suspect that Johannes may be a little more busy/distracted than usual for the next few days/weeks...
John
Quoted 15 lines · Felix Fietkau
When not intersecting,
orig->chan_magis initialized to zero. Because of that, the regulatory antenna gain limit never gets set.Signed-off-by Felix Fietkau <[email protected]>--- net/wireless/reg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/wireless/reg.c +0
-0@@ -915,8 +915,7 @@ static void handle_channel(struct wiphy *wiphy,Quoted 7 lines
Quoted 4 lines
net/wireless/reg.c static void handle_channel(struct wiphy *wiphy, · line 919
Quoted 4 lines
net/wireless/reg.c +0
-2chan->beacon_found = false; 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));Just reading the commit message, I would think it better to initialize
chan->orig_magtoINT_MAX. Just my 0.02$Quoted 8 lines
I'm not sure it's useful for the driver to be able to add initial max antenna gain restrictions that way (which IMHO is the only point to using
chan->orig_mag).
I think it's better (and more predictable) to just stick to the power rules from the regulatory information.- Felix
Quoted 7 lines
Ok,
I was not understanding the usage scenario here. Your patch will ignore any driver initialized max antenna gain, which does not sound right to me. What if
chan->orig_magis a sensible (non-zero) value, which is lower than the value in regulatory power rule? Just seems that the patch changes more than the commit message it saying.
I did take another close look at the code and it seems you're right. I will change the code so that it initializes chan->orig_mag to INT_MAX in wiphy_register, and I will make the patch description a bit more verbose as well.
That way the chan->max_antenna_gain value supplied by the driver gets ignored, which is a good thing, considering that only one driver actually uses max_antenna_gain, and no driver initializes it to something useful.
- Felix
Johannes Berg
maintainerQuoted 5 lines · Felix Fietkau
Quoted 5 lines
I was not understanding the usage scenario here. Your patch will ignore any driver initialized max antenna gain, which does not sound right to me. What if
chan->orig_magis a sensible (non-zero) value, which is lower than the value in regulatory power rule? Just seems that the patch changes more than the commit message it saying.
Quoted 8 lines
I did take another close look at the code and it seems you're right. I will change the code so that it initializes
chan->orig_magtoINT_MAXinwiphy_register, and I will make the patch description a bit more verbose as well.
That way thechan->max_antenna_gainvalue supplied by the driver gets ignored, which is a good thing, considering that only one driver actually usesmax_antenna_gain, and no driver initializes it to something useful.
I know we need the "limit to driver value" behaviour for TX power for sure (otherwise the firmware would assert if it goes over)
johannes
Quoted 16 lines · Johannes Berg
Quoted 5 lines · Felix Fietkau
Quoted 5 lines
I was not understanding the usage scenario here. Your patch will ignore any driver initialized max antenna gain, which does not sound right to me. What if
chan->orig_magis a sensible (non-zero) value, which is lower than the value in regulatory power rule? Just seems that the patch changes more than the commit message it saying.Quoted 8 lines
I did take another close look at the code and it seems you're right. I will change the code so that it initializes
chan->orig_magtoINT_MAXinwiphy_register, and I will make the patch description a bit more verbose as well.
That way thechan->max_antenna_gainvalue supplied by the driver gets ignored, which is a good thing, considering that only one driver actually usesmax_antenna_gain, and no driver initializes it to something useful.
Quoted 2 lines
I know we need the "limit to driver value" behaviour for TX power for sure (otherwise the firmware would assert if it goes over)
Sure. This isn't really necessary for max_antenna_gain though, it's up to the driver if it even wants to make use of this (mac80211 doesn't). ath9k uses it to check if tx power needs to be reduced, when an eeprom-specified antenna gain exceeds the regulatory max antenna gain.
I only noticed this, because I'm going to submit a patch soon to add a configurable antenna gain to nl80211/mac80211. It is useful for setups where you have a highly directional antenna with a big antenna gain and want to make sure that the txpower stays within legal limits.
- Felix