cfg80211: reg: Reset to upstream

Reset net/wireless to upstream commit 460f3fd8a4 ("Merge
android11-5.4.61+ (d240b69) into msm-5.4"). This change re-introduces
removal of support for built-in regdb by commit 7478b98826 ("Revert
"cfg80211: reg: remove support for built-in regdb"").

Change-Id: Id6e87eb589d246448e005d0daed1edd57473e880
Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
This commit is contained in:
Siddharth Gupta 2020-10-16 18:47:40 -07:00
parent 508a6c80d7
commit 1362ad85e2
8 changed files with 4 additions and 1793 deletions

View File

@ -200,23 +200,5 @@ Then in some part of your code after your wiphy has been registered:
Statically compiled regulatory database
---------------------------------------
In most situations the userland solution using CRDA as described
above is the preferred solution. However in some cases a set of
rules built into the kernel itself may be desirable. To account
for this situation, a configuration option has been provided
(i.e. CONFIG_CFG80211_INTERNAL_REGDB). With this option enabled,
the wireless database information contained in net/wireless/db.txt is
used to generate a data structure encoded in net/wireless/regdb.c.
That option also enables code in net/wireless/reg.c which queries
the data in regdb.c as an alternative to using CRDA.
The file net/wireless/db.txt should be kept up-to-date with the db.txt
file available in the git repository here:
git://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git
Again, most users in most situations should be using the CRDA package
provided with their distribution, and in most other situations users
should be building and using CRDA on their own rather than using
this option. If you are not absolutely sure that you should be using
CONFIG_CFG80211_INTERNAL_REGDB then _DO_NOT_USE_IT_.
When a database should be fixed into the kernel, it can be provided as a
firmware file at build time that is then linked into the kernel.

View File

@ -1,3 +1,2 @@
regdb.c
shipped-certs.c
extra-certs.c

View File

@ -176,30 +176,8 @@ config CFG80211_DEBUGFS
If unsure, say N.
config CFG80211_INTERNAL_REGDB
bool "use statically compiled regulatory rules database" if EXPERT
default n
depends on CFG80211
help
This option generates an internal data structure representing
the wireless regulatory rules described in net/wireless/db.txt
and includes code to query that database. This is an alternative
to using CRDA for defining regulatory rules for the kernel.
Using this option requires some parsing of the db.txt at build time,
the parser will be upkept with the latest wireless-regdb updates but
older wireless-regdb formats will be ignored. The parser may later
be replaced to avoid issues with conflicts on versions of
wireless-regdb.
For details see:
http://wireless.kernel.org/en/developers/Regulatory
Most distributions have a CRDA package. So if unsure, say N.
config CFG80211_CRDA_SUPPORT
bool "support CRDA" if CFG80211_INTERNAL_REGDB
bool "support CRDA" if EXPERT
default y
help
You should enable this option unless you know for sure you have no

View File

@ -16,16 +16,9 @@ cfg80211-y += pmsr.o
cfg80211-$(CONFIG_OF) += of.o
cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o
cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o
cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o
CFLAGS_trace.o := -I$(src)
clean-files += shipped-certs.c extra-certs.c
$(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk
@$(AWK) -f $(srctree)/$(src)/genregdb.awk < $< > $@
clean-files := regdb.c
cfg80211-$(CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS) += shipped-certs.o
ifneq ($(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR),)
cfg80211-y += extra-certs.o
@ -64,3 +57,4 @@ $(obj)/extra-certs.c: $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR:"%"=%) \
echo 'unsigned int extra_regdb_certs_len = sizeof(extra_regdb_certs);'; \
) > $@)
clean-files += shipped-certs.c extra-certs.c

File diff suppressed because it is too large Load Diff

View File

