All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: j@w1.fi
Cc: hostap@lists.infradead.org, linux-wireless@vger.kernel.org,
	nbd@nbd.name, ryder.lee@mediatek.com, evelyn.tsai@mediatek.com,
	lorenzo.bianconi@redhat.com
Subject: [PATCH 2/9] DFS: introduce dfs_set_valid_channel utility routine
Date: Mon, 20 Dec 2021 16:48:17 +0100	[thread overview]
Message-ID: <f1a1a91eb7caf87ca5ab0f431da78f774f973b48.1640014128.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1640014128.git.lorenzo@kernel.org>

This is a preliminary patch to introduce radar/CAC background
detection support.

Tested-by: Owen Peng <owen.peng@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 src/ap/dfs.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index 5c99ecfd0..a97403756 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -567,6 +567,27 @@ dfs_get_valid_channel(struct hostapd_iface *iface,
 	return chan;
 }
 
+static int dfs_set_valid_channel(struct hostapd_iface *iface, int skip_radar)
+{
+	struct hostapd_channel_data *channel;
+	u8 cf1 = 0, cf2 = 0;
+	int sec = 0;
+
+	channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
+					skip_radar);
+	if (!channel) {
+		wpa_printf(MSG_ERROR, "could not get valid channel");
+		return -1;
+	}
+
+	iface->freq = channel->freq;
+	iface->conf->channel = channel->chan;
+	iface->conf->secondary_channel = sec;
+	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
+	hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
+
+	return 0;
+}
 
 static int set_dfs_state_freq(struct hostapd_iface *iface, int freq, u32 state)
 {
@@ -755,7 +776,6 @@ static unsigned int dfs_get_cac_time(struct hostapd_iface *iface,
  */
 int hostapd_handle_dfs(struct hostapd_iface *iface)
 {
-	struct hostapd_channel_data *channel;
 	int res, n_chans, n_chans1, start_chan_idx, start_chan_idx1;
 	int skip_radar = 0;
 
@@ -810,22 +830,10 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
 		wpa_printf(MSG_DEBUG, "DFS %d chans unavailable - choose other channel: %s",
 			   res, res ? "yes": "no");
 		if (res) {
-			int sec = 0;
-			u8 cf1 = 0, cf2 = 0;
-
-			channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
-							skip_radar);
-			if (!channel) {
-				wpa_printf(MSG_ERROR, "could not get valid channel");
+			if (dfs_set_valid_channel(iface, skip_radar) < 0) {
 				hostapd_set_state(iface, HAPD_IFACE_DFS);
 				return 0;
 			}
-
-			iface->freq = channel->freq;
-			iface->conf->channel = channel->chan;
-			iface->conf->secondary_channel = sec;
-			hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
-			hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
 		}
 	} while (res);
 
-- 
2.33.1


  parent reply	other threads:[~2021-12-20 15:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 15:48 [PATCH 0/9] introduce background radar detection support Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 1/9] Sync include/uapi/linux/nl80211.h with mac80211-next.git Lorenzo Bianconi
2022-03-03 21:58   ` Jouni Malinen
2021-12-20 15:48 ` Lorenzo Bianconi [this message]
2021-12-20 15:48 ` [PATCH 3/9] DFS: add capability select radar-only channels Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 4/9] nl80211: report background radar/cac detection capability Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 5/9] DFS: configure background radar/cac detection Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 6/9] DFS: introduce hostapd_dfs_request_channel_switch routine Lorenzo Bianconi
2022-03-03 22:54   ` Jouni Malinen
2022-03-04 11:52     ` Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 7/9] DFS: enable CSA for background radar detection Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 8/9] DFS: switch to background radar channel if available Lorenzo Bianconi
2022-03-03 22:20   ` Jouni Malinen
2022-03-04 13:46     ` Lorenzo Bianconi
2021-12-20 15:48 ` [PATCH 9/9] DFS: introduce radar_background parameter to config file Lorenzo Bianconi
2022-03-03 21:56   ` Jouni Malinen
2022-03-04 11:08     ` Lorenzo Bianconi
2022-03-03 23:19 ` [PATCH 0/9] introduce background radar detection support Jouni Malinen
2022-03-04  9:48   ` Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1a1a91eb7caf87ca5ab0f431da78f774f973b48.1640014128.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=evelyn.tsai@mediatek.com \
    --cc=hostap@lists.infradead.org \
    --cc=j@w1.fi \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.