Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp508385imw; Wed, 13 Jul 2022 02:48:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sz1tUMeFBx37ZH7qhWZfhJJjj2bS12p9Y3QyZgg6Z3mVbsnHqLgqMzqNZbqwDsZGN/jwAN X-Received: by 2002:a17:903:22d0:b0:16b:f798:1cff with SMTP id y16-20020a17090322d000b0016bf7981cffmr2584844plg.23.1657705707148; Wed, 13 Jul 2022 02:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657705707; cv=none; d=google.com; s=arc-20160816; b=OOPtRo2HIFCAEsEUIqKPwinRG1hqGdJ76NF6oZGe1rNEO9bOfxlj3D0HG/K3973X59 V8hKfh7L5XUWI5XolEs20l6jVzAkbkKfKbW96rYPSWmhbNUzTadg/yi4DqAjG8pbCK57 Dr8VOLg/qywlTXDyd+QGqOAfX1iFUSkQokzVwLD4KZ4VqFRGLNiWIHnKfTL/2FZ028Aw 3gPpjcslo7Rfsw+vJyaEpsALg92OsKoWZhCCiokNQErJay7bDEc3WRk+yJ4nWzn3bNnF w6SMjaVNJtAnFtgl9BY+EDh7Q4q3f0c26vQAeu1oUUoC3+mdJthyoogFjKre2U8MP3Zm M4Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JdJA/BoOw80ocllxCb1mlD/BYSFA49Ga4jUo8vuSqgg=; b=pkfDpq5EPXtTkhJWL2Lgbl31Yo5lIGMjhBTOtkQzV6vhLAcxsCek3k5XKrtG7S7/IH kfJkA15q463d31HhRp4jl/69lz4iP3ytVHR+gVZgS6LWD2g2FcwbuEI6cmK7sPwGbchM cstwo6HKwtUq0cZbJDq1fT71sQhSPldrqfz2EFsF9t118N6GpPM0CDxCk6BM07S1psq1 Jd7p6WOWbllvLwY7KfpfsBI7U0paW8p6nGXPVBKAyYz+ogiu1BH0rsC1Ww8/zuHy0pXX HAvgbNOUF/2i7okmSbzCVBuZZ9Zj80p+kR6hJd2Yuvo7FUrHFKv8wLWAqfoIWWEoNzM6 mlww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=ltFow1F0; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a18-20020a170902ecd200b0016a496aedefsi18419905plh.300.2022.07.13.02.48.19; Wed, 13 Jul 2022 02:48:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=ltFow1F0; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236191AbiGMJpR (ORCPT + 65 others); Wed, 13 Jul 2022 05:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235307AbiGMJpL (ORCPT ); Wed, 13 Jul 2022 05:45:11 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A18FEE1F8 for ; Wed, 13 Jul 2022 02:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=JdJA/BoOw80ocllxCb1mlD/BYSFA49Ga4jUo8vuSqgg=; t=1657705509; x=1658915109; b=ltFow1F0S17p6zMAmcgsyzLphtj3buwj79OMQ4PqkPfTY8A e/4Dj2ztFyKTNUpWlVGZuLemdlnI0nq3OPuqZhjgHkuWebzeG7hv9CCw1f7n9R/Nu9q7yIA3Y/e+5 d5YNnUdnwu1Rf4cR61UKRDJ8/JrmaheqyrGebH75pL98agfkPthmkcjIHiRXBr06oq/v4bQn5Z9Kx lATiDmb3YCRuXHdHSinDkH+eapW+n7a0wRYyYHcpIW0PL2cIkcZIkVQ8oSf9CM76ssYc626IPpgFN SMldJDZg/dvvjycNo8e6uw3mttCjtSeJLIIj5ZiwibLKpFmWXngHA6kxs+w57RCg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1oBYvb-00EgvB-9w; Wed, 13 Jul 2022 11:45:07 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Shaul Triebitz Subject: [PATCH 10/76] wifi: mac80211: implement callbacks for _link_station Date: Wed, 13 Jul 2022 11:43:56 +0200 Message-Id: <20220713114425.f8dd4c9e6ac2.I8705f04cb349065f10fbb27286f5800444be37a6@changeid> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220713094502.163926-1-johannes@sipsolutions.net> References: <20220713094502.163926-1-johannes@sipsolutions.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Shaul Triebitz Implement callbacks for cfg80211 add_link_station, mod_link_station, and del_link_station API. Signed-off-by: Shaul Triebitz Signed-off-by: Johannes Berg --- net/mac80211/cfg.c | 105 ++++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.c | 7 +++ net/mac80211/sta_info.h | 1 + 3 files changed, 113 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index a63f9235bcc3..777c133c3f0b 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -4588,6 +4588,108 @@ static void ieee80211_del_intf_link(struct wiphy *wiphy, ieee80211_vif_set_links(sdata, wdev->valid_links); } +static int sta_add_link_station(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct link_station_parameters *params) +{ + struct sta_info *sta; + int ret; + + sta = sta_info_get_bss(sdata, params->mld_mac); + if (!sta) + return -ENOENT; + + ret = ieee80211_sta_allocate_link(sta, params->link_id); + if (ret) + return ret; + + ret = sta_link_apply_parameters(local, sta, params); + if (ret) { + ieee80211_sta_free_link(sta, params->link_id); + return ret; + } + + /* ieee80211_sta_activate_link frees the link upon failure */ + return ieee80211_sta_activate_link(sta, params->link_id); +} + +static int +ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev, + struct link_station_parameters *params) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ieee80211_local *local = wiphy_priv(wiphy); + int ret; + + mutex_lock(&sdata->local->sta_mtx); + ret = sta_add_link_station(local, sdata, params); + mutex_unlock(&sdata->local->sta_mtx); + + return ret; +} + +static int sta_mod_link_station(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct link_station_parameters *params) +{ + struct sta_info *sta; + + sta = sta_info_get_bss(sdata, params->mld_mac); + if (!sta) + return -ENOENT; + + if (!(sta->sta.valid_links & BIT(params->link_id))) + return -EINVAL; + + return sta_link_apply_parameters(local, sta, params); +} + +static int +ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev, + struct link_station_parameters *params) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ieee80211_local *local = wiphy_priv(wiphy); + int ret; + + mutex_lock(&sdata->local->sta_mtx); + ret = sta_mod_link_station(local, sdata, params); + mutex_unlock(&sdata->local->sta_mtx); + + return ret; +} + +static int sta_del_link_station(struct ieee80211_sub_if_data *sdata, + struct link_station_del_parameters *params) +{ + struct sta_info *sta; + + sta = sta_info_get_bss(sdata, params->mld_mac); + if (!sta) + return -ENOENT; + + if (!(sta->sta.valid_links & BIT(params->link_id))) + return -EINVAL; + + ieee80211_sta_remove_link(sta, params->link_id); + + return 0; +} + +static int +ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev, + struct link_station_del_parameters *params) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + int ret; + + mutex_lock(&sdata->local->sta_mtx); + ret = sta_del_link_station(sdata, params); + mutex_unlock(&sdata->local->sta_mtx); + + return ret; +} + const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -4695,4 +4797,7 @@ const struct cfg80211_ops mac80211_config_ops = { .set_radar_background = ieee80211_set_radar_background, .add_intf_link = ieee80211_add_intf_link, .del_intf_link = ieee80211_del_intf_link, + .add_link_station = ieee80211_add_link_station, + .mod_link_station = ieee80211_mod_link_station, + .del_link_station = ieee80211_del_link_station, }; diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index d738534a709e..a4fa0ce7bd92 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2702,6 +2702,13 @@ static int link_sta_info_hash_add(struct ieee80211_local *local, link_sta_rht_params); } +void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id) +{ + lockdep_assert_held(&sta->sdata->local->sta_mtx); + + sta_remove_link(sta, link_id, false); +} + int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id) { struct ieee80211_sub_if_data *sdata = sta->sdata; diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index a1724e366a35..ea0eeee808a5 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -900,6 +900,7 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, unsigned long exp_time); int ieee80211_sta_allocate_link(struct sta_info *sta, unsigned int link_id); +void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id); int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id); void ieee80211_sta_remove_link(struct sta_info *sta, unsigned int link_id); -- 2.36.1