]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mac80211_hwsim: add PMSR abort support via virtio
authorJaewan Kim <jaewan@google.com>
Wed, 22 Mar 2023 13:16:36 +0000 (13:16 +0000)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 Mar 2023 10:46:11 +0000 (11:46 +0100)
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.

Add necessary functionalities for mac80211_hwsim to abort previous PMSR
request. The abortion request is sent to the wmedium where the PMSR request
is actually handled.

In detail, add new mac80211_hwsim command 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>
Link: https://lore.kernel.org/r/20230322131637.2633968-5-jaewan@google.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/virtual/mac80211_hwsim.c
drivers/net/wireless/virtual/mac80211_hwsim.h

index c7cb4f66a16854a368987128daf7fb9c6b4ad888..f04fb92dde2e4e3ec07108cbc3825bef1a03c857 100644 (file)
@@ -3377,6 +3377,67 @@ out_free:
        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;
+       struct sk_buff *skb = NULL;
+       struct nlattr *pmsr;
+       void *msg_head;
+       u32 _portid;
+       int err = 0;
+
+       data = hw->priv;
+       _portid = READ_ONCE(data->wmediumd);
+       if (!_portid && !hwsim_virtio_enabled)
+               return;
+
+       mutex_lock(&data->mutex);
+
+       if (data->pmsr_request != request) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
+       if (!skb) {
+               err = -ENOMEM;
+               goto out;
+       }
+
+       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;
+
+       pmsr = nla_nest_start(skb, HWSIM_ATTR_PMSR_REQUEST);
+       if (!pmsr) {
+               err = -ENOMEM;
+               goto out;
+       }
+
+       err = mac80211_hwsim_send_pmsr_request(skb, request);
+       if (err)
+               goto out;
+
+       err = nla_nest_end(skb, pmsr);
+       if (err)
+               goto out;
+
+       genlmsg_end(skb, msg_head);
+       if (hwsim_virtio_enabled)
+               hwsim_tx_virtio(data, skb);
+       else
+               hwsim_unicast_netgroup(data, skb, _portid);
+
+out:
+       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,        \
@@ -3401,6 +3462,7 @@ out_free:
        .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,                      \
index 98e586a56582e4592ab656a9dedcc6632bce9cde..383f3e39c911759c278e124e485a8a3959e571e0 100644 (file)
@@ -83,6 +83,7 @@ enum hwsim_tx_control_flags {
  *     are the same as to @HWSIM_CMD_ADD_MAC_ADDR.
  * @HWSIM_CMD_START_PMSR: request to start peer measurement with the
  *     %HWSIM_ATTR_PMSR_REQUEST.
+ * @HWSIM_CMD_ABORT_PMSR: abort previously sent peer measurement
  * @__HWSIM_CMD_MAX: enum limit
  */
 enum {
@@ -96,6 +97,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)