From patchwork Thu May 10 11:50:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 10391731 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 22C5260153 for ; Thu, 10 May 2018 11:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12CBC28A9C for ; Thu, 10 May 2018 11:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10A6A28AA4; Thu, 10 May 2018 11:50:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B48A28A9C for ; Thu, 10 May 2018 11:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757120AbeEJLuQ (ORCPT ); Thu, 10 May 2018 07:50:16 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:38170 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757098AbeEJLuP (ORCPT ); Thu, 10 May 2018 07:50:15 -0400 Received: by mail-wm0-f65.google.com with SMTP id y189-v6so3846854wmc.3 for ; Thu, 10 May 2018 04:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:references:to:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=oYzSn1ViFBixUi6Gd220k8zGedEMIknAhbMfJK95Akc=; b=d4bcb9/BOYo/PB7Z/AfjGl19s41p0G27XnSmzmGymKkxVaPWO8+3wQpsUsOKTAjs9i 0+E2TrZgJejFG94H/hfnHy4y43ypdbHcbbkOf5UNuLs9pa97tglVP9zSMVZIFszlpX6t laWbtFZ/oeJqYEb29hUd+xwpcy3IJDyelhgc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:to:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=oYzSn1ViFBixUi6Gd220k8zGedEMIknAhbMfJK95Akc=; b=M8lcciMLs94tUlcZAZSfEZu4p07rFecr7yfAUG2Z7rk4gjqeP9gyFjfhgqLnIQTN/3 Bg5iHJD7KYtw/mvEHbEIuS4TTV+VgpFhzZaCUoKv8VxEp5+1zLSp7FPTY/yCbEgmDHcu f2XnW7PW9FVB6ZXg+dUhsZciGIZsjF6IDDLixhX6OtCk/Q5+2NML8Z3nQwclzVsMrwva kM7BJv1Tew1ntEZVkovShz5jOkyIoVTxr1yo7+Cdm6E3HUxQJBCoEKHm4WkqdQ0eHF9j 757KmI1g75I96+Cj4gHMWq2GvwjRzLMdY/IVzTYfstLSXDRTfY076eZ62mv+WEAt2QVJ wIkQ== X-Gm-Message-State: ALKqPwcUQVeovqdzC9L/cE94MG08kMe0Tg+jUaJ5YhpcgLrJjuRPD5zG GlitIUxem/rZZBJoRUsbzmcbNW56QaY= X-Google-Smtp-Source: AB8JxZr/QxjBlTMOmTONCz+7DPKBgoVZz7jIUFil147SxA+lhK+ktHUXcTSJ54hBm0K1GezrbM7Rbg== X-Received: by 2002:a50:b412:: with SMTP id b18-v6mr1934606edh.244.1525953013375; Thu, 10 May 2018 04:50:13 -0700 (PDT) Received: from [192.168.178.129] (f140230.upc-f.chello.nl. [80.56.140.230]) by smtp.gmail.com with ESMTPSA id m15-v6sm542585edj.49.2018.05.10.04.50.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 May 2018 04:50:12 -0700 (PDT) Subject: [RESEND PATCH] cfg80211: dynamically allocate per-tid stats for station info References: <5AF430B2.2060903@broadcom.com> To: Johannes Berg Cc: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , linux-wireless From: Arend van Spriel X-Forwarded-Message-Id: <5AF430B2.2060903@broadcom.com> Message-ID: <5AF431F4.9060408@broadcom.com> Date: Thu, 10 May 2018 13:50:12 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <5AF430B2.2060903@broadcom.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arend van Spriel With the addition of TXQ stats in the per-tid statistics the struct station_info grew significantly. This resulted in stack limit warnings like below: CC [M] drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.o drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function ‘brcmf_notify_connect_status_ap’: drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:5530:1: error: the frame size of 1592 bytes is larger than 1024 bytes This patch adds an allocation function that those who want to provide per-tid stats should use to allocate the tid array, ie. struct station_info::pertid. Cc: Toke Høiland-Jørgensen Fixes: 52539ca89f36 ("cfg80211: Expose TXQ stats and parameters to userspace") Signed-off-by: Arend van Spriel --- + linux-wireless list Johannes, Toke, Here an alternative approach. Currently the only cfg80211-based driver providing per-tid stats is mac80211. This patch only changes mac80211 and the other driver can keep using stack allocation. Even mac80211 could if wanted, but I left that part as is. I considered making the new helper more generic and allocate 'pertid' based on filled flags, ie.: int cfg80211_sinfo_prepare(struct station_info *sinfo, gfp_t gfp) { : if (sinfo->filled & BIT(NL80211_STA_INFO_TID_STATS)) { sinfo->pertid = kzalloc(..., gfp); if (!pertid) return -ENOMEM; } : return 0; } but decided to stick close to the issue. Regards, Arend --- include/net/cfg80211.h | 9 ++++++++- net/mac80211/sta_info.c | 11 ++++++----- net/wireless/nl80211.c | 4 +++- net/wireless/util.c | 12 ++++++++++++ 4 files changed, 29 insertions(+), 7 deletions(-) int i; diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8db6071..784377a 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1230,7 +1230,7 @@ struct station_info { u64 rx_beacon; u64 rx_duration; u8 rx_beacon_signal_avg; - struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1]; + struct cfg80211_tid_stats *pertid; s8 ack_signal; s8 avg_ack_signal; }; @@ -5701,6 +5701,13 @@ void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, struct ieee80211_channel *chan, gfp_t gfp); +/** + * cfg80211_sinfo_alloc_tid_stats - allocate per-tid statistics. + * + * @sinfo: the station information + * @gfp: allocation flags + */ +int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp); /** * cfg80211_new_sta - notify userspace about station diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 43f34aa..25e8b15 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2233,11 +2233,12 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE); } - sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS); - for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) { - struct cfg80211_tid_stats *tidstats = &sinfo->pertid[i]; - - sta_set_tidstats(sta, tidstats, i); + if (!cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) { + for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) { + struct cfg80211_tid_stats *tidstats = &sinfo->pertid[i]; + + sta_set_tidstats(sta, tidstats, i); + } } if (ieee80211_vif_is_mesh(&sdata->vif)) { diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index f7715b8..e51cae7 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -4663,7 +4663,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid, int tid; tidsattr = nla_nest_start(msg, NL80211_STA_INFO_TID_STATS); - if (!tidsattr) + if (!tidsattr || !sinfo->pertid) goto nla_put_failure; for (tid = 0; tid < IEEE80211_NUM_TIDS + 1; tid++) { @@ -4702,6 +4702,8 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid, } nla_nest_end(msg, tidsattr); + + kfree(sinfo->pertid); } nla_nest_end(msg, sinfoattr); diff --git a/net/wireless/util.c b/net/wireless/util.c index d112e9a..b956c23fe 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1750,6 +1750,18 @@ int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr, } EXPORT_SYMBOL(cfg80211_get_station); +int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp) +{ + sinfo->pertid = kcalloc(sizeof(*(sinfo->pertid)), + IEEE80211_NUM_TIDS + 1, gfp); + if (!sinfo->pertid) + return -ENOMEM; + + sinfo->filled |= NL80211_STA_INFO_TID_STATS; + return 0; +} +EXPORT_SYMBOL(cfg80211_sinfo_alloc_tid_stats); + void cfg80211_free_nan_func(struct cfg80211_nan_func *f) {