carl9170fw.git
3 years agomac80211: Handle special status codes in SAE commit
Jouni Malinen [Fri, 31 Jul 2020 18:38:30 +0000 (21:38 +0300)]
mac80211: Handle special status codes in SAE commit

SAE authentication has been extended with H2E (IEEE 802.11 REVmd) and PK
(WFA) options. Those extensions use special status code values in the
SAE commit messages (Authentication frame with transaction sequence
number 1) to identify which extension is in use. mac80211 was
interpreting those new values as the AP denying authentication and that
resulted in failure to complete SAE authentication in some cases.

Fix this by adding exceptions for the new status code values 126 and
127.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Link: https://lore.kernel.org/r/20200731183830.18735-1-jouni@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: Add missing and new AKM suite selector definitions
Veerendranath Jakkam [Wed, 17 Jun 2020 11:31:32 +0000 (17:01 +0530)]
ieee80211: Add missing and new AKM suite selector definitions

Add the definitions for missing AKM selectors defined in
IEEE P802.11-REVmd/D3.0, table 9-151. These definitions will
be used by various drivers that support these new AKM suites.

Signed-off-by: Veerendranath Jakkam <vjakkam@codeaurora.org>
Link: https://lore.kernel.org/r/20200617113132.13477-1-vjakkam@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: check the correct bit for EMA AP
Shaul Triebitz [Thu, 28 May 2020 19:34:37 +0000 (21:34 +0200)]
mac80211: check the correct bit for EMA AP

An AP supporting EMA (Enhanced Multi-BSSID advertisement) should set
bit 83 in the extended capabilities IE (9.4.2.26 in the 802.11ax D5 spec).
So the *3rd* bit of the 10th byte should be checked.
Also, in one place, the wrong byte was checked.
(cfg80211_find_ie returns a pointer to the beginning of the IE,
 so the data really starts at ie[2], so the 10th byte
 should be ie[12]. To avoid this confusion, use cfg80211_find_elem
 instead).

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Link: https://lore.kernel.org/r/20200528213443.4316121fa2a3.I9745582f8d41ad8e689dac0fefcd70b276d7c1ea@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: add HE ext EIDs and 6 GHz capability defines
Johannes Berg [Thu, 28 May 2020 19:34:28 +0000 (21:34 +0200)]
ieee80211: add HE ext EIDs and 6 GHz capability defines

Add the HE extended element IDs and the definitions for the
HE 6 GHz band capabilities element, from Draft 5.0.

Link: https://lore.kernel.org/r/20200528213443.1a6689fe093f.Ifdc5400fb01779351354daf38663ebeea03c9ad9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: add code to obtain and parse 6 GHz operation field
Johannes Berg [Thu, 28 May 2020 19:34:27 +0000 (21:34 +0200)]
ieee80211: add code to obtain and parse 6 GHz operation field

Add some code to obtain and parse the 6 GHz operation field
inside the HE operation element.

While at it, fix the required length using sizeof() the new
struct, which is 5 instead of 4 now.

Link: https://lore.kernel.org/r/20200528213443.42ca72c45ca9.Id74bc1b03da9ea6574f9bc70deeb60dfc1634359@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: definitions for reduced neighbor reports
Tova Mussai [Thu, 28 May 2020 19:34:26 +0000 (21:34 +0200)]
ieee80211: definitions for reduced neighbor reports

Add the necessary definitions to parse reduced neighbor
report elements.

Signed-off-by: Tova Mussai <tova.mussai@intel.com>
[change struct name, remove IEEE80211_MIN_AP_NEIGHBOR_INFO_SIZE]
Link: https://lore.kernel.org/r/20200528213443.4f9154461c06.I518d9898ad982f838112ea9ca14a20d6bbb16394@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 18:39:09 +0000 (13:39 -0500)]
cfg80211: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20200507183909.GA12993@embeddedor
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: Add new AMPDU factor macro for HE peer caps
Tamizh Chelvam [Mon, 4 May 2020 17:04:59 +0000 (22:34 +0530)]
mac80211: Add new AMPDU factor macro for HE peer caps

Add IEEE80211_HE_VHT_MAX_AMPDU_FACTOR and IEEE80211_HE_HT_MAX_AMPDU_FACTOR
as per spec to use for peer max ampdu factor.

Signed-off-by: Tamizh Chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1588611900-21185-1-git-send-email-tamizhr@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: S1G defines
Thomas Pedersen [Thu, 30 Apr 2020 17:25:53 +0000 (10:25 -0700)]
ieee80211: S1G defines

These are found in IEEE-802.11ah-2016.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200430172554.18383-5-thomas@adapt-ip.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: add KHz variants of frame RX API
Thomas Pedersen [Thu, 30 Apr 2020 17:25:50 +0000 (10:25 -0700)]
cfg80211: add KHz variants of frame RX API

Drivers may wish to report the RX frequency in units of
KHz. Provide cfg80211_rx_mgmt_khz() and wrap it with
cfg80211_rx_mgmt() so exisiting drivers which can't report
KHz anyway don't need to change. Add a similar wrapper for
cfg80211_report_obss_beacon() so the frequency units stay
somewhat consistent.

This doesn't actually change the nl80211 API yet.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200430172554.18383-2-thomas@adapt-ip.com
[fix mac80211 calling the non-khz version of obss beacon report,
 drop trace point name changes]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: Fix incorrect mask for default PE duration
Pradeep Kumar Chitrapu [Wed, 6 May 2020 10:24:30 +0000 (03:24 -0700)]
ieee80211: Fix incorrect mask for default PE duration

Fixes bitmask for HE opration's default PE duration.

