^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2018 - 2019 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __PMSR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define __PMSR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <net/cfg80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "nl80211.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "rdev-ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct nlattr *ftmreq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct cfg80211_pmsr_request_peer *out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct genl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) const struct cfg80211_pmsr_capabilities *capa = rdev->wiphy.pmsr_capa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct nlattr *tb[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) u32 preamble = NL80211_PREAMBLE_DMG; /* only optional in DMG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* validate existing data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) if (!(rdev->wiphy.pmsr_capa->ftm.bandwidths & BIT(out->chandef.width))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) NL_SET_ERR_MSG(info->extack, "FTM: unsupported bandwidth");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* no validation needed - was already done via nested policy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) nla_parse_nested_deprecated(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) if (tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) preamble = nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* set up values - struct is 0-initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) out->ftm.requested = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) switch (out->chandef.chan->band) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) case NL80211_BAND_60GHZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* optional */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (!tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) NL_SET_ERR_MSG(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "FTM: must specify preamble");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (!(capa->ftm.preambles & BIT(preamble))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) "FTM: invalid preamble");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) out->ftm.preamble = preamble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) out->ftm.burst_period = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) out->ftm.burst_period =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) out->ftm.asap = !!tb[NL80211_PMSR_FTM_REQ_ATTR_ASAP];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (out->ftm.asap && !capa->ftm.asap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) tb[NL80211_PMSR_FTM_REQ_ATTR_ASAP],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) "FTM: ASAP mode not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (!out->ftm.asap && !capa->ftm.non_asap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) NL_SET_ERR_MSG(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) "FTM: non-ASAP mode not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) out->ftm.num_bursts_exp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) out->ftm.num_bursts_exp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (capa->ftm.max_bursts_exponent >= 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) out->ftm.num_bursts_exp > capa->ftm.max_bursts_exponent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) "FTM: max NUM_BURSTS_EXP must be set lower than the device limit");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) out->ftm.burst_duration = 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) out->ftm.burst_duration =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) out->ftm.ftms_per_burst = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) out->ftm.ftms_per_burst =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (capa->ftm.max_ftms_per_burst &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) (out->ftm.ftms_per_burst > capa->ftm.max_ftms_per_burst ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) out->ftm.ftms_per_burst == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) "FTM: FTMs per burst must be set lower than the device limit but non-zero");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) out->ftm.ftmr_retries = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_FTMR_RETRIES])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) out->ftm.ftmr_retries =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_FTMR_RETRIES]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) out->ftm.request_lci = !!tb[NL80211_PMSR_FTM_REQ_ATTR_REQUEST_LCI];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (out->ftm.request_lci && !capa->ftm.request_lci) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) tb[NL80211_PMSR_FTM_REQ_ATTR_REQUEST_LCI],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "FTM: LCI request not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) out->ftm.request_civicloc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) !!tb[NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) if (out->ftm.request_civicloc && !capa->ftm.request_civicloc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) tb[NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) "FTM: civic location request not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) out->ftm.trigger_based =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) !!tb[NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (out->ftm.trigger_based && !capa->ftm.trigger_based) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) tb[NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) "FTM: trigger based ranging is not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) out->ftm.non_trigger_based =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) !!tb[NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (out->ftm.non_trigger_based && !capa->ftm.non_trigger_based) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) tb[NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) "FTM: trigger based ranging is not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (out->ftm.trigger_based && out->ftm.non_trigger_based) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) NL_SET_ERR_MSG(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) "FTM: can't set both trigger based and non trigger based");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if ((out->ftm.trigger_based || out->ftm.non_trigger_based) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) out->ftm.preamble != NL80211_PREAMBLE_HE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) "FTM: non EDCA based ranging must use HE preamble");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct nlattr *peer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct cfg80211_pmsr_request_peer *out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct genl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct nlattr *tb[NL80211_PMSR_PEER_ATTR_MAX + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct nlattr *req[NL80211_PMSR_REQ_ATTR_MAX + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct nlattr *treq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int err, rem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* no validation needed - was already done via nested policy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) nla_parse_nested_deprecated(tb, NL80211_PMSR_PEER_ATTR_MAX, peer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (!tb[NL80211_PMSR_PEER_ATTR_ADDR] ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) !tb[NL80211_PMSR_PEER_ATTR_CHAN] ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) !tb[NL80211_PMSR_PEER_ATTR_REQ]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) NL_SET_ERR_MSG_ATTR(info->extack, peer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) "insufficient peer data");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) memcpy(out->addr, nla_data(tb[NL80211_PMSR_PEER_ATTR_ADDR]), ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /* reuse info->attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) memset(info->attrs, 0, sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) err = nla_parse_nested_deprecated(info->attrs, NL80211_ATTR_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) tb[NL80211_PMSR_PEER_ATTR_CHAN],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) NULL, info->extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) err = nl80211_parse_chandef(rdev, info, &out->chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /* no validation needed - was already done via nested policy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) nla_parse_nested_deprecated(req, NL80211_PMSR_REQ_ATTR_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) tb[NL80211_PMSR_PEER_ATTR_REQ], NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!req[NL80211_PMSR_REQ_ATTR_DATA]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) tb[NL80211_PMSR_PEER_ATTR_REQ],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) "missing request type/data");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (req[NL80211_PMSR_REQ_ATTR_GET_AP_TSF])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) out->report_ap_tsf = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (out->report_ap_tsf && !rdev->wiphy.pmsr_capa->report_ap_tsf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) req[NL80211_PMSR_REQ_ATTR_GET_AP_TSF],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) "reporting AP TSF is not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) nla_for_each_nested(treq, req[NL80211_PMSR_REQ_ATTR_DATA], rem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) switch (nla_type(treq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) case NL80211_PMSR_TYPE_FTM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) err = pmsr_parse_ftm(rdev, treq, out, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) NL_SET_ERR_MSG_ATTR(info->extack, treq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) "unsupported measurement type");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct nlattr *reqattr = info->attrs[NL80211_ATTR_PEER_MEASUREMENTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct cfg80211_registered_device *rdev = info->user_ptr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct wireless_dev *wdev = info->user_ptr[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct cfg80211_pmsr_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct nlattr *peers, *peer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) int count, rem, err, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (!rdev->wiphy.pmsr_capa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (!reqattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) peers = nla_find(nla_data(reqattr), nla_len(reqattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) NL80211_PMSR_ATTR_PEERS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) if (!peers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) nla_for_each_nested(peer, peers, rem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (count > rdev->wiphy.pmsr_capa->max_peers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) NL_SET_ERR_MSG_ATTR(info->extack, peer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) "Too many peers used");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) req = kzalloc(struct_size(req, peers, count), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (!req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (info->attrs[NL80211_ATTR_TIMEOUT])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) req->timeout = nla_get_u32(info->attrs[NL80211_ATTR_TIMEOUT]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) if (info->attrs[NL80211_ATTR_MAC]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (!rdev->wiphy.pmsr_capa->randomize_mac_addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) NL_SET_ERR_MSG_ATTR(info->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) info->attrs[NL80211_ATTR_MAC],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) "device cannot randomize MAC address");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) err = nl80211_parse_random_mac(info->attrs, req->mac_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) req->mac_addr_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) memcpy(req->mac_addr, wdev_address(wdev), ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) eth_broadcast_addr(req->mac_addr_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) nla_for_each_nested(peer, peers, rem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* NB: this reuses info->attrs, but we no longer need it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) err = pmsr_parse_peer(rdev, peer, &req->peers[idx], info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) req->n_peers = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) req->cookie = cfg80211_assign_cookie(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) req->nl_portid = info->snd_portid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) err = rdev_start_pmsr(rdev, wdev, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) list_add_tail(&req->list, &wdev->pmsr_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) nl_set_extack_cookie_u64(info->extack, req->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) out_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) kfree(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) void cfg80211_pmsr_complete(struct wireless_dev *wdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct cfg80211_pmsr_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct cfg80211_pmsr_request *tmp, *prev, *to_free = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct sk_buff *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) void *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) trace_cfg80211_pmsr_complete(wdev->wiphy, wdev, req->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if (!msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) goto free_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) hdr = nl80211hdr_put(msg, 0, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) NL80211_CMD_PEER_MEASUREMENT_COMPLETE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (!hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) goto free_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) NL80211_ATTR_PAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) goto free_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, req->cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) NL80211_ATTR_PAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) goto free_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) genlmsg_end(msg, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) genlmsg_unicast(wiphy_net(wdev->wiphy), msg, req->nl_portid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) goto free_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) free_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) nlmsg_free(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) free_request:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) spin_lock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * cfg80211_pmsr_process_abort() may have already moved this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * to the free list, and will free it later. In this case, don't free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * it here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) list_for_each_entry_safe(tmp, prev, &wdev->pmsr_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (tmp == req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) list_del(&req->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) to_free = req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) spin_unlock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) kfree(to_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) EXPORT_SYMBOL_GPL(cfg80211_pmsr_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static int nl80211_pmsr_send_ftm_res(struct sk_buff *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) struct cfg80211_pmsr_result *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if (res->status == NL80211_PMSR_STATUS_FAILURE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if (nla_put_u32(msg, NL80211_PMSR_FTM_RESP_ATTR_FAIL_REASON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) res->ftm.failure_reason))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (res->ftm.failure_reason ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) NL80211_PMSR_FTM_FAILURE_PEER_BUSY &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) res->ftm.busy_retry_time &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) nla_put_u32(msg, NL80211_PMSR_FTM_RESP_ATTR_BUSY_RETRY_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) res->ftm.busy_retry_time))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) #define PUT(tp, attr, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) if (nla_put_##tp(msg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) NL80211_PMSR_FTM_RESP_ATTR_##attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) res->ftm.val)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) goto error; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) #define PUTOPT(tp, attr, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) if (res->ftm.val##_valid) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) PUT(tp, attr, val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) #define PUT_U64(attr, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) if (nla_put_u64_64bit(msg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) NL80211_PMSR_FTM_RESP_ATTR_##attr,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) res->ftm.val, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) NL80211_PMSR_FTM_RESP_ATTR_PAD)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) goto error; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) #define PUTOPT_U64(attr, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (res->ftm.val##_valid) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) PUT_U64(attr, val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (res->ftm.burst_index >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) PUT(u32, BURST_INDEX, burst_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) PUTOPT(u32, NUM_FTMR_ATTEMPTS, num_ftmr_attempts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) PUTOPT(u32, NUM_FTMR_SUCCESSES, num_ftmr_successes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) PUT(u8, NUM_BURSTS_EXP, num_bursts_exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) PUT(u8, BURST_DURATION, burst_duration);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) PUT(u8, FTMS_PER_BURST, ftms_per_burst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) PUTOPT(s32, RSSI_AVG, rssi_avg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) PUTOPT(s32, RSSI_SPREAD, rssi_spread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (res->ftm.tx_rate_valid &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) !nl80211_put_sta_rate(msg, &res->ftm.tx_rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) NL80211_PMSR_FTM_RESP_ATTR_TX_RATE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) if (res->ftm.rx_rate_valid &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) !nl80211_put_sta_rate(msg, &res->ftm.rx_rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) NL80211_PMSR_FTM_RESP_ATTR_RX_RATE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) PUTOPT_U64(RTT_AVG, rtt_avg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) PUTOPT_U64(RTT_VARIANCE, rtt_variance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) PUTOPT_U64(RTT_SPREAD, rtt_spread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) PUTOPT_U64(DIST_AVG, dist_avg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) PUTOPT_U64(DIST_VARIANCE, dist_variance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) PUTOPT_U64(DIST_SPREAD, dist_spread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (res->ftm.lci && res->ftm.lci_len &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) nla_put(msg, NL80211_PMSR_FTM_RESP_ATTR_LCI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) res->ftm.lci_len, res->ftm.lci))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) if (res->ftm.civicloc && res->ftm.civicloc_len &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) nla_put(msg, NL80211_PMSR_FTM_RESP_ATTR_CIVICLOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) res->ftm.civicloc_len, res->ftm.civicloc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) #undef PUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) #undef PUTOPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #undef PUT_U64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) #undef PUTOPT_U64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return -ENOSPC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) static int nl80211_pmsr_send_result(struct sk_buff *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct cfg80211_pmsr_result *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct nlattr *pmsr, *peers, *peer, *resp, *data, *typedata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) pmsr = nla_nest_start_noflag(msg, NL80211_ATTR_PEER_MEASUREMENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if (!pmsr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) peers = nla_nest_start_noflag(msg, NL80211_PMSR_ATTR_PEERS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) if (!peers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) peer = nla_nest_start_noflag(msg, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) if (!peer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if (nla_put(msg, NL80211_PMSR_PEER_ATTR_ADDR, ETH_ALEN, res->addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) resp = nla_nest_start_noflag(msg, NL80211_PMSR_PEER_ATTR_RESP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) if (!resp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (nla_put_u32(msg, NL80211_PMSR_RESP_ATTR_STATUS, res->status) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) nla_put_u64_64bit(msg, NL80211_PMSR_RESP_ATTR_HOST_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) res->host_time, NL80211_PMSR_RESP_ATTR_PAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) if (res->ap_tsf_valid &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) nla_put_u64_64bit(msg, NL80211_PMSR_RESP_ATTR_AP_TSF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) res->ap_tsf, NL80211_PMSR_RESP_ATTR_PAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (res->final && nla_put_flag(msg, NL80211_PMSR_RESP_ATTR_FINAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) data = nla_nest_start_noflag(msg, NL80211_PMSR_RESP_ATTR_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) typedata = nla_nest_start_noflag(msg, res->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (!typedata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) switch (res->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) case NL80211_PMSR_TYPE_FTM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) if (nl80211_pmsr_send_ftm_res(msg, res))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) nla_nest_end(msg, typedata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) nla_nest_end(msg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) nla_nest_end(msg, resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) nla_nest_end(msg, peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) nla_nest_end(msg, peers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) nla_nest_end(msg, pmsr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) return -ENOSPC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) void cfg80211_pmsr_report(struct wireless_dev *wdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) struct cfg80211_pmsr_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) struct cfg80211_pmsr_result *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) struct sk_buff *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) void *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) trace_cfg80211_pmsr_report(wdev->wiphy, wdev, req->cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) result->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * Currently, only variable items are LCI and civic location,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * both of which are reasonably short so we don't need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * worry about them here for the allocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) if (!msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PEER_MEASUREMENT_RESULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) if (!hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) NL80211_ATTR_PAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, req->cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) NL80211_ATTR_PAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) err = nl80211_pmsr_send_result(msg, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) pr_err_ratelimited("peer measurement result: message didn't fit!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) genlmsg_end(msg, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) genlmsg_unicast(wiphy_net(wdev->wiphy), msg, req->nl_portid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) nlmsg_free(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) EXPORT_SYMBOL_GPL(cfg80211_pmsr_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) static void cfg80211_pmsr_process_abort(struct wireless_dev *wdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct cfg80211_pmsr_request *req, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) LIST_HEAD(free_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) lockdep_assert_held(&wdev->mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) spin_lock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) list_for_each_entry_safe(req, tmp, &wdev->pmsr_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) if (req->nl_portid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) list_move_tail(&req->list, &free_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) spin_unlock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) list_for_each_entry_safe(req, tmp, &free_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) rdev_abort_pmsr(rdev, wdev, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) kfree(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) void cfg80211_pmsr_free_wk(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) struct wireless_dev *wdev = container_of(work, struct wireless_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) pmsr_free_wk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) wdev_lock(wdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) cfg80211_pmsr_process_abort(wdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) wdev_unlock(wdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) void cfg80211_pmsr_wdev_down(struct wireless_dev *wdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) struct cfg80211_pmsr_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) bool found = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) spin_lock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) list_for_each_entry(req, &wdev->pmsr_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) found = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) req->nl_portid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) spin_unlock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if (found)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) cfg80211_pmsr_process_abort(wdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) WARN_ON(!list_empty(&wdev->pmsr_list));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) void cfg80211_release_pmsr(struct wireless_dev *wdev, u32 portid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) struct cfg80211_pmsr_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) spin_lock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) list_for_each_entry(req, &wdev->pmsr_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) if (req->nl_portid == portid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) req->nl_portid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) schedule_work(&wdev->pmsr_free_wk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) spin_unlock_bh(&wdev->pmsr_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) #endif /* __PMSR_H */