On Sat, May 16, 2020 at 02:00:30AM +0000, Luo bin wrote:
> +static int hinic_set_pauseparam(struct net_device *netdev,
> +                             struct ethtool_pauseparam *pause)
> +{
> +     struct hinic_dev *nic_dev = netdev_priv(netdev);
> +     struct hinic_pause_config pause_info = {0};
> +     struct hinic_port_cap port_cap = {0};
> +     int err;
> +
> +     err = hinic_port_get_cap(nic_dev, &port_cap);
> +     if (err) {
> +             netif_err(nic_dev, drv, netdev,
> +                       "Failed to get port capability\n");
> +             return -EIO;
> +     }
> +
> +     if (pause->autoneg != port_cap.autoneg_state) {
> +             netif_err(nic_dev, drv, netdev,
> +                       "To change autoneg please use: ethtool -s <dev> 
> autoneg <on|off>\n");
> +             return -EOPNOTSUPP;
> +     }

It is unclear at the moment if this is the correct thing to do. There
was a discussion this week involving Russell King and Doug Berger you
might want to read.

> +
> +     pause_info.auto_neg = pause->autoneg;
> +     pause_info.rx_pause = pause->rx_pause;
> +     pause_info.tx_pause = pause->tx_pause;
> +
> +     down(&nic_dev->hwdev->func_to_io.nic_cfg.cfg_lock);
> +     err = hinic_set_hw_pause_info(nic_dev->hwdev, &pause_info);
> +     if (err) {
> +             netif_err(nic_dev, drv, netdev, "Failed to set pauseparam\n");
> +             up(&nic_dev->hwdev->func_to_io.nic_cfg.cfg_lock);
> +             return err;
> +     }
> +     nic_dev->hwdev->func_to_io.nic_cfg.pause_set = true;
> +     nic_dev->hwdev->func_to_io.nic_cfg.auto_neg = pause->autoneg;
> +     nic_dev->hwdev->func_to_io.nic_cfg.rx_pause = pause->rx_pause;
> +     nic_dev->hwdev->func_to_io.nic_cfg.tx_pause = pause->tx_pause;
> +     up(&nic_dev->hwdev->func_to_io.nic_cfg.cfg_lock);
> +
> +     netif_info(nic_dev, drv, netdev, "Set pause options, tx: %s, rx: %s\n",
> +                pause->tx_pause ? "on" : "off",
> +                pause->rx_pause ? "on" : "off");

netif_dbg()

        Andrew

Reply via email to