linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
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 v2 1/5] hinic: add support to set and get pause params
Date: Tue, 23 Jun 2020 14:54:21 -0700	[thread overview]
Message-ID: <20200623145421.163d22fd@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200623142409.19081-2-luobin9@huawei.com>

On Tue, 23 Jun 2020 22:24:05 +0800 Luo bin wrote:
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> index e9e6f4c9309a..e69edb01fd9b 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> @@ -467,6 +467,7 @@ int hinic_open(struct net_device *netdev)
>  	if (ret)
>  		netif_warn(nic_dev, drv, netdev,
>  			   "Failed to revert port state\n");
> +

Unrelated chunk, please drop.

>  err_port_state:
>  	free_rxqs(nic_dev);
>  	if (nic_dev->flags & HINIC_RSS_ENABLE) {
> @@ -887,6 +888,26 @@ static void netdev_features_init(struct net_device *netdev)
>  	netdev->features = netdev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;
>  }
>  
> +static void hinic_refresh_nic_cfg(struct hinic_dev *nic_dev)
> +{
> +	struct hinic_nic_cfg *nic_cfg = &nic_dev->hwdev->func_to_io.nic_cfg;
> +	struct hinic_pause_config pause_info = {0};
> +	struct hinic_port_cap port_cap = {0};
> +
> +	if (hinic_port_get_cap(nic_dev, &port_cap))
> +		return;
> +
> +	mutex_lock(&nic_cfg->cfg_mutex);
> +	if (nic_cfg->pause_set || !port_cap.autoneg_state) {
> +		nic_cfg->auto_neg = port_cap.autoneg_state;
> +		pause_info.auto_neg = nic_cfg->auto_neg;
> +		pause_info.rx_pause = nic_cfg->rx_pause;
> +		pause_info.tx_pause = nic_cfg->tx_pause;
> +		hinic_set_hw_pause_info(nic_dev->hwdev, &pause_info);
> +	}
> +	mutex_unlock(&nic_cfg->cfg_mutex);
> +}
> +
>  /**
>   * link_status_event_handler - link event handler
>   * @handle: nic device for the handler
> @@ -918,6 +939,9 @@ static void link_status_event_handler(void *handle, void *buf_in, u16 in_size,
>  
>  		up(&nic_dev->mgmt_lock);
>  
> +		if (!HINIC_IS_VF(nic_dev->hwdev->hwif))
> +			hinic_refresh_nic_cfg(nic_dev);
> +
>  		netif_info(nic_dev, drv, nic_dev->netdev, "HINIC_Link is UP\n");
>  	} else {
>  		down(&nic_dev->mgmt_lock);
> @@ -950,26 +974,38 @@ static int set_features(struct hinic_dev *nic_dev,
>  	u32 csum_en = HINIC_RX_CSUM_OFFLOAD_EN;
>  	int err = 0;
>  
> -	if (changed & NETIF_F_TSO)
> +	if (changed & NETIF_F_TSO) {
>  		err = hinic_port_set_tso(nic_dev, (features & NETIF_F_TSO) ?
>  					 HINIC_TSO_ENABLE : HINIC_TSO_DISABLE);
> +		if (err)
> +			return err;
> +	}
>  
> -	if (changed & NETIF_F_RXCSUM)
> +	if (changed & NETIF_F_RXCSUM) {
>  		err = hinic_set_rx_csum_offload(nic_dev, csum_en);
> +		if (err)
> +			return err;
> +	}
>  
>  	if (changed & NETIF_F_LRO) {
>  		err = hinic_set_rx_lro_state(nic_dev,
>  					     !!(features & NETIF_F_LRO),
>  					     HINIC_LRO_RX_TIMER_DEFAULT,
>  					     HINIC_LRO_MAX_WQE_NUM_DEFAULT);
> +		if (err)
> +			return err;
>  	}
>  
> -	if (changed & NETIF_F_HW_VLAN_CTAG_RX)
> +	if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
>  		err = hinic_set_rx_vlan_offload(nic_dev,
>  						!!(features &
>  						   NETIF_F_HW_VLAN_CTAG_RX));
> +		if (err)
> +			return err;
> +	}

I missed this on v1, but this looks broken, multiple features may be
changed at the same time. If user requests RXCSUM and LRO to be changed
and LRO change fails the RXCSUM will be left in a different state than
dev->features indicates.
  
> -	return err;
> +	/* enable pause and disable pfc by default */
> +	return hinic_dcb_set_pfc(nic_dev->hwdev, 0, 0);

Why do you disable PFC every time features are changed?

> +int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap)

This is only ever called with 0, 0 as parameters.

  reply	other threads:[~2020-06-23 21:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 14:24 [PATCH net-next v2 0/5] hinic: add some ethtool ops support Luo bin
2020-06-23 14:24 ` [PATCH net-next v2 1/5] hinic: add support to set and get pause params Luo bin
2020-06-23 21:54   ` Jakub Kicinski [this message]
2020-06-27  1:30     ` luobin (L)
2020-06-23 14:24 ` [PATCH net-next v2 2/5] hinic: add support to set and get irq coalesce Luo bin
2020-06-23 21:56   ` Jakub Kicinski
2020-06-23 14:24 ` [PATCH net-next v2 3/5] hinic: add self test support Luo bin
2020-06-23 14:24 ` [PATCH net-next v2 4/5] hinic: add support to identify physical device Luo bin
2020-06-23 21:58   ` Jakub Kicinski
2020-06-23 14:24 ` [PATCH net-next v2 5/5] hinic: add support to get eeprom information Luo bin
2020-06-23 22:02   ` Jakub Kicinski
2020-06-27  2:11     ` 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=20200623145421.163d22fd@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --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).