Re: [ath9k-devel] AR9280 AP mode - 5GHz band

2014-07-08 Thread Janusz Dziedzic
On 8 July 2014 08:20, Hosam Hittini  wrote:
> Hello there,
>
> I have this dual band wireless adapter
> https://www.thinkpenguin.com/gnu-linux/penguin-wireless-n-dual-band-usb-adapter-gnu-linux-tpe-nusbdb
> and it uses AR9280 chipset for the 5GHz communication
> It’s using ath9k driver; I have Ubuntu 13.10 running 3.11 kernel and the
> adapter worked out of the box
> I’m using hostapd to configure the adapter as a software AP
> When I tried to configure the adapter as an AP on the 2.4GHz channels it
> worked fine
> When tried the 5GHz channels it gives me the following error
>
> channel [1] (40) is disabled for use in AP mode, flags: 0x77
> wlan1: IEEE 802.11 Configured channel (40) not found from the channel list
> of current mode (2) IEEE 802.11a
> wlan1: IEEE 802.11 Hardware does not support configured channel
>
> In addition, iw list command shows that the 5GHz channels have the “passive
> scanning” and “no IBSS” flags
> I can associate with an AP on the 5GHz though
> How to solve that

You can try this - works fine with my 9280
Compile your kernel with options:
CONFIG_ATH_REG_DYNAMIC_USER_REG_HINTS=y
CONFIG_ATH_REG_DYNAMIC_USER_CERT_TESTING=y

Next set country, eg. iw reg set US
And check channels available (iw list). You should get 36-48 and
149-165 available.
If available, next you can check hostapd.

DFS channels should works as well when you enable DFS:
CONFIG_ATH9K_DFS_CERTIFIED required

BR
Janusz

> Thank you
>
> Regards,
> Eng. Hosam Hittini
>
>
> ___
> ath9k-devel mailing list
> ath9k-devel@lists.ath9k.org
> https://lists.ath9k.org/mailman/listinfo/ath9k-devel
>
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] AR9004 scan in AP mode?

2015-02-22 Thread Janusz Dziedzic
On 20 February 2015 at 21:49, Jonathan Bagg  wrote:
>
> I'm evaluating the AR9485 and AR9462 using a 3.18.0 kernel.  I am not
> able to scan (iw wlan0 scan) when the devices are in AP mode. I'm
> wondering if this not possible because the AR9485 and AR9462 lack
> hardware / firmware or is it a limitation of the ath9k driver that could
> be added at some point?
>
try iw wlan0 scan ap-force

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] ath9k: use_chanctx=1 sta + p2p_client - oops

2015-05-21 Thread Janusz Dziedzic
Hello,

During tests of multi channel concurency with AR9462 (rev 01) I hit such oops

gdb point xmit.c +2378

[70874.035886] BUG: unable to handle kernel NULL pointer dereference
at   (null)
[70874.043725] IP: [] ath_tx_start+0x129/0x450 [ath9k]
[70874.050173] PGD cb5e4067 PUD cae20067 PMD 0
[70874.054462] Oops:  [#1] SMP
[70874.057702] Modules linked in: iwlmvm(E) iwlwifi(E) ath10k_pci(OE)
ath10k_core(OE) ath9k(E) ath9k_common(E) ath9k_hw(E) ath(E)
mac80211(OE) cfg80211(OE) ftdi_sio(E) usbserial(E) ctr(E) ccm(E)
arc4(E) dm_crypt(E) cmac(E) dell_wmi(E) sparse_keymap(E) intel_rapl(E)
dell_laptop(E) iosf_mbi(E) dcdbas(E) x86_pkg_temp_thermal(E)
intel_powerclamp(E) i8k(E) coretemp(E) kvm_intel(E) kvm(E) rfcomm(E)
bnep(E) crct10dif_pclmul(E) crc32_pclmul(E) snd_hda_codec_idt(E)
ghash_clmulni_intel(E) snd_hda_codec_generic(E) uvcvideo(E)
aesni_intel(E) videobuf2_vmalloc(E) aes_x86_64(E) videobuf2_memops(E)
lrw(E) gf128mul(E) glue_helper(E) ablk_helper(E) videobuf2_core(E)
cryptd(E) snd_hda_intel(E) v4l2_common(E) snd_hda_controller(E)
videodev(E) snd_hda_codec(E) snd_hda_core(E) snd_hwdep(E) joydev(E)
serio_raw(E) snd_pcm(E) media(E) ath3k(E) snd_seq_midi(E)
snd_seq_midi_event(E) btusb(E) btbcm(E) snd_rawmidi(E) btintel(E)
bluetooth(E) snd_seq(E) lpc_ich(E) snd_seq_device(E) snd_timer(E)
dell_smo8800(E) mac_hid(E) snd(E) mei_me(E) soundcore(E) shpchp(E)
mei(E) binfmt_misc(E) parport_pc(E) ppdev(E) lp(E) parport(E)
nouveau(E) mxm_wmi(E) i915(E) ttm(E) i2c_algo_bit(E) drm_kms_helper(E)
e1000e(E) sdhci_pci(E) ahci(E) ptp(E) sdhci(E) psmouse(E) libahci(E)
drm(E) wmi(E) pps_core(E) video(E) [last unloaded: cfg80211]
[70874.172405] CPU: 5 PID: 12739 Comm: wpa_supplicant Tainted: G
 W  OE   4.1.0-rc1master-2015-05-14-00-wl-ath+ #21
[70874.183090] Hardware name: Dell Inc. Latitude E6430/0H3MT5, BIOS
A13 09/02/2013
[70874.190389] task: 8800c88dd100 ti: 8800c9df4000 task.ti:
8800c9df4000
[70874.197863] RIP: 0010:[]  []
ath_tx_start+0x129/0x450 [ath9k]
[70874.206734] RSP: 0018:8800c9df75a8  EFLAGS: 00010216
[70874.212037] RAX:  RBX: 8800cabc93e0 RCX: 0038
[70874.219164] RDX: 880222846988 RSI: 8800cabca6f0 RDI: 
[70874.226290] RBP: 8800c9df7628 R08:  R09: 
[70874.233414] R10: 88020a2a4d44 R11:  R12: 8802228453b8
[70874.240541] R13: 8800c9df7658 R14: 8800c9ae6000 R15: 880222846ce8
[70874.247667] FS:  7fe30e448740() GS:88022e34()
knlGS:
[70874.255747] CS:  0010 DS:  ES:  CR0: 80050033
[70874.261485] CR2:  CR3: b7529000 CR4: 001407e0
[70874.268610] Stack:
[70874.270616]  8800c9df7698 8800 88020a2a4d44

[70874.278042]  8800cabca710  8802228468b0
8800cabca6f0
[70874.285465]   880209bb1700 8800c9df7638
8800ca9a4018
[70874.292894] Call Trace:
[70874.295336]  [] ath9k_tx+0xaf/0x2b0 [ath9k]
[70874.301084]  [] ?
rate_control_get_rate+0x14a/0x150 [mac80211]
[70874.308478]  [] ieee80211_tx_frags+0x104/0x410 [mac80211]
[70874.315435]  [] __ieee80211_tx+0x7e/0x180 [mac80211]
[70874.321961]  [] ieee80211_tx+0xbe/0xf0 [mac80211]
[70874.328224]  [] ieee80211_xmit+0xa1/0x100 [mac80211]
[70874.334748]  []
__ieee80211_tx_skb_tid_band+0x6a/0x80 [mac80211]
[70874.342314]  [] ieee80211_send_auth+0x166/0x1d0 [mac80211]
[70874.349361]  [] ieee80211_probe_auth+0x138/0x3d0 [mac80211]
[70874.356493]  [] ieee80211_mgd_auth+0x295/0x310 [mac80211]
[70874.363452]  [] ieee80211_auth+0x18/0x20 [mac80211]
[70874.369894]  [] cfg80211_mlme_auth+0xf3/0x1c0 [cfg80211]
[70874.376761]  [] ? do_select+0x6d6/0x790
[70874.382155]  [] nl80211_authenticate+0x2ad/0x310 [cfg80211]
[70874.389283]  [] genl_family_rcv_msg+0x1a5/0x3d0
[70874.395368]  [] ? poll_select_copy_remaining+0x130/0x130
[70874.402233]  [] ? genl_family_rcv_msg+0x3d0/0x3d0
[70874.408491]  [] genl_rcv_msg+0x91/0xd0
[70874.413795]  [] netlink_rcv_skb+0xc1/0xe0
[70874.419359]  [] genl_rcv+0x2c/0x40
[70874.424315]  [] netlink_unicast+0xf6/0x200
[70874.429966]  [] netlink_sendmsg+0x414/0x670
[70874.435705]  [] sock_sendmsg+0x3d/0x50
[70874.441010]  [] ___sys_sendmsg+0x29e/0x2c0
[70874.446663]  [] ? fsnotify+0x306/0x490
[70874.451967]  [] ? SYSC_recvfrom+0xd4/0x160
[70874.457617]  [] __sys_sendmsg+0x42/0x80
[70874.463006]  [] SyS_sendmsg+0x12/0x20
[70874.468224]  [] system_call_fastpath+0x16/0x75
[70874.474222] Code: 84 bd 02 00 00 41 8b 86 9c 00 00 00 83 e0 0f 48
8d 0c c5 00 00 00 00 48 c1 e0 07 48 29 c8 4c 8d 7c 02 18 49 8b 47 48
49 8b 75 00 <48> 39 30 0f 85 fa 02 00 00 41 f6 46 28 08 74 08 49 8b 47
48 c6
[70874.493638] RIP  [] ath_tx_start+0x129/0x450 [ath9k]
[70874.500166]  RSP 
[70874.503648] CR2: 
[70874.511427] ---[ end trace abdb98269f393a51 ]---
[70874.516037] Kernel panic - not syncing: Fatal exception in interrupt
[70874.522420] Kernel Offset: disabled
[

[ath9k-devel] [RFC] ath9k: allow to receive probe request when offchannel

2015-06-09 Thread Janusz Dziedzic
This fix problem that p2p group negotiation didn't work
correctly when chanctx used, because we didn't receive
probe requests when offchannel and use_chanctx=1

Signed-off-by: Janusz Dziedzic 
---
@Felix, Sujith could you review? I am not sure I put this in correct place.

 drivers/net/wireless/ath/ath9k/channel.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 2066650..6301d44 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1157,6 +1157,7 @@ static bool ath_chanctx_defer_switch(struct ath_softc *sc)
 static void ath_offchannel_channel_change(struct ath_softc *sc)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+   u32 rfilt;
 
ath_dbg(common, CHAN_CTX, "%s: offchannel state: %s\n",
__func__, offchannel_state_string(sc->offchannel.state));
@@ -1179,6 +1180,11 @@ static void ath_offchannel_channel_change(struct 
ath_softc *sc)
ath_scan_complete(sc, false);
break;
case ATH_OFFCHANNEL_ROC_START:
+   /* Allow to receive probe requests */
+   rfilt = ath_calcrxfilter(sc);
+   rfilt |= ATH9K_RX_FILTER_PROBEREQ;
+   ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
+
if (sc->cur_chan != &sc->offchannel.chan)
break;
 
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-09 Thread Janusz Dziedzic
Add p2p dev support when ath9k loaded with
use_chanctx=1. This will fix problem, when first
interface is an AP and next we would like to run
p2p_find. Before p2p scan failed.

Signed-off-by: Janusz Dziedzic 
---
@Felix, Sujith please review. I am not sure if didn't miss some
case for NL80211_IFTYPE_P2P_DEVICE (special handling required?).

 drivers/net/wireless/ath/ath9k/init.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index f8d11ef..7da1a17 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -736,13 +736,14 @@ static const struct ieee80211_iface_limit 
if_limits_multi[] = {
 BIT(NL80211_IFTYPE_P2P_CLIENT) |
 BIT(NL80211_IFTYPE_P2P_GO) },
{ .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+   { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) },
 };
 
 static const struct ieee80211_iface_combination if_comb_multi[] = {
{
.limits = if_limits_multi,
.n_limits = ARRAY_SIZE(if_limits_multi),
-   .max_interfaces = 2,
+   .max_interfaces = 3,
.num_different_channels = 2,
.beacon_int_infra_match = true,
},
@@ -855,6 +856,9 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct 
ieee80211_hw *hw)
BIT(NL80211_IFTYPE_MESH_POINT) |
BIT(NL80211_IFTYPE_WDS);
 
+   if (ath9k_is_chanctx_enabled())
+   hw->wiphy->interface_modes |= 
BIT(NL80211_IFTYPE_P2P_DEVICE);
+
hw->wiphy->iface_combinations = if_comb;
hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
}
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-15 Thread Janusz Dziedzic
On 15 June 2015 at 12:33, Sujith Manoharan  wrote:
> Janusz Dziedzic wrote:
>> Add p2p dev support when ath9k loaded with
>> use_chanctx=1. This will fix problem, when first
>> interface is an AP and next we would like to run
>> p2p_find. Before p2p scan failed.
>>
>> Signed-off-by: Janusz Dziedzic 
>> ---
>> @Felix, Sujith please review. I am not sure if didn't miss some
>> case for NL80211_IFTYPE_P2P_DEVICE (special handling required?).
>
> At least the callbacks for adding/removing interfaces need
> to be handled ?
>
Strange, but I didn't hit any problem yet with my simple patch.

> But, can you describe the sequence of commands used that
> resulted in this issue ?
>
1. load ath9k with use_chanctx=1
2. run wpa_supplicant using wlan0
3. connect wlan0 to AP
4. when we are connected, run p2p_find form wpa_cli
5. scan will failed with Operation not supported (even I will
force-ap-scan, while chanctx version using hw_scan callback ...)
6. p2p_find will fail

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: allow to receive probe request when offchannel

2015-06-15 Thread Janusz Dziedzic
adding Sujith correct mail

On 10 June 2015 at 07:03, Janusz Dziedzic  wrote:
> This fix problem that p2p group negotiation didn't work
> correctly when chanctx used, because we didn't receive
> probe requests when offchannel and use_chanctx=1
>
> Signed-off-by: Janusz Dziedzic 
> ---
> @Felix, Sujith could you review? I am not sure I put this in correct place.
>
>  drivers/net/wireless/ath/ath9k/channel.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
> b/drivers/net/wireless/ath/ath9k/channel.c
> index 2066650..6301d44 100644
> --- a/drivers/net/wireless/ath/ath9k/channel.c
> +++ b/drivers/net/wireless/ath/ath9k/channel.c
> @@ -1157,6 +1157,7 @@ static bool ath_chanctx_defer_switch(struct ath_softc 
> *sc)
>  static void ath_offchannel_channel_change(struct ath_softc *sc)
>  {
> struct ath_common *common = ath9k_hw_common(sc->sc_ah);
> +   u32 rfilt;
>
> ath_dbg(common, CHAN_CTX, "%s: offchannel state: %s\n",
> __func__, offchannel_state_string(sc->offchannel.state));
> @@ -1179,6 +1180,11 @@ static void ath_offchannel_channel_change(struct 
> ath_softc *sc)
> ath_scan_complete(sc, false);
> break;
> case ATH_OFFCHANNEL_ROC_START:
> +   /* Allow to receive probe requests */
> +   rfilt = ath_calcrxfilter(sc);
> +   rfilt |= ATH9K_RX_FILTER_PROBEREQ;
> +   ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
> +
> if (sc->cur_chan != &sc->offchannel.chan)
> break;
>
> --
> 1.9.1
>
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-15 Thread Janusz Dziedzic
On 15 June 2015 at 13:38, Janusz Dziedzic  wrote:
> On 15 June 2015 at 12:33, Sujith Manoharan  wrote:
>> Janusz Dziedzic wrote:
>>> Add p2p dev support when ath9k loaded with
>>> use_chanctx=1. This will fix problem, when first
>>> interface is an AP and next we would like to run
>>> p2p_find. Before p2p scan failed.
>>>
>>> Signed-off-by: Janusz Dziedzic 
>>> ---
>>> @Felix, Sujith please review. I am not sure if didn't miss some
>>> case for NL80211_IFTYPE_P2P_DEVICE (special handling required?).
>>
>> At least the callbacks for adding/removing interfaces need
>> to be handled ?
>>
> Strange, but I didn't hit any problem yet with my simple patch.
>
>> But, can you describe the sequence of commands used that
>> resulted in this issue ?
>>
> 1. load ath9k with use_chanctx=1
> 2. run wpa_supplicant using wlan0
> 3. connect wlan0 to AP
3. setup AP using wlan0
> 4. run p2p_find form wpa_cli
> 5. scan will failed with Operation not supported (even I will
> force-ap-scan, while chanctx version using hw_scan callback ...)
> 6. p2p_find will fail
>
> BR
> Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [RFC] ath9k: advertise p2p dev support when chanctx

2015-06-15 Thread Janusz Dziedzic
On 16 June 2015 at 03:25, Sujith Manoharan  wrote:
> Arend van Spriel wrote:
>> The p2p-device is designed to be used for p2p discovery and p2p action
>> frame exchange. It make it easier for driver and/or firmware to
>> determine if user-space request is p2p related or not. However, in
>> discussions with Jouni I got the impression that ath (or qca) firmware
>> and/or drivers did not need this design. Not sure if that claim is
>> unaffected by the "use_chanctx=1" parameter.
>
> Thanks for the explanation.
>
> I don't think advertising support for p2p-device is required for
> ath9k. P2P discovery works properly with the normal station/ap interface
> types and the 'use_chanctx' modparam simply enables multiple channel
> contexts.
>
Works except case I described.
p2p_find is combination of scan and ROC, and scan don't work when we
have configured AP from wpa_supplicant.
In case of adding p2p-device AP + P2P_FIND works perfectly, also AP +
P2P_CLIENT/P2P_GO works OK when use_chanctx.

Other fix I can image is change wpa_supplicant and add
NL80211_SCAN_FLAG_AP to p2p_find, and set in ath9k driver
wiphy->features |= NL80211_FEATURE_AP_SCAN;

NL80211_FEATURE_AP_SCAN is not set when use_chanctx=1

I am not sure which is better. First one required only fix in ath9k,
second one also required changes in wpa_supplicant.

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/3] ath9k: make rxfilter per HW

2015-06-22 Thread Janusz Dziedzic
mac80211 configure rxfilter per HW,
so we don't need this per channel.

This fix problem when chanctx used and ath9k
allocate new internal ath_chanctx (eg. when
offchannel) and we loose rxfilter configuration.

Eg. when p2p_find (with use_chanctx=1), during
remain on channel, driver create new ath_chanctx
with incorrect rxfilter. Then we didn't receive
probe requests and fail p2p_find.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h |  3 ++-
 drivers/net/wireless/ath/ath9k/main.c  |  2 +-
 drivers/net/wireless/ath/ath9k/recv.c  | 12 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index a7a81b3..030fd0f 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -356,7 +356,6 @@ struct ath_chanctx {
 
short nvifs;
short nvifs_assigned;
-   unsigned int rxfilter;
 };
 
 enum ath_chanctx_event {
@@ -1001,8 +1000,10 @@ struct ath_softc {
struct cfg80211_chan_def cur_chandef;
struct ath_chanctx chanctx[ATH9K_NUM_CHANCTX];
struct ath_chanctx *cur_chan;
+   unsigned int rxfilter;
spinlock_t chan_lock;
 
+
 #ifdef CONFIG_MAC80211_LEDS
bool led_registered;
char led_name[32];
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index d285e3a..945f002 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1463,7 +1463,7 @@ static void ath9k_configure_filter(struct ieee80211_hw 
*hw,
*total_flags &= SUPPORTED_FILTERS;
 
spin_lock_bh(&sc->chan_lock);
-   sc->cur_chan->rxfilter = *total_flags;
+   sc->rxfilter = *total_flags;
spin_unlock_bh(&sc->chan_lock);
 
ath9k_ps_wakeup(sc);
diff --git a/drivers/net/wireless/ath/ath9k/recv.c 
b/drivers/net/wireless/ath/ath9k/recv.c
index 6c75fb1..5f72c65 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -389,31 +389,31 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 
spin_lock_bh(&sc->chan_lock);
 
-   if (sc->cur_chan->rxfilter & FIF_PROBE_REQ)
+   if (sc->rxfilter & FIF_PROBE_REQ)
rfilt |= ATH9K_RX_FILTER_PROBEREQ;
 
if (sc->sc_ah->is_monitoring)
rfilt |= ATH9K_RX_FILTER_PROM;
 
-   if ((sc->cur_chan->rxfilter & FIF_CONTROL) ||
+   if ((sc->rxfilter & FIF_CONTROL) ||
sc->sc_ah->dynack.enabled)
rfilt |= ATH9K_RX_FILTER_CONTROL;
 
if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) &&
(sc->cur_chan->nvifs <= 1) &&
-   !(sc->cur_chan->rxfilter & FIF_BCN_PRBRESP_PROMISC))
+   !(sc->rxfilter & FIF_BCN_PRBRESP_PROMISC))
rfilt |= ATH9K_RX_FILTER_MYBEACON;
else
rfilt |= ATH9K_RX_FILTER_BEACON;
 
if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
-   (sc->cur_chan->rxfilter & FIF_PSPOLL))
+   (sc->rxfilter & FIF_PSPOLL))
rfilt |= ATH9K_RX_FILTER_PSPOLL;
 
if (sc->cur_chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
rfilt |= ATH9K_RX_FILTER_COMP_BAR;
 
-   if (sc->cur_chan->nvifs > 1 || (sc->cur_chan->rxfilter & 
FIF_OTHER_BSS)) {
+   if (sc->cur_chan->nvifs > 1 || (sc->rxfilter & FIF_OTHER_BSS)) {
/* This is needed for older chips */
if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160)
rfilt |= ATH9K_RX_FILTER_PROM;
@@ -878,7 +878,7 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
 */
spin_lock_bh(&sc->chan_lock);
if (!ath9k_cmn_rx_accept(common, hdr, rx_status, rx_stats, 
decrypt_error,
-sc->cur_chan->rxfilter)) {
+sc->rxfilter)) {
spin_unlock_bh(&sc->chan_lock);
return -EINVAL;
}
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 0/3] ath9k: P2P patches when chanctx used

2015-06-22 Thread Janusz Dziedzic
Patches for problems I hit during P2P tests when
multichannel used (driver loaded with use_chanctx=1).

Janusz Dziedzic (3):
  ath9k: handle RoC abort correctly
  ath9k: make rxfilter per HW
  ath9k: advertise p2p dev support when chanctx

 drivers/net/wireless/ath/ath9k/ath9k.h   |  3 ++-
 drivers/net/wireless/ath/ath9k/channel.c |  3 ++-
 drivers/net/wireless/ath/ath9k/init.c|  6 +-
 drivers/net/wireless/ath/ath9k/main.c|  2 +-
 drivers/net/wireless/ath/ath9k/recv.c| 12 ++--
 5 files changed, 16 insertions(+), 10 deletions(-)

-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 3/3] ath9k: advertise p2p dev support when chanctx

2015-06-22 Thread Janusz Dziedzic
Advertise p2p device support when ath9k loaded with
use_chanctx=1.

This will fix problem, when first interface is an AP
and next we would like to run p2p_find.
Before p2p find (scan phase) failed with EOPNOTSUPP.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/init.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index f8d11ef..7da1a17 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -736,13 +736,14 @@ static const struct ieee80211_iface_limit 
if_limits_multi[] = {
 BIT(NL80211_IFTYPE_P2P_CLIENT) |
 BIT(NL80211_IFTYPE_P2P_GO) },
{ .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+   { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) },
 };
 
 static const struct ieee80211_iface_combination if_comb_multi[] = {
{
.limits = if_limits_multi,
.n_limits = ARRAY_SIZE(if_limits_multi),
-   .max_interfaces = 2,
+   .max_interfaces = 3,
.num_different_channels = 2,
.beacon_int_infra_match = true,
},
@@ -855,6 +856,9 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct 
ieee80211_hw *hw)
BIT(NL80211_IFTYPE_MESH_POINT) |
BIT(NL80211_IFTYPE_WDS);
 
+   if (ath9k_is_chanctx_enabled())
+   hw->wiphy->interface_modes |= 
BIT(NL80211_IFTYPE_P2P_DEVICE);
+
hw->wiphy->iface_combinations = if_comb;
hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
}
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/3] ath9k: handle RoC abort correctly

2015-06-22 Thread Janusz Dziedzic
In case we will get ROC abort we should not call
ieee80211_remain_on_channel_expired().

