From patchwork Sat Nov 16 11:57:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 11247555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A71E96C1 for ; Sat, 16 Nov 2019 11:57:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8483C206D3 for ; Sat, 16 Nov 2019 11:57:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TWsmqdrn"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gQ2fhqLd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8483C206D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:To:From:Subject:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Fy/Ee+Z8FCZeuZD3j3PfrvbYRtrPi+2qQQCFSV+3LTo=; b=TWsmqdrna+j+e6 fPYSf86QKNQW7mt7yD7vVkFdksEL/GcEqKZWvXCovQvtJLrYRx6K5J7KA/KCSmc/u8yf8IDWuJ5Mt ucmgqMZcUGqvspEGXpghn7Pav7seob3Zs2hCCR/iiQrCEa23a0hCsX5WwURNasx39rXwlnhGdDNVd 5Y90ebYmVwhd14lYe+55JSE1KrbuWRyTVFmDp0AhzNwPTOp+7XxM/axHWh5ZQo+rVsab7Pp4cLkTk hUoO5mVNg/FiUe2LUIrQGJAkcptP7R2T9TqU5ryyMG1vfZWid9IXo+uRtTBQqsIY5ZryWzh2cvhGT we5uAsNunynd1YNrnoiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVwhk-0006s4-RL; Sat, 16 Nov 2019 11:57:28 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVwhg-0006ot-Ur for ath10k@lists.infradead.org; Sat, 16 Nov 2019 11:57:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573905444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YXoS2W5BbZsp09HQfFBXWaQ8N7PlWsSs7THfUeKuQyo=; b=gQ2fhqLdaB/5nfGphtVLDMUeuKCz0PBM2BYBZalfz4Jwwvh0t3l1wFlUDmJg1wfcvgTc2S B8iyigvoFXuXULqzkNAOfozLXQjH7JvCksiBooDwd6g6AdlEAqU+2cGFIx4gbwSDT1v1lp GydnCl+pAC6Cwqb7jNTMt6epQP1swcc= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-7yni84wHNfWYvlkj43BPhw-1; Sat, 16 Nov 2019 06:57:22 -0500 Received: by mail-lf1-f69.google.com with SMTP id y188so3970630lfc.6 for ; Sat, 16 Nov 2019 03:57:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=x+t/BOQM8F7dbfpj4lBhXe72lJwS1NOF599JEwP8bYk=; b=LEuCmsvwezWHjK89hKhqMuVIm+N/TUFPZhzKhYzMJjq1tkd/lEjoMhkNOggBqP3aWp bcnZURW8ajaPRTv1W83H8nSVeAh7KvDDNdXVgq29xy4V3ilbNXnaAS+I2HrdRodcIwRp dLKU1lUH6dSQdRes3JbR20X37/9q5PtWWjhcbIi48/Fbh1QEPokrrx8usOtM+irODV8l PRqxUzqlAx49SmqTayGxhlUcBGWPZcF0YXmfLSSvLTKRf+dUyG3nrmjI12+GbxNa+5VO JoCRnkzLqMtVefZcIS2OrNB09JX6jgyzK6Jth5YRFcJgKHjnCARdDHZZ5GdoNB+d4nsH RNIw== X-Gm-Message-State: APjAAAWiH86fpJPNEX8TqcxnJoA9OyKnBq9WwEgJTXz2ZE5ehitwGI49 0lo4v0P6C3eWPie7HYFWRdGO0/kAMld4LccUo0ldDKhisF1QbdGNTi5dMEWfLsddSp7Ykfe3WpP k6VNk49VriC7wCyzZ0WhlaA== X-Received: by 2002:a2e:9156:: with SMTP id q22mr10462789ljg.166.1573905440930; Sat, 16 Nov 2019 03:57:20 -0800 (PST) X-Google-Smtp-Source: APXvYqz0L+POcRH+ZCGceuYnd9tkUS+fm0ri2a2QHKWHz6GQdx5Ehz43kLACA3daj8P4f0JD6MpnUA== X-Received: by 2002:a2e:9156:: with SMTP id q22mr10462771ljg.166.1573905440761; Sat, 16 Nov 2019 03:57:20 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a00:7660:6da:443::2]) by smtp.gmail.com with ESMTPSA id s28sm6071884lfp.92.2019.11.16.03.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2019 03:57:18 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 1483C181911; Sat, 16 Nov 2019 12:57:18 +0100 (CET) Subject: [PATCH v10 1/4] mac80211: Add new sta_info getter by sta/vif addrs From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: Johannes Berg Date: Sat, 16 Nov 2019 12:57:18 +0100 Message-ID: <157390543799.662247.14225450732789555896.stgit@toke.dk> In-Reply-To: <157390543688.662247.3735146484299260207.stgit@toke.dk> References: <157390543688.662247.3735146484299260207.stgit@toke.dk> User-Agent: StGit/0.21 MIME-Version: 1.0 X-MC-Unique: 7yni84wHNfWYvlkj43BPhw-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191116_035725_063082_C0607627 X-CRM114-Status: GOOD ( 10.57 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [205.139.110.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kan Yan , Rajkumar Manoharan , Kevin Hayes , make-wifi-fast@lists.bufferbloat.net, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org, John Crispin , Lorenzo Bianconi , Felix Fietkau Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org From: Toke Høiland-Jørgensen 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øiland-Jørgensen --- 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; } +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_data *sdata, struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, const u8 *addr); +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, struct sk_buff *skb) .skb = skb, .info = IEEE80211_SKB_CB(skb), }; - struct rhlist_head *tmp; struct sta_info *sta; rcu_read_lock(); - 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 = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2); + if (sta) status.sta = &sta->sta; - break; - } __ieee80211_tx_status(hw, &status); rcu_read_unlock();