vxlan: move cleanup to uninit

Put destruction of per-cpu statistics removal in
ndo_uninit since it is created by ndo_init.
This also avoids any problems that might be cause by destructor
being called after module removed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
vxlan: make vxlan_xmit_one void

The function vxlan_xmit_one always returns NETDEV_TX_OK, so there
is no point in keeping track of return values etc.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David L Stevens <dlstevens@us.ibm.com>
vxlan: convert remotes list to list_rcu

Based on initial work by Mike Rapoport <mike.rapoport@ravellosystems.com>
Use list macros and RCU for tracking multiple remotes.

Note: this code assumes list always has at least one entry,
because delete is not supported.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
vxlan: port module param should be ushort

UDP ports are limited to 16 bits.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
vxlan: Use initializer for dummy structures

For the notification code, a couple of places build fdb entries on
the stack, use structure initialization instead and fix formatting.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
vxlan: cosmetic cleanup's

Fix whitespace and spelling

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David L Stevens <dlstevens@us.ibm.com>
kconfig: sort found symbols by relevance

When searching for symbols, return the symbols sorted by relevance.

Sorting is done as thus:
  - first, symbols that match exactly
  - then, alphabetical sort

Since the search can be a regexp, it is possible that more than one symbol
matches exactly. In this case, we can't decide which to sort first, so we
fallback to alphabeticall sort.

Explain this (new!) sorting heuristic in the documentation.

Reported-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Roland Eggner <edvx1@systemanalysen.net>
Cc: Wang YanQing <udknight@gmail.com>

--
Changes v1->v2:
  - drop the previous, complex heuristic in favour of a simpler heuristic
    that is both easier to understand, *and* to maintain (Jean)
  - explain sorting heuristic in the doc  (Jean)
kconfig/[mn]conf: make it explicit in the search box that a regexp is possible

Reported-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: Michal Marek <mmarek@suse.cz>
kconfig: loop as long as we changed some symbols in randconfig

Because of choice-in-a-choice constructs, it can happen that not all
symbols are assigned a value during randconfig, leading in rare cases
to this situation:

    ---8<--- choice-in-choice.in
    choice
        bool "A/B/C"
    config A
        bool "A"

    config B
        bool "B"
    if B
    choice
        bool "E/F"
    config E
        bool "E"
    config F
        bool "F"
    endchoice
    endif # B

    config C
        bool "C"
    endchoice
    ---8<---

    $ ./scripts/kconfig/conf --randconfig choice-in-choice.in
    [--SNIP--]
    $ ./scripts/kconfig/conf --silentoldconfig choice-in-choice.in </dev/null
    [--SNIP--]
    A/B/C
      1. A (A)
    > 2. B (B)
      3. C (C)
    choice[1-3]: 2
      E/F
      > 1. E (E) (NEW)
        2. F (F) (NEW)
      choice[1-2]: aborted!

    Console input/output is redirected. Run 'make oldconfig' to update
    configuration.

Fix this by looping in randconfig for as long as some symbol gets assigned
a value.

Note: this was spotted with the USB EHCI Debug Device Gadget (USB_G_DBGP),
which uses this choice-in-a-choice construct, and exhibits this problem.
The example above is just a stripped-down minimalist test-case.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG

Currently, randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG
is specified.

For example, given those two files (Thomas' test-case):

    ---8<--- Config.test.in
    config OPTIONA
        bool "Option A"

    choice
        prompt "This is a choice"

    config CHOICE_OPTIONA
        bool "Choice Option A"

    config CHOICE_OPTIONB
        bool "Choice Option B"

    endchoice

    config OPTIONB
        bool "Option B"
    ---8<--- Config.test.in

    ---8<--- config.defaults
    CONFIG_OPTIONA=y
    ---8<--- config.defaults

And running:
    ./scripts/kconfig/conf --randconfig Config.test.in

does properly randomise the two choice symbols (and the two booleans).

However, running:
    KCONFIG_ALLCONFIG=config.defaults \
    ./scripts/kconfig/conf --randconfig Config.test.in

does *not* reandomise the two choice entries, and only CHOICE_OPTIONA
will ever be selected. (OPTIONA will always be set (expected), and
OPTIONB will be be properly randomised (expected).)

This patch defers setting that a choice has a value until a symbol for
that choice is indeed set, so that choices are properly randomised when
KCONFIG_ALLCONFIG is set, but not if a symbol for that choice is set.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>

---
Changes v3 -> v4
  - fix previous issue where some choices would not be set, which would
    cause silentoldconfig to ask for them and was then breaking this
    workflow (as reported by Arnd and Sedat):
        KCONFIG_ALLCONFIG=foo.defconfig make randconfig
        make silentoldconfig </dev/nullo
    which I have tested (3h28min!) with:
        touch defconfig
        for(( i=0; i<10000; i++ )); do
            KCONFIG_ALLCONFIG=$(pwd)/defconfig make randconfig >/dev/null 2>&1
            make silentoldconfig </dev/null >/dev/null 2>&1 || break
        done
    which did not break at all.
  - change done in v3 (below) is already fixed by a previous patch

Changes v2 -> v3
  - ensure only one symbol is set in a choice

Changes v1 -> v2:
  - further postpone setting that a choice has a value until
    one is indeed set
  - do not print symbols that are part of an invisible choice
ath9k_htc: Support reporting tx and rx chain mask.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ath9k_htc: Add ethtool stats support.

This provides some of the same info found in
the ath9k_htc debugfs through the standard ethtool stats API.

This logic is only supported when ath9k_htc debugfs kernel
feature is enabled, since that is the only time stats
are actually gathered.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ath9k: fix queue depth accounting in ath_tx_txqaddbuf

ath_tx_txqaddbuf assumes that all the linked buffers in the queue passed
to it are part of the same A-MPDU or MPDU. The CAB queue rework violates
this assumption, which can cause the internal queue depth to go
negative.
Fix this by increasing the counter for all slots of [bf, bf->bf_lastbf]

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ipw2200: fix error return code in ipw_load()

Fix to return -ENOMEM in the ipw_rx_queue_alloc() error handling
case instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cw1200: Fix up a large pile of sparse warnings

Most of these relate to endianness problems, and are purely cosmetic.

But a couple of them were legit -- listen interval parsing and some of
the rate selection code would malfunction on BE systems.

There's still one cosmetic warning remaining, in the (admittedly) ugly
code in cw1200_spi.c.  It's there because the hardware needs 16-bit SPI
transfers, but many SPI controllers only operate 8 bits at a time.

If there's a cleaner way of handling this, I'm all ears.

Signed-off-by: Solomon Peachy <pizza@shaftnet.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ath9k: Enable WoW only for supported models

Since platform support is required for WoW, identify and
and enable Wow only for supported cards.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ipw2x00: printing the wrong array in debug code

Smatch complains that this is a read past the end of the array.  It
turns out we are printing the wrong array here.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
rt2x00: read 5GHz TX power values from the correct offset

The current code uses the same index value both
for the channel information array and for the TX
power table. The index starts from 14, however the
index of the TX power table must start from zero.

Fix it, in order to get the correct TX power value
for a given channel.

The changes in rt61pci.c and rt73usb.c are compile
tested only.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: stable@vger.kernel.org
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
rt2x00: rt2800pci: don't use TXWI_DESC_SIZE directly

Different chipsets may use different TXWI descriptor
size. Instead of using a hardcoded value, use the
'queue->winfo_size' which holds the correct value for
a given device.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
rt2x00: rt2800: unify [RT]XWI_SIZE defines

Use common names instead of chip specific ones.
The patch contains no functional changes, but
it makes it easier to add support for further
descriptor sizes.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>