In other case I hit such warning on MIPS and
p2p negotiation failed (tested with use_chanctx=1).

ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506632
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: Stopping current chanctx: 2412
ath: phy0: Flush timeout: 200
ath: phy0: ath_chanctx_set_next: Set channel 2412 MHz
ath: phy0: Set channel: 2412 MHz width: 0
ath: phy0: Reset to 2412 MHz, HT40: 0 fastcc: 0
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_TSF_TIMER, state: 
ATH_CHANCTX_STATE_IDLE
ath: phy0: ath_offchannel_channel_change: offchannel state: 
ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
ATH_CHANCTX_STATE_IDLE
ath: phy0: Cancel RoC
ath: phy0: RoC aborted
ath: phy0: RoC request on vif: 00:03:7f:4e:a0:cd, type: 1 duration: 500
ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506705
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: ath_offchannel_channel_change: offchannel state: 
ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
ATH_CHANCTX_STATE_IDLE
[ cut here ]
WARNING: CPU: 0 PID: 3312 at drivers/net/wireless/ath/ath9k/main.c:2319
Modules linked in: ath9k ath9k_common ath9k_hw ath mac80211 cfg80211

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 2066650..e211325 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -926,7 +926,8 @@ void ath_roc_complete(struct ath_softc *sc, bool abort)
 
sc->offchannel.roc_vif = NULL;
sc->offchannel.roc_chan = NULL;
-   ieee80211_remain_on_channel_expired(sc->hw);
+   if (!abort)
+   ieee80211_remain_on_channel_expired(sc->hw);
ath_offchannel_next(sc);
ath9k_ps_restore(sc);
 }
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH 1/3] ath9k: handle RoC abort correctly

2015-06-23 Thread Janusz Dziedzic
On 22 June 2015 at 16:01, Krishna Chaitanya  wrote:
> On Mon, Jun 22, 2015 at 6:32 PM, Michal Kazior  
> wrote:
>> On 22 June 2015 at 13:56, Krishna Chaitanya  wrote:
>>> On Mon, Jun 22, 2015 at 5:13 PM, Janusz Dziedzic
>>>  wrote:
>>>> In case we will get ROC abort we should not call
>>>> ieee80211_remain_on_channel_expired().
>>>>
>>>> In other case I hit such warning on MIPS and
>>>> p2p negotiation failed (tested with use_chanctx=1).
>>>>
>>>> ath: phy0: Starting RoC period
>>>> ath: phy0: Channel definition created: 2412 MHz
>>>> ath: phy0: Assigned next_chan to 2412 MHz
>>>> ath: phy0: Offchannel duration for chan 2412 MHz : 506632
>>>> ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
>>>> ath: phy0: Stopping current chanctx: 2412
>>>> ath: phy0: Flush timeout: 200
>>>> ath: phy0: ath_chanctx_set_next: Set channel 2412 MHz
>>>> ath: phy0: Set channel: 2412 MHz width: 0
>>>> ath: phy0: Reset to 2412 MHz, HT40: 0 fastcc: 0
>>>> ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_TSF_TIMER, state: 
>>>> ATH_CHANCTX_STATE_IDLE
>>>> ath: phy0: ath_offchannel_channel_change: offchannel state: 
>>>> ATH_OFFCHANNEL_ROC_START
>>>> ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
>>>> ATH_CHANCTX_STATE_IDLE
>>>> ath: phy0: Cancel RoC
>>>> ath: phy0: RoC aborted
>>>> ath: phy0: RoC request on vif: 00:03:7f:4e:a0:cd, type: 1 duration: 500
>>>> ath: phy0: Starting RoC period
>>>> ath: phy0: Channel definition created: 2412 MHz
>>>> ath: phy0: Assigned next_chan to 2412 MHz
>>>> ath: phy0: Offchannel duration for chan 2412 MHz : 506705
>>>> ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
>>>> ath: phy0: ath_offchannel_channel_change: offchannel state: 
>>>> ATH_OFFCHANNEL_ROC_START
>>>> ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
>>>> ATH_CHANCTX_STATE_IDLE
>>>> [ cut here ]
>>>> WARNING: CPU: 0 PID: 3312 at drivers/net/wireless/ath/ath9k/main.c:2319
>>>> Modules linked in: ath9k ath9k_common ath9k_hw ath mac80211 cfg80211
>>>>
>>>> Signed-off-by: Janusz Dziedzic 
>>>> ---
>>>>  drivers/net/wireless/ath/ath9k/channel.c | 3 ++-
>>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
>>>> b/drivers/net/wireless/ath/ath9k/channel.c
>>>> index 2066650..e211325 100644
>>>> --- a/drivers/net/wireless/ath/ath9k/channel.c
>>>> +++ b/drivers/net/wireless/ath/ath9k/channel.c
>>>> @@ -926,7 +926,8 @@ void ath_roc_complete(struct ath_softc *sc, bool abort)
>>>>
>>>> sc->offchannel.roc_vif = NULL;
>>>> sc->offchannel.roc_chan = NULL;
>>>> -   ieee80211_remain_on_channel_expired(sc->hw);
>>>> +   if (!abort)
>>>> +   ieee80211_remain_on_channel_expired(sc->hw);
>>>> ath_offchannel_next(sc);
>>>> ath9k_ps_restore(sc);
>>>>  }
>>> If HW aborts RoC in middle, should not we inform mac80211
>>> that RoC is expired?
>>
>> Good point. The ath_roc_complete() can be called with abort=true from
>> ath9k_cancel_pending_offchannel() as well. I guess ath_roc_complete()
>> needs a "reason" argument (instead of "abort") with: expired, aborted,
>> cancelled values. ieee80211_remain_on_channel_expired() should be
>> called whenever reason != cancelled.
> Agree, make sense.
>> By the way - is ath_roc_complete() lock protected properly? It looks
>> like it isn't from a quick glance. Neither sdata lock nor local->mtx
>> can be implied in all contexts and sc->mutex isn't always held while
>> it's called, hmm.. or am I missing something?
>>
>>> Also the we are clearing roc_vif independent of abort, so the warning
>>> indicates that roc_complete has not come from FW, may be we should
>>> understand that first?
>>
>> There's no FW in ath9k.
>>
>> The problem is the following sequence:
>>  1. mac80211 requests roc A
>>  2. mac80211 cancels roc A
>>a. ath9k calls expired() and hw_roc_done work is scheduled
>>  3. mac80211 requests roc B
>>  4. mac80211 starts to process the scheduled hw_roc_done
>>  5. mac80211 thinks roc B has expired
>>  6. mac80211 requests roc C
>>  7. ath9k WARN_ON is hit
>>
>> There's a race between (3) and (4). Depending on circumstances (3) and
>> (4) may be reordered so the current code doesn't fail all the time.
> Ok i understand, but if we get roc_complete for B before 6, then it works
> fine at least at ath9k level, C will be unblocked.
>
> Anyways, handling the cancel case should resolve it along with proper locking.

Thanks for comments, will send v2

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/3 v2] ath9k: handle RoC cancel correctly

2015-06-23 Thread Janusz Dziedzic
In case we will get ROC cancel from mac80211 we
should not call ieee80211_remain_on_channel_expired().

In other case I hit such warning on MIPS and
p2p negotiation failed (tested with use_chanctx=1).

ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506632
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: Stopping current chanctx: 2412
ath: phy0: Flush timeout: 200
ath: phy0: ath_chanctx_set_next: Set channel 2412 MHz
ath: phy0: Set channel: 2412 MHz width: 0
ath: phy0: Reset to 2412 MHz, HT40: 0 fastcc: 0
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_TSF_TIMER, state: 
ATH_CHANCTX_STATE_IDLE
ath: phy0: ath_offchannel_channel_change: offchannel state: 
ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
ATH_CHANCTX_STATE_IDLE
ath: phy0: Cancel RoC
ath: phy0: RoC aborted
ath: phy0: RoC request on vif: 00:03:7f:4e:a0:cd, type: 1 duration: 500
ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506705
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: ath_offchannel_channel_change: offchannel state: 
ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
ATH_CHANCTX_STATE_IDLE
[ cut here ]
WARNING: CPU: 0 PID: 3312 at drivers/net/wireless/ath/ath9k/main.c:2319
Modules linked in: ath9k ath9k_common ath9k_hw ath mac80211 cfg80211

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  8 +++-
 drivers/net/wireless/ath/ath9k/channel.c | 23 ---
 drivers/net/wireless/ath/ath9k/main.c|  4 ++--
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index 030fd0f..7d41c8f 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -409,6 +409,12 @@ enum ath_offchannel_state {
ATH_OFFCHANNEL_ROC_DONE,
 };
 
+enum ath_roc_complete_reason {
+   ATH_ROC_COMPLETE_EXPIRE,
+   ATH_ROC_COMPLETE_ABORT,
+   ATH_ROC_COMPLETE_CANCEL,
+};
+
 struct ath_offchannel {
struct ath_chanctx chan;
struct timer_list timer;
@@ -470,7 +476,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
 void ath_chanctx_set_next(struct ath_softc *sc, bool force);
 void ath_offchannel_next(struct ath_softc *sc);
 void ath_scan_complete(struct ath_softc *sc, bool abort);
-void ath_roc_complete(struct ath_softc *sc, bool abort);
+void ath_roc_complete(struct ath_softc *sc, enum ath_roc_complete_reason 
reason);
 struct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc);
 
 #else
diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 2066650..35cfcd0 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -915,18 +915,27 @@ void ath_offchannel_next(struct ath_softc *sc)
}
 }
 
-void ath_roc_complete(struct ath_softc *sc, bool abort)
+void ath_roc_complete(struct ath_softc *sc, enum ath_roc_complete_reason 
reason)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 
-   if (abort)
+   sc->offchannel.roc_vif = NULL;
+   sc->offchannel.roc_chan = NULL;
+
+   switch(reason) {
+   case ATH_ROC_COMPLETE_ABORT:
ath_dbg(common, CHAN_CTX, "RoC aborted\n");
-   else
+   ieee80211_remain_on_channel_expired(sc->hw);
+   break;
+   case ATH_ROC_COMPLETE_EXPIRE:
ath_dbg(common, CHAN_CTX, "RoC expired\n");
+   ieee80211_remain_on_channel_expired(sc->hw);
+   break;
+   case ATH_ROC_COMPLETE_CANCEL:
+   ath_dbg(common, CHAN_CTX, "RoC canceled\n");
+   break;
+   }
 
-   sc->offchannel.roc_vif = NULL;
-   sc->offchannel.roc_chan = NULL;
-   ieee80211_remain_on_channel_expired(sc->hw);
ath_offchannel_next(sc);
ath9k_ps_restore(sc);
 }
@@ -1058,7 +1067,7 @@ static void ath_offchannel_timer(unsigned long data)
case ATH_OFFCHANNEL_ROC_START:
case ATH_OFFCHANNEL_ROC_WAIT:
sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE;
-   ath_roc_complete(sc, false);
+   ath_roc_complete(sc, ATH_ROC_COMPLETE_EXPIRE);
break;
default:
break;
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index 945f002..2277e09 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2244,7 +2244,7 @@ static v

[ath9k-devel] [PATCH 1/2] ath9k: setup rxfilter for all chanctx

2015-07-09 Thread Janusz Dziedzic
While mac80211 setup this per HW, set same
rxfilter configuration for all chanctx.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index b7b77e0..3de829f 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1459,13 +1459,15 @@ static void ath9k_configure_filter(struct ieee80211_hw 
*hw,
   u64 multicast)
 {
struct ath_softc *sc = hw->priv;
+   struct ath_chanctx *ctx;
u32 rfilt;
 
changed_flags &= SUPPORTED_FILTERS;
*total_flags &= SUPPORTED_FILTERS;
 
spin_lock_bh(&sc->chan_lock);
-   sc->cur_chan->rxfilter = *total_flags;
+   ath_for_each_chanctx(sc, ctx)
+   ctx->rxfilter = *total_flags;
spin_unlock_bh(&sc->chan_lock);
 
ath9k_ps_wakeup(sc);
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/2] ath9k: setup rxfilter when offchannel

2015-07-09 Thread Janusz Dziedzic
Setup rxfiler correctly for offchannel ctx.

This fix problem we didn't configure rxfilter, next
didn't receive probe requests and next failed
p2p_find. This was seen when ath9k loaded with
use_chanctx=1

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index 3de829f..b45084d 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1468,6 +1468,7 @@ static void ath9k_configure_filter(struct ieee80211_hw 
*hw,
spin_lock_bh(&sc->chan_lock);
ath_for_each_chanctx(sc, ctx)
ctx->rxfilter = *total_flags;
+   sc->offchannel.chan.rxfilter = *total_flags;
spin_unlock_bh(&sc->chan_lock);
 
ath9k_ps_wakeup(sc);
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ath9k: multicast don't work when: two STA (sta + p2p_client) + hwcrypt

2015-07-12 Thread Janusz Dziedzic
On 18 June 2015 at 10:06, Janusz Dziedzic  wrote:
> STA iface:
> ath: phy0: Set HW Key 0 (pairwise) vif: 2c:d0:5a:d3:f1:e9 sta:
> f4:b7:e2:38:83:f3 - idx: 4
> ath: phy0: Set HW Key 0 (group) vif: 2c:d0:5a:d3:f1:e9 sta:
> (null) - idx: 1
>
> P2P_CLIENT iface:
> ath: phy0: Set HW Key 0 (pairwise) vif: 2e:d0:5a:d3:f1:e9 sta:
> 0c:8b:fd:1e:58:9f - idx: 68
> ath: phy0: Set HW Key 0 (group) vif: 2e:d0:5a:d3:f1:e9 sta:
> (null) - idx: 1
>
> Seems we overwrite multicast hw key - both idx = 1
>
> 1) First patch I made:
>
> diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c
> index 1816b4e..b15873b 100644
> --- a/drivers/net/wireless/ath/key.c
> +++ b/drivers/net/wireless/ath/key.c
> @@ -507,6 +507,15 @@ int ath_key_config(struct ath_common *common,
>
> if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
> switch (vif->type) {
> +   case NL80211_IFTYPE_STATION:
> +   idx = key->keyidx;
> +   if (vif->bss_conf.bssid) {
> +   ether_addr_copy(gmac, bssid);
> +   gmac[0] |= 0x01;
> +   mac = gmac;
> +   idx =
> ath_reserve_key_cache_slot(common, key->cipher);
> +   }
> +   break;
> case NL80211_IFTYPE_AP:
> memcpy(gmac, vif->addr, ETH_ALEN);
> gmac[0] |= 0x01;
>
> Multicast works fine for STA/P2P_CLIENT but multicast rekeying don't
> work correctly, while we have 2 multicast keys installed for the same
> bssid (eg. idx 6, 68) after rekey. Seem hw choose always key with
> lowest idx - hw decrypt mcast packects correctly every second rekey
> :-)
>
> BTW, this needs attention to be sure hw decrypt frames correctly - I
> am checking RX_FLAG_DECRYPTED flag, while often HW send crypted
> packets and mac80211 decrypt them correctly (every second rekey for
> example). So, some mixture of hwcrypt and swcrypt is seen :)
>
> 2) works perfectly when ath9k loaded with nohwcrypt=1
>
> Any ideas how to solve this correctly (is it possible with hwcrypt at all)?
>
> BR
> Janusz

Adding ath9k-devel@lists.ath9k.org
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Wi-Fi Direct multi-role support in ath9k

2015-07-14 Thread Janusz Dziedzic
On 14 July 2015 at 16:31, Adrien Decostre  wrote:
> Dear all,
>
>
>
> I am experimenting a bit with Wi-Fi Direct on top of the ath9k driver and I
> am wondering if it is possible to operate at the same moment, on the same
> IEEE802.11n module, a software AP for an infrastructure Wi-Fi network (e.g.
> by using hostapd) and a soft AP for a Wi-Fi Direct link.
>
> As far as I understand, for this, the driver needs to support the
> “multi-role” feature. Is it right?
>
> Is this feature already supported by the ath9k driver?
>
You should load driver with use_chanctx=1 (before compile with
CONFIG_ATH9K_CHANNEL_CONTEXT)
I tested AP and P2P_GO on different channels using AR9462.

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v3 4/4] ath9k: setup rxfilter when offchannel

2015-07-21 Thread Janusz Dziedzic
Setup rxfiler correctly for offchannel ctx.

This fix problem we didn't configure rxfilter, next
didn't receive probe requests and next failed
p2p_find. This was seen when ath9k loaded with
use_chanctx=1

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index 3de829f..c27143b 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1468,6 +1468,9 @@ static void ath9k_configure_filter(struct ieee80211_hw 
*hw,
spin_lock_bh(&sc->chan_lock);
ath_for_each_chanctx(sc, ctx)
ctx->rxfilter = *total_flags;
+#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
+   sc->offchannel.chan.rxfilter = *total_flags;
+#endif
spin_unlock_bh(&sc->chan_lock);
 
ath9k_ps_wakeup(sc);
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v3 3/4] ath9k: setup rxfilter for all chanctx

2015-07-21 Thread Janusz Dziedzic
While mac80211 setup this per HW, set same
rxfilter configuration for all chanctx.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index b7b77e0..3de829f 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1459,13 +1459,15 @@ static void ath9k_configure_filter(struct ieee80211_hw 
*hw,
   u64 multicast)
 {
struct ath_softc *sc = hw->priv;
+   struct ath_chanctx *ctx;
u32 rfilt;
 
changed_flags &= SUPPORTED_FILTERS;
*total_flags &= SUPPORTED_FILTERS;
 
spin_lock_bh(&sc->chan_lock);
-   sc->cur_chan->rxfilter = *total_flags;
+   ath_for_each_chanctx(sc, ctx)
+   ctx->rxfilter = *total_flags;
spin_unlock_bh(&sc->chan_lock);
 
ath9k_ps_wakeup(sc);
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v3 1/4] ath9k: advertise p2p dev support when chanctx

2015-07-21 Thread Janusz Dziedzic
Advertise p2p device support when ath9k loaded with
use_chanctx=1.

This will fix problem, when first interface is an AP
and next we would like to run p2p_find.
Before p2p find (scan phase) failed with EOPNOTSUPP.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/init.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index eff0e53..89a457d 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -736,13 +736,14 @@ static const struct ieee80211_iface_limit 
if_limits_multi[] = {
 BIT(NL80211_IFTYPE_P2P_CLIENT) |
 BIT(NL80211_IFTYPE_P2P_GO) },
{ .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+   { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) },
 };
 
 static const struct ieee80211_iface_combination if_comb_multi[] = {
{
.limits = if_limits_multi,
.n_limits = ARRAY_SIZE(if_limits_multi),
-   .max_interfaces = 2,
+   .max_interfaces = 3,
.num_different_channels = 2,
.beacon_int_infra_match = true,
},
@@ -855,6 +856,10 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, 
struct ieee80211_hw *hw)
BIT(NL80211_IFTYPE_MESH_POINT) |
BIT(NL80211_IFTYPE_WDS);
 
+   if (ath9k_is_chanctx_enabled())
+   hw->wiphy->interface_modes |=
+   BIT(NL80211_IFTYPE_P2P_DEVICE);
+
hw->wiphy->iface_combinations = if_comb;
hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
}
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v3 2/4] ath9k: handle RoC cancel correctly

2015-07-21 Thread Janusz Dziedzic
In case we will get ROC cancel from mac80211 we
should not call ieee80211_remain_on_channel_expired().

In other case I hit such warning on MIPS and
p2p negotiation failed (tested with use_chanctx=1).

ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506632
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: Stopping current chanctx: 2412
ath: phy0: Flush timeout: 200
ath: phy0: ath_chanctx_set_next: Set channel 2412 MHz
ath: phy0: Set channel: 2412 MHz width: 0
ath: phy0: Reset to 2412 MHz, HT40: 0 fastcc: 0
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_TSF_TIMER, state: 
ATH_CHANCTX_STATE_IDLE
ath: phy0: ath_offchannel_channel_change: offchannel state: 
ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
ATH_CHANCTX_STATE_IDLE
ath: phy0: Cancel RoC
ath: phy0: RoC aborted
ath: phy0: RoC request on vif: 00:03:7f:4e:a0:cd, type: 1 duration: 500
ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506705
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: ath_offchannel_channel_change: offchannel state: 
ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: 
ATH_CHANCTX_STATE_IDLE
[ cut here ]
WARNING: CPU: 0 PID: 3312 at drivers/net/wireless/ath/ath9k/main.c:2319
Modules linked in: ath9k ath9k_common ath9k_hw ath mac80211 cfg80211

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  9 -
 drivers/net/wireless/ath/ath9k/channel.c | 23 ---
 drivers/net/wireless/ath/ath9k/main.c|  4 ++--
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index a7a81b3..db7a7b6 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -410,6 +410,12 @@ enum ath_offchannel_state {
ATH_OFFCHANNEL_ROC_DONE,
 };
 
+enum ath_roc_complete_reason {
+   ATH_ROC_COMPLETE_EXPIRE,
+   ATH_ROC_COMPLETE_ABORT,
+   ATH_ROC_COMPLETE_CANCEL,
+};
+
 struct ath_offchannel {
struct ath_chanctx chan;
struct timer_list timer;
@@ -471,7 +477,8 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
 void ath_chanctx_set_next(struct ath_softc *sc, bool force);
 void ath_offchannel_next(struct ath_softc *sc);
 void ath_scan_complete(struct ath_softc *sc, bool abort);
-void ath_roc_complete(struct ath_softc *sc, bool abort);
+void ath_roc_complete(struct ath_softc *sc,
+ enum ath_roc_complete_reason reason);
 struct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc);
 
 #else
diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 2066650..90f5773 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -915,18 +915,27 @@ void ath_offchannel_next(struct ath_softc *sc)
}
 }
 
-void ath_roc_complete(struct ath_softc *sc, bool abort)
+void ath_roc_complete(struct ath_softc *sc, enum ath_roc_complete_reason 
reason)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 
-   if (abort)
+   sc->offchannel.roc_vif = NULL;
+   sc->offchannel.roc_chan = NULL;
+
+   switch (reason) {
+   case ATH_ROC_COMPLETE_ABORT:
ath_dbg(common, CHAN_CTX, "RoC aborted\n");
-   else
+   ieee80211_remain_on_channel_expired(sc->hw);
+   break;
+   case ATH_ROC_COMPLETE_EXPIRE:
ath_dbg(common, CHAN_CTX, "RoC expired\n");
+   ieee80211_remain_on_channel_expired(sc->hw);
+   break;
+   case ATH_ROC_COMPLETE_CANCEL:
+   ath_dbg(common, CHAN_CTX, "RoC canceled\n");
+   break;
+   }
 
-   sc->offchannel.roc_vif = NULL;
-   sc->offchannel.roc_chan = NULL;
-   ieee80211_remain_on_channel_expired(sc->hw);
ath_offchannel_next(sc);
ath9k_ps_restore(sc);
 }
@@ -1058,7 +1067,7 @@ static void ath_offchannel_timer(unsigned long data)
case ATH_OFFCHANNEL_ROC_START:
case ATH_OFFCHANNEL_ROC_WAIT:
sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE;
-   ath_roc_complete(sc, false);
+   ath_roc_complete(sc, ATH_ROC_COMPLETE_EXPIRE);
break;
default:
break;
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index cfd45cb..b7b77e0 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2246,7 +2246,7 @@ stat

Re: [ath9k-devel] how to get frequency on AP mode

2015-07-21 Thread Janusz Dziedzic
On 22 July 2015 at 08:20, Joe Qiao  wrote:
> Dear experts,
>
>
>
> I’m running latest version of ath9k driver with AP mode. And usually get
> current frequency with ioctl SIOCGIWFREQ via monitor interface. After
> upgrade kernel, the monitor interface disappear. It lead me to never can get
> frequency at all.
>
>
>
> I checked the function of cfg80211_wext_giwfreq, which only support STATION,
> ADHOC and MONITOR mode to get frequency.
>
>
iw wlan0 info

Interface wlan0
ifindex 21
wdev 0x1
addr 2c:d0:5a:d3:f1:e9
ssid test_5G_5180_open
type AP
wiphy 0
channel 36 (5180 MHz), width: 20 MHz, center1: 5180 MHz

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 05/12] ath9k: use u32 when calculate tsf

2015-11-12 Thread Janusz Dziedzic
Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 5640e88..d86566b 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1405,7 +1405,7 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
-   s32 tsf, target_tsf;
+   u32 tsf, target_tsf;
 
if (!avp || !avp->noa.has_next_tsf)
return;
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 10/12] ath9k: MCC, add NOA also in case of an AP

2015-11-12 Thread Janusz Dziedzic
In case of MCC and AP interface, add also NOA attr
that will inform stations about absence of an AP.
There is a chance that some stations will handle
this NOA attr correctly and will know exactly when
AP is present/absent.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/beacon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/beacon.c 
b/drivers/net/wireless/ath/ath9k/beacon.c
index f50a6bc..5cf0cd7 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -148,7 +148,8 @@ static struct ath_buf *ath9k_beacon_generate(struct 
ieee80211_hw *hw,
 
ath_assign_seq(common, skb);
 
-   if (vif->p2p)
+   /* Always assign NOA attr when MCC enabled */
+   if (ath9k_is_chanctx_enabled())
ath9k_beacon_add_noa(sc, avp, skb);
 
bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 01/12] ath9k: add debug messages to aggr/chanctx funcs

