Linux wireless drivers development
 help / color / mirror / Atom feed
* Re: [PATCH] wl12xx: remove warning message during IBSS Tx
From: Shahar Lev @ 2011-10-08 20:30 UTC (permalink / raw)
  To: Luciano Coelho; +Cc: Arik Nemtsov, Johannes Berg, linux-wireless
In-Reply-To: <1318104160.9690.49.camel@cumari>

Part of a plot to increase the chances of my submissions getting
through by posing as Mr. Levi.

Thanks,
The Other Shahar

On Sat, Oct 8, 2011 at 10:02 PM, Luciano Coelho <coelho@ti.com> wrote:
> On Sat, 2011-10-08 at 21:55 +0200, Arik Nemtsov wrote:
>> On Sat, Oct 8, 2011 at 21:45, Luciano Coelho <coelho@ti.com> wrote:
>> >
>> > But what I meant with "the bug" was that, if this can be avoided in
>> > mac80211, why not do it there? Is it a a big effort to do it in
>> > mac80211?
>>
>> Not sure it's a big effort, but it requires testing etc. I'm afraid
>> we're all pretty busy with other stuff right now :)
>
> Not a very good excuse when it comes to upstreaming, but okay, I'll take
> this in anyway. :)
>
> Thanks, Shahar, and welcome! :)
>
> (BTW, Shahar Lev is not to be confused with Shahar Levi, as they are two
> different persons :)
>
> --
> Cheers,
> Luca.
>
>

^ permalink raw reply

* [PATCH 2/2] ath9k: only send FCS-fail packets to mac80211 if requested
From: Felix Fietkau @ 2011-10-08 20:02 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof
In-Reply-To: <1318104179-90126-1-git-send-email-nbd@openwrt.org>

