Commit 8689c051 authored by Arend van Spriel's avatar Arend van Spriel Committed by Johannes Berg

cfg80211: dynamically allocate per-tid stats for station info

With the addition of TXQ stats in the per-tid statistics the struct
station_info grew significantly. This resulted in stack size warnings
due to the structure itself being above the limit for the warnings.

Add an allocation function that those who want to provide per-tid
stats should use to allocate the tid array, i.e.
struct station_info::pertid.

Cc: Toke Høiland-Jørgensen <toke@toke.dk>
Fixes: 52539ca8 ("cfg80211: Expose TXQ stats and parameters to userspace")
Signed-off-by: default avatarArend van Spriel <aspriel@gmail.com>
[johannes: fix missing BIT() and logic by removing]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 57c6cb81
...@@ -1184,6 +1184,7 @@ struct cfg80211_tid_stats { ...@@ -1184,6 +1184,7 @@ struct cfg80211_tid_stats {
* @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
* @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
* (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs. * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
* Note that this doesn't use the @filled bit, but is used if non-NULL.
* @ack_signal: signal strength (in dBm) of the last ACK frame. * @ack_signal: signal strength (in dBm) of the last ACK frame.
* @avg_ack_signal: average rssi value of ack packet for the no of msdu's has * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
* been sent. * been sent.
...@@ -1230,7 +1231,7 @@ struct station_info { ...@@ -1230,7 +1231,7 @@ struct station_info {
u64 rx_beacon; u64 rx_beacon;
u64 rx_duration; u64 rx_duration;
u8 rx_beacon_signal_avg; u8 rx_beacon_signal_avg;
struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1]; struct cfg80211_tid_stats *pertid;
s8 ack_signal; s8 ack_signal;
s8 avg_ack_signal; s8 avg_ack_signal;
}; };
...@@ -5701,6 +5702,13 @@ void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, ...@@ -5701,6 +5702,13 @@ void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
gfp_t gfp); 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 * cfg80211_new_sta - notify userspace about station
......
...@@ -2233,12 +2233,13 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) ...@@ -2233,12 +2233,13 @@ 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_RX_BITRATE);
} }
sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS); if (!cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) {
for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) { for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
struct cfg80211_tid_stats *tidstats = &sinfo->pertid[i]; struct cfg80211_tid_stats *tidstats = &sinfo->pertid[i];
sta_set_tidstats(sta, tidstats, i); sta_set_tidstats(sta, tidstats, i);
} }
}
if (ieee80211_vif_is_mesh(&sdata->vif)) { if (ieee80211_vif_is_mesh(&sdata->vif)) {
#ifdef CONFIG_MAC80211_MESH #ifdef CONFIG_MAC80211_MESH
......
...@@ -4658,7 +4658,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid, ...@@ -4658,7 +4658,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
#undef PUT_SINFO #undef PUT_SINFO
#undef PUT_SINFO_U64 #undef PUT_SINFO_U64
if (sinfo->filled & BIT(NL80211_STA_INFO_TID_STATS)) { if (sinfo->pertid) {
struct nlattr *tidsattr; struct nlattr *tidsattr;
int tid; int tid;
...@@ -4702,6 +4702,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid, ...@@ -4702,6 +4702,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
} }
nla_nest_end(msg, tidsattr); nla_nest_end(msg, tidsattr);
kfree(sinfo->pertid);
} }
nla_nest_end(msg, sinfoattr); nla_nest_end(msg, sinfoattr);
......
...@@ -1787,6 +1787,17 @@ bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range, ...@@ -1787,6 +1787,17 @@ bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
return false; return false;
} }
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;
return 0;
}
EXPORT_SYMBOL(cfg80211_sinfo_alloc_tid_stats);
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
const unsigned char rfc1042_header[] __aligned(2) = const unsigned char rfc1042_header[] __aligned(2) =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment