Re: [RFC (v7)] add basic register-field manipulation macros

2016-08-19 Thread Kalle Valo
Linus Torvalds  writes:

> On Thu, Aug 18, 2016 at 10:11 AM, Jakub Kicinski
>  wrote:
>> Hi!
>>
>> This is what I came up with.  Changes:
>
> I can live with this, certainly. I'm not really sure how many drivers
> (or perhaps core code, for that matter) will actually start using it,
> but it at least _looks_ like a usable interface that seems to be quite
> resistant to people doing stupid things with it that would result in
> surprising results (either performance or semantics).

I'm guessing that at least in ath9k and ath10k there would be use of
these macros.

> So I'm ok with something like this coming through (for example) the
> wireless tree if the drivers there are the first ones to start using
> this.
>
> Let's see if anybody else objects.

Great, thanks for the help. Let's wait for other comments and Jakub can
then resend this without RFC. I can then take it through my tree.

-- 
Kalle Valo


Re: ath9k: Fix beacon configuration assertion failure

2016-08-19 Thread Kalle Valo
Adi Ratiu  wrote:
> commit cfda2d8e2314 ("ath9k: Fix beacon configuration for
> addition/removal of interfaces") reworked beacon configs to happen at
> IF changes and missed cases when NL80211_IFTYPE_STATION has no beacons
> with the corresponding values iter_data.primary_beacon_vif == 0 and
> iter_data.nbcnvifs == 0 in ath9k_calculate_summary_state(), thus
> calling ath9k_beacon_config() with null and giving the below warning.
> 
> Fix this by calling beacon config only when a beacon actually exists,
> i.e. by checking iter_data.beacons which should be set only inside
> ath9k_vif_iter_set_beacon() (the line "iter_data.beacons = true;" in
> ath9k_calculate_summary_state() is a bug in above rework commit).
> 
> [   16.910537] [ cut here ]
> [   16.910549] WARNING: CPU: 2 PID: 6 at 
> drivers/net/wireless/ath/ath9k/beacon.c:642 ath9k_beacon_config+0x12c/0x130 
> [ath9k]
> [   16.910551] Modules linked in: intel_rapl x86_pkg_temp_thermal 
> intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul 
> crc32_pclmul crc32c_intel ghash_clmulni_intel hid_generic aesni_intel usbhid 
> hid aes_x86_64 joydev mousedev arc4 lrw ath9k dell_laptop ath9k_common 
> ath9k_hw ath mac80211 gf128mul glue_helper ablk_helper dell_smbios input_leds 
> cryptd led_class snd_hda_codec_hdmi psmouse cfg80211 serio_raw atkbd 
> snd_hda_codec_realtek libps2 rfkill r8169 sr_mod snd_hda_codec_generic dcdbas 
> cdrom mii snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core i8042 snd_pcm 
> snd_timer serio ac xhci_pci xhci_hcd battery i2c_i801 tpm_tis pcspkr 
> tpm_tis_core evdev shpchp lpc_ich i2c_smbus tpm sch_fq_codel ip_tables 
> x_tables
> [   16.910620] CPU: 2 PID: 6 Comm: kworker/u16:0 Not tainted 
> 4.8.0-rc1-next-20160815-g118253a #1
> [   16.910621] Hardware name: Dell Inc. Inspiron 3521/018DYG, BIOS A14 
> 07/31/2015
> [   16.910648] Workqueue: phy0 ieee80211_iface_work [mac80211]
> [   16.910652]   880159f13630 813140f0 
> 
> [   16.910657]   880159f13670 8106b22b 
> 02820202
> [   16.910661]  880156bc1500  880153cc8018 
> 880153cc8018
> [   16.910666] Call Trace:
> [   16.910674]  [] dump_stack+0x63/0x83
> [   16.910678]  [] __warn+0xcb/0xf0
> [   16.910682]  [] warn_slowpath_null+0x1d/0x20
> [   16.910690]  [] ath9k_beacon_config+0x12c/0x130 [ath9k]
> [   16.910696]  [] ath9k_calculate_summary_state+0xf6/0x350 
> [ath9k]
> [   16.910703]  [] ath9k_bss_info_changed+0x186/0x1a0 
> [ath9k]
> [   16.910720]  [] 
> ieee80211_bss_info_change_notify+0xb1/0x200 [mac80211]
> [   16.910737]  [] ieee80211_assoc_success+0x677/0xdeb 
> [mac80211]
> [   16.910746]  [] ? up+0x32/0x50
> [   16.910751]  [] ? wake_up_klogd+0x3b/0x50
> [   16.910755]  [] ? console_unlock+0x539/0x5f0
> [   16.910760]  [] ? vprintk_emit+0x254/0x490
> [   16.910765]  [] ? vprintk_default+0x1f/0x30
> [   16.910769]  [] ? printk+0x48/0x50
> [   16.910788]  [] ieee80211_rx_mgmt_assoc_resp+0x152/0x4c0 
> [mac80211]
> [   16.910807]  [] ieee80211_sta_rx_queued_mgmt+0x18f/0x840 
> [mac80211]
> [   16.910813]  [] ? lock_timer_base.isra.2+0x80/0xa0
> [   16.910817]  [] ? cpuacct_charge+0x86/0xa0
> [   16.910822]  [] ? update_curr+0xb7/0x160
> [   16.910827]  [] ? dequeue_entity+0x24c/0xa20
> [   16.910831]  [] ? dequeue_task_fair+0x5c3/0x960
> [   16.910848]  [] ? ieee80211_iface_work+0xd4/0x410 
> [mac80211]
> [   16.910865]  [] ieee80211_iface_work+0x295/0x410 
> [mac80211]
> [   16.910870]  [] ? finish_task_switch+0x77/0x1e0
> [   16.910875]  [] process_one_work+0x1e5/0x470
> [   16.910880]  [] worker_thread+0x48/0x4e0
> [   16.910885]  [] ? process_one_work+0x470/0x470
> [   16.910888]  [] kthread+0xc9/0xe0
> [   16.910894]  [] ? __switch_to+0x2c3/0x610
> [   16.910899]  [] ret_from_fork+0x1f/0x40
> [   16.910902]  [] ? kthread_create_on_node+0x40/0x40
> [   16.910904] ---[ end trace aa169ad4461f2f18 ]---
> 
> Signed-off-by: Ioan-Adrian Ratiu 

Benjamin, does this look reasonable to you? I'm planning to queue this for 4.8.

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9281191/



Re: [PATCH] wlcore: mesh: add zone time sync support

2016-08-19 Thread Kalle Valo
"Pedersen, Thomas"  writes:

> On Mon, 2016-08-08 at 11:57 +0300, Guy Mishol wrote:
>> Add zone time sync support for mesh role.
>> This allows to configure the mesh peer
>> master of each zone for time synchronization.
>
> What is this? mac80211 already tries to maintain TSF sync with mesh
> peers if get/set TSF ops are supported by the driver.

Yeah, and why use debugfs?

-- 
Kalle Valo


Re: ath9k: Fix beacon configuration assertion failure

2016-08-19 Thread Kalle Valo
Kalle Valo  writes:

> Adi Ratiu  wrote:
>> commit cfda2d8e2314 ("ath9k: Fix beacon configuration for
>> addition/removal of interfaces") reworked beacon configs to happen at
>> IF changes and missed cases when NL80211_IFTYPE_STATION has no beacons
>> with the corresponding values iter_data.primary_beacon_vif == 0 and
>> iter_data.nbcnvifs == 0 in ath9k_calculate_summary_state(), thus
>> calling ath9k_beacon_config() with null and giving the below warning.
>> 
>> Fix this by calling beacon config only when a beacon actually exists,
>> i.e. by checking iter_data.beacons which should be set only inside
>> ath9k_vif_iter_set_beacon() (the line "iter_data.beacons = true;" in
>> ath9k_calculate_summary_state() is a bug in above rework commit).
>> 
>> [   16.910537] [ cut here ]
>> [   16.910549] WARNING: CPU: 2 PID: 6 at 
>> drivers/net/wireless/ath/ath9k/beacon.c:642 ath9k_beacon_config+0x12c/0x130 
>> [ath9k]
>> [   16.910551] Modules linked in: intel_rapl x86_pkg_temp_thermal 
>> intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul 
>> crc32_pclmul crc32c_intel ghash_clmulni_intel hid_generic aesni_intel usbhid 
>> hid aes_x86_64 joydev mousedev arc4 lrw ath9k dell_laptop ath9k_common 
>> ath9k_hw ath mac80211 gf128mul glue_helper ablk_helper dell_smbios 
>> input_leds cryptd led_class snd_hda_codec_hdmi psmouse cfg80211 serio_raw 
>> atkbd snd_hda_codec_realtek libps2 rfkill r8169 sr_mod snd_hda_codec_generic 
>> dcdbas cdrom mii snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core i8042 
>> snd_pcm snd_timer serio ac xhci_pci xhci_hcd battery i2c_i801 tpm_tis pcspkr 
>> tpm_tis_core evdev shpchp lpc_ich i2c_smbus tpm sch_fq_codel ip_tables 
>> x_tables
>> [   16.910620] CPU: 2 PID: 6 Comm: kworker/u16:0 Not tainted 
>> 4.8.0-rc1-next-20160815-g118253a #1
>> [   16.910621] Hardware name: Dell Inc. Inspiron 3521/018DYG, BIOS A14 
>> 07/31/2015
>> [   16.910648] Workqueue: phy0 ieee80211_iface_work [mac80211]
>> [   16.910652]   880159f13630 813140f0 
>> 
>> [   16.910657]   880159f13670 8106b22b 
>> 02820202
>> [   16.910661]  880156bc1500  880153cc8018 
>> 880153cc8018
>> [   16.910666] Call Trace:
>> [   16.910674]  [] dump_stack+0x63/0x83
>> [   16.910678]  [] __warn+0xcb/0xf0
>> [   16.910682]  [] warn_slowpath_null+0x1d/0x20
>> [   16.910690]  [] ath9k_beacon_config+0x12c/0x130 [ath9k]
>> [   16.910696]  [] 
>> ath9k_calculate_summary_state+0xf6/0x350 [ath9k]
>> [   16.910703]  [] ath9k_bss_info_changed+0x186/0x1a0 
>> [ath9k]
>> [   16.910720]  [] 
>> ieee80211_bss_info_change_notify+0xb1/0x200 [mac80211]
>> [   16.910737]  [] ieee80211_assoc_success+0x677/0xdeb 
>> [mac80211]
>> [   16.910746]  [] ? up+0x32/0x50
>> [   16.910751]  [] ? wake_up_klogd+0x3b/0x50
>> [   16.910755]  [] ? console_unlock+0x539/0x5f0
>> [   16.910760]  [] ? vprintk_emit+0x254/0x490
>> [   16.910765]  [] ? vprintk_default+0x1f/0x30
>> [   16.910769]  [] ? printk+0x48/0x50
>> [   16.910788]  [] 
>> ieee80211_rx_mgmt_assoc_resp+0x152/0x4c0 [mac80211]
>> [   16.910807]  [] 
>> ieee80211_sta_rx_queued_mgmt+0x18f/0x840 [mac80211]
>> [   16.910813]  [] ? lock_timer_base.isra.2+0x80/0xa0
>> [   16.910817]  [] ? cpuacct_charge+0x86/0xa0
>> [   16.910822]  [] ? update_curr+0xb7/0x160
>> [   16.910827]  [] ? dequeue_entity+0x24c/0xa20
>> [   16.910831]  [] ? dequeue_task_fair+0x5c3/0x960
>> [   16.910848]  [] ? ieee80211_iface_work+0xd4/0x410 
>> [mac80211]
>> [   16.910865]  [] ieee80211_iface_work+0x295/0x410 
>> [mac80211]
>> [   16.910870]  [] ? finish_task_switch+0x77/0x1e0
>> [   16.910875]  [] process_one_work+0x1e5/0x470
>> [   16.910880]  [] worker_thread+0x48/0x4e0
>> [   16.910885]  [] ? process_one_work+0x470/0x470
>> [   16.910888]  [] kthread+0xc9/0xe0
>> [   16.910894]  [] ? __switch_to+0x2c3/0x610
>> [   16.910899]  [] ret_from_fork+0x1f/0x40
>> [   16.910902]  [] ? kthread_create_on_node+0x40/0x40
>> [   16.910904] ---[ end trace aa169ad4461f2f18 ]---
>> 
>> Signed-off-by: Ioan-Adrian Ratiu 
>
> Benjamin, does this look reasonable to you? I'm planning to queue this for 
> 4.8.

Actually, I see two patches which might be related but not identical:

ath9k: fix client mode beacon configuration
https://patchwork.kernel.org/patch/9247699/

ath9k: Fix beacon configuration assertion failure
https://patchwork.kernel.org/patch/9281191/

Felix (CCed) & Benjamin: please take a look and advice which one I
should take.

-- 
Kalle Valo


Re: ath9k: fix misleading indent

2016-08-19 Thread Kalle Valo
Bob Copeland  wrote:
> Fixes smatch warning:
> 
> ath9k_vif_iter_set_beacon() warn if statement not indented
> 
> Signed-off-by: Bob Copeland 
> Reviewed-by: Julian Calaby 

Thanks, 1 patch applied to ath-next branch of ath.git:

4c51e7db87b7 ath9k: fix misleading indent

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9241937/



Re: [1/1,V3] ath9k: consider return code on

2016-08-19 Thread Kalle Valo
Eduardo Abinader  wrote:
> just to comply with current ath9k_hw_nvram_read to return value, hence
> behaving reacting accordingly.
> 
> Signed-off-by: Eduardo Abinader 

Thanks, 1 patch applied to ath-next branch of ath.git:

a5d268277ad5 ath9k: consider return code on

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9249821/



Re: [4.8] ath9k: fix using sta->drv_priv before initializing it

2016-08-19 Thread Kalle Valo
Felix Fietkau  wrote:
> A station pointer can be passed to the driver on tx, before it has been
> marked as associated. Since ath9k_sta_state was initializing the entry
> too late, it resulted in some spurious crashes.
> 
> Fixes: df3c6eb34da5 ("ath9k: Use sta_state() callback")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Felix Fietkau 

I'm planning to queue this for 4.8.

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9255463/



Re: [1/8] wil6210: align to latest auto generated wmi.h

2016-08-19 Thread Kalle Valo
Maya Erez  wrote:
> Align to latest version of the auto generated wmi file
> describing the interface with FW.
> 
> Signed-off-by: Maya Erez 

Thanks, 8 patches applied to ath-next branch of ath.git:

0163b0319900 wil6210: align to latest auto generated wmi.h
f1b7764f8626 wil6210: fix HALP handling in case of HALP vote time-out
74b6ac586d9c wil6210: support rx key setting for all TIDs
ef86f249fa49 wil6210: change HALP logging category to IRQ
d35c2b6f8ffa wil6210: fix stop p2p device handling
b0c0e688e523 wil6210: Fix driver down flow
dc90506f1458 wil6210: prevent usage of incorrect TX hwtail
2690c4c0e83b wil6210: fix wiphy registration sequence

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9259343/



Re: ath9k: Fix beacon configuration assertion failure

2016-08-19 Thread Ioan-Adrian Ratiu
Hi

On Fri, 19 Aug 2016, Kalle Valo  wrote:
> Kalle Valo  writes:
>
>> Adi Ratiu  wrote:
>>> commit cfda2d8e2314 ("ath9k: Fix beacon configuration for
>>> addition/removal of interfaces") reworked beacon configs to happen at
>>> IF changes and missed cases when NL80211_IFTYPE_STATION has no beacons
>>> with the corresponding values iter_data.primary_beacon_vif == 0 and
>>> iter_data.nbcnvifs == 0 in ath9k_calculate_summary_state(), thus
>>> calling ath9k_beacon_config() with null and giving the below warning.
>>> 
>>> Fix this by calling beacon config only when a beacon actually exists,
>>> i.e. by checking iter_data.beacons which should be set only inside
>>> ath9k_vif_iter_set_beacon() (the line "iter_data.beacons = true;" in
>>> ath9k_calculate_summary_state() is a bug in above rework commit).
>>> 
>>> [   16.910537] [ cut here ]
>>> [   16.910549] WARNING: CPU: 2 PID: 6 at 
>>> drivers/net/wireless/ath/ath9k/beacon.c:642 ath9k_beacon_config+0x12c/0x130 
>>> [ath9k]
>>> [   16.910551] Modules linked in: intel_rapl x86_pkg_temp_thermal 
>>> intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul 
>>> crc32_pclmul crc32c_intel ghash_clmulni_intel hid_generic aesni_intel 
>>> usbhid hid aes_x86_64 joydev mousedev arc4 lrw ath9k dell_laptop 
>>> ath9k_common ath9k_hw ath mac80211 gf128mul glue_helper ablk_helper 
>>> dell_smbios input_leds cryptd led_class snd_hda_codec_hdmi psmouse cfg80211 
>>> serio_raw atkbd snd_hda_codec_realtek libps2 rfkill r8169 sr_mod 
>>> snd_hda_codec_generic dcdbas cdrom mii snd_hda_intel snd_hda_codec 
>>> snd_hwdep snd_hda_core i8042 snd_pcm snd_timer serio ac xhci_pci xhci_hcd 
>>> battery i2c_i801 tpm_tis pcspkr tpm_tis_core evdev shpchp lpc_ich i2c_smbus 
>>> tpm sch_fq_codel ip_tables x_tables
>>> [   16.910620] CPU: 2 PID: 6 Comm: kworker/u16:0 Not tainted 
>>> 4.8.0-rc1-next-20160815-g118253a #1
>>> [   16.910621] Hardware name: Dell Inc. Inspiron 3521/018DYG, BIOS A14 
>>> 07/31/2015
>>> [   16.910648] Workqueue: phy0 ieee80211_iface_work [mac80211]
>>> [   16.910652]   880159f13630 813140f0 
>>> 
>>> [   16.910657]   880159f13670 8106b22b 
>>> 02820202
>>> [   16.910661]  880156bc1500  880153cc8018 
>>> 880153cc8018
>>> [   16.910666] Call Trace:
>>> [   16.910674]  [] dump_stack+0x63/0x83
>>> [   16.910678]  [] __warn+0xcb/0xf0
>>> [   16.910682]  [] warn_slowpath_null+0x1d/0x20
>>> [   16.910690]  [] ath9k_beacon_config+0x12c/0x130 [ath9k]
>>> [   16.910696]  [] 
>>> ath9k_calculate_summary_state+0xf6/0x350 [ath9k]
>>> [   16.910703]  [] ath9k_bss_info_changed+0x186/0x1a0 
>>> [ath9k]
>>> [   16.910720]  [] 
>>> ieee80211_bss_info_change_notify+0xb1/0x200 [mac80211]
>>> [   16.910737]  [] ieee80211_assoc_success+0x677/0xdeb 
>>> [mac80211]
>>> [   16.910746]  [] ? up+0x32/0x50
>>> [   16.910751]  [] ? wake_up_klogd+0x3b/0x50
>>> [   16.910755]  [] ? console_unlock+0x539/0x5f0
>>> [   16.910760]  [] ? vprintk_emit+0x254/0x490
>>> [   16.910765]  [] ? vprintk_default+0x1f/0x30
>>> [   16.910769]  [] ? printk+0x48/0x50
>>> [   16.910788]  [] 
>>> ieee80211_rx_mgmt_assoc_resp+0x152/0x4c0 [mac80211]
>>> [   16.910807]  [] 
>>> ieee80211_sta_rx_queued_mgmt+0x18f/0x840 [mac80211]
>>> [   16.910813]  [] ? lock_timer_base.isra.2+0x80/0xa0
>>> [   16.910817]  [] ? cpuacct_charge+0x86/0xa0
>>> [   16.910822]  [] ? update_curr+0xb7/0x160
>>> [   16.910827]  [] ? dequeue_entity+0x24c/0xa20
>>> [   16.910831]  [] ? dequeue_task_fair+0x5c3/0x960
>>> [   16.910848]  [] ? ieee80211_iface_work+0xd4/0x410 
>>> [mac80211]
>>> [   16.910865]  [] ieee80211_iface_work+0x295/0x410 
>>> [mac80211]
>>> [   16.910870]  [] ? finish_task_switch+0x77/0x1e0
>>> [   16.910875]  [] process_one_work+0x1e5/0x470
>>> [   16.910880]  [] worker_thread+0x48/0x4e0
>>> [   16.910885]  [] ? process_one_work+0x470/0x470
>>> [   16.910888]  [] kthread+0xc9/0xe0
>>> [   16.910894]  [] ? __switch_to+0x2c3/0x610
>>> [   16.910899]  [] ret_from_fork+0x1f/0x40
>>> [   16.910902]  [] ? kthread_create_on_node+0x40/0x40
>>> [   16.910904] ---[ end trace aa169ad4461f2f18 ]---
>>> 
>>> Signed-off-by: Ioan-Adrian Ratiu 
>>
>> Benjamin, does this look reasonable to you? I'm planning to queue this for 
>> 4.8.
>
> Actually, I see two patches which might be related but not identical:
>
> ath9k: fix client mode beacon configuration
> https://patchwork.kernel.org/patch/9247699/
>
> ath9k: Fix beacon configuration assertion failure
> https://patchwork.kernel.org/patch/9281191/

Definitely we're touching the same logic and I'm leaning in the
direction of dropping my patch and using Felix's.

I can't test the other patch right noum though because I'm on vacantion.
I'll test next week and report back.

>
> Felix (CCed) & Benjamin: please take a look and advice which one I
> should take.
>
> -- 
> Kalle Valo


Re: [PATCH 1/3] ath10k: Ensure there are no stale ar->txqs entries.

2016-08-19 Thread Ben Greear



On 08/18/2016 11:59 PM, Michal Kazior wrote:

On 19 August 2016 at 03:26,   wrote:

From: Ben Greear 

I was seeing kernel crashes due to accessing freed memory
while debugging a 9984 firmware that was crashing often.

This patch fixes the crashes.  I am not certain if there
is a better way or not.

Signed-off-by: Ben Greear 
---
  drivers/net/wireless/ath/ath10k/mac.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 5659ef1..916119c 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -4172,8 +4172,10 @@ static void ath10k_mac_txq_init(struct ieee80211_txq 
*txq)
  static void ath10k_mac_txq_unref(struct ath10k *ar, struct ieee80211_txq *txq)
  {
 struct ath10k_txq *artxq = (void *)txq->drv_priv;
+   struct ath10k_txq *tmp, *walker;
 struct ath10k_skb_cb *cb;
 struct sk_buff *msdu;
+   struct ieee80211_txq *txq_tmp;
 int msdu_id;

 if (!txq)
@@ -4182,6 +4184,14 @@ static void ath10k_mac_txq_unref(struct ath10k *ar, 
struct ieee80211_txq *txq)
 spin_lock_bh(&ar->txqs_lock);
 if (!list_empty(&artxq->list))
 list_del_init(&artxq->list);
+
+   /* Remove from ar->txqs in case it still exists there. */
+   list_for_each_entry_safe(walker, tmp, &ar->txqs, list) {
+   txq_tmp = container_of((void *)walker, struct ieee80211_txq,
+  drv_priv);
+   if (txq_tmp == txq)
+   list_del(&walker->list);
+   }


How could this even happen? All artxq->list accesses (add/del) are
protected by txqs_lock so this shouldn't happen, no?

Do you perhaps have the logic around txqs reworked in your tree?


I don't have any significant changes as far as I can tell.

I can build you a buggy 9984 firmware to reproduce the problem if you want...

Maybe the upstream patch could WARN_ON in this case to see if anyone else
ever hits it?

I did see a comment in the mac80211 about some assumptions on the driver with
regard to station teardown...I am not 100% sure ath10k meets that assumption,
so maybe that is why I could see this problem.

Thanks,
Ben


--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com


[PATCH] rtlwifi: Fix missing country code for Great Britain

2016-08-19 Thread Larry Finger
Some RTL8821AE devices sold in Great Britain have the country code of
0x25 encoded in their EEPROM. This value is not tested in the routine
that establishes the regulatory info for the chip. The fix is to set
this code to have the same capabilities as the EU countries.

Signed-off-by: Larry Finger 
Cc: Stable 
---
 drivers/net/wireless/realtek/rtlwifi/regd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/regd.c 
b/drivers/net/wireless/realtek/rtlwifi/regd.c
index 3524441..6ee6bf8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/regd.c
+++ b/drivers/net/wireless/realtek/rtlwifi/regd.c
@@ -345,9 +345,9 @@ static const struct ieee80211_regdomain 
*_rtl_regdomain_select(
return &rtl_regdom_no_midband;
case COUNTRY_CODE_IC:
return &rtl_regdom_11;
-   case COUNTRY_CODE_ETSI:
case COUNTRY_CODE_TELEC_NETGEAR:
return &rtl_regdom_60_64;
+   case COUNTRY_CODE_ETSI:
case COUNTRY_CODE_SPAIN:
case COUNTRY_CODE_FRANCE:
case COUNTRY_CODE_ISRAEL:
@@ -406,6 +406,8 @@ static u8 channel_plan_to_country_code(u8 channelplan)
return COUNTRY_CODE_WORLD_WIDE_13;
case 0x22:
return COUNTRY_CODE_IC;
+   case 0x25:
+   return COUNTRY_CODE_ETSI;
case 0x32:
return COUNTRY_CODE_TELEC_NETGEAR;
case 0x41:
-- 
2.6.6



Re: [PATCH v2] brcmfmac: shut down AP and set IBSS mode only on primary interface

2016-08-19 Thread Rafał Miłecki
On 11 August 2016 at 07:44, Wright Feng  wrote:
> When stopping hostap on virtual interface, driver will set INFRA and AP
> mode that may affect the functionality on primary interface. For example,
> if we create and stop hostapd on virtual interface then association
> cannot work on primary interface because INFRA mode has been set to IBSS.
> Hence we shut down AP and set IBSS mode only on primary interface.

You also excluded from execution code setting BRCMF_C_SET_AP to 0.
Does it get a reset at some point? Maybe with a "bss" call? I'm
wondering if it's possible to use interface in managed mode if it was
used as AP once.

-- 
Rafał


[PATCHv7 0/4] register-field manipulation macros

2016-08-19 Thread Jakub Kicinski
Hi!

Looks like we're good to go :)

I've thrown in two mt7601u cleanups, macros are as approved
by Linus in the RFC.  I'm posting this already to give build
bot a head start while we wait for any additional feedback
on LKML.

-- v6 blurb:

This set moves to a global header file macros which I find
very useful and worth popularising.  The basic problem is
that since C bitfields are not very dependable accessing
subfields of registers becomes slightly inconvenient.
It is nice to have the necessary mask and shift operations
wrapped in a macro and have that macro compute shift
at compilation time using FFS.

My implementation follows what Felix Fietkau has done in
mt76.  Hannes Frederic Sowa suggested more use of standard
Linux/GCC functions.  Since the RFC I've also added a 
compile-time check to validate that the value passed to
setters fits in the mask.

I attempted the use of static inlines instead of macros
but it makes GCC < 6.0 barf at the BUILD_BUG_ON()s.
I also noticed that forcing arguments to be u32 for inlines
makes the compiler use 32bit arithmetic where it could
get away with 64bit before (on 64bit machines, obviously).
That's a potential performance concern but probably not
a very practical one today.  Apart from looking "cleaner"
static inlines would have the advantage that we could #undef
the auxiliary macros at the end of the header.

Build bot caught a build failure with -Os set.  AFAICT gcc
did not handle temporary variable I put in the macro
expression too well.  I work around that by defining
__BUILD_BUG_ON_NOT_POWER_OF_2 and using it instead of
BUILD_BUG_ON(!tmp || is_power_of_2(tmp)).

I'm planning to use those macros in another driver soon,
Felix may also use them when upstreaming mt76 if he chooses
to do so.

IMHO if accepted it would be best to push these through
Kalle's wireless drivers' tree, since the only existing
user is in drivers/net/wireless/.

v7:
 - drop the explicit type marking (u32/u64) - depend on the type
   of the mask instead;
 - only allow compilation time constant masks;
 - barf at "type of register too small to ever match mask" on get;
 - rename PUT -> PREP.
v6:
 - do a full rename in patch 2;
 - CC many people.
v5:
 - repost.
v4:
 - add documentation in the header.
v3:
 - don't use variables in statement expressions;
 - use __BUILD_BUG_ON_NOT_POWER_OF_2.
v2:
 - change Felix's email address.

Jakub Kicinski (4):
  add basic register-field manipulation macros
  mt7601u: remove redefinition of GENMASK
  mt7601u: remove unnecessary include
  mt7601u: use linux/bitfield.h

 drivers/net/wireless/mediatek/mt7601u/dma.c |  2 +-
 drivers/net/wireless/mediatek/mt7601u/dma.h | 10 ++-
 drivers/net/wireless/mediatek/mt7601u/eeprom.c  | 12 ++--
 drivers/net/wireless/mediatek/mt7601u/init.c| 10 +--
 drivers/net/wireless/mediatek/mt7601u/mac.c | 38 +-
 drivers/net/wireless/mediatek/mt7601u/main.c|  1 -
 drivers/net/wireless/mediatek/mt7601u/mcu.c | 20 +++---
 drivers/net/wireless/mediatek/mt7601u/mt7601u.h |  4 +-
 drivers/net/wireless/mediatek/mt7601u/phy.c | 44 ++--
 drivers/net/wireless/mediatek/mt7601u/regs.h|  4 --
 drivers/net/wireless/mediatek/mt7601u/tx.c  | 19 ++---
 drivers/net/wireless/mediatek/mt7601u/util.h| 77 
 include/linux/bitfield.h| 93 +
 include/linux/bug.h |  3 +
 14 files changed, 177 insertions(+), 160 deletions(-)
 delete mode 100644 drivers/net/wireless/mediatek/mt7601u/util.h
 create mode 100644 include/linux/bitfield.h

-- 
1.9.1



[PATCHv7 3/4] mt7601u: remove unnecessary include

2016-08-19 Thread Jakub Kicinski
There is no need to include linux/version.h in a in-tree
driver.

Reviewed-by: Dinan Gunawardena 
Signed-off-by: Jakub Kicinski 
---
 drivers/net/wireless/mediatek/mt7601u/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c 
b/drivers/net/wireless/mediatek/mt7601u/main.c
index e70dd9523911..43ebd460ba86 100644
--- a/drivers/net/wireless/mediatek/mt7601u/main.c
+++ b/drivers/net/wireless/mediatek/mt7601u/main.c
@@ -15,7 +15,6 @@
 #include "mt7601u.h"
 #include "mac.h"
 #include 
-#include 
 
 static int mt7601u_start(struct ieee80211_hw *hw)
 {
-- 
1.9.1



[PATCHv7 1/4] add basic register-field manipulation macros

2016-08-19 Thread Jakub Kicinski
Common approach to accessing register fields is to define
structures or sets of macros containing mask and shift pair.
Operations on the register are then performed as follows:

 field = (reg >> shift) & mask;

 reg &= ~(mask << shift);
 reg |= (field & mask) << shift;

Defining shift and mask separately is tedious.  Ivo van Doorn
came up with an idea of computing them at compilation time
based on a single shifted mask (later refined by Felix) which
can be used like this:

 #define REG_FIELD 0x000ff000

 field = FIELD_GET(REG_FIELD, reg);

 reg &= ~REG_FIELD;
 reg |= FIELD_PREP(REG_FIELD, field);

FIELD_{GET,PREP} macros take care of finding out what the
appropriate shift is based on compilation time ffs operation.

GENMASK can be used to define registers (which is usually
less error-prone and easier to match with datasheets).

This approach is the most convenient I've seen so to limit code
multiplication let's move the macros to a global header file.
Attempts to use static inlines instead of macros failed due
to false positive triggering of BUILD_BUG_ON()s, especially with
GCC < 6.0.

Reviewed-by: Dinan Gunawardena 
Signed-off-by: Jakub Kicinski 
---
 include/linux/bitfield.h | 93 
 include/linux/bug.h  |  3 ++
 2 files changed, 96 insertions(+)
 create mode 100644 include/linux/bitfield.h

diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
new file mode 100644
index ..32ca8863e66d
--- /dev/null
+++ b/include/linux/bitfield.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 Felix Fietkau 
+ * Copyright (C) 2004 - 2009 Ivo van Doorn 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _LINUX_BITFIELD_H
+#define _LINUX_BITFIELD_H
+
+#include 
+
+/*
+ * Bitfield access macros
+ *
+ * FIELD_{GET,PREP} macros take as first parameter shifted mask
+ * from which they extract the base mask and shift amount.
+ * Mask must be a compilation time constant.
+ *
+ * Example:
+ *
+ *  #define REG_FIELD_A  GENMASK(6, 0)
+ *  #define REG_FIELD_B  BIT(7)
+ *  #define REG_FIELD_C  GENMASK(15, 8)
+ *  #define REG_FIELD_D  GENMASK(31, 16)
+ *
+ * Get:
+ *  a = FIELD_GET(REG_FIELD_A, reg);
+ *  b = FIELD_GET(REG_FIELD_B, reg);
+ *
+ * Set:
+ *  reg = FIELD_PREP(REG_FIELD_A, 1) |
+ *   FIELD_PREP(REG_FIELD_B, 0) |
+ *   FIELD_PREP(REG_FIELD_C, c) |
+ *   FIELD_PREP(REG_FIELD_D, 0x40);
+ *
+ * Modify:
+ *  reg &= ~REG_FIELD_C;
+ *  reg |= FIELD_PREP(REG_FIELD_C, c);
+ */
+
+#define _bf_shf(x) (__builtin_ffsll(x) - 1)
+
+#define _BF_FIELD_CHECK(_mask, _reg, _val, _pfx)   \
+   ({  \
+   BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
+_pfx "mask is not constant");  \
+   BUILD_BUG_ON_MSG(!(_mask), _pfx "mask is zero");\
+   BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?   \
+~((_mask) >> _bf_shf(_mask)) & (_val) : 0, \
+_pfx "value too large for the field"); \
+   BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \
+_pfx "type of reg too small for mask"); \
+   __BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \
+ (1ULL << _bf_shf(_mask))); \
+   })
+
+/**
+ * FIELD_PREP() - prepare a bitfield element
+ * @_mask: shifted mask defining the field's length and position
+ * @_val:  value to put in the field
+ *
+ * FIELD_PREP() masks and shifts up the value.  The result should
+ * be combined with other fields of the bitfield using logical OR.
+ */
+#define FIELD_PREP(_mask, _val)
\
+   ({  \
+   _BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
+   ((typeof(_mask))(_val) << _bf_shf(_mask)) & (_mask);\
+   })
+
+/**
+ * FIELD_GET() - extract a bitfield element
+ * @_mask: shifted mask defining the field's length and position
+ * @_reg:  32bit value of entire bitfield
+ *
+ * FIELD_GET() extracts the field specified by @_mask from the
+ * bitfield passed in as @_reg by masking and shifting it down.
+ */
+#define FIELD_GET(_mask, _reg) \
+   ({  \
+   _BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: ");\
+   (typ

[PATCHv7 2/4] mt7601u: remove redefinition of GENMASK

2016-08-19 Thread Jakub Kicinski
Remove redefinition of GENMASK which should not be there
in the upstream version of the code.

Reviewed-by: Dinan Gunawardena 
Signed-off-by: Jakub Kicinski 
---
 drivers/net/wireless/mediatek/mt7601u/regs.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/regs.h 
b/drivers/net/wireless/mediatek/mt7601u/regs.h
index afd8978e83fa..27a429d90cec 100644
--- a/drivers/net/wireless/mediatek/mt7601u/regs.h
+++ b/drivers/net/wireless/mediatek/mt7601u/regs.h
@@ -17,10 +17,6 @@
 
 #include 
 
-#ifndef GENMASK
-#define GENMASK(h, l)   (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l))
-#endif
-
 #define MT_ASIC_VERSION0x
 
 #define MT76XX_REV_E3  0x22
-- 
1.9.1



[PATCHv7 4/4] mt7601u: use linux/bitfield.h

2016-08-19 Thread Jakub Kicinski
Use the newly added linux/bitfield.h.

Reviewed-by: Dinan Gunawardena 
Signed-off-by: Jakub Kicinski 
---
 drivers/net/wireless/mediatek/mt7601u/dma.c |  2 +-
 drivers/net/wireless/mediatek/mt7601u/dma.h | 10 ++--
 drivers/net/wireless/mediatek/mt7601u/eeprom.c  | 12 ++--
 drivers/net/wireless/mediatek/mt7601u/init.c| 10 ++--
 drivers/net/wireless/mediatek/mt7601u/mac.c | 38 ++--
 drivers/net/wireless/mediatek/mt7601u/mcu.c | 20 +++
 drivers/net/wireless/mediatek/mt7601u/mt7601u.h |  4 +-
 drivers/net/wireless/mediatek/mt7601u/phy.c | 44 +++---
 drivers/net/wireless/mediatek/mt7601u/tx.c  | 19 +++---
 drivers/net/wireless/mediatek/mt7601u/util.h| 77 -
 10 files changed, 81 insertions(+), 155 deletions(-)
 delete mode 100644 drivers/net/wireless/mediatek/mt7601u/util.h

diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c 
b/drivers/net/wireless/mediatek/mt7601u/dma.c
index 57a80cfa39b1..a8bc064bc14f 100644
--- a/drivers/net/wireless/mediatek/mt7601u/dma.c
+++ b/drivers/net/wireless/mediatek/mt7601u/dma.c
@@ -103,7 +103,7 @@ static void mt7601u_rx_process_seg(struct mt7601u_dev *dev, 
u8 *data,
 
if (unlikely(rxwi->zero[0] || rxwi->zero[1] || rxwi->zero[2]))
dev_err_once(dev->dev, "Error: RXWI zero fields are set\n");
-   if (unlikely(MT76_GET(MT_RXD_INFO_TYPE, fce_info)))
+   if (unlikely(FIELD_GET(MT_RXD_INFO_TYPE, fce_info)))
dev_err_once(dev->dev, "Error: RX path seen a non-pkt urb\n");
 
trace_mt_rx(dev, rxwi, fce_info);
diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.h 
b/drivers/net/wireless/mediatek/mt7601u/dma.h
index 978e8a90b87f..270d126880c0 100644
--- a/drivers/net/wireless/mediatek/mt7601u/dma.h
+++ b/drivers/net/wireless/mediatek/mt7601u/dma.h
@@ -18,8 +18,6 @@
 #include 
 #include 
 
-#include "util.h"
-
 #define MT_DMA_HDR_LEN 4
 #define MT_RX_INFO_LEN 4
 #define MT_FCE_INFO_LEN4
@@ -79,9 +77,9 @@ static inline int mt7601u_dma_skb_wrap(struct sk_buff *skb,
 */
 
info = flags |
-   MT76_SET(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |
-   MT76_SET(MT_TXD_INFO_D_PORT, d_port) |
-   MT76_SET(MT_TXD_INFO_TYPE, type);
+   FIELD_PREP(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |
+   FIELD_PREP(MT_TXD_INFO_D_PORT, d_port) |
+   FIELD_PREP(MT_TXD_INFO_TYPE, type);
 
put_unaligned_le32(info, skb_push(skb, sizeof(info)));
return skb_put_padto(skb, round_up(skb->len, 4) + 4);
@@ -90,7 +88,7 @@ static inline int mt7601u_dma_skb_wrap(struct sk_buff *skb,
 static inline int
 mt7601u_dma_skb_wrap_pkt(struct sk_buff *skb, enum mt76_qsel qsel, u32 flags)
 {
-   flags |= MT76_SET(MT_TXD_PKT_INFO_QSEL, qsel);
+   flags |= FIELD_PREP(MT_TXD_PKT_INFO_QSEL, qsel);
return mt7601u_dma_skb_wrap(skb, WLAN_PORT, DMA_PACKET, flags);
 }
 
diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c 
b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
index 8d8ee0344f7b..da6faea092d6 100644
--- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
@@ -45,8 +45,8 @@ mt7601u_efuse_read(struct mt7601u_dev *dev, u16 addr, u8 
*data,
val = mt76_rr(dev, MT_EFUSE_CTRL);
val &= ~(MT_EFUSE_CTRL_AIN |
 MT_EFUSE_CTRL_MODE);
-   val |= MT76_SET(MT_EFUSE_CTRL_AIN, addr & ~0xf) |
-  MT76_SET(MT_EFUSE_CTRL_MODE, mode) |
+   val |= FIELD_PREP(MT_EFUSE_CTRL_AIN, addr & ~0xf) |
+  FIELD_PREP(MT_EFUSE_CTRL_MODE, mode) |
   MT_EFUSE_CTRL_KICK;
mt76_wr(dev, MT_EFUSE_CTRL, val);
 
@@ -128,8 +128,8 @@ mt7601u_set_chip_cap(struct mt7601u_dev *dev, u8 *eeprom)
if (!field_valid(nic_conf0 >> 8))
return;
 
-   if (MT76_GET(MT_EE_NIC_CONF_0_RX_PATH, nic_conf0) > 1 ||
-   MT76_GET(MT_EE_NIC_CONF_0_TX_PATH, nic_conf0) > 1)
+   if (FIELD_GET(MT_EE_NIC_CONF_0_RX_PATH, nic_conf0) > 1 ||
+   FIELD_GET(MT_EE_NIC_CONF_0_TX_PATH, nic_conf0) > 1)
dev_err(dev->dev,
"Error: device has more than 1 RX/TX stream!\n");
 }
@@ -150,7 +150,7 @@ mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 
*eeprom)
 
mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->macaddr));
mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(dev->macaddr + 4) |
-   MT76_SET(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
+   FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
 
return 0;
 }
@@ -176,7 +176,7 @@ mt7601u_set_channel_power(struct mt7601u_dev *dev, u8 
*eeprom)
u8 max_pwr;
 
val = mt7601u_rr(dev, MT_TX_ALC_CFG_0);
-   max_pwr = MT76_GET(MT_TX_ALC_CFG_0_LIMIT_0, val);
+   max_pwr = FIELD_GET(MT_TX_ALC_CFG_0_LIMIT_0, val);
 
if (mt7601u_has_tssi(dev, eeprom)) {
mt7601u_set_channel_tar

Re: [PATCHv7 4/4] mt7601u: use linux/bitfield.h

2016-08-19 Thread Arend Van Spriel
On 19-8-2016 18:44, Jakub Kicinski wrote:
> Use the newly added linux/bitfield.h.
> 
> Reviewed-by: Dinan Gunawardena 
> Signed-off-by: Jakub Kicinski 
> ---
>  drivers/net/wireless/mediatek/mt7601u/dma.c |  2 +-
>  drivers/net/wireless/mediatek/mt7601u/dma.h | 10 ++--
>  drivers/net/wireless/mediatek/mt7601u/eeprom.c  | 12 ++--
>  drivers/net/wireless/mediatek/mt7601u/init.c| 10 ++--
>  drivers/net/wireless/mediatek/mt7601u/mac.c | 38 ++--
>  drivers/net/wireless/mediatek/mt7601u/mcu.c | 20 +++
>  drivers/net/wireless/mediatek/mt7601u/mt7601u.h |  4 +-
>  drivers/net/wireless/mediatek/mt7601u/phy.c | 44 +++---
>  drivers/net/wireless/mediatek/mt7601u/tx.c  | 19 +++---
>  drivers/net/wireless/mediatek/mt7601u/util.h| 77 
> -
>  10 files changed, 81 insertions(+), 155 deletions(-)
>  delete mode 100644 drivers/net/wireless/mediatek/mt7601u/util.h
> 
> diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c 
> b/drivers/net/wireless/mediatek/mt7601u/dma.c
> index 57a80cfa39b1..a8bc064bc14f 100644
> --- a/drivers/net/wireless/mediatek/mt7601u/dma.c
> +++ b/drivers/net/wireless/mediatek/mt7601u/dma.c
> @@ -103,7 +103,7 @@ static void mt7601u_rx_process_seg(struct mt7601u_dev 
> *dev, u8 *data,
>  
>   if (unlikely(rxwi->zero[0] || rxwi->zero[1] || rxwi->zero[2]))
>   dev_err_once(dev->dev, "Error: RXWI zero fields are set\n");
> - if (unlikely(MT76_GET(MT_RXD_INFO_TYPE, fce_info)))
> + if (unlikely(FIELD_GET(MT_RXD_INFO_TYPE, fce_info)))
>   dev_err_once(dev->dev, "Error: RX path seen a non-pkt urb\n");
>  
>   trace_mt_rx(dev, rxwi, fce_info);
> diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.h 
> b/drivers/net/wireless/mediatek/mt7601u/dma.h
> index 978e8a90b87f..270d126880c0 100644
> --- a/drivers/net/wireless/mediatek/mt7601u/dma.h
> +++ b/drivers/net/wireless/mediatek/mt7601u/dma.h
> @@ -18,8 +18,6 @@
>  #include 
>  #include 
>  
> -#include "util.h"
> -
>  #define MT_DMA_HDR_LEN   4
>  #define MT_RX_INFO_LEN   4
>  #define MT_FCE_INFO_LEN  4
> @@ -79,9 +77,9 @@ static inline int mt7601u_dma_skb_wrap(struct sk_buff *skb,
>*/
>  
>   info = flags |
> - MT76_SET(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |
> - MT76_SET(MT_TXD_INFO_D_PORT, d_port) |
> - MT76_SET(MT_TXD_INFO_TYPE, type);
> + FIELD_PREP(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |
> + FIELD_PREP(MT_TXD_INFO_D_PORT, d_port) |
> + FIELD_PREP(MT_TXD_INFO_TYPE, type);

So what are those flags? Is there no field definition for those.

>   put_unaligned_le32(info, skb_push(skb, sizeof(info)));
>   return skb_put_padto(skb, round_up(skb->len, 4) + 4);
> @@ -90,7 +88,7 @@ static inline int mt7601u_dma_skb_wrap(struct sk_buff *skb,
>  static inline int
>  mt7601u_dma_skb_wrap_pkt(struct sk_buff *skb, enum mt76_qsel qsel, u32 flags)
>  {
> - flags |= MT76_SET(MT_TXD_PKT_INFO_QSEL, qsel);
> + flags |= FIELD_PREP(MT_TXD_PKT_INFO_QSEL, qsel);

Ah. This is the flags being ORed in above. I suppose there are more
callsites to mt7601u_dma_skb_wrap().

>   return mt7601u_dma_skb_wrap(skb, WLAN_PORT, DMA_PACKET, flags);
>  }
>  
> diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c 
> b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
> index 8d8ee0344f7b..da6faea092d6 100644
> --- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
> @@ -45,8 +45,8 @@ mt7601u_efuse_read(struct mt7601u_dev *dev, u16 addr, u8 
> *data,
>   val = mt76_rr(dev, MT_EFUSE_CTRL);
>   val &= ~(MT_EFUSE_CTRL_AIN |
>MT_EFUSE_CTRL_MODE);
> - val |= MT76_SET(MT_EFUSE_CTRL_AIN, addr & ~0xf) |
> -MT76_SET(MT_EFUSE_CTRL_MODE, mode) |
> + val |= FIELD_PREP(MT_EFUSE_CTRL_AIN, addr & ~0xf) |
> +FIELD_PREP(MT_EFUSE_CTRL_MODE, mode) |
>  MT_EFUSE_CTRL_KICK;

MT_EFUSE_CTRL_KICK is probably a 1-bit field in MT_EFUSE_CTRL register.
It looks like you did not want to go all the way although you do give an
example in bitfield.h, ie. + *  #define REG_FIELD_B  BIT(7).

Regards,
Arend


[PATCH] cfg80211: Add stub for cfg80211_get_station()

2016-08-19 Thread Linus Lüssing
This allows modules using this function (currently: batman-adv) to
compile even if cfg80211 is not built at all, thus relaxing
dependencies.

Signed-off-by: Linus Lüssing 
---
 include/net/cfg80211.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9c23f4d3..beb7610 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1102,6 +1102,7 @@ struct station_info {
struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1];
 };
 
+#if IS_ENABLED(CONFIG_CFG80211)
 /**
  * cfg80211_get_station - retrieve information about a given station
  * @dev: the device where the station is supposed to be connected to
@@ -1114,6 +1115,14 @@ struct station_info {
  */
 int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
 struct station_info *sinfo);
+#else
+static inline int cfg80211_get_station(struct net_device *dev,
+  const u8 *mac_addr,
+  struct station_info *sinfo)
+{
+   return -ENOENT;
+}
+#endif
 
 /**
  * enum monitor_flags - monitor flags
-- 
2.1.4



[PATCH 02/20] rtl8xxxu: Mark 0x2001:0x3308 as tested

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

D-Link DWA-121 is reported as working.

Reported-by: Stefano Bravi 
Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 47d0868..ca4c40d 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5975,6 +5975,10 @@ static int rtl8xxxu_probe(struct usb_interface 
*interface,
if (id->idProduct == 0x648b)
untested = 0;
break;
+   case 0x2001:
+   if (id->idProduct == 0x3308)
+   untested = 0;
+   break;
default:
break;
}
@@ -6147,6 +6151,9 @@ static struct usb_device_id dev_table[] = {
 /* Tested by Jocelyn Mayer */
 {USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0x648b, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
+/* Tested by Stefano Bravi */
+{USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x3308, 0xff, 0xff, 0xff),
+   .driver_info = (unsigned long)&rtl8192cu_fops},
 /* Currently untested 8188 series devices */
 {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8191, 0xff, 0xff, 
0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
@@ -6194,8 +6201,6 @@ static struct usb_device_id dev_table[] = {
.driver_info = (unsigned long)&rtl8192cu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x13d3, 0x3357, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
-{USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x3308, 0xff, 0xff, 0xff),
-   .driver_info = (unsigned long)&rtl8192cu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x330b, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x2019, 0x4902, 0xff, 0xff, 0xff),
-- 
2.7.4



[PATCH 01/20] rtl8xxxu: Mark 0x20f4:0x648b as tested

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Successfully tested by Jocelyn Mayer

Reported-by: J. Mayer 
Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 77048db..47d0868 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5971,6 +5971,10 @@ static int rtl8xxxu_probe(struct usb_interface 
*interface,
if (id->idProduct == 0x1004)
untested = 0;
break;
+   case 0x20f4:
+   if (id->idProduct == 0x648b)
+   untested = 0;
+   break;
default:
break;
}
@@ -6140,6 +6144,9 @@ static struct usb_device_id dev_table[] = {
 /* Tested by Andrea Merello */
 {USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x1004, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
+/* Tested by Jocelyn Mayer */
+{USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0x648b, 0xff, 0xff, 0xff),
+   .driver_info = (unsigned long)&rtl8192cu_fops},
 /* Currently untested 8188 series devices */
 {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8191, 0xff, 0xff, 
0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
@@ -6199,8 +6206,6 @@ static struct usb_device_id dev_table[] = {
.driver_info = (unsigned long)&rtl8192cu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x2019, 0xed17, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
-{USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0x648b, 0xff, 0xff, 0xff),
-   .driver_info = (unsigned long)&rtl8192cu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x4855, 0x0090, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)&rtl8192cu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x4856, 0x0091, 0xff, 0xff, 0xff),
-- 
2.7.4



[PATCH 03/20] rtl8xxxu: Fix error handling if rtl8xxxu_init_device() fails

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

For some reason we lost the code bailing if rtl8xxxu_init_device()
returned an error.

This catches the error and also cleans up the error handling.

Signed-off-by: Jes Sorensen 
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c| 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index ca4c40d..9c6305b 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5947,7 +5947,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
struct ieee80211_hw *hw;
struct usb_device *udev;
struct ieee80211_supported_band *sband;
-   int ret = 0;
+   int ret;
int untested = 1;
 
udev = usb_get_dev(interface_to_usbdev(interface));
@@ -5995,6 +5995,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
hw = ieee80211_alloc_hw(sizeof(struct rtl8xxxu_priv), &rtl8xxxu_ops);
if (!hw) {
ret = -ENOMEM;
+   priv = NULL;
goto exit;
}
 
@@ -6043,6 +6044,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
}
 
ret = rtl8xxxu_init_device(hw);
+   if (ret)
+   goto exit;
 
hw->wiphy->max_scan_ssids = 1;
hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
@@ -6093,9 +6096,20 @@ static int rtl8xxxu_probe(struct usb_interface 
*interface,
goto exit;
}
 
+   return 0;
+
 exit:
-   if (ret < 0)
-   usb_put_dev(udev);
+   usb_set_intfdata(interface, NULL);
+
+   if (priv) {
+   kfree(priv->fw_data);
+   mutex_destroy(&priv->usb_buf_mutex);
+   mutex_destroy(&priv->h2c_mutex);
+   }
+   usb_put_dev(udev);
+
+   ieee80211_free_hw(hw);
+
return ret;
 }
 
-- 
2.7.4



[PATCH 04/20] rtl8xxxu: Add TP-Link TL-WN823N v2 to list of supported devices

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

This is an rtl8192eu based dongle (the v1 is an rtl8192cu). Reported
and tested by Myckel Habets.

Reported-by: Myckel Habets 
Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 9c6305b..948f153 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5979,6 +5979,10 @@ static int rtl8xxxu_probe(struct usb_interface 
*interface,
if (id->idProduct == 0x3308)
untested = 0;
break;
+   case 0x2357:
+   if (id->idProduct == 0x0109)
+   untested = 0;
+   break;
default:
break;
}
@@ -6146,6 +6150,9 @@ static struct usb_device_id dev_table[] = {
.driver_info = (unsigned long)&rtl8723au_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x818b, 0xff, 0xff, 
0xff),
.driver_info = (unsigned long)&rtl8192eu_fops},
+/* Tested by Myckel Habets */
+{USB_DEVICE_AND_INTERFACE_INFO(0x2357, 0x0109, 0xff, 0xff, 0xff),
+   .driver_info = (unsigned long)&rtl8192eu_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0xb720, 0xff, 0xff, 
0xff),
.driver_info = (unsigned long)&rtl8723bu_fops},
 #ifdef CONFIG_RTL8XXXU_UNTESTED
-- 
2.7.4



[PATCH 13/20] rtl8xxxu: Convert flags in rtl8xxxu_fileops to bitflags

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

This leaves space for a few more flags within the same space.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index c8d7075..c5b6846 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1340,8 +1340,8 @@ struct rtl8xxxu_fileops {
int rx_agg_buf_size;
char tx_desc_size;
char rx_desc_size;
-   char has_s0s1;
-   char has_tx_report;
+   u8 has_s0s1:1;
+   u8 has_tx_report:1;
u32 adda_1t_init;
u32 adda_1t_path_on;
u32 adda_2t_path_on_a;
-- 
2.7.4



[PATCH 19/20] rtl8xxxu: gen1: Fix non static symbol warning

2016-08-19 Thread Jes . Sorensen
From: Wei Yongjun 

Fixes the following sparse warning:

drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:898:1: warning:
 symbol 'rtl8xxxu_gen1_h2c_cmd' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index e02fab0..508d46f 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -894,7 +894,7 @@ int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv *priv,
return retval;
 }
 
-int
+static int
 rtl8xxxu_gen1_h2c_cmd(struct rtl8xxxu_priv *priv, struct h2c_cmd *h2c, int len)
 {
struct device *dev = &priv->udev->dev;
-- 
2.7.4



[PATCH 16/20] rtl8xxxu: Determine the need for SGI before handling specific TX desc formats

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

In order to be able to split out the TX descriptor handling code,
determine in advance the need to mark SGI.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 2f951cf..6dc3f52 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4770,7 +4770,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
u16 rate_flag = tx_info->control.rates[0].flags;
int tx_desc_size = priv->fops->tx_desc_size;
int ret;
-   bool usedesc40, ampdu_enable;
+   bool usedesc40, ampdu_enable, sgi = false;
 
if (skb_headroom(skb) < tx_desc_size) {
dev_warn(dev,
@@ -4854,6 +4854,12 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
else
rate = tx_rate->hw_value;
 
+   if (rate_flag & IEEE80211_TX_RC_SHORT_GI ||
+   (ieee80211_is_data_qos(hdr->frame_control) &&
+sta && sta->ht_cap.cap &
+(IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20)))
+   sgi = true;
+
seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
if (!usedesc40) {
tx_desc->txdw5 = cpu_to_le32(rate);
@@ -4886,12 +4892,8 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
(sta && vif && vif->bss_conf.use_short_preamble))
tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
 
-   if (rate_flag & IEEE80211_TX_RC_SHORT_GI ||
-   (ieee80211_is_data_qos(hdr->frame_control) &&
-sta && sta->ht_cap.cap &
-(IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))) {
+   if (sgi)
tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
-   }
 
if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
/*
-- 
2.7.4



[PATCH 15/20] rtl8xxxu: Simplify calculating of hw value used for setting TX rate

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Calculating the value in one place rather than using one calculation
in one place and a different one for management frames in another
location makes little sense.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 6de5b8f..2f951cf 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4848,7 +4848,8 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
}
}
 
-   if (rate_flag & IEEE80211_TX_RC_MCS)
+   if (rate_flag & IEEE80211_TX_RC_MCS &&
+   !ieee80211_is_mgmt(hdr->frame_control))
rate = tx_info->control.rates[0].idx + DESC_RATE_MCS0;
else
rate = tx_rate->hw_value;
@@ -4869,7 +4870,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
 
if (ieee80211_is_mgmt(hdr->frame_control)) {
-   tx_desc->txdw5 = cpu_to_le32(tx_rate->hw_value);
+   tx_desc->txdw5 = cpu_to_le32(rate);
tx_desc->txdw4 |=
cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
tx_desc->txdw5 |=
@@ -4923,7 +4924,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
 
if (ieee80211_is_mgmt(hdr->frame_control)) {
-   tx_desc40->txdw4 = cpu_to_le32(tx_rate->hw_value);
+   tx_desc40->txdw4 = cpu_to_le32(rate);
tx_desc40->txdw3 |=
cpu_to_le32(TXDESC40_USE_DRIVER_RATE);
tx_desc40->txdw4 |=
-- 
2.7.4



[PATCH 20/20] net: wireless: rtl8xxxu: Make rtl8xxxu_ampdu_action less chatty

2016-08-19 Thread Jes . Sorensen
From: Hans de Goede 

On my home network rtl8xxxu is spamming the log with
IEEE80211_AMPDU_RX_START / IEEE80211_AMPDU_RX_STOP every few seconds
turn these messages into debug messages.

Signed-off-by: Hans de Goede 
Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 508d46f..c362083 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5696,7 +5696,7 @@ rtl8xxxu_ampdu_action(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 
switch (action) {
case IEEE80211_AMPDU_TX_START:
-   dev_info(dev, "%s: IEEE80211_AMPDU_TX_START\n", __func__);
+   dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_START\n", __func__);
ampdu_factor = sta->ht_cap.ampdu_factor;
ampdu_density = sta->ht_cap.ampdu_density;
rtl8xxxu_set_ampdu_factor(priv, ampdu_factor);
@@ -5706,21 +5706,21 @@ rtl8xxxu_ampdu_action(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
ampdu_factor, ampdu_density);
break;
case IEEE80211_AMPDU_TX_STOP_FLUSH:
-   dev_info(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH\n", __func__);
+   dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH\n", __func__);
rtl8xxxu_set_ampdu_factor(priv, 0);
rtl8xxxu_set_ampdu_min_space(priv, 0);
break;
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
-   dev_info(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH_CONT\n",
+   dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH_CONT\n",
 __func__);
rtl8xxxu_set_ampdu_factor(priv, 0);
rtl8xxxu_set_ampdu_min_space(priv, 0);
break;
case IEEE80211_AMPDU_RX_START:
-   dev_info(dev, "%s: IEEE80211_AMPDU_RX_START\n", __func__);
+   dev_dbg(dev, "%s: IEEE80211_AMPDU_RX_START\n", __func__);
break;
case IEEE80211_AMPDU_RX_STOP:
-   dev_info(dev, "%s: IEEE80211_AMPDU_RX_STOP\n", __func__);
+   dev_dbg(dev, "%s: IEEE80211_AMPDU_RX_STOP\n", __func__);
break;
default:
break;
-- 
2.7.4



[PATCH 08/20] rtl8xxxu: Remove now obsolete rtl8xxxu_old_init_queue_reserved_page()

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Switching over the old devices to use the new function allows us to
get rid of this legacy.

Signed-off-by: Jes Sorensen 
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 30 ++
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 948f153..efe24a6 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -3847,28 +3847,6 @@ void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv)
rtl8xxxu_write32(priv, REG_RX_WAIT_CCA, val32);
 }
 
-static void rtl8xxxu_old_init_queue_reserved_page(struct rtl8xxxu_priv *priv)
-{
-   u8 val8;
-   u32 val32;
-
-   if (priv->ep_tx_normal_queue)
-   val8 = TX_PAGE_NUM_NORM_PQ;
-   else
-   val8 = 0;
-
-   rtl8xxxu_write8(priv, REG_RQPN_NPQ, val8);
-
-   val32 = (TX_PAGE_NUM_PUBQ << RQPN_PUB_PQ_SHIFT) | RQPN_LOAD;
-
-   if (priv->ep_tx_high_queue)
-   val32 |= (TX_PAGE_NUM_HI_PQ << RQPN_HI_PQ_SHIFT);
-   if (priv->ep_tx_low_queue)
-   val32 |= (TX_PAGE_NUM_LO_PQ << RQPN_LO_PQ_SHIFT);
-
-   rtl8xxxu_write32(priv, REG_RQPN, val32);
-}
-
 static void rtl8xxxu_init_queue_reserved_page(struct rtl8xxxu_priv *priv)
 {
struct rtl8xxxu_fileops *fops = priv->fops;
@@ -3929,12 +3907,8 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
goto exit;
}
 
-   if (!macpower) {
-   if (priv->fops->total_page_num)
-   rtl8xxxu_init_queue_reserved_page(priv);
-   else
-   rtl8xxxu_old_init_queue_reserved_page(priv);
-   }
+   if (!macpower)
+   rtl8xxxu_init_queue_reserved_page(priv);
 
ret = rtl8xxxu_init_queue_priority(priv);
dev_dbg(dev, "%s: init_queue_priority %i\n", __func__, ret);
-- 
2.7.4



[PATCH 14/20] rtl8xxxu: Introduce fops bitflag indicating type of thermal meter

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Do not rely on TX descriptor size to determine the thermal meter
type.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h   | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 2 +-
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index c5b6846..68d80c4 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1342,6 +1342,7 @@ struct rtl8xxxu_fileops {
char rx_desc_size;
u8 has_s0s1:1;
u8 has_tx_report:1;
+   u8 gen2_thermal_meter:1;
u32 adda_1t_init;
u32 adda_1t_path_on;
u32 adda_2t_path_on_a;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index 9a1994f..9901199 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -1505,6 +1505,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = {
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
.rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
.has_s0s1 = 0,
+   .gen2_thermal_meter = 1,
.adda_1t_init = 0x0fc01616,
.adda_1t_path_on = 0x0fc01616,
.adda_2t_path_on_a = 0x0fc01616,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 0b6a6ca..dd2c0f0 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -1667,6 +1667,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
.rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
.has_s0s1 = 1,
.has_tx_report = 1,
+   .gen2_thermal_meter = 1,
.adda_1t_init = 0x01c00014,
.adda_1t_path_on = 0x01c00014,
.adda_2t_path_on_a = 0x01c00014,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 81b9582..6de5b8f 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4195,7 +4195,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
/*
 * This should enable thermal meter
 */
-   if (priv->fops->tx_desc_size == sizeof(struct rtl8xxxu_txdesc40))
+   if (priv->fops->gen2_thermal_meter)
rtl8xxxu_write_rfreg(priv,
 RF_A, RF6052_REG_T_METER_8723B, 0x37cf8);
else
-- 
2.7.4



[PATCH 17/20] rtl8xxxu: Determine need for shore preamble before updating TX descriptors

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Another patch to move this detection out of the code handling the TX
descriptor update.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 6dc3f52..cfb2dfd 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4770,7 +4770,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
u16 rate_flag = tx_info->control.rates[0].flags;
int tx_desc_size = priv->fops->tx_desc_size;
int ret;
-   bool usedesc40, ampdu_enable, sgi = false;
+   bool usedesc40, ampdu_enable, sgi = false, short_preamble = false;
 
if (skb_headroom(skb) < tx_desc_size) {
dev_warn(dev,
@@ -4860,6 +4860,10 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20)))
sgi = true;
 
+   if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ||
+   (sta && vif && vif->bss_conf.use_short_preamble))
+   short_preamble = true;
+
seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
if (!usedesc40) {
tx_desc->txdw5 = cpu_to_le32(rate);
@@ -4888,8 +4892,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
if (ieee80211_is_data_qos(hdr->frame_control))
tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
 
-   if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ||
-   (sta && vif && vif->bss_conf.use_short_preamble))
+   if (short_preamble)
tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
 
if (sgi)
@@ -4935,8 +4938,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE);
}
 
-   if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ||
-   (sta && vif && vif->bss_conf.use_short_preamble))
+   if (short_preamble)
tx_desc40->txdw5 |=
cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
 
-- 
2.7.4



[PATCH 05/20] rtl8xxxu: Add TX page defines for 8723b

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

This switches the 8723b driver to use the new
rtl8xxxu_init_queue_reserved_page() function.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h   | 6 ++
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 4 
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 4341d56..da4f148 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -43,6 +43,7 @@
 
 #define TX_TOTAL_PAGE_NUM  0xf8
 #define TX_TOTAL_PAGE_NUM_8192E0xf3
+#define TX_TOTAL_PAGE_NUM_8723B0xf7
 /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */
 #define TX_PAGE_NUM_PUBQ   0xe7
 #define TX_PAGE_NUM_HI_PQ  0x0c
@@ -54,6 +55,11 @@
 #define TX_PAGE_NUM_LO_PQ_8192E0x0c
 #define TX_PAGE_NUM_NORM_PQ_8192E  0x00
 
+#define TX_PAGE_NUM_PUBQ_8723B 0xe7
+#define TX_PAGE_NUM_HI_PQ_8723B0x0c
+#define TX_PAGE_NUM_LO_PQ_8723B0x02
+#define TX_PAGE_NUM_NORM_PQ_8723B  0x02
+
 #define RTL_FW_PAGE_SIZE   4096
 #define RTL8XXXU_FIRMWARE_POLL_MAX 1000
 
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 9d45afb..c1323f0 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -1674,4 +1674,8 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
.pbp_rx = PBP_PAGE_SIZE_256,
.pbp_tx = PBP_PAGE_SIZE_256,
.mactable = rtl8723b_mac_init_table,
+   .total_page_num = TX_TOTAL_PAGE_NUM_8723B,
+   .page_num_hi = TX_PAGE_NUM_HI_PQ_8723B,
+   .page_num_lo = TX_PAGE_NUM_LO_PQ_8723B,
+   .page_num_norm = TX_PAGE_NUM_NORM_PQ_8723B,
 };
-- 
2.7.4



[PATCH 10/20] rtl8xxxu: Add bit definitions for REG_FPGA0_TX_INFO

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

This adds TX antenna selection bit defines for OFDM mode.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index 921c565..a338890 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -780,6 +780,10 @@
 #define  FPGA_RF_MODE_OFDM BIT(25)
 
 #define REG_FPGA0_TX_INFO  0x0804
+#define  FPGA0_TX_INFO_OFDM_PATH_A BIT(0)
+#define  FPGA0_TX_INFO_OFDM_PATH_B BIT(1)
+#define  FPGA0_TX_INFO_OFDM_PATH_C BIT(2)
+#define  FPGA0_TX_INFO_OFDM_PATH_D BIT(3)
 #define REG_FPGA0_PSD_FUNC 0x0808
 #define REG_FPGA0_TX_GAIN  0x080c
 #define REG_FPGA0_RF_TIMING1   0x0810
-- 
2.7.4



[PATCH 18/20] rtl8xxxu: Split filling of TX descriptors into separate functions

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Split the filling of TX descriptors into a generic portion used on all
devices, and format specific helper functions provided in the fops
structure.

This also cleaned up some mess, even if non harmful, in the handling
of txdesc40 descriptors, where the code randomly would switch between
the pointer to tx_desc and tx_desc40.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h   |  12 ++
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c |   1 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c |   1 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c |   1 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c |   1 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 198 -
 6 files changed, 125 insertions(+), 89 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 68d80c4..1f54b89 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1336,6 +1336,10 @@ struct rtl8xxxu_fileops {
  u32 ramask, int sgi);
void (*report_connect) (struct rtl8xxxu_priv *priv,
u8 macid, bool connect);
+   void (*fill_txdesc) (struct ieee80211_hdr *hdr,
+struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
+u16 rate_flag, bool sgi, bool short_preamble,
+bool ampdu_enable);
int writeN_block_size;
int rx_agg_buf_size;
char tx_desc_size;
@@ -1429,6 +1433,14 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, 
struct sk_buff *skb);
 int rtl8xxxu_gen2_channel_to_group(int channel);
 bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv,
  int result[][8], int c1, int c2);
+void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr,
+struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
+u16 rate_flag, bool sgi, bool short_preamble,
+bool ampdu_enable);
+void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr,
+struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate,
+u16 rate_flag, bool sgi, bool short_preamble,
+bool ampdu_enable);
 
 extern struct rtl8xxxu_fileops rtl8192cu_fops;
 extern struct rtl8xxxu_fileops rtl8192eu_fops;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
index cd13c25..f9e2050 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
@@ -567,6 +567,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = {
.set_tx_power = rtl8xxxu_gen1_set_tx_power,
.update_rate_mask = rtl8xxxu_update_rate_mask,
.report_connect = rtl8xxxu_gen1_report_connect,
+   .fill_txdesc = rtl8xxxu_fill_txdesc_v1,
.writeN_block_size = 128,
.rx_agg_buf_size = 16000,
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index 9901199..841522e 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -1501,6 +1501,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = {
.set_tx_power = rtl8192e_set_tx_power,
.update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
.report_connect = rtl8xxxu_gen2_report_connect,
+   .fill_txdesc = rtl8xxxu_fill_txdesc_v2,
.writeN_block_size = 128,
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
.rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
index d6f4968..aef3730 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
@@ -384,6 +384,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = {
.set_tx_power = rtl8xxxu_gen1_set_tx_power,
.update_rate_mask = rtl8xxxu_update_rate_mask,
.report_connect = rtl8xxxu_gen1_report_connect,
+   .fill_txdesc = rtl8xxxu_fill_txdesc_v1,
.writeN_block_size = 1024,
.rx_agg_buf_size = 16000,
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index dd2c0f0..6c086b5 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -1662,6 +1662,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
.set_tx_power = rtl8723b_set_tx_power,
.upda

[PATCH 09/20] rtl8xxxu: Simplify code setting TX buffer boundary

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

With all devices now offering fops->total_page_num, get rid of the
if mess for setting the TX buffer boundary.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index efe24a6..7a697c0 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -3968,13 +3968,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
/*
 * Set TX buffer boundary
 */
-   if (priv->rtl_chip == RTL8192E)
-   val8 = TX_TOTAL_PAGE_NUM_8192E + 1;
-   else
-   val8 = TX_TOTAL_PAGE_NUM + 1;
-
-   if (priv->rtl_chip == RTL8723B)
-   val8 -= 1;
+   val8 = priv->fops->total_page_num + 1;
 
rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8);
rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8);
-- 
2.7.4



[PATCH 12/20] rtl8xxxu: Use flag to indicate whether device has TX report timer support

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Use a fileops flag to indicate whether the device has TX report timer
support. This will make it easier to include future devices such as
8188eu to use the TX report timer.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h   | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 5 ++---
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index da4f148..c8d7075 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1341,6 +1341,7 @@ struct rtl8xxxu_fileops {
char tx_desc_size;
char rx_desc_size;
char has_s0s1;
+   char has_tx_report;
u32 adda_1t_init;
u32 adda_1t_path_on;
u32 adda_2t_path_on_a;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index c1323f0..0b6a6ca 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -1666,6 +1666,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
.rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
.has_s0s1 = 1,
+   .has_tx_report = 1,
.adda_1t_init = 0x01c00014,
.adda_1t_path_on = 0x01c00014,
.adda_2t_path_on_a = 0x01c00014,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 7a697c0..81b9582 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4000,10 +4000,9 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
priv->fops->usb_quirks(priv);
 
/*
-* Presumably this is for 8188EU as well
-* Enable TX report and TX report timer
+* Enable TX report and TX report timer for 8723bu/8188eu/...
 */
-   if (priv->rtl_chip == RTL8723B) {
+   if (priv->fops->has_tx_report) {
val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL);
val8 |= TX_REPORT_CTRL_TIMER_ENABLE;
rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8);
-- 
2.7.4



[PATCH 06/20] rtl8xxxu: Switch 8723a to use new rtl8xxxu_init_queue_reserved_page() routine

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

This changes the pub-queue value written to REQ_RQPN, however the old
code used a hard coded minimum value assuming there would always be an
active lo-queue, even when no USB EP was found for it.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
index 686c551..d6f4968 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
@@ -396,4 +396,8 @@ struct rtl8xxxu_fileops rtl8723au_fops = {
.pbp_rx = PBP_PAGE_SIZE_128,
.pbp_tx = PBP_PAGE_SIZE_128,
.mactable = rtl8xxxu_gen1_mac_init_table,
+   .total_page_num = TX_TOTAL_PAGE_NUM,
+   .page_num_hi = TX_PAGE_NUM_HI_PQ,
+   .page_num_lo = TX_PAGE_NUM_LO_PQ,
+   .page_num_norm = TX_PAGE_NUM_NORM_PQ,
 };
-- 
2.7.4



[PATCH 07/20] rtl8xxxu: Switch 8192cu/8188cu devices to use rtl8xxxu_init_queue_reserved_page()

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

This was the last user of the old
rtl8xxxu_old_init_queue_reserved_page() which can now be removed.

Signed-off-by: Jes Sorensen 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
index 69d1a14..cd13c25 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
@@ -579,5 +579,9 @@ struct rtl8xxxu_fileops rtl8192cu_fops = {
.pbp_rx = PBP_PAGE_SIZE_128,
.pbp_tx = PBP_PAGE_SIZE_128,
.mactable = rtl8xxxu_gen1_mac_init_table,
+   .total_page_num = TX_TOTAL_PAGE_NUM,
+   .page_num_hi = TX_PAGE_NUM_HI_PQ,
+   .page_num_lo = TX_PAGE_NUM_LO_PQ,
+   .page_num_norm = TX_PAGE_NUM_NORM_PQ,
 };
 #endif
-- 
2.7.4



[PATCH 11/20] rtl8xxxu: Add interrupt bit definitions for gen2 parts

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

These are primarily needed for SDIO/PCI parts, but the vendor driver
still sets them for some USB devices.

Signed-off-by: Jes Sorensen 
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h  | 56 ++
 1 file changed, 56 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index a338890..3555a2f 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -213,10 +213,66 @@
 #define REG_HMBOX_EXT_10x008a
 #define REG_HMBOX_EXT_20x008c
 #define REG_HMBOX_EXT_30x008e
+
 /* Interrupt registers for 8192e/8723bu/8812 */
 #define REG_HIMR0  0x00b0
+#define IMR0_TXCCK BIT(30) /* TXRPT interrupt when 
CCX bit
+  of the packet is set */
+#define IMR0_PSTIMEOUT BIT(29) /* Power Save Time Out 
Int */
+#define IMR0_GTINT4BIT(28) /* Set when GTIMER4 
expires */
+#define IMR0_GTINT3BIT(27) /* Set when GTIMER3 
expires */
+#define IMR0_TBDER BIT(26) /* Transmit Beacon0 
Error */
+#define IMR0_TBDOK BIT(25) /* Transmit Beacon0 OK 
*/
+#define IMR0_TSF_BIT32_TOGGLE  BIT(24) /* TSF Timer BIT32 
toggle
+  indication interrupt */
+#define IMR0_BCNDMAINT0BIT(20) /* Beacon DMA Interrupt 
0 */
+#define IMR0_BCNDERR0  BIT(16) /* Beacon Queue DMA 
Error 0 */
+#define IMR0_HSISR_IND_ON_INT  BIT(15) /* HSISR Indicator 
(HSIMR &
+  HSISR is true) */
+#define IMR0_BCNDMAINT_E   BIT(14) /* Beacon DMA Interrupt
+  Extension for Win7 */
+#define IMR0_ATIMEND   BIT(12) /* CTWidnow End or
+  ATIM Window End */
+#define IMR0_HISR1_IND_INT BIT(11) /* HISR1 Indicator
+  (HISR1 & HIMR1 is true) */
+#define IMR0_C2HCMDBIT(10) /* CPU to Host Command 
INT
+  Status, Write 1 to clear */
+#define IMR0_CPWM2 BIT(9)  /* CPU power Mode 
exchange INT
+  Status, Write 1 to clear */
+#define IMR0_CPWM  BIT(8)  /* CPU power Mode 
exchange INT
+  Status, Write 1 to clear */
+#define IMR0_HIGHDOK   BIT(7)  /* High Queue DMA OK */
+#define IMR0_MGNTDOK   BIT(6)  /* Management Queue DMA 
OK */
+#define IMR0_BKDOK BIT(5)  /* AC_BK DMA OK */
+#define IMR0_BEDOK BIT(4)  /* AC_BE DMA OK */
+#define IMR0_VIDOK BIT(3)  /* AC_VI DMA OK */
+#define IMR0_VODOK BIT(2)  /* AC_VO DMA OK */
+#define IMR0_RDU   BIT(1)  /* Rx Descriptor 
Unavailable */
+#define IMR0_ROK   BIT(0)  /* Receive DMA OK */
 #define REG_HISR0  0x00b4
 #define REG_HIMR1  0x00b8
+#define IMR1_BCNDMAINT7BIT(27) /* Beacon DMA Interrupt 
7 */
+#define IMR1_BCNDMAINT6BIT(26) /* Beacon DMA Interrupt 
6 */
+#define IMR1_BCNDMAINT5BIT(25) /* Beacon DMA Interrupt 
5 */
+#define IMR1_BCNDMAINT4BIT(24) /* Beacon DMA Interrupt 
4 */
+#define IMR1_BCNDMAINT3BIT(23) /* Beacon DMA Interrupt 
3 */
+#define IMR1_BCNDMAINT2BIT(22) /* Beacon DMA Interrupt 
2 */
+#define IMR1_BCNDMAINT1BIT(21) /* Beacon DMA Interrupt 
1 */
+#define IMR1_BCNDERR7  BIT(20) /* Beacon Queue DMA Err 
Int 7 */
+#define IMR1_BCNDERR6  BIT(19) /* Beacon Queue DMA Err 
Int 6 */
+#define IMR1_BCNDERR5  BIT(18) /* Beacon Queue DMA Err 
Int 5 */
+#define IMR1_BCNDERR4  BIT(17) /* Beacon Queue DMA Err 
Int 4 */
+#define IMR1_BCNDERR3  BIT(16) /* Beacon Queue DMA Err 
Int 3 */
+#define IMR1_BCNDERR2  BIT(15) /* Beacon Queue DMA Err 
Int 2 */
+#define IMR1_BCNDERR1  BIT(14) /* Beacon Queue DMA Err 
Int 1 */
+#define IMR1_ATIMEND_E BIT(13) /* ATIM Window End 
Extension
+  for Win7 */
+#define IMR1_TXE

[PATCH 00/20] rtl8xxxu patches for wireless-drivers-next

2016-08-19 Thread Jes . Sorensen
From: Jes Sorensen 

Hi

This is a set of patches for the rtl8xxxu driver relative to
wireless-drivers-next as of 2016-08-19.

It includes a couple of cases where the 8192cu driver is marked as
tested. Note while these do move the USB location around, they still
stay within the CONFIG_RTL8XXXU_UNTESTED zone. There has been some
suggestion that we should deprecate 8192cu support from rtlwifi in
favor of rtl8xxxu, however I think that is really for the rtlwifi
maintainer to make that call.

In addition this set includes a couple of minor fixes I received from
Wei Yongjun and Hans de Goede, and a number of changes that helps
prepare the code for the rtl8188eu support I am currently working on.

Cheers,
Jes


Hans de Goede (1):
  net: wireless: rtl8xxxu: Make rtl8xxxu_ampdu_action less chatty

Jes Sorensen (18):
  rtl8xxxu: Mark 0x20f4:0x648b as tested
  rtl8xxxu: Mark 0x2001:0x3308 as tested
  rtl8xxxu: Fix error handling if rtl8xxxu_init_device() fails
  rtl8xxxu: Add TP-Link TL-WN823N v2 to list of supported devices
  rtl8xxxu: Add TX page defines for 8723b
  rtl8xxxu: Switch 8723a to use new rtl8xxxu_init_queue_reserved_page()
routine
  rtl8xxxu: Switch 8192cu/8188cu devices to use
rtl8xxxu_init_queue_reserved_page()
  rtl8xxxu: Remove now obsolete rtl8xxxu_old_init_queue_reserved_page()
  rtl8xxxu: Simplify code setting TX buffer boundary
  rtl8xxxu: Add bit definitions for REG_FPGA0_TX_INFO
  rtl8xxxu: Add interrupt bit definitions for gen2 parts
  rtl8xxxu: Use flag to indicate whether device has TX report timer
support
  rtl8xxxu: Convert flags in rtl8xxxu_fileops to bitflags
  rtl8xxxu: Introduce fops bitflag indicating type of thermal meter
  rtl8xxxu: Simplify calculating of hw value used for setting TX rate
  rtl8xxxu: Determine the need for SGI before handling specific TX desc
formats
  rtl8xxxu: Determine need for shore preamble before updating TX
descriptors
  rtl8xxxu: Split filling of TX descriptors into separate functions

Wei Yongjun (1):
  rtl8xxxu: gen1: Fix non static symbol warning

 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h   |  22 +-
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c |   5 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c |   2 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c |   5 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c |   7 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 319 +++--
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h  |  60 
 7 files changed, 271 insertions(+), 149 deletions(-)

-- 
2.7.4