Fixes: daa5b83513a7 ("mac80211: update HE operation fields to D3.0")
Signed-off-by: Pradeep Kumar Chitrapu <pradeepc@codeaurora.org>
Link: https://lore.kernel.org/r/20200506102430.5153-1-pradeepc@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: share 802.11 unit conversion helpers
Thomas Pedersen [Thu, 2 Apr 2020 01:18:02 +0000 (18:18 -0700)]
ieee80211: share 802.11 unit conversion helpers

MHZ_TO_KHZ, and KHZ_TO_MHZ are useful to drivers and
elsewhere so export these in the common ieee80211 header.
Move the power helpers also because we might as well.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200402011810.22947-2-thomas@adapt-ip.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: Parse HE membership selector
Ilan Peer [Thu, 26 Mar 2020 13:09:35 +0000 (15:09 +0200)]
cfg80211: Parse HE membership selector

This extends the support for drivers that rebuilds IEs in the
FW (same as with HT/VHT).

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200326150855.20feaabfb484.I886252639604c8e3e84b8ef97962f1b0e4beec81@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: implement Operating Mode Notification extended NSS support
Johannes Berg [Thu, 26 Mar 2020 13:09:32 +0000 (15:09 +0200)]
mac80211: implement Operating Mode Notification extended NSS support

Somehow we missed this for a long time, but similar to the extended
NSS support in VHT capabilities, we need to have this in Operating
Mode notification.

Implement it by
 * parsing the 160/80+80 bit there and setting the bandwidth
   appropriately
 * having callers of ieee80211_get_vht_max_nss() pass in the current
   max NSS value as received in the operating mode notification in
   order to modify it appropriately depending on the extended NSS
   bits.

This updates all drivers that use it, i.e. only iwlwifi/mvm.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200326150855.098483728cfa.I4e8c25d3288441759c2793247197229f0696a37d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: fix HE SPR size calculation
Johannes Berg [Wed, 25 Mar 2020 08:09:19 +0000 (09:09 +0100)]
ieee80211: fix HE SPR size calculation

The he_sr_control field is just a u8, so le32_to_cpu()
shouldn't be applied to it; this was evidently copied
from ieee80211_he_oper_size(). Fix it, and also adjust
the type of the local variable.

