From patchwork Fri Nov 15 13:20:37 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: 11246353 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 D0E6613B2 for ; Fri, 15 Nov 2019 13:20:51 +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 A59B120740 for ; Fri, 15 Nov 2019 13:20:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DC+pf5By"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DVfZUxAc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A59B120740 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=DC+pf5Byjgrt+4 jtRdt0Byd5uM6zBJorR95cJWB+r80hzbSXEzcrOLnIqNxHCJ1XvpLZCYFLTq/qGSrCWAuG/x5xkpP HwqnIA/qgb/CtCom5eKKxbO+P/3u44GiPbPGvmf/C+MBNCory6198estb4qR9WI0WQD7RxHQIbKxQ CMb4PZ8PtVhvsLeiJN2kmBBIr0BwwQDJo07xxZaMlYPM5N4Fb8r82IRxGx85Yc6N4DLJO0e3X2DbQ ORSXTXxIwIqHgI76lc1Nd9s3DuLtwTmIwVXhiJgppOI0O+AQHBaT8BQFq6vg7w9cOS7FYvMA1zo+C hjzqo4lmGZt+6CdF1gKQ==; 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 1iVbWt-0000v0-0f; Fri, 15 Nov 2019 13:20:51 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVbWo-0000s1-4W for ath10k@lists.infradead.org; Fri, 15 Nov 2019 13:20:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573824045; 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=DVfZUxAcyeDuGSYWJLaUCzvXlLkLrAA7YIzngWYviunidQKg9oroBLDAknOMZ1p4qioXPT OHuce8++UNpf5wUq8MvLw9cjzWhQ38pV+xc7436kdvOGqf4RVAYZLBlWqFFDzMSWfxRyMU bZBLkgDOoGbcx1CMjlL5EXXYsmk7l54= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-OVGUoSS7PlG4IcMHUK5rMQ-1; Fri, 15 Nov 2019 08:20:42 -0500 Received: by mail-lj1-f197.google.com with SMTP id y17so1538830ljm.16 for ; Fri, 15 Nov 2019 05:20:41 -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=tyD2vz48N1jMq5sFmqEDH6o7AlBZdVd0PZN+htKeQluFnhioNtVa9MgFvLqBipD/mv 6PWxqPUHJBwynh12TS1ppvtczAYc49DgasftguPJtf7mIRlpCdlxRSYVSAx1FPddk8/B vctXIrMY3aNtULIzzyd1pvyxEcD4WLA2FfGSQr9ewq9K8UlpXcktRyeDhXO/CpHoPQAg 5eq8BzcO4oyvpa9EjpQAL4Bm7Z3YN1RvgIJUE28YXgaJjrLJSANsJ840EE1Qvhq++XUm AV3sK+A6QzsC00XPnvGFAGG2psZNiXc0tAVJEKd9S4yDNnNluqYEBPRbUipPsIsh6gYa CtyA== X-Gm-Message-State: APjAAAV7QTcbxP7m3jJdxy4HcXg1vlKTq65QLUmLuA+pyJhGZn8sO8tS F/7j2m9U+etf18od5skYwyrUT+Ot62oIEpcz3BmEJcKoWQicahO2BRTqT/CYZ9N86UBDgwEkgax jixYwqg4kRHDR7He9PDPr6A== X-Received: by 2002:ac2:430d:: with SMTP id l13mr9984251lfh.114.1573824040784; Fri, 15 Nov 2019 05:20:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwjtwhBuf6diGEEm4m0JGBfBPFikNScE7ZnAZecoaHzG4zmmeoECoLruj7w1iqNj4pJC9ozgA== X-Received: by 2002:ac2:430d:: with SMTP id l13mr9984230lfh.114.1573824040606; Fri, 15 Nov 2019 05:20:40 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk (borgediget.toke.dk. [85.204.121.218]) by smtp.gmail.com with ESMTPSA id t17sm3977910ljc.88.2019.11.15.05.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 05:20:39 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id F14BB1818C6; Fri, 15 Nov 2019 14:20:37 +0100 (CET) Subject: [PATCH v9 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: Fri, 15 Nov 2019 14:20:37 +0100 Message-ID: <157382403786.580235.15008951293054113025.stgit@toke.dk> In-Reply-To: <157382403672.580235.12525941420808058808.stgit@toke.dk> References: <157382403672.580235.12525941420808058808.stgit@toke.dk> User-Agent: StGit/0.21 MIME-Version: 1.0 X-MC-Unique: OVGUoSS7PlG4IcMHUK5rMQ-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191115_052046_254292_C4C447BB X-CRM114-Status: GOOD ( 10.83 ) 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 [207.211.31.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();