2015-11-12 Thread Janusz Dziedzic
Add/extend debug messages when chanctx used.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 11 ---
 drivers/net/wireless/ath/ath9k/hw.c  |  8 
 drivers/net/wireless/ath/ath9k/xmit.c| 15 +++
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 90f5773..35802c9 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -403,7 +403,7 @@ static void ath_chanctx_offchannel_noa(struct ath_softc *sc,
avp->offchannel_duration = sc->sched.offchannel_duration;
 
ath_dbg(common, CHAN_CTX,
-   "offchannel noa_duration: %d, noa_start: %d, noa_index: %d\n",
+   "offchannel noa_duration: %d, noa_start: %u, noa_index: %d\n",
avp->offchannel_duration,
avp->offchannel_start,
avp->noa_index);
@@ -443,7 +443,7 @@ static void ath_chanctx_set_periodic_noa(struct ath_softc 
*sc,
avp->periodic_noa = true;
 
ath_dbg(common, CHAN_CTX,
-   "noa_duration: %d, noa_start: %d, noa_index: %d, periodic: 
%d\n",
+   "noa_duration: %d, noa_start: %u, noa_index: %d, periodic: 
%d\n",
avp->noa_duration,
avp->noa_start,
avp->noa_index,
@@ -464,7 +464,7 @@ static void ath_chanctx_set_oneshot_noa(struct ath_softc 
*sc,
avp->noa_duration = duration + sc->sched.channel_switch_time;
 
ath_dbg(common, CHAN_CTX,
-   "oneshot noa_duration: %d, noa_start: %d, noa_index: %d, 
periodic: %d\n",
+   "oneshot noa_duration: %d, noa_start: %u, noa_index: %d, 
periodic: %d\n",
avp->noa_duration,
avp->noa_start,
avp->noa_index,
@@ -1401,6 +1401,7 @@ void ath9k_chanctx_wake_queues(struct ath_softc *sc, 
struct ath_chanctx *ctx)
 
 static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif 
*avp)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
s32 tsf, target_tsf;
 
@@ -1418,6 +1419,10 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
if (target_tsf - tsf < ATH_P2P_PS_STOP_TIME)
target_tsf = tsf + ATH_P2P_PS_STOP_TIME;
 
+   ath_dbg(common, CHAN_CTX, "%s absent %d tsf 0x%08X next_tsf 0x%08X 
(%dms)\n",
+   __func__, avp->noa.absent, tsf, target_tsf,
+   (target_tsf - tsf) / 1000);
+
ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 
100);
 }
 
diff --git a/drivers/net/wireless/ath/ath9k/hw.c 
b/drivers/net/wireless/ath/ath9k/hw.c
index bdfff46..4af19e4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2299,10 +2299,10 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
else
nextTbtt = bs->bs_nexttbtt;
 
-   ath_dbg(common, BEACON, "next DTIM %d\n", bs->bs_nextdtim);
-   ath_dbg(common, BEACON, "next beacon %d\n", nextTbtt);
-   ath_dbg(common, BEACON, "beacon period %d\n", beaconintval);
-   ath_dbg(common, BEACON, "DTIM period %d\n", dtimperiod);
+   ath_dbg(common, BEACON, "next DTIM %u\n", bs->bs_nextdtim);
+   ath_dbg(common, BEACON, "next beacon %u\n", nextTbtt);
+   ath_dbg(common, BEACON, "beacon period %u\n", beaconintval);
+   ath_dbg(common, BEACON, "DTIM period %u\n", dtimperiod);
 
ENABLE_REGWRITE_BUFFER(ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
b/drivers/net/wireless/ath/ath9k/xmit.c
index 3e3dac3..26698a6 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1473,11 +1473,14 @@ static bool ath_tx_sched_aggr(struct ath_softc *sc, 
struct ath_txq *txq,
 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
  u16 tid, u16 *ssn)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_atx_tid *txtid;
struct ath_txq *txq;
struct ath_node *an;
u8 density;
 
+   ath_dbg(common, XMIT, "%s called\n", __func__);
+
an = (struct ath_node *)sta->drv_priv;
txtid = ATH_AN_2_TID(an, tid);
txq = txtid->txq;
@@ -1512,10 +1515,13 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct 
ieee80211_sta *sta,
 
 void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_node *an = (struct ath_node *)sta->drv_priv;
struct ath_atx_tid *txtid = ATH_AN_2_TI

[ath9k-devel] [PATCH 04/12] ath9k: P2P_CLIENT, send frames after 1ms AP/GO will aprear

2015-11-12 Thread Janusz Dziedzic
AP/GO will aprear after NOA, wait 1ms to be sure AP
could receive/answer this frames.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index dddaaea..5640e88 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1417,6 +1417,8 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
target_tsf = avp->noa.next_tsf;
if (!avp->noa.absent)
target_tsf -= ATH_P2P_PS_STOP_TIME;
+   else
+   target_tsf += ATH_P2P_PS_STOP_TIME;
 
if (target_tsf - tsf < ATH_P2P_PS_STOP_TIME)
target_tsf = tsf + ATH_P2P_PS_STOP_TIME;
@@ -1543,6 +1545,8 @@ void ath9k_p2p_ps_timer(void *priv)
tsf = ath9k_hw_gettsf32(sc->sc_ah);
if (!avp->noa.absent)
tsf += ATH_P2P_PS_STOP_TIME;
+   else
+   tsf -= ATH_P2P_PS_STOP_TIME;
 
if (!avp->noa.has_next_tsf ||
avp->noa.next_tsf - tsf > BIT(31))
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 09/12] ath9k: request NOA update when chanctx active

2015-11-12 Thread Janusz Dziedzic
Request NOA update when chanctx active, also in case
of STA.

Signed-off-by: Janusz Dziedzic 
---
This depends on:
[PATCH] mac80211: add new IEEE80211_VIF_GET_NOA_UPDATE flag

 drivers/net/wireless/ath/ath9k/channel.c | 2 +-
 drivers/net/wireless/ath/ath9k/main.c| 5 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index db49bc5..4320928 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1439,7 +1439,7 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, 
struct ieee80211_vif *vif)
if (!sc->p2p_ps_timer)
return;
 
-   if (vif->type != NL80211_IFTYPE_STATION || !vif->p2p)
+   if (vif->type != NL80211_IFTYPE_STATION)
return;
 
sc->p2p_ps_vif = avp;
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index d184e68..ab46a4d 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -974,7 +974,7 @@ static void ath9k_update_bssid_mask(struct ath_softc *sc,
if (ctx->nvifs_assigned != 1)
continue;
 
-   if (!avp->vif->p2p || !iter_data->has_hw_macaddr)
+   if (!iter_data->has_hw_macaddr)
continue;
 
ether_addr_copy(common->curbssid, avp->bssid);
@@ -1251,6 +1251,9 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
sc->cur_chan->nvifs++;
 
+   if (vif->type == NL80211_IFTYPE_STATION && ath9k_is_chanctx_enabled())
+   vif->driver_flags |= IEEE80211_VIF_GET_NOA_UPDATE;
+
if (ath9k_uses_beacons(vif->type))
ath9k_beacon_assign_slot(sc, vif);
 
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 11/12] ath9k: MCC add sta_ap_ratio module param

2015-11-12 Thread Janusz Dziedzic
In case of MCC we can setup STA/AP(GO) ratio.
Eg. setting sta_ap_ratio=80
STA will get 80% of time, while AP(GO) 20%.
Setup correct ctwindow.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  2 +
 drivers/net/wireless/ath/ath9k/channel.c | 69 +---
 drivers/net/wireless/ath/ath9k/hw.h  |  1 +
 drivers/net/wireless/ath/ath9k/init.c|  3 ++
 4 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index b42f4a9..4616229 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -37,6 +37,7 @@ extern int ath9k_modparam_nohwcrypt;
 extern int ath9k_led_blink;
 extern bool is_ath9k_unloaded;
 extern int ath9k_use_chanctx;
+extern int ath9k_sta_ap_ratio;
 
 /*/
 /* Descriptor Management */
@@ -335,6 +336,7 @@ struct ath_chanctx {
struct timespec tsf_ts;
u64 tsf_val;
u32 last_beacon;
+   u32 ctwindow;
 
int flush_timeout;
u16 txpower;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 4320928..b0d74f0 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -313,11 +313,21 @@ ath_chanctx_get_next(struct ath_softc *sc, struct 
ath_chanctx *ctx)
return &sc->chanctx[!idx];
 }
 
+static u32 get_ratio(u32 beacon_int)
+{
+   if (ath9k_sta_ap_ratio < 20 ||
+   ath9k_sta_ap_ratio > 80)
+   return beacon_int / 2;
+
+   return (beacon_int * ath9k_sta_ap_ratio) / 100;
+}
+
 static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_chanctx *prev, *cur;
struct timespec ts;
-   u32 cur_tsf, prev_tsf, beacon_int;
+   u32 cur_tsf, prev_tsf, beacon_int, diff;
s32 offset;
 
beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
@@ -344,7 +354,14 @@ static void ath_chanctx_adjust_tbtt_delta(struct ath_softc 
*sc)
if (offset < 0 || offset > 3 * beacon_int)
return;
 
-   offset = beacon_int / 2 - (offset % beacon_int);
+   diff = 2 * prev->ctwindow;
+   diff += sc->sched.channel_switch_time;
+   if (diff > beacon_int / 2)
+   diff = beacon_int / 2;
+
+   ath_dbg(common, CHAN_CTX, "Setup beacon interval offset %u ms\n",
+   diff / 1000);
+   offset = diff - (offset % beacon_int);
prev->tsf_val += offset;
 }
 
@@ -435,7 +452,7 @@ static void ath_chanctx_set_periodic_noa(struct ath_softc 
*sc,
sc->sched.channel_switch_time;
else
avp->noa_duration =
-   TU_TO_USEC(cur_conf->beacon_interval) / 2 +
+   TU_TO_USEC(get_ratio(cur_conf->beacon_interval)) +
sc->sched.channel_switch_time;
 
if (test_bit(ATH_OP_SCANNING, &common->op_flags) ||
@@ -481,7 +498,8 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
struct ath_beacon_config *cur_conf;
struct ath_vif *avp = NULL;
struct ath_chanctx *ctx;
-   u32 tsf_time;
+   u32 tsf_time, defer_time;
+   u32 beacon_resp_time = ah->config.sw_beacon_response_time;
u32 beacon_int;
 
if (vif)
@@ -565,10 +583,26 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
cur_conf = &sc->cur_chan->beacon;
beacon_int = TU_TO_USEC(cur_conf->beacon_interval);
 
-   /* defer channel switch by a quarter beacon interval */
-   tsf_time = sc->sched.next_tbtt + beacon_int / 4;
+   /* defer channel switch */
+   defer_time = beacon_int - get_ratio(beacon_int);
+   defer_time -= sc->sched.channel_switch_time;
+   defer_time /= 2;
+
+   if (defer_time < TU_TO_USEC(2 + beacon_resp_time)) {
+   defer_time *= 2;
+   if (defer_time > TU_TO_USEC(3 + beacon_resp_time))
+   defer_time -= TU_TO_USEC(3 + beacon_resp_time);
+   else
+   defer_time = 1000;
+   }
+
+   ath_dbg(common, CHAN_CTX, "Setup defer_time %u (%u ms)\n",
+   defer_time, defer_time / 1000);
+
+   tsf_time = sc->sched.next_tbtt + defer_time;
sc->sched.switch_start_time = tsf_time;
sc->cur_chan->last_beacon = sc->sched.next_tbtt;
+   sc->cur_chan->ctwindow = defer_time;
 
/*
 * If an offchannel switch is scheduled to happen after
@@ -707,7 +741,7 @@ void ath

[ath9k-devel] [PATCH 12/12] ath9k: MCC, print time elapsed between events

2015-11-12 Thread Janusz Dziedzic
This is useful for MCC debugging and bug fixing.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  1 +
 drivers/net/wireless/ath/ath9k/channel.c | 19 +--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index 4616229..952a467 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -983,6 +983,7 @@ struct ath_softc {
struct ath_offchannel offchannel;
struct ath_chanctx *next_chan;
struct completion go_beacon;
+   struct timespec last_event_time;
 #endif
 
unsigned long driver_data;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index b0d74f0..d6b1076 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -226,6 +226,20 @@ static const char *chanctx_state_string(enum 
ath_chanctx_state state)
}
 }
 
+static const u32 chanctx_event_delta(struct ath_softc *sc)
+{
+   u64 ms;
+   struct timespec ts, *old;
+
+   getrawmonotonic(&ts);
+   old = &sc->last_event_time;
+   ms = ts.tv_sec * 1000 + ts.tv_nsec / 100;
+   ms -= old->tv_sec * 1000 + old->tv_nsec / 100;
+   sc->last_event_time = ts;
+
+   return (u32)ms;
+}
+
 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -507,10 +521,11 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
 
spin_lock_bh(&sc->chan_lock);
 
-   ath_dbg(common, CHAN_CTX, "cur_chan: %d MHz, event: %s, state: %s\n",
+   ath_dbg(common, CHAN_CTX, "cur_chan: %d MHz, event: %s, state: %s, 
delta: %u ms\n",
sc->cur_chan->chandef.center_freq1,
chanctx_event_string(ev),
-   chanctx_state_string(sc->sched.state));
+   chanctx_state_string(sc->sched.state),
+   chanctx_event_delta(sc));
 
switch (ev) {
case ATH_CHANCTX_EVENT_BEACON_PREPARE:
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 08/12] ath9k: P2P_CLIENT, get/set NOA correctly

2015-11-12 Thread Janusz Dziedzic
In case we get BSS_CHANGED_P2P_PS early, from
mac80211, we didn't set NOA timer correctly,
while p2p_ps_vif was NULL.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 2615392..db49bc5 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1443,6 +1443,10 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, 
struct ieee80211_vif *vif)
return;
 
sc->p2p_ps_vif = avp;
+
+   if (sc->ps_flags & PS_BEACON_SYNC)
+   return;
+
tsf = ath9k_hw_gettsf32(sc->sc_ah);
ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
ath9k_update_p2p_ps_timer(sc, avp);
@@ -1585,8 +1589,7 @@ void ath9k_p2p_bss_info_changed(struct ath_softc *sc,
 
spin_lock_bh(&sc->sc_pcu_lock);
spin_lock_irqsave(&sc->sc_pm_lock, flags);
-   if (!(sc->ps_flags & PS_BEACON_SYNC))
-   ath9k_update_p2p_ps(sc, vif);
+   ath9k_update_p2p_ps(sc, vif);
spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
spin_unlock_bh(&sc->sc_pcu_lock);
 }
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 07/12] ath9k: MCC enable Opportunistic Power Save

2015-11-12 Thread Janusz Dziedzic
When adding NOA attr enable Opportunistiv Power Save.
Before we calculate ctwindow but didn't enable oppps.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 4f60ddb..2615392 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1505,6 +1505,8 @@ void ath9k_beacon_add_noa(struct ath_softc *sc, struct 
ath_vif *avp,
 
noa->index = avp->noa_index;
noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp);
+   if (noa->oppps_ctwindow)
+   noa->oppps_ctwindow |= BIT(7);
 
if (avp->noa_duration) {
if (avp->periodic_noa) {
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 03/12] ath9k: queue null frames in case of MCC

2015-11-12 Thread Janusz Dziedzic
While mac80211 using null frames when connection polling,
we should queue this frames while NOA could be there, and
AP, P2P_GO could be not present.

Without this patch, with no traffic we often saw disconnections
while we try to send nullfunc when AP/GO wasn't present.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/xmit.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
b/drivers/net/wireless/ath/ath9k/xmit.c
index 26698a6..82fc76f 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2331,6 +2331,12 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff 
*skb,
 
queue = ieee80211_is_data_present(hdr->frame_control);
 
+   /* If chanctx, queue all null frames while NOA could be there */
+   if (ath9k_is_chanctx_enabled() &&
+   ieee80211_is_nullfunc(hdr->frame_control) &&
+   !txctl->force_channel)
+   queue = true;
+
/* Force queueing of all frames that belong to a virtual interface on
 * a different channel context, to ensure that they are sent on the
 * correct channel.
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 06/12] ath9k: setup correct skb priority for nullfunc

2015-11-12 Thread Janusz Dziedzic
After queue nullfunc for MCC case, we hit WARN_ON
in xmit.c:2398 while skb priority wasn't set.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index d86566b..4f60ddb 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1101,6 +1101,7 @@ ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, 
struct ath_vif *avp,
nullfunc->frame_control |=
cpu_to_le16(IEEE80211_FCTL_PM);
 
+   skb->priority = 7;
skb_set_queue_mapping(skb, IEEE80211_AC_VO);
if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) {
dev_kfree_skb_any(skb);
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 02/12] ath9k: print real timer value

2015-11-12 Thread Janusz Dziedzic
In case of low HZ before this patch we saw wrong
values in debug message. Print real timeout value.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 35802c9..dddaaea 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -356,14 +356,16 @@ static void ath_chanctx_setup_timer(struct ath_softc *sc, 
u32 tsf_time)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
+   unsigned long timeout;
 
ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, 100);
tsf_time -= ath9k_hw_gettsf32(ah);
-   tsf_time = msecs_to_jiffies(tsf_time / 1000) + 1;
-   mod_timer(&sc->sched.timer, jiffies + tsf_time);
+   timeout = msecs_to_jiffies(tsf_time / 1000) + 1;
+   mod_timer(&sc->sched.timer, jiffies + timeout);
 
ath_dbg(common, CHAN_CTX,
-   "Setup chanctx timer with timeout: %d ms\n", 
jiffies_to_msecs(tsf_time));
+   "Setup chanctx timer with timeout: %d (%d) ms\n",
+   tsf_time / 1000, jiffies_to_msecs(timeout));
 }
 
 static void ath_chanctx_handle_bmiss(struct ath_softc *sc,
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath9k: incorrect queue may be stopped/awaken

2015-11-12 Thread Janusz Dziedzic
On 3 November 2015 at 18:37, Borja Salazar  wrote:
> When channel context is enabled, we could be
> stopping/awakening an incorrect queue.
> ---
>  drivers/net/wireless/ath/ath9k/xmit.c | 22 --
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
> b/drivers/net/wireless/ath/ath9k/xmit.c
> index 3e3dac3..9b17a59 100644
> --- a/drivers/net/wireless/ath/ath9k/xmit.c
> +++ b/drivers/net/wireless/ath/ath9k/xmit.c
> @@ -147,7 +147,12 @@ static void ath_txq_skb_done(struct ath_softc *sc, 
> struct ath_txq *txq,
>  {
> struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
> struct ath_frame_info *fi = get_frame_info(skb);
> -   int q = fi->txq;
> +   int q;
> +
> +   if (ath9k_is_chanctx_enabled())
> +   q = fi->txq;
> +   else
> +   q = info->hw_queue;
>
> if (q < 0)
> return;
> @@ -158,10 +163,7 @@ static void ath_txq_skb_done(struct ath_softc *sc, 
> struct ath_txq *txq,
>
> if (txq->stopped &&
> txq->pending_frames < sc->tx.txq_max_pending[q]) {
> -   if (ath9k_is_chanctx_enabled())
> -   ieee80211_wake_queue(sc->hw, info->hw_queue);
> -   else
> -   ieee80211_wake_queue(sc->hw, q);
> +   ieee80211_wake_queue(sc->hw, q);
> txq->stopped = false;
> }
>  }
> @@ -2299,17 +2301,17 @@ int ath_tx_start(struct ieee80211_hw *hw, struct 
> sk_buff *skb,
>  * info are no longer valid (overwritten by the ath_frame_info data.
>  */
>
> -   q = skb_get_queue_mapping(skb);
> +   if (ath9k_is_chanctx_enabled())
> +   q = skb_get_queue_mapping(skb);
> +   else
> +   q = info->hw_queue;
>
> ath_txq_lock(sc, txq);
> if (txq == sc->tx.txq_map[q]) {
> fi->txq = q;
> if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
> !txq->stopped) {
> -   if (ath9k_is_chanctx_enabled())
> -   ieee80211_stop_queue(sc->hw, info->hw_queue);
> -   else
> -   ieee80211_stop_queue(sc->hw, q);
> +   ieee80211_stop_queue(sc->hw, q);
> txq->stopped = true;
> }
> }
> --
> 2.3.6
>
Hello, could you check it again?
I see such patch that enable hw_queues only for MCC and disable for
non-MCC mode.

ath9k: Enable HW queue control only for MCC

Enabling HW queue control for normal (non-mcc) mode
causes problems with queue management, resulting
in traffic stall. Since it is mainly required for
fairness in MCC mode, disable it for the general case.

Bug: https://dev.openwrt.org/ticket/18164

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH v2] ath9k: incorrect queue may be stopped/awaken

2015-11-13 Thread Janusz Dziedzic
On 13 November 2015 at 11:45, Borja Salazar  wrote:

> Hi,
>
> Let me explain the patch more thoroughly. We are testing MCC and we've
> found some issues with the queues handlers, the main problem is that when
> we transmit a multicast/broadcast frame, where hw_queue is 8 (CAB), we
> check queue status, which is 2(q), and if it is full and we have to stop
> it, we end stopping the wrong queue, 8, which is not full. From this point
> onwards stations are unable to connect to the AP.
>
> Let me know if something is not clear.
>
> I am interested if you reintroduce bug that Sujith already fix in commit:
ath9k: Enable HW queue control only for MCC

While as I understand correctly this patch disable hw queues for non-mcc
(also clear IEEE80211_HW_QUEUE_CONTROL) and your

+   if (ath9k_is_chanctx_enabled())
+   q = fi->txq;
+   else
+   q = info->hw_queue;

Use again hw_queue for standard non-mcc operation.

Please check this, I am sure while did only simple check :)

BR
Janusz



