mac80211: use Kconfig counters to elide unnecessary code

There are many drivers with different behaviour, but in a lot of
systems only a single driver will ever be built. In that case we
can get rid of code paths that this driver doesn't need and also
optimize the ones that it always takes to not have a check.

To make that possible, make use Kconfig counters to
 (a) the number of times each feature flag was desired
 (b) the number of mac80211 drivers built
and use Kconfig selects to select those flags that any drivers
need to be dynamic (e.g. if they can only determine this flag's
setting at runtime.)

If the dynamic request isn't set then

 if (a) > 0 then it was requested ON by at least one driver
 if (a) < (b) then it was requested OFF by at least one driver

This allows determining whether or not it's safe to elide some
code entirely.

For added safety, add a HW registration time check for it.

With our iwlwifi/mvm driver, this reduces mac80211's code size
by just over 6KB (on x86/64), or about 1%. It's not that much,
but a fair amount of it (just under 1KB) is in the TX/RX/status
paths which are the hottest code in mac80211.

Signed-off-by: Johannes Berg <>
27 files changed