linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/2] mac80211: add offload channel switch support
From: Luis R. Rodriguez @ 2010-05-11 20:55 UTC (permalink / raw)
  To: Johannes Berg, David Quan, Michael Green, Stephen Chen, Dan Tian,
	Kevin Hayes, Cliff Holden
  Cc: wey-yi.w.guy, linux-wireless
In-Reply-To: <1273586443.20312.14.camel@jlt3.sipsolutions.net>

On Tue, May 11, 2010 at 7:00 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Thu, 2010-05-06 at 14:58 -0700, Luis R. Rodriguez wrote:
>> On Thu, May 6, 2010 at 8:25 AM,  <wey-yi.w.guy@intel.com> wrote:
>> > From: Wey-Yi Guy <wey-yi.w.guy@intel.com>

>> > with this offload approach, driver has more control on how to handle the
>> > channel switch request from AP, also can provide more accurate timing
>> > calculation
>>
>> Is the current timing insufficient, and if so can you provide more
>> details. If the real reason for this callback is not timing
>> considerations is the real reason a firmware API thing? If so it
>> doesn't hurt to just say that to avoid confusing developer in deciding
>> which approach to take.
>
> The current mac80211 approach is flawed, for various reasons which I
> won't get into here, most of which we can fix. However, due to
> regulatory concerns our firmware also wants to have more control, like
> checking that the AP is beaconing again after a channel switch before
> letting us transmit frames.

OK this makes perfect sense if the channel you are switching to is
also a DFS channel, but it sounds like something we can also implement
on mac80211, unless of course firmware can make that guarantee for us
quicker. This is the sort of explanation that I think might be very
useful to the driver developer when choosing which mac80211 CSA
operation to implement -- either the standard mac80211 implementation
or a driver specific one.

I take it this tries to resolve some sort of race condition where the
AP decided to switch to another DFS channel, told the STAs, went to
the other channel, and as it does the swtich gets radar signals and
needs to quite down.

> Timing is obviously also a consideration,
> since the firmware can re-enable transmission quickly after the channel
> switch, regardless of the delay in processing the frame or the timer on
> the host.

Reason for me asking for details about this was because I was
wondering whether the reasons for you guys implementing a separate CSA
callback could be addressed by adjusting the internal existing
mac80211 CSA implementation further. Timing constraints to re-enable
TX seem to be the biggest concern here since checking whether or not
the AP is beaconing *can* certainly be done on mac80211. Is there a
measurable TX drop due to the extra latency introduced by using a host
based implementation?

If a driver developer reads the documentation it would be nice for
them to easily get enough information to decide which approach to take
and to do that the more details we can provide the better. If we
haven't tested a mac80211 enhanced approach why not try that first?

>> > The drivers like to support the channel switch offloading function
>>
>> Maybe: "The drivers that require a dedicated channel switch callback"...
>>
>> > will have
>> > to provide the mactime information (at least for mgmt and action frames)
>>
>> Might be good to specify why, or at least in the documentation code below.
>
> Actually, it's up to them. But if you implement the callback, you'll
> want to know precisely when to expect the channel switch

Right, that was my point, it was not clear that this was the reason
for having it so it might help the developer if the documentation
stated that.

> so you'll want
> to know when the frame that contained the CSA was received, which you
> have to provide to mac80211 in the "mactime" rx status field.

Right, thanks for the details, I was just hoping we could clarify that
to the driver developers a little more on the patch.

