All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 3/8] netdev: update RSSI polling to use netdev_get_station
Date: Mon, 11 Jan 2021 09:12:34 -0800	[thread overview]
Message-ID: <20210111171239.472372-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20210111171239.472372-1-prestwoj@gmail.com>

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

---
 src/netdev.c | 61 +++++++++-------------------------------------------
 1 file changed, 10 insertions(+), 51 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index 3cda1c48..1e54acec 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -124,7 +124,6 @@ struct netdev {
 	uint8_t cur_rssi_level_idx;
 	int8_t cur_rssi;
 	struct l_timeout *rssi_poll_timeout;
-	uint32_t rssi_poll_cmd_id;
 	uint8_t set_mac_once[6];
 
 	uint32_t set_powered_cmd_id;
@@ -379,47 +378,16 @@ static void netdev_set_rssi_level_idx(struct netdev *netdev)
 	netdev->cur_rssi_level_idx = new_level;
 }
 
-static void netdev_rssi_poll_cb(struct l_genl_msg *msg, void *user_data)
+static void netdev_rssi_poll_cb(struct netdev *netdev,
+				struct netdev_station_info *info,
+				void *user_data)
 {
-	struct netdev *netdev = user_data;
-	struct l_genl_attr attr, nested;
-	uint16_t type, len;
-	const void *data;
-	bool found;
 	uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx;
 
-	netdev->rssi_poll_cmd_id = 0;
-
-	if (!l_genl_attr_init(&attr, msg))
-		goto done;
-
-	found = false;
-	while (l_genl_attr_next(&attr, &type, &len, &data)) {
-		if (type != NL80211_ATTR_STA_INFO)
-			continue;
-
-		found = true;
-		break;
-	}
-
-	if (!found || !l_genl_attr_recurse(&attr, &nested))
+	if (!info)
 		goto done;
 
-	found = false;
-	while (l_genl_attr_next(&nested, &type, &len, &data)) {
-		if (type != NL80211_STA_INFO_SIGNAL_AVG)
-			continue;
-
-		if (len != 1)
-			continue;
-
-		found = true;
-		netdev->cur_rssi = *(const int8_t *) data;
-		break;
-	}
-
-	if (!found)
-		goto done;
+	netdev->cur_rssi =  info->cur_rssi;
 
 	/*
 	 * Note we don't have to handle LOW_SIGNAL_THRESHOLD here.  The
@@ -441,16 +409,12 @@ done:
 static void netdev_rssi_poll(struct l_timeout *timeout, void *user_data)
 {
 	struct netdev *netdev = user_data;
-	struct l_genl_msg *msg;
-
-	msg = l_genl_msg_new_sized(NL80211_CMD_GET_STATION, 64);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
-	l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN,
-							netdev->handshake->aa);
 
-	netdev->rssi_poll_cmd_id = l_genl_family_send(nl80211, msg,
-							netdev_rssi_poll_cb,
-							netdev, NULL);
+	if (netdev_get_station(netdev, netdev->handshake->aa,
+				netdev_rssi_poll_cb, NULL, NULL) < 0) {
+		/* Some problem occurred, rearm timer and try again */
+		l_timeout_modify(netdev->rssi_poll_timeout, 6);
+	}
 }
 
 /* To be called whenever operational or rssi_levels_num are updated */
@@ -472,11 +436,6 @@ static void netdev_rssi_polling_update(struct netdev *netdev)
 
 		l_timeout_remove(netdev->rssi_poll_timeout);
 		netdev->rssi_poll_timeout = NULL;
-
-		if (netdev->rssi_poll_cmd_id) {
-			l_genl_family_cancel(nl80211, netdev->rssi_poll_cmd_id);
-			netdev->rssi_poll_cmd_id = 0;
-		}
 	}
 }
 
-- 
2.26.2

  parent reply	other threads:[~2021-01-11 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 17:12 [PATCH 1/8] doc: diagnostic DBus interface definition James Prestwood
2021-01-11 17:12 ` [PATCH 2/8] netdev: add netdev_get_station James Prestwood
2021-01-11 20:49   ` Denis Kenzior
2021-01-11 20:54     ` James Prestwood
2021-01-11 21:08       ` Denis Kenzior
2021-01-11 17:12 ` James Prestwood [this message]
2021-01-11 17:12 ` [PATCH 4/8] netdev: parse rates in netdev_get_station James Prestwood
2021-01-11 17:12 ` [PATCH 5/8] dbus: add diagnostic interface definition James Prestwood
2021-01-11 20:52   ` Denis Kenzior
2021-01-11 17:12 ` [PATCH 6/8] netdev: parse expected throughput in netdev_get_station James Prestwood
2021-01-11 17:12 ` [PATCH 7/8] station: create StationDiagnostic interface James Prestwood
2021-01-11 21:04   ` Denis Kenzior
2021-01-11 17:12 ` [PATCH 8/8] test: add a script for GetDiagnostics James Prestwood
2021-01-11 20:51 ` [PATCH 1/8] doc: diagnostic DBus interface definition Denis Kenzior

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=20210111171239.472372-3-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.