public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <shaojijie@huawei.com>, <yisen.zhuang@huawei.com>,
	<salil.mehta@huawei.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<horms@kernel.org>, <shenjian15@huawei.com>,
	<wangpeiyang1@huawei.com>, <liuyonglong@huawei.com>,
	<sudongming1@huawei.com>, <xujunsheng@huawei.com>,
	<shiyongbang@huawei.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH net-next 03/10] net: hibmcge: Add mdio and hardware configuration supported in this module
Date: Thu, 1 Aug 2024 17:04:44 +0800	[thread overview]
Message-ID: <746dfc27-f880-4bbe-b9bd-c8bb82303ffe@huawei.com> (raw)
In-Reply-To: <ba5b8b48-64b7-417d-a000-2e82e242c399@lunn.ch>

Thanks for reviewing

on 2024/8/1 8:42, Andrew Lunn wrote:
>> +int hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
>> +{
>> +	if (speed != HBG_PORT_MODE_SGMII_10M &&
>> +	    speed != HBG_PORT_MODE_SGMII_100M &&
>> +	    speed != HBG_PORT_MODE_SGMII_1000M)
>> +		return -EOPNOTSUPP;
>> +
>> +	if (duplex != DUPLEX_FULL && duplex != DUPLEX_HALF)
>> +		return -EOPNOTSUPP;
>> +
>> +	if (speed == HBG_PORT_MODE_SGMII_1000M && duplex == DUPLEX_HALF)
>> +		return -EOPNOTSUPP;
> If you tell phylib you don't support 1G/Half, this will not happen.

ok, I will delete it in V2

>
>> +/* sgmii autoneg always enable */
>> +int hbg_hw_sgmii_autoneg(struct hbg_priv *priv)
>> +{
>> +	wait_time = 0;
>> +	do {
>> +		msleep(HBG_HW_AUTONEG_TIMEOUT_STEP);
>> +		wait_time += HBG_HW_AUTONEG_TIMEOUT_STEP;
>> +
>> +		an_state.bits = hbg_reg_read(priv, HBG_REG_AN_NEG_STATE_ADDR);
>> +		if (an_state.an_done)
>> +			break;
>> +	} while (wait_time < HBG_HW_AUTONEG_TIMEOUT_MS);
> include/linux/iopoll.h

Thanks for the guide. These macros will simplify the code.

>
>> +static const u32 hbg_mode_ability[] = {
>> +	ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
>> +	ETHTOOL_LINK_MODE_100baseT_Full_BIT,
>> +	ETHTOOL_LINK_MODE_100baseT_Half_BIT,
>> +	ETHTOOL_LINK_MODE_10baseT_Full_BIT,
>> +	ETHTOOL_LINK_MODE_10baseT_Half_BIT,
>> +	ETHTOOL_LINK_MODE_Autoneg_BIT,
>> +	ETHTOOL_LINK_MODE_TP_BIT,
>> +};
>> +
>> +static int hbg_mac_init(struct hbg_priv *priv)
>> +{
>> +	struct hbg_mac *mac = &priv->mac;
>> +	u32 i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(hbg_mode_ability); i++)
>> +		linkmode_set_bit(hbg_mode_ability[i], mac->supported);
> Humm, odd. Where is this leading...
>
>> +#define HBG_MDIO_FREQUENCE_2_5M		0x1
> I assume it supports other frequencies. You might want to implement
> the DT property 'clock-frequency'. Many modern PHY will work faster
> than 2.5Mhz.

it's a good idea,

>
>> +static int hbg_phy_connect(struct hbg_priv *priv)
>> +{
>> +	struct phy_device *phydev = priv->mac.phydev;
>> +	struct hbg_mac *mac = &priv->mac;
>> +	int ret;
>> +
>> +	linkmode_copy(phydev->supported, mac->supported);
>> +	linkmode_copy(phydev->advertising, mac->supported);
> And here it is. Why? Do you see any other MAC driver doing this?
>
> What you probably want is:
>
> phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
>
> which is what other MAC drivers do.

Yeah, using phy_remove_link_mode, the hbg_mode_ability[] and linkmode_set_bit
of the previous code can be removed together.

Thank you.

>
>> +
>> +	phy_connect_direct(priv->netdev, mac->phydev, hbg_phy_adjust_link,
>> +			   PHY_INTERFACE_MODE_SGMII);
>> +	ret = devm_add_action_or_reset(&priv->pdev->dev,
>> +				       hbg_phy_disconnect, mac->phydev);
>> +	if (ret)
>> +		return ret;
>> +
>> +	phy_attached_info(phydev);
>> +	return 0;
>> +}
>> +
>> +/* include phy link and mac link */
>> +u32 hbg_get_link_status(struct hbg_priv *priv)
>> +{
>> +	struct phy_device *phydev = priv->mac.phydev;
>> +	int ret;
>> +
>> +	if (!phydev)
>> +		return HBG_LINK_DOWN;
>> +
>> +	phy_read_status(phydev);
>> +	if ((phydev->state != PHY_UP && phydev->state != PHY_RUNNING) ||
>> +	    !phydev->link)
>> +		return HBG_LINK_DOWN;
>> +
>> +	ret = hbg_hw_sgmii_autoneg(priv);
>> +	if (ret)
>> +		return HBG_LINK_DOWN;
>> +
>> +	return HBG_LINK_UP;
>> +}
> There should not be any need for this. So why do you have it?

I'll move this to another patch where it's more appropriate.

>
> 	Andrew

Thanks, Jijie


  reply	other threads:[~2024-08-01  9:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31  9:42 [RFC PATCH net-next 00/10] Add support of HIBMCGE Ethernet Driver Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 01/10] net: hibmcge: Add pci table supported in this module Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 02/10] net: hibmcge: Add read/write registers supported through the bar space Jijie Shao
2024-08-05 12:55   ` Simon Horman
2024-08-05 13:08     ` Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 03/10] net: hibmcge: Add mdio and hardware configuration supported in this module Jijie Shao
2024-08-01  0:42   ` Andrew Lunn
2024-08-01  9:04     ` Jijie Shao [this message]
2024-08-01 12:07       ` Andrew Lunn
2024-07-31  9:42 ` [RFC PATCH net-next 04/10] net: hibmcge: Add interrupt " Jijie Shao
2024-07-31 13:14   ` Joe Damato
2024-08-01 11:31     ` Jijie Shao
2024-08-05 12:57   ` Simon Horman
2024-08-05 13:29     ` Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 05/10] net: hibmcge: Implement some .ndo functions Jijie Shao
2024-08-01  0:51   ` Andrew Lunn
2024-08-01  9:13     ` Jijie Shao
2024-08-01 12:18       ` Andrew Lunn
2024-08-01 12:33         ` Jijie Shao
2024-08-01 12:36           ` Andrew Lunn
2024-08-01 13:08             ` Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 06/10] net: hibmcge: Implement .ndo_start_xmit function Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 07/10] net: hibmcge: Implement rx_poll function to receive packets Jijie Shao
2024-07-31 13:23   ` Joe Damato
2024-08-01 11:58     ` Jijie Shao
2024-07-31  9:42 ` [RFC PATCH net-next 08/10] net: hibmcge: Implement workqueue and some ethtool_ops functions Jijie Shao
2024-08-01  1:10   ` Andrew Lunn
2024-08-01 11:10     ` Jijie Shao
2024-08-01 12:26       ` Andrew Lunn
2024-08-01 13:06         ` Jijie Shao
2024-08-01 20:16           ` Andrew Lunn
2024-07-31  9:42 ` [RFC PATCH net-next 09/10] net: hibmcge: Add a Makefile and update Kconfig for hibmcge Jijie Shao
2024-08-01  1:13   ` Andrew Lunn
2024-08-01 12:15     ` Jijie Shao
2024-08-01 12:33       ` Andrew Lunn
2024-07-31  9:42 ` [RFC PATCH net-next 10/10] net: hibmcge: Add maintainer " 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=746dfc27-f880-4bbe-b9bd-c8bb82303ffe@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --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=shenjian15@huawei.com \
    --cc=shiyongbang@huawei.com \
    --cc=sudongming1@huawei.com \
    --cc=wangpeiyang1@huawei.com \
    --cc=xujunsheng@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