Skip to contentSkip to conversation

wiphy: update wiphy_radio_work_is_running to return int

PATCH Superseded James Prestwood 1 participant 2 messages Dec 6, 2021 Kbuild

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH v3 1/2 wiphy: update wiphy_radio_work_is_running to return int

This differentiates between pending, running, and non-existent:
1, 0, -ENOENT respectively

---
 src/wiphy.c | 10 +++++-----
 src/wiphy.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
src/wiphy.c +5 -5
index bb1f9824..219a3695 100644
@@ -2013,14 +2013,14 @@ void wiphy_radio_work_done(struct wiphy *wiphy, uint32_t id)
 		wiphy_radio_work_next(wiphy);
 }
 
-bool wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id)
+int wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id)
 {
-	struct wiphy_radio_work_item *item = l_queue_peek_head(wiphy->work);
-
+	struct wiphy_radio_work_item *item = l_queue_find(wiphy->work, match_id,
+							L_UINT_TO_PTR(id));
 	if (!item)
-		return false;
+		return -ENOENT;
 
-	return item->id == id;
+	return item == l_queue_peek_head(wiphy->work) ? 0 : 1;
 }
 
 static int wiphy_init(void)
src/wiphy.h +1 -1
index 9f0d6d07..592eba70 100644
@@ -130,4 +130,4 @@ uint32_t wiphy_radio_work_insert(struct wiphy *wiphy,
 				int priority,
 				const struct wiphy_radio_work_item_ops *ops);
 void wiphy_radio_work_done(struct wiphy *wiphy, uint32_t id);
-bool wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id);
+int wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id);
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v3 2/2 offchannel: introduce new offchannel module

This module provides a convenient wrapper around both CMD_[CANCEL_]_REMAIN_ON_CHANNEL APIs.

Certain protocols require going offchannel to send frames, and/or wait for a response. The frame-xchg module somewhat does this but has some limitations. For example you cannot just go offchannel; an initial frame must be sent out to start the procedure. In addition frame-xchg does not work for broadcasts since it expects an ACK.

This module is much simpler and only handles going offchannel for a duration. During this time frames may be sent or received. After the duration the caller will get a callback and any included error if there was one. Any offchannel request can be cancelled prior to the duration expriring if the offchannel work has finished early.

---
 Makefile.am      |   1 +
 src/offchannel.c | 314 +++++++++++++++++++++++++++++++++++++++++++++++
 src/offchannel.h |  29 +++++
 3 files changed, 344 insertions(+)
 create mode 100644 src/offchannel.c
 create mode 100644 src/offchannel.h

v3:
* wait until cancel ROC event before calling done on work in cases where ROC has started
* Fixed nl80211 cancel logic to only cancel if the command has not yet left the genl queue, not unconditionally

Makefile.am +1 -0
index 1e1c230f..d93dd2c9 100644
@@ -247,6 +247,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h src/missing.h \
 					src/ip-pool.h src/ip-pool.c \
 					src/band.h src/band.c \
 					src/sysfs.h src/sysfs.c \
+					src/offchannel.h src/offchannel.c \
 					$(eap_sources) \
 					$(builtin_sources)
 
src/offchannel.c new file +314 -0

314 lines not on this page · raw message

src/offchannel.h new file +29 -0
new file mode 100644
index 00000000..1ffa94f1
@@ -0,0 +1,29 @@
+/*
+ *
+ *  Wireless daemon for Linux
+ *
+ *  Copyright (C) 2021  Intel Corporation. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+typedef void (*offchannel_started_cb_t)(void *user_data);
+typedef void (*offchannel_destroy_cb_t)(int error, void *user_data);
+
+uint32_t offchannel_start(uint64_t wdev_id, uint32_t freq, uint32_t duration,
+			offchannel_started_cb_t started, void *user_data,
+			offchannel_destroy_cb_t destroy);
+void offchannel_cancel(uint64_t wdev_id, uint32_t id);
Signature · 1 line
2.31.1