>> > +/**
>> > + * ieee80211_chswitch_done - Complete channel switch process
>> > + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
>> > + * @is_seccess: make the channel switch successful or not
>>
>> Typo, is_seccess, not success. Also, I don't get what this is for, can
>> you elaborate?
>
> Channel switching could fail, for instance if the AP doesn't show up on
> the new channel. We don't have a way to handle that yet in mac80211, but
> why not let it know.

Oh definitely I agree, I was just hoping this can be explained ont he
kdoc above, it was not clear from reading the code.

>> I'd appreciate more feedback on the why this is being done. Its not
>> clear to me how we are limited by the current implementation.
>
> Ok like I said -- timing is a big thing. Regulatory enforcement in our
> firmware is another.

Regulatory enforcement is already handled by the mac80211 CSA, the
check for beaconing on the channel we move to *can* be done by
mac80211 as well, so that would only leave timing constraints.

  Luis

^ permalink raw reply

* Re: pull request: wireless-next-2.6 2010-05-11
From: David Miller @ 2010-05-11 20:32 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, netdev
In-Reply-To: <20100511190510.GD2400@tuxdriver.com>

From: "John W. Linville" <linville@tuxdriver.com>
Date: Tue, 11 May 2010 15:05:10 -0400

> Another round of bits intended for 2.6.35...mostly driver updates this
> time.  The biggest item of note is some continued attention for rt2800
> from the rt2x00 team.

Pulled, thanks John.

^ permalink raw reply

* Re: [PATCH 2/4] ath9k: add debugfs files for reading/writing the rx and tx chainmask
From: Luis R. Rodriguez @ 2010-05-11 20:14 UTC (permalink / raw)
  To: Felix Fietkau
  Cc: Luis Rodriguez, linux-wireless@vger.kernel.org,
	linville@tuxdriver.com
In-Reply-To: <4BE9B61A.2090708@openwrt.org>

On Tue, May 11, 2010 at 12:55:06PM -0700, Felix Fietkau wrote:
> On 2010-05-11 8:15 PM, Luis R. Rodriguez wrote:
> > On Tue, May 11, 2010 at 8:23 AM, Felix Fietkau <nbd@openwrt.org> wrote:
> >> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> > 
> > How about we use bruno's patch instead and we help review it for
> > 802.11n? Then this would not be needed?
> I'd like to keep those separate. I've seen cards where the wrong
> chainmask was programmed into the eeprom, this debugfs file is for
> detecting that and trying other settings.
> When Bruno's patch gets implemented for ath9k, the values that it can
> set should be masked by the internal value, while the debugfs file can
> override the internal value.

Fair enough, thanks.

  Luis

^ permalink raw reply

* Re: [PATCH 2/4] ath9k: add debugfs files for reading/writing the rx and tx chainmask
From: Felix Fietkau @ 2010-05-11 19:55 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: linux-wireless, linville
In-Reply-To: <AANLkTilDwhBErduNt_vZLSsEVVkC1SDMwUPkoumym1o3@mail.gmail.com>

On 2010-05-11 8:15 PM, Luis R. Rodriguez wrote:
> On Tue, May 11, 2010 at 8:23 AM, Felix Fietkau <nbd@openwrt.org> wrote:
>> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> 
> How about we use bruno's patch instead and we help review it for
> 802.11n? Then this would not be needed?
I'd like to keep those separate. I've seen cards where the wrong
chainmask was programmed into the eeprom, this debugfs file is for
detecting that and trying other settings.
When Bruno's patch gets implemented for ath9k, the values that it can
set should be masked by the internal value, while the debugfs file can
override the internal value.

- Felix

^ permalink raw reply

* Re: [PATCH V3] mac80211: fix paged defragmentation
From: John W. Linville @ 2010-05-11 19:43 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Abhijeet Kolekar, linux-wireless@vger.kernel.org, Zhu, Yi
In-Reply-To: <1273604696.20312.29.camel@jlt3.sipsolutions.net>

On Tue, May 11, 2010 at 09:04:56PM +0200, Johannes Berg wrote:
> On Tue, 2010-05-11 at 11:52 -0700, Abhijeet Kolekar wrote:
> > Hello John,
> > On Tue, 2010-05-11 at 11:24 -0700, John W. Linville wrote:
> > > On Tue, May 11, 2010 at 11:16:50AM -0700, Abhijeet Kolekar wrote:
> > > > Hello John,
> > > > On Tue, 2010-05-11 at 11:14 -0700, John W. Linville wrote:
> > > > > On Tue, May 11, 2010 at 11:22:11AM -0700, Abhijeet Kolekar wrote:
> > > > > > Paged RX skb patch broke the defragmentation. We need to read hdr again
> > > > > > after linearization.
> > > > > > 
> > > > > > It fixes following bug
> > > > > > http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194
> > > > > > 
> > > > > > Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
> > > > > > Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
> > > > > > ---
> > > > > > v2: Changed hdr reading.
> > > > > > v3: Added more comments.
> > > > > >  net/mac80211/rx.c |    6 ++++++
> > > > > >  1 files changed, 6 insertions(+), 0 deletions(-)
> > > > > > 
> > > > > > diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> > > > > > index 9a08f2c..6e2a7bc 100644
> > > > > > --- a/net/mac80211/rx.c
> > > > > > +++ b/net/mac80211/rx.c
> > > > > > @@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
> > > > > >  	if (skb_linearize(rx->skb))
> > > > > >  		return RX_DROP_UNUSABLE;
> > > > > >  
> > > > > > +	/*
> > > > > > +	 *  skb_linearize() might change the skb->data and
> > > > > > +	 *  previously cached variables (in this case, hdr) need to
> > > > > > +	 *  be refreshed with the new data.
> > > > > > +	 */
> > > > > > +	hdr = (struct ieee80211_hdr *)rx->skb->data;
> > > > > >  	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
> > > > > >  
> > > > > >  	if (frag == 0) {
> > > > > 
> > > > > And what about making sure the compiler doesn't optimize this away?
> > > > > 
> > > >  To avoid the double assignment, there is one more approach is to
> > > > directly read fc and seq_ctrl  using skb_data. I will send that in the
> > > > next version.
> > > 
> > > I don't think the double assignment is so bad, I just think that a
> > > compiler might decide to ignore the second assignment.  Am I wrong?
> > > 
> > I don't understand why compiler will ignore the second assignment other
> > than the above reason. What will be the solution in this case?
> 
> ACCESS_ONCE()? I have no idea why/if the compiler would actually do this
> though.

I don't know about "if", but "why" might be that as far as the compiler
can see you have two identical assignments without an obvious change to
the data source in between.  But maybe passing rx->skb to skb_linearize
is enough information to make the compiler aware that rx->skb->data
might have changed?  Any better language lawyers than me around?

I think ACCESS_ONCE would be enough, but maybe it isn't necessary...?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [PATCH] ar9170usb:add vendor and device ID for Qwest/Actiontec 802AIN Wireless N USB Network Adapter
From: John W. Linville @ 2010-05-11 19:16 UTC (permalink / raw)
  To: Steve Tanner; +Cc: linux-wireless, Christian Lamparter
In-Reply-To: <AANLkTilNQBE7zwSaNjcaHG4YPD_zfK63aepIzccWIdSj@mail.gmail.com>

On Tue, May 11, 2010 at 02:19:35AM -0700, Steve Tanner wrote:
> * add support for the Qwest/Actiontec 802AIN Wireless N USB Network Adapter.
> 
> lsusb identifies the device as: "ID 1668:1200 Actiontec Electronics, Inc. [hex]"
> 
> usb_modeswitch package and appropriate rules are required to switch
> the device from "ID 0ace:20ff ZyDas"
> 
> Changes-licensed-under: GPL

Need a "Signed-off-by", please!

http://linux.yyz.us/patch-format.html

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* pull request: wireless-next-2.6 2010-05-11
From: John W. Linville @ 2010-05-11 19:05 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev

Dave,

Another round of bits intended for 2.6.35...mostly driver updates this
time.  The biggest item of note is some continued attention for rt2800
from the rt2x00 team.

Please let me know if there are problems!

John

---

The following changes since commit d250fe91ae129bff0968e685cc9c466d3a5e3482:
  David S. Miller (1):
        Merge branch 'master' of git://git.kernel.org/.../kaber/nf-next-2.6

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6.git for-davem

Christian Lamparter (1):
      ar9170usb: remove deprecated aggregation code

Dan Carpenter (4):
      iwlwifi: remove stray mutex_unlock()
      ath9k/htc_drv_main: null dereference typo
      ath9k/htc_drv_main: off by one error
      ath5k: several off by one range checks

David Kilroy (1):
      orinoco: refactor xmit path

Felix Fietkau (1):
      ath9k: fix another source of corrupt frames

Gertjan van Wingerde (9):
      rt2x00: Fix setting of txdesc->length field.
      rt2x00: Clean up rt2800usb.h.
      rt2x00: Don't check whether hardware crypto is enabled when reading RXD.
      rt2x00: Factor out TXWI writing to common rt2800 code.
      rt2x00: Factor out RXWI processing to common rt2800 code.
      rt2x00: Clean up all driver's kick_tx_queue callback functions.
      rt2x00: provide beacon's txdesc to write_beacon callback function.
      rt2x00: Fix beaconing on rt2800.
      rt2x00: Clean up generic procedures on descriptor writing.

Helmut Schaa (3):
      rt2x00: rt2800: update initial SIFS values
      rt2x00: rt2800: don't overwrite SIFS values on erp changes
      rt2x00: rt2800: use correct txop value in tx descriptor

Ivo van Doorn (1):
      rt2x00: Fix RF3052 channel initialization

Johannes Berg (3):
      mac80211: fix BSS info reconfiguration
      cfg80211/mac80211: better channel handling
      mac80211: improve HT channel handling

John W. Linville (5):
      mac80211: set IEEE80211_TX_CTL_FIRST_FRAGMENT for beacons
      rtl8180: assign sequence numbers in the driver
      rtl8180: add software-based support for IBSS mode
      rtl8180: change PCI DMA mask to DMA_BIT_MASK(32)
      Merge branch 'master' of git://git.kernel.org/.../linville/wireless-next-2.6 into for-davem

Juuso Oikarinen (4):
      wl1271: Add sysfs file to retrieve HW PG-version and ROM-version
      wl1271: Fix 32 bit register read related endiannes bug
      wl1271: Fix to join and channel number handling
      wl1271: Reduce PSM entry hang over period from 128 => 1 ms

Luis R. Rodriguez (4):
      ath9k_common: move the rate status setting into ath9k_process_rate()
      ath9k_common: drop incomming frames with an invalid hardware rate
      ath9k_hw: Update initvals for AR9003 for xb113
      ath9k_hw: enable PCIe low power mode for AR9003

Randy Dunlap (1):
      wireless: depends on NET

Stephen Rothwell (1):
      ar9170: fix for driver-core ABI change

Sujith (2):
      ath9k_htc: Fix beaconing in IBSS mode
      ath9k_htc: Handle IDLE LED properly

Teemu Paasikivi (1):
      wl1271: Increase timeout for command event waiting

Xose Vazquez Perez (1):
      wireless: rt2x00: rt2800usb: replace X by x

 drivers/net/wireless/Kconfig                     |    1 +
 drivers/net/wireless/ath/ar9170/ar9170.h         |   52 +--
 drivers/net/wireless/ath/ar9170/main.c           |  558 +---------------------
 drivers/net/wireless/ath/ar9170/usb.c            |    5 +-
 drivers/net/wireless/ath/ath5k/ani.c             |    6 +-
 drivers/net/wireless/ath/ath9k/ar9003_initvals.h |  204 ++++----
 drivers/net/wireless/ath/ath9k/common.c          |   49 ++-
 drivers/net/wireless/ath/ath9k/htc.h             |    5 +-
 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c  |   39 +--
 drivers/net/wireless/ath/ath9k/htc_drv_init.c    |    2 +-
 drivers/net/wireless/ath/ath9k/htc_drv_main.c    |   42 +-
 drivers/net/wireless/ath/ath9k/hw.c              |   20 +
 drivers/net/wireless/iwlwifi/iwl-3945.c          |    1 -
 drivers/net/wireless/libertas/cfg.c              |    1 +
 drivers/net/wireless/mac80211_hwsim.c            |   19 +-
 drivers/net/wireless/orinoco/cfg.c               |    1 +
 drivers/net/wireless/orinoco/main.c              |  169 ++++---
 drivers/net/wireless/orinoco/orinoco.h           |    6 +
 drivers/net/wireless/orinoco/orinoco_usb.c       |   91 ++--
 drivers/net/wireless/rndis_wlan.c                |    4 +-
 drivers/net/wireless/rt2x00/rt2400pci.c          |   22 +-
 drivers/net/wireless/rt2x00/rt2500pci.c          |   22 +-
 drivers/net/wireless/rt2x00/rt2500usb.c          |   66 +--
 drivers/net/wireless/rt2x00/rt2800lib.c          |  178 +++++++-
 drivers/net/wireless/rt2x00/rt2800lib.h          |    3 +
 drivers/net/wireless/rt2x00/rt2800pci.c          |  166 ++-----
 drivers/net/wireless/rt2x00/rt2800usb.c          |  182 ++------
 drivers/net/wireless/rt2x00/rt2800usb.h          |   40 --
 drivers/net/wireless/rt2x00/rt2x00.h             |    3 +-
 drivers/net/wireless/rt2x00/rt2x00crypto.c       |    1 +
 drivers/net/wireless/rt2x00/rt2x00ht.c           |   17 +
 drivers/net/wireless/rt2x00/rt2x00queue.c        |   23 +-
 drivers/net/wireless/rt2x00/rt2x00queue.h        |    2 +
 drivers/net/wireless/rt2x00/rt2x00reg.h          |   10 +
 drivers/net/wireless/rt2x00/rt61pci.c            |   41 +-
 drivers/net/wireless/rt2x00/rt73usb.c            |   51 +--
 drivers/net/wireless/rtl818x/rtl8180.h           |   11 +
 drivers/net/wireless/rtl818x/rtl8180_dev.c       |   96 ++++-
 drivers/net/wireless/wl12xx/wl1271.h             |    4 +-
 drivers/net/wireless/wl12xx/wl1271_boot.c        |   12 +
 drivers/net/wireless/wl12xx/wl1271_boot.h        |    3 +
 drivers/net/wireless/wl12xx/wl1271_cmd.c         |    2 +-
 drivers/net/wireless/wl12xx/wl1271_cmd.h         |    2 +-
 drivers/net/wireless/wl12xx/wl1271_io.h          |    4 +-
 drivers/net/wireless/wl12xx/wl1271_main.c        |   63 +++-
 include/linux/nl80211.h                          |   13 +
 include/net/cfg80211.h                           |   11 +-
 include/net/mac80211.h                           |    6 +
 net/mac80211/Makefile                            |    3 +-
 net/mac80211/cfg.c                               |   58 +++-
 net/mac80211/chan.c                              |  127 +++++
 net/mac80211/ibss.c                              |    5 +-
 net/mac80211/ieee80211_i.h                       |   16 +-
 net/mac80211/main.c                              |    2 +-
 net/mac80211/mlme.c                              |   44 +-
 net/mac80211/tx.c                                |    5 +-
 net/mac80211/util.c                              |   25 +-
 net/wireless/chan.c                              |   56 +--
 net/wireless/core.h                              |   12 +-
 net/wireless/ibss.c                              |    5 -
 net/wireless/nl80211.c                           |  171 +++++--
 net/wireless/sme.c                               |    5 -
 net/wireless/wext-compat.c                       |   15 +-
 net/wireless/wext-sme.c                          |    2 +-
 64 files changed, 1369 insertions(+), 1511 deletions(-)
 create mode 100644 net/mac80211/chan.c

Omnibus patch available here:

	http://www.kernel.org/pub/linux/kernel/people/linville/wireless-next-2.6-2010-05-11.patch.bz2
 
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [PATCH V3] mac80211: fix paged defragmentation
From: Johannes Berg @ 2010-05-11 19:04 UTC (permalink / raw)
  To: Abhijeet Kolekar
  Cc: John W. Linville, linux-wireless@vger.kernel.org, Zhu, Yi
In-Reply-To: <1273603952.5955.45.camel@abhi-desktop>

On Tue, 2010-05-11 at 11:52 -0700, Abhijeet Kolekar wrote:
> Hello John,
> On Tue, 2010-05-11 at 11:24 -0700, John W. Linville wrote:
> > On Tue, May 11, 2010 at 11:16:50AM -0700, Abhijeet Kolekar wrote:
> > > Hello John,
> > > On Tue, 2010-05-11 at 11:14 -0700, John W. Linville wrote:
> > > > On Tue, May 11, 2010 at 11:22:11AM -0700, Abhijeet Kolekar wrote:
> > > > > Paged RX skb patch broke the defragmentation. We need to read hdr again
> > > > > after linearization.
> > > > > 
> > > > > It fixes following bug
> > > > > http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194
> > > > > 
> > > > > Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
> > > > > Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
> > > > > ---
> > > > > v2: Changed hdr reading.
> > > > > v3: Added more comments.
> > > > >  net/mac80211/rx.c |    6 ++++++
> > > > >  1 files changed, 6 insertions(+), 0 deletions(-)
> > > > > 
> > > > > diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> > > > > index 9a08f2c..6e2a7bc 100644
> > > > > --- a/net/mac80211/rx.c
> > > > > +++ b/net/mac80211/rx.c
> > > > > @@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
> > > > >  	if (skb_linearize(rx->skb))
> > > > >  		return RX_DROP_UNUSABLE;
> > > > >  
> > > > > +	/*
> > > > > +	 *  skb_linearize() might change the skb->data and
> > > > > +	 *  previously cached variables (in this case, hdr) need to
> > > > > +	 *  be refreshed with the new data.
> > > > > +	 */
> > > > > +	hdr = (struct ieee80211_hdr *)rx->skb->data;
> > > > >  	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
> > > > >  
> > > > >  	if (frag == 0) {
> > > > 
> > > > And what about making sure the compiler doesn't optimize this away?
> > > > 
> > >  To avoid the double assignment, there is one more approach is to
> > > directly read fc and seq_ctrl  using skb_data. I will send that in the
> > > next version.
> > 
> > I don't think the double assignment is so bad, I just think that a
> > compiler might decide to ignore the second assignment.  Am I wrong?
> > 
> I don't understand why compiler will ignore the second assignment other
> than the above reason. What will be the solution in this case?

ACCESS_ONCE()? I have no idea why/if the compiler would actually do this
though.

johannes


^ permalink raw reply

* Re: [PATCH V3] mac80211: fix paged defragmentation
From: Abhijeet Kolekar @ 2010-05-11 18:52 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless@vger.kernel.org, Zhu, Yi
In-Reply-To: <20100511182423.GC2400@tuxdriver.com>

Hello John,
On Tue, 2010-05-11 at 11:24 -0700, John W. Linville wrote:
> On Tue, May 11, 2010 at 11:16:50AM -0700, Abhijeet Kolekar wrote:
> > Hello John,
> > On Tue, 2010-05-11 at 11:14 -0700, John W. Linville wrote:
> > > On Tue, May 11, 2010 at 11:22:11AM -0700, Abhijeet Kolekar wrote:
> > > > Paged RX skb patch broke the defragmentation. We need to read hdr again
> > > > after linearization.
> > > > 
> > > > It fixes following bug
> > > > http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194
> > > > 
> > > > Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
> > > > Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
> > > > ---
> > > > v2: Changed hdr reading.
> > > > v3: Added more comments.
> > > >  net/mac80211/rx.c |    6 ++++++
> > > >  1 files changed, 6 insertions(+), 0 deletions(-)
> > > > 
> > > > diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> > > > index 9a08f2c..6e2a7bc 100644
> > > > --- a/net/mac80211/rx.c
> > > > +++ b/net/mac80211/rx.c
> > > > @@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
> > > >  	if (skb_linearize(rx->skb))
> > > >  		return RX_DROP_UNUSABLE;
> > > >  
> > > > +	/*
> > > > +	 *  skb_linearize() might change the skb->data and
> > > > +	 *  previously cached variables (in this case, hdr) need to
> > > > +	 *  be refreshed with the new data.
> > > > +	 */
> > > > +	hdr = (struct ieee80211_hdr *)rx->skb->data;
> > > >  	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
> > > >  
> > > >  	if (frag == 0) {
> > > 
> > > And what about making sure the compiler doesn't optimize this away?
> > > 
> >  To avoid the double assignment, there is one more approach is to
> > directly read fc and seq_ctrl  using skb_data. I will send that in the
> > next version.
> 
> I don't think the double assignment is so bad, I just think that a
> compiler might decide to ignore the second assignment.  Am I wrong?
> 
I don't understand why compiler will ignore the second assignment other
than the above reason. What will be the solution in this case?

Abhijeet

> John



^ permalink raw reply

* Re: [PATCH V3] mac80211: fix paged defragmentation
From: John W. Linville @ 2010-05-11 18:24 UTC (permalink / raw)
  To: Abhijeet Kolekar; +Cc: linux-wireless@vger.kernel.org, Zhu, Yi
In-Reply-To: <1273601810.5955.44.camel@abhi-desktop>

On Tue, May 11, 2010 at 11:16:50AM -0700, Abhijeet Kolekar wrote:
> Hello John,
> On Tue, 2010-05-11 at 11:14 -0700, John W. Linville wrote:
> > On Tue, May 11, 2010 at 11:22:11AM -0700, Abhijeet Kolekar wrote:
> > > Paged RX skb patch broke the defragmentation. We need to read hdr again
> > > after linearization.
> > > 
> > > It fixes following bug
> > > http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194
> > > 
> > > Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
> > > Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
> > > ---
> > > v2: Changed hdr reading.
> > > v3: Added more comments.
> > >  net/mac80211/rx.c |    6 ++++++
> > >  1 files changed, 6 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> > > index 9a08f2c..6e2a7bc 100644
> > > --- a/net/mac80211/rx.c
> > > +++ b/net/mac80211/rx.c
> > > @@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
> > >  	if (skb_linearize(rx->skb))
> > >  		return RX_DROP_UNUSABLE;
> > >  
> > > +	/*
> > > +	 *  skb_linearize() might change the skb->data and
> > > +	 *  previously cached variables (in this case, hdr) need to
> > > +	 *  be refreshed with the new data.
> > > +	 */
> > > +	hdr = (struct ieee80211_hdr *)rx->skb->data;
> > >  	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
> > >  
> > >  	if (frag == 0) {
> > 
> > And what about making sure the compiler doesn't optimize this away?
> > 
>  To avoid the double assignment, there is one more approach is to
> directly read fc and seq_ctrl  using skb_data. I will send that in the
> next version.

I don't think the double assignment is so bad, I just think that a
compiler might decide to ignore the second assignment.  Am I wrong?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [RFC PATCH 1/2] mac80211: Add nl80211 antenna configuration
From: Luis R. Rodriguez @ 2010-05-11 18:26 UTC (permalink / raw)
  To: Johannes Berg, ic.felix
  Cc: Bruno Randolf, linville, linux-wireless, holgerschurig
In-Reply-To: <1273601969.20312.23.camel@jlt3.sipsolutions.net>

On Tue, May 11, 2010 at 11:19 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Tue, 2010-05-11 at 11:14 -0700, Luis R. Rodriguez wrote:
>
>> > Allow setting TX and RX antenna configuration via nl80211/cfg80211.
>>
>> I think we should call this TX / RX chainmask given that with 802.11n
>> hardware this is what this is called.
>
> Well, but even with 11n hw you might be able to select _antennas_ rather
> than chains. I'm convinced we'll need to differentiate that very
> closely, and 11g hw has only antenna, not chain, selection.

Heh you're right, you might have for example 3 antennas but only two
RX chains, for example. I still think it would be good for us to
figure out a way to bring these two notions together on a standard API
for both 11n and legacy, if possible.

  Luis

^ permalink raw reply

* [PATCH 1/5] drivers/net/wireless/hostap: Drop memory allocation cast
From: Julia Lawall @ 2010-05-11 18:25 UTC (permalink / raw)
  To: Jouni Malinen, John W. Linville, linux-wireless, netdev,
	linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Drop cast on the result of kmalloc and similar functions.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
@@

- (T *)
  (\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
   kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...))
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/net/wireless/hostap/hostap_80211_rx.c |    3 +--
 drivers/net/wireless/hostap/hostap_ioctl.c    |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index f4c5612..e0b3e8d 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -355,8 +355,7 @@ static struct hostap_bss_info *__hostap_add_bss(local_info_t *local, u8 *bssid,
 		list_del(&bss->list);
 		local->num_bss_info--;
 	} else {
-		bss = (struct hostap_bss_info *)
-			kmalloc(sizeof(*bss), GFP_ATOMIC);
+		bss = kmalloc(sizeof(*bss), GFP_ATOMIC);
 		if (bss == NULL)
 			return NULL;
 	}
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 9a08230..a85e43a 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -3039,8 +3039,7 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
 	    p->length > 1024 || !p->pointer)
 		return -EINVAL;
 
-	param = (struct prism2_download_param *)
-		kmalloc(p->length, GFP_KERNEL);
+	param = kmalloc(p->length, GFP_KERNEL);
 	if (param == NULL)
 		return -ENOMEM;
 

^ permalink raw reply related

* Re: [PATCH V3] mac80211: fix paged defragmentation
From: Abhijeet Kolekar @ 2010-05-11 18:16 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless@vger.kernel.org, Zhu, Yi
In-Reply-To: <20100511181439.GB2400@tuxdriver.com>

Hello John,
On Tue, 2010-05-11 at 11:14 -0700, John W. Linville wrote:
> On Tue, May 11, 2010 at 11:22:11AM -0700, Abhijeet Kolekar wrote:
> > Paged RX skb patch broke the defragmentation. We need to read hdr again
> > after linearization.
> > 
> > It fixes following bug
> > http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194
> > 
> > Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
> > Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
> > ---
> > v2: Changed hdr reading.
> > v3: Added more comments.
> >  net/mac80211/rx.c |    6 ++++++
> >  1 files changed, 6 insertions(+), 0 deletions(-)
> > 
> > diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> > index 9a08f2c..6e2a7bc 100644
> > --- a/net/mac80211/rx.c
> > +++ b/net/mac80211/rx.c
> > @@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
> >  	if (skb_linearize(rx->skb))
> >  		return RX_DROP_UNUSABLE;
> >  
> > +	/*
> > +	 *  skb_linearize() might change the skb->data and
> > +	 *  previously cached variables (in this case, hdr) need to
> > +	 *  be refreshed with the new data.
> > +	 */
> > +	hdr = (struct ieee80211_hdr *)rx->skb->data;
> >  	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
> >  
> >  	if (frag == 0) {
> 
> And what about making sure the compiler doesn't optimize this away?
> 
 To avoid the double assignment, there is one more approach is to
directly read fc and seq_ctrl  using skb_data. I will send that in the
next version.

Abhijeet

> John



^ permalink raw reply

* Re: [RFC PATCH 1/2] mac80211: Add nl80211 antenna configuration
From: Johannes Berg @ 2010-05-11 18:19 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: Bruno Randolf, linville, linux-wireless, holgerschurig
In-Reply-To: <AANLkTilowwAyqLrIJ0_mlZxnqY-TqSHM3xdXkbO8aH6-@mail.gmail.com>

On Tue, 2010-05-11 at 11:14 -0700, Luis R. Rodriguez wrote:

> > Allow setting TX and RX antenna configuration via nl80211/cfg80211.
> 
> I think we should call this TX / RX chainmask given that with 802.11n
> hardware this is what this is called.

Well, but even with 11n hw you might be able to select _antennas_ rather
than chains. I'm convinced we'll need to differentiate that very
closely, and 11g hw has only antenna, not chain, selection.

johannes


^ permalink raw reply

* Re: [RFC PATCH 0/2] mac80211: antenna configuration
From: Luis R. Rodriguez @ 2010-05-11 18:17 UTC (permalink / raw)
  To: Bruno Randolf; +Cc: Johannes Berg, linville, linux-wireless, holgerschurig
In-Reply-To: <201005111834.36879.br1@einfach.org>

On Tue, May 11, 2010 at 2:34 AM, Bruno Randolf <br1@einfach.org> wrote:
> On Tuesday 11 May 2010 17:53:19 you wrote:
>> On Tue, 2010-05-11 at 17:38 +0900, Bruno Randolf wrote:
>> > i have followed holger schurig's suggestion to use a bitmap for allowed
>> > antennas. when multiple antennas are selected in the bitmap, the driver
>> > may use diversity. i think that this allows for the most flexible, yet
>> > simple configuration of antennas, and drivers can just reject
>> > configurations they cannot support. i hope that this will also be
>> > generic enough for 802.11n with multiple antennas
>>
>> Not sure ... 11n has antennas and chains, but people mix them up
>> frequently. Does this API even make sense for 11n? Use cases? Should it
>> be about *antennas*, or about *chains*?
>
> thanks for the review! i'll resend tomorrow.
>
> i personally don't know about 802.11n - and what i need is about *antennas* :)

I figured, let us help you with the 11n review.

  Luis

^ permalink raw reply

* Re: [PATCH 2/4] ath9k: add debugfs files for reading/writing the rx and tx chainmask
From: Luis R. Rodriguez @ 2010-05-11 18:15 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, linville
In-Reply-To: <1273591383-76696-2-git-send-email-nbd@openwrt.org>

On Tue, May 11, 2010 at 8:23 AM, Felix Fietkau <nbd@openwrt.org> wrote:
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>

How about we use bruno's patch instead and we help review it for
802.11n? Then this would not be needed?

  Luis

^ permalink raw reply

* Re: [PATCH V3] mac80211: fix paged defragmentation
From: John W. Linville @ 2010-05-11 18:14 UTC (permalink / raw)
  To: Abhijeet Kolekar; +Cc: linux-wireless, yi.zhu
In-Reply-To: <1273602131-9188-1-git-send-email-abhijeet.kolekar@intel.com>

On Tue, May 11, 2010 at 11:22:11AM -0700, Abhijeet Kolekar wrote:
> Paged RX skb patch broke the defragmentation. We need to read hdr again
> after linearization.
> 
> It fixes following bug
> http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194
> 
> Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
> Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
> ---
> v2: Changed hdr reading.
> v3: Added more comments.
>  net/mac80211/rx.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> index 9a08f2c..6e2a7bc 100644
> --- a/net/mac80211/rx.c
> +++ b/net/mac80211/rx.c
> @@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
>  	if (skb_linearize(rx->skb))
>  		return RX_DROP_UNUSABLE;
>  
> +	/*
> +	 *  skb_linearize() might change the skb->data and
> +	 *  previously cached variables (in this case, hdr) need to
> +	 *  be refreshed with the new data.
> +	 */
> +	hdr = (struct ieee80211_hdr *)rx->skb->data;
>  	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
>  
>  	if (frag == 0) {

And what about making sure the compiler doesn't optimize this away?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [RFC PATCH 1/2] mac80211: Add nl80211 antenna configuration
From: Luis R. Rodriguez @ 2010-05-11 18:14 UTC (permalink / raw)
  To: Bruno Randolf; +Cc: johannes, linville, linux-wireless, holgerschurig
In-Reply-To: <20100511083900.28289.43864.stgit@tt-desk>

On Tue, May 11, 2010 at 1:39 AM, Bruno Randolf <br1@einfach.org> wrote:

Subject should be for cfg80211, not mac80211. In fact can you submit
the mac80211 stuff in a separate secondary patch? Some more comments
below.

> Allow setting TX and RX antenna configuration via nl80211/cfg80211.

I think we should call this TX / RX chainmask given that with 802.11n
hardware this is what this is called.

> The antenna configuration is defined as a bitmap of allowed antennas. This
> bitmap is 8 bit at the moment, each bit representing one antenna.

If you use chainmask for this instead of 'antenna configuration' the
wording would be something like:

The chainmask is defined as a bitmap of chain configurations used for TX/RX. The
bitmap allows for configuring up to up to 4 chains for both TX and RX,
4 bits for each TX chain, 4 bits for each RX chain.

> If multiple
> antennas are selected, the driver may use diversity for receive and transmit.

For 802.11n this is called "selection diversity" but typically just
referred to as "diversity", for legacy this is called "antenna
diversity". It may be good to elaborate how selection diversity or
antenna diversity might be enabled, ie, will this be another command,
or what. I think for legacy another command makes sense, and it may be
possible for us to use the same command for enabling selection
diversity, I am not sure if we can fine tune the diversity algorithm
at this time, I will have to review this and get back to you.

> This allows for a simple, yet flexible configuration interface for antennas,
> while drivers may reject configurations they cannot support.

:) !

  Luis

^ permalink raw reply

* [PATCH V3] mac80211: fix paged defragmentation
From: Abhijeet Kolekar @ 2010-05-11 18:22 UTC (permalink / raw)
  To: linux-wireless; +Cc: yi.zhu, Abhijeet Kolekar

Paged RX skb patch broke the defragmentation. We need to read hdr again
after linearization.

It fixes following bug
http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2194

Signed-off-by: Zhu, Yi <yi.zhu@intel.com>
Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
---
v2: Changed hdr reading.
v3: Added more comments.
 net/mac80211/rx.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 9a08f2c..6e2a7bc 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
 	if (skb_linearize(rx->skb))
 		return RX_DROP_UNUSABLE;
 
+	/*
+	 *  skb_linearize() might change the skb->data and
+	 *  previously cached variables (in this case, hdr) need to
+	 *  be refreshed with the new data.
+	 */
+	hdr = (struct ieee80211_hdr *)rx->skb->data;
 	seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
 
 	if (frag == 0) {
-- 
1.6.3.3


^ permalink raw reply related

* Re: kernel BUG in iwl-agn-rs.c:2076, WAS: iwlagn + some accesspoint == hardlock
From: reinette chatre @ 2010-05-11 17:21 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: John W. Linville, NilsRadtkelkml@think-future.de,
	linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org
In-Reply-To: <201005111750.08533.borntraeger@de.ibm.com>

On Tue, 2010-05-11 at 08:50 -0700, Christian Borntraeger wrote:
> Am Donnerstag 06 Mai 2010 18:28:48 schrieb reinette chatre:
> > Below seven iwlwifi patches were added after rc4. If you are unable to
> > bisect ... perhaps you can run a while by reverting more and more from
> > this list?
> > 
> > f2fa1b015e9c199e45c836c769d94db595150731 iwlwifi: correct 6000 EEPROM regulatory address
> > 88be026490ed89c2ffead81a52531fbac5507e01 iwlwifi: fix scan races
> > 8b9fce77737ae9983f61ec56cd53f52fb738b2c7 iwlwifi: work around bogus active chains detection
> > ece6444c2fe80dab679beb5f0d58b091f1933b00 iwlwifi: need check for valid qos packet before free
> > de0f60ea94e132c858caa64a44b2012e1e8580b0 iwlwifi: avoid Tx queue memory allocation in interface down
> > 04f2dec1c3d375c4072613880f28f43b66524876 iwlwifi: use consistent table for tx data collect
> > dd48744964296b5713032ea1d66eb9e3d990e287 iwlwifi: fix DMA allocation warnings
> 
> Just to give you some feedback. Sometimes it takes a while until it crashes.
> My hand made bisect is currently at two remaining patches:
> 
> de0f60ea94e132c858caa64a44b2012e1e8580b0
> 8b9fce77737ae9983f61ec56cd53f52fb738b2c7
> 
> reverting both solves my hard lockup. I will try to isolate the "bad" patch
> but this takes some more days since I wont be in the "hazardous environment"
> this week.

Thank you for digging into this. It will be very helpful it you can get
us a trace of the crash - any chance that netconsole may work?

Reinette



^ permalink raw reply

* Re: kernel BUG in iwl-agn-rs.c:2076, WAS: iwlagn + some accesspoint == hardlock
From: Christian Borntraeger @ 2010-05-11 15:50 UTC (permalink / raw)
  To: reinette chatre
  Cc: John W. Linville, NilsRadtkelkml@think-future.de,
	linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org
In-Reply-To: <1273163328.2226.2530.camel@rchatre-DESK>

Am Donnerstag 06 Mai 2010 18:28:48 schrieb reinette chatre:
> Below seven iwlwifi patches were added after rc4. If you are unable to
> bisect ... perhaps you can run a while by reverting more and more from
> this list?
> 
> f2fa1b015e9c199e45c836c769d94db595150731 iwlwifi: correct 6000 EEPROM regulatory address
> 88be026490ed89c2ffead81a52531fbac5507e01 iwlwifi: fix scan races
> 8b9fce77737ae9983f61ec56cd53f52fb738b2c7 iwlwifi: work around bogus active chains detection
> ece6444c2fe80dab679beb5f0d58b091f1933b00 iwlwifi: need check for valid qos packet before free
> de0f60ea94e132c858caa64a44b2012e1e8580b0 iwlwifi: avoid Tx queue memory allocation in interface down
> 04f2dec1c3d375c4072613880f28f43b66524876 iwlwifi: use consistent table for tx data collect
> dd48744964296b5713032ea1d66eb9e3d990e287 iwlwifi: fix DMA allocation warnings

Just to give you some feedback. Sometimes it takes a while until it crashes.
My hand made bisect is currently at two remaining patches:

de0f60ea94e132c858caa64a44b2012e1e8580b0
8b9fce77737ae9983f61ec56cd53f52fb738b2c7

reverting both solves my hard lockup. I will try to isolate the "bad" patch
but this takes some more days since I wont be in the "hazardous environment"
this week.

Christian

^ permalink raw reply

* [PATCH 3/4] ath9k: add debugfs files for reading/writing registers
From: Felix Fietkau @ 2010-05-11 15:23 UTC (permalink / raw)
  To: linux-wireless; +Cc: lrodriguez, linville
In-Reply-To: <1273591383-76696-2-git-send-email-nbd@openwrt.org>

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

diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 8d7c046..29898f8 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -795,6 +795,86 @@ static const struct file_operations fops_recv = {
 	.owner = THIS_MODULE
 };
 
+static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
+                                size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	char buf[32];
+	unsigned int len;
+
+	len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.regidx);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	unsigned long regidx;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &regidx))
+		return -EINVAL;
+
+	sc->debug.regidx = regidx;
+	return count;
+}
+
+static const struct file_operations fops_regidx = {
+	.read = read_file_regidx,
+	.write = write_file_regidx,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
+static ssize_t read_file_regval(struct file *file, char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_hw *ah = sc->sc_ah;
+	char buf[32];
+	unsigned int len;
+	u32 regval;
+
+	regval = REG_READ_D(ah, sc->debug.regidx);
+	len = snprintf(buf, sizeof(buf), "0x%08x\n", regval);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_hw *ah = sc->sc_ah;
+	unsigned long regval;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &regval))
+		return -EINVAL;
+
+	REG_WRITE_D(ah, sc->debug.regidx, regval);
+	return count;
+}
+
+static const struct file_operations fops_regval = {
+	.read = read_file_regval,
+	.write = write_file_regval,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
 int ath9k_init_debug(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
@@ -846,6 +926,15 @@ int ath9k_init_debug(struct ath_hw *ah)
 			sc->debug.debugfs_phy, sc, &fops_tx_chainmask))
 		goto err;
 
