From: Rohan Dutta <[email protected]>

When an AP is getting started, configure the AP as SMD-enabled if
userspace provides configuration for the Seamless Mobility Domain (SMD).

The SMD parameters are:
 - SMD Identifier: unique identifier of the SMD
 - SMD Preparation Timeout: Valid duration for a prepared target AP MLD
 - Downlink Data Forwarding: Forwarding support for buffered DL packets
 - Max Number of Peer AP MLDs: Number of target AP MLDs that a non-AP
                               MLD can prepare with
 - SMD Type: Type of SMD
 - SMD PTK Mode: PTK mode used in the SMD
 - Neighbor Probing: UHR Neighboring AP Probing

Without these parameters configured, drivers and lower layers cannot
support SMD BSS Transition.

Signed-off-by: Rohan Dutta <[email protected]>
Co-developed-by: Aditya Sathish <[email protected]>
Signed-off-by: Aditya Sathish <[email protected]>
Co-developed-by: Sidhanta Sahu <[email protected]>
Signed-off-by: Sidhanta Sahu <[email protected]>
Signed-off-by: Pooventhiran G <[email protected]>
---
 include/net/cfg80211.h | 25 ++++++++++++++++
 include/net/mac80211.h |  2 ++
 net/mac80211/cfg.c     |  5 ++++
 net/wireless/nl80211.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 110 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9aa7d2d4a184..df85dc804c50 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1587,6 +1587,29 @@ struct cfg80211_s1g_short_beacon {
        size_t short_tail_len;
 };
 