> Regards,
>
> [image: Fon] Borja SalazarFirmware teamAll
> information in this email is confidential
> 
>
> On Fri, Nov 13, 2015 at 11:33 AM, Borja Salazar 
> wrote:
>
>> When channel context is enabled, we could be
>> stopping/awakening an incorrect queue.
>>
>> Signed-off-by: Borja Salazar 
>> ---
>>  drivers/net/wireless/ath/ath9k/xmit.c | 22 --
>>  1 file changed, 12 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/xmit.c
>> b/drivers/net/wireless/ath/ath9k/xmit.c
>> index 3e3dac3..9b17a59 100644
>> --- a/drivers/net/wireless/ath/ath9k/xmit.c
>> +++ b/drivers/net/wireless/ath/ath9k/xmit.c
>> @@ -147,7 +147,12 @@ static void ath_txq_skb_done(struct ath_softc *sc,
>> struct ath_txq *txq,
>>  {
>> struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
>> struct ath_frame_info *fi = get_frame_info(skb);
>> -   int q = fi->txq;
>> +   int q;
>> +
>> +   if (ath9k_is_chanctx_enabled())
>> +   q = fi->txq;
>> +   else
>> +   q = info->hw_queue;
>>
>> if (q < 0)
>> return;
>> @@ -158,10 +163,7 @@ static void ath_txq_skb_done(struct ath_softc *sc,
>> struct ath_txq *txq,
>>
>> if (txq->stopped &&
>> txq->pending_frames < sc->tx.txq_max_pending[q]) {
>> -   if (ath9k_is_chanctx_enabled())
>> -   ieee80211_wake_queue(sc->hw, info->hw_queue);
>> -   else
>> -   ieee80211_wake_queue(sc->hw, q);
>> +   ieee80211_wake_queue(sc->hw, q);
>> txq->stopped = false;
>> }
>>  }
>> @@ -2299,17 +2301,17 @@ int ath_tx_start(struct ieee80211_hw *hw, struct
>> sk_buff *skb,
>>  * info are no longer valid (overwritten by the ath_frame_info
>> data.
>>  */
>>
>> -   q = skb_get_queue_mapping(skb);
>> +   if (ath9k_is_chanctx_enabled())
>> +   q = skb_get_queue_mapping(skb);
>> +   else
>> +   q = info->hw_queue;
>>
>> ath_txq_lock(sc, txq);
>> if (txq == sc->tx.txq_map[q]) {
>> fi->txq = q;
>> if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
>> !txq->stopped) {
>> -   if (ath9k_is_chanctx_enabled())
>> -   ieee80211_stop_queue(sc->hw,
>> info->hw_queue);
>> -   else
>> -   ieee80211_stop_queue(sc->hw, q);
>> +   ieee80211_stop_queue(sc->hw, q);
>> txq->stopped = true;
>> }
>> }
>> --
>> 2.3.6
>>
>>
>
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH v2] ath9k: incorrect queue may be stopped/awaken

2015-11-13 Thread Janusz Dziedzic
Send again as txt.


On 13 November 2015 at 12:17, Janusz Dziedzic  wrote:
>
>
>
> On 13 November 2015 at 11:45, Borja Salazar  wrote:
>>
>> Hi,
>>
>> Let me explain the patch more thoroughly. We are testing MCC and we've found 
>> some issues with the queues handlers, the main problem is that when we 
>> transmit a multicast/broadcast frame, where hw_queue is 8 (CAB), we check 
>> queue status, which is 2(q), and if it is full and we have to stop it, we 
>> end stopping the wrong queue, 8, which is not full. From this point onwards 
>> stations are unable to connect to the AP.
>>
>> Let me know if something is not clear.
>>
> I am interested if you reintroduce bug that Sujith already fix in commit:
> ath9k: Enable HW queue control only for MCC
>
> While as I understand correctly this patch disable hw queues for non-mcc 
> (also clear IEEE80211_HW_QUEUE_CONTROL) and your
>
> +   if (ath9k_is_chanctx_enabled())
> +   q = fi->txq;
> +   else
> +   q = info->hw_queue;
>
> Use again hw_queue for standard non-mcc operation.
>
> Please check this, I am sure while did only simple check :)
>
> BR
> Janusz
>
>
>>
>> Regards,
>>
>> Borja Salazar
>> Firmware team
>> All information in this email is confidential
>>
>> On Fri, Nov 13, 2015 at 11:33 AM, Borja Salazar  
>> wrote:
>>>
>>> When channel context is enabled, we could be
>>> stopping/awakening an incorrect queue.
>>>
>>> Signed-off-by: Borja Salazar 
>>> ---
>>>  drivers/net/wireless/ath/ath9k/xmit.c | 22 --
>>>  1 file changed, 12 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
>>> b/drivers/net/wireless/ath/ath9k/xmit.c
>>> index 3e3dac3..9b17a59 100644
>>> --- a/drivers/net/wireless/ath/ath9k/xmit.c
>>> +++ b/drivers/net/wireless/ath/ath9k/xmit.c
>>> @@ -147,7 +147,12 @@ static void ath_txq_skb_done(struct ath_softc *sc, 
>>> struct ath_txq *txq,
>>>  {
>>> struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
>>> struct ath_frame_info *fi = get_frame_info(skb);
>>> -   int q = fi->txq;
>>> +   int q;
>>> +
>>> +   if (ath9k_is_chanctx_enabled())
>>> +   q = fi->txq;
>>> +   else
>>> +   q = info->hw_queue;
>>>
>>> if (q < 0)
>>> return;
>>> @@ -158,10 +163,7 @@ static void ath_txq_skb_done(struct ath_softc *sc, 
>>> struct ath_txq *txq,
>>>
>>> if (txq->stopped &&
>>> txq->pending_frames < sc->tx.txq_max_pending[q]) {
>>> -   if (ath9k_is_chanctx_enabled())
>>> -   ieee80211_wake_queue(sc->hw, info->hw_queue);
>>> -   else
>>> -   ieee80211_wake_queue(sc->hw, q);
>>> +   ieee80211_wake_queue(sc->hw, q);
>>> txq->stopped = false;
>>> }
>>>  }
>>> @@ -2299,17 +2301,17 @@ int ath_tx_start(struct ieee80211_hw *hw, struct 
>>> sk_buff *skb,
>>>  * info are no longer valid (overwritten by the ath_frame_info data.
>>>  */
>>>
>>> -   q = skb_get_queue_mapping(skb);
>>> +   if (ath9k_is_chanctx_enabled())
>>> +   q = skb_get_queue_mapping(skb);
>>> +   else
>>> +   q = info->hw_queue;
>>>
>>> ath_txq_lock(sc, txq);
>>> if (txq == sc->tx.txq_map[q]) {
>>> fi->txq = q;
>>> if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
>>> !txq->stopped) {
>>> -   if (ath9k_is_chanctx_enabled())
>>> -   ieee80211_stop_queue(sc->hw, 
>>> info->hw_queue);
>>> -   else
>>> -   ieee80211_stop_queue(sc->hw, q);
>>> +   ieee80211_stop_queue(sc->hw, q);
>>> txq->stopped = true;
>>> }
>>> }
>>> --
>>> 2.3.6
>>>
>>
>
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 01/13] ath9k: add debug messages to aggr/chanctx funcs

2015-11-27 Thread Janusz Dziedzic
Add/extend debug messages when chanctx used.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 11 ---
 drivers/net/wireless/ath/ath9k/hw.c  |  8 
 drivers/net/wireless/ath/ath9k/xmit.c| 15 +++
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 90f5773..35802c9 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -403,7 +403,7 @@ static void ath_chanctx_offchannel_noa(struct ath_softc *sc,
avp->offchannel_duration = sc->sched.offchannel_duration;
 
ath_dbg(common, CHAN_CTX,
-   "offchannel noa_duration: %d, noa_start: %d, noa_index: %d\n",
+   "offchannel noa_duration: %d, noa_start: %u, noa_index: %d\n",
avp->offchannel_duration,
avp->offchannel_start,
avp->noa_index);
@@ -443,7 +443,7 @@ static void ath_chanctx_set_periodic_noa(struct ath_softc 
*sc,
avp->periodic_noa = true;
 
ath_dbg(common, CHAN_CTX,
-   "noa_duration: %d, noa_start: %d, noa_index: %d, periodic: 
%d\n",
+   "noa_duration: %d, noa_start: %u, noa_index: %d, periodic: 
%d\n",
avp->noa_duration,
avp->noa_start,
avp->noa_index,
@@ -464,7 +464,7 @@ static void ath_chanctx_set_oneshot_noa(struct ath_softc 
*sc,
avp->noa_duration = duration + sc->sched.channel_switch_time;
 
ath_dbg(common, CHAN_CTX,
-   "oneshot noa_duration: %d, noa_start: %d, noa_index: %d, 
periodic: %d\n",
+   "oneshot noa_duration: %d, noa_start: %u, noa_index: %d, 
periodic: %d\n",
avp->noa_duration,
avp->noa_start,
avp->noa_index,
@@ -1401,6 +1401,7 @@ void ath9k_chanctx_wake_queues(struct ath_softc *sc, 
struct ath_chanctx *ctx)
 
 static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif 
*avp)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
s32 tsf, target_tsf;
 
@@ -1418,6 +1419,10 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
if (target_tsf - tsf < ATH_P2P_PS_STOP_TIME)
target_tsf = tsf + ATH_P2P_PS_STOP_TIME;
 
+   ath_dbg(common, CHAN_CTX, "%s absent %d tsf 0x%08X next_tsf 0x%08X 
(%dms)\n",
+   __func__, avp->noa.absent, tsf, target_tsf,
+   (target_tsf - tsf) / 1000);
+
ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 
100);
 }
 
diff --git a/drivers/net/wireless/ath/ath9k/hw.c 
b/drivers/net/wireless/ath/ath9k/hw.c
index bdfff46..4af19e4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2299,10 +2299,10 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
else
nextTbtt = bs->bs_nexttbtt;
 
-   ath_dbg(common, BEACON, "next DTIM %d\n", bs->bs_nextdtim);
-   ath_dbg(common, BEACON, "next beacon %d\n", nextTbtt);
-   ath_dbg(common, BEACON, "beacon period %d\n", beaconintval);
-   ath_dbg(common, BEACON, "DTIM period %d\n", dtimperiod);
+   ath_dbg(common, BEACON, "next DTIM %u\n", bs->bs_nextdtim);
+   ath_dbg(common, BEACON, "next beacon %u\n", nextTbtt);
+   ath_dbg(common, BEACON, "beacon period %u\n", beaconintval);
+   ath_dbg(common, BEACON, "DTIM period %u\n", dtimperiod);
 
ENABLE_REGWRITE_BUFFER(ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
b/drivers/net/wireless/ath/ath9k/xmit.c
index 3e3dac3..26698a6 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1473,11 +1473,14 @@ static bool ath_tx_sched_aggr(struct ath_softc *sc, 
struct ath_txq *txq,
 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
  u16 tid, u16 *ssn)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_atx_tid *txtid;
struct ath_txq *txq;
struct ath_node *an;
u8 density;
 
+   ath_dbg(common, XMIT, "%s called\n", __func__);
+
an = (struct ath_node *)sta->drv_priv;
txtid = ATH_AN_2_TID(an, tid);
txq = txtid->txq;
@@ -1512,10 +1515,13 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct 
ieee80211_sta *sta,
 
 void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_node *an = (struct ath_node *)sta->drv_priv;
struct ath_atx_tid *txtid = ATH_AN_2_TI

[ath9k-devel] [PATCH v2 04/13] ath9k: P2P_CLIENT, send frames after 1ms AP/GO will aprear

2015-11-27 Thread Janusz Dziedzic
AP/GO will aprear after NOA, wait 1ms to be sure AP
could receive/answer this frames.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index dddaaea..5640e88 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1417,6 +1417,8 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
target_tsf = avp->noa.next_tsf;
if (!avp->noa.absent)
target_tsf -= ATH_P2P_PS_STOP_TIME;
+   else
+   target_tsf += ATH_P2P_PS_STOP_TIME;
 
if (target_tsf - tsf < ATH_P2P_PS_STOP_TIME)
target_tsf = tsf + ATH_P2P_PS_STOP_TIME;
@@ -1543,6 +1545,8 @@ void ath9k_p2p_ps_timer(void *priv)
tsf = ath9k_hw_gettsf32(sc->sc_ah);
if (!avp->noa.absent)
tsf += ATH_P2P_PS_STOP_TIME;
+   else
+   tsf -= ATH_P2P_PS_STOP_TIME;
 
if (!avp->noa.has_next_tsf ||
avp->noa.next_tsf - tsf > BIT(31))
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 06/13] ath9k: setup correct skb priority for nullfunc

2015-11-27 Thread Janusz Dziedzic
After queue nullfunc for MCC case, we hit WARN_ON
in xmit.c:2398 while skb priority wasn't set.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 28bbbef..2afb8da 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1101,6 +1101,7 @@ ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, 
struct ath_vif *avp,
nullfunc->frame_control |=
cpu_to_le16(IEEE80211_FCTL_PM);
 
+   skb->priority = 7;
skb_set_queue_mapping(skb, IEEE80211_AC_VO);
if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) {
dev_kfree_skb_any(skb);
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 02/13] ath9k: print real timer value

2015-11-27 Thread Janusz Dziedzic
In case of low HZ before this patch we saw wrong
values in debug message. Print real timeout value.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 35802c9..dddaaea 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -356,14 +356,16 @@ static void ath_chanctx_setup_timer(struct ath_softc *sc, 
u32 tsf_time)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
+   unsigned long timeout;
 
ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, 100);
tsf_time -= ath9k_hw_gettsf32(ah);
-   tsf_time = msecs_to_jiffies(tsf_time / 1000) + 1;
-   mod_timer(&sc->sched.timer, jiffies + tsf_time);
+   timeout = msecs_to_jiffies(tsf_time / 1000) + 1;
+   mod_timer(&sc->sched.timer, jiffies + timeout);
 
ath_dbg(common, CHAN_CTX,
-   "Setup chanctx timer with timeout: %d ms\n", 
jiffies_to_msecs(tsf_time));
+   "Setup chanctx timer with timeout: %d (%d) ms\n",
+   tsf_time / 1000, jiffies_to_msecs(timeout));
 }
 
 static void ath_chanctx_handle_bmiss(struct ath_softc *sc,
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 05/13] ath9k: use u32 when calculate tsf

2015-11-27 Thread Janusz Dziedzic
Use u32 while ath9k_hw_gettsf32() and
ath9k_hw_gen_timer_start() require u32.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 5640e88..28bbbef 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1405,7 +1405,7 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
-   s32 tsf, target_tsf;
+   u32 tsf, target_tsf;
 
if (!avp || !avp->noa.has_next_tsf)
return;
@@ -1427,7 +1427,7 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc 
*sc, struct ath_vif *avp)
__func__, avp->noa.absent, tsf, target_tsf,
(target_tsf - tsf) / 1000);
 
-   ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 
100);
+   ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, target_tsf, 100);
 }
 
 static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif 
*vif)
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 03/13] ath9k: queue null frames in case of MCC

2015-11-27 Thread Janusz Dziedzic
While mac80211 using null frames when connection polling,
we should queue this frames while NOA could be there, and
AP, P2P_GO could be not present.

Without this patch, with no traffic we often saw disconnections
while we try to send nullfunc when AP/GO wasn't present.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/xmit.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
b/drivers/net/wireless/ath/ath9k/xmit.c
index 26698a6..82fc76f 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2331,6 +2331,12 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff 
*skb,
 
queue = ieee80211_is_data_present(hdr->frame_control);
 
+   /* If chanctx, queue all null frames while NOA could be there */
+   if (ath9k_is_chanctx_enabled() &&
+   ieee80211_is_nullfunc(hdr->frame_control) &&
+   !txctl->force_channel)
+   queue = true;
+
/* Force queueing of all frames that belong to a virtual interface on
 * a different channel context, to ensure that they are sent on the
 * correct channel.
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 09/13] ath9k: request NOA update when chanctx active

2015-11-27 Thread Janusz Dziedzic
Request NOA update when chanctx active, also in case
of STA.

Signed-off-by: Janusz Dziedzic 
---
This depends on:
mac80211: add new IEEE80211_VIF_GET_NOA_UPDATE flag

 drivers/net/wireless/ath/ath9k/channel.c | 2 +-
 drivers/net/wireless/ath/ath9k/main.c| 5 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 5a1ede6..c94d7d9 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1439,7 +1439,7 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, 
struct ieee80211_vif *vif)
if (!sc->p2p_ps_timer)
return;
 
-   if (vif->type != NL80211_IFTYPE_STATION || !vif->p2p)
+   if (vif->type != NL80211_IFTYPE_STATION)
return;
 
sc->p2p_ps_vif = avp;
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index d184e68..ab46a4d 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -974,7 +974,7 @@ static void ath9k_update_bssid_mask(struct ath_softc *sc,
if (ctx->nvifs_assigned != 1)
continue;
 
-   if (!avp->vif->p2p || !iter_data->has_hw_macaddr)
+   if (!iter_data->has_hw_macaddr)
continue;
 
ether_addr_copy(common->curbssid, avp->bssid);
@@ -1251,6 +1251,9 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
sc->cur_chan->nvifs++;
 
+   if (vif->type == NL80211_IFTYPE_STATION && ath9k_is_chanctx_enabled())
+   vif->driver_flags |= IEEE80211_VIF_GET_NOA_UPDATE;
+
if (ath9k_uses_beacons(vif->type))
ath9k_beacon_assign_slot(sc, vif);
 
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 07/13] ath9k: MCC enable Opportunistic Power Save

2015-11-27 Thread Janusz Dziedzic
When adding NOA attr enable Opportunistic Power Save.
Before we calculate ctwindow but didn't enable oppps.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 2afb8da..31b4d0e 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1505,6 +1505,8 @@ void ath9k_beacon_add_noa(struct ath_softc *sc, struct 
ath_vif *avp,
 
noa->index = avp->noa_index;
noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp);
+   if (noa->oppps_ctwindow)
+   noa->oppps_ctwindow |= BIT(7);
 
if (avp->noa_duration) {
if (avp->periodic_noa) {
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 10/13] ath9k: MCC, add NOA also in case of an AP

2015-11-27 Thread Janusz Dziedzic
In case of MCC and AP interface, add also NOA attr
that will inform stations about absence of an AP.
There is a chance that some stations will handle
this NOA attr correctly and will know exactly when
AP is present/absent.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/beacon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/beacon.c 
b/drivers/net/wireless/ath/ath9k/beacon.c
index f50a6bc..5cf0cd7 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -148,7 +148,8 @@ static struct ath_buf *ath9k_beacon_generate(struct 
ieee80211_hw *hw,
 
ath_assign_seq(common, skb);
 
-   if (vif->p2p)
+   /* Always assign NOA attr when MCC enabled */
+   if (ath9k_is_chanctx_enabled())
ath9k_beacon_add_noa(sc, avp, skb);
 
bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 13/13] ath9k: remove ath9k_mod_tsf64_tu

2015-11-27 Thread Janusz Dziedzic
Remove ath9k_mod_tsf64_tu() function while we could
use div_u64_rem() function.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/common-beacon.c | 22 --
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/common-beacon.c 
b/drivers/net/wireless/ath/ath9k/common-beacon.c
index 6ad4447..01d6d32 100644
--- a/drivers/net/wireless/ath/ath9k/common-beacon.c
+++ b/drivers/net/wireless/ath/ath9k/common-beacon.c
@@ -18,30 +18,16 @@
 
 #define FUDGE 2
 
-/* Calculate the modulo of a 64 bit TSF snapshot with a TU divisor */
-static u32 ath9k_mod_tsf64_tu(u64 tsf, u32 div_tu)
-{
-   u32 tsf_mod, tsf_hi, tsf_lo, mod_hi, mod_lo;
-
-   tsf_mod = tsf & (BIT(10) - 1);
-   tsf_hi = tsf >> 32;
-   tsf_lo = ((u32) tsf) >> 10;
-
-   mod_hi = tsf_hi % div_tu;
-   mod_lo = ((mod_hi << 22) + tsf_lo) % div_tu;
-
-   return (mod_lo << 10) | tsf_mod;
-}
-
 static u32 ath9k_get_next_tbtt(struct ath_hw *ah, u64 tsf,
   unsigned int interval)
 {
-   unsigned int offset;
+   unsigned int offset, divisor;
 
tsf += TU_TO_USEC(FUDGE + ah->config.sw_beacon_response_time);
-   offset = ath9k_mod_tsf64_tu(tsf, interval);
+   divisor = TU_TO_USEC(interval);
+   div_u64_rem(tsf, divisor, &offset);
 
-   return (u32) tsf + TU_TO_USEC(interval) - offset;
+   return (u32) tsf + divisor - offset;
 }
 
 /*
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 08/13] ath9k: P2P_CLIENT, get/set NOA correctly

2015-11-27 Thread Janusz Dziedzic
In case we get BSS_CHANGED_P2P_PS early, from
mac80211, we didn't set NOA timer correctly,
while p2p_ps_vif was NULL.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/channel.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 31b4d0e..5a1ede6 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1443,6 +1443,10 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, 
struct ieee80211_vif *vif)
return;
 
sc->p2p_ps_vif = avp;
+
+   if (sc->ps_flags & PS_BEACON_SYNC)
+   return;
+
tsf = ath9k_hw_gettsf32(sc->sc_ah);
ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
ath9k_update_p2p_ps_timer(sc, avp);
@@ -1585,8 +1589,7 @@ void ath9k_p2p_bss_info_changed(struct ath_softc *sc,
 
spin_lock_bh(&sc->sc_pcu_lock);
spin_lock_irqsave(&sc->sc_pm_lock, flags);
-   if (!(sc->ps_flags & PS_BEACON_SYNC))
-   ath9k_update_p2p_ps(sc, vif);
+   ath9k_update_p2p_ps(sc, vif);
spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
spin_unlock_bh(&sc->sc_pcu_lock);
 }
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param

2015-11-27 Thread Janusz Dziedzic
In case of MCC we can setup STA/AP(GO) ratio.
Eg. setting sta_ap_ratio=80
STA will get 80% of time, while AP(GO) 20%.
Setup correct ctwindow.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  2 +
 drivers/net/wireless/ath/ath9k/channel.c | 69 +---
 drivers/net/wireless/ath/ath9k/hw.h  |  1 +
 drivers/net/wireless/ath/ath9k/init.c|  3 ++
 4 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index b42f4a9..4616229 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -37,6 +37,7 @@ extern int ath9k_modparam_nohwcrypt;
 extern int ath9k_led_blink;
 extern bool is_ath9k_unloaded;
 extern int ath9k_use_chanctx;
+extern int ath9k_sta_ap_ratio;
 
 /*/
 /* Descriptor Management */
@@ -335,6 +336,7 @@ struct ath_chanctx {
struct timespec tsf_ts;
u64 tsf_val;
u32 last_beacon;
+   u32 ctwindow;
 
int flush_timeout;
u16 txpower;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index c94d7d9..8ab856c 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -313,11 +313,21 @@ ath_chanctx_get_next(struct ath_softc *sc, struct 
ath_chanctx *ctx)
return &sc->chanctx[!idx];
 }
 
+static u32 get_ratio(u32 beacon_int)
+{
+   if (ath9k_sta_ap_ratio < 20 ||
+   ath9k_sta_ap_ratio > 80)
+   return beacon_int / 2;
+
+   return (beacon_int * ath9k_sta_ap_ratio) / 100;
+}
+
 static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
 {
+   struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_chanctx *prev, *cur;
struct timespec ts;
-   u32 cur_tsf, prev_tsf, beacon_int;
+   u32 cur_tsf, prev_tsf, beacon_int, diff;
s32 offset;
 
beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
@@ -344,7 +354,14 @@ static void ath_chanctx_adjust_tbtt_delta(struct ath_softc 
*sc)
if (offset < 0 || offset > 3 * beacon_int)
return;
 
-   offset = beacon_int / 2 - (offset % beacon_int);
+   diff = 2 * prev->ctwindow;
+   diff += sc->sched.channel_switch_time;
+   if (diff > beacon_int / 2)
+   diff = beacon_int / 2;
+
+   ath_dbg(common, CHAN_CTX, "Setup beacon interval offset %u ms\n",
+   diff / 1000);
+   offset = diff - (offset % beacon_int);
prev->tsf_val += offset;
 }
 