+	if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR,
+			sc->debug.debugfs_phy, sc, &fops_regidx))
+		goto err;
+
+	if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR,
+			sc->debug.debugfs_phy, sc, &fops_regval))
+		goto err;
+
+	sc->debug.regidx = 0;
 	return 0;
 err:
 	ath9k_exit_debug(ah);
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 7314360..5147b87 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -153,6 +153,7 @@ struct ath_stats {
 
 struct ath9k_debug {
 	struct dentry *debugfs_phy;
+	u32 regidx;
 	struct ath_stats stats;
 };
 
-- 
1.6.4.2


^ permalink raw reply related

* [PATCH 1/4] ath9k: use debugfs_remove_recursive() instead of keeping pointers to all entries
From: Felix Fietkau @ 2010-05-11 15:23 UTC (permalink / raw)
  To: linux-wireless; +Cc: lrodriguez, linville

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/debug.c |   55 +++++++++----------------------
 drivers/net/wireless/ath/ath9k/debug.h |    7 ----
 2 files changed, 16 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 64e30cd..679257c 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -722,52 +722,36 @@ int ath9k_init_debug(struct ath_hw *ah)
 	sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
 						      ath9k_debugfs_root);
 	if (!sc->debug.debugfs_phy)
-		goto err;
+		return -ENOMEM;
 
 #ifdef CONFIG_ATH_DEBUG
