mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: <shaojijie@huawei.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<andrew+netdev@lunn.ch>, <horms@kernel.org>,
	<shenjian15@huawei.com>, <liuyonglong@huawei.com>,
	<chenhao418@huawei.com>, <jonathan.cameron@huawei.com>,
	<shameerali.kolothum.thodi@huawei.com>, <salil.mehta@huawei.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 net-next 1/3] net: hibmcge: support scenario without PHY
Date: Mon, 30 Jun 2025 22:58:35 +0800	[thread overview]
Message-ID: <d591574c-80e5-494d-8b67-7b85594fd821@huawei.com> (raw)
In-Reply-To: <aGJNHsCMwVLqbAq0@soc-5CG4396X81.clients.intel.com>


on 2025/6/30 16:38, Larysa Zaremba wrote:
> On Thu, Jun 26, 2025 at 10:06:11AM +0800, Jijie Shao wrote:
>> Currently, the driver uses phylib to operate PHY by default.
>>
>> On some boards, the PHY device is separated from the MAC device.
>> As a result, the hibmcge driver cannot operate the PHY device.
>>
>> In this patch, the driver determines whether a PHY is available
>> based on register configuration. If no PHY is available,
>> the driver use fixed_phy to register fake phydev.
> uses/will use

Thank you, if I need to send v4 for other reasons, I will modify it together.

>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> Some minor cosmetic problems, but overall seems like you nicely incorporated v2
> feedback.
>
> Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
>
>> ---
>> ChangeLog:
>> v2 -> v3:
>>    - Use fixed_phy to re-implement the no-phy scenario, suggested by Andrew Lunn
>>    v2: https://lore.kernel.org/all/20250623034129.838246-1-shaojijie@huawei.com/
>> ---
>>   .../net/ethernet/hisilicon/hibmcge/hbg_mdio.c | 38 +++++++++++++++++++
>>   1 file changed, 38 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
>> index 42b0083c9193..41558fe7770c 100644
>> --- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
>> +++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
>> @@ -2,6 +2,7 @@
>>   // Copyright (c) 2024 Hisilicon Limited.
>>   
>>   #include <linux/phy.h>
>> +#include <linux/phy_fixed.h>
>>   #include <linux/rtnetlink.h>
>>   #include "hbg_common.h"
>>   #include "hbg_hw.h"
>> @@ -19,6 +20,7 @@
>>   #define HBG_MDIO_OP_INTERVAL_US		(5 * 1000)
>>   
>>   #define HBG_NP_LINK_FAIL_RETRY_TIMES	5
>> +#define HBG_NO_PHY	0xFF
> Number does not align with one in the previous line.


Because the macro name is much shorter than the above,
there is a tab between the numbers and the name in these two lines.

Thanks,
Jijie Shao

>
>>   
>>   static void hbg_mdio_set_command(struct hbg_mac *mac, u32 cmd)
>>   {
>> @@ -229,6 +231,39 @@ void hbg_phy_stop(struct hbg_priv *priv)
>>   	phy_stop(priv->mac.phydev);
>>   }
>>   
>> +static void hbg_fixed_phy_uninit(void *data)
>> +{
>> +	fixed_phy_unregister((struct phy_device *)data);
>> +}
>> +
>> +static int hbg_fixed_phy_init(struct hbg_priv *priv)
>> +{
>> +	struct fixed_phy_status hbg_fixed_phy_status = {
>> +		.link = 1,
>> +		.speed = SPEED_1000,
>> +		.duplex = DUPLEX_FULL,
>> +		.pause = 1,
>> +		.asym_pause = 1,
>> +	};
>> +	struct device *dev = &priv->pdev->dev;
>> +	struct phy_device *phydev;
>> +	int ret;
>> +
>> +	phydev = fixed_phy_register(&hbg_fixed_phy_status, NULL);
>> +	if (IS_ERR(phydev)) {
>> +		dev_err_probe(dev, IS_ERR(phydev),
>> +			      "failed to register fixed PHY device\n");
>> +		return IS_ERR(phydev);
>> +	}
>> +
>> +	ret = devm_add_action_or_reset(dev, hbg_fixed_phy_uninit, phydev);
>> +	if (ret)
>> +		return ret;
>> +
>> +	priv->mac.phydev = phydev;
>> +	return hbg_phy_connect(priv);
>> +}
>> +
>>   int hbg_mdio_init(struct hbg_priv *priv)
>>   {
>>   	struct device *dev = &priv->pdev->dev;
>> @@ -238,6 +273,9 @@ int hbg_mdio_init(struct hbg_priv *priv)
>>   	int ret;
>>   
>>   	mac->phy_addr = priv->dev_specs.phy_addr;
>> +	if (mac->phy_addr == HBG_NO_PHY)
>> +		return hbg_fixed_phy_init(priv);
>> +
>>   	mdio_bus = devm_mdiobus_alloc(dev);
>>   	if (!mdio_bus)
>>   		return dev_err_probe(dev, -ENOMEM,
>> -- 
>> 2.33.0
>>
>>

  reply	other threads:[~2025-06-30 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26  2:06 [PATCH v3 net-next 0/3] Support some features for the HIBMCGE driver Jijie Shao
2025-06-26  2:06 ` [PATCH v3 net-next 1/3] net: hibmcge: support scenario without PHY Jijie Shao
2025-06-30  8:38   ` Larysa Zaremba
2025-06-30 14:58     ` Jijie Shao [this message]
2025-06-26  2:06 ` [PATCH v3 net-next 2/3] net: hibmcge: adjust the burst len configuration of the MAC controller to improve TX performance Jijie Shao
2025-06-26  2:06 ` [PATCH v3 net-next 3/3] net: hibmcge: configure FIFO thresholds according to the MAC controller documentation 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=d591574c-80e5-494d-8b67-7b85594fd821@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --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=shameerali.kolothum.thodi@huawei.com \
    --cc=shenjian15@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

all inboxes | Powered by JetHome®