From patchwork Tue Oct 3 21:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 729237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE055E8FDBC for ; Tue, 3 Oct 2023 21:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232460AbjJCV6r (ORCPT ); Tue, 3 Oct 2023 17:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbjJCV6q (ORCPT ); Tue, 3 Oct 2023 17:58:46 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACD1A6 for ; Tue, 3 Oct 2023 14:58:43 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 93B19A80071 for ; Tue, 3 Oct 2023 21:58:41 +0000 (UTC) Received: from ben-dt5.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 1833913C2B0; Tue, 3 Oct 2023 14:58:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 1833913C2B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1696370321; bh=j+2iI5Ljhwh3oxtbEWOohd0yhLv4csUwh/m1ozxjmsE=; h=From:To:Cc:Subject:Date:From; b=NB+Tm4WcTVfAWO3KkbQpH1D6SvEXN7KrBaBR8dkzd87OW0id+HEPQxuuCys3Bpo/B 72cFxAHfSTv15o8hu1ETtaThslXCFVcUmgupzWgvFkgs1BZKNfYoAuwYL2ErOvSuu/ kiMViskWEQ2efPWJ0PJQA/MdCL9bjV4X/deyHLqM= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH] mac80211: ethtool: check link sta if deflink sta not found. Date: Tue, 3 Oct 2023 14:58:39 -0700 Message-Id: <20231003215839.981227-1-greearb@candelatech.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-MDID: 1696370322-O5XpusY6R4Lx X-MDID-O: us5; ut7; 1696370322; O5XpusY6R4Lx; ; f7146c1849a4b08a52804beb1c1cdf45 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear While testing with wifi-7 radio put into AX mode, link-0 is created. sdata->deflink.u.mgd.bssid was 00 in this case, so sta was not found. Use link-0 for sta if it is available to do a better job of reporting ethtool stats. Signed-off-by: Ben Greear --- net/mac80211/ethtool.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mac80211/ethtool.c b/net/mac80211/ethtool.c index 6bd7fba8a867..1b58304fc68a 100644 --- a/net/mac80211/ethtool.c +++ b/net/mac80211/ethtool.c @@ -96,6 +96,7 @@ static void ieee80211_get_stats2(struct net_device *dev, struct ieee80211_local *local = sdata->local; struct station_info sinfo; struct survey_info survey; + struct ieee80211_link_data *link; int i, q; int z; #define STA_STATS_SURVEY_LEN 7 @@ -128,6 +129,12 @@ static void ieee80211_get_stats2(struct net_device *dev, if (sdata->vif.type == NL80211_IFTYPE_STATION) { sta = sta_info_get_bss(sdata, sdata->deflink.u.mgd.bssid); + if (!sta) { + link = sdata_dereference(sdata->link[0], sdata); + if (link) + sta = sta_info_get_bss(sdata, link->u.mgd.bssid); + } + if (!(sta && !WARN_ON(sta->sdata->dev != dev))) goto do_survey;