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

Commit d2c2bb9f authored by Luciano Coelho's avatar Luciano Coelho
Browse files

wl12xx: split channel array per band in sched_scan



The firmware, in practice, treats the channels in three separate
blocks, one for each band (bg, a and j).  Instead of using a single
array and doing some magic with indices, split the array in 3 to make
it more readable.

Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent d192d268
Loading
Loading
Loading
Loading
+29 −32
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
				    struct cfg80211_sched_scan_request *req,
				    struct conn_scan_ch_params *channels,
				    u32 band, bool radar, bool passive,
				    int start)
				    int start, int max_channels)
{
	struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
	int i, j;
@@ -334,7 +334,7 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
	bool force_passive = !req->n_ssids;

	for (i = 0, j = start;
	     i < req->n_channels && j < MAX_CHANNELS_ALL_BANDS;
	     i < req->n_channels && j < max_channels;
	     i++) {
		flags = req->channels[i]->flags;

@@ -380,46 +380,42 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
	return j - start;
}

static int
static bool
wl1271_scan_sched_scan_channels(struct wl1271 *wl,
				struct cfg80211_sched_scan_request *req,
				struct wl1271_cmd_sched_scan_config *cfg)
{
	int idx = 0;

	cfg->passive[0] =
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
						    IEEE80211_BAND_2GHZ,
						    false, true, idx);
	idx += cfg->passive[0];

						    false, true, 0,
						    MAX_CHANNELS_2GHZ);
	cfg->active[0] =
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
						    IEEE80211_BAND_2GHZ,
						    false, false, idx);
	/*
	 * 5GHz channels always start at position 14, not immediately
	 * after the last 2.4GHz channel
	 */
	idx = 14;

						    false, false,
						    cfg->passive[0],
						    MAX_CHANNELS_2GHZ);
	cfg->passive[1] =
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
						    IEEE80211_BAND_5GHZ,
						    false, true, idx);
	idx += cfg->passive[1];

						    false, true, 0,
						    MAX_CHANNELS_5GHZ);
	cfg->dfs =
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
						    IEEE80211_BAND_5GHZ,
						    true, true, idx);
	idx += cfg->dfs;

						    true, true,
						    cfg->passive[1],
						    MAX_CHANNELS_5GHZ);
	cfg->active[1] =
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
		wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
						    IEEE80211_BAND_5GHZ,
						    false, false, idx);
	idx += cfg->active[1];
						    false, false,
						    cfg->passive[1] + cfg->dfs,
						    MAX_CHANNELS_5GHZ);
	/* 802.11j channels are not supported yet */
	cfg->passive[2] = 0;
	cfg->active[2] = 0;

	wl1271_debug(DEBUG_SCAN, "    2.4GHz: active %d passive %d",
		     cfg->active[0], cfg->passive[0]);
@@ -427,7 +423,9 @@ wl1271_scan_sched_scan_channels(struct wl1271 *wl,
		     cfg->active[1], cfg->passive[1]);
	wl1271_debug(DEBUG_SCAN, "    DFS: %d", cfg->dfs);

	return idx;
	return  cfg->passive[0] || cfg->active[0] ||
		cfg->passive[1] || cfg->active[1] || cfg->dfs ||
		cfg->passive[2] || cfg->active[2];
}

int wl1271_scan_sched_scan_config(struct wl1271 *wl,
@@ -436,7 +434,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl,
{
	struct wl1271_cmd_sched_scan_config *cfg = NULL;
	struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
	int i, total_channels, ret;
	int i, ret;
	bool force_passive = !req->n_ssids;

	wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
@@ -471,8 +469,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl,
		cfg->ssid_len = 0;
	}

	total_channels = wl1271_scan_sched_scan_channels(wl, req, cfg);
	if (total_channels == 0) {
	if (!wl1271_scan_sched_scan_channels(wl, req, cfg)) {
		wl1271_error("scan channel list is empty");
		ret = -EINVAL;
		goto out;
+7 −10
Original line number Diff line number Diff line
@@ -112,18 +112,13 @@ struct wl1271_cmd_trigger_scan_to {
	__le32 timeout;
} __packed;

#define MAX_CHANNELS_ALL_BANDS 41
#define MAX_CHANNELS_2GHZ	14
#define MAX_CHANNELS_5GHZ	23
#define MAX_CHANNELS_4GHZ	4

#define SCAN_MAX_CYCLE_INTERVALS 16
#define SCAN_MAX_BANDS 3

enum {
	SCAN_CHANNEL_TYPE_2GHZ_PASSIVE,
	SCAN_CHANNEL_TYPE_2GHZ_ACTIVE,
	SCAN_CHANNEL_TYPE_5GHZ_PASSIVE,
	SCAN_CHANNEL_TYPE_5GHZ_ACTIVE,
	SCAN_CHANNEL_TYPE_5GHZ_DFS,
};

enum {
	SCAN_SSID_FILTER_ANY      = 0,
	SCAN_SSID_FILTER_SPECIFIC = 1,
@@ -182,7 +177,9 @@ struct wl1271_cmd_sched_scan_config {

	u8 padding[3];

	struct conn_scan_ch_params channels[MAX_CHANNELS_ALL_BANDS];
	struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
	struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
	struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
} __packed;