From: Larysa Zaremba <larysa.zaremba@intel.com>
To: Jijie Shao <shaojijie@huawei.com>
Cc: <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 10:38:54 +0200 [thread overview]
Message-ID: <aGJNHsCMwVLqbAq0@soc-5CG4396X81.clients.intel.com> (raw)
In-Reply-To: <20250626020613.637949-2-shaojijie@huawei.com>
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
>
> 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.
>
> 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
>
>
next prev parent reply other threads:[~2025-06-30 8:39 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 [this message]
2025-06-30 14:58 ` Jijie Shao
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=aGJNHsCMwVLqbAq0@soc-5CG4396X81.clients.intel.com \
--to=larysa.zaremba@intel.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=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=shaojijie@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®