@ -1,147 +0,0 @@
#!/usr/bin/awk -f
# SPDX-License-Identifier: ISC
#
# genregdb.awk -- generate regdb.c from db.txt
#
# Actually, it reads from stdin (presumed to be db.txt) and writes
# to stdout (presumed to be regdb.c), but close enough...
#
# Copyright 2009 John W. Linville <linville@tuxdriver.com>
BEGIN {
active = 0
rules = 0;
print "/*"
print " * DO NOT EDIT -- file generated from data in db.txt"
print " */"
print ""
print "#include <linux/nl80211.h>"
print "#include <net/cfg80211.h>"
print "#include \"regdb.h\""
print ""
regdb = "const struct ieee80211_regdomain *reg_regdb[] = {\n"
}
function parse_country_head() {
country=$2
sub(/:/, "", country)
printf "static const struct ieee80211_regdomain regdom_%s = {\n", country
printf "\t.alpha2 = \"%s\",\n", country
if ($NF ~ /DFS-ETSI/)
printf "\t.dfs_region = NL80211_DFS_ETSI,\n"
else if ($NF ~ /DFS-FCC/)
printf "\t.dfs_region = NL80211_DFS_FCC,\n"
else if ($NF ~ /DFS-JP/)
printf "\t.dfs_region = NL80211_DFS_JP,\n"
printf "\t.reg_rules = {\n"
active = 1
regdb = regdb "\t&regdom_" country ",\n"
}
function parse_reg_rule()
{
flag_starts_at = 7
start = $1
sub(/\(/, "", start)
end = $3
bw = $5
sub(/\),/, "", bw)
gain = 0
power = $6
# power might be in mW...
units = $7
dfs_cac = 0
sub(/\(/, "", power)
sub(/\),/, "", power)
sub(/\),/, "", units)
sub(/\)/, "", units)
if (units == "mW") {
flag_starts_at = 8
power = 10 * log(power)/log(10)
if ($8 ~ /[[:digit:]]/) {
flag_starts_at = 9
dfs_cac = $8
}
} else {
if ($7 ~ /[[:digit:]]/) {
flag_starts_at = 8
dfs_cac = $7
}
}
sub(/\(/, "", dfs_cac)
sub(/\),/, "", dfs_cac)
flagstr = ""
for (i=flag_starts_at; i<=NF; i++)
flagstr = flagstr $i
split(flagstr, flagarray, ",")
flags = ""
for (arg in flagarray) {
if (flagarray[arg] == "NO-OFDM") {
flags = flags "\n\t\t\tNL80211_RRF_NO_OFDM | "
} else if (flagarray[arg] == "NO-CCK") {
flags = flags "\n\t\t\tNL80211_RRF_NO_CCK | "
} else if (flagarray[arg] == "NO-INDOOR") {
flags = flags "\n\t\t\tNL80211_RRF_NO_INDOOR | "
} else if (flagarray[arg] == "NO-OUTDOOR") {
flags = flags "\n\t\t\tNL80211_RRF_NO_OUTDOOR | "
} else if (flagarray[arg] == "DFS") {
flags = flags "\n\t\t\tNL80211_RRF_DFS | "
} else if (flagarray[arg] == "PTP-ONLY") {
flags = flags "\n\t\t\tNL80211_RRF_PTP_ONLY | "
} else if (flagarray[arg] == "PTMP-ONLY") {
flags = flags "\n\t\t\tNL80211_RRF_PTMP_ONLY | "
} else if (flagarray[arg] == "PASSIVE-SCAN") {
flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
} else if (flagarray[arg] == "NO-IBSS") {
flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
} else if (flagarray[arg] == "NO-IR") {
flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
} else if (flagarray[arg] == "AUTO-BW") {
flags = flags "\n\t\t\tNL80211_RRF_AUTO_BW | "
}
}
flags = flags "0"
printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %.0f, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
rules++
}
function print_tail_country()
{
active = 0
printf "\t},\n"
printf "\t.n_reg_rules = %d\n", rules
printf "};\n\n"
rules = 0;
}
/^[ \t]*#/ {
# Ignore
}
!active && /^[ \t]*$/ {
# Ignore
}
!active && /country/ {
parse_country_head()
}
active && /^[ \t]*\(/ {
parse_reg_rule()
}
active && /^[ \t]*$/ {
print_tail_country()
}
END {
if (active)
print_tail_country()
print regdb "};"
print ""
print "int reg_regdb_size = ARRAY_SIZE(reg_regdb);"
}

View File

@ -61,7 +61,6 @@
#include "core.h"
#include "reg.h"
#include "rdev-ops.h"
#include "regdb.h"
#include "nl80211.h"
/*
@ -504,38 +503,6 @@ static int reg_schedule_apply(const struct ieee80211_regdomain *regdom)
return 0;
}
#ifdef CONFIG_CFG80211_INTERNAL_REGDB
static int reg_query_builtin(const char *alpha2)
{
const struct ieee80211_regdomain *regdom = NULL;
unsigned int i;
for (i = 0; i < reg_regdb_size; i++) {
if (alpha2_equal(alpha2, reg_regdb[i]->alpha2)) {
regdom = reg_copy_regd(reg_regdb[i]);
break;
}
}
if (!regdom)
return -ENODATA;
return reg_schedule_apply(regdom);
}
/* Feel free to add any other sanity checks here */
static void reg_regdb_size_check(void)
{
/* We should ideally BUILD_BUG_ON() but then random builds would fail */
WARN_ONCE(!reg_regdb_size, "db.txt is empty, you should update it...");
}
#else
static inline void reg_regdb_size_check(void) {}
static inline int reg_query_builtin(const char *alpha2)
{
return -ENODATA;
}
#endif /* CONFIG_CFG80211_INTERNAL_REGDB */
#ifdef CONFIG_CFG80211_CRDA_SUPPORT
/* Max number of consecutive attempts to communicate with CRDA */
#define REG_MAX_CRDA_TIMEOUTS 10
@ -1141,10 +1108,6 @@ int reg_reload_regdb(void)
static bool reg_query_database(struct regulatory_request *request)
{
/* query internal regulatory database (if it exists) */
if (reg_query_builtin(request->alpha2) == 0)
return true;
if (query_regdb_file(request->alpha2) == 0)
return true;
@ -4043,8 +4006,6 @@ int __init regulatory_init(void)
spin_lock_init(&reg_pending_beacons_lock);
spin_lock_init(&reg_indoor_lock);
reg_regdb_size_check();
rcu_assign_pointer(cfg80211_regdomain, cfg80211_world_regdom);
user_alpha2[0] = '9';

View File

@ -1,11 +0,0 @@
/* SPDX-License-Identifier: ISC */
/* Copyright 2009 John W. Linville <linville@tuxdriver.com>
*/
#ifndef __REGDB_H__
#define __REGDB_H__
extern const struct ieee80211_regdomain *reg_regdb[];
extern int reg_regdb_size;
#endif /* __REGDB_H__ */