Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75aab666 authored by Dedy Lansky's avatar Dedy Lansky Committed by Lior David
Browse files

wil6210: support FCC board file



Driver already supports China specific board file.
Extend this to support list of countries that follow FCC rules. Upon
reg domain change, use appropriate (default, CN or FCC) board file.

Change-Id: Ia62977fdb1b1da6b985909d7e8dfa239c124e9a0
Signed-off-by: default avatarDedy Lansky <dlansky@codeaurora.org>
Signed-off-by: default avatarLior David <liord@codeaurora.org>
parent c228dd27
Loading
Loading
Loading
Loading
+49 −10
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@
#include "fw.h"

#define WIL_MAX_ROC_DURATION_MS 5000
#define CTRY_CHINA "CN"
#define WIL_BRD_SUFFIX_CN "CN"
#define WIL_BRD_SUFFIX_FCC "FCC"

bool disable_ap_sme;
module_param(disable_ap_sme, bool, 0444);
@@ -53,6 +54,25 @@ static struct ieee80211_channel wil_60ghz_channels[] = {
	CHAN60G(4, 0),
};

struct wil_regd_2_brd_suffix {
	const char regdomain[3]; /* alpha2 */
	const char *brd_suffix;
};

static struct wil_regd_2_brd_suffix wil_regd_2_brd_suffix_map[] = {
	{"BO", WIL_BRD_SUFFIX_FCC},
	{"CN", WIL_BRD_SUFFIX_CN},
	{"EC", WIL_BRD_SUFFIX_FCC},
	{"GU", WIL_BRD_SUFFIX_FCC},
	{"HN", WIL_BRD_SUFFIX_FCC},
	{"JM", WIL_BRD_SUFFIX_FCC},
	{"MX", WIL_BRD_SUFFIX_FCC},
	{"NI", WIL_BRD_SUFFIX_FCC},
	{"PY", WIL_BRD_SUFFIX_FCC},
	{"TT", WIL_BRD_SUFFIX_FCC},
	{"US", WIL_BRD_SUFFIX_FCC},
};

enum wil_nl_60g_cmd_type {
	NL_60G_CMD_FW_WMI,
	NL_60G_CMD_DEBUG,
@@ -2481,24 +2501,43 @@ wil_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
	return 0;
}

static void wil_get_brd_reg_suffix(struct wil6210_priv *wil,
				   const u8 *new_regdomain,
				   char *brd_reg_suffix, size_t len)
{
	int i;
	struct wil_regd_2_brd_suffix *entry;

	for (i = 0; i < ARRAY_SIZE(wil_regd_2_brd_suffix_map); i++) {
		entry = &wil_regd_2_brd_suffix_map[i];
		if (!memcmp(entry->regdomain, new_regdomain, 2)) {
			strlcpy(brd_reg_suffix, entry->brd_suffix, len);
			return;
		}
	}

	/* regdomain not found in our map, set suffix to none */
	brd_reg_suffix[0] = '\0';
}

static int wil_switch_board_file(struct wil6210_priv *wil,
				 const u8 *new_regdomain)
{
	int rc = 0;
	char brd_reg_suffix[WIL_BRD_SUFFIX_LEN];

	if (!country_specific_board_file)
		return 0;

	if (memcmp(wil->regdomain, CTRY_CHINA, 2) == 0) {
		wil_info(wil, "moving out of China reg domain, use default board file\n");
		wil->board_file_country[0] = '\0';
	} else if (memcmp(new_regdomain, CTRY_CHINA, 2) == 0) {
		wil_info(wil, "moving into China reg domain, use country specific board file\n");
		strlcpy(wil->board_file_country, CTRY_CHINA,
			sizeof(wil->board_file_country));
	} else {
	wil_get_brd_reg_suffix(wil, new_regdomain, brd_reg_suffix,
			       sizeof(brd_reg_suffix));
	if (!strcmp(wil->board_file_reg_suffix, brd_reg_suffix))
		return 0;
	}

	wil_info(wil, "switch board file suffix '%s' => '%s'\n",
		 wil->board_file_reg_suffix, brd_reg_suffix);
	strlcpy(wil->board_file_reg_suffix, brd_reg_suffix,
		sizeof(wil->board_file_reg_suffix));

	/* need to switch board file - reset the device */

+4 −4
Original line number Diff line number Diff line
@@ -1182,19 +1182,19 @@ void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len)
			board_file = WIL_BOARD_FILE_NAME;
	}

	if (wil->board_file_country[0] == '\0') {
	if (wil->board_file_reg_suffix[0] == '\0') {
		strlcpy(buf, board_file, len);
		return;
	}

	/* use country specific board file */
	if (len < strlen(board_file) + 4 /* for _XX and terminating null */)
	if (len < strlen(board_file) + 1 + WIL_BRD_SUFFIX_LEN) /* 1 for '_' */
		return;

	ext = strrchr(board_file, '.');
	prefix_len = (ext ? ext - board_file : strlen(board_file));
	snprintf(buf, len, "%.*s_%.2s",
		 prefix_len, board_file, wil->board_file_country);
	snprintf(buf, len, "%.*s_%.3s",
		 prefix_len, board_file, wil->board_file_reg_suffix);
	if (ext)
		strlcat(buf, ext, len);
}
+3 −1
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ union wil_tx_desc;
 */
#define WIL_MAX_VIFS 4

#define WIL_BRD_SUFFIX_LEN 4 /* max 3 letters + terminating null */

/**
 * extract bits [@b0:@b1] (inclusive) from the value @x
 * it should be @b0 <= @b1, or result is incorrect
@@ -905,7 +907,7 @@ struct wil6210_priv {
	const char *hw_name;
	const char *wil_fw_name;
	char *board_file;
	char board_file_country[3]; /* alpha2 */
	char board_file_reg_suffix[WIL_BRD_SUFFIX_LEN]; /* empty or CN or FCC */
	u32 brd_file_addr;
	u32 brd_file_max_size;
	DECLARE_BITMAP(hw_capa, hw_capa_last);