@@ -435,7 +452,7 @@ static void ath_chanctx_set_periodic_noa(struct ath_softc 
*sc,
sc->sched.channel_switch_time;
else
avp->noa_duration =
-   TU_TO_USEC(cur_conf->beacon_interval) / 2 +
+   TU_TO_USEC(get_ratio(cur_conf->beacon_interval)) +
sc->sched.channel_switch_time;
 
if (test_bit(ATH_OP_SCANNING, &common->op_flags) ||
@@ -481,7 +498,8 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
struct ath_beacon_config *cur_conf;
struct ath_vif *avp = NULL;
struct ath_chanctx *ctx;
-   u32 tsf_time;
+   u32 tsf_time, defer_time;
+   u32 beacon_resp_time = ah->config.sw_beacon_response_time;
u32 beacon_int;
 
if (vif)
@@ -565,10 +583,26 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
cur_conf = &sc->cur_chan->beacon;
beacon_int = TU_TO_USEC(cur_conf->beacon_interval);
 
-   /* defer channel switch by a quarter beacon interval */
-   tsf_time = sc->sched.next_tbtt + beacon_int / 4;
+   /* defer channel switch */
+   defer_time = beacon_int - get_ratio(beacon_int);
+   defer_time -= sc->sched.channel_switch_time;
+   defer_time /= 2;
+
+   if (defer_time < TU_TO_USEC(2 + beacon_resp_time)) {
+   defer_time *= 2;
+   if (defer_time > TU_TO_USEC(3 + beacon_resp_time))
+   defer_time -= TU_TO_USEC(3 + beacon_resp_time);
+   else
+   defer_time = 1000;
+   }
+
+   ath_dbg(common, CHAN_CTX, "Setup defer_time %u (%u ms)\n",
+   defer_time, defer_time / 1000);
+
+   tsf_time = sc->sched.next_tbtt + defer_time;
sc->sched.switch_start_time = tsf_time;
sc->cur_chan->last_beacon = sc->sched.next_tbtt;
+   sc->cur_chan->ctwindow = defer_time;
 
/*
 * If an offchannel switch is scheduled to happen after
@@ -707,7 +741,7 @@ void ath

[ath9k-devel] [PATCH v2 12/13] ath9k: MCC, print time elapsed between events

2015-11-27 Thread Janusz Dziedzic
This is useful for MCC debugging and bug fixing.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  1 +
 drivers/net/wireless/ath/ath9k/channel.c | 19 +--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index 4616229..952a467 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -983,6 +983,7 @@ struct ath_softc {
struct ath_offchannel offchannel;
struct ath_chanctx *next_chan;
struct completion go_beacon;
+   struct timespec last_event_time;
 #endif
 
unsigned long driver_data;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c 
b/drivers/net/wireless/ath/ath9k/channel.c
index 8ab856c..65ad7be 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -226,6 +226,20 @@ static const char *chanctx_state_string(enum 
ath_chanctx_state state)
}
 }
 
+static const u32 chanctx_event_delta(struct ath_softc *sc)
+{
+   u64 ms;
+   struct timespec ts, *old;
+
+   getrawmonotonic(&ts);
+   old = &sc->last_event_time;
+   ms = ts.tv_sec * 1000 + ts.tv_nsec / 100;
+   ms -= old->tv_sec * 1000 + old->tv_nsec / 100;
+   sc->last_event_time = ts;
+
+   return (u32)ms;
+}
+
 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
 {
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -507,10 +521,11 @@ void ath_chanctx_event(struct ath_softc *sc, struct 
ieee80211_vif *vif,
 
spin_lock_bh(&sc->chan_lock);
 
-   ath_dbg(common, CHAN_CTX, "cur_chan: %d MHz, event: %s, state: %s\n",
+   ath_dbg(common, CHAN_CTX, "cur_chan: %d MHz, event: %s, state: %s, 
delta: %u ms\n",
sc->cur_chan->chandef.center_freq1,
chanctx_event_string(ev),
-   chanctx_state_string(sc->sched.state));
+   chanctx_state_string(sc->sched.state),
+   chanctx_event_delta(sc));
 
switch (ev) {
case ATH_CHANCTX_EVENT_BEACON_PREPARE:
-- 
1.9.1

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] l3/l4 checksum offload

2015-12-16 Thread Janusz Dziedzic
Hello,

Is there ath9k HW that supports l3/l4 checksum offload?

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param

2015-12-17 Thread Janusz Dziedzic
On 11 December 2015 at 09:19, Kalle Valo  wrote:
> Janusz Dziedzic  writes:
>
>> In case of MCC we can setup STA/AP(GO) ratio.
>> Eg. setting sta_ap_ratio=80
>> STA will get 80% of time, while AP(GO) 20%.
>> Setup correct ctwindow.
>>
>> Signed-off-by: Janusz Dziedzic 
>
> Why? What's the use case?
>
By default beacon_int/2 is used in current implementation.
This patch was developed as a proof of concept in case we would like
to use MCC and need change this 50/50.
Eg, for some reason we need higher BW/ more air time for STA or AP -
depends on case.
For my case STA connection to Gateway was more important that clients
connected to an AP - so just used
70/30.

> And isn't there a better way to do this? Like using nl80211 (via
> wpasupplicant?) or debugfs?
>
I wasn't sure here, but maybe some prio param on the VIF could be used here?
Eg.
VIF1 - prio 50
VIF2 - prio 100

VIF1_time = 50 / (50 + 100) = 33%
VIF2_time = 100 / (50 + 100) = 66%

with some default prio eg. 100.
But for sure this is more work, and I am not sure someone else will need this?

BR
Janusz
> --
> Kalle Valo
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ath9k_htc - Netgear WNDA3200 - monitor mode

2016-03-21 Thread Janusz Dziedzic
On 21 March 2016 at 22:28, Roger James  wrote:
> Hi,
>
> I am trying to use a Netgear WNDA3200 usb dongle plugged into a box
> running Ubuntu 15.10 to monitor a WPA2_PSK encrypted network. This stick
> uses the AR7010+AR9280 chipsets.  For the particular problem I am
> investigating I need to as much of the traffic on the channel as I can.
> However I seem to miss almost all of the unicast traffic. I have come
> across this problem many times before on other wireless chipsets. I was
> hoping the Atheros would be different. I can see unicast 802.11
> management traffic but not protected unicast data/qos data frames. I
> have hacked the driver to give me  the current filter settings via
> debugfs and this is what I see.
>
> RXFILTER: 0xc03f UCAST MCAST BCAST CONTROL BEACON PROM PSPOLL
> MCAST_BCAST_ALL
>
> Which looks OK to me. I have also checked that all the packets seen by
> driver make it up to user level.
>
> Is this expected behaviour?
>
> Is this something to do with htc USB chipset?
>
> Is this something to do with a Netgear customisation?
>
> Has anyone else seen this kind of behaviour?
>
> Is there any way round it?
>
> Help!! This is driving me nuts. I have done so many tests with this and
> other adapters that I have lost the plot.
>
> I have a whole slew of tests and results available on request. But I
> won't clutter the list with them.
>
I think this is expected, while USB device have to use HW/internal
buffers for frames (next send them to PC).
So, this memory is limited and in case of heavy traffic lot of frame
will be lost. I am not sure how many frames could be buffered (just
guessing - about 10?).

So, best choice for sniffer is a PCI (PCIex) card where HW using
memory from PC mapped via DMA. So, you can get all frames in such
case.
In my setup I am using ath9k (AR9462 dualband) and ath10k, Intel7260
for VHT. All of them works very good.

BR
Janusz

> Roger
>
> ___
> ath9k-devel mailing list
> ath9k-devel@lists.ath9k.org
> https://lists.ath9k.org/mailman/listinfo/ath9k-devel
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Beacon reception events at WiFi Client

2016-03-24 Thread Janusz Dziedzic
On 23 March 2016 at 16:33, sandeep suresh  wrote:
> Dear experts,
>We have a AR9287 based WiFi module on the gateway board operating in 
> client mode. WiFi beacons are generated from the WiFi AP say every 100ms. How 
> can we get an event at WiFi client side every time a beacon is received? At 
> these beacon synchronization points, we want to trigger some calculations in 
> another Linux process. Please help.

It should be possible with NL80211_CMD_REGISTER_FRAME, but seems
mac80211 only supports IEEE80211_STYPE_PROBE_REQ for STA mode - so
kernel changes required here.

For quick check you can use NL80211_TEST_CMD and report such command
every beacon from mac80211 (changes in kernel required). But next you
will be sure quality of nl80211 event will be fine for you.

Other option is:
- iw wlan0 interface add mon0 type monitor
- ifconfig mon0 up
- tshark -i mon0 -Y beacon_filter_here

So, you can write simple app (similar to tshark) that will open mon0
and every beacon you are interest send signal() to another process
(but not sure about timing here, you can get beacons in packeges - eg.
5 beacons at once).

BR
Janusz

> Thanks & regards
> Sandeep.
> ___
> ath9k-devel mailing list
> ath9k-devel@lists.ath9k.org
> https://lists.ath9k.org/mailman/listinfo/ath9k-devel
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] ath9k gpio request

2016-06-02 Thread Janusz Dziedzic
On 2 June 2016 at 10:02, Pan, Miaoqing  wrote:
> Seems there are something wrong in the datasheet,  try
>
> --- a/drivers/net/wireless/ath/ath9k/reg.h
> +++ b/drivers/net/wireless/ath/ath9k/reg.h
> @@ -1122,8 +1122,8 @@ enum {
>  #define AR9300_NUM_GPIO  16
>  #define AR9330_NUM_GPIO 16
>  #define AR9340_NUM_GPIO 23
> -#define AR9462_NUM_GPIO 10
> -#define AR9485_NUM_GPIO 12
> +#define AR9462_NUM_GPIO 14
> +#define AR9485_NUM_GPIO 11
>  #define AR9531_NUM_GPIO 18
>  #define AR9550_NUM_GPIO 24
>  #define AR9561_NUM_GPIO 23
> @@ -1139,8 +1139,8 @@ enum {
>  #define AR9300_GPIO_MASK0xF4FF
>  #define AR9330_GPIO_MASK0xF4FF
>  #define AR9340_GPIO_MASK0x000F
> -#define AR9462_GPIO_MASK0x03FF
> -#define AR9485_GPIO_MASK0x0FFF
> +#define AR9462_GPIO_MASK0x3FFF
> +#define AR9485_GPIO_MASK0x07FF
>  #define AR9531_GPIO_MASK0x000F
>  #define AR9550_GPIO_MASK0x000F
>  #define AR9561_GPIO_MASK0x000F
>

Thanks, changes in reg.h solve the problem (my card AR9462 rev 01).

BR
Janusz

> Thanks,
> Miaoqing
>
> 
> From: Sudip Mukherjee 
> Sent: Wednesday, June 1, 2016 8:18 PM
> To: Pan, Miaoqing; Kalle Valo
> Cc: Stephen Rothwell; ath9k-devel; linux-n...@vger.kernel.org; 
> linux-ker...@vger.kernel.org; linux-wirel...@vger.kernel.org; 
> ath9k-devel@lists.ath9k.org; net...@vger.kernel.org; Miaoqing Pan
> Subject: Re: ath9k gpio request
>
> On Wednesday 01 June 2016 04:42 PM, Sudip Mukherjee wrote:
>> On Wednesday 01 June 2016 12:24 PM, Pan, Miaoqing wrote:
>>> which chip ?  And what's the GPIO number ?
>>
>> lspci -v reports:
>> 09:00.0 Network controller: Qualcomm Atheros AR9462 Wireless Network
>> Adapter (rev 01)
>>  Subsystem: Foxconn International, Inc. Device e052
>>  Flags: bus master, fast devsel, latency 0, IRQ 19
>>  Memory at c050 (64-bit, non-prefetchable) [size=512K]
>>  Expansion ROM at c058 [disabled] [size=64K]
>>  Capabilities: [40] Power Management version 2
>>  Capabilities: [50] MSI: Enable- Count=1/4 Maskable+ 64bit+
>>  Capabilities: [70] Express Endpoint, MSI 00
>>  Capabilities: [100] Advanced Error Reporting
>>  Capabilities: [140] Virtual Channel
>>  Capabilities: [160] Device Serial Number 00-00-00-00-00-00-00-00
>>  Kernel driver in use: ath9k
>>
>> Any easy way to find out the gpio number or i can modify the module to
>> find that out.
>
> Its trying for GPIO 11 with label ath9k-rfkill.
>
> The attached dmesg is with some modification as below.
>
> diff --git a/drivers/net/wireless/ath/ath9k/hw.c
> b/drivers/net/wireless/ath/ath9k/hw.c
> index 8b2895f9..23deea7 100644
> --- a/drivers/net/wireless/ath/ath9k/hw.c
> +++ b/drivers/net/wireless/ath/ath9k/hw.c
> @@ -2729,14 +2729,16 @@ static void ath9k_hw_gpio_cfg_wmac(struct ath_hw
> *ah, u32 gpio, bool out,
>   static void ath9k_hw_gpio_request(struct ath_hw *ah, u32 gpio, bool out,
>const char *label, u32 ah_signal_type)
>   {
> -   WARN_ON(gpio >= ah->caps.num_gpio_pins);
> +// WARN_ON(gpio >= ah->caps.num_gpio_pins);
> +
> +   pr_err("sudip: %d %s\n", gpio, label);
>
>  if (BIT(gpio) & ah->caps.gpio_mask)
>  ath9k_hw_gpio_cfg_wmac(ah, gpio, out, ah_signal_type);
>  else if (AR_SREV_SOC(ah))
>  ath9k_hw_gpio_cfg_soc(ah, gpio, out, label);
> -   else
> -   WARN_ON(1);
> +// else
> +// WARN_ON(1);
>   }
>
> Regards
> Sudip
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] Cryptography of ath9k driver

2016-10-26 Thread Janusz Dziedzic
On 26 October 2016 at 08:53, Jeon  wrote:

> I am investigating how ath9k performs cryptography.
>
> In slide 15 of DEFCON conference 2014 (link
> ),
> it says, ath9k performs cryptography a on software side.
>
> On the other hand, when I look into ath9k source codes, I found somethings
> like below:
>
> ath9k/common.c:162-166:
>
> if (ah->sw_mgmt_crypto_rx &&
>   (rxs->flag & RX_FLAG_DECRYPTED) &&
>   ieee80211_is_mgmt(fc))
>   /* Use software decrypt for management frames. */
>   rxs->flag &= ~RX_FLAG_DECRYPTED;
>
> As I understand, ath9k can choose hw/sw cryptography for management
> frames. However, what about data frames? I couldn't find any clue about
> cryptography for data frames.
>
> Can I take it as ath9k already performs software cryptography for data
> frames and shifts the responsibility of cryptography to mac80211 driver?
> And exceptionally for management frames, can ath9k choose hw/sw
> cryptography?
>
>
modinfo ath9k (check nohwcrypt param)

BR
Janusz
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [question] TBTT value

2016-11-21 Thread Janusz Dziedzic
On 21 November 2016 at 18:06, Gucea Doru  wrote:
> Hello, everyone
>
> We looked at the beacon behavior [1] at the station side and we are
> trying to understand the logic used for computing the nexttbtt -
> Target Beacon Transmission Time - value [2]:
>
> return (u32) tsf + divisor - offset;
>
> What's the reason for taking only 32 bits from TSF - which is 64 bits
> long -  and losing the upper 32 bits?
>
> I noticed that the nexttbtt  value is later used for arming the
> AR_NEXT_TBTT_TIMER [3] but there is no clear explanation related to
> this hardware timer. What is the connection between this hardware
> timer and TSF? My assumption is that, for triggering this timer, the
> value from the timer is continuously compared with the TSF value but I
> can't figure it out how a 32 bit value is compared with a 64 bit
> value.
>
> [1] 
> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/common-beacon.c#L41
> [2] 
> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/common-beacon.c#L30
> [3] 
> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/hw.c?v=4.3#L2278
>

As I remember correctly this is used only in case chan_ctx is used
(driver loaded with use_chanctx=1 and compiled with
ATH9K_CHANNEL_CONTEXT).
This allow to create/use AP and STA on different channels (multichannel case).
We need to send (AP)/ recevie (STA) beacons and because of that we
need to configure timer and switch channels (reseting the chip).
So in common case we switch channels (from ath9k driver) about every 50ms.

ath9k_hw_gen_timer_start() is used here (timer based on jiffies is not
good enough for that) and this required u32.

BR
Janusz

> Thanks,
> Doru
> ___
> ath9k-devel mailing list
> ath9k-devel@lists.ath9k.org
> https://lists.ath9k.org/mailman/listinfo/ath9k-devel
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [question] TBTT value

2016-11-27 Thread Janusz Dziedzic
On 26 November 2016 at 14:18, Gucea Doru  wrote:
> On Tue, Nov 22, 2016 at 9:16 AM, Janusz Dziedzic
>  wrote:
>> On 21 November 2016 at 18:06, Gucea Doru  wrote:
>>> Hello, everyone
>>>
>>> We looked at the beacon behavior [1] at the station side and we are
>>> trying to understand the logic used for computing the nexttbtt -
>>> Target Beacon Transmission Time - value [2]:
>>>
>>> return (u32) tsf + divisor - offset;
>>>
>>> What's the reason for taking only 32 bits from TSF - which is 64 bits
>>> long -  and losing the upper 32 bits?
>>>
>>> I noticed that the nexttbtt  value is later used for arming the
>>> AR_NEXT_TBTT_TIMER [3] but there is no clear explanation related to
>>> this hardware timer. What is the connection between this hardware
>>> timer and TSF? My assumption is that, for triggering this timer, the
>>> value from the timer is continuously compared with the TSF value but I
>>> can't figure it out how a 32 bit value is compared with a 64 bit
>>> value.
>>>
>>> [1] 
>>> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/common-beacon.c#L41
>>> [2] 
>>> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/common-beacon.c#L30
>>> [3] 
>>> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/hw.c?v=4.3#L2278
>>>
>>
>> As I remember correctly this is used only in case chan_ctx is used
>> (driver loaded with use_chanctx=1 and compiled with
>> ATH9K_CHANNEL_CONTEXT).
>> This allow to create/use AP and STA on different channels (multichannel 
>> case).
>> We need to send (AP)/ recevie (STA) beacons and because of that we
>> need to configure timer and switch channels (reseting the chip).
>> So in common case we switch channels (from ath9k driver) about every 50ms.
>>
>> ath9k_hw_gen_timer_start() is used here (timer based on jiffies is not
>> good enough for that) and this required u32.
>>
>
> OK, so you are saying that the AR_NEXT_TBTT_TIMER  might be used for
> supporting MCC. However, I'm not interested in understanding the MCC
> use-case, but the Power-Save one (I enabled it with iwconfig wlan0 set
> power_save on).
>
> The AR_NEXT_TBTT TIMER is set inside the
> ath9k_hw_set_sta_beacon_timers function [1] which also sets the sleep
> registers (AR_SLEEP1 and AR_SLEEP2). The role of the
> AR_NEXT_TBTT_TIMER is to wake up the hardware every time a new beacon
> is received. I'm not sure what should happen when the AR_NEXT_TBTT is
> triggered:
> 1) for ath9k: the interrupt routine, ath_isr [2], is called and the
> hardware enters the ATH9K_PM_AWAKE state, then the receive tasklet is
> scheduled.
> 2) for ath9k_htc: the receive callback, ath9k_htc_rxep [3], is called
> by the firmware, then the receive tasklet is scheduled, then the
> tasklet puts the hardware in the ATH9K_PM_AWAKE state.
>
> From my tests with the ath9k_htc driver I noticed a buggy PS
> behaviour. The biggest problem seems to be that the
> ath9k_hw_set_sta_beacon_timers function is never called, so once the
> hardware enters the PS mode there is no hardware trigger to wake up
> the hardware. However, there is a mac80211 beacon loss software timer
> is the one that wakes up the hardware after 7 lost beacon.
>
ath9k have to receive all beacons - check PVB/Multicast - while don't
use firmware ...

In case of ath9k_htc probably firmware can do that and send beacon
only in case PVB/Multicast changed - no need to wakeup mac80211 each
beacon - but I think you can check this while firmware source are
available ...

BTW, as I remember mac80211 PS is buggy and because of that is
disabled by default in ath9k*

BR
Janusz

> Could you provide me more details about the link between Power Save
> Mode and the hardware triggers/sleep registers from
> ath9k_hw_set_sta_beacon_timers?
> The ath9k_hw_set_sta_beacon_timers should be called every time a
> beacon is received, right?
>
> [1] 
> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/hw.c?v=4.3#L2269
> [2] 
> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/main.c#L486
> [3] 
> http://lxr.free-electrons.com/source/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c?v=2.6.35#L639
>
>
>> BR
>> Janusz
>>
>>> Thanks,
>>> Doru
>>> ___
>>> ath9k-devel mailing list
>>> ath9k-devel@lists.ath9k.org
>>> https://lists.ath9k.org/mailman/listinfo/ath9k-devel
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/2] ath10k: wmi_mgmt_rx setup band

2013-04-16 Thread Janusz Dziedzic
Setup band using wmi_event and phy_mode
reported by FW/HW.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   38 +++--
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 1cb55bb..4d2257a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -240,6 +240,35 @@ static int wmi_event_scan(struct ath10k *ar, struct 
sk_buff *skb)
return 0;
 }
 
+
+static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
+{
+   enum ieee80211_band band;
+
+   switch (phy_mode) {
+   case MODE_11A:
+   case MODE_11NA_HT20:
+   case MODE_11NA_HT40:
+   case MODE_11AC_VHT20:
+   case MODE_11AC_VHT40:
+   case MODE_11AC_VHT80:
+   band = IEEE80211_BAND_5GHZ;
+   break;
+   case MODE_11G:
+   case MODE_11B:
+   case MODE_11GONLY:
+   case MODE_11NG_HT20:
+   case MODE_11NG_HT40:
+   case MODE_11AC_VHT20_2G:
+   case MODE_11AC_VHT40_2G:
+   case MODE_11AC_VHT80_2G:
+   default:
+   band = IEEE80211_BAND_2GHZ;
+   }
+
+   return band;
+}
+
 static int wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
 {
struct wmi_mgmt_rx_event *event = (void *)skb->data;
@@ -247,6 +276,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
struct ieee80211_hdr *hdr;
u32 rx_status;
u32 channel;
+   u32 phy_mode;
u32 snr;
u32 buf_len;
u16 fc;
@@ -255,6 +285,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
buf_len   = __le32_to_cpu(event->hdr.buf_len);
rx_status = __le32_to_cpu(event->hdr.status);
snr   = __le32_to_cpu(event->hdr.snr);
+   phy_mode  = __le32_to_cpu(event->hdr.phy_mode);
 
memset(status, 0, sizeof(*status));
 
@@ -275,12 +306,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
if (rx_status & WMI_RX_STATUS_ERR_MIC)
status->flag |= RX_FLAG_MMIC_ERROR;
 
-   /* FIXME: We probably should use event->phy_mode for that */
-   if (channel > 14)
-   status->band = IEEE80211_BAND_5GHZ;
-   else
-   status->band = IEEE80211_BAND_2GHZ;
-
+   status->band = phy_mode_to_band(phy_mode);
status->freq = ieee80211_channel_to_frequency(channel, status->band);
status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/2] ath10k: wmi_mgmt_rx setup rate info

2013-04-16 Thread Janusz Dziedzic
Setup rate info when receive mgmt frame
via WMI layer.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   64 +++--
 1 file changed, 62 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 4d2257a..82debae 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -269,6 +269,63 @@ static inline enum ieee80211_band phy_mode_to_band(u32 
phy_mode)
return band;
 }
 
+static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band)
+{
+   u8 rate_idx = 0;
+
+   /* rate in Kbps */
+   switch (rate) {
+   case 1000:
+   rate_idx = 0;
+   break;
+   case 2000:
+   rate_idx = 1;
+   break;
+   case 5500:
+   rate_idx = 2;
+   break;
+   case 11000:
+   rate_idx = 3;
+   break;
+   case 6000:
+   rate_idx = 4;
+   break;
+   case 9000:
+   rate_idx = 5;
+   break;
+   case 12000:
+   rate_idx = 6;
+   break;
+   case 18000:
+   rate_idx = 7;
+   break;
+   case 24000:
+   rate_idx = 8;
+   break;
+   case 36000:
+   rate_idx = 9;
+   break;
+   case 48000:
+   rate_idx = 10;
+   break;
+   case 54000:
+   rate_idx = 11;
+   break;
+   default:
+   break;
+   }
+
+   if (band == IEEE80211_BAND_5GHZ) {
+   if (rate_idx > 3)
+   /* Omit CCK rates */
+   rate_idx -= 4;
+   else
+   rate_idx = 0;
+   }
+
+   return rate_idx;
+}
+
 static int wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
 {
struct wmi_mgmt_rx_event *event = (void *)skb->data;
@@ -278,6 +335,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
u32 channel;
u32 phy_mode;
u32 snr;
+   u32 rate;
u32 buf_len;
u16 fc;
 
@@ -286,6 +344,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
rx_status = __le32_to_cpu(event->hdr.status);
snr   = __le32_to_cpu(event->hdr.snr);
phy_mode  = __le32_to_cpu(event->hdr.phy_mode);
+   rate  = __le32_to_cpu(event->hdr.rate);
 
memset(status, 0, sizeof(*status));
 
@@ -309,6 +368,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
status->band = phy_mode_to_band(phy_mode);
status->freq = ieee80211_channel_to_frequency(channel, status->band);
status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
+   status->rate_idx = get_rate_idx(rate, status->band);
 
skb_pull(skb, sizeof(event->hdr));
 
@@ -321,8 +381,8 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
   fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
 
ath10k_dbg(ATH10K_DBG_WMI,
-  "event mgmt rx freq %d band %d snr %d\n",
-  status->freq, status->band, status->signal);
+  "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
+  status->freq, status->band, status->signal, 
status->rate_idx);
 
/*
 * packets from HTC come aligned to 4byte boundaries
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/2] ath10k: don't defer mgmt_rx frames

2013-04-16 Thread Janusz Dziedzic
Don't defer mgmt_rx frames. Pass them
immediately to mac80211 layer. Also
this will prevent mixing context we will
call ieee80211_rx()/ieee80211_tx_status().
Now this will be called from tasklet.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 82debae..2cf9f3b 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1084,6 +1084,9 @@ static void wmi_process_rx(void *ptr, struct sk_buff *skb)
case WMI_HOST_SWBA_EVENTID:
wmi_event_process(wmi, skb);
return;
+   case WMI_MGMT_RX_EVENTID:
+   wmi_event_process(wmi, skb);
+   return;
default:
break;
}
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/2] ath10k: don't use irqsave when rx/tx_status

2013-04-16 Thread Janusz Dziedzic
Don't use ieee80211_rx_irqsave()/ieee80211_tx_status_irqsave()
while we call this function from tasklet.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/txrx.c |6 +++---
 drivers/net/wireless/ath/ath10k/wmi.c  |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/txrx.c 
b/drivers/net/wireless/ath/ath10k/txrx.c
index a40d019..0879a70 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -81,7 +81,7 @@ void ath10k_data_tx_completed(struct htt_struct *htt,
info->flags |= IEEE80211_TX_STAT_ACK;
/* fall through */
case HTT_DATA_TX_STATUS_NO_ACK:
-   ieee80211_tx_status_irqsafe(htt->ar->hw, txi->u.data.msdu);
+   ieee80211_tx_status(htt->ar->hw, txi->u.data.msdu);
break;
case HTT_DATA_TX_STATUS_DISCARD:
/* fall through */
@@ -260,7 +260,7 @@ void ath10k_process_rx(struct ath10k *ar, struct 
htt_rx_info *info)
   status->freq,
   status->band);
 
-   ieee80211_rx_irqsafe(ar->hw, info->skb);
+   ieee80211_rx(ar->hw, info->skb);
 }
 
 void ath10k_mgmt_tx_completed(struct htt_struct *htt,
@@ -295,7 +295,7 @@ void ath10k_mgmt_tx_completed(struct htt_struct *htt,
if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
info->flags |= IEEE80211_TX_STAT_ACK;
 
-   ieee80211_tx_status_irqsafe(htt->ar->hw, msdu);
+   ieee80211_tx_status(htt->ar->hw, msdu);
break;
case HTT_MGMT_TX_STATUS_RETRY:
/* fall through */
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 2cf9f3b..1a331b6 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -390,7 +390,7 @@ static int wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
 */
skb_trim(skb, buf_len);
 
-   ieee80211_rx_irqsafe(ar->hw, skb);
+   ieee80211_rx(ar->hw, skb);
return 0;
 }
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/3] ath10k: kill CE_SEND_CB/CE_RECV_CB

2013-04-18 Thread Janusz Dziedzic
kill typedefs
CE_SEND_CB/CE_RECV_CB

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/ce.c |   17 ++
 drivers/net/wireless/ath/ath10k/ce.h |   43 +-
 2 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ce.c 
