[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4a36b46d-3f71-430f-8158-da58769ae52a@lunn.ch>
Date: Wed, 22 Nov 2023 17:24:20 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jiawen Wu <jiawenwu@...stnetic.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, linux@...linux.org.uk,
horms@...nel.org, mengyuanlou@...-swift.com
Subject: Re: [PATCH net-next 2/5] net: wangxun: add ethtool_ops for ring
parameters
> +int wx_set_ring(struct wx *wx, u32 new_tx_count, u32 new_rx_count)
> +{
> + struct wx_ring *temp_ring;
> + int i, err = 0;
> +
> + /* allocate temporary buffer to store rings in */
> + i = max_t(int, wx->num_tx_queues, wx->num_rx_queues);
> + temp_ring = vmalloc(i * sizeof(struct wx_ring));
So it is O.K. for the pages to be scattered around the physical
address space, not contiguous. Does this memory ever get passed to the
hardware?
> +static int ngbe_set_ringparam(struct net_device *netdev,
> + struct ethtool_ringparam *ring,
> + struct kernel_ethtool_ringparam *kernel_ring,
> + struct netlink_ext_ack *extack)
> +{
> + struct wx *wx = netdev_priv(netdev);
> + u32 new_rx_count, new_tx_count;
> + int i, err = 0;
> +
> + if (ring->rx_mini_pending || ring->rx_jumbo_pending)
> + return -EINVAL;
EOPNOTSUP would be better, to indicate you don't support it, not that
it is invalid.
> + if (ring->rx_mini_pending || ring->rx_jumbo_pending)
> + return -EINVAL;
Same here.
> +
> + 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.
Andrew
Powered by blists - more mailing lists