From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Jiawen Wu <jiawenwu@trustnetic.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, andrew@lunn.ch, netdev@vger.kernel.org,
mengyuanlou@net-swift.com
Subject: Re: [PATCH net-next v2 1/7] net: ngbe: implement phylink to handle PHY device
Date: Mon, 4 Dec 2023 10:10:43 +0000 [thread overview]
Message-ID: <ZW2loxTO6oKNYLew@shell.armlinux.org.uk> (raw)
In-Reply-To: <20231204091905.1186255-2-jiawenwu@trustnetic.com>
On Mon, Dec 04, 2023 at 05:18:59PM +0800, Jiawen Wu wrote:
> Add phylink support for Wangxun 1Gb Ethernet controller.
>
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
> drivers/net/ethernet/wangxun/libwx/wx_type.h | 1 +
> drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 21 ++-
> drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c | 127 +++++++++++-------
> 3 files changed, 88 insertions(+), 61 deletions(-)
>
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
> index 165e82de772e..4088637440c6 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
> @@ -940,6 +940,7 @@ struct wx {
> int speed;
> int duplex;
> struct phy_device *phydev;
If you also embed struct phylink_config() in struct wx, then you can get
to it in the MAC operations using an inline function in wx_type.h:
static inline struct wx *phylink_to_wx(struct phylink_config *config)
{
return container_of(config, struct wx, phylink_config);
}
which will be more efficient than doing the
netdev_priv(to_net_dev(config->dev)) dance. It's also what other network
drivers that use phylink do, so it brings consistency of implementation.
...
> -static void ngbe_handle_link_change(struct net_device *dev)
> +static void ngbe_phy_fixup(struct wx *wx)
> {
> - struct wx *wx = netdev_priv(dev);
> - struct phy_device *phydev;
> - u32 lan_speed, reg;
> + struct phy_device *phydev = wx->phydev;
> + struct ethtool_eee eee;
>
> - phydev = wx->phydev;
> - if (!(wx->link != phydev->link ||
> - wx->speed != phydev->speed ||
> - wx->duplex != phydev->duplex))
> + phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
> + phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
> + phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
Phylink restricts the advertisement according to the capabilities
provided, do you should not need to do this. Please remove.
> +
> + phydev->mac_managed_pm = true;
Please don't bypass phylink's management of this, instead set the
"mac_managed_pm" boolean in struct phylink_config.
...
> +static int ngbe_phylink_init(struct wx *wx)
> {
> - int ret;
> + struct phylink_config *config;
> + phy_interface_t phy_mode;
> + struct phylink *phylink;
>
> - ret = phy_connect_direct(wx->netdev,
> - wx->phydev,
> - ngbe_handle_link_change,
> - PHY_INTERFACE_MODE_RGMII_ID);
> - if (ret) {
> - wx_err(wx, "PHY connect failed.\n");
> - return ret;
> - }
> + config = devm_kzalloc(&wx->pdev->dev, sizeof(*config), GFP_KERNEL);
> + if (!config)
> + return -ENOMEM;
>
> - return 0;
> -}
> + config->dev = &wx->netdev->dev;
> + config->type = PHYLINK_NETDEV;
> + config->mac_capabilities = MAC_1000FD | MAC_100FD |
> + MAC_SYM_PAUSE | MAC_ASYM_PAUSE;
>
> -static void ngbe_phy_fixup(struct wx *wx)
> -{
> - struct phy_device *phydev = wx->phydev;
> - struct ethtool_eee eee;
> + phy_mode = PHY_INTERFACE_MODE_RGMII_ID;
> + __set_bit(PHY_INTERFACE_MODE_RGMII_ID, config->supported_interfaces);
As mentioned above, also set config->mac_managed_pm.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2023-12-04 10:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 9:18 [PATCH net-next v2 0/7] Implement more ethtool_ops for Wangxun Jiawen Wu
2023-12-04 9:18 ` [PATCH net-next v2 1/7] net: ngbe: implement phylink to handle PHY device Jiawen Wu
2023-12-04 10:10 ` Russell King (Oracle) [this message]
2023-12-04 9:19 ` [PATCH net-next v2 2/7] net: wangxun: unified phylink implementation in libwx Jiawen Wu
2023-12-04 9:19 ` [PATCH net-next v2 3/7] net: wangxun: add flow control support Jiawen Wu
2023-12-04 9:19 ` [PATCH net-next v2 4/7] net: wangxun: add ethtool_ops for ring parameters Jiawen Wu
2023-12-04 9:19 ` [PATCH net-next v2 5/7] net: wangxun: add coalesce options support Jiawen Wu
2023-12-04 9:19 ` [PATCH net-next v2 6/7] net: wangxun: add ethtool_ops for channel number Jiawen Wu
2023-12-04 9:19 ` [PATCH net-next v2 7/7] net: wangxun: add ethtool_ops for msglevel Jiawen Wu
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=ZW2loxTO6oKNYLew@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiawenwu@trustnetic.com \
--cc=kuba@kernel.org \
--cc=mengyuanlou@net-swift.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.