b/drivers/net/wireless/ath/ath10k/ce.c
index c7a96c0..3fd4fce 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -667,26 +667,35 @@ void ath10k_ce_disable_interrupts(struct ath10k *ar)
 }
 
 void ath10k_ce_send_cb_register(struct ce_state *ce_state,
-   CE_SEND_CB fn_ptr,
+   void (*send_cb) (struct ce_state *ce_state,
+void 
*per_transfer_send_context,
+u32 buffer,
+unsigned int nbytes,
+unsigned int transfer_id),
int disable_interrupts)
 {
struct ath10k *ar = ce_state->ar;
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 
spin_lock_bh(&ar_pci->ce_lock);
-   ce_state->send_cb = fn_ptr;
+   ce_state->send_cb = send_cb;
ath10k_ce_per_engine_handler_adjust(ce_state, disable_interrupts);
spin_unlock_bh(&ar_pci->ce_lock);
 }
 
 void ath10k_ce_recv_cb_register(struct ce_state *ce_state,
-   CE_RECV_CB fn_ptr)
+   void (*recv_cb) (struct ce_state *ce_state,
+void 
*per_transfer_recv_context,
+u32 buffer,
+unsigned int nbytes,
+unsigned int transfer_id,
+unsigned int flags))
 {
struct ath10k *ar = ce_state->ar;
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 
spin_lock_bh(&ar_pci->ce_lock);
-   ce_state->recv_cb = fn_ptr;
+   ce_state->recv_cb = recv_cb;
ath10k_ce_per_engine_handler_adjust(ce_state, 0);
spin_unlock_bh(&ar_pci->ce_lock);
 }
diff --git a/drivers/net/wireless/ath/ath10k/ce.h 
b/drivers/net/wireless/ath/ath10k/ce.h
index 484fba3..8beb606 100644
--- a/drivers/net/wireless/ath/ath10k/ce.h
+++ b/drivers/net/wireless/ath/ath10k/ce.h
@@ -38,23 +38,6 @@
 
 struct ce_state;
 
-/*
- * Pops 1 completed send buffer from Source ring.
- */
-typedef void (*CE_SEND_CB) (struct ce_state *ce_state,
-   void *per_transfer_send_context,
-   u32 buffer,
-   unsigned int nbytes,
-   unsigned int transfer_id);
-/*
- * Pops 1 completed send buffer from Destination ring.
- */
-typedef void (*CE_RECV_CB) (struct ce_state *ce_state,
-   void *per_transfer_recv_context,
-   u32 buffer,
-   unsigned int nbytes,
-   unsigned int transfer_id,
-   unsigned int flags);
 
 /* Copy Engine operational state */
 enum ce_op_state {
@@ -144,8 +127,17 @@ struct ce_state {
u32 ctrl_addr;
enum ce_op_state state;
 
-   CE_SEND_CB send_cb;
-   CE_RECV_CB recv_cb;
+   void (*send_cb) (struct ce_state *ce_state,
+void *per_transfer_send_context,
+u32 buffer,
+unsigned int nbytes,
+unsigned int transfer_id);
+   void (*recv_cb) (struct ce_state *ce_state,
+void *per_transfer_recv_context,
+u32 buffer,
+unsigned int nbytes,
+unsigned int transfer_id,
+unsigned int flags);
 
unsigned int src_sz_max;
struct ce_ring_state *src_ring;
@@ -200,7 +192,11 @@ int ath10k_ce_send(struct ce_state *ce_state,
   unsigned int flags);
 
 void ath10k_ce_send_cb_register(struct ce_state *ce_state,
-   CE_SEND_CB fn_ptr,
+   void (*send_cb) (struct ce_state *ce_state,
+void 
*per_transfer_send_context,
+u32 buffer,
+unsigned int nbytes,
+unsigned int transfer_id),
int disable_interrupts);
 
 /* Append a simple buffer (address/length) to a sendlist. */
@@ -243,7 +239,12 @@ int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state,
   u32 buffer);
 
 void ath10k_ce_recv_cb_register(struct ce_state *ce_state,
-  

[ath9k-devel] [PATCH 2/3] ath10k: kill WARN_ON in ce.c

2013-04-18 Thread Janusz Dziedzic
Kill WARN_ON in ce.c, use ath10k_warn() instead.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/ce.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/ce.c 
b/drivers/net/wireless/ath/ath10k/ce.c
index 3fd4fce..27b27de 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -82,7 +82,9 @@ static int ath10k_ce_send_nolock(struct ce_state *ce_state,
u32 desc_flags = 0;
int ret = 0;
 
-   WARN_ON(nbytes > ce_state->src_sz_max);
+   if (nbytes > ce_state->src_sz_max)
+   ath10k_warn("%s: send more we can (nbytes: %d, max: %d)\n",
+   __func__, nbytes, ce_state->src_sz_max);
 
TARGET_ACCESS_BEGIN(ar);
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 3/3] ath10k: kill MAX_SSID_LEN define

2013-04-18 Thread Janusz Dziedzic
Use IEEE80211_MAX_SSID_LEN instead.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/core.h |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 193ac31..402cddb 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -34,7 +34,6 @@
 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
 #define WO(_f)  ((_f##_OFFSET) >> 2)
 
-#define MAX_SSID_LEN 32
 #define ATH10K_SCAN_ID 0
 #define WMI_READY_TIMEOUT (5 * HZ)
 #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)
@@ -216,7 +215,7 @@ struct ath10k_vif {
u8 tim_bitmap[16];
u8 tim_len;
u32 ssid_len;
-   u8 ssid[MAX_SSID_LEN];
+   u8 ssid[IEEE80211_MAX_SSID_LEN];
bool hidden_ssid;
/* P2P_IE with NoA attribute for P2P_GO case */
u32 noa_len;
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function

2013-04-18 Thread Janusz Dziedzic
Add ath10k_bmi_read32/ath10k_bmi_write32 functions
and use them in core layer when read32/write32.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/bmi.h  |   10 ++
 drivers/net/wireless/ath/ath10k/core.c |   24 
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/bmi.h 
b/drivers/net/wireless/ath/ath10k/bmi.h
index e2bd70b..2035d5d 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -191,6 +191,16 @@ int ath10k_bmi_read_memory(struct ath10k *ar, u32 address,
   void *buffer, u32 length);
 int ath10k_bmi_write_memory(struct ath10k *ar, u32 address,
const void *buffer, u32 length);
+static inline int ath10k_bmi_read32(struct ath10k *ar, u32 address,
+   void *buffer)
+{
+   return ath10k_bmi_read_memory(ar, address, buffer, sizeof(u32));
+}
+static inline int ath10k_bmi_write32(struct ath10k *ar, u32 address,
+void *buffer)
+{
+   return ath10k_bmi_write_memory(ar, address, buffer, sizeof(u32));
+}
 int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param);
 int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address);
 int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length);
diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 213c851..0934a29 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -150,7 +150,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
param_target = __cpu_to_le32(HTC_PROTOCOL_VERSION);
host_addr = host_interest_item_address(ar->target_type,
   HI_ITEM(hi_app_host_interest));
