30 May, 2018

2 commits

  • [ Upstream commit 95f3ce6a77893ac828ba841df44421620de4314b ]

    sta_info_alloc can be called from atomic paths (such as RX path)
    so we need to call pcpu_alloc with the correct gfp.

    Fixes: c9c5962b56c1 ("mac80211: enable collecting station statistics per-CPU")
    Signed-off-by: Sara Sharon
    Signed-off-by: Luca Coelho
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sara Sharon
     
  • [ Upstream commit d78d9ee9d40aca4781d2c5334972544601a4c3a2 ]

    If sta_info_alloc fails after allocating the per CPU statistics,
    they are not properly freed.

    Fixes: c9c5962b56c1 ("mac80211: enable collecting station statistics per-CPU")
    Signed-off-by: Sara Sharon
    Signed-off-by: Luca Coelho
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sara Sharon
     

16 Jun, 2017

1 commit

  • It seems like a historic accident that these return unsigned char *,
    and in many places that means casts are required, more often than not.

    Make these functions (skb_put, __skb_put and pskb_put) return void *
    and remove all the casts across the tree, adding a (u8 *) cast only
    where the unsigned char pointer was used directly, all done with the
    following spatch:

    @@
    expression SKB, LEN;
    typedef u8;
    identifier fn = { skb_put, __skb_put };
    @@
    - *(fn(SKB, LEN))
    + *(u8 *)fn(SKB, LEN)

    @@
    expression E, SKB, LEN;
    identifier fn = { skb_put, __skb_put };
    type T;
    @@
    - E = ((T *)(fn(SKB, LEN)))
    + E = fn(SKB, LEN)

    which actually doesn't cover pskb_put since there are only three
    users overall.

    A handful of stragglers were converted manually, notably a macro in
    drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
    instances in net/bluetooth/hci_sock.c. In the former file, I also
    had to fix one whitespace problem spatch introduced.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

08 Jun, 2017

1 commit


02 Jun, 2017

1 commit

  • In the commit enabling per-CPU station statistics, I inadvertedly
    copy-pasted some code to update rx_packets and forgot to change it
    to update rx_dropped_misc. Fix that.

    This addresses https://bugzilla.kernel.org/show_bug.cgi?id=195953.

    Fixes: c9c5962b56c1 ("mac80211: enable collecting station statistics per-CPU")
    Reported-by: Petru-Florin Mihancea
    Signed-off-by: Johannes Berg

    Johannes Berg
     

17 May, 2017

1 commit

  • CoDel can be too aggressive if a station sends at a very low rate,
    leading reduced throughput. This gets worse the more stations are
    present, as each station gets more bursty the longer the round-robin
    scheduling between stations takes.

    This adds dynamic adjustment of CoDel parameters per station. It uses
    the rate selection information to estimate throughput and sets more
    lenient CoDel parameters if the estimated throughput is below a
    threshold (modified by the number of active stations).

    A new callback is added that drivers can use to notify mac80211 about
    changes in expected throughput, so the same adjustment can be made for
    cards that implement rate control in firmware. Drivers that don't use
    this will just get the default parameters.

    Signed-off-by: Toke Høiland-Jørgensen
    [remove currently unnecessary EXPORT_SYMBOL, fix kernel-doc, remove
    inline annotation]
    Signed-off-by: Johannes Berg

    Toke Høiland-Jørgensen
     

28 Apr, 2017

