All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH v3 1/3] scan: parse the scan start time
Date: Thu, 21 Nov 2019 09:28:42 -0800	[thread overview]
Message-ID: <20191121172844.16796-1-prestwoj@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2910 bytes --]

The kernel sends NL80211_ATTR_SCAN_START_TIME_TSF with CMD_TRIGGER and
RRM requires this value for beacon measurement reports.

The start time is parsed during CMD_TRIGGER and set into the scan context.
A getter was added to obtain this time value for an already triggered
scan.
---
 src/scan.c | 31 +++++++++++++++++++++++++++++++
 src/scan.h |  2 ++
 2 files changed, 33 insertions(+)

-v3:
 * Added getter for scan triggered time rather than storing it in each
   bss individually.

diff --git a/src/scan.c b/src/scan.c
index e007ce5d..43e4cb84 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -91,6 +91,9 @@ struct scan_context {
 	unsigned int start_cmd_id;
 	/* Non-zero if GET_SCAN is still running */
 	unsigned int get_scan_cmd_id;
+
+	/* The time the current scan was started. Reported in TRIGGER_SCAN */
+	uint64_t start_time_tsf;
 	/*
 	 * Whether the top request in the queue has triggered the current
 	 * scan.  May be set and cleared multiple times during a single
@@ -778,6 +781,25 @@ bool scan_periodic_stop(uint64_t wdev_id)
 	return true;
 }
 
+uint64_t scan_get_triggered_time(uint64_t wdev_id, uint32_t id)
+{
+	struct scan_context *sc;
+	struct scan_request *sr;
+
+	sc = l_queue_find(scan_contexts, scan_context_match, &wdev_id);
+	if (!sc)
+		return 0;
+
+	sr = l_queue_find(sc->requests, scan_request_match, L_UINT_TO_PTR(id));
+	if (!sr)
+		return 0;
+
+	if (!sc->triggered)
+		return 0;
+
+	return sc->start_time_tsf;
+}
+
 static void scan_periodic_timeout(struct l_timeout *timeout, void *user_data)
 {
 	struct scan_context *sc = user_data;
@@ -1439,6 +1461,7 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data)
 	uint32_t wiphy_id;
 	struct scan_context *sc;
 	bool active_scan = false;
+	uint64_t start_time_tsf = 0;
 
 	cmd = l_genl_msg_get_command(msg);
 
@@ -1461,6 +1484,12 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data)
 		case NL80211_ATTR_SCAN_SSIDS:
 			active_scan = true;
 			break;
+		case NL80211_ATTR_SCAN_START_TIME_TSF:
+			if (len != sizeof(uint64_t))
+				return;
+
+			start_time_tsf = l_get_u64(data);
+			break;
 		}
 	}
 
@@ -1543,6 +1572,8 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data)
 		else
 			sc->state = SCAN_STATE_PASSIVE;
 
+		sc->start_time_tsf = start_time_tsf;
+
 		break;
 
 	case NL80211_CMD_SCAN_ABORTED:
diff --git a/src/scan.h b/src/scan.h
index 8fc2aa56..b6c4e12d 100644
--- a/src/scan.h
+++ b/src/scan.h
@@ -124,6 +124,8 @@ void scan_periodic_start(uint64_t wdev_id, scan_trigger_func_t trigger,
 				scan_notify_func_t func, void *userdata);
 bool scan_periodic_stop(uint64_t wdev_id);
 
+uint64_t scan_get_triggered_time(uint64_t wdev_id, uint32_t id);
+
 void scan_bss_free(struct scan_bss *bss);
 int scan_bss_rank_compare(const void *a, const void *b, void *user);
 
-- 
2.17.1

             reply	other threads:[~2019-11-21 17:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21 17:28 James Prestwood [this message]
2019-11-21 17:28 ` [PATCH v3 2/3] rrm: include actual scan start time in report James Prestwood
2019-11-21 17:28 ` [PATCH v3 3/3] rrm: add packed struct for beacon reports James Prestwood

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=20191121172844.16796-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /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.