Skip to content

Commit

Permalink
cfg80211: reg: remove support for built-in regdb
Browse files Browse the repository at this point in the history
Parsing and building C structures from a regdb is no longer needed
since the "firmware" file (regulatory.db) can be linked into the
kernel image to achieve the same effect.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Oct 11, 2017
1 parent 1ea4ff3 commit c8c240e
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 287 deletions.
22 changes: 2 additions & 20 deletions Documentation/networking/regulatory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 0 additions & 1 deletion net/wireless/.gitignore

This file was deleted.

24 changes: 1 addition & 23 deletions net/wireless/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,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
depends on CFG80211
help
Expand Down
6 changes: 0 additions & 6 deletions net/wireless/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o ocb.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)

$(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk
@$(AWK) -f $(srctree)/$(src)/genregdb.awk < $< > $@

clean-files := regdb.c
17 changes: 0 additions & 17 deletions net/wireless/db.txt

This file was deleted.

158 changes: 0 additions & 158 deletions net/wireless/genregdb.awk

This file was deleted.

39 changes: 0 additions & 39 deletions net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include "core.h"
#include "reg.h"
#include "rdev-ops.h"
#include "regdb.h"
#include "nl80211.h"

/*
Expand Down Expand Up @@ -495,38 +494,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
Expand Down Expand Up @@ -885,10 +852,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;

Expand Down Expand Up @@ -3580,8 +3543,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';
Expand Down
23 changes: 0 additions & 23 deletions net/wireless/regdb.h

This file was deleted.

0 comments on commit c8c240e

Please sign in to comment.