2 commits

  • Existing API 'ieee80211_get_sdata_band' returns default 2 GHz band even
    if the channel context configuration is NULL. This crashes for chipsets
    which support 5 Ghz alone when it tries to access members of 'sband'.
    Channel context configuration can be NULL in multivif case and when
    channel switch is in progress (or) when it fails. Fix this by replacing
    the API 'ieee80211_get_sdata_band' with 'ieee80211_get_sband' which
    returns a NULL pointer for sband when the channel configuration is NULL.

    An example scenario is as below:

    In multivif mode (AP + STA) with drivers like ath10k, when we do a
    channel switch in the AP vif (which has a number of clients connected)
    and a STA vif which is connected to some other AP, when the channel
    switch in AP vif fails, while the STA vifs tries to connect to the
    other AP, there is a window where the channel context is NULL/invalid
    and this results in a crash while the clients connected to the AP vif
    tries to reconnect and this race is very similar to the one investigated
    by Michal in https://patchwork.kernel.org/patch/3788161/ and this does
    happens with hardware that supports 5Ghz alone after long hours of
    testing with continuous channel switch on the AP vif

    ieee80211 phy0: channel context reservation cannot be finalized because
    some interfaces aren't switching
    wlan0: failed to finalize CSA, disconnecting
    wlan0-1: deauthenticating from 8c:fd:f0:01:54:9c by local choice
    (Reason: 3=DEAUTH_LEAVING)

    WARNING: CPU: 1 PID: 19032 at net/mac80211/ieee80211_i.h:1013 sta_info_alloc+0x374/0x3fc [mac80211]
    [] (sta_info_alloc [mac80211])
    [] (ieee80211_add_station [mac80211]))
    [] (nl80211_new_station [cfg80211])

    Unable to handle kernel NULL pointer dereference at virtual
    address 00000014
    pgd = d5f4c000
    Internal error: Oops: 17 [#1] PREEMPT SMP ARM
    PC is at sta_info_alloc+0x380/0x3fc [mac80211]
    LR is at sta_info_alloc+0x37c/0x3fc [mac80211]
    [] (sta_info_alloc [mac80211])
    [] (ieee80211_add_station [mac80211])
    [] (nl80211_new_station [cfg80211]))

    Cc: Michal Kazior
    Signed-off-by: Mohammed Shafi Shajakhan
    Signed-off-by: Johannes Berg

    Mohammed Shafi Shajakhan
     
  • Instead of hand-coding the bit manipulations, use the bitfield
    macros to generate the code for the encoded bitrate.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

06 Mar, 2017

1 commit


27 Feb, 2017

