netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wojciech Drewek <wojciech.drewek@intel.com>
To: Jijie Shao <shaojijie@huawei.com>, <yisen.zhuang@huawei.com>,
	<salil.mehta@huawei.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <shenjian15@huawei.com>, <wangjie125@huawei.com>,
	<liuyonglong@huawei.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2 net 2/2] net: hns: fix fake link up on xge port
Date: Mon, 4 Dec 2023 11:19:59 +0100	[thread overview]
Message-ID: <c382dc51-3a3c-4c79-90c0-13e2e716d0a9@intel.com> (raw)
In-Reply-To: <20231204011051.4055031-3-shaojijie@huawei.com>



On 04.12.2023 02:10, Jijie Shao wrote:
> From: Yonglong Liu <liuyonglong@huawei.com>
> 
> If a xge port just connect with an optical module and no fiber,
> it may have a fake link up because there may be interference on
> the hardware. This patch adds an anti-shake to avoid the problem.
> And the time of anti-shake is base on tests.
> 
> Fixes: b917078c1c10 ("net: hns: Add ACPI support to check SFP present")
> Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
>  .../net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 29 +++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> index 928d934cb21a..c3abb14edd51 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> @@ -66,6 +66,27 @@ static enum mac_mode hns_get_enet_interface(const struct hns_mac_cb *mac_cb)
>  	}
>  }
>  
> +static void hns_mac_link_anti_shake(struct mac_driver *mac_ctrl_drv,
> +				    u32 *link_status)
> +{

It would be cleaner to return the link status than using output arg IMO

> +#define HNS_MAC_LINK_WAIT_TIME 5
> +#define HNS_MAC_LINK_WAIT_CNT 40
> +
> +	int i;
> +
> +	if (!mac_ctrl_drv->get_link_status) {
> +		*link_status = 0;
> +		return;
> +	}
> +
> +	for (i = 0; i < HNS_MAC_LINK_WAIT_CNT; i++) {
> +		msleep(HNS_MAC_LINK_WAIT_TIME);
> +		mac_ctrl_drv->get_link_status(mac_ctrl_drv, link_status);
> +		if (!*link_status)
> +			break;
> +	}
> +}
> +
>  void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status)
>  {
>  	struct mac_driver *mac_ctrl_drv;
> @@ -83,6 +104,14 @@ void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status)
>  							       &sfp_prsnt);
>  		if (!ret)
>  			*link_status = *link_status && sfp_prsnt;
> +
> +		/* for FIBER port, it may have a fake link up.
> +		 * when the link status changes from down to up, we need to do
> +		 * anti-shake. the anti-shake time is base on tests.
> +		 * only FIBER port need to do this.
> +		 */
> +		if (*link_status && !mac_cb->link)
> +			hns_mac_link_anti_shake(mac_ctrl_drv, link_status);
>  	}
>  
>  	mac_cb->link = *link_status;

  reply	other threads:[~2023-12-04 10:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04  1:10 [PATCH V2 net 0/2] There are some bugfix for the HNS ethernet driver Jijie Shao
2023-12-04  1:10 ` [PATCH V2 net 1/2] net: hns: fix wrong head when modify the tx feature when sending packets Jijie Shao
2023-12-04 10:15   ` Wojciech Drewek
2023-12-04 14:41     ` Jijie Shao
2023-12-04  1:10 ` [PATCH V2 net 2/2] net: hns: fix fake link up on xge port Jijie Shao
2023-12-04 10:19   ` Wojciech Drewek [this message]
2023-12-04 14:43     ` Jijie Shao

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=c382dc51-3a3c-4c79-90c0-13e2e716d0a9@intel.com \
    --to=wojciech.drewek@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=salil.mehta@huawei.com \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=wangjie125@huawei.com \
    --cc=yisen.zhuang@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).