-   ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ret = ath10k_bmi_write32(ar, host_addr, (u8 *)¶m_target);
if (ret) {
ath10k_err("settings HTC version failed\n");
return ret;
@@ -159,7 +159,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
/* set the firmware mode to STA/IBSS/AP */
host_addr = host_interest_item_address(ar->target_type,
   HI_ITEM(hi_option_flag));
-   ret = ath10k_bmi_read_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ret = ath10k_bmi_read32(ar, host_addr, (u8 *)¶m_target);
param_host = __le32_to_cpu(param_target);
if (ret) {
ath10k_err("setting firmware mode (1/2) failed\n");
@@ -182,7 +182,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
param_target = __cpu_to_le32(param_host);
host_addr = host_interest_item_address(ar->target_type,
   HI_ITEM(hi_option_flag));
-   ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ret = ath10k_bmi_write32(ar, host_addr, (u8 *)¶m_target);
if (ret) {
ath10k_err("setting firmware mode (2/2) failed\n");
return ret;
@@ -192,7 +192,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
/* We do all byte-swapping on the host */
host_addr = host_interest_item_address(ar->target_type,
   HI_ITEM(hi_be));
-   ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ret = ath10k_bmi_write32(ar, host_addr, (u8 *)¶m_target);
if (ret) {
ath10k_err("setting host CPU BE mode failed\n");
return ret;
@@ -202,7 +202,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
param_target = __cpu_to_le32(0);
host_addr = host_interest_item_address(ar->target_type,
   HI_ITEM(hi_fw_swap));
-   ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ret = ath10k_bmi_write32(ar, host_addr, (u8 *)¶m_target);
 
if (ret) {
ath10k_err("setting FW data/desc swap flags failed\n");
@@ -296,7 +296,7 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,
/* Determine where in Target RAM to write Board Data */
host_addr = host_interest_item_address(ar->target_type,
   
HI_ITEM(hi_board_ext_data));
-   ath10k_bmi_read_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ath10k_bmi_read32(ar, host_addr, (u8 *)¶m_target);
board_ext_address = __le32_to_cpu(param_target);
 
ath10k_dbg(ATH10K_DBG_BOOT,
@@ -327,7 +327,7 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,
param_target = __cpu_to_le32((board_ext_data_size << 
1

[ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 functions

2013-04-18 Thread Janusz Dziedzic
Add ath10k_bmi_read32/ath10k_bmi_write32 functions
and use them in core layer when read32/write32.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/bmi.h  |   27 +++
 drivers/net/wireless/ath/ath10k/core.c |   79 +---
 2 files changed, 49 insertions(+), 57 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/bmi.h 
b/drivers/net/wireless/ath/ath10k/bmi.h
index e2bd70b..f431589 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -191,6 +191,33 @@ int ath10k_bmi_read_memory(struct ath10k *ar, u32 address,
   void *buffer, u32 length);
 int ath10k_bmi_write_memory(struct ath10k *ar, u32 address,
const void *buffer, u32 length);
+
+#define ath10k_bmi_read32(ar, item, val)   \
+   ({  \
+   int ret;\
+   u32 addr;   \
+   __le32 tmp; \
+   \
+   addr = host_interest_item_address(ar->target_type,  \
+ HI_ITEM(item));   \
+   ret = ath10k_bmi_read_memory(ar, addr, (u8 *) &tmp, 4); \
+   *val = __le32_to_cpu(tmp);  \
+   ret;\
+})
+
+#define ath10k_bmi_write32(ar, item, val)  \
+   ({  \
+   int ret;\
+   u32 address;\
+   __le32 v = __cpu_to_le32(val);  \
+   \
+   address = host_interest_item_address(ar->target_type,   \
+HI_ITEM(item));\
+   ret = ath10k_bmi_write_memory(ar, address,  \
+(u8 *) &v, sizeof(v)); \
+   ret;\
+   })
+
 int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param);
 int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address);
 int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length);
diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 8cbdc04..8921bd2 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -136,26 +136,19 @@ conn_fail:
 
 static int ath10k_init_configure_target(struct ath10k *ar)
 {
-   __le32 param_target;
u32 param_host;
int ret;
-   u32 host_addr;
 
/* tell target which HTC version it is used*/
-   param_target = __cpu_to_le32(HTC_PROTOCOL_VERSION);
-   host_addr = host_interest_item_address(ar->target_type,
-  HI_ITEM(hi_app_host_interest));
-   ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   param_host = HTC_PROTOCOL_VERSION;
+   ret = ath10k_bmi_write32(ar, hi_app_host_interest, param_host);
if (ret) {
ath10k_err("settings HTC version failed\n");
return ret;
}
 
/* set the firmware mode to STA/IBSS/AP */
-   host_addr = host_interest_item_address(ar->target_type,
-  HI_ITEM(hi_option_flag));
-   ret = ath10k_bmi_read_memory(ar, host_addr, (u8 *)¶m_target, 4);
-   param_host = __le32_to_cpu(param_target);
+   ret = ath10k_bmi_read32(ar, hi_option_flag, ¶m_host);
if (ret) {
ath10k_err("setting firmware mode (1/2) failed\n");
return ret;
@@ -174,30 +167,23 @@ static int ath10k_init_configure_target(struct ath10k *ar)
/* fwsubmode */
param_host |= (0 << HI_OPTION_FW_SUBMODE_SHIFT);
 
-   param_target = __cpu_to_le32(param_host);
-   host_addr = host_interest_item_address(ar->target_type,
-  HI_ITEM(hi_option_flag));
-   ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)¶m_target, 4);
+   ret = ath10k_bmi_write32(ar, hi_option_flag, param_host);
if (ret) {
ath10k_err("setting firmware mode (2/2) failed\n");
return ret;
}
 
-   param_target = __cpu_to_le32(0);
+   param_host = 0;
/* We do all byte-swapping on the host */
-   host_addr = host_interest_item_address(ar->target_type,
-

[ath9k-devel] [RFC] ath10k: kill regtable

2013-04-22 Thread Janusz Dziedzic
Remove register table abstraction layer.
Use direct defines for ar988x.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/Makefile  |4 +-
 drivers/net/wireless/ath/ath10k/ar9888_regtable.c |  167 -
 drivers/net/wireless/ath/ath10k/ar9888_regtable.h |   26 ---
 drivers/net/wireless/ath/ath10k/ar9888def.h   |3 +
 drivers/net/wireless/ath/ath10k/ce.c  |1 -
 drivers/net/wireless/ath/ath10k/ce.h  |6 +-
 drivers/net/wireless/ath/ath10k/core.h|1 -
 drivers/net/wireless/ath/ath10k/pci.c |  179 +-
 drivers/net/wireless/ath/ath10k/pci.h |9 +-
 drivers/net/wireless/ath/ath10k/regtable.c|   43 -
 drivers/net/wireless/ath/ath10k/regtable.h|  206 -
 11 files changed, 97 insertions(+), 548 deletions(-)
 delete mode 100644 drivers/net/wireless/ath/ath10k/ar9888_regtable.c
 delete mode 100644 drivers/net/wireless/ath/ath10k/ar9888_regtable.h
 delete mode 100644 drivers/net/wireless/ath/ath10k/regtable.c
 delete mode 100644 drivers/net/wireless/ath/ath10k/regtable.h

diff --git a/drivers/net/wireless/ath/ath10k/Makefile 
b/drivers/net/wireless/ath/ath10k/Makefile
index efd8798..a4179f4 100644
--- a/drivers/net/wireless/ath/ath10k/Makefile
+++ b/drivers/net/wireless/ath/ath10k/Makefile
@@ -14,9 +14,7 @@ ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o
 
 obj-$(CONFIG_ATH10K_PCI) += ath10k_pci.o
 ath10k_pci-y += pci.o \
-   ce.o \
-   regtable.o \
-   ar9888_regtable.o
+   ce.o
 
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/ath/ath10k/ar9888_regtable.c 
b/drivers/net/wireless/ath/ath10k/ar9888_regtable.c
deleted file mode 100644
index 5e0b25a..000
--- a/drivers/net/wireless/ath/ath10k/ar9888_regtable.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2005-2011 Atheros Communications Inc.
- * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "ar9888_regtable.h"
-#include "ar9888def.h"
-
-/* AR9888_V1 hostdef, targetdef structures */
-static struct targetdef ar9888_target_def = {
-   .D_RTC_SOC_BASE_ADDRESS =   RTC_SOC_BASE_ADDRESS,
-   .D_RTC_WMAC_BASE_ADDRESS =  RTC_WMAC_BASE_ADDRESS,
-   .D_SYSTEM_SLEEP_OFFSET =WLAN_SYSTEM_SLEEP_OFFSET,
-   .D_WLAN_SYSTEM_SLEEP_OFFSET =   WLAN_SYSTEM_SLEEP_OFFSET,
-   .D_WLAN_SYSTEM_SLEEP_DISABLE_LSB =  WLAN_SYSTEM_SLEEP_DISABLE_LSB,
-   .D_WLAN_SYSTEM_SLEEP_DISABLE_MASK = WLAN_SYSTEM_SLEEP_DISABLE_MASK,
-   .D_CLOCK_CONTROL_OFFSET =   CLOCK_CONTROL_OFFSET,
-   .D_CLOCK_CONTROL_SI0_CLK_MASK = CLOCK_CONTROL_SI0_CLK_MASK,
-   .D_RESET_CONTROL_OFFSET =   SOC_RESET_CONTROL_OFFSET,
-   .D_RESET_CONTROL_MBOX_RST_MASK =RESET_CONTROL_MBOX_RST_MASK,
-   .D_RESET_CONTROL_SI0_RST_MASK = RESET_CONTROL_SI0_RST_MASK,
-   .D_WLAN_RESET_CONTROL_OFFSET =  WLAN_RESET_CONTROL_OFFSET,
-   .D_WLAN_RESET_CONTROL_COLD_RST_MASK =   
WLAN_RESET_CONTROL_COLD_RST_MASK,
-   .D_WLAN_RESET_CONTROL_WARM_RST_MASK =   
WLAN_RESET_CONTROL_WARM_RST_MASK,
-   .D_GPIO_BASE_ADDRESS =  GPIO_BASE_ADDRESS,
-   .D_GPIO_PIN0_OFFSET =   GPIO_PIN0_OFFSET,
-   .D_GPIO_PIN1_OFFSET =   GPIO_PIN1_OFFSET,
-   .D_GPIO_PIN0_CONFIG_MASK =  GPIO_PIN0_CONFIG_MASK,
-   .D_GPIO_PIN1_CONFIG_MASK =  GPIO_PIN1_CONFIG_MASK,
-   .D_SI_CONFIG_BIDIR_OD_DATA_LSB =SI_CONFIG_BIDIR_OD_DATA_LSB,
-   .D_SI_CONFIG_BIDIR_OD_DATA_MASK =   SI_CONFIG_BIDIR_OD_DATA_MASK,
-   .D_SI_CONFIG_I2C_LSB =  SI_CONFIG_I2C_LSB,
-   .D_SI_CONFIG_I2C_MASK = SI_CONFIG_I2C_MASK,
-   .D_SI_CONFIG_POS_SAMPLE_LSB =   SI_CONFIG_POS_SAMPLE_LSB,
-   .D_SI_CONFIG_POS_SAMPLE_MASK =  SI_CONFIG_POS_SAMPLE_MASK,
-   .D_SI_CONFIG_INACTIVE_CLK_LSB = SI_CONFIG_INACTIVE_CLK_LSB,
-   .D_SI_CONFIG_INACTIVE_CLK_MASK =SI_CONFIG_INACTIVE_CLK_MASK,
-   

[ath9k-devel] [PATCH] ath10k: ath10k_bmi_write32() calls cleanup

2013-04-22 Thread Janusz Dziedzic
Remove not needed param_host variable,
simplify code.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/core.c |   27 +--
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index b3c1e45..ab49049 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -134,8 +134,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
int ret;
 
/* tell target which HTC version it is used*/
-   param_host = HTC_PROTOCOL_VERSION;
-   ret = ath10k_bmi_write32(ar, hi_app_host_interest, param_host);
+   ret = ath10k_bmi_write32(ar, hi_app_host_interest, 
HTC_PROTOCOL_VERSION);
if (ret) {
ath10k_err("settings HTC version failed\n");
return ret;
@@ -167,17 +166,15 @@ static int ath10k_init_configure_target(struct ath10k *ar)
return ret;
}
 
-   param_host = 0;
/* We do all byte-swapping on the host */
-   ret = ath10k_bmi_write32(ar, hi_be, param_host);
+   ret = ath10k_bmi_write32(ar, hi_be, 0);
if (ret) {
ath10k_err("setting host CPU BE mode failed\n");
return ret;
}
 
/* FW descriptor/Data swap flags */
-   param_host = 0;
-   ret = ath10k_bmi_write32(ar, hi_fw_swap, param_host);
+   ret = ath10k_bmi_write32(ar, hi_fw_swap, 0);
 
if (ret) {
ath10k_err("setting FW data/desc swap flags failed\n");
@@ -197,7 +194,6 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,
u32 fw_entry_size;
u8 *temp_eeprom = NULL, *fw_buf = NULL;
u32 board_data_size;
-   u32 param_host;
 
switch (file) {
default:
@@ -293,8 +289,8 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,
/*
 * Record the fact that extended board Data IS 
initialized
 */
-   param_host = (board_ext_data_size << 16) | 1;
-   ath10k_bmi_write32(ar, hi_board_ext_data_config, 
param_host);
+   ath10k_bmi_write32(ar, hi_board_ext_data_config,
+  (board_ext_data_size << 16) | 1);
 
fw_entry_size = board_data_size;
}
@@ -347,8 +343,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
}
 
/* Record the fact that Board Data is initialized */
-   param_host = 1;
-   ath10k_bmi_write32(ar, hi_board_data_initialized, param_host);
+   ath10k_bmi_write32(ar, hi_board_data_initialized, 1);
 
/* Transfer One Time Programmable data */
address = ar->hw_params.patch_load_addr;
@@ -376,18 +371,14 @@ static int ath10k_init_download_firmware(struct ath10k 
*ar)
 
if (uart_print) {
/* Configure GPIO AR9888 UART */
-   param_host = 7;
-   ath10k_bmi_write32(ar, hi_dbg_uart_txpin, param_host);
-
-   param_host = 1;
-   ath10k_bmi_write32(ar, hi_serial_enable, param_host);
+   ath10k_bmi_write32(ar, hi_dbg_uart_txpin, 7);
+   ath10k_bmi_write32(ar, hi_serial_enable, 1);
} else {
/*
 * Explicitly setting UART prints to zero as target turns it on
 * based on scratch registers.
 */
-   param_host = 0;
-   ath10k_bmi_write32(ar, hi_serial_enable, param_host);
+   ath10k_bmi_write32(ar, hi_serial_enable, 0);
}
 
ath10k_dbg(ATH10K_DBG_CORE, "Firmware downloaded\n");
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath10k: kill ar9888def.h file

2013-04-22 Thread Janusz Dziedzic
Move ar9888 definitions to hw.h file.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/ar9888def.h |  237 ---
 drivers/net/wireless/ath/ath10k/hw.h|  217 
 drivers/net/wireless/ath/ath10k/pci.h   |2 +-
 3 files changed, 218 insertions(+), 238 deletions(-)
 delete mode 100644 drivers/net/wireless/ath/ath10k/ar9888def.h

diff --git a/drivers/net/wireless/ath/ath10k/ar9888def.h 
b/drivers/net/wireless/ath/ath10k/ar9888def.h
deleted file mode 100644
index 85e9265..000
--- a/drivers/net/wireless/ath/ath10k/ar9888def.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2005-2011 Atheros Communications Inc.
- * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _AR9888DEF_H_
-#define _AR9888DEF_H_
-
-#include "targaddrs.h"
-
-/* Number of Copy Engines supported */
-#define CE_COUNT 8
-
-/*
- * Total number of PCIe MSI interrupts requested for all interrupt sources.
- * PCIe standard forces this to be a power of 2.
- * Some Host OS's limit MSI requests that can be granted to 8
- * so for now we abide by this limit and avoid requesting more
- * than that.
- */
-#define MSI_NUM_REQUEST_LOG2   3
-#define MSI_NUM_REQUEST(1<> RTC_STATE_V_LSB)
-
-#endif /* __ATH10K_AR9888DEF_H__ */
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index d0ca76d..c900514 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -18,6 +18,8 @@
 #ifndef _HW_H_
 #define _HW_H_
 
+#include "targaddrs.h"
+
 #define TARGET_TYPE_AR9888 7
 
 /* Supported FW version */
@@ -71,4 +73,219 @@
 #define TARGET_VOW_CONFIG  0
 #define TARGET_NUM_MSDU_DESC   (1024 + 400)
 
+
+/* Number of Copy Engines supported */
+#define CE_COUNT 8
+
+/*
+ * Total number of PCIe MSI interrupts requested for all interrupt sources.
+ * PCIe standard forces this to be a power of 2.
+ * Some Host OS's limit MSI requests that can be granted to 8
+ * so for now we abide by this limit and avoid requesting more
+ * than that.
+ */
+#define MSI_NUM_REQUEST_LOG2   3
+#define MSI_NUM_REQUEST(1<> RTC_STATE_V_LSB)
+
 #endif /* _HW_H_ */
diff --git a/drivers/net/wireless/ath/ath10k/pci.h 
b/drivers/net/wireless/ath/ath10k/pci.h
index 093e874..7630217 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -20,7 +20,7 @@
 
 #include 
 
-#include "ar9888def.h"
+#include "hw.h"
 #include "ce.h"
 
 /*
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath10k: Handle P2P_GO NOA notification FW 599+

2013-04-23 Thread Janusz Dziedzic
In FW 599+ NOA structure was changed. So we have
to change this in case of using newest firmware.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   14 +++---
 drivers/net/wireless/ath/ath10k/wmi.h |   22 +++---
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 3de4bb2..540c6d2 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -539,12 +539,12 @@ static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
   struct wmi_p2p_noa_info *noa)
 {
struct ath10k_p2p_noa_attr *noa_attr;
-   u8  ctwindow_oppps = (u8) __le32_to_cpu(noa->opp_ps_info);
+   u8  ctwindow_oppps = noa->ctwindow_oppps;
u8 ctwindow = ctwindow_oppps >> WMI_P2P_OPPPS_CTWINDOW_OFFSET;
bool oppps = !!(ctwindow_oppps & WMI_P2P_OPPPS_ENABLE_BIT);
__le16 *noa_attr_len;
u16 attr_len;
-   u32 noa_descriptors = __le32_to_cpu(noa->num_descriptors);
+   u8 noa_descriptors = noa->num_descriptors;
int i;
 
/* P2P IE */
@@ -560,7 +560,7 @@ static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
noa_attr_len = (__le16 *) &data[7]; /* 2 bytes */
noa_attr = (struct ath10k_p2p_noa_attr *) &data[9];
 
-   noa_attr->index = __le32_to_cpu(noa->index);
+   noa_attr->index = noa->index;
noa_attr->oppps_ctwindow = ctwindow;
if (oppps)
noa_attr->oppps_ctwindow |= ATH10K_P2P_OPPPS_ENABLE_BIT;
@@ -582,8 +582,8 @@ static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
 static u32 ath10k_p2p_calc_noa_ie_len(struct wmi_p2p_noa_info *noa)
 {
u32 len = 0;
-   u32 noa_descriptors = __le32_to_cpu(noa->num_descriptors);
-   u8 opp_ps_info = (u8) __le32_to_cpu(noa->opp_ps_info);
+   u8 noa_descriptors = noa->num_descriptors;
+   u8 opp_ps_info = noa->ctwindow_oppps;
bool opps_enabled = !!(opp_ps_info & WMI_P2P_OPPPS_ENABLE_BIT);
 
 
@@ -609,8 +609,8 @@ static void ath10k_wmi_update_noa(struct ath10k *ar, struct 
ath10k_vif *arvif,
if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
return;
 
-   ath10k_dbg(ATH10K_DBG_BEACON, "noa changed: %d\n", 
noa->p2p_noa_changed);
-   if (noa->p2p_noa_changed) {
+   ath10k_dbg(ATH10K_DBG_BEACON, "noa changed: %d\n", noa->changed);
+   if (noa->changed & WMI_P2P_NOA_CHANGED_BIT) {
new_len = ath10k_p2p_calc_noa_ie_len(noa);
if (!new_len)
goto cleanup;
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 2bb8f0a..eb9c8d4 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2406,20 +2406,20 @@ struct wmi_quiet_info {
 #define WMI_P2P_MAX_NOA_DESCRIPTORS 4
 #define WMI_P2P_OPPPS_ENABLE_BIT   BIT(0)
 #define WMI_P2P_OPPPS_CTWINDOW_OFFSET  1
+#define WMI_P2P_NOA_CHANGED_BITBIT(0)
 
 struct wmi_p2p_noa_info {
-   /* Flag to indicate an update in NOA schedule */
-   __le32 p2p_noa_changed;
-   /* Identifies the instance of NOA sub element */
-   __le32 index;
-   /*
-* Bit 0:   Opp PS state of the AP
-* Bits 1-7:Ctwindow in TUs
-* Bits 8-31:   Reserved
-*/
-   __le32 opp_ps_info;
+   /* Bit 0 - Flag to indicate an update in NOA schedule
+  Bits 7-1 - Reserved */
+   u8 changed;
+   /* NOA index */
+   u8 index;
+   /* Bit 0 - Opp PS state of the AP
+  Bits 1-7 - Ctwindow in TUs */
+   u8 ctwindow_oppps;
/* Number of NOA descriptors */
-   __le32 num_descriptors;
+   u8 num_descriptors;
+
struct wmi_p2p_noa_descriptor 
noa_descriptors[WMI_P2P_MAX_NOA_DESCRIPTORS];
 } __packed;
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath10k: kill static int max_delay

2013-04-23 Thread Janusz Dziedzic
Kill static variable max_delay.
Move this to struct ath10k_pci.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/pci.c |5 ++---
 drivers/net/wireless/ath/ath10k/pci.h |2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index 0d1523b..9ee678a 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -445,7 +445,6 @@ void ath10k_do_pci_wake(struct ath10k *ar)
 {
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
void __iomem *pci_addr = ar_pci->mem;
-   static int max_delay;
int tot_delay = 0;
int curr_delay = 5;
 
@@ -475,8 +474,8 @@ void ath10k_do_pci_wake(struct ath10k *ar)
curr_delay += 5;
}
 
-   if (tot_delay > max_delay)
-   max_delay = tot_delay;
+   if (tot_delay > ar_pci->max_delay)
+   ar_pci->max_delay = tot_delay;
 }
 
 void ath10k_do_pci_sleep(struct ath10k *ar)
diff --git a/drivers/net/wireless/ath/ath10k/pci.h 
b/drivers/net/wireless/ath/ath10k/pci.h
index 188593e..70d3b12 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -222,6 +222,8 @@ struct ath10k_pci {
 
bool hw_v1_workaround;
spinlock_t hw_v1_workaround_lock;
+
+   int max_delay;
 };
 
 static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH v2] ath10k: kill static int max_delay

2013-04-24 Thread Janusz Dziedzic
Kill not used max_delay variable

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/pci.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index 40ca6d3..861da39 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -431,7 +431,6 @@ void ath10k_do_pci_wake(struct ath10k *ar)
 {
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
void __iomem *pci_addr = ar_pci->mem;
-   static int max_delay;
int tot_delay = 0;
int curr_delay = 5;
 
@@ -460,9 +459,6 @@ void ath10k_do_pci_wake(struct ath10k *ar)
if (curr_delay < 50)
curr_delay += 5;
}
-
-   if (tot_delay > max_delay)
-   max_delay = tot_delay;
 }
 
 void ath10k_do_pci_sleep(struct ath10k *ar)
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/2] ath10k: use ieee80211 NoA definitions

2013-04-29 Thread Janusz Dziedzic
Remove internal types definition and
use ieee80211/cfg80211 notice of absence definitions.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   10 +-
 drivers/net/wireless/ath/ath10k/wmi.h |   18 --
 2 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 8d542e5..2d4c7d9 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -538,7 +538,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, struct 
ath10k_vif *arvif,
 static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
   struct wmi_p2p_noa_info *noa)
 {
-   struct ath10k_p2p_noa_attr *noa_attr;
+   struct ieee80211_p2p_noa_attr *noa_attr;
u8  ctwindow_oppps = noa->ctwindow_oppps;
u8 ctwindow = ctwindow_oppps >> WMI_P2P_OPPPS_CTWINDOW_OFFSET;
bool oppps = !!(ctwindow_oppps & WMI_P2P_OPPPS_ENABLE_BIT);
@@ -558,12 +558,12 @@ static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
/* NOA ATTR */
data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE;
noa_attr_len = (__le16 *) &data[7]; /* 2 bytes */
-   noa_attr = (struct ath10k_p2p_noa_attr *) &data[9];
+   noa_attr = (struct ieee80211_p2p_noa_attr *) &data[9];
 
noa_attr->index = noa->index;
noa_attr->oppps_ctwindow = ctwindow;
if (oppps)
-   noa_attr->oppps_ctwindow |= ATH10K_P2P_OPPPS_ENABLE_BIT;
+   noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT;
 
for (i = 0; i < noa_descriptors; i++) {
noa_attr->desc[i].count =
@@ -575,7 +575,7 @@ static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
}
 
attr_len = 2; /* index + oppps_ctwindow */
-   attr_len += noa_descriptors * sizeof(struct ath10k_p2p_noa_desc);
+   attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc);
*noa_attr_len = __cpu_to_le16(attr_len);
 }
 
@@ -593,7 +593,7 @@ static u32 ath10k_p2p_calc_noa_ie_len(struct 
wmi_p2p_noa_info *noa)
len += 1 + 1 + 4; /* EID + len + OUI */
len += 1 + 2; /* noa attr  + attr len */
len += 1 + 1; /* index + oppps_ctwindow */
-   len += noa_descriptors * sizeof(struct ath10k_p2p_noa_desc);
+   len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc);
 
return len;
 }
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 9946a51..986f0c1 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2766,24 +2766,6 @@ struct wmi_add_bcn_filter_cmd {
 /* By default disable power save for IBSS */
 #define ATH10K_DEFAULT_ATIM 0
 
-
-/* TODO to be removed when cfg80211 changes will be merged:
-   cfg80211: add P2P Notice of Absence attribute */
-struct ath10k_p2p_noa_desc {
-   u8 count;
-   __le32 duration;
-   __le32 interval;
-   __le32 start_time;
-} __packed;
-
-struct ath10k_p2p_noa_attr {
-   u8 index;
-   u8 oppps_ctwindow;
-   struct ath10k_p2p_noa_desc desc[4];
-} __packed;
-
-#define ATH10K_P2P_OPPPS_ENABLE_BITBIT(7)
-
 struct ath10k;
 struct ath10k_vif;
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 2/2] ath10k: WMI wmi_bcn_info update

2013-04-29 Thread Janusz Dziedzic
Sync with FW ver .614 - wmi_bcn_info structure.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.h |9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 986f0c1..d32ba23 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2408,14 +2408,6 @@ struct wmi_tim_info {
__le32 tim_num_ps_pending;
 } __packed;
 
-struct wmi_quiet_info {
-   __le32 is_enabled;
-   __le32 tbttcount;
-   __le32 period;
-   __le32 duration;
-   __le32 offset;
-} __packed;
-
 /* Maximum number of NOA Descriptors supported */
 #define WMI_P2P_MAX_NOA_DESCRIPTORS 4
 #define WMI_P2P_OPPPS_ENABLE_BIT   BIT(0)
@@ -2439,7 +2431,6 @@ struct wmi_p2p_noa_info {
 
 struct wmi_bcn_info {
struct wmi_tim_info tim_info;
-   struct wmi_quiet_info quiet_info;
struct wmi_p2p_noa_info p2p_noa_info;
 } __packed;
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [RFC/RFT 1/2] ath10k: WMI add AP PS

2013-04-30 Thread Janusz Dziedzic
Add AP power save (UAPSD) structures, enums.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   26 +
 drivers/net/wireless/ath/ath10k/wmi.h |   67 +
 2 files changed, 93 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 5272f18..453138b 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1850,6 +1850,32 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 
vdev_id,
return ath10k_wmi_cmd_send(ar, skb, WMI_STA_POWERSAVE_PARAM_CMDID);
 }
 
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value)
+{
+   struct wmi_ap_ps_peer_cmd *cmd;
+   struct sk_buff *skb;
+
+   if (!mac)
+   return -EINVAL;
+
+   skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+   if (!skb)
+   return -ENOMEM;
+
+   cmd = (struct wmi_ap_ps_peer_cmd *) skb->data;
+   cmd->vdev_id = __cpu_to_le32(vdev_id);
+   cmd->param_id= __cpu_to_le32(param_id);
+   cmd->param_value = __cpu_to_le32(value);
+   memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
+
+   ath10k_dbg(ATH10K_DBG_WMI,
+  "wmi ap ps param vdev_id 0x%X param %d value %d "
+  "mac_addr %pM\n", vdev_id, param_id, value, mac);
+
+   return ath10k_wmi_cmd_send(ar, skb, WMI_AP_PS_PEER_PARAM_CMDID);
+}
+
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 9946a51..b9f5b62 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2397,6 +2397,71 @@ struct wmi_sta_mimo_ps_mode_cmd {
__le32 mimo_pwrsave_mode;
 } __packed;
 
+
+/* U-APSD configuration of peer station from (re)assoc request and TSPECs */
+enum wmi_ap_ps_param_uapsd {
+   WMI_AP_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
+   WMI_AP_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
+   WMI_AP_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
+   WMI_AP_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
+   WMI_AP_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
+   WMI_AP_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
+   WMI_AP_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
+   WMI_AP_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
+};
+
+/* U-APSD maximum service period of peer station */
+enum wmi_ap_ps_peer_param_max_sp {
+   WMI_AP_PS_PEER_PARAM_MAX_SP_UNLIMITED = 0,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_2 = 1,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_4 = 2,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_6 = 3,
+   /* keep last! */
+   MAX_WMI_AP_PS_PEER_PARAM_MAX_SP,
+};
+
+/*
+ * AP power save parameter
+ * Set a power save specific parameter for a peer station
+ */
+enum wmi_ap_ps_peer_param {
+   /* Set uapsd configuration for a given peer.
+*
+* This will include the delivery and trigger enabled state for every 
AC.
+* The host  MLME needs to set this based on AP capability and stations
+* request Set in the association request  received from the station.
+*
+* Lower 8 bits of the value specify the UAPSD configuration.
+*
+* (see enum wmi_ap_ps_param_uapsd)
+* The default value is 0.
+*/
+   WMI_AP_PS_PEER_PARAM_UAPSD = 0,
+
+   /**
+* Set the service period for a UAPSD capable station
+*
+* The service period from wme ie in the (re)assoc request frame.
+*
+* (see enum wmi_ap_ps_peer_param_max_sp)
+*/
+   WMI_AP_PS_PEER_PARAM_MAX_SP = 1,
+
+   /** Time in seconds for aging out buffered frames for STA in power save 
*/
+   WMI_AP_PS_PEER_PARAM_AGEOUT_TIME = 2,
+};
+
+struct wmi_ap_ps_peer_cmd {
+   /** unique id identifying the VDEV, generated by the caller */
+   __le32 vdev_id;
+   /** peer MAC address */
+   struct wmi_mac_addr peer_macaddr;
+   /** AP powersave param (see enum wmi_ap_ps_peer_param) */
+   __le32 param_id;
+   /** AP powersave param value */
+   __le32 param_value;
+} __packed;
+
 /* 128 clients = 4 words */
 #define WMI_TIM_BITMAP_ARRAY_SIZE 4
 
@@ -2836,6 +2901,8 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
 int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
enum wmi_sta_powersave_param param_id,
u32 value);
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value);
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg);
 int at

[ath9k-devel] [RFC/RFT 2/2] ath10k: add AP UAPSD support

2013-04-30 Thread Janusz Dziedzic
Add support for AP (P2P_GO) UAPSD.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/mac.c |   43 -
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 5b433ee..94ac7b8 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -873,7 +873,7 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar,
 }
 
 /*
- * FIXME: Handle UAPSD later.
+ * FIXME: Handle STA UAPSD later.
  */
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
struct ath10k_vif *arvif,
@@ -881,9 +881,49 @@ static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
struct ieee80211_bss_conf *bss_conf,
struct wmi_peer_assoc_complete_arg *arg)
 {
+   u32 uapsd = 0;
+   u32 max_sp = 0;
+
if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
if (sta->wme)
arg->peer_flags |= WMI_PEER_QOS;
+
+   if (sta->wme && sta->uapsd_queues) {
+
+   ath10k_dbg(ATH10K_DBG_MAC, "uapsd_queues: 0x%X, "
+  "max_sp: %d\n", sta->uapsd_queues,
+  sta->max_sp);
+
+   arg->peer_flags |= WMI_PEER_APSD;
+
+   if (sta->uapsd_queues & 
IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
+   uapsd |= WMI_AP_PS_UAPSD_AC0_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC0_TRIGGER_EN;
+   if (sta->uapsd_queues & 
IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
+   uapsd |= WMI_AP_PS_UAPSD_AC1_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC1_TRIGGER_EN;
+   if (sta->uapsd_queues & 
IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
+   uapsd |= WMI_AP_PS_UAPSD_AC2_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC2_TRIGGER_EN;
+   if (sta->uapsd_queues & 
IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
+   uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC3_TRIGGER_EN;
+
+
+   if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP)
+   max_sp = sta->max_sp;
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_UAPSD,
+  uapsd);
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_MAX_SP,
+  max_sp);
+   }
+
} else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
if (bss_conf->qos)
arg->peer_flags |= WMI_PEER_QOS;
@@ -2721,6 +2761,7 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
ar->hw->wiphy->max_remain_on_channel_duration = 5000;
 
+   ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
/*
 * on LL hardware queues are managed entirely by the FW
 * so we only advertise to mac we can do the queues thing
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [RFC/RFT v2 1/2] ath10k: WMI add AP PS

2013-05-06 Thread Janusz Dziedzic
Add AP power save (UAPSD) structures, enums.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   26 +
 drivers/net/wireless/ath/ath10k/wmi.h |   68 +
 2 files changed, 94 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 3b819c8..20f0ea5 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1908,6 +1908,32 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 
vdev_id,
return ath10k_wmi_cmd_send(ar, skb, WMI_STA_POWERSAVE_PARAM_CMDID);
 }
 
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value)
+{
+   struct wmi_ap_ps_peer_cmd *cmd;
+   struct sk_buff *skb;
+
+   if (!mac)
+   return -EINVAL;
+
+   skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+   if (!skb)
+   return -ENOMEM;
+
+   cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
+   cmd->vdev_id = __cpu_to_le32(vdev_id);
+   cmd->param_id= __cpu_to_le32(param_id);
+   cmd->param_value = __cpu_to_le32(value);
+   memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
+
+   ath10k_dbg(ATH10K_DBG_WMI,
+  "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr 
%pM\n",
+  vdev_id, param_id, value, mac);
+
+   return ath10k_wmi_cmd_send(ar, skb, WMI_AP_PS_PEER_PARAM_CMDID);
+}
+
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 2ad0431..8d482ab 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2461,6 +2461,72 @@ struct wmi_sta_mimo_ps_mode_cmd {
__le32 mimo_pwrsave_mode;
 } __packed;
 
+/* U-APSD configuration of peer station from (re)assoc request and TSPECs */
+enum wmi_ap_ps_param_uapsd {
+   WMI_AP_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
+   WMI_AP_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
+   WMI_AP_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
+   WMI_AP_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
+   WMI_AP_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
+   WMI_AP_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
+   WMI_AP_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
+   WMI_AP_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
+};
+
+/* U-APSD maximum service period of peer station */
+enum wmi_ap_ps_peer_param_max_sp {
+   WMI_AP_PS_PEER_PARAM_MAX_SP_UNLIMITED = 0,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_2 = 1,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_4 = 2,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_6 = 3,
+   MAX_WMI_AP_PS_PEER_PARAM_MAX_SP,
+};
+
+/*
+ * AP power save parameter
+ * Set a power save specific parameter for a peer station
+ */
+enum wmi_ap_ps_peer_param {
+   /* Set uapsd configuration for a given peer.
+*
+* Include the delivery and trigger enabled state for every AC.
+* The host  MLME needs to set this based on AP capability and stations
+* request Set in the association request  received from the station.
+*
+* Lower 8 bits of the value specify the UAPSD configuration.
+*
+* (see enum wmi_ap_ps_param_uapsd)
+* The default value is 0.
+*/
+   WMI_AP_PS_PEER_PARAM_UAPSD = 0,
+
+   /*
+* Set the service period for a UAPSD capable station
+*
+* The service period from wme ie in the (re)assoc request frame.
+*
+* (see enum wmi_ap_ps_peer_param_max_sp)
+*/
+   WMI_AP_PS_PEER_PARAM_MAX_SP = 1,
+
+   /* Time in seconds for aging out buffered frames for STA in PS */
+   WMI_AP_PS_PEER_PARAM_AGEOUT_TIME = 2,
+};
+
+struct wmi_ap_ps_peer_cmd {
+   /* unique id identifying the VDEV, generated by the caller */
+   __le32 vdev_id;
+
+   /* peer MAC address */
+   struct wmi_mac_addr peer_macaddr;
+
+   /* AP powersave param (see enum wmi_ap_ps_peer_param) */
+   __le32 param_id;
+
+   /* AP powersave param value */
+   __le32 param_value;
+} __packed;
+
 /* 128 clients = 4 words */
 #define WMI_TIM_BITMAP_ARRAY_SIZE 4
 
@@ -2876,6 +2942,8 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
 int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
enum wmi_sta_powersave_param param_id,
u32 value);
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value);
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg);
 int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_a

[ath9k-devel] [RFC/RFT v2 2/2] ath10k: add AP UAPSD support

2013-05-06 Thread Janusz Dziedzic
Add support for AP (P2P_GO) UAPSD.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/mac.c |   84 ++---
 1 file changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index b5cc3c8..833b53e 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -886,21 +886,90 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar,
   arg->peer_num_spatial_streams);
 }
 
+static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar,
+  struct ath10k_vif *arvif,
+  struct ieee80211_sta *sta,
+  struct ieee80211_bss_conf *bss_conf,
+  struct wmi_peer_assoc_complete_arg *arg)
+{
+   u32 uapsd = 0;
+   u32 max_sp = 0;
+
+   if (sta->wme)
+   arg->peer_flags |= WMI_PEER_QOS;
+
+   if (sta->wme && sta->uapsd_queues) {
+   ath10k_dbg(ATH10K_DBG_MAC, "uapsd_queues: 0x%X, max_sp: %d\n",
+  sta->uapsd_queues, sta->max_sp);
+
+   arg->peer_flags |= WMI_PEER_APSD;
+
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
+   uapsd |= WMI_AP_PS_UAPSD_AC0_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC0_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
+   uapsd |= WMI_AP_PS_UAPSD_AC1_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC1_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
+   uapsd |= WMI_AP_PS_UAPSD_AC2_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC2_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
+   uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC3_TRIGGER_EN;
+
+
+   if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP)
+   max_sp = sta->max_sp;
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_UAPSD,
+  uapsd);
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_MAX_SP,
+  max_sp);
+
+   /* TODO setup this based on STA listen interval and
+  beacon interval. Currently we don't know
+  sta->listen_interval - mac80211 patch required.
+  Currently use 10 seconds */
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_AGEOUT_TIME,
+  10);
+   }
+}
+
 /*
- * FIXME: Handle UAPSD later.
+ * FIXME: Handle STA UAPSD later.
  */
+static void ath10k_peer_assoc_h_qos_sta(struct ath10k *ar,
+   struct ath10k_vif *arvif,
+   struct ieee80211_sta *sta,
+   struct ieee80211_bss_conf *bss_conf,
+   struct wmi_peer_assoc_complete_arg *arg)
+{
+   if (bss_conf->qos)
+   arg->peer_flags |= WMI_PEER_QOS;
+}
+
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
struct ath10k_vif *arvif,
struct ieee80211_sta *sta,
struct ieee80211_bss_conf *bss_conf,
struct wmi_peer_assoc_complete_arg *arg)
 {
-   if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
-   if (sta->wme)
-   arg->peer_flags |= WMI_PEER_QOS;
-   } else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
-   if (bss_conf->qos)
-   arg->peer_flags |= WMI_PEER_QOS;
+   switch (arvif->vdev_type) {
+   case WMI_VDEV_TYPE_AP:
+   ath10k_peer_assoc_h_qos_ap(ar, arvif, sta, bss_conf, arg);
+   break;
+   case WMI_VDEV_TYPE_STA:
+   ath10k_peer_assoc_h_qos_sta(ar, arvif, sta, bss_conf, arg);
+   break;
+   default:
+   break;
}
 }
 
@@ -2776,6 +2845,7 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
ar->hw->wiphy->max_remain_on_chan

[ath9k-devel] [PATCH 0/3] UAPSD support for STA/AP mode

2013-05-08 Thread Janusz Dziedzic
First two paches add PS/UAPSD support for AP/P2P_GO mode.
Last one enable UAPSD for STA mode.

In case of FW issues we can easy disable this features by cleaning:
IEEE80211_HW_SUPPORTS_UAPSD/WIPHY_FLAG_AP_UAPSD still have code included.


Janusz Dziedzic (3):
  ath10k: WMI add AP PS
  ath10k: add AP UAPSD support
  ath10k: enable STA UAPSD support

 drivers/net/wireless/ath/ath10k/core.h |1 +
 drivers/net/wireless/ath/ath10k/mac.c  |  165 +---
 drivers/net/wireless/ath/ath10k/wmi.c  |   26 +
 drivers/net/wireless/ath/ath10k/wmi.h  |   68 +
 4 files changed, 249 insertions(+), 11 deletions(-)

-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH 1/3] ath10k: WMI add AP PS

2013-05-08 Thread Janusz Dziedzic
Add AP power save (UAPSD) structures, enums.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   26 +
 drivers/net/wireless/ath/ath10k/wmi.h |   68 +
 2 files changed, 94 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 15e8123..c5f6fda 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1896,6 +1896,32 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 
vdev_id,
return ath10k_wmi_cmd_send(ar, skb, WMI_STA_POWERSAVE_PARAM_CMDID);
 }
 
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value)
+{
+   struct wmi_ap_ps_peer_cmd *cmd;
+   struct sk_buff *skb;
+
+   if (!mac)
+   return -EINVAL;
+
+   skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+   if (!skb)
+   return -ENOMEM;
+
+   cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
+   cmd->vdev_id = __cpu_to_le32(vdev_id);
+   cmd->param_id= __cpu_to_le32(param_id);
+   cmd->param_value = __cpu_to_le32(value);
+   memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
+
+   ath10k_dbg(ATH10K_DBG_WMI,
+  "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr 
%pM\n",
+  vdev_id, param_id, value, mac);
+
+   return ath10k_wmi_cmd_send(ar, skb, WMI_AP_PS_PEER_PARAM_CMDID);
+}
+
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 2ad0431..8d482ab 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2461,6 +2461,72 @@ struct wmi_sta_mimo_ps_mode_cmd {
__le32 mimo_pwrsave_mode;
 } __packed;
 