Prevents lots of broken frames from showing up on monitor interfaces
by default.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/recv.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index c7306dc..bc71c0e 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -811,6 +811,7 @@ static bool ath9k_rx_accept(struct ath_common *common,
 			    struct ath_rx_status *rx_stats,
 			    bool *decrypt_error)
 {
+	struct ath_softc *sc = (struct ath_softc *) common->priv;
 	bool is_mc, is_valid_tkip, strip_mic, mic_error;
 	struct ath_hw *ah = common->ah;
 	__le16 fc;
@@ -875,7 +876,7 @@ static bool ath9k_rx_accept(struct ath_common *common,
 		status_mask = ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
 			      ATH9K_RXERR_KEYMISS;
 
-		if (ah->is_monitoring)
+		if (ah->is_monitoring && (sc->rx.rxfilter & FIF_FCSFAIL))
 			status_mask |= ATH9K_RXERR_CRC;
 
 		if (rx_stats->rs_status & ~status_mask)
-- 
1.7.3.2


^ permalink raw reply related

* [PATCH 1/2] ath9k_hw: fix a regression in key miss handling
From: Felix Fietkau @ 2011-10-08 20:02 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof

The commit "ath9k_hw: Fix incorrect key_miss handling" changed the code
to only report key miss errors if a MIC error wasn't reported.
When checking the flags in that order in the MAC code, it might miss some
real events, because the value of the MIC error flag is undefined under
some conditions.

The primary issue addressed by the previous commit is making sure that
MIC errors are properly reported on the STA side. This can be fixed in
a better way by adding a separate rx status flag for key miss and
ignoring it for multicast frames.

This fix slightly improves stability in AP mode on some older hardware,
like AR9132.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
---
 drivers/net/wireless/ath/ath9k/ar9003_mac.c |    4 ++--
 drivers/net/wireless/ath/ath9k/mac.c        |    4 ++--
 drivers/net/wireless/ath/ath9k/mac.h        |    1 +
 drivers/net/wireless/ath/ath9k/recv.c       |   27 ++++++++++++++-------------
 4 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index 6cabc85..b363cc0 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -525,8 +525,8 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
 			rxs->rs_status |= ATH9K_RXERR_DECRYPT;
 		else if (rxsp->status11 & AR_MichaelErr)
 			rxs->rs_status |= ATH9K_RXERR_MIC;
-		else if (rxsp->status11 & AR_KeyMiss)
-			rxs->rs_status |= ATH9K_RXERR_DECRYPT;
+		if (rxsp->status11 & AR_KeyMiss)
+			rxs->rs_status |= ATH9K_RXERR_KEYMISS;
 	}
 
 	return 0;
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 22f23ea..43f53d6 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -620,8 +620,8 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
 			rs->rs_status |= ATH9K_RXERR_DECRYPT;
 		else if (ads.ds_rxstatus8 & AR_MichaelErr)
 			rs->rs_status |= ATH9K_RXERR_MIC;
-		else if (ads.ds_rxstatus8 & AR_KeyMiss)
-			rs->rs_status |= ATH9K_RXERR_DECRYPT;
+		if (ads.ds_rxstatus8 & AR_KeyMiss)
+			rs->rs_status |= ATH9K_RXERR_KEYMISS;
 	}
 
 	return 0;
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index 91c9654..934caa7 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -181,6 +181,7 @@ struct ath_htc_rx_status {
 #define ATH9K_RXERR_FIFO          0x04
 #define ATH9K_RXERR_DECRYPT       0x08
 #define ATH9K_RXERR_MIC           0x10
+#define ATH9K_RXERR_KEYMISS       0x20
 
 #define ATH9K_RX_MORE             0x01
 #define ATH9K_RX_MORE_AGGR        0x02
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index f658ec6..c7306dc 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -823,7 +823,8 @@ static bool ath9k_rx_accept(struct ath_common *common,
 		test_bit(rx_stats->rs_keyix, common->tkip_keymap);
 	strip_mic = is_valid_tkip && ieee80211_is_data(fc) &&
 		!(rx_stats->rs_status &
-		(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC));
+		(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC |
+		 ATH9K_RXERR_KEYMISS));
 
 	if (!rx_stats->rs_datalen)
 		return false;
@@ -851,6 +852,8 @@ static bool ath9k_rx_accept(struct ath_common *common,
 	 * descriptors.
 	 */
 	if (rx_stats->rs_status != 0) {
+		u8 status_mask;
+
 		if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
 			rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
 			mic_error = false;
@@ -858,7 +861,8 @@ static bool ath9k_rx_accept(struct ath_common *common,
 		if (rx_stats->rs_status & ATH9K_RXERR_PHY)
 			return false;
 
-		if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
+		if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) ||
+		    (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) {
 			*decrypt_error = true;
 			mic_error = false;
 		}
@@ -868,17 +872,14 @@ static bool ath9k_rx_accept(struct ath_common *common,
 		 * decryption and MIC failures. For monitor mode,
 		 * we also ignore the CRC error.
 		 */
-		if (ah->is_monitoring) {
-			if (rx_stats->rs_status &
-			    ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
-			      ATH9K_RXERR_CRC))
-				return false;
-		} else {
-			if (rx_stats->rs_status &
-			    ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
-				return false;
-			}
-		}
+		status_mask = ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
+			      ATH9K_RXERR_KEYMISS;
+
+		if (ah->is_monitoring)
+			status_mask |= ATH9K_RXERR_CRC;
+
+		if (rx_stats->rs_status & ~status_mask)
+			return false;
 	}
 
 	/*
-- 
1.7.3.2


^ permalink raw reply related

* Re: [PATCH] wl12xx: remove warning message during IBSS Tx
From: Luciano Coelho @ 2011-10-08 20:02 UTC (permalink / raw)
  To: Arik Nemtsov; +Cc: Shahar Lev, Johannes Berg, linux-wireless
In-Reply-To: <CA+XVXff_5isgfReUYXh8K1nNTtAqnFp5tb36EKLL7MBaTka+UQ@mail.gmail.com>

On Sat, 2011-10-08 at 21:55 +0200, Arik Nemtsov wrote: 
> On Sat, Oct 8, 2011 at 21:45, Luciano Coelho <coelho@ti.com> wrote:
> >
> > But what I meant with "the bug" was that, if this can be avoided in
> > mac80211, why not do it there? Is it a a big effort to do it in
> > mac80211?
> 
> Not sure it's a big effort, but it requires testing etc. I'm afraid
> we're all pretty busy with other stuff right now :)

Not a very good excuse when it comes to upstreaming, but okay, I'll take
this in anyway. :)

Thanks, Shahar, and welcome! :)

(BTW, Shahar Lev is not to be confused with Shahar Levi, as they are two
different persons :)

-- 
Cheers,
Luca.


^ permalink raw reply

* Re: [PATCH] wl12xx: remove warning message during IBSS Tx
From: Arik Nemtsov @ 2011-10-08 19:55 UTC (permalink / raw)
  To: Luciano Coelho; +Cc: Shahar Lev, Johannes Berg, linux-wireless
In-Reply-To: <1318103127.9690.46.camel@cumari>

On Sat, Oct 8, 2011 at 21:45, Luciano Coelho <coelho@ti.com> wrote:
>
> But what I meant with "the bug" was that, if this can be avoided in
> mac80211, why not do it there? Is it a a big effort to do it in
> mac80211?

Not sure it's a big effort, but it requires testing etc. I'm afraid
we're all pretty busy with other stuff right now :)

Arik

^ permalink raw reply

* Re: [PATCH] wl12xx: remove warning message during IBSS Tx
From: Luciano Coelho @ 2011-10-08 19:45 UTC (permalink / raw)
  To: Arik Nemtsov; +Cc: Shahar Lev, Johannes Berg, linux-wireless
In-Reply-To: <CA+XVXfd+vN7b=oYrysPCuynAgy5=4SgRHuznJRW0h+6ez7YqsQ@mail.gmail.com>

On Sat, 2011-10-08 at 21:19 +0200, Arik Nemtsov wrote: 
> On Fri, Oct 7, 2011 at 23:17, Luciano Coelho <coelho@ti.com> wrote:
> > On Fri, 2011-10-07 at 23:03 +0200, Shahar Lev wrote:
> >> On Fri, Oct 7, 2011 at 6:20 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> >> > Maybe you should also change that? :-)
> >>
> >> Consider it added to our collective TODO.
> >
> > Well, the fix is probably supposed to be done in mac80211, instead of
> > hiding the bug by removing the warning, isn't it?
> 
> Sometimes data is sent when the IBSS interface is not connected.
> wl12xx handles this correctly by throwing the packets. In this sense
> there's no "bug".
> All this patch does is remove warning messages that confuse the users
> (and developers).
> 
> I agree fixing mac80211 is the better thing to do, and we'll get to it
> when time permits.

Okay, not a big problem to do this in the driver.

But what I meant with "the bug" was that, if this can be avoided in
mac80211, why not do it there? Is it a a big effort to do it in
mac80211?


-- 
Cheers,
Luca.


^ permalink raw reply

* problem in b43_nrssi_hw_update()?
From: Dan Carpenter @ 2011-10-08 19:29 UTC (permalink / raw)
  To: mb; +Cc: linux-wireless

My latest testing version of Smatch complains about the wrapping in
b43_nrssi_hw_update() when val is 0xffff. The function is defined
like this:

/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)
{
        u16 i;
        s16 tmp;

	for (i = 0; i < 64; i++) {
                tmp = b43_nrssi_hw_read(dev, i);
                tmp -= val;
                tmp = clamp_val(tmp, -32, 31);
                b43_nrssi_hw_write(dev, i, tmp);
        }
}

It's only called from one place like this:

                /* The specs state to update the NRSSI LT with
                 * the value 0x7FFFFFFF here. I think that is some weird
                 * compiler optimization in the original driver.
                 * Essentially, what we do here is resetting all NRSSI LT
                 * entries to -32 (see the clamp_val() in nrssi_hw_update())
                 */
                b43_nrssi_hw_update(dev, 0xFFFF);       //FIXME?

Since tmp in b43_nrssi_hw_update() is s16 and val is always
(u16)0xFFFF, that means that:
	tmp -= val;
is always the same just tmp += 1;

This code has a fixme, and it seems like an overly complicated way
of adding 1 to a variable, plus it doesn't seem to match the
documentation very well.  :P

I know you've looked at this before and that's why it has the FIXME
comment...  I'm not sure what to do...

regards,
dan carpenter

^ permalink raw reply

* Re: [PATCH] wl12xx: remove warning message during IBSS Tx
From: Arik Nemtsov @ 2011-10-08 19:19 UTC (permalink / raw)
  To: Luciano Coelho; +Cc: Shahar Lev, Johannes Berg, linux-wireless
In-Reply-To: <1318022253.3549.108.camel@cumari>

On Fri, Oct 7, 2011 at 23:17, Luciano Coelho <coelho@ti.com> wrote:
> On Fri, 2011-10-07 at 23:03 +0200, Shahar Lev wrote:
>> On Fri, Oct 7, 2011 at 6:20 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> > Maybe you should also change that? :-)
>>
>> Consider it added to our collective TODO.
>
> Well, the fix is probably supposed to be done in mac80211, instead of
> hiding the bug by removing the warning, isn't it?

Sometimes data is sent when the IBSS interface is not connected.
wl12xx handles this correctly by throwing the packets. In this sense
there's no "bug".
All this patch does is remove warning messages that confuse the users
(and developers).

I agree fixing mac80211 is the better thing to do, and we'll get to it
when time permits.

Arik

^ permalink raw reply

* Compat-wireless release for 2011-10-08 is baked
From: Compat-wireless cronjob account @ 2011-10-08 19:02 UTC (permalink / raw)
  To: linux-wireless


compat-wireless code metrics

    811845 - Total upstream lines of code being pulled
      2431 - backport code changes
      2113 - backport code additions
       318 - backport code deletions
      8588 - backport from compat module
     11019 - total backport code
    1.3573 - % of code consists of backport work

^ permalink raw reply

* Re: [PATCH 0/8] wireless: add DFS master support
From: Luis R. Rodriguez @ 2011-10-08 18:26 UTC (permalink / raw)
  To: Zefir Kurtisi; +Cc: linux-wireless, linville, Johannes Berg
In-Reply-To: <4E908C6D.7040703@neratec.com>

On Sat, Oct 8, 2011 at 10:46 AM, Zefir Kurtisi
<zefir.kurtisi@neratec.com> wrote:
> On 08.10.2011 00:32, Luis R. Rodriguez wrote:
>>
>> On Fri, Oct 7, 2011 at 3:29 PM, Luis R. Rodriguez
>> <mcgrof@qca.qualcomm.com>  wrote:
>>>
>>> On Fri, Oct 7, 2011 at 2:11 PM, Luis R. Rodriguez
>>> <mcgrof@qca.qualcomm.com>  wrote:
>>>>
>>>> On Tue, Oct 4, 2011 at 5:14 PM, Luis R. Rodriguez
>>>> <mcgrof@qca.qualcomm.com>  wrote:
>>>>>
>>>>> On Tue, Oct 4, 2011 at 4:47 PM, Luis R. Rodriguez
>>>>> <mcgrof@qca.qualcomm.com>  wrote:
>>>>>>
>>>>>> This set of 8 patches adds DFS master support to the Linux wireless
>>>>>> subsystem.
>>>>>> I've reviewed future possible changes to DFS master regions and it
>>>>>> seems that
>>>>>> we are not going to be having multiple DFS regions for one country,
>>>>>> instead
>>>>>> we'll always have one DFS region for one country.
>>>>>>
>>>>>> The changes here are spread out throughout wireless-regdb, crda the
>>>>>> kernel and
>>>>>> lastly iw. The changes made allow for older verions of CRDA to work
>>>>>> with new
>>>>>> wireless-regdb files with DFS region support. If you want DFS master
>>>>>> region
>>>>>> support you'll need to upgrade your CRDA, your kernel and then hope
>>>>>> someone
>>>>>> implements DFS master support for your respective driver.
>>>>>>
>>>>>> This patch series does not have specific driver changes, although some
>>>>>> seem to
>>>>>> be backing in the oven right now.
>>>>>
>>>>> Here's a puzzle though... If we change this series to use the other
>>>>> pad byte that was available, the first pad byte, instead of the last
>>>>> one, we loose backward compatibility support and I cannot figure out
>>>>> why. What I ended up seeing was that crda sends the message, and for
>>>>> some reason (return code is 222 from nl_wait_for_ack(), whatever that
>>>>> is) the kernel rejects it. I suspect it may have to do with some sort
>>>>> of offset to the *other* data that makes some of the rules output
>>>>> invalid data for the attribute policy, but at least when I hexdump the
>>>>> wireless-regdb the only changes I see are in the signature and the pad
>>>>> shift.
>>>>>
>>>>> I got tired of trying though and after seeing flipping the pad bytes
>>>>> things worked decided to stay with it. In my original RFC in December
>>>>> I had used u16 instead, but since the data was in the last pad byte
>>>>> things still worked. So something is fishy about only using the first
>>>>> pad byte. The change below, as far as I can tell, should not have any
>>>>> issues but it does with the older version of CRDA and even a new one.
>>>>
>>>> Johannes spotted the issue, I'll send the fix, thanks to Johannes.
>>>> John, Johannes the patches still apply my fix goes on top of these
>>>> changes, the fix is not addressing a regression introduced by this
>>>> patchset, instead it fixes a long standing issue which would prevent
>>>> us from using the next available pad byte.
>>>
>>> I'm going to respin this to make use of 2 bits:
>>>
>>> 00 unset
>>> 01 FCC
>>> 10 ETSI
>>> 11 JP
>>>
>>> We may need some more DFS values later but
>>
>> Sorry I did not finish this e-mail I meant that we may later have a
>> requirement for more DFS values but at this time we don't, we should
>> consider whether or not we will want to leave more bits for usage of
>> more DFS values and if so how many? Using two bits will give us
>> support for what we know today but nothing for the future.
>>
> For the future things we do not know of today we should add another bit and
> define
>
> 111 unknown / other
>
> to be able to mark special countrycodes that do not fully belong to the
> three known domains.

I thought about this a bit more, so we'd have to define this as a U8
attribute either way, so I would instead of calling NL80211_DFS_REGION
call it something like NL80211_CTRY_REQS and for now only use 2 bits
for the known DFS regions. We'd mask out the rest of the values. If we
ever decide we need a new DFS region we could just extend the values
on NL80211_CTRY_REQS after the last region. If we want to add a new
requirement that is country specific other than DFS we could start at
the end of the u8 instead of after the last DFS region. We could do
this without making any explicit reservations.

> We could use some invalid coding for those CCs (like no
> DFS domain set in CC

Sure, I should point out today every single regulatory domain will
have this set except US, only because I added a patch to match US to
DFS-FCC DFS region.

> but flag set for frequency band) to identify those
> special domains,

So you're saying in case later we find out we need band specific DFS data later?

> but using an additional bit would make things easier to
> handle.

We can extend this as we go, and just ensure upon review of new code
that we accommodate non -DFS crap at the end of the u8. Whatdya think?

  Luis

^ permalink raw reply

* [PATCH v3 3/4] ath: remove ath_regulatory::current_rd_ext
From: Felix Fietkau @ 2011-10-08 18:06 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof
In-Reply-To: <1318097182-78364-2-git-send-email-nbd@openwrt.org>

It is unused since the previous dead code that was using it had been
removed earlier.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath.h           |    1 -
 drivers/net/wireless/ath/ath9k/hw.c      |    5 -----
 drivers/net/wireless/ath/carl9170/main.c |    1 -
 3 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index bb71b4f..908fdbc 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -72,7 +72,6 @@ struct ath_regulatory {
 	u16 country_code;
 	u16 max_power_level;
 	u16 current_rd;
-	u16 current_rd_ext;
 	int16_t power_limit;
 	struct reg_dmn_pair_mapping *regpair;
 };
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 949656d..fd7c207 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2072,11 +2072,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
 	eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
 	regulatory->current_rd = eeval;
 
-	eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1);
-	if (AR_SREV_9285_12_OR_LATER(ah))
-		eeval |= AR9285_RDEXT_DEFAULT;
-	regulatory->current_rd_ext = eeval;
-
 	if (ah->opmode != NL80211_IFTYPE_AP &&
 	    ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
 		if (regulatory->current_rd == 0x64 ||
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index beca710..f06e069 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1896,7 +1896,6 @@ static int carl9170_parse_eeprom(struct ar9170 *ar)
 		ar->hw->channel_change_time = 80 * 1000;
 
 	regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]);
-	regulatory->current_rd_ext = le16_to_cpu(ar->eeprom.reg_domain[1]);
 
 	/* second part of wiphy init */
 	SET_IEEE80211_PERM_ADDR(ar->hw, ar->eeprom.mac_address);
-- 
1.7.3.2


^ permalink raw reply related

* [PATCH v3 2/4] ath9k_hw: clean up tx power handling
From: Felix Fietkau @ 2011-10-08 18:06 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof
In-Reply-To: <1318097182-78364-1-git-send-email-nbd@openwrt.org>

The code for handling various restrictions concerning regulatory limits,
antenna gain, etc. is very convoluted and duplicated across various
EEPROM parsing implementations, making it hard to review.

This patch partially cleans up the mess by unifying regulatory limit
handling in one function and simplifying handling of antenna gain.
It also removes unused transmit power scaling arrays from the EEPROM code,
which belonged to an unimplemented API that isn't supposed to be in
the driver anyway.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath.h                 |    1 -
 drivers/net/wireless/ath/ath9k/ar5008_phy.c    |   11 +----
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |   39 +++------------
 drivers/net/wireless/ath/ath9k/ar9003_paprd.c  |    9 +---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c    |   11 +----
 drivers/net/wireless/ath/ath9k/common.c        |    6 ++-
 drivers/net/wireless/ath/ath9k/eeprom.h        |    7 ++-
 drivers/net/wireless/ath/ath9k/eeprom_4k.c     |   27 ++--------
 drivers/net/wireless/ath/ath9k/eeprom_9287.c   |   33 ++----------
 drivers/net/wireless/ath/ath9k/eeprom_def.c    |   43 +++++------------
 drivers/net/wireless/ath/ath9k/hw.c            |   63 ++++++++++++++++--------
 drivers/net/wireless/ath/ath9k/hw.h            |    9 +---
 drivers/net/wireless/ath/ath9k/init.c          |    2 -
 13 files changed, 85 insertions(+), 176 deletions(-)

diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index 4ed7f24..bb71b4f 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -71,7 +71,6 @@ struct ath_regulatory {
 	char alpha2[2];
 	u16 country_code;
 	u16 max_power_level;
-	u32 tp_scale;
 	u16 current_rd;
 	u16 current_rd_ext;
 	int16_t power_limit;
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 0a749c8..f199e9e 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -763,10 +763,8 @@ static void ar5008_hw_set_channel_regs(struct ath_hw *ah,
 static int ar5008_hw_process_ini(struct ath_hw *ah,
 				 struct ath9k_channel *chan)
 {
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ath_common *common = ath9k_hw_common(ah);
 	int i, regWrites = 0;
-	struct ieee80211_channel *channel = chan->chan;
 	u32 modesIndex, freqIndex;
 
 	switch (chan->chanmode) {
@@ -903,14 +901,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
 	ar5008_hw_set_channel_regs(ah, chan);
 	ar5008_hw_init_chain_masks(ah);
 	ath9k_olc_init(ah);
-
-	/* Set TX power */
-	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(regulatory, chan),
-				 channel->max_antenna_gain * 2,
-				 channel->max_power * 2,
-				 min((u32) MAX_RATE_POWER,
-				 (u32) regulatory->power_limit), false);
+	ath9k_hw_apply_txpower(ah, chan);
 
 	/* Write analog registers */
 	if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 51398f0..d7a5ca7 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3021,6 +3021,10 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
 		return (pBase->miscConfiguration >> 0x3) & 0x1;
 	case EEP_ANT_DIV_CTL1:
 		return eep->base_ext1.ant_div_control;
+	case EEP_ANTENNA_GAIN_5G:
+		return eep->modalHeader5G.antennaGain;
+	case EEP_ANTENNA_GAIN_2G:
+		return eep->modalHeader2G.antennaGain;
 	default:
 		return 0;
 	}
@@ -4764,20 +4768,14 @@ static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
 static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
 					       struct ath9k_channel *chan,
 					       u8 *pPwrArray, u16 cfgCtl,
-					       u8 twiceAntennaReduction,
-					       u8 twiceMaxRegulatoryPower,
+					       u8 antenna_reduction,
 					       u16 powerLimit)
 {
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ath_common *common = ath9k_hw_common(ah);
 	struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
 	u16 twiceMaxEdgePower = MAX_RATE_POWER;
-	static const u16 tpScaleReductionTable[5] = {
-		0, 3, 6, 9, MAX_RATE_POWER
-	};
 	int i;
-	int16_t  twiceLargestAntenna;
-	u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
+	u16 scaledPower = 0, minCtlPower;
 	static const u16 ctlModesFor11a[] = {
 		CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
 	};
@@ -4795,28 +4793,7 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
 	bool is2ghz = IS_CHAN_2GHZ(chan);
 
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
-
-	/* Compute TxPower reduction due to Antenna Gain */
-	if (is2ghz)
-		twiceLargestAntenna = pEepData->modalHeader2G.antennaGain;
-	else
-		twiceLargestAntenna = pEepData->modalHeader5G.antennaGain;
-
-	twiceLargestAntenna = (int16_t)min((twiceAntennaReduction) -
-				twiceLargestAntenna, 0);
-
-	/*
-	 * scaledPower is the minimum of the user input power level
-	 * and the regulatory allowed power level
-	 */
-	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-
-	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
-		maxRegAllowedPower -=
-			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
-	}
-
-	scaledPower = min(powerLimit, maxRegAllowedPower);
+	scaledPower = powerLimit - antenna_reduction;
 
 	/*
 	 * Reduce scaled Power by number of chains active to get
@@ -5003,7 +4980,6 @@ static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx)
 static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
 					struct ath9k_channel *chan, u16 cfgCtl,
 					u8 twiceAntennaReduction,
-					u8 twiceMaxRegulatoryPower,
 					u8 powerLimit, bool test)
 {
 	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
@@ -5056,7 +5032,6 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
 	ar9003_hw_set_power_per_rate_table(ah, chan,
 					   targetPowerValT2, cfgCtl,
 					   twiceAntennaReduction,
-					   twiceMaxRegulatoryPower,
 					   powerLimit);
 
 	if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index 609acb2..a1a08b3 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -19,7 +19,6 @@
 
 void ar9003_paprd_enable(struct ath_hw *ah, bool val)
 {
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ath9k_channel *chan = ah->curchan;
 	struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
 
@@ -54,13 +53,7 @@ void ar9003_paprd_enable(struct ath_hw *ah, bool val)
 
 	if (val) {
 		ah->paprd_table_write_done = true;
-
-		ah->eep_ops->set_txpower(ah, chan,
-				ath9k_regd_get_ctl(regulatory, chan),
-				chan->chan->max_antenna_gain * 2,
-				chan->chan->max_power * 2,
-				min((u32) MAX_RATE_POWER,
-				(u32) regulatory->power_limit), false);
+		ath9k_hw_apply_txpower(ah, chan);
 	}
 
 	REG_RMW_FIELD(ah, AR_PHY_PAPRD_CTRL0_B0,
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 7db6e86..779f407 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -631,9 +631,7 @@ static void ar9003_hw_prog_ini(struct ath_hw *ah,
 static int ar9003_hw_process_ini(struct ath_hw *ah,
 				 struct ath9k_channel *chan)
 {
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	unsigned int regWrites = 0, i;
-	struct ieee80211_channel *channel = chan->chan;
 	u32 modesIndex;
 
 	switch (chan->chanmode) {
@@ -693,14 +691,7 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
 	ar9003_hw_override_ini(ah);
 	ar9003_hw_set_channel_regs(ah, chan);
 	ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
-
-	/* Set TX power */
-	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(regulatory, chan),
-				 channel->max_antenna_gain * 2,
-				 channel->max_power * 2,
-				 min((u32) MAX_RATE_POWER,
-				 (u32) regulatory->power_limit), false);
+	ath9k_hw_apply_txpower(ah, chan);
 
 	return 0;
 }
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index dc705a2..905f1b3 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -161,10 +161,12 @@ EXPORT_SYMBOL(ath9k_cmn_count_streams);
 void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
 			    u16 new_txpow, u16 *txpower)
 {
-	if (cur_txpow != new_txpow) {
+	struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
+
+	if (reg->power_limit != new_txpow) {
 		ath9k_hw_set_txpowerlimit(ah, new_txpow, false);
 		/* read back in case value is clamped */
-		*txpower = ath9k_hw_regulatory(ah)->power_limit;
+		*txpower = reg->max_power_level;
 	}
 }
 EXPORT_SYMBOL(ath9k_cmn_update_txpow);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
index 5d92f96..909a224 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
@@ -248,7 +248,9 @@ enum eeprom_param {
 	EEP_PAPRD,
 	EEP_MODAL_VER,
 	EEP_ANT_DIV_CTL1,
-	EEP_CHAIN_MASK_REDUCE
+	EEP_CHAIN_MASK_REDUCE,
+	EEP_ANTENNA_GAIN_2G,
+	EEP_ANTENNA_GAIN_5G
 };
 
 enum ar5416_rates {
@@ -652,8 +654,7 @@ struct eeprom_ops {
 	void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
 	void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
 			   u16 cfgCtl, u8 twiceAntennaReduction,
-			   u8 twiceMaxRegulatoryPower, u8 powerLimit,
-			   bool test);
+			   u8 powerLimit, bool test);
 	u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
 };
 
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index 303560e..ab6811d 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -350,6 +350,8 @@ static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah,
 		return pModal->antdiv_ctl1;
 	case EEP_TXGAIN_TYPE:
 		return pBase->txGainType;
