Commit graph

111 commits

Author SHA1 Message Date
Arnd Bergmann fe041deba4 ath9k: use timespec64 for tsf_ts
ath9k is the last remaining user of the deprecated getrawmonotonic()
interface. There is nothing wrong with this usage, but migrating
to a timespec64 based interface lets us clean up the old API.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-06-29 14:44:49 +03:00
Johannes Berg 7b6ddeaf27 mac80211: use QoS NDP for AP probing
When connected to a QoS/WMM AP, mac80211 should use a QoS NDP
for probing it, instead of a regular non-QoS one, fix this.

Change all the drivers to *not* allow QoS NDP for now, even
though it looks like most of them should be OK with that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2017-11-27 11:23:20 +01:00
Kees Cook 7ac767645a ath: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-10-27 16:54:19 +03:00
Ville Syrjälä ba24d63dd3 ath9k: Avoid a potential deadlock
Lockdep warns us that sc_pm_lock and cc_lock can cause a deadlock when
cc_lock is acquired by itself with interrupts enabled. Disable irqs
whenever taking cc_lock to avoid this.

[   19.094524] kworker/u2:0/5 just changed the state of lock:
[   19.094578]  (&(&sc->sc_pm_lock)->rlock){-.-...}, at: [<f836c00e>] ath_isr+0x15e/0x200 [ath9k]
[   19.094674] but this lock took another, HARDIRQ-unsafe lock in the past:
[   19.094731]  (&(&common->cc_lock)->rlock){+.-...}
[   19.094741]

               and interrupts could create inverse lock ordering between them.

[   19.094866]
               other info that might help us debug this:
[   19.094926]  Possible interrupt unsafe locking scenario:

[   19.094985]        CPU0                    CPU1
[   19.095036]        ----                    ----
[   19.095086]   lock(&(&common->cc_lock)->rlock);
[   19.095197]                                local_irq_disable();
[   19.095305]                                lock(&(&sc->sc_pm_lock)->rlock);
[   19.095423]                                lock(&(&common->cc_lock)->rlock);
[   19.095539]   <Interrupt>
[   19.095636]     lock(&(&sc->sc_pm_lock)->rlock);
[   19.095745]
                *** DEADLOCK ***

[   19.095965] 3 locks held by kworker/u2:0/5:
[   19.096067]  #0:  ("%s"wiphy_name(local->hw.wiphy)){.+.+.+}, at: [<c1067f37>] process_one_work+0x127/0x580
[   19.096260]  #1:  ((&local->dynamic_ps_enable_work)){+.+...}, at: [<c1067f37>] process_one_work+0x127/0x580
[   19.096447]  #2:  (&sc->mutex){+.+...}, at: [<f836b8b0>] ath9k_config+0x30/0x1d0 [ath9k]
[   19.096639]
               the shortest dependencies between 2nd lock and 1st lock:
