static int gve_set_coalesce()

in build/gve_ethtool.c [874:918]


static int gve_set_coalesce(struct net_device *netdev,
			    struct ethtool_coalesce *ec
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8,6) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9,0)) || RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,2)
			    ,
			    struct kernel_ethtool_coalesce *kernel_ec,
			    struct netlink_ext_ack *extack
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8,6) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9,0)) || RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,2) */
			    )
{
	struct gve_priv *priv = netdev_priv(netdev);
	u32 tx_usecs_orig = priv->tx_coalesce_usecs;
	u32 rx_usecs_orig = priv->rx_coalesce_usecs;
	int idx;

	if (gve_is_gqi(priv))
		return -EOPNOTSUPP;

	if (ec->tx_coalesce_usecs > GVE_MAX_ITR_INTERVAL_DQO ||
	    ec->rx_coalesce_usecs > GVE_MAX_ITR_INTERVAL_DQO)
		return -EINVAL;
	priv->tx_coalesce_usecs = ec->tx_coalesce_usecs;
	priv->rx_coalesce_usecs = ec->rx_coalesce_usecs;

	if (tx_usecs_orig != priv->tx_coalesce_usecs) {
		for (idx = 0; idx < priv->tx_cfg.num_queues; idx++) {
			int ntfy_idx = gve_tx_idx_to_ntfy(priv, idx);
			struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];

			gve_set_itr_coalesce_usecs_dqo(priv, block,
						       priv->tx_coalesce_usecs);
		}
	}

	if (rx_usecs_orig != priv->rx_coalesce_usecs) {
		for (idx = 0; idx < priv->rx_cfg.num_queues; idx++) {
			int ntfy_idx = gve_rx_idx_to_ntfy(priv, idx);
			struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];

			gve_set_itr_coalesce_usecs_dqo(priv, block,
						       priv->rx_coalesce_usecs);
		}
	}

	return 0;
}