Fixes: ef11a931bd1c ("mac80211: HE: add Spatial Reuse element parsing support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20200325090918.dfe483b49e06.Ia53622f23b2610a2ae6ea39a199866196fe946c1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: add WPA3 OWE AKM suite selector
Sergey Matyukevich [Thu, 13 Feb 2020 13:16:17 +0000 (13:16 +0000)]
ieee80211: add WPA3 OWE AKM suite selector

Add the definition for Opportunistic Wireless Encryption AKM selector.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Link: https://lore.kernel.org/r/20200213131608.10541-3-sergey.matyukevich.os@quantenna.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: parse also the RSNXE IE
Shaul Triebitz [Fri, 31 Jan 2020 11:12:57 +0000 (13:12 +0200)]
mac80211: parse also the RSNXE IE

Parse also the RSN Extension IE when parsing the rest of the IEs.
It will be used in a later patch.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/20200131111300.891737-21-luca@coelho.fi
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: fix 'the' doubling in comments
Zvika Yehudai [Mon, 3 Feb 2020 08:08:23 +0000 (10:08 +0200)]
ieee80211: fix 'the' doubling in comments

Remove redundant 'the' where 'the the' was written.

Signed-off-by: Zvika Yehudai <zvikayeh@gmail.com>
Link: https://lore.kernel.org/r/20200203080823.24949-1-zvikayeh@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: add ieee80211_is_any_nullfunc()
Thomas Pedersen [Tue, 14 Jan 2020 05:59:40 +0000 (21:59 -0800)]
mac80211: add ieee80211_is_any_nullfunc()

commit 08a5bdde3812 ("mac80211: consider QoS Null frames for STA_NULLFUNC_ACKED")
Fixed a bug where we failed to take into account a
nullfunc frame can be either non-QoS or QoS. It turns out
there is at least one more bug in
ieee80211_sta_tx_notify(), introduced in
commit 7b6ddeaf27ec ("mac80211: use QoS NDP for AP probing"),
where we forgot to check for the QoS variant and so
assumed the QoS nullfunc frame never went out

Fix this by adding a helper ieee80211_is_any_nullfunc()
which consolidates the check for non-QoS and QoS nullfunc
frames. Replace existing compound conditionals and add a
couple more missing checks for QoS variant.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200114055940.18502-3-thomas@adapt-ip.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agotrivial: mac80211: fix indentation
John Crispin [Fri, 6 Dec 2019 14:31:03 +0000 (15:31 +0100)]
trivial: mac80211: fix indentation

Signed-off-by: John Crispin <john@phrozen.org>
Link: https://lore.kernel.org/r/20191206143103.3645-1-john@phrozen.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: add support for the ADDBA extension element
John Crispin [Mon, 29 Jul 2019 10:45:12 +0000 (12:45 +0200)]
mac80211: add support for the ADDBA extension element

HE allows peers to negotiate the aggregation fragmentation level to be used
during transmission. The level can be 1-3. The Ext element is added behind
the ADDBA request inside the action frame. The responder will then reply
with the same level or a lower one if the requested one is not supported.
This patch only handles the negotiation part as the ADDBA frames get passed
to the ATH11k firmware, which does the rest of the magic for us aswell as
generating the requests.

Signed-off-by: Shashidhar Lakkavalli <slakkavalli@datto.com>
Signed-off-by: John Crispin <john@phrozen.org>
Link: https://lore.kernel.org/r/20190729104512.27615-1-john@phrozen.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: fix ieee80211_he_oper_size() comment
John Crispin [Mon, 29 Jul 2019 10:23:41 +0000 (12:23 +0200)]
mac80211: fix ieee80211_he_oper_size() comment

Johannes mentioned that the comment should not reference mac80211 as other
subsystems might call the helper.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20190729102342.8659-1-john@phrozen.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: HE: add Spatial Reuse element parsing support
John Crispin [Tue, 18 Jun 2019 06:19:14 +0000 (08:19 +0200)]
mac80211: HE: add Spatial Reuse element parsing support

Add support to mac80211 for parsing SPR elements as per
P802.11ax_D4.0 section 9.4.2.241.

Signed-off-by: Shashidhar Lakkavalli <slakkavalli@datto.com>
Signed-off-by: John Crispin <john@phrozen.org>
Link: https://lore.kernel.org/r/20190618061915.7102-2-john@phrozen.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: add support for parsing ADDBA_EXT IEs
John Crispin [Sat, 13 Jul 2019 16:36:41 +0000 (18:36 +0200)]
mac80211: add support for parsing ADDBA_EXT IEs

ADDBA_EXT IEs can be used to negotiate the BA fragmentation level.

Signed-off-by: John Crispin <john@phrozen.org>
Link: https://lore.kernel.org/r/20190713163642.18491-2-john@phrozen.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agotreewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Thomas Gleixner [Tue, 4 Jun 2019 08:11:33 +0000 (10:11 +0200)]
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

  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 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 #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: Add a missing extended capability flag definition
Ilan Peer [Wed, 29 May 2019 12:25:33 +0000 (15:25 +0300)]
ieee80211: Add a missing extended capability flag definition

Add the "OBSS Narrow Bandwidth RU In OFDMA Tolerance Support" flag
definition to the definitions of the flags covered by the Extended
Capability IE.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agonl80211: add support for SAE authentication offload
Chung-Hsien Hsu [Thu, 9 May 2019 09:49:06 +0000 (09:49 +0000)]
nl80211: add support for SAE authentication offload

Let drivers advertise support for station-mode SAE authentication
offload with a new NL80211_EXT_FEATURE_SAE_OFFLOAD flag.

Signed-off-by: Chung-Hsien Hsu <stanley.hsu@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: update HE IEs to D4.0 spec
Liad Kaufman [Fri, 15 Mar 2019 15:39:07 +0000 (17:39 +0200)]
ieee80211: update HE IEs to D4.0 spec

Update the out-dated comments as well, and have them point to
the correct sections in the D4.0 spec.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: support non-inheritance element
Sara Sharon [Fri, 15 Mar 2019 15:39:03 +0000 (17:39 +0200)]
cfg80211: support non-inheritance element

Subelement profile may specify element IDs it doesn't inherit
from the management frame. Support it.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: update HE IEs to D3.3
Liad Kaufman [Wed, 6 Feb 2019 11:17:20 +0000 (13:17 +0200)]
mac80211: update HE IEs to D3.3

Update element names and new fields according to D3.3 of
the HE spec.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: support max channel switch time element
Sara Sharon [Wed, 6 Feb 2019 11:17:09 +0000 (13:17 +0200)]
mac80211: support max channel switch time element

2018 REVmd of the spec introduces the max channel switch time
element which is optionally included in beacons/probes when there
is a channel switch / extended channel switch element.
The value represents the maximum delay between the time the AP
transmitted the last beacon in current channel and the expected
time of the first beacon in the new channel, in TU.

Parse the value and pass it to the driver.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoiwlwifi: mvm: support FTM initiator
Johannes Berg [Wed, 5 Dec 2018 10:33:34 +0000 (11:33 +0100)]
iwlwifi: mvm: support FTM initiator

Add support for FTM initiator, i.e. peer measurements with FTM
if the firmware supports FTM.

Additionally, add two defines we depend on in
include/linux/ieee80211.h.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: Use const more consistently in for_each_element macros
Jouni Malinen [Mon, 11 Feb 2019 14:29:04 +0000 (16:29 +0200)]
cfg80211: Use const more consistently in for_each_element macros

Enforce the first argument to be a correct type of a pointer to struct
element and avoid unnecessary typecasts from const to non-const pointers
(the change in validate_ie_attr() is needed to make this part work). In
addition, avoid signed/unsigned comparison within for_each_element() and
mark struct element packed just in case.

Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: fix for_each_element_extid()
Johannes Berg [Fri, 8 Feb 2019 16:56:33 +0000 (17:56 +0100)]
ieee80211: fix for_each_element_extid()

The data/datalen argument names cannot be used as those
are also the struct element names, fix that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: indicate support for multiple BSSID
Sara Sharon [Wed, 16 Jan 2019 21:03:25 +0000 (23:03 +0200)]
mac80211: indicate support for multiple BSSID

Set multi-bssid support flags according to driver support.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: support multi-bssid
Sara Sharon [Wed, 16 Jan 2019 16:22:56 +0000 (18:22 +0200)]
mac80211: support multi-bssid

Add support for multi-bssid.

This includes:
- Parsing multi-bssid element
- Overriding DTIM values
- Taking into account in various places the inner BSSID instead of
  transmitter BSSID
- Save aside some multi-bssid properties needed by drivers

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: add and use strongly typed element iteration macros
Johannes Berg [Thu, 7 Feb 2019 20:44:41 +0000 (21:44 +0100)]
cfg80211: add and use strongly typed element iteration macros

Rather than always iterating elements from frames with pure
u8 pointers, add a type "struct element" that encapsulates
the id/datalen/data format of them.

Then, add the element iteration macros
 * for_each_element
 * for_each_element_id
 * for_each_element_extid

which take, as their first 'argument', such a structure and
iterate through a given u8 array interpreting it as elements.

While at it and since we'll need it, also add
 * for_each_subelement
 * for_each_subelement_id
 * for_each_subelement_extid

which instead of taking data/length just take an outer element
and use its data/datalen.

Also add for_each_element_completed() to determine if any of
the loops above completed, i.e. it was able to parse all of
the elements successfully and no data remained.

Use for_each_element_id() in cfg80211_find_ie_match() as the
first user of this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: update HE operation fields to D3.0
Shaul Triebitz [Sat, 15 Dec 2018 09:03:05 +0000 (11:03 +0200)]
mac80211: update HE operation fields to D3.0

HE Operation element has changed in 11ax D3.0.  Update the fields
accordingly.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: add bits for TWT in Extended Capabilities IE
Emmanuel Grumbach [Sat, 15 Dec 2018 09:03:03 +0000 (11:03 +0200)]
ieee80211: add bits for TWT in Extended Capabilities IE

These bits are defined in ieee802.11ax to advertise support
for TWT in addition to the bits in the HE IE.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years ago{nl,mac}80211: report gate connectivity in station info
Bob Copeland [Thu, 25 Oct 2018 19:48:53 +0000 (15:48 -0400)]
{nl,mac}80211: report gate connectivity in station info

Capture the current state of gate connectivity from the mesh
formation field in mesh config whenever we receive a beacon,
and report that via GET_STATION.  This allows applications
doing mesh peering in userspace to make peering decisions
based on peers' current upstream connectivity.

Signed-off-by: Bob Copeland <bobcopeland@fb.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: minstrel: Enable STBC and LDPC for VHT Rates
Chaitanya T K [Sat, 6 Oct 2018 17:34:59 +0000 (19:34 +0200)]
mac80211: minstrel: Enable STBC and LDPC for VHT Rates

If peer support reception of STBC and LDPC, enable them for better
performance.

Signed-off-by: Chaitanya TK <chaitanya.mgit@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agowireless: align to draft 11ax D3.0
Shaul Triebitz [Wed, 5 Sep 2018 05:06:08 +0000 (08:06 +0300)]
wireless: align to draft 11ax D3.0

Align to new 11ax draft D3.0.  Change/add new MAC and PHY capabilities
and update drivers' 11ax capabilities and mac80211's debugfs
accordingly.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: add new VHT capability fields/parsing
Johannes Berg [Fri, 31 Aug 2018 08:31:16 +0000 (11:31 +0300)]
ieee80211: add new VHT capability fields/parsing

IEEE 802.11-2016 extended the VHT capability fields to allow
indicating the number of spatial streams depending on the
actually used bandwidth, add support for decoding this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: remove redundant leading zeroes
Sara Sharon [Fri, 31 Aug 2018 08:31:09 +0000 (11:31 +0300)]
ieee80211: remove redundant leading zeroes

The defines of IEEE80211_HE_OPERATION_VHT_OPER_INFO and
IEEE80211_HE_OPERATION_MULTI_BSSID_AP have leading zeroes
that makes the number look like it is bigger than 32 bit.
This is misleading, remove it.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: bump IEEE80211_MAX_AMPDU_BUF to support HE
Johannes Berg [Mon, 18 Jun 2018 20:39:29 +0000 (22:39 +0200)]
ieee80211: bump IEEE80211_MAX_AMPDU_BUF to support HE

Bump the IEEE80211_MAX_AMPDU_BUF size to 0x100 for HE support
and - for now - use IEEE80211_MAX_AMPDU_BUF_HT everywhere.

This is derived from my internal patch, parts of which Luca
had sent upstream.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocfg80211: Add support for HE
Luca Coelho [Sat, 9 Jun 2018 06:14:42 +0000 (09:14 +0300)]
cfg80211: Add support for HE

Add support for the HE in cfg80211 and also add userspace API to
nl80211 to send rate information out, conforming with P802.11ax_D2.0.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Ido Yariv <idox.yariv@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
[added missing DIV_ROUND_UP + hweight from the linux kernel]
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agomac80211: add get TID helper
Sara Sharon [Mon, 19 Feb 2018 12:48:40 +0000 (14:48 +0200)]
mac80211: add get TID helper

Extracting the TID from the QOS header is common enough
to justify helper.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agoieee80211: Increase PMK maximum length to 64 bytes
Srinivas Dasari [Tue, 6 Feb 2018 14:19:35 +0000 (19:49 +0530)]
ieee80211: Increase PMK maximum length to 64 bytes

Increase the PMK maximum length to 64 bytes to accommodate
the key length used in DPP with the NIST P-521 and
Brainpool 512 curves.

Signed-off-by: Srinivas Dasari <dasaris@codeaurora.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocarl9170 firmware: refresh ch9.h
Christian Lamparter [Fri, 5 Feb 2021 10:38:29 +0000 (11:38 +0100)]
carl9170 firmware: refresh ch9.h

This patch refreshes the upstream linux ch9.h header definitions.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocarl9170 firmware: prepare header update
Christian Lamparter [Fri, 5 Feb 2021 09:24:38 +0000 (10:24 +0100)]
carl9170 firmware: prepare header update

This patch brings the shared firmware headers in line with the carl9170
linux kernel driver.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agotreewide: Replace GPLv2 boilerplate/reference with SPDX - rule 325
Thomas Gleixner [Wed, 29 May 2019 23:57:40 +0000 (16:57 -0700)]
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 325

Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license 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 you should have received a
  copy of the gnu general public license along with this program see
  the file copying if not see http www gnu org licenses

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 1 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000435.742096485@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocarl9170: fix struct alignment conflict
Arnd Bergmann [Thu, 4 Feb 2021 16:29:17 +0000 (17:29 +0100)]
carl9170: fix struct alignment conflict

Multiple structures in the carl9170 driver have alignment
impossible alignment constraints that gcc warns about when
building with 'make W=1':

include/shared/fwcmd.h:243:2: warning: alignment 1 of 'union <anonymous>' is less than 4 [-Wpacked-not-aligned]
include/shared/wlan.h:373:1: warning: alignment 1 of 'struct ar9170_rx_frame_single' is less than 2 [-Wpacked-not-aligned]

In the carl9170_cmd structure, multiple members that have an explicit
alignment requirement of four bytes are added into a union with explicit
byte alignment, but this in turn is part of a structure that also has
four-byte alignment.

In the wlan.h header, multiple structures contain a ieee80211_hdr member
that is required to be two-byte aligned to avoid alignmnet faults when
processing network headers, but all members are forced to be byte-aligned
using the __packed tag at the end of the struct definition.

In both cases, leaving out the packing does not change the internal
layout of the structure but changes the alignment constraint of the
structure itself.

Change all affected structures to only apply packing where it does
not violate the alignment requirement of the contained structure.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocarl9170: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 15:19:21 +0000 (10:19 -0500)]
carl9170: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507151921.GA5083@embeddedor
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocarl9170 toolchain: update to gcc 10.2.0
Christian Lamparter [Fri, 24 Jul 2020 22:47:12 +0000 (00:47 +0200)]
carl9170 toolchain: update to gcc 10.2.0

