From: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>,
<netdev@vger.kernel.org>, <davem@davemloft.net>,
<linux@armlinux.org.uk>, <kuba@kernel.org>,
<hkallweit1@gmail.com>, <richardcochran@gmail.com>,
<rdunlap@infradead.org>, <bryan.whitehead@microchip.com>,
<edumazet@google.com>, <pabeni@redhat.com>,
<maxime.chevallier@bootlin.com>, <linux-kernel@vger.kernel.org>,
<horms@kernel.org>, <UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH net-next V5 4/5] net: lan743x: Migrate phylib to phylink
Date: Fri, 6 Sep 2024 14:23:18 +0530 [thread overview]
Message-ID: <ZtrC/sCeXN5IgjWd@HYD-DK-UNGSW21.microchip.com> (raw)
In-Reply-To: <cad5b31d-7713-4a1d-88e4-58d6878e90c5@lunn.ch>
Hi Andrew,
Thank you for review the patches.
The 09/05/2024 15:11, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> > +static struct {
> > + unsigned long mask;
> > + int speed;
> > + int duplex;
> > +} lan743x_mac_caps_params[] = {
> > + { MAC_2500FD, SPEED_2500, DUPLEX_FULL },
> > + { MAC_1000FD, SPEED_1000, DUPLEX_FULL },
> > + { MAC_100FD, SPEED_100, DUPLEX_FULL },
> > + { MAC_10FD, SPEED_10, DUPLEX_FULL },
> > + { MAC_100HD, SPEED_100, DUPLEX_HALF },
> > + { MAC_10HD, SPEED_10, DUPLEX_HALF },
> > +};
> > +
> > +static int lan743x_find_max_speed(unsigned long caps, int *speed, int *duplex)
> > +{
> > + int i;
> > +
> > + *speed = SPEED_UNKNOWN;
> > + *duplex = DUPLEX_UNKNOWN;
> > + for (i = 0; i < ARRAY_SIZE(lan743x_mac_caps_params); i++) {
> > + if (caps & lan743x_mac_caps_params[i].mask) {
> > + *speed = lan743x_mac_caps_params[i].speed;
> > + *duplex = lan743x_mac_caps_params[i].duplex;
> > + break;
> > + }
> > + }
> > +
> > + return *speed == SPEED_UNKNOWN ? -EINVAL : 0;
> > +}
> > +
> > +static int lan743x_phylink_create(struct lan743x_adapter *adapter)
> > +{
> > + struct net_device *netdev = adapter->netdev;
> > + struct phylink *pl;
> > +
> > + adapter->phylink_config.dev = &netdev->dev;
> > + adapter->phylink_config.type = PHYLINK_NETDEV;
> > + adapter->phylink_config.mac_managed_pm = false;
> > +
> > + adapter->phylink_config.mac_capabilities = MAC_ASYM_PAUSE |
> > + MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD;
> > +
>
>
> > + case PHY_INTERFACE_MODE_SGMII:
> > + __set_bit(PHY_INTERFACE_MODE_SGMII,
> > + adapter->phylink_config.supported_interfaces);
> > + __set_bit(PHY_INTERFACE_MODE_1000BASEX,
> > + adapter->phylink_config.supported_interfaces);
> > + __set_bit(PHY_INTERFACE_MODE_2500BASEX,
> > + adapter->phylink_config.supported_interfaces);
> > + adapter->phylink_config.mac_capabilities |= MAC_2500FD;
>
>
> > +static int lan743x_phylink_connect(struct lan743x_adapter *adapter)
> > +{
> > + struct device_node *dn = adapter->pdev->dev.of_node;
> > + struct net_device *dev = adapter->netdev;
> > + struct phy_device *phydev;
> > + int ret;
> > +
> > + if (dn)
> > + ret = phylink_of_phy_connect(adapter->phylink, dn, 0);
> > +
> > + if (!dn || (ret && !lan743x_phy_handle_exists(dn))) {
> > + phydev = phy_find_first(adapter->mdiobus);
> > + if (phydev) {
> > + /* attach the mac to the phy */
> > + ret = phylink_connect_phy(adapter->phylink, phydev);
> > + } else if (((adapter->csr.id_rev & ID_REV_ID_MASK_) ==
> > + ID_REV_ID_LAN7431_) || adapter->is_pci11x1x) {
> > + struct phylink_link_state state;
> > + unsigned long caps;
> > +
> > + caps = adapter->phylink_config.mac_capabilities;
> > + ret = lan743x_find_max_speed(caps, &state.speed,
> > + &state.duplex);
>
> This seems like an overly complicated way to determine the speed. If
> MAC_2500FD is set, you know it is 2500. Otherwise it must by 1000. Why
> not use a simple if?
Ok. I will fix
>
> I'm not the best at reviewing phylink patches, but since Russell is
> off-lime, i'm the best you have. So
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> but please do consider simplifying the code above.
>
> Andrew
--
Thanks,
Raju
next prev parent reply other threads:[~2024-09-06 8:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 9:06 [PATCH net-next V5 0/5] Add support to PHYLINK for LAN743x/PCI11x1x chips Raju Lakkaraju
2024-09-04 9:06 ` [PATCH net-next V5 1/5] net: phylink: Add phylink_set_fixed_link() to configure fixed link state in phylink Raju Lakkaraju
2024-09-04 9:06 ` [PATCH net-next V5 2/5] net: lan743x: Create separate PCS power reset function Raju Lakkaraju
2024-09-04 9:06 ` [PATCH net-next V5 3/5] net: lan743x: Create separate Link Speed Duplex state function Raju Lakkaraju
2024-09-04 9:06 ` [PATCH net-next V5 4/5] net: lan743x: Migrate phylib to phylink Raju Lakkaraju
2024-09-05 13:11 ` Andrew Lunn
2024-09-06 8:53 ` Raju Lakkaraju [this message]
2024-09-05 13:49 ` Maxime Chevallier
2024-09-04 9:06 ` [PATCH net-next V5 5/5] net: lan743x: Add support to ethtool phylink get and set settings Raju Lakkaraju
2024-09-05 13:00 ` Andrew Lunn
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=ZtrC/sCeXN5IgjWd@HYD-DK-UNGSW21.microchip.com \
--to=raju.lakkaraju@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=bryan.whitehead@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.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®