Re: [PATCH net-next v4 1/2] net: macb: implement ethtool_ops.get|set_channels()
From: Jakub Kicinski <kuba@kernel.org>
Date: 2026-03-19 02:38:27
Also in:
lkml
On Tue, 17 Mar 2026 17:19:08 +0100 Théo Lebrun wrote:
+static int macb_set_channels(struct net_device *netdev,
+ struct ethtool_channels *ch)
+{
+ struct macb *bp = netdev_priv(netdev);
+ unsigned int old_count = bp->num_queues;
+ unsigned int count = ch->combined_count;
+ int ret;
+
+ /*
+ * MACB_CAPS_QUEUE_DISABLE means that the field QUEUE_DISABLE/BIT0 in
+ * the per-queue RBQP register disables queue Rx. If we don't have that
+ * capability we can have multiple queues but we must always run with
+ * all enabled.
+ */
+ if (!(bp->caps & MACB_CAPS_QUEUE_DISABLE))
+ return -EOPNOTSUPP;
+
+ /*
+ * An ideal .set_channels() implementation uses upfront allocated
+ * resources and swaps them in, bringing reliability under memory
+ * pressure. However, here we implement it for memory savings in
+ * setups with less than max number of queues active.
+ *
+ * Signal it by refusing .set_channels() once interface is opened.
+ */
+ if (netif_running(bp->dev))
+ return -EBUSY;
+
+ ret = netif_set_real_num_queues(bp->dev, count, count);
+ if (ret)
+ return ret;
+
+ bp->num_queues = count;
+ return 0;
+}
Looks like some left over here:
drivers/net/ethernet/cadence/macb_main.c:4173:15: warning: unused variable 'old_count' [-Wunused-variable]
4173 | unsigned int old_count = bp->num_queues;
| ^~~~~~~~~