+/* U-APSD configuration of peer station from (re)assoc request and TSPECs */
+enum wmi_ap_ps_param_uapsd {
+   WMI_AP_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
+   WMI_AP_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
+   WMI_AP_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
+   WMI_AP_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
+   WMI_AP_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
+   WMI_AP_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
+   WMI_AP_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
+   WMI_AP_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
+};
+
+/* U-APSD maximum service period of peer station */
+enum wmi_ap_ps_peer_param_max_sp {
+   WMI_AP_PS_PEER_PARAM_MAX_SP_UNLIMITED = 0,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_2 = 1,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_4 = 2,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_6 = 3,
+   MAX_WMI_AP_PS_PEER_PARAM_MAX_SP,
+};
+
+/*
+ * AP power save parameter
+ * Set a power save specific parameter for a peer station
+ */
+enum wmi_ap_ps_peer_param {
+   /* Set uapsd configuration for a given peer.
+*
+* Include the delivery and trigger enabled state for every AC.
+* The host  MLME needs to set this based on AP capability and stations
+* request Set in the association request  received from the station.
+*
+* Lower 8 bits of the value specify the UAPSD configuration.
+*
+* (see enum wmi_ap_ps_param_uapsd)
+* The default value is 0.
+*/
+   WMI_AP_PS_PEER_PARAM_UAPSD = 0,
+
+   /*
+* Set the service period for a UAPSD capable station
+*
+* The service period from wme ie in the (re)assoc request frame.
+*
+* (see enum wmi_ap_ps_peer_param_max_sp)
+*/
+   WMI_AP_PS_PEER_PARAM_MAX_SP = 1,
+
+   /* Time in seconds for aging out buffered frames for STA in PS */
+   WMI_AP_PS_PEER_PARAM_AGEOUT_TIME = 2,
+};
+
+struct wmi_ap_ps_peer_cmd {
+   /* unique id identifying the VDEV, generated by the caller */
+   __le32 vdev_id;
+
+   /* peer MAC address */
+   struct wmi_mac_addr peer_macaddr;
+
+   /* AP powersave param (see enum wmi_ap_ps_peer_param) */
+   __le32 param_id;
+
+   /* AP powersave param value */
+   __le32 param_value;
+} __packed;
+
 /* 128 clients = 4 words */
 #define WMI_TIM_BITMAP_ARRAY_SIZE 4
 
@@ -2876,6 +2942,8 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
 int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
enum wmi_sta_powersave_param param_id,
u32 value);
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value);
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg);
 int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_a

[ath9k-devel] [PATCH 2/3] ath10k: add AP UAPSD support

2013-05-08 Thread Janusz Dziedzic
Add support for AP (P2P_GO) UAPSD.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/mac.c |   85 ++---
 1 file changed, 78 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 930a092..91de248 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -886,21 +886,91 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar,
   arg->peer_num_spatial_streams);
 }
 
+static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar,
+  struct ath10k_vif *arvif,
+  struct ieee80211_sta *sta,
+  struct ieee80211_bss_conf *bss_conf,
+  struct wmi_peer_assoc_complete_arg *arg)
+{
+   u32 uapsd = 0;
+   u32 max_sp = 0;
+
+   if (sta->wme)
+   arg->peer_flags |= WMI_PEER_QOS;
+
+   if (sta->wme && sta->uapsd_queues) {
+   ath10k_dbg(ATH10K_DBG_MAC, "uapsd_queues: 0x%X, max_sp: %d\n",
+  sta->uapsd_queues, sta->max_sp);
+
+   arg->peer_flags |= WMI_PEER_APSD;
+   arg->peer_flags |= WMI_RC_UAPSD_FLAG;
+
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
+   uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC3_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
+   uapsd |= WMI_AP_PS_UAPSD_AC2_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC2_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
+   uapsd |= WMI_AP_PS_UAPSD_AC1_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC1_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
+   uapsd |= WMI_AP_PS_UAPSD_AC0_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC0_TRIGGER_EN;
+
+
+   if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP)
+   max_sp = sta->max_sp;
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_UAPSD,
+  uapsd);
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_MAX_SP,
+  max_sp);
+
+   /* TODO setup this based on STA listen interval and
+  beacon interval. Currently we don't know
+  sta->listen_interval - mac80211 patch required.
+  Currently use 10 seconds */
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_AGEOUT_TIME,
+  10);
+   }
+}
+
 /*
- * FIXME: Handle UAPSD later.
+ * FIXME: Handle STA UAPSD later.
  */
+static void ath10k_peer_assoc_h_qos_sta(struct ath10k *ar,
+   struct ath10k_vif *arvif,
+   struct ieee80211_sta *sta,
+   struct ieee80211_bss_conf *bss_conf,
+   struct wmi_peer_assoc_complete_arg *arg)
+{
+   if (bss_conf->qos)
+   arg->peer_flags |= WMI_PEER_QOS;
+}
+
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
struct ath10k_vif *arvif,
struct ieee80211_sta *sta,
struct ieee80211_bss_conf *bss_conf,
struct wmi_peer_assoc_complete_arg *arg)
 {
-   if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
-   if (sta->wme)
-   arg->peer_flags |= WMI_PEER_QOS;
-   } else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
-   if (bss_conf->qos)
-   arg->peer_flags |= WMI_PEER_QOS;
+   switch (arvif->vdev_type) {
+   case WMI_VDEV_TYPE_AP:
+   ath10k_peer_assoc_h_qos_ap(ar, arvif, sta, bss_conf, arg);
+   break;
+   case WMI_VDEV_TYPE_STA:
+   ath10k_peer_assoc_h_qos_sta(ar, arvif, sta, bss_conf, arg);
+   break;
+   default:
+   break;
}
 }
 
@@ -2798,6 +2868,7 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->flags |= WIPHY

[ath9k-devel] [PATCH 3/3] ath10k: enable STA UAPSD support

2013-05-08 Thread Janusz Dziedzic
Enable UAPSD support for STA mode.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/core.h |1 +
 drivers/net/wireless/ath/ath10k/mac.c  |   80 ++--
 2 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 6c681cf..bef85fb 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -217,6 +217,7 @@ struct ath10k_vif {
union {
struct {
u8 bssid[ETH_ALEN];
+   u32 uapsd;
} sta;
struct {
/* 127 stations; wmi limit */
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 91de248..9b24530 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -2296,6 +2296,68 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
return ret;
 }
 
+#define SET_UAPSD(enable, out, flags) do { \
+   if ((enable))   \
+   (out) |= (flags);   \
+   else\
+   (out) &= ~(flags);  \
+} while (0)
+
+static int ath10k_conf_tx_uapsd(struct ath10k *ar, struct ieee80211_vif *vif,
+u16 ac, bool uapsd)
+{
+   struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
+   u32 value;
+   int ret = 0;
+
+   if (arvif->vdev_type != WMI_VDEV_TYPE_STA)
+   return 0;
+
+   switch (ac) {
+   case IEEE80211_AC_VO:
+   SET_UAPSD(uapsd, arvif->u.sta.uapsd,
+ WMI_STA_PS_UAPSD_AC3_DELIVERY_EN |
+ WMI_STA_PS_UAPSD_AC3_TRIGGER_EN);
+   break;
+   case IEEE80211_AC_VI:
+   SET_UAPSD(uapsd, arvif->u.sta.uapsd,
+ WMI_STA_PS_UAPSD_AC2_DELIVERY_EN |
+ WMI_STA_PS_UAPSD_AC2_TRIGGER_EN);
+   break;
+   case IEEE80211_AC_BE:
+   SET_UAPSD(uapsd, arvif->u.sta.uapsd,
+ WMI_STA_PS_UAPSD_AC1_DELIVERY_EN |
+ WMI_STA_PS_UAPSD_AC1_TRIGGER_EN);
+   break;
+   case IEEE80211_AC_BK:
+   SET_UAPSD(uapsd, arvif->u.sta.uapsd,
+ WMI_STA_PS_UAPSD_AC0_DELIVERY_EN |
+ WMI_STA_PS_UAPSD_AC0_TRIGGER_EN);
+   break;
+   }
+
+   ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
+ WMI_STA_PS_PARAM_UAPSD,
+ arvif->u.sta.uapsd);
+   if (ret) {
+   ath10k_warn("could not set uapsd params (%d)\n", ret);
+   goto exit;
+   }
+
+   if (arvif->u.sta.uapsd)
+   value = WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD;
+   else
+   value = WMI_STA_PS_RX_WAKE_POLICY_WAKE;
+
+   ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
+ WMI_STA_PS_PARAM_RX_WAKE_POLICY,
+ value);
+   if (ret)
+   ath10k_warn("could not set rx wake param (%d)\n", ret);
+exit:
+   return ret;
+}
+
 static int ath10k_conf_tx(struct ieee80211_hw *hw,
  struct ieee80211_vif *vif, u16 ac,
  const struct ieee80211_tx_queue_params *params)
@@ -2321,8 +2383,10 @@ static int ath10k_conf_tx(struct ieee80211_hw *hw,
break;
}
 
-   if (WARN_ON(!p))
-   return -EINVAL;
+   if (WARN_ON(!p)) {
+   ret = -EINVAL;
+   goto exit;
+   }
 
p->cwmin = params->cw_min;
p->cwmax = params->cw_max;
@@ -2335,13 +2399,20 @@ static int ath10k_conf_tx(struct ieee80211_hw *hw,
 */
p->txop = params->txop * 32;
 
-   /* FIXME: can we pass the params->uapsd to the FW? */
+
/* FIXME: FW accepts wmm params per hw, not per vif */
 
ret = ath10k_wmi_pdev_set_wmm_params(ar, &ar->wmm_params);
-   if (ret)
+   if (ret) {
ath10k_warn("could not set wmm params (%d)\n", ret);
+   goto exit;
+   }
 
+   ret = ath10k_conf_tx_uapsd(ar, vif, ac, params->uapsd);
+   if (ret)
+   ath10k_warn("could not set sta uapsd (%d)\n", ret);
+
+exit:
mutex_unlock(&ar->conf_mutex);
return ret;
 }
@@ -2842,6 +2913,7 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->flags = IEEE80211_HW_SIGNAL_DBM |
IEEE80211_HW_SUPPORTS_PS |
IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
+   IEEE80211_HW_SUPPORTS_UA

[ath9k-devel] [PATCH v2 1/3] ath10k: WMI add AP PS

2013-05-09 Thread Janusz Dziedzic
Add AP power save (UAPSD) structures, enums.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/wmi.c |   26 +
 drivers/net/wireless/ath/ath10k/wmi.h |   68 +
 2 files changed, 94 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index d2d712d..bd1f076 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1903,6 +1903,32 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 
vdev_id,
return ath10k_wmi_cmd_send(ar, skb, WMI_STA_POWERSAVE_PARAM_CMDID);
 }
 
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value)
+{
+   struct wmi_ap_ps_peer_cmd *cmd;
+   struct sk_buff *skb;
+
+   if (!mac)
+   return -EINVAL;
+
+   skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+   if (!skb)
+   return -ENOMEM;
+
+   cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
+   cmd->vdev_id = __cpu_to_le32(vdev_id);
+   cmd->param_id = __cpu_to_le32(param_id);
+   cmd->param_value = __cpu_to_le32(value);
+   memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
+
+   ath10k_dbg(ATH10K_DBG_WMI,
+  "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr 
%pM\n",
+  vdev_id, param_id, value, mac);
+
+   return ath10k_wmi_cmd_send(ar, skb, WMI_AP_PS_PEER_PARAM_CMDID);
+}
+
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index 2ad0431..8d482ab 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2461,6 +2461,72 @@ struct wmi_sta_mimo_ps_mode_cmd {
__le32 mimo_pwrsave_mode;
 } __packed;
 
+/* U-APSD configuration of peer station from (re)assoc request and TSPECs */
+enum wmi_ap_ps_param_uapsd {
+   WMI_AP_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
+   WMI_AP_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
+   WMI_AP_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
+   WMI_AP_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
+   WMI_AP_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
+   WMI_AP_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
+   WMI_AP_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
+   WMI_AP_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
+};
+
+/* U-APSD maximum service period of peer station */
+enum wmi_ap_ps_peer_param_max_sp {
+   WMI_AP_PS_PEER_PARAM_MAX_SP_UNLIMITED = 0,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_2 = 1,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_4 = 2,
+   WMI_AP_PS_PEER_PARAM_MAX_SP_6 = 3,
+   MAX_WMI_AP_PS_PEER_PARAM_MAX_SP,
+};
+
+/*
+ * AP power save parameter
+ * Set a power save specific parameter for a peer station
+ */
+enum wmi_ap_ps_peer_param {
+   /* Set uapsd configuration for a given peer.
+*
+* Include the delivery and trigger enabled state for every AC.
+* The host  MLME needs to set this based on AP capability and stations
+* request Set in the association request  received from the station.
+*
+* Lower 8 bits of the value specify the UAPSD configuration.
+*
+* (see enum wmi_ap_ps_param_uapsd)
+* The default value is 0.
+*/
+   WMI_AP_PS_PEER_PARAM_UAPSD = 0,
+
+   /*
+* Set the service period for a UAPSD capable station
+*
+* The service period from wme ie in the (re)assoc request frame.
+*
+* (see enum wmi_ap_ps_peer_param_max_sp)
+*/
+   WMI_AP_PS_PEER_PARAM_MAX_SP = 1,
+
+   /* Time in seconds for aging out buffered frames for STA in PS */
+   WMI_AP_PS_PEER_PARAM_AGEOUT_TIME = 2,
+};
+
+struct wmi_ap_ps_peer_cmd {
+   /* unique id identifying the VDEV, generated by the caller */
+   __le32 vdev_id;
+
+   /* peer MAC address */
+   struct wmi_mac_addr peer_macaddr;
+
+   /* AP powersave param (see enum wmi_ap_ps_peer_param) */
+   __le32 param_id;
+
+   /* AP powersave param value */
+   __le32 param_value;
+} __packed;
+
 /* 128 clients = 4 words */
 #define WMI_TIM_BITMAP_ARRAY_SIZE 4
 
@@ -2876,6 +2942,8 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
 int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
enum wmi_sta_powersave_param param_id,
u32 value);
+int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
+  enum wmi_ap_ps_peer_param param_id, u32 value);
 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
  const struct wmi_scan_chan_list_arg *arg);
 int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_arg 
*a

[ath9k-devel] [PATCH v2 2/3] ath10k: add AP UAPSD support

2013-05-09 Thread Janusz Dziedzic
Add support for AP (P2P_GO) UAPSD.

To test this functionality you can use
wpa_supplicant, and enable AP UAPSD:
- p2p_set go_apsd 1
- p2p_group_add (or configure SoftAP)
After that our P2P_GO/AP will indicate support
for UAPSD in beacon/probe_resp WME IE.
Now you can connect UAPSD capable station with
configured UAPSD AC trigger/delivery bits.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/mac.c |   85 ++---
 1 file changed, 78 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 818b8e6..110ad3d 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -906,21 +906,91 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar,
   arg->peer_num_spatial_streams);
 }
 
+static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar,
+  struct ath10k_vif *arvif,
+  struct ieee80211_sta *sta,
+  struct ieee80211_bss_conf *bss_conf,
+  struct wmi_peer_assoc_complete_arg *arg)
+{
+   u32 uapsd = 0;
+   u32 max_sp = 0;
+
+   if (sta->wme)
+   arg->peer_flags |= WMI_PEER_QOS;
+
+   if (sta->wme && sta->uapsd_queues) {
+   ath10k_dbg(ATH10K_DBG_MAC, "uapsd_queues: 0x%X, max_sp: %d\n",
+  sta->uapsd_queues, sta->max_sp);
+
+   arg->peer_flags |= WMI_PEER_APSD;
+   arg->peer_flags |= WMI_RC_UAPSD_FLAG;
+
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
+   uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC3_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
+   uapsd |= WMI_AP_PS_UAPSD_AC2_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC2_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
+   uapsd |= WMI_AP_PS_UAPSD_AC1_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC1_TRIGGER_EN;
+   if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
+   uapsd |= WMI_AP_PS_UAPSD_AC0_DELIVERY_EN |
+WMI_AP_PS_UAPSD_AC0_TRIGGER_EN;
+
+
+   if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP)
+   max_sp = sta->max_sp;
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_UAPSD,
+  uapsd);
+
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_MAX_SP,
+  max_sp);
+
+   /* TODO setup this based on STA listen interval and
+  beacon interval. Currently we don't know
+  sta->listen_interval - mac80211 patch required.
+  Currently use 10 seconds */
+   ath10k_wmi_set_ap_ps_param(ar, arvif->vdev_id,
+  sta->addr,
+  WMI_AP_PS_PEER_PARAM_AGEOUT_TIME,
+  10);
+   }
+}
+
 /*
- * FIXME: Handle UAPSD later.
+ * FIXME: Handle STA UAPSD later.
  */
+static void ath10k_peer_assoc_h_qos_sta(struct ath10k *ar,
+   struct ath10k_vif *arvif,
+   struct ieee80211_sta *sta,
+   struct ieee80211_bss_conf *bss_conf,
+   struct wmi_peer_assoc_complete_arg *arg)
+{
+   if (bss_conf->qos)
+   arg->peer_flags |= WMI_PEER_QOS;
+}
+
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
struct ath10k_vif *arvif,
struct ieee80211_sta *sta,
struct ieee80211_bss_conf *bss_conf,
struct wmi_peer_assoc_complete_arg *arg)
 {
-   if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
-   if (sta->wme)
-   arg->peer_flags |= WMI_PEER_QOS;
-   } else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
-   if (bss_conf->qos)
-   arg->peer_flags |= WMI_PEER_QOS;
+   switch (arvif->vdev_type) {
+   case WMI_VDEV_TYPE_AP:
+   ath10k_peer_assoc_h_qos_ap(ar, arvif, sta, bss_conf, arg);
+   b

[ath9k-devel] [PATCH v2 3/3] ath10k: enable STA UAPSD support

2013-05-09 Thread Janusz Dziedzic
Enable UAPSD support for STA mode.

By default mac80211 enable UAPSD for
Voice AC. So, to test this functionality
we need AP with enable UAPSD and run traffic
using VO AC (eg. ping -Q 0xFF). After sending
such ping from AP->STA, HW/FW should not get this
data after AP indicate this in beacon->pvb.
Instead should wait host will send trigger frame
(could be ping STA->AP). For non-UAPSD ACs standard
PS should be used (NULL frames, PSPOLL).

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/core.h |1 +
 drivers/net/wireless/ath/ath10k/mac.c  |   78 
 2 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 6c681cf..bef85fb 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -217,6 +217,7 @@ struct ath10k_vif {
union {
struct {
u8 bssid[ETH_ALEN];
+   u32 uapsd;
} sta;
struct {
/* 127 stations; wmi limit */
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 110ad3d..c7ee70a 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -963,9 +963,6 @@ static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar,
}
 }
 
-/*
- * FIXME: Handle STA UAPSD later.
- */
 static void ath10k_peer_assoc_h_qos_sta(struct ath10k *ar,
struct ath10k_vif *arvif,
struct ieee80211_sta *sta,
@@ -2318,6 +2315,63 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
return ret;
 }
 
+static int ath10k_conf_tx_uapsd(struct ath10k *ar, struct ieee80211_vif *vif,
+u16 ac, bool enable)
+{
+   struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
+   u32 value = 0;
+   int ret = 0;
+
+   if (arvif->vdev_type != WMI_VDEV_TYPE_STA)
+   return 0;
+
+   switch (ac) {
+   case IEEE80211_AC_VO:
+   value = WMI_STA_PS_UAPSD_AC3_DELIVERY_EN |
+   WMI_STA_PS_UAPSD_AC3_TRIGGER_EN;
+   break;
+   case IEEE80211_AC_VI:
+   value = WMI_STA_PS_UAPSD_AC2_DELIVERY_EN |
+   WMI_STA_PS_UAPSD_AC2_TRIGGER_EN;
+   break;
+   case IEEE80211_AC_BE:
+   value = WMI_STA_PS_UAPSD_AC1_DELIVERY_EN |
+   WMI_STA_PS_UAPSD_AC1_TRIGGER_EN;
+   break;
+   case IEEE80211_AC_BK:
+   value = WMI_STA_PS_UAPSD_AC0_DELIVERY_EN |
+   WMI_STA_PS_UAPSD_AC0_TRIGGER_EN;
+   break;
+   }
+
+   if (enable)
+   arvif->u.sta.uapsd |= value;
+   else
+   arvif->u.sta.uapsd &= ~value;
+
+   ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
+ WMI_STA_PS_PARAM_UAPSD,
+ arvif->u.sta.uapsd);
+   if (ret) {
+   ath10k_warn("could not set uapsd params %d\n", ret);
+   goto exit;
+   }
+
+   if (arvif->u.sta.uapsd)
+   value = WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD;
+   else
+   value = WMI_STA_PS_RX_WAKE_POLICY_WAKE;
+
+   ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
+ WMI_STA_PS_PARAM_RX_WAKE_POLICY,
+ value);
+   if (ret)
+   ath10k_warn("could not set rx wake param %d\n", ret);
+
+exit:
+   return ret;
+}
+
 static int ath10k_conf_tx(struct ieee80211_hw *hw,
  struct ieee80211_vif *vif, u16 ac,
  const struct ieee80211_tx_queue_params *params)
@@ -2343,8 +2397,10 @@ static int ath10k_conf_tx(struct ieee80211_hw *hw,
break;
}
 
-   if (WARN_ON(!p))
-   return -EINVAL;
+   if (WARN_ON(!p)) {
+   ret = -EINVAL;
+   goto exit;
+   }
 
p->cwmin = params->cw_min;
p->cwmax = params->cw_max;
@@ -2357,13 +2413,18 @@ static int ath10k_conf_tx(struct ieee80211_hw *hw,
 */
p->txop = params->txop * 32;
 
-   /* FIXME: can we pass the params->uapsd to the FW? */
/* FIXME: FW accepts wmm params per hw, not per vif */
-
ret = ath10k_wmi_pdev_set_wmm_params(ar, &ar->wmm_params);
+   if (ret) {
+   ath10k_warn("could not set wmm params %d\n", ret);
+   goto exit;
+   }
+
+   ret = ath10k_conf_tx_uapsd(ar, vif, ac, params->uapsd);
if (ret)
-   ath10k_warn("could not set wmm params (%d)\n", ret);
+   ath10k_warn("could not set st

[ath9k-devel] [PATCH] ath10k: improve firmware crash message

2013-05-10 Thread Janusz Dziedzic
print hardware name/id, firware version,
make register dump more compact

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath10k/pci.c |   20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index e348fd9..b7840c8 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -697,11 +697,18 @@ static u16 ath10k_pci_hif_get_free_queue_number(struct 
ath10k *ar, u8 pipe)
 static void ath10k_pci_hif_dump_area(struct ath10k *ar)
 {
u32 reg_dump_area = 0;
-   u32 reg_dump_values[REG_DUMP_COUNT_QCA988X];
+   u32 reg_dump_values[REG_DUMP_COUNT_QCA988X] = {};
u32 host_addr;
int ret;
u32 i;
 
+   ath10k_err("firmware crashed!\n");
+   ath10k_err("hardware name %s version 0x%x\n",
+  ar->hw_params.name, ar->target_version);
+   ath10k_err("firmware version: %u.%u.%u.%u\n", ar->fw_version_major,
+  ar->fw_version_minor, ar->fw_version_release,
+  ar->fw_version_build);
+
host_addr = host_interest_item_address(HI_ITEM(hi_failure_state));
if (ath10k_pci_diag_read_mem(ar, host_addr,
 ®_dump_area, sizeof(u32)) != 0) {
@@ -719,9 +726,16 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)
return;
}
 
+   BUILD_BUG_ON(REG_DUMP_COUNT_QCA988X % 4);
+
ath10k_err("target Register Dump\n");
-   for (i = 0; i < REG_DUMP_COUNT_QCA988X; i++)
-   ath10k_err("[%02d]: 0x%08X\n", i, reg_dump_values[i]);
+   for (i = 0; i < REG_DUMP_COUNT_QCA988X; i += 4)
+   ath10k_err("[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X\n",
+  i,
+  reg_dump_values[i],
+  reg_dump_values[i + 1],
+  reg_dump_values[i + 2],
+  reg_dump_values[i + 3]);
 }
 
 static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe,
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCH] ath9k: DFS radar use correct width enum

2013-09-16 Thread Janusz Dziedzic
Use correct width enums when setup
radar_detect_widths for DFS.

Signed-off-by: Janusz Dziedzic 
---
 drivers/net/wireless/ath/ath9k/init.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index c9470d0..867b0a4 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -808,8 +808,8 @@ static const struct ieee80211_iface_combination if_comb[] = 
{
.max_interfaces = 1,
.num_different_channels = 1,
.beacon_int_infra_match = true,
-   .radar_detect_widths =  BIT(NL80211_CHAN_NO_HT) |
-   BIT(NL80211_CHAN_HT20),
+   .radar_detect_widths =  BIT(NL80211_CHAN_WIDTH_20_NOHT) |
+   BIT(NL80211_CHAN_WIDTH_20),
}
 };
 
-- 
1.7.9.5

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel