Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp523306ybc; Sat, 16 Nov 2019 03:58:03 -0800 (PST) X-Google-Smtp-Source: APXvYqz8D4oXrQCyLLjq4YD2yU7q5rzyXLhAd4B9W7Gyn1D2nHashynrllj9PON6mKKLp3ZmhKdG X-Received: by 2002:a17:906:600b:: with SMTP id o11mr9019811ejj.175.1573905483448; Sat, 16 Nov 2019 03:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573905483; cv=none; d=google.com; s=arc-20160816; b=ALHLF+H2WBDbDw/3kUR9bT4ZC18LHemzX0jBWIn7nzFOclriG6CjhFeBUWwcmmJq86 z/A+e0CW8bjCNYv/uBBwyWm9ETLCPxLSbhE4Rx/2WiWXlj/rk9UiFzjZu6N2Z/RSGVPx +lCq9qIuLoMCUzzRMvl5rBXC+bkH6PVQhsUMTU6+6v41Nj5wUfS2KQaAAk7ZcAX5TCso 8XTLb5zC7E5x7Cr85FGxgUFnbispZEF+3gE6H6f2G2Tpr8cVQf1ZxaqkrD4NKgkIGR7G VaDACzvbdBlpz/vBhSvlAa9q76047z7M+dua5O8H9u6Lq3bpFDQZSjaCjX4wVPHh+HA/ hxrg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=YXoS2W5BbZsp09HQfFBXWaQ8N7PlWsSs7THfUeKuQyo=; b=FeOOI1Pdzu8en0f0I9AAgZ0ZWsjH89ZIIM6JOoPR6dXM4EoSRsnZ1H2DwscY6W5M59 DWRTRu2GwWyLe2jFzeP/Y5Zomhp+pjkwKnnj/zw0VDC7W8zRfDTQIhtTu4t08+2WSEab ihOgaIFh1pIg5LPhMMcTq8G/OHMwa40s7+bjy3Ma8MFqEG/LgUdjiw6OCkCX5S1drXdf XLnEcW5LDphysmKlXiSfWpi3NU/gFlAhtuzIN/LVHxio9Ki0TTbCW1Rw+2VTRRQ8lMO8 qCxxe+8igjr00wPN3KuJYsq0Ltf6/T+UlZZ137eX2lbFWiI9TjFArKptTuv85VAE/pBH 1/vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Rk/Ofw01"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w25si8202554edl.418.2019.11.16.03.57.38; Sat, 16 Nov 2019 03:58:03 -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=@redhat.com header.s=mimecast20190719 header.b="Rk/Ofw01"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727471AbfKPL5Y (ORCPT + 99 others); Sat, 16 Nov 2019 06:57:24 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:42413 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726794AbfKPL5Y (ORCPT ); Sat, 16 Nov 2019 06:57:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573905443; 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=Rk/Ofw01ilidAHxDEbF3CVU5u1j47aBhV9BPoWiB/TuUDJpToPSeH+r8JL4r5OS/orRu4r 3+y1nDwm0C1rbTB7O9TMeIzKHOrkJmc112sXUkMdpXbJLkhmWhsm8A8MDCQCvyjYcfjq40 uNBvcn/j599rKWosYV2HdsmOZ5l3PZk= 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-5-RKWHDo-eN4WZzo496X8XSg-1; Sat, 16 Nov 2019 06:57:22 -0500 Received: by mail-lf1-f69.google.com with SMTP id k30so3979149lfj.5 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=RIrbk8qt/rUfbPI0Kt9mPe0FftkWljsrwfGoBWi4UxxaQ+tMnhhsxiPXdgjyWEd9iZ rlZrYJCc+HF5tJtm+T92BXPg4N5QlOAVHfRgLYy6vnwnXJRYuJnpH+3puaxbXvCsl8bS yagrbfZggOVkv73kcU5JUxru2PmKs+9l3RZAHesL0ECr6CeyQAicvRUlo4MXIwxTb/sk OR5Qs41HNE7pBtsuMMWhHrNEA6qdAOu+iPZIIJYDWg+S8UImCD7x9rH+/6Unzoyfaxtz yL9+RF+goj24CyD9V3ris+SfuA3KH/ve1BWDb9TUhtd+Q6QoHi9JRQJaGJYMliLH3UN1 39hQ== X-Gm-Message-State: APjAAAXs9P1oBoFSxNMqvi+bXg/xhSTfY79lN0/dZo8FNSv5r8uhTTX5 +p/Qs8JrHbFh/TAylrSUlsigPO2pgrTYEuQoCppVDo/DBorSyBsgD1GQ3iGVhs63rWRQ4GhRhqk LoaEmUUB2lWauaia/jlcx6Z8Iuzg= X-Received: by 2002:a2e:9156:: with SMTP id q22mr10462785ljg.166.1573905440929; Sat, 16 Nov 2019 03:57:20 -0800 (PST) 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 Cc: linux-wireless@vger.kernel.org, make-wifi-fast@lists.bufferbloat.net, ath10k@lists.infradead.org, John Crispin , Lorenzo Bianconi , Felix Fietkau , Kan Yan , Rajkumar Manoharan , Kevin Hayes 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: RKWHDo-eN4WZzo496X8XSg-1 X-Mimecast-Spam-Score: 0 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, =09return NULL; } =20 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local, +=09=09=09=09 const u8 *sta_addr, const u8 *vif_addr) +{ +=09struct rhlist_head *tmp; +=09struct sta_info *sta; + +=09rcu_read_lock(); +=09for_each_sta_info(local, sta_addr, sta, tmp) { +=09=09if (ether_addr_equal(vif_addr, sta->sdata->vif.addr)) { +=09=09=09rcu_read_unlock(); +=09=09=09/* this is safe as the caller must already hold +=09=09=09 * another rcu read section or the mutex +=09=09=09 */ +=09=09=09return sta; +=09=09} +=09} +=09rcu_read_unlock(); +=09return NULL; +} + struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata, =09=09=09=09 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, =09=09=09=09 const u8 *addr); =20 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local, +=09=09=09=09 const u8 *sta_addr, const u8 *vif_addr); + #define for_each_sta_info(local, _addr, _sta, _tmp)=09=09=09\ =09rhl_for_each_entry_rcu(_sta, _tmp,=09=09=09=09\ =09=09=09 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) =09=09.skb =3D skb, =09=09.info =3D IEEE80211_SKB_CB(skb), =09}; -=09struct rhlist_head *tmp; =09struct sta_info *sta; =20 =09rcu_read_lock(); =20 -=09for_each_sta_info(local, hdr->addr1, sta, tmp) { -=09=09/* skip wrong virtual interface */ -=09=09if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr)) -=09=09=09continue; - +=09sta =3D sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2); +=09if (sta) =09=09status.sta =3D &sta->sta; -=09=09break; -=09} =20 =09__ieee80211_tx_status(hw, &status); =09rcu_read_unlock();