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 08/10] net: hibmcge: Implement workqueue and some ethtool_ops functions
Date: Thu, 1 Aug 2024 19:10:44 +0800	[thread overview]
Message-ID: <c44a5759-855a-4a8c-a4d3-d37e16fdebdc@huawei.com> (raw)
In-Reply-To: <b20b5d68-2dab-403c-b37b-084218e001bc@lunn.ch>


on 2024/8/1 9:10, Andrew Lunn wrote:
>> +static void hbg_ethtool_get_drvinfo(struct net_device *netdev,
>> +				    struct ethtool_drvinfo *drvinfo)
>> +{
>> +	strscpy(drvinfo->version, HBG_MOD_VERSION, sizeof(drvinfo->version));
>> +	drvinfo->version[sizeof(drvinfo->version) - 1] = '\0';
> A version is pointless, it tells you nothing useful. If you don't
> touch version, the core will fill it with the uname, so you know
> exactly what kernel this is, which is useful.
>
>> +static u32 hbg_ethtool_get_link(struct net_device *netdev)
>> +{
>> +	struct hbg_priv *priv = netdev_priv(netdev);
>> +
>> +	return priv->mac.link_status;
>> +}
>> +
>> +static int hbg_ethtool_get_ksettings(struct net_device *netdev,
>> +				     struct ethtool_link_ksettings *ksettings)
>> +{
>> +	struct hbg_priv *priv = netdev_priv(netdev);
>> +
>> +	phy_ethtool_ksettings_get(priv->mac.phydev, ksettings);
> You can avoid this wrapper since phy_attach_direct sets netdev->phydev
> to phydev. You can then call phy_ethtool_get_link_ksettings() etc.

Yes, It`s ok

>
>> +static int hbg_ethtool_set_ksettings(struct net_device *netdev,
>> +				     const struct ethtool_link_ksettings *cmd)
>> +{
>> +	struct hbg_priv *priv = netdev_priv(netdev);
>> +
>> +	if (cmd->base.speed == SPEED_1000 && cmd->base.duplex == DUPLEX_HALF)
>> +		return -EINVAL;
> So long as you have told phylib about not supporting 1000Base/Half,
> phy_ethtool_set_link_ksettings() will return an error for you.

okay,

>
>> +static const struct ethtool_ops hbg_ethtool_ops = {
>> +	.get_drvinfo		= hbg_ethtool_get_drvinfo,
>> +	.get_link		= hbg_ethtool_get_link,
> Why not ethtool_op_get_link() ?

It`s a good idea

>
>> +	.get_link_ksettings	= hbg_ethtool_get_ksettings,
>> +	.set_link_ksettings	= hbg_ethtool_set_ksettings,
>> +};
>> +static void hbg_update_link_status(struct hbg_priv *priv)
>> +{
>> +	u32 link;
>> +
>> +	link = hbg_get_link_status(priv);
>> +	if (link == priv->mac.link_status)
>> +		return;
>> +
>> +	priv->mac.link_status = link;
>> +	if (link == HBG_LINK_DOWN) {
>> +		netif_carrier_off(priv->netdev);
>> +		netif_tx_stop_all_queues(priv->netdev);
>> +		dev_info(&priv->pdev->dev, "link down!");
>> +	} else {
>> +		netif_tx_wake_all_queues(priv->netdev);
>> +		netif_carrier_on(priv->netdev);
>> +		dev_info(&priv->pdev->dev, "link up!");
>> +	}
>> +}
> Why do you need this? phylib will poll the PHY once per second and
> call the adjust_link callback whenever the link changes state.

However, we hope that the network port can be linked only when
the PHY and MAC are linked.
The adjust_link callback can ensure that the PHY status is normal,
but cannot ensure that the MAC address is linked.

so, in hbg_get_link_status:
+/* 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;
+}

>
>> @@ -177,12 +226,17 @@ static int hbg_init(struct net_device *netdev)
>>   	ret = hbg_irq_init(priv);
>>   	if (ret)
>>   		return ret;
>> -
>>   	ret = devm_add_action_or_reset(&priv->pdev->dev, hbg_irq_uninit, priv);
> This white space change does not belong here.

Yes, I'll fix that in V2

Thanks again,

Jijie Shao



  reply	other threads:[~2024-08-01 11:10 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
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 [this message]
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=c44a5759-855a-4a8c-a4d3-d37e16fdebdc@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