+	case EEP_ANTENNA_GAIN_2G:
+		return pModal->antennaGainCh[0];
 	default:
 		return 0;
 	}
@@ -462,8 +464,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 						 struct ath9k_channel *chan,
 						 int16_t *ratesArray,
 						 u16 cfgCtl,
-						 u16 AntennaReduction,
-						 u16 twiceMaxRegulatoryPower,
+						 u16 antenna_reduction,
 						 u16 powerLimit)
 {
 #define CMP_TEST_GRP \
@@ -472,20 +473,16 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 	|| (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \
 	    ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))
 
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	int i;
-	int16_t twiceLargestAntenna;
 	u16 twiceMinEdgePower;
 	u16 twiceMaxEdgePower = MAX_RATE_POWER;
-	u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
+	u16 scaledPower = 0, minCtlPower;
 	u16 numCtlModes;
 	const u16 *pCtlMode;
 	u16 ctlMode, freq;
 	struct chan_centers centers;
 	struct cal_ctl_data_4k *rep;
 	struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
-	static const u16 tpScaleReductionTable[5] =
-		{ 0, 3, 6, 9, MAX_RATE_POWER };
 	struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
 		0, { 0, 0, 0, 0}
 	};
@@ -503,19 +500,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
 
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
 
-	twiceLargestAntenna = pEepData->modalHeader.antennaGainCh[0];
-	twiceLargestAntenna = (int16_t)min(AntennaReduction -
-					   twiceLargestAntenna, 0);
-
-	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
-		maxRegAllowedPower -=
-			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
-	}
-
-	scaledPower = min(powerLimit, maxRegAllowedPower);
-	scaledPower = max((u16)0, scaledPower);
-
+	scaledPower = powerLimit - antenna_reduction;
 	numCtlModes = ARRAY_SIZE(ctlModesFor11g) - SUB_NUM_CTL_MODES_AT_2G_40;
 	pCtlMode = ctlModesFor11g;
 
@@ -671,7 +656,6 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 				    struct ath9k_channel *chan,
 				    u16 cfgCtl,
 				    u8 twiceAntennaReduction,
-				    u8 twiceMaxRegulatoryPower,
 				    u8 powerLimit, bool test)
 {
 	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
@@ -691,7 +675,6 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 	ath9k_hw_set_4k_power_per_rate_table(ah, chan,
 					     &ratesArray[0], cfgCtl,
 					     twiceAntennaReduction,
-					     twiceMaxRegulatoryPower,
 					     powerLimit);
 
 	ath9k_hw_set_4k_power_cal_table(ah, chan);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 6698b72..90d771f 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -336,6 +336,9 @@ static u32 ath9k_hw_ar9287_get_eeprom(struct ath_hw *ah,
 			return pBase->tempSensSlopePalOn;
 		else
 			return 0;
+	case EEP_ANTENNA_GAIN_2G:
+		return max_t(u8, pModal->antennaGainCh[0],
+				 pModal->antennaGainCh[1]);
 	default:
 		return 0;
 	}
@@ -554,8 +557,7 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
 						     struct ath9k_channel *chan,
 						     int16_t *ratesArray,
 						     u16 cfgCtl,
-						     u16 AntennaReduction,
-						     u16 twiceMaxRegulatoryPower,
+						     u16 antenna_reduction,
 						     u16 powerLimit)
 {
 #define CMP_CTL \
@@ -569,12 +571,8 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN     6
 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN   10
 
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	u16 twiceMaxEdgePower = MAX_RATE_POWER;
-	static const u16 tpScaleReductionTable[5] =
-		{ 0, 3, 6, 9, MAX_RATE_POWER };
 	int i;
-	int16_t twiceLargestAntenna;
 	struct cal_ctl_data_ar9287 *rep;
 	struct cal_target_power_leg targetPowerOfdm = {0, {0, 0, 0, 0} },
 				    targetPowerCck = {0, {0, 0, 0, 0} };
@@ -582,7 +580,7 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
 				    targetPowerCckExt = {0, {0, 0, 0, 0} };
 	struct cal_target_power_ht targetPowerHt20,
 				    targetPowerHt40 = {0, {0, 0, 0, 0} };
-	u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
+	u16 scaledPower = 0, minCtlPower;
 	static const u16 ctlModesFor11g[] = {
 		CTL_11B, CTL_11G, CTL_2GHT20,
 		CTL_11B_EXT, CTL_11G_EXT, CTL_2GHT40
@@ -597,24 +595,7 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
 	tx_chainmask = ah->txchainmask;
 
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
-
-	/* Compute TxPower reduction due to Antenna Gain */
-	twiceLargestAntenna = max(pEepData->modalHeader.antennaGainCh[0],
-				  pEepData->modalHeader.antennaGainCh[1]);
-	twiceLargestAntenna = (int16_t)min((AntennaReduction) -
-					   twiceLargestAntenna, 0);
-
-	/*
-	 * scaledPower is the minimum of the user input power level
-	 * and the regulatory allowed power level.
-	 */
-	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-
-	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX)
-		maxRegAllowedPower -=
-			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
-
-	scaledPower = min(powerLimit, maxRegAllowedPower);
+	scaledPower = powerLimit - antenna_reduction;
 
 	/*
 	 * Reduce scaled Power by number of chains active
@@ -815,7 +796,6 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
 static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah,
 					struct ath9k_channel *chan, u16 cfgCtl,
 					u8 twiceAntennaReduction,
-					u8 twiceMaxRegulatoryPower,
 					u8 powerLimit, bool test)
 {
 	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
@@ -834,7 +814,6 @@ static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah,
 	ath9k_hw_set_ar9287_power_per_rate_table(ah, chan,
 						 &ratesArray[0], cfgCtl,
 						 twiceAntennaReduction,
-						 twiceMaxRegulatoryPower,
 						 powerLimit);
 
 	ath9k_hw_set_ar9287_power_cal_table(ah, chan);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index eda681f..e175e20 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -400,6 +400,7 @@ static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah,
 	struct ar5416_eeprom_def *eep = &ah->eeprom.def;
 	struct modal_eep_header *pModal = eep->modalHeader;
 	struct base_eep_header *pBase = &eep->baseEepHeader;
+	int band = 0;
 
 	switch (param) {
 	case EEP_NFTHRESH_5:
@@ -467,6 +468,14 @@ static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah,
 			return pBase->pwr_table_offset;
 		else
 			return AR5416_PWR_TABLE_OFFSET_DB;
+	case EEP_ANTENNA_GAIN_2G:
+		band = 1;
+		/* fall through */
+	case EEP_ANTENNA_GAIN_5G:
+		return max_t(u8, max_t(u8,
+			pModal[band].antennaGainCh[0],
+			pModal[band].antennaGainCh[1]),
+			pModal[band].antennaGainCh[2]);
 	default:
 		return 0;
 	}
