From: Andrew Lunn <andrew@lunn.ch>
To: Luo bin <luobin9@huawei.com>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, luoxianjun@huawei.com,
yin.yinshi@huawei.com, cloud.wangxiaoyun@huawei.com
Subject: Re: [PATCH net-next] hinic: add support to set and get pause param
Date: Sat, 16 May 2020 17:14:11 +0200 [thread overview]
Message-ID: <20200516151411.GT527401@lunn.ch> (raw)
In-Reply-To: <20200516020030.23017-1-luobin9@huawei.com>
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
next prev parent reply other threads:[~2020-05-16 15:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 2:00 [PATCH net-next] hinic: add support to set and get pause param Luo bin
2020-05-16 15:14 ` Andrew Lunn [this message]
2020-05-16 20:25 ` David Miller
2020-05-18 0:51 ` luobin (L)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200516151411.GT527401@lunn.ch \
--to=andrew@lunn.ch \
--cc=cloud.wangxiaoyun@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=luobin9@huawei.com \
--cc=luoxianjun@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=yin.yinshi@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).