Skip to contentSkip to conversation

net: phy: add API to read 802.3-c45 IDs

PATCH Superseded Xu Liang 3 participants 6 messages Jun 28, 2021 – Jun 29, 2021

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Xu Liang

author maintainer
#0 lore raw

PATCH v4 1/2 net: phy: add API to read 802.3-c45 IDs

Add API to read 802.3-c45 IDs so that C22/C45 mixed device can use C45 APIs without failing ID checks.

---
 drivers/net/phy/phy_device.c | 14 ++++++++++++++
 include/linux/phy.h          |  1 +
 2 files changed, 15 insertions(+)
drivers/net/phy/phy_device.c +14 -0
index 0a2d8bedf73d..c8969642076f 100644
@@ -935,6 +935,20 @@ void phy_device_remove(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(phy_device_remove);
 
+/**
+ * get_phy_c45_ids - Read 802.3-c45 IDs for phy device.
+ * @phydev: phy_device structure to read 802.3-c45 IDs
+ *
+ * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
+ * the "devices in package" is invalid.
+ */
+int phy_get_c45_ids(struct phy_device *phydev)
+{
+	return get_phy_c45_ids(phydev->mdio.bus, phydev->mdio.addr,
+			       &phydev->c45_ids);
+}
+EXPORT_SYMBOL(phy_get_c45_ids);
+
 /**
  * phy_find_first - finds the first PHY device on the bus
  * @bus: the target MII bus
include/linux/phy.h +1 -0
index 852743f07e3e..e46b23a2113b 100644
@@ -1391,6 +1391,7 @@ static inline int phy_device_register(struct phy_device *phy)
 static inline void phy_device_free(struct phy_device *phydev) { }
 #endif /* CONFIG_PHYLIB */
 void phy_device_remove(struct phy_device *phydev);
+int phy_get_c45_ids(struct phy_device *phydev);
 int phy_init_hw(struct phy_device *phydev);
 int phy_suspend(struct phy_device *phydev);
 int phy_resume(struct phy_device *phydev);
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v4 2/2 net: phy: add Maxlinear GPY115/21x/24x driver

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs. Separate from XWAY PHY driver because this series has different register layout and new features not supported in XWAY PHY.

---
v2 changes:
Fix format warning from checkpath and some comments.
Use smaller PHY ID mask.
Split FWV register mask.
Call phy_trigger_machine if necessary when clear interrupt.
v3 changes:
Replace unnecessary phy_modify_mmd_changed with phy_modify_mmd Move firmware version print to probe.
v4 changes:
Separate PHY ID for new silicon.
Use full Maxlinear name in Kconfig.
Add and use C45 ID read API, and use genphy_c45_pma_read_abilities. Use my name instead of company as author.

 MAINTAINERS               |   6 +
 drivers/net/phy/Kconfig   |   6 +
 drivers/net/phy/Makefile  |   1 +
 drivers/net/phy/mxl-gpy.c | 671 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 684 insertions(+)
 create mode 100644 drivers/net/phy/mxl-gpy.c
MAINTAINERS +6 -0
index 0cce91cd5624..7a6c184a71ef 100644
@@ -11167,6 +11167,12 @@ W:	https://linuxtv.org
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/radio/radio-maxiradio*
 
+MAXLINEAR ETHERNET PHY DRIVER
+M:	Xu Liang <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/net/phy/mxl-gpy.c
+
 MCAN MMIO DEVICE DRIVER
 M:	Chandrasekar Ramakrishnan <[email protected]>
 L:	[email protected]
drivers/net/phy/Kconfig +6 -0
index 288bf405ebdb..7dba83822bc0 100644
@@ -207,6 +207,12 @@ config MARVELL_88X2222_PHY
 	  Support for the Marvell 88X2222 Dual-port Multi-speed Ethernet
 	  Transceiver.
 
+config MAXLINEAR_GPHY
+	tristate "Maxlinear Ethernet PHYs"
+	help
+	  Support for the Maxlinear GPY115, GPY211, GPY212, GPY215,
+	  GPY241, GPY245 PHYs.
+
 config MICREL_PHY
 	tristate "Micrel PHYs"
 	help
drivers/net/phy/Makefile +1 -0
index bcda7ed2455d..7aa3a5bd9bc2 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_MICREL_PHY)	+= micrel.o
 obj-$(CONFIG_MICROCHIP_PHY)	+= microchip.o
 obj-$(CONFIG_MICROCHIP_T1_PHY)	+= microchip_t1.o
 obj-$(CONFIG_MICROSEMI_PHY)	+= mscc/
