From: Tariq Toukan <tariqt@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: <netdev@vger.kernel.org>, Saeed Mahameed <saeedm@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>,
Carolina Jubran <cjubran@nvidia.com>,
Rahul Rameshbabu <rrameshbabu@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net-next 4/5] net/mlx5e: Expose the VF/SF RX drop counter on the representor
Date: Thu, 4 Apr 2024 20:33:56 +0300 [thread overview]
Message-ID: <20240404173357.123307-5-tariqt@nvidia.com> (raw)
In-Reply-To: <20240404173357.123307-1-tariqt@nvidia.com>
From: Carolina Jubran <cjubran@nvidia.com>
Q counters are device-level counters that track specific
events, among which are out_of_buffer events. These events
occur when packets are dropped due to a lack of receive
buffer in the RX queue.
Expose the total number of rx_out_of_buffer events on the
VF/SF to their respective representor, using the
"ethtool -S devname --all-groups|--groups rep-port" under the
name of "rep-port-out_of_buf".
The "rep-port-out_of_buf" equals the sum of all
Q counters rx_out_of_buffer values allocated on the VF/SF.
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 48 +++++++++++++++++++
.../ethernet/mellanox/mlx5/core/en_stats.h | 3 ++
2 files changed, 51 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index a74ee698671c..691f6d7fe0c6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -273,6 +273,44 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
kvfree(out);
}
+static int mlx5e_rep_query_q_counter(struct mlx5_core_dev *mdev, int vport, void *out)
+{
+ u32 in[MLX5_ST_SZ_DW(query_q_counter_in)] = {};
+
+ MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
+ MLX5_SET(query_q_counter_in, in, other_vport, 1);
+ MLX5_SET(query_q_counter_in, in, vport_number, vport);
+ MLX5_SET(query_q_counter_in, in, aggregate, 1);
+
+ return mlx5_cmd_exec_inout(mdev, query_q_counter, in, out);
+}
+
+int mlx5e_stats_rep_port_get(struct mlx5e_priv *priv,
+ struct ethtool_rep_port_stats *rep_port_stats,
+ struct netlink_ext_ack *extack)
+{
+ u32 out[MLX5_ST_SZ_DW(query_q_counter_out)] = {};
+ struct mlx5e_rep_priv *rpriv = priv->ppriv;
+ struct mlx5_eswitch_rep *rep = rpriv->rep;
+ int err;
+
+ if (!MLX5_CAP_GEN(priv->mdev, q_counter_other_vport) ||
+ !MLX5_CAP_GEN(priv->mdev, q_counter_aggregation)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Representor port stats is not supported on this device");
+ return -EOPNOTSUPP;
+ }
+
+ err = mlx5e_rep_query_q_counter(priv->mdev, rep->vport, out);
+ if (err) {
+ NL_SET_ERR_MSG_MOD(extack, "Failed reading stats on vport");
+ return err;
+ }
+ rep_port_stats->out_of_buf = MLX5_GET(query_q_counter_out, out, out_of_buffer);
+
+ return 0;
+}
+
static void mlx5e_rep_get_strings(struct net_device *dev,
u32 stringset, u8 *data)
{
@@ -377,6 +415,15 @@ static u32 mlx5e_rep_get_rxfh_indir_size(struct net_device *netdev)
return mlx5e_ethtool_get_rxfh_indir_size(priv);
}
+static int mlx5e_rep_get_port_stats(struct net_device *netdev,
+ struct ethtool_rep_port_stats *rep_port_stats,
+ struct netlink_ext_ack *extack)
+{
+ struct mlx5e_priv *priv = netdev_priv(netdev);
+
+ return mlx5e_stats_rep_port_get(priv, rep_port_stats, extack);
+}
+
static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES |
@@ -394,6 +441,7 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
.set_coalesce = mlx5e_rep_set_coalesce,
.get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size,
.get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size,
+ .get_rep_port_stats = mlx5e_rep_get_port_stats,
};
static void mlx5e_sqs2vport_stop(struct mlx5_eswitch *esw,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index b71e3fdf92c5..ffddbe4d6543 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -128,6 +128,9 @@ void mlx5e_stats_eth_ctrl_get(struct mlx5e_priv *priv,
void mlx5e_stats_rmon_get(struct mlx5e_priv *priv,
struct ethtool_rmon_stats *rmon,
const struct ethtool_rmon_hist_range **ranges);
+int mlx5e_stats_rep_port_get(struct mlx5e_priv *priv,
+ struct ethtool_rep_port_stats *rep_port_stats,
+ struct netlink_ext_ack *extack);
void mlx5e_get_link_ext_stats(struct net_device *dev,
struct ethtool_link_ext_stats *stats);
--
2.44.0
next prev parent reply other threads:[~2024-04-04 17:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 17:33 [PATCH net-next 0/5] mlx5e rc2 misc patches Tariq Toukan
2024-04-04 17:33 ` [PATCH net-next 1/5] net/mlx5e: Extract checking of FEC support for a link mode Tariq Toukan
2024-04-04 17:33 ` [PATCH net-next 2/5] net/mlx5e: Support FEC settings for 100G/lane modes Tariq Toukan
2024-04-04 17:33 ` [PATCH net-next 3/5] ethtool: add interface to read representor Rx statistics Tariq Toukan
2024-04-06 4:53 ` Jakub Kicinski
2024-04-06 5:25 ` Rahul Rameshbabu
2024-04-06 5:46 ` Jakub Kicinski
2024-04-04 17:33 ` Tariq Toukan [this message]
2024-04-04 17:33 ` [PATCH net-next 5/5] net/mlx5e: Un-expose functions in en.h Tariq Toukan
2024-04-05 5:53 ` Kalesh Anakkur Purayil
2024-04-06 4:56 ` [PATCH net-next 0/5] mlx5e rc2 misc patches Jakub Kicinski
2024-04-06 5:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240404173357.123307-5-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rrameshbabu@nvidia.com \
--cc=saeedm@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).