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

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

---
 src/netdev.c | 59 ++++++++--------------------------------------------
 1 file changed, 9 insertions(+), 50 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index 7777869f..fa31b06a 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_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_current_station(netdev, 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 21:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 21:34 [PATCH v2 1/7] dbus: add helper for appending a dictionary James Prestwood
2021-01-11 21:34 ` [PATCH v2 2/7] netdev: add netdev_get_station/current_station James Prestwood
2021-01-11 21:34 ` James Prestwood [this message]
2021-01-11 21:34 ` [PATCH v2 4/7] netdev: parse rates in netdev_get_station James Prestwood
2021-01-11 21:35 ` [PATCH v2 5/7] netdev: parse expected throughput " James Prestwood
2021-01-11 21:35 ` [PATCH v2 6/7] station: create StationDiagnostic interface James Prestwood
2021-01-11 21:35 ` [PATCH v2 7/7] test: add a script for GetDiagnostics 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=20210111213502.551370-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.