@@ -986,21 +995,15 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 						  struct ath9k_channel *chan,
 						  int16_t *ratesArray,
 						  u16 cfgCtl,
-						  u16 AntennaReduction,
-						  u16 twiceMaxRegulatoryPower,
+						  u16 antenna_reduction,
 						  u16 powerLimit)
 {
 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN     6  /* 10*log10(2)*2 */
 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN   9 /* 10*log10(3)*2 */
 
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
 	u16 twiceMaxEdgePower = MAX_RATE_POWER;
-	static const u16 tpScaleReductionTable[5] =
-		{ 0, 3, 6, 9, MAX_RATE_POWER };
-
 	int i;
-	int16_t twiceLargestAntenna;
 	struct cal_ctl_data *rep;
 	struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
 		0, { 0, 0, 0, 0}
@@ -1012,7 +1015,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 	struct cal_target_power_ht targetPowerHt20, targetPowerHt40 = {
 		0, {0, 0, 0, 0}
 	};
-	u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
+	u16 scaledPower = 0, minCtlPower;
 	static const u16 ctlModesFor11a[] = {
 		CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
 	};
@@ -1031,27 +1034,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
 
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
 
-	twiceLargestAntenna = max(
-		pEepData->modalHeader
-			[IS_CHAN_2GHZ(chan)].antennaGainCh[0],
-		pEepData->modalHeader
-			[IS_CHAN_2GHZ(chan)].antennaGainCh[1]);
-
-	twiceLargestAntenna = max((u8)twiceLargestAntenna,
-				  pEepData->modalHeader
-				  [IS_CHAN_2GHZ(chan)].antennaGainCh[2]);
-
-	twiceLargestAntenna = (int16_t)min(AntennaReduction -
-					   twiceLargestAntenna, 0);
-
-	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
-
-	if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
-		maxRegAllowedPower -=
-			(tpScaleReductionTable[(regulatory->tp_scale)] * 2);
-	}
-
-	scaledPower = min(powerLimit, maxRegAllowedPower);
+	scaledPower = powerLimit - antenna_reduction;
 
 	switch (ar5416_get_ntxchains(tx_chainmask)) {
 	case 1:
@@ -1256,7 +1239,6 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
 				    struct ath9k_channel *chan,
 				    u16 cfgCtl,
 				    u8 twiceAntennaReduction,
-				    u8 twiceMaxRegulatoryPower,
 				    u8 powerLimit, bool test)
 {
 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
@@ -1278,7 +1260,6 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
 	ath9k_hw_set_def_power_per_rate_table(ah, chan,
 					       &ratesArray[0], cfgCtl,
 					       twiceAntennaReduction,
-					       twiceMaxRegulatoryPower,
 					       powerLimit);
 
 	ath9k_hw_set_def_power_cal_table(ah, chan);
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 42ebe8f..949656d 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -433,7 +433,6 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
 
 	regulatory->country_code = CTRY_DEFAULT;
 	regulatory->power_limit = MAX_RATE_POWER;
-	regulatory->tp_scale = ATH9K_TP_SCALE_MAX;
 
 	ah->hw_version.magic = AR5416_MAGIC;
 	ah->hw_version.subvendorid = 0;
@@ -1389,9 +1388,7 @@ static bool ath9k_hw_chip_reset(struct ath_hw *ah,
 static bool ath9k_hw_channel_change(struct ath_hw *ah,
 				    struct ath9k_channel *chan)
 {
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
 	struct ath_common *common = ath9k_hw_common(ah);
-	struct ieee80211_channel *channel = chan->chan;
 	u32 qnum;
 	int r;
 
@@ -1416,14 +1413,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 		return false;
 	}
 	ath9k_hw_set_clockrate(ah);
-
-	ah->eep_ops->set_txpower(ah, chan,
-			     ath9k_regd_get_ctl(regulatory, chan),
-			     channel->max_antenna_gain * 2,
-			     channel->max_power * 2,
-			     min((u32) MAX_RATE_POWER,
-			     (u32) regulatory->power_limit), false);
-
+	ath9k_hw_apply_txpower(ah, chan);
 	ath9k_hw_rfbus_done(ah);
 
 	if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
@@ -2498,23 +2488,56 @@ bool ath9k_hw_disable(struct ath_hw *ah)
 }
 EXPORT_SYMBOL(ath9k_hw_disable);
 
+static int get_antenna_gain(struct ath_hw *ah, struct ath9k_channel *chan)
+{
+	enum eeprom_param gain_param;
+
+	if (IS_CHAN_2GHZ(chan))
+		gain_param = EEP_ANTENNA_GAIN_2G;
+	else
+		gain_param = EEP_ANTENNA_GAIN_5G;
+
+	return ah->eep_ops->get_eeprom(ah, gain_param);
+}
+
+void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
+{
+	struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
+	struct ieee80211_channel *channel;
+	int chan_pwr, new_pwr, max_gain;
+	int ant_gain, ant_reduction = 0;
+
+	if (!chan)
+		return;
+
+	channel = chan->chan;
+	chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
+	new_pwr = min_t(int, chan_pwr, reg->power_limit);
+	max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2;
+
+	ant_gain = get_antenna_gain(ah, chan);
+	if (ant_gain > max_gain)
+		ant_reduction = ant_gain - max_gain;
+
+	ah->eep_ops->set_txpower(ah, chan,
+				 ath9k_regd_get_ctl(reg, chan),
+				 ant_reduction, new_pwr, false);
+}
+
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
 {
-	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
+	struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
 	struct ath9k_channel *chan = ah->curchan;
 	struct ieee80211_channel *channel = chan->chan;
-	int reg_pwr = min_t(int, MAX_RATE_POWER, limit);
-	int chan_pwr = channel->max_power * 2;
 
+	reg->power_limit = min_t(int, limit, MAX_RATE_POWER);
 	if (test)
-		reg_pwr = chan_pwr = MAX_RATE_POWER;
+		channel->max_power = MAX_RATE_POWER / 2;
 
-	regulatory->power_limit = reg_pwr;
+	ath9k_hw_apply_txpower(ah, chan);
 
-	ah->eep_ops->set_txpower(ah, chan,
-				 ath9k_regd_get_ctl(regulatory, chan),
-				 channel->max_antenna_gain * 2,
-				 chan_pwr, reg_pwr, test);
+	if (test)
+		channel->max_power = DIV_ROUND_UP(reg->max_power_level, 2);
 }
 EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit);
 
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 24889f7..684c33c 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -390,14 +390,6 @@ enum ath9k_power_mode {
 	ATH9K_PM_UNDEFINED
 };
 
-enum ath9k_tp_scale {
-	ATH9K_TP_SCALE_MAX = 0,
-	ATH9K_TP_SCALE_50,
-	ATH9K_TP_SCALE_25,
-	ATH9K_TP_SCALE_12,
-	ATH9K_TP_SCALE_MIN
-};
-
 enum ser_reg_mode {
 	SER_REG_MODE_OFF = 0,
 	SER_REG_MODE_ON = 1,
@@ -968,6 +960,7 @@ void ath9k_hw_htc_resetinit(struct ath_hw *ah);
 /* PHY */
 void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
 				   u32 *coef_mantissa, u32 *coef_exponent);