[   19.096813]  -> (&(&common->cc_lock)->rlock){+.-...} ops: 38 {
[   19.096816]     HARDIRQ-ON-W at:
[   19.096816]                       __lock_acquire+0x57e/0x1260
[   19.096816]                       lock_acquire+0xb1/0x1c0
[   19.096816]                       _raw_spin_lock_bh+0x3f/0x50
[   19.096816]                       ath_chanctx_set_channel+0xb6/0x2c0 [ath9k]
[   19.096816]                       ath9k_config+0xa8/0x1d0 [ath9k]
[   19.096816]                       ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]                       ieee80211_do_open+0x67a/0x920 [mac80211]
[   19.096816]                       ieee80211_open+0x41/0x50 [mac80211]
[   19.096816]                       __dev_open+0xab/0x140
[   19.096816]                       __dev_change_flags+0x89/0x150
[   19.096816]                       dev_change_flags+0x28/0x60
[   19.096816]                       do_setlink+0x290/0x890
[   19.096816]                       rtnl_newlink+0x7cf/0x8e0
[   19.096816]                       rtnetlink_rcv_msg+0xbf/0x1f0
[   19.096816]                       netlink_rcv_skb+0xb9/0xe0
[   19.096816]                       rtnetlink_rcv+0x1e/0x30
[   19.096816]                       netlink_unicast+0x13a/0x2c0
[   19.096816]                       netlink_sendmsg+0x290/0x380
[   19.096816]                       ___sys_sendmsg+0x1e2/0x280
[   19.096816]                       __sys_sendmsg+0x3f/0x80
[   19.096816]                       SyS_socketcall+0x58c/0x6b0
[   19.096816]                       do_fast_syscall_32+0x96/0x1d0
[   19.096816]                       entry_SYSENTER_32+0x4c/0x7b
[   19.096816]     IN-SOFTIRQ-W at:
[   19.096816]                       __lock_acquire+0x55a/0x1260
[   19.096816]                       lock_acquire+0xb1/0x1c0
[   19.096816]                       _raw_spin_lock+0x3c/0x50
[   19.096816]                       ath_ps_full_sleep+0x24/0x70 [ath9k]
[   19.096816]                       call_timer_fn+0xa4/0x300
[   19.096816]                       run_timer_softirq+0x1b1/0x560
[   19.096816]                       __do_softirq+0xb0/0x430
[   19.096816]                       do_softirq_own_stack+0x33/0x40
[   19.096816]                       irq_exit+0xad/0xc0
[   19.096816]                       smp_apic_timer_interrupt+0x31/0x40
[   19.096816]                       apic_timer_interrupt+0x37/0x3c
[   19.096816]                       wp_page_copy+0xb8/0x580
[   19.096816]                       do_wp_page+0x64/0x420
[   19.096816]                       handle_mm_fault+0x430/0x990
[   19.096816]                       __do_page_fault+0x18b/0x430
[   19.096816]                       do_page_fault+0xb/0x10
[   19.096816]                       common_exception+0x62/0x6a
[   19.096816]     INITIAL USE at:
[   19.096816]                      __lock_acquire+0x204/0x1260
[   19.096816]                      lock_acquire+0xb1/0x1c0
[   19.096816]                      _raw_spin_lock_bh+0x3f/0x50
[   19.096816]                      ath_chanctx_set_channel+0xb6/0x2c0 [ath9k]
[   19.096816]                      ath9k_config+0xa8/0x1d0 [ath9k]
[   19.096816]                      ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]                      ieee80211_do_open+0x67a/0x920 [mac80211]
[   19.096816]                      ieee80211_open+0x41/0x50 [mac80211]
[   19.096816]                      __dev_open+0xab/0x140
[   19.096816]                      __dev_change_flags+0x89/0x150
[   19.096816]                      dev_change_flags+0x28/0x60
[   19.096816]                      do_setlink+0x290/0x890
[   19.096816]                      rtnl_newlink+0x7cf/0x8e0
[   19.096816]                      rtnetlink_rcv_msg+0xbf/0x1f0
[   19.096816]                      netlink_rcv_skb+0xb9/0xe0
[   19.096816]                      rtnetlink_rcv+0x1e/0x30
[   19.096816]                      netlink_unicast+0x13a/0x2c0
[   19.096816]                      netlink_sendmsg+0x290/0x380
[   19.096816]                      ___sys_sendmsg+0x1e2/0x280
[   19.096816]                      __sys_sendmsg+0x3f/0x80
[   19.096816]                      SyS_socketcall+0x58c/0x6b0
[   19.096816]                      do_fast_syscall_32+0x96/0x1d0
[   19.096816]                      entry_SYSENTER_32+0x4c/0x7b
[   19.096816]   }
[   19.096816]   ... key      at: [<f837b694>] __key.61991+0x0/0xffffc96c [ath9k]
[   19.096816]   ... acquired at:
[   19.096816]    lock_acquire+0xb1/0x1c0
[   19.096816]    _raw_spin_lock+0x3c/0x50
[   19.096816]    ath9k_ps_wakeup+0x85/0xe0 [ath9k]
[   19.096816]    ath9k_bss_info_changed+0x2a/0x1b0 [ath9k]
[   19.096816]    ieee80211_bss_info_change_notify+0xf3/0x360 [mac80211]
[   19.096816]    ieee80211_recalc_txpower+0x33/0x40 [mac80211]
[   19.096816]    ieee80211_set_tx_power+0x45/0x1d0 [mac80211]
[   19.096816]    cfg80211_wext_siwtxpower+0xd3/0x350 [cfg80211]
[   19.096816]    ioctl_standard_call+0x4e/0x400
[   19.096816]    wext_handle_ioctl+0xf4/0x190
[   19.096816]    dev_ioctl+0xb7/0x630
[   19.096816]    sock_ioctl+0x13e/0x2d0
[   19.096816]    do_vfs_ioctl+0x84/0x750
[   19.096816]    SyS_ioctl+0x34/0x60
[   19.096816]    do_fast_syscall_32+0x96/0x1d0
[   19.096816]    entry_SYSENTER_32+0x4c/0x7b

