Subject: RE: [PATCH net-next 2/5] net: wangxun: add ethtool_ops for ring parameters

From: Jiawen Wu <[email-masked]>
Date: Thu, 23 Nov 2023 17:25:26 +0800

> > +	new_tx_count = clamp_t(u32, ring->tx_pending, WX_MIN_TXD, WX_MAX_TXD);
> > +	new_tx_count = ALIGN(new_tx_count, WX_REQ_TX_DESCRIPTOR_MULTIPLE);
> > +
> > +	new_rx_count = clamp_t(u32, ring->rx_pending, WX_MIN_RXD, WX_MAX_RXD);
> > +	new_rx_count = ALIGN(new_rx_count, WX_REQ_RX_DESCRIPTOR_MULTIPLE);
> > +
> > +	if (new_tx_count == wx->tx_ring_count &&
> > +	    new_rx_count == wx->rx_ring_count)
> > +		return 0;
> > +
> > +	if (!netif_running(wx->netdev)) {
> > +		for (i = 0; i < wx->num_tx_queues; i++)
> > +			wx->tx_ring[i]->count = new_tx_count;
> > +		for (i = 0; i < wx->num_rx_queues; i++)
> > +			wx->rx_ring[i]->count = new_rx_count;
> > +		wx->tx_ring_count = new_tx_count;
> > +		wx->rx_ring_count = new_rx_count;
> > +
> > +		return 0;
> > +	}
> > +
> > +	txgbe_down(wx);
> > +
> > +	err = wx_set_ring(wx, new_tx_count, new_rx_count);
> > +
> > +	txgbe_up(wx);
> > +
> > +	return err;
> 
> Could most of this be moved into the library? It looks pretty similar
> for the two devices.

I tried to move them into the library, but *_down() and *_up() here
involves some different flows for the two devices, it's not easy to handle.