This patch also removes some of SHA256SUMS' old entries.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
3 years agocarl9170 toolchain: update to gcc 10.1.0
Christian Lamparter [Sat, 9 May 2020 20:33:20 +0000 (22:33 +0200)]
carl9170 toolchain: update to gcc 10.1.0

This patch also removes some of SHA256SUMS' old entries.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agocarl9170 toolchain: update to gcc 9.3.0
Christian Lamparter [Fri, 20 Mar 2020 19:27:34 +0000 (20:27 +0100)]
carl9170 toolchain: update to gcc 9.3.0

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: don't crash on NULL expressions in expr_eq()
Thomas Hebb [Mon, 9 Dec 2019 08:19:17 +0000 (00:19 -0800)]
kconfig: don't crash on NULL expressions in expr_eq()

NULL expressions are taken to always be true, as implemented by the
expr_is_yes() macro and by several other functions in expr.c. As such,
they ought to be valid inputs to expr_eq(), which compares two
expressions.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: Add option to get the full help text with listnewconfig
Laura Abbott [Mon, 4 Nov 2019 22:10:08 +0000 (17:10 -0500)]
kconfig: Add option to get the full help text with listnewconfig

make listnewconfig will list the individual options that need to be set.
This is useful but there's no easy way to get the help text associated
with the options at the same time. Introduce a new targe
'make helpnewconfig' which lists the full help text of all the
new options as well. This makes it easier to automatically generate
changes that are easy for humans to review. This command also adds
markers between each option for easier parsing.

Signed-off-by: Laura Abbott <labbott@redhat.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: split util.c out of parser.y
Masahiro Yamada [Sun, 25 Aug 2019 17:28:33 +0000 (02:28 +0900)]
kconfig: split util.c out of parser.y

util.c exists both in scripts/kconfig/ and scripts/kconfig/lxdialog.

Prior to commit 54b8ae66ae1a ("kbuild: change *FLAGS_<basetarget>.o
to take the path relative to $(obj)"), Kbuild could not pass different
flags to source files with the same basename. Now that this issue
was solved, you can split util.c out of parser.y and compile them
independently of each other.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agocarl9170 toolchain: update binutils, newlib and gmp
Christian Lamparter [Sat, 1 Feb 2020 17:54:28 +0000 (18:54 +0100)]
carl9170 toolchain: update binutils, newlib and gmp

This patch updates three toolchain sources:
binutils - 2.34
newlib - 3.3.0
gmp - 6.2.0

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agocarl9170 toolchain: update to binutils 2.33.1
Christian Lamparter [Sat, 26 Oct 2019 16:29:18 +0000 (18:29 +0200)]
carl9170 toolchain: update to binutils 2.33.1

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agocarl9170: config: update CMakeFiles
Christian Lamparter [Fri, 27 Sep 2019 20:49:51 +0000 (22:49 +0200)]
carl9170: config: update CMakeFiles

 - parser and lexer were renamed from the previous generic zconf.*.*

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: Clear "written" flag to avoid data loss
M. Vefa Bicakci [Sat, 3 Aug 2019 10:02:12 +0000 (06:02 -0400)]
kconfig: Clear "written" flag to avoid data loss

Prior to this commit, starting nconfig, xconfig or gconfig, and saving
the .config file more than once caused data loss, where a .config file
that contained only comments would be written to disk starting from the
second save operation.

This bug manifests itself because the SYMBOL_WRITTEN flag is never
cleared after the first call to conf_write, and subsequent calls to
conf_write then skip all of the configuration symbols due to the
SYMBOL_WRITTEN flag being set.

This commit resolves this issue by clearing the SYMBOL_WRITTEN flag
from all symbols before conf_write returns.

Fixes: 8e2442a5f86e ("kconfig: fix missing choice values in auto.conf")
Cc: linux-stable <stable@vger.kernel.org> # 4.19+
Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: fix missing choice values in auto.conf
Masahiro Yamada [Fri, 12 Jul 2019 06:07:09 +0000 (15:07 +0900)]
kconfig: fix missing choice values in auto.conf

Since commit 00c864f8903d ("kconfig: allow all config targets to write
auto.conf if missing"), Kconfig creates include/config/auto.conf in the
defconfig stage when it is missing.

Joonas Kylmälä reported incorrect auto.conf generation under some
circumstances.

To reproduce it, apply the following diff:

|  --- a/arch/arm/configs/imx_v6_v7_defconfig
|  +++ b/arch/arm/configs/imx_v6_v7_defconfig
|  @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y
|   CONFIG_USB_CONFIGFS_F_HID=y
|   CONFIG_USB_CONFIGFS_F_UVC=y
|   CONFIG_USB_CONFIGFS_F_PRINTER=y
|  -CONFIG_USB_ZERO=m
|  -CONFIG_USB_AUDIO=m
|  -CONFIG_USB_ETH=m
|  -CONFIG_USB_G_NCM=m
|  -CONFIG_USB_GADGETFS=m
|  -CONFIG_USB_FUNCTIONFS=m
|  -CONFIG_USB_MASS_STORAGE=m
|  -CONFIG_USB_G_SERIAL=m
|  +CONFIG_USB_FUNCTIONFS=y
|   CONFIG_MMC=y
|   CONFIG_MMC_SDHCI=y
|   CONFIG_MMC_SDHCI_PLTFM=y

And then, run:

$ make ARCH=arm mrproper imx_v6_v7_defconfig

You will see CONFIG_USB_FUNCTIONFS=y is correctly contained in the
.config, but not in the auto.conf.

Please note drivers/usb/gadget/legacy/Kconfig is included from a choice
block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value.

This is probably a similar situation described in commit beaaddb62540
("kconfig: tests: test defconfig when two choices interact").

When sym_calc_choice() is called, the choice symbol forgets the
SYMBOL_DEF_USER unless all of its choice values are explicitly set by
the user.

The choice symbol is given just one chance to recall it because
set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES
is set.

When sym_calc_choice() is called again, the choice symbol forgets it
forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid.
Hence, we cannot call sym_clear_all_valid() again and again.

It is crazy to repeat set and unset of internal flags. However, we
cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;"
Doing so would re-introduce the problem solved by commit 5d09598d488f
("kconfig: fix new choices being skipped upon config update").

To work around the issue, conf_write_autoconf() stopped calling
sym_clear_all_valid().

conf_write() must be changed accordingly. Currently, it clears
SYMBOL_WRITE after the symbol is written into the .config file. This
is needed to prevent it from writing the same symbol multiple times in
case the symbol is declared in two or more locations. I added the new
flag SYMBOL_WRITTEN, to track the symbols that have been written.

Anyway, this is a cheesy workaround in order to suppress the issue
as far as defconfig is concerned.

Handling of choices is totally broken. sym_clear_all_valid() is called
every time a user touches a symbol from the GUI interface. To reproduce
it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch
around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear
from the .config file.

I added the Fixes tag since it is more fatal than before. But, this
has been broken since long long time before, and still it is.
We should take a closer look to fix this correctly somehow.

Fixes: 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing")
Cc: linux-stable <stable@vger.kernel.org> # 4.19+
Reported-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: remove meaningless if-conditional in conf_read()
Masahiro Yamada [Thu, 11 Jul 2019 07:33:17 +0000 (16:33 +0900)]
kconfig: remove meaningless if-conditional in conf_read()

sym_is_choice(sym) has already been checked by previous if-block:

    if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
            continue;

Hence, the following code is redundant, and the comment is misleading:

    if (!sym_is_choice(sym))
            continue;
    /* fall through */

It always takes 'continue', never falls though.

Clean up the dead code.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: Fix spelling of sym_is_changable
Marco Ammon [Thu, 4 Jul 2019 10:50:41 +0000 (12:50 +0200)]
kconfig: Fix spelling of sym_is_changable

There is a spelling mistake in "changable", it is corrected to
"changeable" and all call sites are updated accordingly.

Signed-off-by: Marco Ammon <marco.ammon@fau.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agodocs: kbuild: convert docs to ReST and rename to *.rst
Mauro Carvalho Chehab [Wed, 12 Jun 2019 17:52:48 +0000 (14:52 -0300)]
docs: kbuild: convert docs to ReST and rename to *.rst

The kbuild documentation clearly shows that the documents
there are written at different times: some use markdown,
some use their own peculiar logic to split sections.

Convert everything to ReST without affecting too much
the author's style and avoiding adding uneeded markups.

The conversion is actually:
  - add blank lines and identation in order to identify paragraphs;
  - fix tables markups;
  - add some lists markups;
  - mark literal blocks;
  - adjust title markups.

At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: add static qualifier to expand_string()
Masahiro Yamada [Mon, 27 May 2019 14:37:23 +0000 (23:37 +0900)]
kconfig: add static qualifier to expand_string()

Now expand_string() is only used in preprocess.c

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: require the argument of --defconfig
Masahiro Yamada [Mon, 27 May 2019 14:37:22 +0000 (23:37 +0900)]
kconfig: require the argument of --defconfig

Currently, the argument for --defconfig is optional. If the argument
is not passed, the hard-coded default arch/$(ARCH)/defconfig is used.

It no longer happens in Linux since the last users of the default are
gone by the following commits:

- Commit f3e20ad67b4c ("s390: move arch/s390/defconfig to
  arch/s390/configs/defconfig")

- Commit 986a13769c4b ("alpha: move arch/alpha/defconfig to
  arch/alpha/configs/defconfig")

I want to kill the Linux-specific directory path embedded in the
Kconfig binary.

The --savedefconfig (reverse operation of --defconfig) requires an
argument, so it should not hurt to do likewise for --defconfig.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: Terminate menu blocks with a comment in the generated config
Alexander Popov [Fri, 17 May 2019 19:42:22 +0000 (22:42 +0300)]
kconfig: Terminate menu blocks with a comment in the generated config

Currently menu blocks start with a pretty header but end with nothing in
the generated config. So next config options stick together with the
options from the menu block.

Let's terminate menu blocks in the generated config with a comment and
a newline if needed. Example:

...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y
# end of Network testing
# end of Networking options

CONFIG_HAMRADIO=y
...

Signed-off-by: Alexander Popov <alex.popov@linux.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: make conf_get_autoconfig_name() static
Masahiro Yamada [Sun, 12 May 2019 16:00:53 +0000 (01:00 +0900)]
kconfig: make conf_get_autoconfig_name() static

This is only used in confdata.c

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: use snprintf for formatting pathnames
Jacob Garber [Fri, 10 May 2019 19:28:52 +0000 (13:28 -0600)]
kconfig: use snprintf for formatting pathnames

Valid pathnames will never exceed PATH_MAX, but these file names
are unsanitized and can cause buffer overflow if set incorrectly.
Use snprintf to avoid this. This was flagged during a Coverity scan
of the coreboot project, which also uses kconfig for its build system.

Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: remove useless NULL pointer check in conf_write_dep()
Masahiro Yamada [Fri, 10 May 2019 16:56:48 +0000 (01:56 +0900)]
kconfig: remove useless NULL pointer check in conf_write_dep()

conf_write_dep() has just one caller:

    conf_write_dep("include/config/auto.conf.cmd");

"name" always points to a valid string.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: make parent directories for the saved .config as needed
Masahiro Yamada [Fri, 10 May 2019 16:56:01 +0000 (01:56 +0900)]
kconfig: make parent directories for the saved .config as needed

With menuconfig / nconfig, users can input any file path from the
"Save" menu, but it fails if the parent directory does not exist.

Why not create the parent directory automatically. I think this is
a user-friendly behavior.

I changed the error messages in menuconfig / nconfig.

"Nonexistent directory" is no longer the most likely reason of the
failure. Perhaps, the user specified the existing directory, or
attempted to write to the location without write permission.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: do not write .config if the content is the same
Masahiro Yamada [Fri, 10 May 2019 06:12:05 +0000 (15:12 +0900)]
kconfig: do not write .config if the content is the same

Kconfig updates the .config when it exits even if its content is
exactly the same as before. Since its timestamp becomes newer than
that of other build artifacts, additional processing is invoked,
which is annoying.

- syncconfig is invoked to update include/config/auto.conf, etc.

- kernel/configs.o is recompiled if CONFIG_IKCONFIG is enabled,
  then vmlinux is relinked as well.

If the .config is not changed at all, we do not have to even
touch it. Just bail out showing "No change to .config".

  $ make allmodconfig
  config/conf  --allmodconfig Kconfig
  #
  # configuration written to .config
  #
  $ make allmodconfig
  config/conf  --allmodconfig Kconfig
  #
  # No change to .config
  #

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: do not accept a directory for configuration output
Masahiro Yamada [Fri, 10 May 2019 06:12:04 +0000 (15:12 +0900)]
kconfig: do not accept a directory for configuration output

Currently, conf_write() can be called with a directory name instead
of a file name. As far as I see, this can happen for menuconfig,
nconfig, gconfig.

If it is given with a directory path, conf_write() kindly appends
getenv("KCONFIG_CONFIG"), but this ends up with hacky dir/basename
handling, and screwed up in corner-cases like "what if KCONFIG_CONFIG
is an absolute path?" as discussed before:

  https://patchwork.kernel.org/patch/9910037/

Since conf_write() is already messed up, I'd say "do not do it".
Please pass a file path all the time. If a directory path is specified
for the configuration output, conf_write() will simply error out.

Now that the tmp file is created in the same directory as the .config,
the previously reported "what if KCONFIG_CONFIG points to a different
file system?" has been solved.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Nicolas Porcel <nicolasporcel06@gmail.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokbuild: move ".config not found!" message from Kconfig to Makefile
Masahiro Yamada [Fri, 22 Feb 2019 07:40:11 +0000 (16:40 +0900)]
kbuild: move ".config not found!" message from Kconfig to Makefile

If you run "make" in a pristine source tree, currently Kbuild will
start to build Kconfig to let it show the error message.

It would be more straightforward to check it in Makefile and let
it fail immediately.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: rename zconf.y to parser.y
Masahiro Yamada [Thu, 24 Jan 2019 10:47:30 +0000 (19:47 +0900)]
kconfig: rename zconf.y to parser.y

Use a more logical name.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agokconfig: rename zconf.l to lexer.l
Masahiro Yamada [Thu, 24 Jan 2019 10:47:29 +0000 (19:47 +0900)]
kconfig: rename zconf.l to lexer.l

Use a more logical name.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agocarl9170 toolchain: update to gcc 9.2.0
Christian Lamparter [Sun, 18 Aug 2019 19:17:06 +0000 (21:17 +0200)]
carl9170 toolchain: update to gcc 9.2.0

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
4 years agocarl9170 toolchain: update to gcc 9.1.0
Christian Lamparter [Sun, 5 May 2019 09:17:45 +0000 (11:17 +0200)]
carl9170 toolchain: update to gcc 9.1.0

gcc will now be warning about conflicting alignments
when a pointer from a packed structure is in play.

the include headers will likely need further fixes, but
we can wait until the linux kernel folks know how they
want to deal with ieee80211.h.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agocarl9170: fix printf.c file permission
Christian Lamparter [Mon, 4 Mar 2019 11:50:12 +0000 (12:50 +0100)]
carl9170: fix printf.c file permission

This was set to executable.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agocarl9170 firmware: config: fix missing lkc_proto.h update
Christian Lamparter [Mon, 4 Mar 2019 11:53:02 +0000 (12:53 +0100)]
carl9170 firmware: config: fix missing lkc_proto.h update

Commit: 2396dc74a1e0 ("kconfig: allow all config targets to write auto.conf if missing")
included a hunk for lkc_proto.h that was dropped.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agocarl9170: config: re-add config.cmake
Christian Lamparter [Mon, 4 Mar 2019 11:21:31 +0000 (12:21 +0100)]
carl9170: config: re-add config.cmake

This patch re-adds the custom config.cmake support that was
removed by the cleanup patch.

Reported-by: Jason Self <j@jxself.org>
Fixes: 786134321b6e ("carl9170: config: fix patching errors and update CMakeFiles")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agocarl9170 toolchain: update to gcc 8.3.0
Christian Lamparter [Sun, 24 Feb 2019 20:45:48 +0000 (21:45 +0100)]
carl9170 toolchain: update to gcc 8.3.0

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: remove unused "file" field of yylval union
Masahiro Yamada [Fri, 21 Dec 2018 06:23:02 +0000 (15:23 +0900)]
kconfig: remove unused "file" field of yylval union

This has never been used.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: split the lexer out of zconf.y
Masahiro Yamada [Fri, 21 Dec 2018 08:33:05 +0000 (17:33 +0900)]
kconfig: split the lexer out of zconf.y

Compile zconf.lex.c independently of the other files.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agocarl9170: config: fix patching errors and update CMakeFiles
Christian Lamparter [Sun, 10 Feb 2019 21:53:14 +0000 (22:53 +0100)]
carl9170: config: fix patching errors and update CMakeFiles

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: split some C files out of zconf.y
Masahiro Yamada [Fri, 21 Dec 2018 08:33:04 +0000 (17:33 +0900)]
kconfig: split some C files out of zconf.y

I want to compile each C file independently instead of including all
of them from zconf.y.

Split out confdata.c, expr.c, symbol.c, and preprocess.c .
These are low-hanging fruits.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: convert to SPDX License Identifier
Masahiro Yamada [Tue, 18 Dec 2018 12:13:35 +0000 (21:13 +0900)]
kconfig: convert to SPDX License Identifier

All files in lxdialog/ are licensed under GPL-2.0+, and the rest are
under GPL-2.0. I added GPL-2.0 tags to test scripts in tests/.

Documentation/process/license-rules.rst does not suggest anything
about the flex/bison files. Because flex does not accept the C++
comment style at the very top of a file, I used the C style for
zconf.l, and so for zconf.y for consistency.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: remove keyword lookup table entirely
Masahiro Yamada [Tue, 11 Dec 2018 11:01:10 +0000 (20:01 +0900)]
kconfig: remove keyword lookup table entirely

Commit 7a88488bbc23 ("[PATCH] kconfig: use gperf for kconfig keywords")
introduced gperf for the keyword lookup.

Then, commit bb3290d91695 ("Remove gperf usage from toolchain") killed
the gperf use. As a result, the linear keyword search was left behind.

If we do not use gperf, there is no reason to have the separate table
of the keywords. Move all keywords back to the lexer.

I also refactored the lexer to remove the COMMAND and PARAM states.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: update current_pos in the second lexer
Masahiro Yamada [Tue, 11 Dec 2018 11:01:09 +0000 (20:01 +0900)]
kconfig: update current_pos in the second lexer

To simplify the generated lexer, let the hand-made lexer update the
file name and line number for the parser.

I tested this with DEBUG_PARSE, and confirmed the same file names
and line numbers were dumped.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: switch to ASSIGN_VAL state in the second lexer
Masahiro Yamada [Tue, 11 Dec 2018 11:01:08 +0000 (20:01 +0900)]
kconfig: switch to ASSIGN_VAL state in the second lexer

To simplify the generated lexer, switch to the ASSIGN_VAL state in
the hand-made lexer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: stop associating kconf_id with yylval
Masahiro Yamada [Tue, 11 Dec 2018 11:01:07 +0000 (20:01 +0900)]
kconfig: stop associating kconf_id with yylval

The lexer has conventionally associated kconf_id data with yylval
to carry additional information to the parser.

No token is relying on this any more.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: refactor end token rules
Masahiro Yamada [Tue, 11 Dec 2018 11:01:06 +0000 (20:01 +0900)]
kconfig: refactor end token rules

T_ENDMENU, T_ENDCHOICE, T_ENDIF are the last users of kconf_id
associated with yylval. Refactor them to not use it.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: stop supporting '.' and '/' in unquoted words
Masahiro Yamada [Tue, 11 Dec 2018 11:01:05 +0000 (20:01 +0900)]
kconfig: stop supporting '.' and '/' in unquoted words

In my understanding, special characters such as '.' and '/' are
supported in unquoted words to use bare file paths in the "source"
statement.

With the previous commit surrounding all file paths with double
quotes, we can drop this.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: use T_WORD instead of T_VARIABLE for variables
Masahiro Yamada [Tue, 11 Dec 2018 11:01:02 +0000 (20:01 +0900)]
kconfig: use T_WORD instead of T_VARIABLE for variables

There is no grammatical ambiguity by using T_WORD for variables.
The parser can distinguish variables from symbols from the context.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: use specific tokens instead of T_ASSIGN for assignments
Masahiro Yamada [Tue, 11 Dec 2018 11:01:01 +0000 (20:01 +0900)]
kconfig: use specific tokens instead of T_ASSIGN for assignments

Currently, the lexer returns T_ASSIGN for all of =, :=, and +=
associating yylval with the flavor.

I want to make the generated lexer as simple as possible. So, the
lexer should convert keywords to tokens without thinking about the
meaning.

   =  ->  T_EQUAL
  :=  ->  T_COLON_EQUAL
  +=  ->  T_PLUS_EQUAL

Unfortunately, Kconfig uses = instead of == for the equal operator.
So, the same token T_EQUAL is used for assignment and comparison.
The parser can still distinguish them from the context.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: refactor scanning and parsing "option" properties
Masahiro Yamada [Tue, 11 Dec 2018 11:01:00 +0000 (20:01 +0900)]
kconfig: refactor scanning and parsing "option" properties

For the keywords "modules", "defconfig_list", and "allnoconfig_y",
the lexer should pass specific tokens instead of generic T_WORD.

This simplifies both the lexer and the parser.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years agokconfig: use distinct tokens for type and default properties
Masahiro Yamada [Tue, 11 Dec 2018 11:00:59 +0000 (20:00 +0900)]
kconfig: use distinct tokens for type and default properties

This commit removes kconf_id::stype to prepare for the entire
removal of kconf_id.c

To simplify the lexer, I want keywords straight-mapped to tokens.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>