[   19.096816] -> (&(&sc->sc_pm_lock)->rlock){-.-...} ops: 597 {
[   19.096816]    IN-HARDIRQ-W at:
[   19.096816]                     __lock_acquire+0x6ae/0x1260
[   19.096816]                     lock_acquire+0xb1/0x1c0
[   19.096816]                     _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]                     ath_isr+0x15e/0x200 [ath9k]
[   19.096816]                     __handle_irq_event_percpu+0x44/0x340
[   19.096816]                     handle_irq_event_percpu+0x1d/0x50
[   19.096816]                     handle_irq_event+0x32/0x60
[   19.096816]                     handle_level_irq+0x81/0x100
[   19.096816]                     handle_irq+0x9c/0xd0
[   19.096816]                     do_IRQ+0x5c/0x120
[   19.096816]                     common_interrupt+0x36/0x3c
[   19.096816]                     _raw_spin_unlock_irqrestore+0x57/0x70
[   19.096816]                     ath9k_config+0x16a/0x1d0 [ath9k]
[   19.096816]                     ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]                     ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[   19.096816]                     process_one_work+0x1d1/0x580
[   19.096816]                     worker_thread+0x31/0x380
[   19.096816]                     kthread+0xd9/0x110
[   19.096816]                     ret_from_fork+0x19/0x24
[   19.096816]    IN-SOFTIRQ-W at:
[   19.096816]                     __lock_acquire+0x55a/0x1260
[   19.096816]                     lock_acquire+0xb1/0x1c0
[   19.096816]                     _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]                     ath9k_ps_wakeup+0x24/0xe0 [ath9k]
[   19.096816]                     ath9k_tasklet+0x42/0x260 [ath9k]
[   19.096816]                     tasklet_action+0x196/0x1e0
[   19.096816]                     __do_softirq+0xb0/0x430
[   19.096816]                     do_softirq_own_stack+0x33/0x40
[   19.096816]                     irq_exit+0xad/0xc0
[   19.096816]                     do_IRQ+0x65/0x120
[   19.096816]                     common_interrupt+0x36/0x3c
[   19.096816]                     get_page_from_freelist+0x20a/0x970
[   19.096816]                     __alloc_pages_nodemask+0xca/0xed0
[   19.096816]                     __get_free_pages+0x14/0x30
[   19.096816]                     pgd_alloc+0x1d/0x160
[   19.096816]                     mm_init.isra.47+0x13a/0x1b0
[   19.096816]                     copy_process.part.54+0xb55/0x1700
[   19.096816]                     _do_fork+0xd4/0x6a0
[   19.096816]                     SyS_clone+0x27/0x30
[   19.096816]                     do_fast_syscall_32+0x96/0x1d0
[   19.096816]                     entry_SYSENTER_32+0x4c/0x7b
[   19.096816]    INITIAL USE at:
[   19.096816]                    __lock_acquire+0x204/0x1260
[   19.096816]                    lock_acquire+0xb1/0x1c0
[   19.096816]                    _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]                    ath9k_ps_wakeup+0x24/0xe0 [ath9k]
[   19.096816]                    ath9k_start+0x29/0x1f0 [ath9k]
[   19.096816]                    drv_start+0x71/0x270 [mac80211]
[   19.096816]                    ieee80211_do_open+0x31f/0x920 [mac80211]
[   19.096816]                    ieee80211_open+0x41/0x50 [mac80211]
[   19.096816]                    __dev_open+0xab/0x140
[   19.096816]                    __dev_change_flags+0x89/0x150
[   19.096816]                    dev_change_flags+0x28/0x60
[   19.096816]                    do_setlink+0x290/0x890
[   19.096816]                    rtnl_newlink+0x7cf/0x8e0
[   19.096816]                    rtnetlink_rcv_msg+0xbf/0x1f0
[   19.096816]                    netlink_rcv_skb+0xb9/0xe0
[   19.096816]                    rtnetlink_rcv+0x1e/0x30
[   19.096816]                    netlink_unicast+0x13a/0x2c0
[   19.096816]                    netlink_sendmsg+0x290/0x380
[   19.096816]                    ___sys_sendmsg+0x1e2/0x280
[   19.096816]                    __sys_sendmsg+0x3f/0x80
[   19.096816]                    SyS_socketcall+0x58c/0x6b0
[   19.096816]                    do_fast_syscall_32+0x96/0x1d0
[   19.096816]                    entry_SYSENTER_32+0x4c/0x7b
[   19.096816]  }
[   19.096816]  ... key      at: [<f837b67c>] __key.61994+0x0/0xffffc984 [ath9k]
[   19.096816]  ... acquired at:
[   19.096816]    check_usage_forwards+0x118/0x120
[   19.096816]    mark_lock+0x2e4/0x590
[   19.096816]    __lock_acquire+0x6ae/0x1260
[   19.096816]    lock_acquire+0xb1/0x1c0
[   19.096816]    _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]    ath_isr+0x15e/0x200 [ath9k]
[   19.096816]    __handle_irq_event_percpu+0x44/0x340
[   19.096816]    handle_irq_event_percpu+0x1d/0x50
[   19.096816]    handle_irq_event+0x32/0x60
[   19.096816]    handle_level_irq+0x81/0x100
[   19.096816]    handle_irq+0x9c/0xd0
[   19.096816]    do_IRQ+0x5c/0x120
[   19.096816]    common_interrupt+0x36/0x3c
[   19.096816]    _raw_spin_unlock_irqrestore+0x57/0x70
[   19.096816]    ath9k_config+0x16a/0x1d0 [ath9k]
[   19.096816]    ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]    ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[   19.096816]    process_one_work+0x1d1/0x580
[   19.096816]    worker_thread+0x31/0x380
[   19.096816]    kthread+0xd9/0x110
[   19.096816]    ret_from_fork+0x19/0x24