+void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan);
 
 /*
  * Code Specific to AR5008, AR9001 or AR9002,
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 39514de..af1b325 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -626,7 +626,6 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
 	struct ieee80211_supported_band *sband;
 	struct ieee80211_channel *chan;
 	struct ath_hw *ah = sc->sc_ah;
-	struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
 	int i;
 
 	sband = &sc->sbands[band];
@@ -635,7 +634,6 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
 		ah->curchan = &ah->channels[chan->hw_value];
 		ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
 		ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
-		chan->max_power = reg->max_power_level / 2;
 	}
 }
 
-- 
1.7.3.2


^ permalink raw reply related

* [PATCH v3 4/4] ath9k_hw: remove EEP_REG_1
From: Felix Fietkau @ 2011-10-08 18:06 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof
In-Reply-To: <1318097182-78364-3-git-send-email-nbd@openwrt.org>

It was previously used for current_rd_ext

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |    2 --
 drivers/net/wireless/ath/ath9k/eeprom.h        |    1 -
 drivers/net/wireless/ath/ath9k/eeprom_4k.c     |    2 --
 drivers/net/wireless/ath/ath9k/eeprom_9287.c   |    2 --
 drivers/net/wireless/ath/ath9k/eeprom_def.c    |    2 --
 5 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index d7a5ca7..bf08acc 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2995,8 +2995,6 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
 		return get_unaligned_be16(eep->macAddr + 4);
 	case EEP_REG_0:
 		return le16_to_cpu(pBase->regDmn[0]);
-	case EEP_REG_1:
-		return le16_to_cpu(pBase->regDmn[1]);
 	case EEP_OP_CAP:
 		return pBase->deviceCap;
 	case EEP_OP_MODE:
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
index 909a224..3721770 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
@@ -220,7 +220,6 @@ enum eeprom_param {
 	EEP_MAC_MID,
 	EEP_MAC_LSW,
 	EEP_REG_0,
-	EEP_REG_1,
 	EEP_OP_CAP,
 	EEP_OP_MODE,
 	EEP_RF_SILENT,
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index ab6811d..9a7520f 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -322,8 +322,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah,
 		return get_unaligned_be16(pBase->macAddr + 4);
 	case EEP_REG_0:
 		return pBase->regDmn[0];
-	case EEP_REG_1:
-		return pBase->regDmn[1];
 	case EEP_OP_CAP:
 		return pBase->deviceCap;
 	case EEP_OP_MODE:
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 90d771f..4f5c50a 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -308,8 +308,6 @@ static u32 ath9k_hw_ar9287_get_eeprom(struct ath_hw *ah,
 		return get_unaligned_be16(pBase->macAddr + 4);
 	case EEP_REG_0:
 		return pBase->regDmn[0];
-	case EEP_REG_1:
-		return pBase->regDmn[1];
 	case EEP_OP_CAP:
 		return pBase->deviceCap;
 	case EEP_OP_MODE:
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index e175e20..81e6296 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -415,8 +415,6 @@ static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah,
 		return get_unaligned_be16(pBase->macAddr + 4);
 	case EEP_REG_0:
 		return pBase->regDmn[0];
-	case EEP_REG_1:
-		return pBase->regDmn[1];
 	case EEP_OP_CAP:
 		return pBase->deviceCap;
 	case EEP_OP_MODE:
-- 
1.7.3.2


^ permalink raw reply related

* [PATCH v3 1/4] ath9k_hw: make ath9k_hw_set_interrupts use ah->imask by default
From: Felix Fietkau @ 2011-10-08 18:06 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/beacon.c |   10 +++++-----
 drivers/net/wireless/ath/ath9k/gpio.c   |    4 ++--
 drivers/net/wireless/ath/ath9k/mac.c    |    6 +++---
 drivers/net/wireless/ath/ath9k/mac.h    |    2 +-
 drivers/net/wireless/ath/ath9k/main.c   |   10 +++++-----
 drivers/net/wireless/ath/ath9k/recv.c   |    2 +-
 6 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 9cdeaeb..a13cabb 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -515,7 +515,7 @@ static void ath_beacon_config_ap(struct ath_softc *sc,
 	sc->sc_flags |= SC_OP_TSF_RESET;
 	ath9k_beacon_init(sc, nexttbtt, intval);
 	sc->beacon.bmisscnt = 0;
-	ath9k_hw_set_interrupts(ah, ah->imask);
+	ath9k_hw_set_interrupts(ah);
 	ath9k_hw_enable_interrupts(ah);
 }
 
@@ -643,7 +643,7 @@ static void ath_beacon_config_sta(struct ath_softc *sc,
 	ath9k_hw_set_sta_beacon_timers(ah, &bs);
 	ah->imask |= ATH9K_INT_BMISS;
 
-	ath9k_hw_set_interrupts(ah, ah->imask);
+	ath9k_hw_set_interrupts(ah);
 	ath9k_hw_enable_interrupts(ah);
 }
 
@@ -679,7 +679,7 @@ static void ath_beacon_config_adhoc(struct ath_softc *sc,
 	ath9k_beacon_init(sc, nexttbtt, intval);
 	sc->beacon.bmisscnt = 0;
 
-	ath9k_hw_set_interrupts(ah, ah->imask);
+	ath9k_hw_set_interrupts(ah);
 	ath9k_hw_enable_interrupts(ah);
 }
 
@@ -821,11 +821,11 @@ void ath9k_set_beaconing_status(struct ath_softc *sc, bool status)
 	if (status) {
 		/* Re-enable beaconing */
 		ah->imask |= ATH9K_INT_SWBA;
-		ath9k_hw_set_interrupts(ah, ah->imask);
+		ath9k_hw_set_interrupts(ah);
 	} else {
 		/* Disable SWBA interrupt */
 		ah->imask &= ~ATH9K_INT_SWBA;
-		ath9k_hw_set_interrupts(ah, ah->imask);
+		ath9k_hw_set_interrupts(ah);
 		tasklet_kill(&sc->bcon_tasklet);
 		ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
 	}
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c
index fd0f84e..61eee8c 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -155,7 +155,7 @@ static void ath9k_gen_timer_start(struct ath_hw *ah,
 	if ((ah->imask & ATH9K_INT_GENTIMER) == 0) {
 		ath9k_hw_disable_interrupts(ah);
 		ah->imask |= ATH9K_INT_GENTIMER;
-		ath9k_hw_set_interrupts(ah, ah->imask);
+		ath9k_hw_set_interrupts(ah);
 		ath9k_hw_enable_interrupts(ah);
 	}
 }
@@ -170,7 +170,7 @@ static void ath9k_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer)
 	if (timer_table->timer_mask.val == 0) {
 		ath9k_hw_disable_interrupts(ah);
 		ah->imask &= ~ATH9K_INT_GENTIMER;
-		ath9k_hw_set_interrupts(ah, ah->imask);
+		ath9k_hw_set_interrupts(ah);
 		ath9k_hw_enable_interrupts(ah);
 	}
 }
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 22f23ea..835e81d 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -827,9 +827,9 @@ void ath9k_hw_enable_interrupts(struct ath_hw *ah)
 }
 EXPORT_SYMBOL(ath9k_hw_enable_interrupts);
 
-void ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
+void ath9k_hw_set_interrupts(struct ath_hw *ah)
 {
-	enum ath9k_int omask = ah->imask;
+	enum ath9k_int ints = ah->imask;
 	u32 mask, mask2;
 	struct ath9k_hw_capabilities *pCap = &ah->caps;
 	struct ath_common *common = ath9k_hw_common(ah);
@@ -837,7 +837,7 @@ void ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
 	if (!(ints & ATH9K_INT_GLOBAL))
 		ath9k_hw_disable_interrupts(ah);
 
-	ath_dbg(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints);
+	ath_dbg(common, ATH_DBG_INTERRUPT, "New interrupt mask 0x%x\n", ints);
 
 	mask = ints & ATH9K_INT_COMMON;
 	mask2 = 0;
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index 91c9654..c7cec9c 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -734,7 +734,7 @@ int ath9k_hw_beaconq_setup(struct ath_hw *ah);
 
 /* Interrupt Handling */
 bool ath9k_hw_intrpend(struct ath_hw *ah);
-void ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints);
+void ath9k_hw_set_interrupts(struct ath_hw *ah);
 void ath9k_hw_enable_interrupts(struct ath_hw *ah);
 void ath9k_hw_disable_interrupts(struct ath_hw *ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 9883186..4b2d304 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -273,7 +273,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 
 	ath9k_cmn_update_txpow(ah, sc->curtxpow,
 			       sc->config.txpowlimit, &sc->curtxpow);
-	ath9k_hw_set_interrupts(ah, ah->imask);
+	ath9k_hw_set_interrupts(ah);
 	ath9k_hw_enable_interrupts(ah);
 
 	if (!(sc->sc_flags & (SC_OP_OFFCHANNEL)) && start) {
@@ -823,7 +823,7 @@ irqreturn_t ath_isr(int irq, void *dev)
 
 	if (status & ATH9K_INT_RXEOL) {
 		ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
-		ath9k_hw_set_interrupts(ah, ah->imask);
+		ath9k_hw_set_interrupts(ah);
 	}
 
 	if (status & ATH9K_INT_MIB) {
@@ -1396,7 +1396,7 @@ static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
 		ah->imask &= ~ATH9K_INT_TSFOOR;
 	}
 
-	ath9k_hw_set_interrupts(ah, ah->imask);
+	ath9k_hw_set_interrupts(ah);
 
 	/* Set up ANI */
 	if (iter_data.naps > 0) {
@@ -1571,7 +1571,7 @@ static void ath9k_enable_ps(struct ath_softc *sc)
 	if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
 		if ((ah->imask & ATH9K_INT_TIM_TIMER) == 0) {
 			ah->imask |= ATH9K_INT_TIM_TIMER;
-			ath9k_hw_set_interrupts(ah, ah->imask);
+			ath9k_hw_set_interrupts(ah);
 		}
 		ath9k_hw_setrxabort(ah, 1);
 	}
@@ -1591,7 +1591,7 @@ static void ath9k_disable_ps(struct ath_softc *sc)
 				  PS_WAIT_FOR_TX_ACK);
 		if (ah->imask & ATH9K_INT_TIM_TIMER) {
 			ah->imask &= ~ATH9K_INT_TIM_TIMER;
-			ath9k_hw_set_interrupts(ah, ah->imask);
+			ath9k_hw_set_interrupts(ah);
 		}
 	}
 
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index f658ec6..6449b6f 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1973,7 +1973,7 @@ requeue:
 
 	if (!(ah->imask & ATH9K_INT_RXEOL)) {
 		ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
-		ath9k_hw_set_interrupts(ah, ah->imask);
+		ath9k_hw_set_interrupts(ah);
 	}
 
 	return 0;
