2019-06-01 08:08:46 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-06-04 15:31:56 +00:00
|
|
|
/*
|
|
|
|
* mac80211 ethtool hooks for cfg80211
|
|
|
|
*
|
|
|
|
* Copied from cfg.c - originally
|
|
|
|
* Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
|
|
|
|
* Copyright 2014 Intel Corporation (Author: Johannes Berg)
|
2023-08-28 11:59:57 +00:00
|
|
|
* Copyright (C) 2018, 2022-2023 Intel Corporation
|
2014-06-04 15:31:56 +00:00
|
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <net/cfg80211.h>
|
|
|
|
#include "ieee80211_i.h"
|
|
|
|
#include "sta_info.h"
|
|
|
|
#include "driver-ops.h"
|
|
|
|
|
|
|
|
static int ieee80211_set_ringparam(struct net_device *dev,
|
2021-11-18 12:12:43 +00:00
|
|
|
struct ethtool_ringparam *rp,
|
|
|
|
struct kernel_ethtool_ringparam *kernel_rp,
|
|
|
|
struct netlink_ext_ack *extack)
|
2014-06-04 15:31:56 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
|
2023-09-19 06:40:52 +00:00
|
|
|
int ret;
|
2014-06-04 15:31:56 +00:00
|
|
|
|
|
|
|
if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2023-09-19 06:40:52 +00:00
|
|
|
wiphy_lock(local->hw.wiphy);
|
|
|
|
ret = drv_set_ringparam(local, rp->tx_pending, rp->rx_pending);
|
|
|
|
wiphy_unlock(local->hw.wiphy);
|
|
|
|
|
|
|
|
return ret;
|
2014-06-04 15:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ieee80211_get_ringparam(struct net_device *dev,
|
2021-11-18 12:12:43 +00:00
|
|
|
struct ethtool_ringparam *rp,
|
|
|
|
struct kernel_ethtool_ringparam *kernel_rp,
|
|
|
|
struct netlink_ext_ack *extack)
|
2014-06-04 15:31:56 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
|
|
|
|
|
|
|
|
memset(rp, 0, sizeof(*rp));
|
|
|
|
|
2023-09-19 06:40:52 +00:00
|
|
|
wiphy_lock(local->hw.wiphy);
|
2014-06-04 15:31:56 +00:00
|
|
|
drv_get_ringparam(local, &rp->tx_pending, &rp->tx_max_pending,
|
|
|
|
&rp->rx_pending, &rp->rx_max_pending);
|
2023-09-19 06:40:52 +00:00
|
|
|
wiphy_unlock(local->hw.wiphy);
|
2014-06-04 15:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
|
|
|
|
"rx_packets", "rx_bytes",
|
|
|
|
"rx_duplicates", "rx_fragments", "rx_dropped",
|
2015-04-22 18:55:55 +00:00
|
|
|
"tx_packets", "tx_bytes",
|
2014-06-04 15:31:56 +00:00
|
|
|
"tx_filtered", "tx_retry_failed", "tx_retries",
|
2015-10-16 15:18:11 +00:00
|
|
|
"sta_state", "txrate", "rxrate", "signal",
|
2014-06-04 15:31:56 +00:00
|
|
|
"channel", "noise", "ch_time", "ch_time_busy",
|
|
|
|
"ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
|
|
|
|
};
|
|
|
|
#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
|
|
|
|
|
|
|
|
static int ieee80211_get_sset_count(struct net_device *dev, int sset)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
int rv = 0;
|
|
|
|
|
|
|
|
if (sset == ETH_SS_STATS)
|
|
|
|
rv += STA_STATS_LEN;
|
|
|
|
|
|
|
|
rv += drv_get_et_sset_count(sdata, sset);
|
|
|
|
|
|
|
|
if (rv == 0)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ieee80211_get_stats(struct net_device *dev,
|
|
|
|
struct ethtool_stats *stats,
|
|
|
|
u64 *data)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
struct ieee80211_chanctx_conf *chanctx_conf;
|
|
|
|
struct ieee80211_channel *channel;
|
|
|
|
struct sta_info *sta;
|
|
|
|
struct ieee80211_local *local = sdata->local;
|
2018-05-18 07:57:55 +00:00
|
|
|
struct station_info sinfo;
|
2014-06-04 15:31:56 +00:00
|
|
|
struct survey_info survey;
|
|
|
|
int i, q;
|
|
|
|
#define STA_STATS_SURVEY_LEN 7
|
|
|
|
|
|
|
|
memset(data, 0, sizeof(u64) * STA_STATS_LEN);
|
|
|
|
|
2015-10-16 15:54:47 +00:00
|
|
|
#define ADD_STA_STATS(sta) \
|
|
|
|
do { \
|
2022-08-25 22:33:16 +00:00
|
|
|
data[i++] += sinfo.rx_packets; \
|
|
|
|
data[i++] += sinfo.rx_bytes; \
|
2022-06-14 11:22:49 +00:00
|
|
|
data[i++] += (sta)->rx_stats.num_duplicates; \
|
|
|
|
data[i++] += (sta)->rx_stats.fragments; \
|
2022-08-25 22:33:16 +00:00
|
|
|
data[i++] += sinfo.rx_dropped_misc; \
|
2015-10-16 15:54:47 +00:00
|
|
|
\
|
2018-05-18 07:57:55 +00:00
|
|
|
data[i++] += sinfo.tx_packets; \
|
|
|
|
data[i++] += sinfo.tx_bytes; \
|
2022-06-14 11:22:49 +00:00
|
|
|
data[i++] += (sta)->status_stats.filtered; \
|
2022-08-25 22:33:16 +00:00
|
|
|
data[i++] += sinfo.tx_failed; \
|
|
|
|
data[i++] += sinfo.tx_retries; \
|
2014-06-04 15:31:56 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* For Managed stations, find the single station based on BSSID
|
|
|
|
* and use that. For interface types, iterate through all available
|
|
|
|
* stations and add stats for any station that is assigned to this
|
|
|
|
* network device.
|
|
|
|
*/
|
|
|
|
|
2023-08-28 11:59:57 +00:00
|
|
|
wiphy_lock(local->hw.wiphy);
|
2014-06-04 15:31:56 +00:00
|
|
|
|
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
|
2022-05-16 13:00:15 +00:00
|
|
|
sta = sta_info_get_bss(sdata, sdata->deflink.u.mgd.bssid);
|
2014-06-04 15:31:56 +00:00
|
|
|
|
|
|
|
if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
|
|
|
|
goto do_survey;
|
|
|
|
|
2018-05-18 07:57:55 +00:00
|
|
|
memset(&sinfo, 0, sizeof(sinfo));
|
2018-05-18 09:40:44 +00:00
|
|
|
sta_set_sinfo(sta, &sinfo, false);
|
2014-06-04 15:31:56 +00:00
|
|
|
|
|
|
|
i = 0;
|
2022-06-14 11:22:49 +00:00
|
|
|
ADD_STA_STATS(&sta->deflink);
|
2014-06-04 15:31:56 +00:00
|
|
|
|
|
|
|
data[i++] = sta->sta_state;
|
|
|
|
|
|
|
|
|
2018-06-17 10:06:25 +00:00
|
|
|
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))
|
2018-05-08 12:57:32 +00:00
|
|
|
data[i] = 100000ULL *
|
2018-05-18 07:57:55 +00:00
|
|
|
cfg80211_calculate_bitrate(&sinfo.txrate);
|
2014-06-04 15:31:56 +00:00
|
|
|
i++;
|
2018-06-17 10:06:25 +00:00
|
|
|
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE))
|
2018-05-08 12:57:32 +00:00
|
|
|
data[i] = 100000ULL *
|
2018-05-18 07:57:55 +00:00
|
|
|
cfg80211_calculate_bitrate(&sinfo.rxrate);
|
2014-06-04 15:31:56 +00:00
|
|
|
i++;
|
|
|
|
|
2018-06-17 10:06:25 +00:00
|
|
|
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))
|
2018-05-18 07:57:55 +00:00
|
|
|
data[i] = (u8)sinfo.signal_avg;
|
2014-06-04 15:31:56 +00:00
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
list_for_each_entry(sta, &local->sta_list, list) {
|
|
|
|
/* Make sure this station belongs to the proper dev */
|
|
|
|
if (sta->sdata->dev != dev)
|
|
|
|
continue;
|
|
|
|
|
2018-05-18 07:57:55 +00:00
|
|
|
memset(&sinfo, 0, sizeof(sinfo));
|
2018-05-18 09:40:44 +00:00
|
|
|
sta_set_sinfo(sta, &sinfo, false);
|
2014-06-04 15:31:56 +00:00
|
|
|
i = 0;
|
2022-06-14 11:22:49 +00:00
|
|
|
ADD_STA_STATS(&sta->deflink);
|
2014-06-04 15:31:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do_survey:
|
|
|
|
i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
|
|
|
|
/* Get survey stats for current channel */
|
|
|
|
survey.filled = 0;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
wifi: mac80211: move some future per-link data to bss_conf
To add MLD, reuse the bss_conf structure later for per-link
information, so move some things into it that are per link.
Most transformations were done with the following spatch:
@@
expression sdata;
identifier var = { chanctx_conf, mu_mimo_owner, csa_active, color_change_active, color_change_color };
@@
-sdata->vif.var
+sdata->vif.bss_conf.var
@@
struct ieee80211_vif *vif;
identifier var = { chanctx_conf, mu_mimo_owner, csa_active, color_change_active, color_change_color };
@@
-vif->var
+vif->bss_conf.var
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 11:26:44 +00:00
|
|
|
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
|
2014-06-04 15:31:56 +00:00
|
|
|
if (chanctx_conf)
|
|
|
|
channel = chanctx_conf->def.chan;
|
|
|
|
else
|
|
|
|
channel = NULL;
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
if (channel) {
|
|
|
|
q = 0;
|
|
|
|
do {
|
|
|
|
survey.filled = 0;
|
|
|
|
if (drv_get_survey(local, q, &survey) != 0) {
|
|
|
|
survey.filled = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
q++;
|
|
|
|
} while (channel != survey.channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (survey.filled)
|
|
|
|
data[i++] = survey.channel->center_freq;
|
|
|
|
else
|
|
|
|
data[i++] = 0;
|
|
|
|
if (survey.filled & SURVEY_INFO_NOISE_DBM)
|
|
|
|
data[i++] = (u8)survey.noise;
|
|
|
|
else
|
|
|
|
data[i++] = -1LL;
|
2014-11-14 15:35:34 +00:00
|
|
|
if (survey.filled & SURVEY_INFO_TIME)
|
|
|
|
data[i++] = survey.time;
|
2014-06-04 15:31:56 +00:00
|
|
|
else
|
|
|
|
data[i++] = -1LL;
|
2014-11-14 15:35:34 +00:00
|
|
|
if (survey.filled & SURVEY_INFO_TIME_BUSY)
|
|
|
|
data[i++] = survey.time_busy;
|
2014-06-04 15:31:56 +00:00
|
|
|
else
|
|
|
|
data[i++] = -1LL;
|
2014-11-14 15:35:34 +00:00
|
|
|
if (survey.filled & SURVEY_INFO_TIME_EXT_BUSY)
|
|
|
|
data[i++] = survey.time_ext_busy;
|
2014-06-04 15:31:56 +00:00
|
|
|
else
|
|
|
|
data[i++] = -1LL;
|
2014-11-14 15:35:34 +00:00
|
|
|
if (survey.filled & SURVEY_INFO_TIME_RX)
|
|
|
|
data[i++] = survey.time_rx;
|
2014-06-04 15:31:56 +00:00
|
|
|
else
|
|
|
|
data[i++] = -1LL;
|
2014-11-14 15:35:34 +00:00
|
|
|
if (survey.filled & SURVEY_INFO_TIME_TX)
|
|
|
|
data[i++] = survey.time_tx;
|
2014-06-04 15:31:56 +00:00
|
|
|
else
|
|
|
|
data[i++] = -1LL;
|
|
|
|
|
2023-08-28 11:59:57 +00:00
|
|
|
if (WARN_ON(i != STA_STATS_LEN)) {
|
|
|
|
wiphy_unlock(local->hw.wiphy);
|
2014-06-04 15:31:56 +00:00
|
|
|
return;
|
2023-08-28 11:59:57 +00:00
|
|
|
}
|
2014-06-04 15:31:56 +00:00
|
|
|
|
|
|
|
drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
|
2023-08-28 11:59:57 +00:00
|
|
|
wiphy_unlock(local->hw.wiphy);
|
2014-06-04 15:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ieee80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
|
|
|
int sz_sta_stats = 0;
|
|
|
|
|
|
|
|
if (sset == ETH_SS_STATS) {
|
|
|
|
sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
|
|
|
|
memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
|
|
|
|
}
|
|
|
|
drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ieee80211_get_regs_len(struct net_device *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ieee80211_get_regs(struct net_device *dev,
|
|
|
|
struct ethtool_regs *regs,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
regs->version = wdev->wiphy->hw_version;
|
|
|
|
regs->len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct ethtool_ops ieee80211_ethtool_ops = {
|
|
|
|
.get_drvinfo = cfg80211_get_drvinfo,
|
|
|
|
.get_regs_len = ieee80211_get_regs_len,
|
|
|
|
.get_regs = ieee80211_get_regs,
|
|
|
|
.get_link = ethtool_op_get_link,
|
|
|
|
.get_ringparam = ieee80211_get_ringparam,
|
|
|
|
.set_ringparam = ieee80211_set_ringparam,
|
|
|
|
.get_strings = ieee80211_get_strings,
|
|
|
|
.get_ethtool_stats = ieee80211_get_stats,
|
|
|
|
.get_sset_count = ieee80211_get_sset_count,
|
|
|
|
};
|