From: Jaewan Kim <jaewan@google.com>
To: gregkh@linuxfoundation.org, johannes@sipsolutions.net,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Cc: kernel-team@android.com, adelva@google.com,
Jaewan Kim <jaewan@google.com>
Subject: [PATCH v7 3/4] mac80211_hwsim: add PMSR abort support via virtio
Date: Tue, 7 Feb 2023 08:53:59 +0000 [thread overview]
Message-ID: <20230207085400.2232544-4-jaewan@google.com> (raw)
In-Reply-To: <20230207085400.2232544-1-jaewan@google.com>
PMSR (a.k.a. peer measurement) is generalized measurement between two
devices with Wi-Fi support. And currently FTM (a.k.a. fine time
measurement or flight time measurement) is the one and only measurement.
This change allows mac80211_hwsim to abort previous PMSR request. The
abortion request is sent to the wmedium where the PMSR request is
actually handled.
This change adds HWSIM_CMD_ABORT_PMSR. When mac80211_hwsim receives the
PMSR abortion request via ieee80211_ops.abort_pmsr, the received
cfg80211_pmsr_request is resent to the wmediumd with command
HWSIM_CMD_ABORT_PMSR and attribute HWSIM_ATTR_PMSR_REQUEST. The
attribute is formatted as the same way as nl80211_pmsr_start() expects.
Signed-off-by: Jaewan Kim <jaewan@google.com>
---
V1: Initial commit (split from previously large patch)
---
drivers/net/wireless/mac80211_hwsim.c | 61 +++++++++++++++++++++++++++
drivers/net/wireless/mac80211_hwsim.h | 2 +
2 files changed, 63 insertions(+)
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 331772ff5d45..874c768e73e7 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3343,6 +3343,66 @@ static int mac80211_hwsim_start_pmsr(struct ieee80211_hw *hw,
return err;
}
+static void mac80211_hwsim_abort_pmsr(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct cfg80211_pmsr_request *request)
+{
+ struct mac80211_hwsim_data *data = hw->priv;
+ u32 _portid = READ_ONCE(data->wmediumd);
+ struct sk_buff *skb = NULL;
+ int err = 0;
+ void *msg_head;
+ struct nlattr *pmsr;
+
+ if (!_portid && !hwsim_virtio_enabled)
+ return;
+
+ mutex_lock(&data->mutex);
+
+ if (data->pmsr_request != request) {
+ err = -EINVAL;
+ goto out_err;
+ }
+
+ if (err)
+ return;
+
+ skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!skb)
+ return;
+
+ msg_head = genlmsg_put(skb, 0, 0, &hwsim_genl_family, 0, HWSIM_CMD_ABORT_PMSR);
+
+ if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, ETH_ALEN, data->addresses[1].addr))
+ goto out_err;
+
+ pmsr = nla_nest_start(skb, HWSIM_ATTR_PMSR_REQUEST);
+ if (!pmsr) {
+ err = -ENOMEM;
+ goto out_err;
+ }
+
+ err = mac80211_hwsim_send_pmsr_request(skb, request);
+ if (err)
+ goto out_err;
+
+ err = nla_nest_end(skb, pmsr);
+ if (err)
+ goto out_err;
+
+ genlmsg_end(skb, msg_head);
+ if (hwsim_virtio_enabled)
+ hwsim_tx_virtio(data, skb);
+ else
+ hwsim_unicast_netgroup(data, skb, _portid);
+
+out_err:
+ if (err && skb)
+ nlmsg_free(skb);
+
+ mutex_unlock(&data->mutex);
+}
+
#define HWSIM_COMMON_OPS \
.tx = mac80211_hwsim_tx, \
.wake_tx_queue = ieee80211_handle_wake_tx_queue, \
@@ -3367,6 +3427,7 @@ static int mac80211_hwsim_start_pmsr(struct ieee80211_hw *hw,
.get_et_stats = mac80211_hwsim_get_et_stats, \
.get_et_strings = mac80211_hwsim_get_et_strings, \
.start_pmsr = mac80211_hwsim_start_pmsr, \
+ .abort_pmsr = mac80211_hwsim_abort_pmsr,
#define HWSIM_NON_MLO_OPS \
.sta_add = mac80211_hwsim_sta_add, \
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h
index 4af237cef904..39911cc9533d 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -82,6 +82,7 @@ enum hwsim_tx_control_flags {
* @HWSIM_CMD_DEL_MAC_ADDR: remove the MAC address again, the attributes
* are the same as to @HWSIM_CMD_ADD_MAC_ADDR.
* @HWSIM_CMD_START_PMSR: start PMSR
+ * @HWSIM_CMD_ABORT_PMSR: abort PMSR
* @__HWSIM_CMD_MAX: enum limit
*/
enum {
@@ -95,6 +96,7 @@ enum {
HWSIM_CMD_ADD_MAC_ADDR,
HWSIM_CMD_DEL_MAC_ADDR,
HWSIM_CMD_START_PMSR,
+ HWSIM_CMD_ABORT_PMSR,
__HWSIM_CMD_MAX,
};
#define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
--
2.39.1.519.gcb327c4b5f-goog
next prev parent reply other threads:[~2023-02-07 8:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 8:53 [PATCH v7 0/4] mac80211_hwsim: Add PMSR support Jaewan Kim
2023-02-07 8:53 ` [PATCH v7 1/4] mac80211_hwsim: add PMSR capability support Jaewan Kim
2023-02-07 9:08 ` Greg KH
2023-02-07 9:12 ` Greg KH
2023-02-15 18:01 ` Johannes Berg
2023-02-17 5:11 ` Jaewan Kim
2023-02-17 7:43 ` Greg KH
2023-02-17 9:13 ` Johannes Berg
2023-02-17 9:31 ` Greg KH
2023-02-17 9:34 ` Johannes Berg
2023-02-17 9:41 ` Greg KH
2023-02-17 9:19 ` Johannes Berg
2023-02-07 8:53 ` [PATCH v7 2/4] mac80211_hwsim: add PMSR request support via virtio Jaewan Kim
2023-02-15 18:07 ` Johannes Berg
2023-02-23 15:38 ` Jaewan Kim
2023-02-28 15:06 ` Johannes Berg
2023-02-07 8:53 ` Jaewan Kim [this message]
2023-02-07 8:54 ` [PATCH v7 4/4] mac80211_hwsim: add PMSR report " Jaewan Kim
2023-02-15 18:13 ` Johannes Berg
2023-02-07 9:06 ` [PATCH v7 0/4] mac80211_hwsim: Add PMSR support Greg KH
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=20230207085400.2232544-4-jaewan@google.com \
--to=jaewan@google.com \
--cc=adelva@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes@sipsolutions.net \
--cc=kernel-team@android.com \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).