-- 
1.7.3.2


^ permalink raw reply related

* Re: [PATCH 0/8] wireless: add DFS master support
From: Zefir Kurtisi @ 2011-10-08 17:46 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: linux-wireless, linville, Johannes Berg
In-Reply-To: <CAB=NE6Xz26oOudnyw17_1ijqe+L8qwQAGH8qjZEocgHQOY54eg@mail.gmail.com>

On 08.10.2011 00:32, Luis R. Rodriguez wrote:
> On Fri, Oct 7, 2011 at 3:29 PM, Luis R. Rodriguez
> <mcgrof@qca.qualcomm.com>  wrote:
>> On Fri, Oct 7, 2011 at 2:11 PM, Luis R. Rodriguez
>> <mcgrof@qca.qualcomm.com>  wrote:
>>> On Tue, Oct 4, 2011 at 5:14 PM, Luis R. Rodriguez
>>> <mcgrof@qca.qualcomm.com>  wrote:
>>>> On Tue, Oct 4, 2011 at 4:47 PM, Luis R. Rodriguez
>>>> <mcgrof@qca.qualcomm.com>  wrote:
>>>>> This set of 8 patches adds DFS master support to the Linux wireless subsystem.
>>>>> I've reviewed future possible changes to DFS master regions and it seems that
>>>>> we are not going to be having multiple DFS regions for one country, instead
>>>>> we'll always have one DFS region for one country.
>>>>>
>>>>> The changes here are spread out throughout wireless-regdb, crda the kernel and
>>>>> lastly iw. The changes made allow for older verions of CRDA to work with new
>>>>> wireless-regdb files with DFS region support. If you want DFS master region
>>>>> support you'll need to upgrade your CRDA, your kernel and then hope someone
>>>>> implements DFS master support for your respective driver.
>>>>>
>>>>> This patch series does not have specific driver changes, although some seem to
>>>>> be backing in the oven right now.
>>>>
>>>> Here's a puzzle though... If we change this series to use the other
>>>> pad byte that was available, the first pad byte, instead of the last
>>>> one, we loose backward compatibility support and I cannot figure out
>>>> why. What I ended up seeing was that crda sends the message, and for
>>>> some reason (return code is 222 from nl_wait_for_ack(), whatever that
>>>> is) the kernel rejects it. I suspect it may have to do with some sort
>>>> of offset to the *other* data that makes some of the rules output
>>>> invalid data for the attribute policy, but at least when I hexdump the
>>>> wireless-regdb the only changes I see are in the signature and the pad
>>>> shift.
>>>>
>>>> I got tired of trying though and after seeing flipping the pad bytes
>>>> things worked decided to stay with it. In my original RFC in December
>>>> I had used u16 instead, but since the data was in the last pad byte
>>>> things still worked. So something is fishy about only using the first
>>>> pad byte. The change below, as far as I can tell, should not have any
>>>> issues but it does with the older version of CRDA and even a new one.
>>>
>>> Johannes spotted the issue, I'll send the fix, thanks to Johannes.
>>> John, Johannes the patches still apply my fix goes on top of these
>>> changes, the fix is not addressing a regression introduced by this
>>> patchset, instead it fixes a long standing issue which would prevent
>>> us from using the next available pad byte.
>>
>> I'm going to respin this to make use of 2 bits:
>>
>> 00 unset
>> 01 FCC
>> 10 ETSI
>> 11 JP
>>
>> We may need some more DFS values later but
>
> Sorry I did not finish this e-mail I meant that we may later have a
> requirement for more DFS values but at this time we don't, we should
> consider whether or not we will want to leave more bits for usage of
> more DFS values and if so how many? Using two bits will give us
> support for what we know today but nothing for the future.
>
For the future things we do not know of today we should add another bit 
and define

111 unknown / other

to be able to mark special countrycodes that do not fully belong to the 
three known domains. We could use some invalid coding for those CCs 
(like no DFS domain set in CC but flag set for frequency band) to 
identify those special domains, but using an additional bit would make 
things easier to handle.

> If I use two bits I just don't want complains later if we have DFS
> regions split in the db spec for future changes.
>
>    Luis

Zefir

^ permalink raw reply

* Re: Alfa AWUS036NHR with RTL8188RU chipset
From: Larry Finger @ 2011-10-08 16:52 UTC (permalink / raw)
  To: Toddy; +Cc: linux-wireless
In-Reply-To: <loom.20111008T181929-517@post.gmane.org>

On 10/08/2011 11:24 AM, Toddy wrote:
> Hello Larry,
>
> thanks for the quick reply! Yes I know this version is a bit older, but when I
> use the newest compat-wireless (eg.
> http://www.orbit-lab.org/kernel/compat-wireless-2.6/compat-wireless-2011-10-07.tar.bz2)
> the driver loads but some features like monitor-mode and packet injection
> doesn't work. The listing of available networks (with airodump) doesn't work
> too. Usually I have 13 channels because I live in Germany but if I use the
> newest driver I have only 11 channels. But if I use the older compat-wireless
> package all works fine.

The difference between 11 and 13 channels depends on your CRDA settings. Do you 
have that package installed? Check the output of dmesg to see what domain is 
being set. If you have CRDA installed, then you can force the use of Germany in 
the domain by creating a file named /etc/modprobe.d/50-cfg80211.conf containing 
a single line with "options cfg80211 ieee80211_regdom=DE" (without the quote marks).

You can get a list of available networks using iwconfig or iw. I know those work.

As I do not test, support, nor condone packet injection, I cannot speak to it 
working on any driver.

Larry

^ permalink raw reply

* Re: Alfa AWUS036NHR with RTL8188RU chipset
From: Toddy @ 2011-10-08 16:24 UTC (permalink / raw)
  To: linux-wireless
In-Reply-To: <4E8E2659.3060808@lwfinger.net>

Hello Larry,

thanks for the quick reply! Yes I know this version is a bit older, but when I
use the newest compat-wireless (eg.
http://www.orbit-lab.org/kernel/compat-wireless-2.6/compat-wireless-2011-10-07.tar.bz2)
the driver loads but some features like monitor-mode and packet injection
doesn't work. The listing of available networks (with airodump) doesn't work
too. Usually I have 13 channels because I live in Germany but if I use the
newest driver I have only 11 channels. But if I use the older compat-wireless
package all works fine.

Toddy


^ permalink raw reply

* Re: [PATCH] wl12xx: move debugging definitions to a separate file
From: Luciano Coelho @ 2011-10-08 14:44 UTC (permalink / raw)
  To: linux-wireless
In-Reply-To: <1317975194-18306-1-git-send-email-coelho@ti.com>

On Fri, 2011-10-07 at 11:13 +0300, Luciano Coelho wrote: 
> Separate the debugging macros and other definitions to a new debug.h
> file.  This is be needed because the sdio and spi modules don't need
> to depend on the wl12xx module anymore, but still need to include
> wl12xx.h.  Currently they do depend on it, because of the debugging
> global that wl12xx exports.  A future patch will remove this
> dependency.
> 
> Signed-off-by: Luciano Coelho <coelho@ti.com>
> ---

These defines should be in debug.h as well:

#define DRIVER_NAME "wl1271"
#define DRIVER_PREFIX DRIVER_NAME ": "

I'll move them too and rename wl1271 to wl12xx when I apply.

-- 
Cheers,
Luca.


^ permalink raw reply

* [PATCH] ath9k: disable unnecessary PHY error reporting
From: Felix Fietkau @ 2011-10-08 13:49 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof

PHY errors relevant for ANI are always tracked by hardware counters, the
bits that allow them to pass through the rx filter are independent of that.
Enabling PHY errors in the rx filter often creates lots of useless DMA traffic
and might be responsible for some of the rx dma stop failure warnings.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
---
 drivers/net/wireless/ath/ath9k/ani.c  |    5 -----
 drivers/net/wireless/ath/ath9k/recv.c |    5 +----
 2 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index 01240d6..2776c3c 100644
--- a/drivers/net/wireless/ath/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -504,9 +504,6 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
 		ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
 				     ATH9K_ANI_CCK_WEAK_SIG_THR);
 
-		ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) |
-				     ATH9K_RX_FILTER_PHYERR);
-
 		ath9k_ani_restart(ah);
 		return;
 	}
