RE: [EXT] [PATCH net-next] net: enetc: add ethtool::get_channels support

From: Suman Ghosh
Date: Wed Nov 22 2023 - 05:50:09 EST


>Subject: [EXT] [PATCH net-next] net: enetc: add ethtool::get_channels
>support
>
>External Email
>
>----------------------------------------------------------------------
>Since ETHTOOL_MSG_RSS_GET netlink message [1] has been applied to
>ethtool tree, there is a netlink error when using "ethtool -x eno0"
>command to get RSS information from fsl-enetc driver, and the user
>cannot get the information, the error logs are as follows:
>
>root@ls1028ardb:~# ./ethtool -x eno0
>netlink error: Operation not supported
>
>The rationale is that ethtool will issue a ETHTOOL_MSG_CHANNELS_GET
>netlink message to get the number of Rx ring. However, the fsl-enetc
>driver doesn't support ethtool::get_channels, so it directly returns -
>EOPNOTSUPP error.
>
>[1]: https://urldefense.proofpoint.com/v2/url?u=https-
>3A__git.kernel.org_pub_scm_linux_kernel_git_jkirsher_ethtool.git_commit_
>-3Fid-
>3Dffab99c1f3820e21d65686e030dcf2c4fd0a8bd0&d=DwIDAg&c=nKjWec2b6R0mOyPaz7
>xtfQ&r=7si3Xn9Ly-Se1a655kvEPIYU0nQ9HPeN280sEUv5ROU&m=-
>6bW3FaCKau7jio6XSUWDZw3IEqdetIwhU_Bgcv87QcnjyMDGD0slJGQYFlbVx7l&s=8vMevY
>UEvNkyCjMDO278j67ir4daMquk6QK9wR65NSQ&e=
>
>Signed-off-by: Wei Fang <wei.fang@xxxxxxx>
>---
> .../net/ethernet/freescale/enetc/enetc_ethtool.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
>diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
>b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
>index e993ed04ab57..5fa1000b9b83 100644
>--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
>+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
>@@ -740,6 +740,17 @@ static int enetc_set_rxfh(struct net_device *ndev,
>const u32 *indir,
> return err;
> }
>
>+static void enetc_get_channels(struct net_device *ndev,
>+ struct ethtool_channels *ch)
>+{
>+ struct enetc_ndev_priv *priv = netdev_priv(ndev);
>+
>+ ch->max_rx = priv->num_rx_rings;
>+ ch->max_tx = priv->num_tx_rings;
>+ ch->rx_count = priv->num_rx_rings;
>+ ch->tx_count = priv->num_tx_rings;
[Suman] max_rx/tx and rx/tx_count can be different right? To me it seems like max_rx/tx should read the max value not the current configured values.
>+}
>+
> static void enetc_get_ringparam(struct net_device *ndev,
> struct ethtool_ringparam *ring,
> struct kernel_ethtool_ringparam *kernel_ring, @@ -
>1196,6 +1207,7 @@ static const struct ethtool_ops enetc_pf_ethtool_ops =
>{
> .get_rxfh_indir_size = enetc_get_rxfh_indir_size,
> .get_rxfh = enetc_get_rxfh,
> .set_rxfh = enetc_set_rxfh,
>+ .get_channels = enetc_get_channels,
> .get_ringparam = enetc_get_ringparam,
> .get_coalesce = enetc_get_coalesce,
> .set_coalesce = enetc_set_coalesce,
>@@ -1226,6 +1238,7 @@ static const struct ethtool_ops
>enetc_vf_ethtool_ops = {
> .get_rxfh_indir_size = enetc_get_rxfh_indir_size,
> .get_rxfh = enetc_get_rxfh,
> .set_rxfh = enetc_set_rxfh,
>+ .get_channels = enetc_get_channels,
> .get_ringparam = enetc_get_ringparam,
> .get_coalesce = enetc_get_coalesce,
> .set_coalesce = enetc_set_coalesce,
>--
>2.25.1
>