@@ -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 = {
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(+)