@@ -527,8 +524,6 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
 		ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
 				     aniState->firstepLevel);
 
-	ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) &
-			     ~ATH9K_RX_FILTER_PHYERR);
 	ath9k_ani_restart(ah);
 
 	ENABLE_REGWRITE_BUFFER(ah);
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index f658ec6..d28a5dd 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -433,12 +433,9 @@ void ath_rx_cleanup(struct ath_softc *sc)
 
 u32 ath_calcrxfilter(struct ath_softc *sc)
 {
-#define	RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
-
 	u32 rfilt;
 
-	rfilt = (ath9k_hw_getrxfilter(sc->sc_ah) & RX_FILTER_PRESERVE)
-		| ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
+	rfilt = ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
 		| ATH9K_RX_FILTER_MCAST;
 
 	if (sc->rx.rxfilter & FIF_PROBE_REQ)
-- 
1.7.3.2


^ permalink raw reply related

* can't make compat-wireless-3.1-rc8-1
From: matteo filippetto @ 2011-10-08  8:19 UTC (permalink / raw)
  To: stable; +Cc: linux-wireless

Hi

I try to make compat-wireless-3.1-rc8-1 but I get error on net/wireless/util.c

/home/matteo/Downloads/compat-wireless-3.1-rc8-1-org/net/wireless/util.c:
In function ‘cfg80211_change_iface’:
/home/matteo/Downloads/compat-wireless-3.1-rc8-1-org/net/wireless/util.c:804:2:
error: implicit declaration of function ‘br_port_exists’
make[3]: *** [/home/matteo/Downloads/compat-wireless-3.1-rc8-1-org/net/wireless/util.o]
Error 1
make[2]: *** [/home/matteo/Downloads/compat-wireless-3.1-rc8-1-org/net/wireless]
Error 2
make[1]: *** [_module_/home/matteo/Downloads/compat-wireless-3.1-rc8-1-org]
Error 2
make[1]: Leaving directory `/usr/src/torvalds-linux-a8062e4'
make: *** [modules] Error 2

It' s a problem with the definition of br_port_exists. I solved inserting

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
#define br_port_exists(dev)	(dev->priv_flags & IFF_BRIDGE_PORT)
#else
#define br_port_exists(dev)	(dev->br_port)
#endif

in net/wireless/core.h but I don't think it's the right way to solve this issue.

I try to include "include/linux/compat-3.1.h" in util.c but without success.

Regards
-- 
Matteo Filippetto
http://www.op83.eu

^ permalink raw reply

* Re: moving GIT back to kernel.org...
From: Yinglin Sun @ 2011-10-08  7:09 UTC (permalink / raw)
  To: jeffrey.t.kirsher
  Cc: David Miller, netdev, sfr, linux-wireless, netfilter-devel,
	sparclinux, linux-ide
In-Reply-To: <4E8FF54F.1080306@gmail.com>

On Sat, Oct 8, 2011 at 12:01 AM, Jeff Kirsher <tarbal@gmail.com> wrote:
> On 10/07/2011 11:55 PM, Yinglin Sun wrote:
>> On Fri, Oct 7, 2011 at 12:59 PM, David Miller <davem@davemloft.net> wrote:
>>> From: David Miller <davem@davemloft.net>
>>> Date: Fri, 07 Oct 2011 14:57:03 -0400 (EDT)
>>>
>>>> I'm about to setup my GIT trees on kernel.org, once that is complete
>>>> I will be solely updating those trees again.
>>>>
>>>> I will notify everyone when this is ready to go.
>>>>
>>>> Just a heads up for everyone...
>>> Ok, they are now online, please update your URLs.
>>>
>>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
>>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
>>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git
>>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git
>>>
>> I'm still new to net kernel development, so a little confused about these trees.
>> So we should submit patches based on these trees, instead of Linus'?
>> About net and net-next, How to decide which one to use?
>>
>> Thanks!
>>
>> Yinglin
>>
>
> *If* you have change against the network core/drivers then, you would
> want to use David Miller's net or net-next trees.
>
> As a general rule:
>  - net tree is only for fixes/critical fixes
>  - net-next tree is for everything else
>
> There are always exceptions, but if you stick to the above general rule,
> you will be fine.
>
>

Got it. Thanks Jeff!

Yinglin

^ permalink raw reply

* Re: moving GIT back to kernel.org...
From: Jeff Kirsher @ 2011-10-08  7:01 UTC (permalink / raw)
  To: Yinglin Sun
  Cc: David Miller, netdev, sfr, linux-wireless, netfilter-devel,
	sparclinux, linux-ide
In-Reply-To: <CAN17JHUGnAbHJmwybjJVdxq4JOgHfDxChw1P7q1yrkqH6Ci05w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]

On 10/07/2011 11:55 PM, Yinglin Sun wrote:
> On Fri, Oct 7, 2011 at 12:59 PM, David Miller <davem@davemloft.net> wrote:
>> From: David Miller <davem@davemloft.net>
>> Date: Fri, 07 Oct 2011 14:57:03 -0400 (EDT)
>>
>>> I'm about to setup my GIT trees on kernel.org, once that is complete
>>> I will be solely updating those trees again.
>>>
>>> I will notify everyone when this is ready to go.
>>>
>>> Just a heads up for everyone...
>> Ok, they are now online, please update your URLs.
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git
>>
> I'm still new to net kernel development, so a little confused about these trees.
> So we should submit patches based on these trees, instead of Linus'?
> About net and net-next, How to decide which one to use?
>
> Thanks!
>
> Yinglin
>

*If* you have change against the network core/drivers then, you would
want to use David Miller's net or net-next trees.

As a general rule:
 - net tree is only for fixes/critical fixes
 - net-next tree is for everything else

There are always exceptions, but if you stick to the above general rule,
you will be fine.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 900 bytes --]

^ permalink raw reply

* Re: moving GIT back to kernel.org...
From: Yinglin Sun @ 2011-10-08  6:55 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, sfr, linux-wireless, netfilter-devel, sparclinux,
	linux-ide
In-Reply-To: <20111007.155902.916470368193047875.davem@davemloft.net>

On Fri, Oct 7, 2011 at 12:59 PM, David Miller <davem@davemloft.net> wrote:
> From: David Miller <davem@davemloft.net>
> Date: Fri, 07 Oct 2011 14:57:03 -0400 (EDT)
>
>>
>> I'm about to setup my GIT trees on kernel.org, once that is complete
>> I will be solely updating those trees again.
>>
>> I will notify everyone when this is ready to go.
>>
>> Just a heads up for everyone...
>
> Ok, they are now online, please update your URLs.
>
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git
>

I'm still new to net kernel development, so a little confused about these trees.
So we should submit patches based on these trees, instead of Linus'?
About net and net-next, How to decide which one to use?

Thanks!

Yinglin

^ permalink raw reply

* Re: moving GIT back to kernel.org...
From: Stephen Rothwell @ 2011-10-07 23:10 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, linux-wireless, netfilter-devel, sparclinux, linux-ide
In-Reply-To: <20111007.184657.1471438956485710175.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 1207 bytes --]

Hi Dave,

On Fri, 07 Oct 2011 18:46:57 -0400 (EDT) David Miller <davem@davemloft.net> wrote:
>
> From: Stephen Rothwell <sfr@canb.auug.org.au>
> Date: Sat, 8 Oct 2011 09:42:12 +1100
> 
> > On Fri, 07 Oct 2011 15:59:02 -0400 (EDT) David Miller <davem@davemloft.net> wrote:
> >> git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git
> >> git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git
> > 
> > You used to have sparc-next and ide-next (and the above used to be your
> > "current release fixes" trees) ...
> 
> I've made a dummy sparc-next tree for you to pull from, thanks:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next.git
> 
> As for ide, I only plan to accept real bug fixes for that subsystem
> so I'll avoid creating an ide-next tree for now.

OK, I will use those trees from now on.

Also, I have decided to rename them in linux-next to match your names, so:

Was		Now
---		---
net-current	net
net		net-next
sparc-current	sparc
sparc		sparc-next
ide-curent	ide

and I have dropped the old ide (would be ide-next) tree.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: moving GIT back to kernel.org...
From: David Miller @ 2011-10-07 22:46 UTC (permalink / raw)
  To: sfr; +Cc: netdev, linux-wireless, netfilter-devel, sparclinux, linux-ide
In-Reply-To: <20111008094212.e3342930c1833f73ef602a3e@canb.auug.org.au>

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Sat, 8 Oct 2011 09:42:12 +1100

> On Fri, 07 Oct 2011 15:59:02 -0400 (EDT) David Miller <davem@davemloft.net> wrote:
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git
> 
> You used to have sparc-next and ide-next (and the above used to be your
> "current release fixes" trees) ...

I've made a dummy sparc-next tree for you to pull from, thanks:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next.git

As for ide, I only plan to accept real bug fixes for that subsystem
so I'll avoid creating an ide-next tree for now.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox