Re: [PATCH net-next v27 10/13] rtase: Implement ethtool function
From: Jakub Kicinski
Date: Thu Aug 15 2024 - 21:46:45 EST
On Mon, 12 Aug 2024 14:35:36 +0800 Justin Lai wrote:
> +static void rtase_get_drvinfo(struct net_device *dev,
> + struct ethtool_drvinfo *info)
> +{
> + const struct rtase_private *tp = netdev_priv(dev);
> +
> + strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
> + strscpy(info->bus_info, pci_name(tp->pdev), sizeof(info->bus_info));
> +}
This shouldn't be necessary, can you delete this function from the
driver and check if the output of ethtool -i changes?
ethtool_get_drvinfo() should fill this in for you.
> +static void rtase_get_pauseparam(struct net_device *dev,
> + struct ethtool_pauseparam *pause)
> +{
> + const struct rtase_private *tp = netdev_priv(dev);
> + u16 value = rtase_r16(tp, RTASE_CPLUS_CMD);
> +
> + pause->autoneg = AUTONEG_DISABLE;
> +
> + if ((value & (RTASE_FORCE_TXFLOW_EN | RTASE_FORCE_RXFLOW_EN)) ==
> + (RTASE_FORCE_TXFLOW_EN | RTASE_FORCE_RXFLOW_EN)) {
> + pause->rx_pause = 1;
> + pause->tx_pause = 1;
> + } else if (value & RTASE_FORCE_TXFLOW_EN) {
> + pause->tx_pause = 1;
> + } else if (value & RTASE_FORCE_RXFLOW_EN) {
> + pause->rx_pause = 1;
> + }
This 3 if statements can be replaced with just two lines:
pause->rx_pause = !!(value & RTASE_FORCE_RXFLOW_EN);
pause->tx_pause = !!(value & RTASE_FORCE_TXFLOW_EN);