static int gve_set_channels()

in build/gve_ethtool.c [519:562]


static int gve_set_channels(struct net_device *netdev,
			    struct ethtool_channels *cmd)
{
	struct gve_priv *priv = netdev_priv(netdev);
	struct gve_queue_config new_tx_cfg = priv->tx_cfg;
	struct gve_queue_config new_rx_cfg = priv->rx_cfg;
	struct ethtool_channels old_settings;
	int new_tx = cmd->tx_count;
	int new_rx = cmd->rx_count;

	gve_get_channels(netdev, &old_settings);

	/* Changing combined is not allowed */
	if (cmd->combined_count != old_settings.combined_count)
		return -EINVAL;

	if (!new_rx || !new_tx)
		return -EINVAL;

	if (priv->num_xdp_queues &&
	    (new_tx != new_rx || (2 * new_tx > priv->tx_cfg.max_queues))) {
		dev_err(&priv->pdev->dev, "XDP load failed: The number of configured RX queues should be equal to the number of configured TX queues and the number of configured RX/TX queues should be less than or equal to half the maximum number of RX/TX queues");
		return -EINVAL;
	}

#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,2,0))
	if (old_settings.rx_count != new_rx && priv->num_flow_rules) {
		dev_err(&priv->pdev->dev,
			"Changing number of RX queues is disabled when flow rules are active");
		return -EBUSY;
	}
#endif /* (LINUX_VERSION_CODE< KERNEL_VERSION(6,2,0)) */

	if (!netif_running(netdev)) {
		priv->tx_cfg.num_queues = new_tx;
		priv->rx_cfg.num_queues = new_rx;
		return 0;
	}

	new_tx_cfg.num_queues = new_tx;
	new_rx_cfg.num_queues = new_rx;

	return gve_adjust_queues(priv, new_rx_cfg, new_tx_cfg);
}