+/**
+ * struct cfg80211_smd_params - Seamless Mobility Domain parameters
+ *
+ * @smd_enabled: SMD is enabled on this device
+ * @smd_identifier: SMD ID (ETH_ALEN bytes)
+ * @smd_timeout: timeout in 64 TUs for ST Preparation
+ * @dl_data_fwd: MSDU forwarding supported
+ * @max_num_of_peer_apmlds: max prepared AP MLDs supported (0-7)
+ * @smd_type: SMD type
+ * @ptk_mode: PTK mode
+ * @neighbor_probing: UHR Neighboring AP Probing supported
+ */
+struct cfg80211_smd_params {
+       bool smd_enabled;
+       u8 smd_identifier[ETH_ALEN];
+       u16 smd_timeout;
+       bool dl_data_fwd;
+       u8 max_num_of_peer_apmlds;
+       enum nl80211_smd_type smd_type;
+       enum nl80211_smd_ptk_mode ptk_mode;
+       bool neighbor_probing;
+};
+
 /**
  * struct cfg80211_ap_settings - AP configuration
  *
@@ -1623,6 +1646,7 @@ struct cfg80211_s1g_short_beacon {
  * @mbssid_config: AP settings for multiple bssid
  * @s1g_long_beacon_period: S1G long beacon period
  * @s1g_short_beacon: S1G short beacon data
+ * @smd_params: Seamless Mobility Domain (SMD) parameters
  */
 struct cfg80211_ap_settings {
        struct cfg80211_chan_def chandef;
@@ -1655,6 +1679,7 @@ struct cfg80211_ap_settings {
        struct cfg80211_mbssid_config mbssid_config;
        u8 s1g_long_beacon_period;
        struct cfg80211_s1g_short_beacon s1g_short_beacon;
+       struct cfg80211_smd_params smd_params;
 };
 
 
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 1172d7b83ed1..3a5011945eed 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -797,6 +797,7 @@ struct ieee80211_bss_npca_params {
  * @s1g_long_beacon_period: number of beacon intervals between each long
  *     beacon transmission.
  * @npca: NPCA parameters
+ * @smd_params: SMD parameters
  */
 struct ieee80211_bss_conf {
        struct ieee80211_vif *vif;
@@ -904,6 +905,7 @@ struct ieee80211_bss_conf {
        u8 s1g_long_beacon_period;
 
        struct ieee80211_bss_npca_params npca;
+       struct cfg80211_smd_params smd_params;
 };
 
 #define IEEE80211_NAN_MAX_CHANNELS 3
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 23f4f9ec86d0..b4b42790c5d7 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1796,6 +1796,11 @@ static int ieee80211_start_ap(struct wiphy *wiphy, 
struct net_device *dev,
                }
        }
 
+       if (params->smd_params.smd_enabled)
+               link_conf->smd_params = params->smd_params;
+       else
+               link_conf->smd_params.smd_enabled = false;
+
        if (sdata->vif.type == NL80211_IFTYPE_AP &&
            params->mbssid_config.tx_wdev) {
                err = ieee80211_set_ap_mbssid_options(sdata,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index de93b34444b4..b4ff784d131b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -7225,6 +7225,78 @@ static int nl80211_check_npca(struct 
cfg80211_registered_device *rdev,
        return -EINVAL;
 }
 
+static int nl80211_parse_smd_params(struct genl_info *info,
+                                   struct cfg80211_smd_params *smd_params)
+{
+       struct nlattr *smd_params_attr = info->attrs[NL80211_ATTR_SMD_PARAMS];
+       struct cfg80211_registered_device *rdev = info->user_ptr[0];
+       struct net_device *dev = info->user_ptr[1];
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct nlattr *tb[NL80211_SMD_PARAMS_ATTR_MAX + 1];
+       int err;
+
+       if (!wiphy_ext_feature_isset(&rdev->wiphy,
+                                    NL80211_EXT_FEATURE_SMD)) {
+               GENL_SET_ERR_MSG(info, "SMD is not supported");
+               return -EOPNOTSUPP;
+       }
+
+       if (!wdev->valid_links) {
+               GENL_SET_ERR_MSG(info, "SMD is not allowed without MLO");
+               return -EINVAL;
+       }
+
+       err = nla_parse_nested(tb, NL80211_SMD_PARAMS_ATTR_MAX,
+                              smd_params_attr, nl80211_smd_params_policy,
+                              NULL);
+       if (err) {
+               GENL_SET_ERR_MSG(info, "failed to parse SMD parameters");
+               return err;
+       }
+
+       if (!tb[NL80211_SMD_PARAMS_ATTR_IDENTIFIER] ||
+           !tb[NL80211_SMD_PARAMS_ATTR_TIMEOUT] ||
+           !tb[NL80211_SMD_PARAMS_ATTR_MAX_PEER_APMLDS] ||
+           !tb[NL80211_SMD_PARAMS_ATTR_TYPE] ||
+           !tb[NL80211_SMD_PARAMS_ATTR_PTK_MODE]) {
+               GENL_SET_ERR_MSG(info, "required SMD parameters are missing");
+               return -EINVAL;
+       }
+
+       memcpy(smd_params->smd_identifier,
+              nla_data(tb[NL80211_SMD_PARAMS_ATTR_IDENTIFIER]),
+              ETH_ALEN);
+
+       smd_params->smd_timeout =
+               nla_get_u16(tb[NL80211_SMD_PARAMS_ATTR_TIMEOUT]);
+
+       smd_params->dl_data_fwd =
+               !!tb[NL80211_SMD_PARAMS_ATTR_DL_DATA_FORWARDING];
+       if (smd_params->dl_data_fwd &&
+           !wiphy_ext_feature_isset(&rdev->wiphy,
+                                    
NL80211_EXT_FEATURE_SMD_DL_PKT_FORWARDING)) {
+               GENL_SET_ERR_MSG(info,
+                                "SMD DL packet forwarding is not supported");
+               return -EOPNOTSUPP;
+       }
+
+       smd_params->max_num_of_peer_apmlds =
+               nla_get_u8(tb[NL80211_SMD_PARAMS_ATTR_MAX_PEER_APMLDS]);
+
+       smd_params->smd_type =
+               nla_get_u8(tb[NL80211_SMD_PARAMS_ATTR_TYPE]);
+
+       smd_params->ptk_mode =
+               nla_get_u8(tb[NL80211_SMD_PARAMS_ATTR_PTK_MODE]);
+
+       smd_params->neighbor_probing =
+               !!tb[NL80211_SMD_PARAMS_ATTR_NEIGHBOR_PROBING];
+
+       smd_params->smd_enabled = true;
+
+       return 0;
+}
+
 static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
 {
        struct cfg80211_registered_device *rdev = info->user_ptr[0];
@@ -7506,6 +7578,12 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
 
        /* FIXME: validate MLO/link-id against driver capabilities */
 
+       if (info->attrs[NL80211_ATTR_SMD_PARAMS]) {
+               err = nl80211_parse_smd_params(info, &params->smd_params);
+               if (err)
+                       goto out;
+       }
+
        err = rdev_start_ap(rdev, dev, params);
        if (!err) {
                wdev->links[link_id].ap.beacon_interval = 
params->beacon_interval;

-- 
2.34.1


Reply via email to