2 commits

  • Tracing is limited to 100 characters and this message passes
    the limit when there are a few buffered frames. Shorten it.

    Signed-off-by: Sara Sharon
    Signed-off-by: Johannes Berg

    Sara Sharon
     
  • iwlwifi now supports RSS and can't let mac80211 track the
    PS state based on the Rx frames since they can come out of
    order. iwlwifi is now advertising AP_LINK_PS, and uses
    explicit notifications to teach mac80211 about the PS state
    of the stations and the PS poll / uAPSD trigger frames
    coming our way from the peers.

    Because of that, the TIM stopped being maintained in
    mac80211. I tried to fix this in commit c68df2e7be0c
    ("mac80211: allow using AP_LINK_PS with mac80211-generated TIM IE")
    but that was later reverted by Felix in commit 6c18a6b4e799
    ("Revert "mac80211: allow using AP_LINK_PS with mac80211-generated TIM IE")
    since it broke drivers that do not implement set_tim.

    Since none of the drivers that set AP_LINK_PS have the
    set_tim() handler set besides iwlwifi, I can bail out in
    __sta_info_recalc_tim if AP_LINK_PS AND .set_tim is not
    implemented.

    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Emmanuel Grumbach
     

18 Jan, 2017

1 commit


15 Jan, 2017

1 commit

  • …inux/kernel/git/jberg/mac80211-next

    Johannes Berg says:

    ====================
    For 4.11, we seem to have more than in the past few releases:
    * socket owner support for connections, so when the wifi
    manager (e.g. wpa_supplicant) is killed, connections are
    torn down - wpa_supplicant is critical to managing certain
    operations, and can opt in to this where applicable
    * minstrel & minstrel_ht updates to be more efficient (time and space)
    * set wifi_acked/wifi_acked_valid for skb->destructor use in the
    kernel, which was already available to userspace
    * don't indicate new mesh peers that might be used if there's no
    room to add them
    * multicast-to-unicast support in mac80211, for better medium usage
    (since unicast frames can use *much* higher rates, by ~3 orders of
    magnitude)
    * add API to read channel (frequency) limitations from DT
    * add infrastructure to allow randomizing public action frames for
    MAC address privacy (still requires driver support)
    * many cleanups and small improvements/fixes across the board
    ====================

    Signed-off-by: David S. Miller <davem@davemloft.net>

    David S. Miller
     

11 Jan, 2017

1 commit

  • In the commit below, I forgot to translate the mac80211's
    AC to QoS IE order. Moreover, the condition in the if was
    wrong. Fix both issues.
    This bug would hit only with clients that didn't set all
    the ACs as delivery enabled.

    Fixes: f438ceb81d4 ("mac80211: uapsd_queues is in QoS IE order")
    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Emmanuel Grumbach
     

15 Dec, 2016

2 commits


13 Dec, 2016

1 commit

  • Commit 3b17fbf87d5d introduced sta_get_expected_throughput()
    leaving variable 'struct rate_control_ref* ref' set but unused.
    Compiling with W=1 gives the following warning, fix it.

    net/mac80211/sta_info.c: In function ‘sta_set_sinfo’:
    net/mac80211/sta_info.c:2052:27: warning: variable ‘ref’ set but not used [-Wunused-but-set-variable]

    Fixes: 3b17fbf87d5d ("mac80211: mesh: Add support for HW RC implementation")
    Cc: Johannes Berg
    Cc: Maxim Altshul
    Signed-off-by: Kirtika Ruchandani
    Signed-off-by: Johannes Berg

    Kirtika Ruchandani
     

23 Nov, 2016

1 commit

  • All conflicts were simple overlapping changes except perhaps
    for the Thunder driver.

    That driver has a change_mtu method explicitly for sending
    a message to the hardware. If that fails it returns an
    error.

    Normally a driver doesn't need an ndo_change_mtu method becuase those
    are usually just range changes, which are now handled generically.
    But since this extra operation is needed in the Thunder driver, it has
    to stay.

    However, if the message send fails we have to restore the original
    MTU before the change because the entire call chain expects that if
    an error is thrown by ndo_change_mtu then the MTU did not change.
    Therefore code is added to nicvf_change_mtu to remember the original
    MTU, and to restore it upon nicvf_update_hw_max_frs() failue.

    Signed-off-by: David S. Miller

    David S. Miller
     

15 Nov, 2016

1 commit

  • This reverts commit c68df2e7be0c1238ea3c281fd744a204ef3b15a0.

    __sta_info_recalc_tim turns into a no-op if local->ops->set_tim is not
    set. This prevents the beacon TIM bit from being set for all drivers
    that do not implement this op (almost all of them), thus thoroughly
    essential AP mode powersave functionality.

    Cc: Emmanuel Grumbach
    Fixes: c68df2e7be0c ("mac80211: allow using AP_LINK_PS with mac80211-generated TIM IE")
    Signed-off-by: Felix Fietkau
    Signed-off-by: Johannes Berg

    Felix Fietkau
     

19 Oct, 2016

1 commit

  • The uapsd_queue field is in QoS IE order and not in
    IEEE80211_AC_*'s order.
    This means that mac80211 would get confused between
    BK and BE which is certainly not such a big deal but
    needs to be fixed.

    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Luca Coelho
    Signed-off-by: Johannes Berg

    Emmanuel Grumbach
     

12 Oct, 2016

1 commit

  • This patch adds filtering for multicast data packets on AP_VLAN
    interfaces that have no authorized station connected and changes
    filtering on AP interfaces to not count stations assigned to
    AP_VLAN interfaces.

    This saves airtime and avoids waking up other stations currently
    authorized in this BSS. When using WPA, the packets dropped could
    not be decrypted by any station.

    The behaviour when there are no AP_VLAN interfaces is left unchanged.

    When there are AP_VLAN interfaces, this patch
    1. adds filtering multicast data packets sent on AP_VLAN interfaces
    that have no authorized station connected.
    No filtering happens on 4addr AP_VLAN interfaces.
    2. makes filtering of multicast data packets sent on AP interfaces
    depend on the number of authorized stations in this bss not
    assigned to an AP_VLAN interface.

    Therefore, a new num_mcast_sta counter is added for AP_VLAN interfaces.
    The existing one for AP interfaces is altered to not track stations
    assigned to an AP_VLAN interface.

    The new counter is exposed in debugfs.

    Signed-off-by: Michael Braun
    [reformat commit message a bit, unline ieee80211_vif_{inc,dec}_num_mcast]
    Signed-off-by: Johannes Berg

    Michael Braun
     

04 Oct, 2016

1 commit

  • Resolve the merge conflict between Felix's/my and Toke's patches
    coming into the tree through net and mac80211-next respectively.
    Most of Felix's changes go away due to Toke's new infrastructure
    work, my patch changes to "goto begin" (the label wasn't there
    before) instead of returning NULL so flow control towards drivers
    is preserved better.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

30 Sep, 2016

1 commit

  • The TXQ intermediate queues can cause packet reordering when more than
    one flow is active to a single station. Since some of the wifi-specific
    packet handling (notably sequence number and encryption handling) is
    sensitive to re-ordering, things break if they are applied before the
    TXQ.

    This splits up the TX handlers and fast_xmit logic into two parts: An
    early part and a late part. The former is applied before TXQ enqueue,
    and the latter after dequeue. The non-TXQ path just applies both parts
    at once.

    Because fragments shouldn't be split up or reordered, the fragmentation
    handler is run after dequeue. Any fragments are then kept in the TXQ and
    on subsequent dequeues they take precedence over dequeueing from the FQ
    structure.

    This approach avoids having to scatter special cases all over the place
    for when TXQ is enabled, at the cost of making the fast_xmit and TX
    handler code slightly more complex.

    Signed-off-by: Toke Høiland-Jørgensen
    [fix a few code-style nits, make ieee80211_xmit_fast_finish void,
    remove a useless txq->sta check]
    Signed-off-by: Johannes Berg

    Toke Høiland-Jørgensen
     

23 Sep, 2016

1 commit


20 Sep, 2016

1 commit

  • mac80211 currently uses rhashtable with insecure_elasticity set
    to true. The latter is because of duplicate objects. What's
    more, mac80211 walks the rhashtable chains by hand which is broken
    as rhashtable may contain multiple tables due to resizing or
    rehashing.

    This patch fixes it by converting it to the newly added rhltable
    interface which is designed for use with duplicate objects.

    With rhltable a lookup returns a list of objects instead of a
    single one. This is then fed into the existing for_each_sta_info
    macro.

    This patch also deletes the sta_addr_hash function since rhashtable
    defaults to jhash.

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     

16 Sep, 2016

1 commit

  • In 46fa38e84b65 ("mac80211: allow software PS-Poll/U-APSD with
    AP_LINK_PS"), Johannes allowed to use mac80211's code for handling
    stations that go to PS or send PS-Poll / uAPSD trigger frames for
    devices that enable RSS.

    This means that mac80211 doesn't look at frames anymore but rather
    relies on a notification that will come from the device when a PS
    transition occurs or when a PS-Poll / trigger frame is detected by
    the device.

    iwlwifi will need this capability but still needs mac80211 to take
    care of the TIM IE. Today, if a driver sets AP_LINK_PS, mac80211
    will not update the TIM IE. Change mac80211 to check existence of
    the set_tim driver callback rather than using AP_LINK_PS to decide
    if the driver handles the TIM IE internally or not.

    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Luca Coelho
    [reword commit message a bit]
    Signed-off-by: Johannes Berg

    Emmanuel Grumbach
     

12 Sep, 2016

2 commits

  • Handle the case where the mac80211 intermediate queues are empty and the
    driver has buffered frames

    Fixes: ba8c3d6f16a1 ("mac80211: add an intermediate software queue implementation")
    Signed-off-by: Felix Fietkau
    Signed-off-by: Johannes Berg

    Felix Fietkau
     
  • The ability to change the max_rx_aggregation frames is useful
    in cases of IOP.

    There exist some devices (latest mobile phones and some AP's)
    that tend to not respect a BA sessions maximum size (in Kbps).
    These devices won't respect the AMPDU size that was negotiated during
    association (even though they do respect the maximal number of packets).

    This violation is characterized by a valid number of packets in
    a single AMPDU. Even so, the total size will exceed the size negotiated
    during association.

    Eventually, this will cause some undefined behavior, which in turn
    causes the hw to drop packets, causing the throughput to plummet.

    This patch will make the subframe limitation to be held by each station,
    instead of being held only by hw.

    Signed-off-by: Maxim Altshul
    Signed-off-by: Johannes Berg

    Maxim Altshul
     

12 Aug, 2016

1 commit

  • Depending on which method the driver implements, userspace could
    call this (indirectly, by getting station info) before the driver
    knows about the station, possibly causing it to misbehave.

    Therefore, add a check for sta->uploaded which indicates that the
    driver knows about the station.

    Signed-off-by: Maxim Altshul
    [reword commit message]
    Signed-off-by: Johannes Berg

    Maxim Altshul
     

11 Aug, 2016

1 commit

  • Mesh HWMP module will be able to rely on the HW
    RC algorithm if it exists, for path metric calculations.

    This allows the metric calculation mechanism to calculate
    a correct metric, based on PER and last TX rate both via
    HW RC algorithm if it exists or via parameters collected
    by the SW.

    Signed-off-by: Maxim Altshul
    Signed-off-by: Johannes Berg

    Maxim Altshul
     

09 Jun, 2016

2 commits

  • mac80211's software queues were designed to work
    very closely with device tx queues. They are
    required to make use of 802.11 packet aggregation
    easily and efficiently.

    Due to the way 802.11 aggregation is designed it
    only makes sense to keep fair queuing as close to
    hardware as possible to reduce induced latency and
    inertia and provide the best flow responsiveness.

    This change doesn't translate directly to
    immediate and significant gains. End result
    depends on driver's induced latency. Best results
    can be achieved if driver keeps its own tx
    queue/fifo fill level to a minimum.

    Signed-off-by: Michal Kazior
    Signed-off-by: Johannes Berg

    Michal Kazior
     
  • Qdiscs are designed with no regard to 802.11
    aggregation requirements and hand out
    packet-by-packet with no guarantee they are
    destined to the same tid. This does more bad than
    good no matter how fairly a given qdisc may behave
    on an ethernet interface.

    Software queuing used per-AC netdev subqueue
    congestion control whenever a global AC limit was
    hit. This meant in practice a single station or
    tid queue could starve others rather easily. This
    could resonate with qdiscs in a bad way or could
    just end up with poor aggregation performance.
    Increasing the AC limit would increase induced
    latency which is also bad.

    Disabling qdiscs by default and performing
    taildrop instead of netdev subqueue congestion
    control on the other hand makes it possible for
    tid queues to fill up "in the meantime" while
    preventing stations starving each other.

    This increases aggregation opportunities and
    should allow software queuing based drivers
    achieve better performance by utilizing airtime
    more efficiently with big aggregates.

    Signed-off-by: Michal Kazior
    Signed-off-by: Johannes Berg

    Michal Kazior
     

10 Apr, 2016

1 commit


06 Apr, 2016

7 commits

  • Requires software tx queueing and fast-xmit support. For good
    performance, drivers need frag_list support as well. This avoids the
    need for copying data of aggregated frames. Running without it is only
    supported for debugging purposes.

    To avoid performance and packet size issues, the rate control module or
    driver needs to limit the maximum A-MSDU size by setting
    max_rc_amsdu_len in struct ieee80211_sta.

    Signed-off-by: Felix Fietkau
    [fix locking issue]
    Signed-off-by: Johannes Berg

    Felix Fietkau
     
  • If the driver advertises the new HW flag USE_RSS, make the
    station statistics on the fast-rx path per-CPU. This will
    enable calling the RX in parallel, only hitting locking or
    shared cachelines when the fast-RX path isn't available.

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • The regular RX path has a lot of code, but with a few
    assumptions on the hardware it's possible to reduce the
    amount of code significantly. Currently the assumptions
    on the driver are the following:
    * hardware/driver reordering buffer (if supporting aggregation)
    * hardware/driver decryption & PN checking (if using encryption)
    * hardware/driver did de-duplication
    * hardware/driver did A-MSDU deaggregation
    * AP_LINK_PS is used (in AP mode)
    * no client powersave handling in mac80211 (in client mode)

    of which some are actually checked per packet:
    * de-duplication
    * PN checking
    * decryption
    and additionally packets must
    * not be A-MSDU (have been deaggregated by driver/device)
    * be data packets
    * not be fragmented
    * be unicast
    * have RFC 1042 header

    Additionally dynamically we assume:
    * no encryption or CCMP/GCMP, TKIP/WEP/other not allowed
    * station must be authorized
    * 4-addr format not enabled

    Some data needed for the RX path is cached in a new per-station
    "fast_rx" structure, so that we only need to look at this and
    the packet, no other memory when processing packets on the fast
    RX path.

    After doing the above per-packet checks, the data path collapses
    down to a pretty simple conversion function taking advantage of
    the data cached in the small fast_rx struct.

    This should speed up the RX processing, and will make it easier
    to reason about parallelizing RX (for which statistics will need
    to be per-CPU still.)

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • On 32-bit platforms, the 64-bit counters we keep need to be protected
    to be consistently read. Use the u64_stats_sync mechanism to do that.

    In order to not end up with overly long lines, refactor the tidstats
    assignments a bit.

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • When storing the last_rate_* values in the RX code, there's nothing
    to guarantee consistency, so a concurrent reader could see, e.g.
    last_rate_idx on the new value, but last_rate_flag still on the old,
    getting completely bogus values in the end.

    To fix this, I lifted the sta_stats_encode_rate() function from my
    old rate statistics code, which encodes the entire rate data into a
    single 16-bit value, avoiding the consistency issue.

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • Instead of touching the rx_stats.last_rx from the status path, introduce
    and use a status_stats.last_ack variable. This will make rx_stats.last_rx
    indicate when the last frame was received, making it available for real
    "last_rx" and statistics gathering; statistics, when done per-CPU, will
    need to figure out which place was updated last for those items where the
    "last" value is exposed.

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • Move the averaged values out of rx_stats and into rx_stats_avg,
    to cleanly split them out. The averaged ones cannot be supported
    for parallel RX in a per-CPU fashion, while the other values can
    be collected per CPU and then combined/selected when needed.

    Signed-off-by: Johannes Berg

    Johannes Berg