lkml.org 
[lkml]   [2023]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH net-next 05/11] net: enetc: add support for ethtool --show-channels
    Date
    In a strange twist of events, some libraries such as libbpf perform an
    ETHTOOL_GCHANNELS ioctl to find out the max number of queues owned by a
    device, number which in turn is used for attaching XDP sockets to
    queues.

    To add compatibility with libbpf, it is therefore desirable to report
    something to this ethtool callback.

    According to the ethtool man page, "A channel is an IRQ and the set of
    queues that can trigger that IRQ".

    In enetc (embedded in NXP LS1028A, a dual core SoC, and LS1018A, a
    single core SoC), the enetc_alloc_msix() function allocates a number of
    MSI-X interrupt vectors equal to priv->bdr_int_num (which in turn is
    equal to the number of CPUs, 2 or 1). Each interrupt vector has 1 RX
    ring to process (there are more than 2 RX rings available on an ENETC
    port, but the driver only uses up to 2). In addition, the up to 8 TX
    rings are distributed in a round-robing manner between the up to 2
    available interrupt vectors.

    Therefore, even if we have more resources than 2 RX rings, given the
    definitions, we can only report 2 combined channels. So do that.

    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    ---
    drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 10 ++++++++++
    1 file changed, 10 insertions(+)

    diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
    index 05e2bad609c6..dda02f8d102a 100644
    --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
    +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
    @@ -863,6 +863,15 @@ static int enetc_set_link_ksettings(struct net_device *dev,
    return phylink_ethtool_ksettings_set(priv->phylink, cmd);
    }

    +static void enetc_get_channels(struct net_device *ndev,
    + struct ethtool_channels *chan)
    +{
    + struct enetc_ndev_priv *priv = netdev_priv(ndev);
    +
    + chan->max_combined = priv->bdr_int_num;
    + chan->combined_count = priv->bdr_int_num;
    +}
    +
    static const struct ethtool_ops enetc_pf_ethtool_ops = {
    .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
    ETHTOOL_COALESCE_MAX_FRAMES |
    @@ -893,6 +902,7 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = {
    .set_wol = enetc_set_wol,
    .get_pauseparam = enetc_get_pauseparam,
    .set_pauseparam = enetc_set_pauseparam,
    + .get_channels = enetc_get_channels,
    };

    static const struct ethtool_ops enetc_vf_ethtool_ops = {
    --
    2.34.1
    \
     
     \ /
      Last update: 2023-03-27 00:10    [W:4.142 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site