[   19.096816]
               stack backtrace:
[   19.096816] CPU: 0 PID: 5 Comm: kworker/u2:0 Not tainted 4.13.0-mgm-ovl+ #51
[   19.096816] Hardware name: FUJITSU SIEMENS LIFEBOOK S6120/FJNB16C, BIOS Version 1.26  05/10/2004
[   19.096816] Workqueue: phy0 ieee80211_dynamic_ps_enable_work [mac80211]
[   19.096816] Call Trace:
[   19.096816]  <IRQ>
[   19.096816]  dump_stack+0x16/0x19
[   19.096816]  print_irq_inversion_bug.part.37+0x16c/0x179
[   19.096816]  check_usage_forwards+0x118/0x120
[   19.096816]  ? ret_from_fork+0x19/0x24
[   19.096816]  ? print_shortest_lock_dependencies+0x1a0/0x1a0
[   19.096816]  mark_lock+0x2e4/0x590
[   19.096816]  ? print_shortest_lock_dependencies+0x1a0/0x1a0
[   19.096816]  __lock_acquire+0x6ae/0x1260
[   19.096816]  lock_acquire+0xb1/0x1c0
[   19.096816]  ? ath_isr+0x15e/0x200 [ath9k]
[   19.096816]  _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]  ? ath_isr+0x15e/0x200 [ath9k]
[   19.096816]  ath_isr+0x15e/0x200 [ath9k]
[   19.096816]  __handle_irq_event_percpu+0x44/0x340
[   19.096816]  handle_irq_event_percpu+0x1d/0x50
[   19.096816]  handle_irq_event+0x32/0x60
[   19.096816]  ? handle_nested_irq+0x100/0x100
[   19.096816]  handle_level_irq+0x81/0x100
[   19.096816]  handle_irq+0x9c/0xd0
[   19.096816]  </IRQ>
[   19.096816]  do_IRQ+0x5c/0x120
[   19.096816]  common_interrupt+0x36/0x3c
[   19.096816] EIP: _raw_spin_unlock_irqrestore+0x57/0x70
[   19.096816] EFLAGS: 00000286 CPU: 0
[   19.096816] EAX: f60a3600 EBX: 00000286 ECX: 00000006 EDX: 00000001
[   19.096816] ESI: f46c9e68 EDI: f46c8620 EBP: f60b5e8c ESP: f60b5e84
[   19.096816]  DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
[   19.096816]  ath9k_config+0x16a/0x1d0 [ath9k]
[   19.096816]  ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]  ? ieee80211_hw_config+0x1db/0x5f0 [mac80211]
[   19.096816]  ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[   19.096816]  ? process_one_work+0x127/0x580
[   19.096816]  ? process_one_work+0x127/0x580
[   19.096816]  process_one_work+0x1d1/0x580
[   19.096816]  ? process_one_work+0x127/0x580
[   19.096816]  worker_thread+0x31/0x380
[   19.096816]  kthread+0xd9/0x110
[   19.096816]  ? process_one_work+0x580/0x580
[   19.096816]  ? kthread_create_on_node+0x30/0x30
[   19.096816]  ret_from_fork+0x19/0x24