-	sc->debug.debugfs_debug = debugfs_create_file("debug",
-		S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
-	if (!sc->debug.debugfs_debug)
+	if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR,
+			sc->debug.debugfs_phy, sc, &fops_debug))
 		goto err;
 #endif
 
-	sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR,
-				       sc->debug.debugfs_phy, sc, &fops_dma);
-	if (!sc->debug.debugfs_dma)
+	if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy,
+			sc, &fops_dma))
 		goto err;
 
-	sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
-						     S_IRUSR,
-						     sc->debug.debugfs_phy,
-						     sc, &fops_interrupt);
-	if (!sc->debug.debugfs_interrupt)
+	if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy,
+			sc, &fops_interrupt))
 		goto err;
 
-	sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
-						  S_IRUSR,
-						  sc->debug.debugfs_phy,
-						  sc, &fops_rcstat);
-	if (!sc->debug.debugfs_rcstat)
+	if (!debugfs_create_file("rcstat", S_IRUSR, sc->debug.debugfs_phy,
+			sc, &fops_rcstat))
 		goto err;
 
-	sc->debug.debugfs_wiphy = debugfs_create_file(
-		"wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc,
-		&fops_wiphy);
-	if (!sc->debug.debugfs_wiphy)
+	if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR,
+			sc->debug.debugfs_phy, sc, &fops_wiphy))
 		goto err;
 
-	sc->debug.debugfs_xmit = debugfs_create_file("xmit",
-						     S_IRUSR,
-						     sc->debug.debugfs_phy,
-						     sc, &fops_xmit);
-	if (!sc->debug.debugfs_xmit)
+	if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy,
+			sc, &fops_xmit))
 		goto err;
 
-	sc->debug.debugfs_recv = debugfs_create_file("recv",
-						     S_IRUSR,
-						     sc->debug.debugfs_phy,
-						     sc, &fops_recv);
-	if (!sc->debug.debugfs_recv)
+	if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy,
+			sc, &fops_recv))
 		goto err;
 
 	return 0;
@@ -781,14 +765,7 @@ void ath9k_exit_debug(struct ath_hw *ah)
 	struct ath_common *common = ath9k_hw_common(ah);
 	struct ath_softc *sc = (struct ath_softc *) common->priv;
 
-	debugfs_remove(sc->debug.debugfs_recv);
-	debugfs_remove(sc->debug.debugfs_xmit);
-	debugfs_remove(sc->debug.debugfs_wiphy);
-	debugfs_remove(sc->debug.debugfs_rcstat);
-	debugfs_remove(sc->debug.debugfs_interrupt);
-	debugfs_remove(sc->debug.debugfs_dma);
-	debugfs_remove(sc->debug.debugfs_debug);
-	debugfs_remove(sc->debug.debugfs_phy);
+	debugfs_remove_recursive(sc->debug.debugfs_phy);
 }
 
 int ath9k_debug_create_root(void)
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index c545960..7314360 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -153,13 +153,6 @@ struct ath_stats {
 
 struct ath9k_debug {
 	struct dentry *debugfs_phy;
-	struct dentry *debugfs_debug;
-	struct dentry *debugfs_dma;
-	struct dentry *debugfs_interrupt;
-	struct dentry *debugfs_rcstat;
-	struct dentry *debugfs_wiphy;
-	struct dentry *debugfs_xmit;
-	struct dentry *debugfs_recv;
 	struct ath_stats stats;
 };
 
-- 
1.6.4.2


^ permalink raw reply related

* [PATCH 4/4] ath9k_hw: clean up EEPROM endian handling on AR9003
From: Felix Fietkau @ 2010-05-11 15:23 UTC (permalink / raw)
  To: linux-wireless; +Cc: lrodriguez, linville
In-Reply-To: <1273591383-76696-3-git-send-email-nbd@openwrt.org>

Remove the double swapping of the descriptor data structure, instead
keep it little-endian (native format of the eeprom data), and byteswap
on access.
This allows sparse to verify endian access to the eeprom struct.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |  174 ++++++++++-------------
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.h |   10 +-
 2 files changed, 81 insertions(+), 103 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 8a79550..23eb60e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -38,6 +38,9 @@
 #define AR_SWITCH_TABLE_ALL (0xfff)
 #define AR_SWITCH_TABLE_ALL_S (0)
 
+#define LE16(x) __constant_cpu_to_le16(x)
+#define LE32(x) __constant_cpu_to_le32(x)
+
 static const struct ar9300_eeprom ar9300_default = {
 	.eepromVersion = 2,
 	.templateVersion = 2,
@@ -45,7 +48,7 @@ static const struct ar9300_eeprom ar9300_default = {
 	.custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 		     0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 	.baseEepHeader = {
-		.regDmn = {0, 0x1f},
+		.regDmn = { LE16(0), LE16(0x1f) },
 		.txrxMask =  0x77, /* 4 bits tx and 4 bits rx */
 		.opCapFlags = {
 			.opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
@@ -76,15 +79,15 @@ static const struct ar9300_eeprom ar9300_default = {
 	.modalHeader2G = {
 	/* ar9300_modal_eep_header  2g */
 		/* 4 idle,t1,t2,b(4 bits per setting) */
-		.antCtrlCommon = 0x110,
+		.antCtrlCommon = LE32(0x110),
 		/* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
-		.antCtrlCommon2 = 0x22222,
+		.antCtrlCommon2 = LE32(0x22222),
 
 		/*
 		 * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
 		 * rx1, rx12, b (2 bits each)
 		 */
-		.antCtrlChain = {0x150, 0x150, 0x150},
+		.antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
 
 		/*
 		 * xatten1DB[AR9300_MAX_CHAINS];  3 xatten1_db
@@ -287,12 +290,12 @@ static const struct ar9300_eeprom ar9300_default = {
 	 },
 	.modalHeader5G = {
 		/* 4 idle,t1,t2,b (4 bits per setting) */
-		.antCtrlCommon = 0x110,
+		.antCtrlCommon = LE32(0x110),
 		/* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
-		.antCtrlCommon2 = 0x22222,
+		.antCtrlCommon2 = LE32(0x22222),
 		 /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
 		.antCtrlChain = {
-			0x000, 0x000, 0x000,
+			LE16(0x000), LE16(0x000), LE16(0x000),
 		},
 		 /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
 		.xatten1DB = {0, 0, 0},
@@ -620,9 +623,9 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
 	case EEP_MAC_MSW:
 		return eep->macAddr[4] << 8 | eep->macAddr[5];
 	case EEP_REG_0:
-		return pBase->regDmn[0];
+		return le16_to_cpu(pBase->regDmn[0]);
 	case EEP_REG_1:
-		return pBase->regDmn[1];
+		return le16_to_cpu(pBase->regDmn[1]);
 	case EEP_OP_CAP:
 		return pBase->deviceCap;
 	case EEP_OP_MODE:
@@ -640,93 +643,80 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
 		/* Bit 4 is internal regulator flag */
 		return (pBase->featureEnable & 0x10) >> 4;
 	case EEP_SWREG:
-		return pBase->swreg;
+		return le32_to_cpu(pBase->swreg);
 	default:
 		return 0;
 	}
 }
 
-#ifdef __BIG_ENDIAN
-static void ar9300_swap_eeprom(struct ar9300_eeprom *eep)
+static bool ar9300_eeprom_read_byte(struct ath_common *common, int address,
+				    u8 *buffer)
 {
-	u32 dword;
-	u16 word;
-	int i;
-
-	word = swab16(eep->baseEepHeader.regDmn[0]);
-	eep->baseEepHeader.regDmn[0] = word;
-
-	word = swab16(eep->baseEepHeader.regDmn[1]);
-	eep->baseEepHeader.regDmn[1] = word;
-
-	dword = swab32(eep->baseEepHeader.swreg);
-	eep->baseEepHeader.swreg = dword;
+	u16 val;
 
-	dword = swab32(eep->modalHeader2G.antCtrlCommon);
-	eep->modalHeader2G.antCtrlCommon = dword;
+	if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
+		return false;
 
-	dword = swab32(eep->modalHeader2G.antCtrlCommon2);
-	eep->modalHeader2G.antCtrlCommon2 = dword;
+	*buffer = (val >> (8 * (address % 2))) & 0xff;
+	return true;
+}
 
-	dword = swab32(eep->modalHeader5G.antCtrlCommon);
-	eep->modalHeader5G.antCtrlCommon = dword;
+static bool ar9300_eeprom_read_word(struct ath_common *common, int address,
+				    u8 *buffer)
+{
+	u16 val;
 
-	dword = swab32(eep->modalHeader5G.antCtrlCommon2);
-	eep->modalHeader5G.antCtrlCommon2 = dword;
+	if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
+		return false;
 
-	for (i = 0; i < AR9300_MAX_CHAINS; i++) {
-		word = swab16(eep->modalHeader2G.antCtrlChain[i]);
-		eep->modalHeader2G.antCtrlChain[i] = word;
+	buffer[0] = val >> 8;
+	buffer[1] = val & 0xff;
 
-		word = swab16(eep->modalHeader5G.antCtrlChain[i]);
-		eep->modalHeader5G.antCtrlChain[i] = word;
-	}
+	return true;
 }
-#endif
 
-static bool ar9300_hw_read_eeprom(struct ath_hw *ah,
-				  long address, u8 *buffer, int many)
+static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
+			       int count)
 {
-	int i;
-	u8 value[2];
-	unsigned long eepAddr;
-	unsigned long byteAddr;
-	u16 *svalue;
 	struct ath_common *common = ath9k_hw_common(ah);
+	int i;
 
-	if ((address < 0) || ((address + many) > AR9300_EEPROM_SIZE - 1)) {
+	if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
 		ath_print(common, ATH_DBG_EEPROM,
 			  "eeprom address not in range\n");
 		return false;
 	}
 
-	for (i = 0; i < many; i++) {
-		eepAddr = (u16) (address + i) / 2;
-		byteAddr = (u16) (address + i) % 2;
-		svalue = (u16 *) value;
-		if (!ath9k_hw_nvram_read(common, eepAddr, svalue)) {
-			ath_print(common, ATH_DBG_EEPROM,
-				  "unable to read eeprom region\n");
-			return false;
-		}
-		*svalue = le16_to_cpu(*svalue);
-		buffer[i] = value[byteAddr];
+	/*
+	 * Since we're reading the bytes in reverse order from a little-endian
+	 * word stream, an even address means we only use the lower half of
+	 * the 16-bit word at that address
+	 */
+	if (address % 2 == 0) {
+		if (!ar9300_eeprom_read_byte(common, address--, buffer++))
+			goto error;
+
+		count--;
 	}
 
-	return true;
-}
+	for (i = 0; i < count / 2; i++) {
+		if (!ar9300_eeprom_read_word(common, address, buffer))
+			goto error;
 
-static bool ar9300_read_eeprom(struct ath_hw *ah,
-			       int address, u8 *buffer, int many)
-{
-	int it;
+		address -= 2;
+		buffer += 2;
+	}
+
+	if (count % 2)
+		if (!ar9300_eeprom_read_byte(common, address, buffer))
+			goto error;
 
-	for (it = 0; it < many; it++)
-		if (!ar9300_hw_read_eeprom(ah,
-					   (address - it),
-					   (buffer + it), 1))
-			return false;
 	return true;
+
+error:
+	ath_print(common, ATH_DBG_EEPROM,
+		  "unable to read eeprom region at offset %d\n", address);
+	return false;
 }
 
 static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
@@ -927,30 +917,13 @@ fail:
  */
 static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
 {
-	u8 *mptr = NULL;
-	int mdata_size;
+	u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
 
-	mptr = (u8 *) &ah->eeprom.ar9300_eep;
-	mdata_size = sizeof(struct ar9300_eeprom);
+	if (ar9300_eeprom_restore_internal(ah, mptr,
+			sizeof(struct ar9300_eeprom)) < 0)
+		return false;
 
-	if (mptr && mdata_size > 0) {
-		/* At this point, mptr points to the eeprom data structure
-		 * in it's "default" state. If this is big endian, swap the
-		 * data structures back to "little endian"
-		 */
-		/* First swap, default to Little Endian */
-#ifdef __BIG_ENDIAN
-		ar9300_swap_eeprom((struct ar9300_eeprom *)mptr);
-#endif
-		if (ar9300_eeprom_restore_internal(ah, mptr, mdata_size) >= 0)
-			return true;
-
-		/* Second Swap, back to Big Endian */
-#ifdef __BIG_ENDIAN
-		ar9300_swap_eeprom((struct ar9300_eeprom *)mptr);
-#endif
-	}
-	return false;
+	return true;
 }
 
 /* XXX: review hardware docs */
@@ -998,21 +971,25 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
 static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
 {
 	struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+	__le32 val;
 
 	if (is2ghz)
-		return eep->modalHeader2G.antCtrlCommon;
+		val = eep->modalHeader2G.antCtrlCommon;
 	else
-		return eep->modalHeader5G.antCtrlCommon;
+		val = eep->modalHeader5G.antCtrlCommon;
+	return le32_to_cpu(val);
 }
 
 static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
 {
 	struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+	__le32 val;
 
 	if (is2ghz)
-		return eep->modalHeader2G.antCtrlCommon2;
+		val = eep->modalHeader2G.antCtrlCommon2;
 	else
-		return eep->modalHeader5G.antCtrlCommon2;
+		val = eep->modalHeader5G.antCtrlCommon2;
+	return le32_to_cpu(val);
 }
 
 static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
@@ -1020,15 +997,16 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
 					bool is2ghz)
 {
 	struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
+	__le16 val = 0;
 
 	if (chain >= 0 && chain < AR9300_MAX_CHAINS) {
 		if (is2ghz)
-			return eep->modalHeader2G.antCtrlChain[chain];
+			val = eep->modalHeader2G.antCtrlChain[chain];
 		else
-			return eep->modalHeader5G.antCtrlChain[chain];
+			val = eep->modalHeader5G.antCtrlChain[chain];
 	}
 
-	return 0;
+	return le16_to_cpu(val);
 }
 
 static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index d8c0318..23fb353 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -169,7 +169,7 @@ enum CompressAlgorithm {
 };
 
 struct ar9300_base_eep_hdr {
-	u16 regDmn[2];
+	__le16 regDmn[2];
 	/* 4 bits tx and 4 bits rx */
 	u8 txrxMask;
 	struct eepFlags opCapFlags;
@@ -199,16 +199,16 @@ struct ar9300_base_eep_hdr {
 	u8 rxBandSelectGpio;
 	u8 txrxgain;
 	/* SW controlled internal regulator fields */
-	u32 swreg;
+	__le32 swreg;
 } __packed;
 
 struct ar9300_modal_eep_header {
 	/* 4 idle, t1, t2, b (4 bits per setting) */
-	u32 antCtrlCommon;
+	__le32 antCtrlCommon;
 	/* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
-	u32 antCtrlCommon2;
+	__le32 antCtrlCommon2;
 	/* 6 idle, t, r, rx1, rx12, b (2 bits each) */
-	u16 antCtrlChain[AR9300_MAX_CHAINS];
+	__le16 antCtrlChain[AR9300_MAX_CHAINS];
 	/* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
 	u8 xatten1DB[AR9300_MAX_CHAINS];
 	/* 3  xatten1_margin for merlin (0xa20c/b20c 16:12 */
-- 
1.6.4.2


^ permalink raw reply related

* [PATCH 2/4] ath9k: add debugfs files for reading/writing the rx and tx chainmask
From: Felix Fietkau @ 2010-05-11 15:23 UTC (permalink / raw)
  To: linux-wireless; +Cc: lrodriguez, linville
In-Reply-To: <1273591383-76696-1-git-send-email-nbd@openwrt.org>

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

diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 679257c..8d7c046 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -78,6 +78,90 @@ static const struct file_operations fops_debug = {
 
 #define DMA_BUF_LEN 1024
 
+static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	char buf[32];
+	unsigned int len;
+
+	len = snprintf(buf, sizeof(buf), "0x%08x\n", common->tx_chainmask);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	unsigned long mask;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &mask))
+		return -EINVAL;
+
+	common->tx_chainmask = mask;
+	sc->sc_ah->caps.tx_chainmask = mask;
+	return count;
+}
+
+static const struct file_operations fops_tx_chainmask = {
+	.read = read_file_tx_chainmask,
+	.write = write_file_tx_chainmask,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
+
+static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	char buf[32];
+	unsigned int len;
+
+	len = snprintf(buf, sizeof(buf), "0x%08x\n", common->rx_chainmask);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
+			     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	unsigned long mask;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EINVAL;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &mask))
+		return -EINVAL;
+
+	common->rx_chainmask = mask;
+	sc->sc_ah->caps.rx_chainmask = mask;
+	return count;
+}
+
+static const struct file_operations fops_rx_chainmask = {
+	.read = read_file_rx_chainmask,
+	.write = write_file_rx_chainmask,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE
+};
+
+
 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
 			     size_t count, loff_t *ppos)
 {
@@ -754,6 +838,14 @@ int ath9k_init_debug(struct ath_hw *ah)
 			sc, &fops_recv))
 		goto err;
 
+	if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
+			sc->debug.debugfs_phy, sc, &fops_rx_chainmask))
+		goto err;
+
+	if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
+			sc->debug.debugfs_phy, sc, &fops_tx_chainmask))
+		goto err;
+
 	return 0;
 err:
 	ath9k_exit_debug(ah);
-- 
1.6.4.2


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).