Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp144936ybc; Mon, 18 Nov 2019 22:08:20 -0800 (PST) X-Google-Smtp-Source: APXvYqx9wD4IsJ43+WeBOTSZmHieLwPOWtoPccigyD34nZGl9MbNOv36EEm5y0OXcxCyHj5+OoGE X-Received: by 2002:a17:906:69d7:: with SMTP id g23mr32354876ejs.20.1574143700746; Mon, 18 Nov 2019 22:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574143700; cv=none; d=google.com; s=arc-20160816; b=zPh0Ta+a6I3OvC5BlHmvCBFPHukniE+5NuzFhrx0TTrf1p7D1XIdUWSjUdg+gtio7t AUqZxdBLUaE8ljr9ec2EQ3WkFwLmUOaEsBjhf9p/rT1yVXlpaysxs5UEvTI0SCNYVUJb p/DHHiSSfMBQEjAQJVy27YpOIv19pKv7tEk1MXQ9gnq0N3BlzTRjIHGYCi+DE5ocI4Lt 3WoZhr6vjOpIzx2Fia6ZgVtW/OSnGIkd9HcmsqzSZvjRnvelWDg6vJe2qcNklLvixI4Y zY8WcvFLjpkNW46f/CBRmZwRpk48lhSXhwws+Vy2km1ZYDpnMAHQCI+fiUwCRyb97zh2 Pf9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:from :subject:references:mime-version:message-id:in-reply-to:date :dkim-signature; bh=SUJ++x/TlhzzyCi0jS7LtcmTW7wMb85gdnxub2e66+4=; b=BvTO9yJr55C7ZJiN3BqIntaVe3ucjC0lsuvdbB+Qo0SNDdAHAwJW5MFkGNklaBX/+8 SZdDP+HoAcOMbBun8XkZQuO7TSaED5wHnqoYMiLkrkFhNiPYCwxDoyr2PrBsieTZnchF 6C8mXYNO7XxYwRLKmuRBvVHP/C6fQCyB8fZ4Jq7CblvIuOUlWnn+F/a1F2zKzVk8BPTK 35x/C2tWTWoknPdTJeJbxjAEDJF434QsO03cZnLHj/05zMLTP41nLS4/DZWekl7VemEv 4tLgvTqtimHYuFvG7QONrgPOJV2bvO3nr5RGDdTjfQIrxb3JXq5qApJ5qhjpD2SbRxfg +w3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jzcfBOXO; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18si12957836ejj.427.2019.11.18.22.07.56; Mon, 18 Nov 2019 22:08:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jzcfBOXO; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728869AbfKSGGY (ORCPT + 99 others); Tue, 19 Nov 2019 01:06:24 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:54341 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728017AbfKSGGX (ORCPT ); Tue, 19 Nov 2019 01:06:23 -0500 Received: by mail-pg1-f202.google.com with SMTP id t28so14933858pgl.21 for ; Mon, 18 Nov 2019 22:06:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=SUJ++x/TlhzzyCi0jS7LtcmTW7wMb85gdnxub2e66+4=; b=jzcfBOXOxGybpn7TTyB80D1IkGi0bBq0gVKYBPTYxT3//xKRGogjWxHWfnUxLuQ6YF NUAibcBr6n7a2nLtzBvI1I/He3pN/eVNDKWeJqYZbYsd1e0gXsJXnTZ0pqpCzOi8f+3o fFHs+UGbTbQ3XIFzivdY7soT8yuSQwMlDXDRNYyktpg4/qepd+pTOYIpPIz4/S2UEkDh 7xOgJBp13PkQ34TvIckWDeiQdHqoNlPAUBEhFycLMS2E01YXo096G8e6p3or2T3fLjfG 4gmAFDtJPjGPuiFOViOrxXCIWg84AeT4iBVFhGsqhaFHxdRAYzggxqLkRclxkfxv4Rnq IEBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=SUJ++x/TlhzzyCi0jS7LtcmTW7wMb85gdnxub2e66+4=; b=VdCLKYUgoukaLMEzApy7mDNUHyPknx1Lb7ZnJAK73AYoCU01rksYh3bwvliY1XNu8h wt+j/Xeo8FtKmTgdX2P57B/AD6Tb3M1mfUeexgRfBDnIYzTmME8d2UvlahaTpvApDeW1 HIFgNGvnCrRWwYjb1JM91P+ZbhZd8SJ53XZTmbjN+4ajLrF6scspfsbzMrm3yJqcDWEQ 3I4+inXgaTcykB2cwKV+VcIok5yp6KDftvVvjdhcV3aQAiCrxBBBCLGrjViuQ9vUTeqQ 3zJva+XTOxoCvlcDDoOrf0oAifty38zQcqyj87xXdQzYHxIGUkWh9I8cCGI1coUDGztW FWlw== X-Gm-Message-State: APjAAAUcfgy++sF4qvWYNEreAdurouFwF+fC1HjEXImvjP+1pjuviFB5 kuA45Vu28r8izcB5dd96kWaZM19V X-Received: by 2002:a63:495b:: with SMTP id y27mr3614518pgk.438.1574143580296; Mon, 18 Nov 2019 22:06:20 -0800 (PST) Date: Mon, 18 Nov 2019 22:06:07 -0800 In-Reply-To: <20191119060610.76681-1-kyan@google.com> Message-Id: <20191119060610.76681-2-kyan@google.com> Mime-Version: 1.0 References: <20191119060610.76681-1-kyan@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH v11 1/4] mac80211: Add new sta_info getter by sta/vif addrs From: Kan Yan To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, make-wifi-fast@lists.bufferbloat.net, toke@redhat.com, nbd@nbd.name, yiboz@codeaurora.org, john@phrozen.org, lorenzo@kernel.org, rmanohar@codeaurora.org, kevinhayes@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Toke H=C3=B8iland-J=C3=B8rgensen In ieee80211_tx_status() we don't have an sdata struct when looking up the destination sta. Instead, we just do a lookup by the vif addr that is the source of the packet being completed. Factor this out into a new sta_info getter helper, since we need to use it for accounting AQL as well. Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen --- net/mac80211/sta_info.c | 20 ++++++++++++++++++++ net/mac80211/sta_info.h | 3 +++ net/mac80211/status.c | 10 ++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index bd11fef2139f..465d83b13582 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -210,6 +210,26 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub= _if_data *sdata, return NULL; } =20 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local, + const u8 *sta_addr, const u8 *vif_addr) +{ + struct rhlist_head *tmp; + struct sta_info *sta; + + rcu_read_lock(); + for_each_sta_info(local, sta_addr, sta, tmp) { + if (ether_addr_equal(vif_addr, sta->sdata->vif.addr)) { + rcu_read_unlock(); + /* this is safe as the caller must already hold + * another rcu read section or the mutex + */ + return sta; + } + } + rcu_read_unlock(); + return NULL; +} + struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata, int idx) { diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 369c2dddce52..80e76569144e 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -725,6 +725,9 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_d= ata *sdata, struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, const u8 *addr); =20 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local, + const u8 *sta_addr, const u8 *vif_addr); + #define for_each_sta_info(local, _addr, _sta, _tmp) \ rhl_for_each_entry_rcu(_sta, _tmp, \ sta_info_hash_lookup(local, _addr), hash_node) diff --git a/net/mac80211/status.c b/net/mac80211/status.c index ab8ba5835ca0..0e51def35b8a 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -1073,19 +1073,13 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, s= truct sk_buff *skb) .skb =3D skb, .info =3D IEEE80211_SKB_CB(skb), }; - struct rhlist_head *tmp; struct sta_info *sta; =20 rcu_read_lock(); =20 - for_each_sta_info(local, hdr->addr1, sta, tmp) { - /* skip wrong virtual interface */ - if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr)) - continue; - + sta =3D sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2); + if (sta) status.sta =3D &sta->sta; - break; - } =20 __ieee80211_tx_status(hw, &status); rcu_read_unlock(); --=20 2.24.0.432.g9d3f5f5b63-goog