Cc: QCA ath9k Development <ath9k-devel@qca.qualcomm.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-09-25 10:17:42 +03:00
Johannes Berg 59ae1d127a networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.

An spatch similar to the one for skb_put_zero() converts many
of the places using it:

    @@
    identifier p, p2;
    expression len, skb, data;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, len);
    |
    -memcpy(p, data, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb, data;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, sizeof(*p));
    |
    -memcpy(p, data, sizeof(*p));
    )

    @@
    expression skb, len, data;
    @@
    -memcpy(skb_put(skb, len), data, len);
    +skb_put_data(skb, data, len);

(again, manually post-processed to retain some comments)

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 11:48:37 -04:00
Johannes Berg b080db5853 networking: convert many more places to skb_put_zero()
There were many places that my previous spatch didn't find,
as pointed out by yuan linyu in various patches.

The following spatch found many more and also removes the
now unnecessary casts:

    @@
    identifier p, p2;
    expression len;
    expression skb;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_zero(skb, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_zero(skb, len);
    )
    ... when != p
    (
    p2 = (t2)p;
    -memset(p2, 0, len);
    |
    -memset(p, 0, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_zero(skb, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_zero(skb, sizeof(t));
    )
    ... when != p
    (
    p2 = (t2)p;
    -memset(p2, 0, sizeof(*p));
    |
    -memset(p, 0, sizeof(*p));
    )

    @@
    expression skb, len;
    @@
    -memset(skb_put(skb, len), 0, len);
    +skb_put_zero(skb, len);

Apply it to the tree (with one manual fixup to keep the
comment in vxlan.c, which spatch removed.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 11:48:35 -04:00
Toke Høiland-Jørgensen 63fefa0504 ath9k: Introduce airtime fairness scheduling between stations
This reworks the ath9k driver to schedule transmissions to connected
stations in a way that enforces airtime fairness between them. It
accomplishes this by measuring the time spent transmitting to or
receiving from a station at TX and RX completion, and accounting this to
a per-station, per-QoS level airtime deficit. Then, an FQ-CoDel based
deficit scheduler is employed at packet dequeue time, to control which
station gets the next transmission opportunity.

Airtime fairness can significantly improve the efficiency of the network
when station rates vary. The following throughput values are from a
simple three-station test scenario, where two stations operate at the
highest HT20 rate, and one station at the lowest, and the scheduler is
employed at the access point:

                  Before   /   After
Fast station 1:    19.17   /   25.09 Mbps
Fast station 2:    19.83   /   25.21 Mbps
Slow station:       2.58   /    1.77 Mbps
Total:             41.58   /   52.07 Mbps

The benefit of airtime fairness goes up the more stations are present.
In a 30-station test with one station artificially limited to 1 Mbps,
we have seen aggregate throughput go from 2.14 to 17.76 Mbps.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-12-15 10:43:05 +02:00
Toke Høiland-Jørgensen 50f08edf98 ath9k: Switch to using mac80211 intermediate software queues.
This switches ath9k over to using the mac80211 intermediate software
queueing mechanism for data packets. It removes the queueing inside the
driver, except for the retry queue, and instead pulls from mac80211 when
a packet is needed. The retry queue is used to store a packet that was
pulled but can't be sent immediately.

The old code path in ath_tx_start that would queue packets has been
removed completely, as has the qlen limit tunables (since there's no
longer a queue in the driver to limit).

The mac80211 intermediate software queues offer significant latency
reductions, and this patch allows ath9k to realise them. The exact gains
from this varies with the test scenario, but in an access point scenario
we have seen latency reductions ranging from 1/3 to as much as an order
of magnitude. We also achieve slightly better aggregation.

Median latency (ping) figures with this patch applied at the access point,
with two high-rate stations and one low-rate station (HT20 5Ghz), running
a Flent rtt_fair_var_up test with one TCP flow and one ping flow going to
each station:

                                 Fast station        Slow station
Default pfifo_fast qdisc:            430.4 ms            638.7 ms
fq_codel qdisc on iface:              35.5 ms            211.8 ms
This patch set:                       22.4 ms             38.2 ms

Median aggregation sizes over the same test:

Default pfifo_fast qdisc:            9.5 pkts            1.9 pkts
fq_codel qdisc on iface:            11.2 pkts            1.9 pkts
This patch set:                     13.9 pkts            1.9 pkts

This patch is based on Tim's original patch set, but reworked quite
thoroughly.

Cc: Tim Shepard <shep@alum.mit.edu>
Cc: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-11-15 17:00:04 +02:00
Avraham Stern 7947d3e075 mac80211: Add support for beacon report radio measurement
Add the following to support beacon report radio measurement
with the measurement mode field set to passive or active:
1. Propagate the required scan duration to the device
2. Report the scan start time (in terms of TSF)
3. Report each BSS's detection time (also in terms of TSF)

TSF times refer to the BSS that the interface that requested the
scan is connected to.

Signed-off-by: Assaf Krauss <assaf.krauss@intel.com>
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
[changed ath9k/10k, at76c59x-usb, iwlegacy, wl1251 and wlcore to match
the new API]
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2016-07-06 14:53:19 +02:00
Johannes Berg 57fbcce37b cfg80211: remove enum ieee80211_band
This enum is already perfectly aliased to enum nl80211_band, and
the only reason for it is that we get IEEE80211_NUM_BANDS out of
it. There's no really good reason to not declare the number of
bands in nl80211 though, so do that and remove the cfg80211 one.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2016-04-12 15:56:15 +02:00
Geert Uytterhoeven 344cd850b5 ath9k: Drop useless const on chanctx_event_delta() return type
drivers/net/wireless/ath/ath9k/channel.c:230: warning: type qualifiers ignored on function return type

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-01-26 16:47:38 +02:00
Kalle Valo b9a9693fd9 ath9k: request NOA update when chanctx active
Request NOA update when chanctx active, also in case
of STA.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-01-26 16:47:38 +02:00
Janusz Dziedzic 02edab5b5f ath9k: MCC, print time elapsed between events
This is useful for MCC debugging and bug fixing.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:51:02 +02:00
Janusz Dziedzic b10b7fb31a ath9k: P2P_CLIENT, get/set NOA correctly
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 <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:55 +02:00
Janusz Dziedzic 3edbf0ba04 ath9k: MCC enable Opportunistic Power Save
When adding NOA attr enable Opportunistic Power Save.
Before we calculate ctwindow but didn't enable oppps.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:52 +02:00
Janusz Dziedzic c1b7bea038 ath9k: setup correct skb priority for nullfunc
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 <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:48 +02:00
Janusz Dziedzic 631c45f419 ath9k: use u32 when calculate tsf
Use u32 while ath9k_hw_gettsf32() and
ath9k_hw_gen_timer_start() require u32.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:45 +02:00
Janusz Dziedzic b77b59ae8a ath9k: P2P_CLIENT, send frames after 1ms AP/GO will aprear
AP/GO will aprear after NOA, wait 1ms to be sure AP
could receive/answer this frames.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:41 +02:00
Janusz Dziedzic 2f985539b9 ath9k: print real timer value
In case of low HZ before this patch we saw wrong
values in debug message. Print real timeout value.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:35 +02:00
Janusz Dziedzic 58bb9ca84c ath9k: add debug messages to aggr/chanctx funcs
Add/extend debug messages when chanctx used.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-08 16:50:31 +02:00
Janusz.Dziedzic@tieto.com d83520b7cd ath9k: handle RoC cancel correctly
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 <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-08-06 10:11:06 +03:00
Johannes Berg a344d6778a mac80211: allow drivers to support NL80211_SCAN_FLAG_RANDOM_ADDR
Allow drivers to support NL80211_SCAN_FLAG_RANDOM_ADDR with software
based scanning and generate a random MAC address for them for every
scan request with the flag.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2014-11-19 18:46:09 +01:00
Sujith Manoharan 47b6308b64 ath9k: Move roc completion to the offchannel timer
Currently, when a roc period expires, the offchannel
timer calls ieee80211_remain_on_channel_expired(), but
the roc state is cleared only when the queued work
to switch to the operating channel gets a chance to run.

This race is a problem because mac80211 can issue a
new roc request in this window. To avoid this, handle
roc completion in the offchannel timer itself.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-17 15:32:17 -05:00
Sujith Manoharan d9092c9873 ath9k: Adjust tbtt delta properly
In a GO/STA setup, when we switch to the STA context,
the channel context timer is scheduled with a period of
half the beacon interval. If a beacon is received in
this duration, the timer is adjusted to accommodate
TSF sync done by the HW.

But, if the actual channel switch is delayed for some
reason, we end up rearming the timer every time a new
beacon is received. Avoid this by doing the adjustment
only once.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-17 15:32:17 -05:00
Sujith Manoharan e21a1d8b2b ath9k: Clear offchannel state properly
When a pending roc or scan operation is cancelled,
the offchannel operation is cleared, but the offchannel
state in the main scheduler is not cleared. This causes
problems since an active GO will try to process a stale
offchannel request that was deferred earlier. Fix this
by clearing the state when there is no pending offchannel
(roc/scan) operation.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-17 15:32:16 -05:00
Oleksij Rempel 67dc74f15f ath9k: move spectral.* to common-spectral.*
and rename exports from ath9k_spectral_* to ath9k_cmn_spectral_*

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-11 16:31:14 -05:00
Oleksij Rempel 963916dfe2 ath9k: make ath9k_spectral_scan_ do not depend on ath_softc
last preparation before moving ath9k_spectral_scan_ to spectral.c

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-11 16:31:14 -05:00
Oleksij Rempel ef948da55f ath9k: use ath_common instead of ieee80211_hw in ath9k_spectral_scan_
we don't have here any ieee80211_hw dependencies any way.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-11 16:31:14 -05:00
Oleksij Rempel 8391f60194 ath9k: move spectral_mode to ath_spec_scan_priv
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-11-11 16:31:13 -05:00
Sujith Manoharan 25f3bc7dbd ath9k: Improve flush() in mcc mode
The flush timeout in MCC mode is very small, since
we are constrained by the time slice for each
channel context, but since only the HW queues are
flushed when switching contexts, it is acceptable.

Since the SW queues are also emptied in the mac80211 flush()
callback, a larger duration is needed. Add an override
argument to __ath9k_flush() and set it when flush()
is called in MCC mode. This allows the driver to
drain both the SW and HW queues.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:17 -04:00
Sujith Manoharan 23aab0c25f ath9k: Fix HW scan abort
Instead of using ATH_CHANCTX_EVENT_ASSIGN to abort
a HW scan when a new interface becomes active, use the
mgd_prepare_tx() callback. This allows us to make
sure that the GO's channel becomes operational by
using flush_work().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:17 -04:00
Sujith Manoharan 0a019a58e3 ath9k: Send oneshot NoA
This patch makes sure that a GO interface
sends out a new NoA schedule with 200ms duration
when mgd_prepare_tx() is called.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:17 -04:00
Sujith Manoharan a350335c5f ath9k: Fix RoC expiration
mac80211 has to be notified when a RoC period
expires in the driver. In MCC mode, since the
offchannel/RoC timer is set with the requested
duration, ieee80211_remain_on_channel_expired() needs
to be called when the timer expires.

But, currently it is done after we move back to
the operating channel. This is incorrect - fix this
by calling ieee80211_remain_on_channel_expired() when
the RoC timer expires and in ath_roc_complete() when
the RoC request is aborted.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:16 -04:00
Sujith Manoharan 828fe01acb ath9k: Use a helper function for bmiss
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:16 -04:00
Sujith Manoharan 347a9566ab ath9k: Use a helper function to set NoA
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:16 -04:00
Sujith Manoharan a23152a82f ath9k: Use a helper function for offchannel NoA
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:16 -04:00
Sujith Manoharan c6500ea29a ath9k: Check for active GO in mgd_prepare_tx()
If a GO interface is active when we receive a
mgd_prepare_tx() call, then we need to send
out a new NoA before switching to a new context.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:16 -04:00
Sujith Manoharan 26103b8d1d ath9k: Add a function to check for an active GO
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:16 -04:00
Sujith Manoharan e2d389b5aa ath9k: Check for pending frames properly
Pending frames in the driver can be present
either in the HW queues or SW. ath9k_has_pending_frames()
currently checks for the HW queues first and then
checks if any ACs are queued in the driver.

In MCC mode, we need to check the HW queues alone, since
the SW queues are just marked as 'stopped' - they will
be processed in the next context switch. But since we
don't differentiate this now, mention whether we want
to check if there are frames in the SW queues.

* The flush() callback checks both HW and SW queues.
* The tx_frames_pending() callback does the same.
* The call to __ath9k_flush() in MCC mode checks HW queues alone.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:15 -04:00
Sujith Manoharan 290c8a77e8 ath9k: Fix offchannel flush timeout
An offchannel operation also needs to have
a flush timeout that doesn't exceed the NoA
absence duration of a GO context, so use
channel_switch_time. The first offchannel
operation is set a flush timeout of 10ms since
channel_switch_time will be zero.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:15 -04:00
Sujith Manoharan 67259d51df ath9k: Fix MCC flush timeout
In MCC mode, the duration for a channel context
is half the beacon interval and having a large
flush timeout will adversely affect GO operation,
since the default value of 200ms will overshoot
the advertised NoA absence duration.

The scheduler initiates a channel context switch
only when the slot duration for the current
context expires, so there is no possibility of
having a fixed timeout for flush.

Since the channel_switch_time is added to the
absence duration when the GO sets up the NoA
attribute, this is the maximum time that we
have to flush the TX queues. The duration is very
small, but we don't have a choice in MCC mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:15 -04:00
Sujith Manoharan 2fae0d9fb0 ath9k: Use configurable timeout for flush
The timeout value for flushing the TX queues
is hardcoded at 200ms right now. Use a channel
context-specific value instead to allow adjustments
to the timeout in case MCC is enabled.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:15 -04:00
Sujith Manoharan 8890d05ff5 ath9k: Clear NoA schedule properly
When an active context transitions to inactive
state, the NoA schedule needs to be removed
for the context that has beaconing enabled.
Not doing this will affect p2p clients.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:15 -04:00
Sujith Manoharan 5555c95524 ath9k: Unify reset API
Instead of having ath_reset_internal() and ath_reset()
as two separate calls to perform a HW reset, have
one function. This makes sure that the behavior will
be the same at all callsites.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:14 -04:00
Sujith Manoharan be247c1fae ath9k: Process beacons properly
When the current operating channel context has
been marked as ATH_CHANCTX_STATE_FORCE_ACTIVE,
do not process beacons that might be received,
since we have to wait for the station to become
authorized.

Also, since the cached TSF value will be zero
initially do not rearm the timer in this
case when a beacon is received, since it results
in spurious values.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:14 -04:00
Sujith Manoharan b8f9279be0 ath9k: Enable multi-channel properly
In MCC mode, currently the decision to enable
the multi-channel state machine is done
based on the association status if one of
the interfaces assigned to a context is in
station mode.

This allows the driver to switch to the other
context before the current station is able to
complete the 4-way handshake in case it is
required and this causes problems.

Instead, enable multi-channel mode when the
station moves to the authorized state. This
disallows an early switch to the other channel.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-27 14:16:14 -04:00
Sujith Manoharan e2cba8d759 ath9k: Fix flushing in MCC mode
When we are attempting to switch to a new
channel context, the TX queues are flushed, but
the mac80211 queues are not stopped and traffic
can still come down to the driver.

This patch fixes it by stopping the queues
assigned to the current context/vif before
trying to flush.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-02 14:26:32 -04:00
Sujith Manoharan a064eaa10c ath9k: Add ath9k_chanctx_stop_queues()
This can be used when the queues of a context
needs to be stopped.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-02 14:26:32 -04:00
Sujith Manoharan b39031536a ath9k: Pass context to ath9k_chanctx_wake_queues()
Change the ath9k_chanctx_wake_queues() API so
that we can pass the channel context that needs its
queues to be stopped.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-02 14:26:32 -04:00
Sujith Manoharan 4b60af4ab4 ath9k: Print RoC expiration
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2014-10-02 14:26:31 -04:00