+obj-$(CONFIG_MAXLINEAR_GPHY)	+= mxl-gpy.o
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
 obj-$(CONFIG_NXP_C45_TJA11XX_PHY)	+= nxp-c45-tja11xx.o
 obj-$(CONFIG_NXP_TJA11XX_PHY)	+= nxp-tja11xx.o
drivers/net/phy/mxl-gpy.c new file +671 -0

671 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v4 2/2] net: phy: add Maxlinear GPY115/21x/24x driver

Quoted 31 lines
drivers/net/phy/mxl-gpy.c new file +31 -0
+static int gpy_config_aneg(struct phy_device *phydev)
+{
+	bool changed = false;
+	u32 adv;
+	int ret;
+
+	if (phydev->autoneg == AUTONEG_DISABLE) {
+		/* Configure half duplex with genphy_setup_forced,
+		 * because genphy_c45_pma_setup_forced does not support.
+		 */
+		return phydev->duplex != DUPLEX_FULL
+			? genphy_setup_forced(phydev)
+			: genphy_c45_pma_setup_forced(phydev);
+	}
+
+	ret = genphy_c45_an_config_aneg(phydev);
+	if (ret < 0)
+		return ret;
+	if (ret > 0)
+		changed = true;
+
+	adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
+	ret = phy_modify_changed(phydev, MII_CTRL1000,
+				 ADVERTISE_1000FULL | ADVERTISE_1000HALF,
+				 adv);
+	if (ret < 0)
+		return ret;
+	if (ret > 0)
+		changed = true;
+
+	ret = genphy_c45_check_and_restart_aneg(phydev, changed);

drivers/net/phy/mxl-gpy.c line 215

Quoted 10 lines
drivers/net/phy/mxl-gpy.c new file +10 -0
+	if (ret < 0)
+		return ret;
+
+	if (phydev->interface == PHY_INTERFACE_MODE_USXGMII ||
+	    phydev->interface == PHY_INTERFACE_MODE_INTERNAL)
+		return 0;
+
+	/* No need to trigger re-ANEG if SGMII link speed is 2.5G
+	 * or SGMII ANEG is disabled.
+	 */

Is this correct. Are you using SGMII at 2.5G, or should this comment be 2500BaseX?

Otherwise, this looks good now.

Andrew

author maintainer
#3 lore raw

Re: [PATCH v4 2/2] net: phy: add Maxlinear GPY115/21x/24x driver

Quoted 47 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 31 lines
drivers/net/phy/mxl-gpy.c new file +31 -0
+static int gpy_config_aneg(struct phy_device *phydev)
+{
+     bool changed = false;
+     u32 adv;
+     int ret;
+
+     if (phydev->autoneg == AUTONEG_DISABLE) {
+             /* Configure half duplex with genphy_setup_forced,
+              * because genphy_c45_pma_setup_forced does not support.
+              */
+             return phydev->duplex != DUPLEX_FULL
+                     ? genphy_setup_forced(phydev)
+                     : genphy_c45_pma_setup_forced(phydev);
+     }
+
+     ret = genphy_c45_an_config_aneg(phydev);
+     if (ret < 0)
+             return ret;
+     if (ret > 0)
+             changed = true;
+
+     adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
+     ret = phy_modify_changed(phydev, MII_CTRL1000,
+                              ADVERTISE_1000FULL | ADVERTISE_1000HALF,
+                              adv);
+     if (ret < 0)
+             return ret;
+     if (ret > 0)
+             changed = true;
+
+     ret = genphy_c45_check_and_restart_aneg(phydev, changed);

drivers/net/phy/mxl-gpy.c line 215

Quoted 10 lines
drivers/net/phy/mxl-gpy.c new file +10 -0
+     if (ret < 0)
+             return ret;
+
+     if (phydev->interface == PHY_INTERFACE_MODE_USXGMII ||
+         phydev->interface == PHY_INTERFACE_MODE_INTERNAL)
+             return 0;
+
+     /* No need to trigger re-ANEG if SGMII link speed is 2.5G
+      * or SGMII ANEG is disabled.
+      */

Is this correct. Are you using SGMII at 2.5G, or should this comment be 2500BaseX?

Quoted 4 lines

Otherwise, this looks good now.

Andrew

Can I change to "if link speed is 2.5G"?

#4 lore raw
In reply to Xu Liang
Thank you for the patch! Perhaps something to improve:

Hi Xu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.13 next-20210628]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Xu-Liang/net-phy-add-API-to-read-802-3-c45-IDs/20210628-223411
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 62fb9874f5da54fdb243003b386128037319b219
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/918bc292dd52a4d1c5deacc2f525bf4dd4d9af1f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Xu-Liang/net-phy-add-API-to-read-802-3-c45-IDs/20210628-223411 git checkout 918bc292dd52a4d1c5deacc2f525bf4dd4d9af1f
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/phy/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/net/phy/phy_device.c:946: warning: expecting prototype for get_phy_c45_ids(). Prototype was for phy_get_c45_ids() instead

vim +946 drivers/net/phy/phy_device.c

937
938 /**
939 * get_phy_c45_ids - Read 802.3-c45 IDs for phy device.
940 * @phydev: phy_device structure to read 802.3-c45 IDs
941 *
942 * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
943 * the "devices in package" is invalid.
944 */
945 int phy_get_c45_ids(struct phy_device *phydev)

 > 946	{

947 return get_phy_c45_ids(phydev->mdio.bus, phydev->mdio.addr,
948 &phydev->c45_ids);
949 }
950 EXPORT_SYMBOL(phy_get_c45_ids);
951

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#5 lore raw
In reply to Xu Liang
Thank you for the patch! Perhaps something to improve:

Hi Xu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.13 next-20210628]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Xu-Liang/net-phy-add-API-to-read-802-3-c45-IDs/20210628-223411
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 62fb9874f5da54fdb243003b386128037319b219
config: x86_64-randconfig-a001-20210628 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 4c92e31dd0f1bd152eda883af20ff7fbcaa14945)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/918bc292dd52a4d1c5deacc2f525bf4dd4d9af1f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Xu-Liang/net-phy-add-API-to-read-802-3-c45-IDs/20210628-223411 git checkout 918bc292dd52a4d1c5deacc2f525bf4dd4d9af1f
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/phy/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/net/phy/phy_device.c:946: warning: expecting prototype for get_phy_c45_ids(). Prototype was for phy_get_c45_ids() instead

vim +946 drivers/net/phy/phy_device.c

937
938 /**
939 * get_phy_c45_ids - Read 802.3-c45 IDs for phy device.
940 * @phydev: phy_device structure to read 802.3-c45 IDs
941 *
942 * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
943 * the "devices in package" is invalid.
944 */
945 int phy_get_c45_ids(struct phy_device *phydev)

 > 946	{

947 return get_phy_c45_ids(phydev->mdio.bus, phydev->mdio.addr,
948 &phydev->c45_ids);
949 }
950 EXPORT_SYMBOL(phy_get_c45_ids);
951

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org