[XGMAC error message v1 0/1] Adding device name when printing error.

In Intel SoC FPGA Agilex5, it support several ethernet instances, when there is an error occured at multiple interface it hardly tell which instances that is associated to that error.
Hence, adding the device name at the error message to differentiate between which instance is having issue.
Boon Khai Ng (1): net: dwc_eth_xgmac: Add device name for the error message.
drivers/net/dwc_eth_xgmac.c | 82 +++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 30 deletions(-)

Agilex5 having several ethernet instance, adding the device name at the error message to differentiate between which instance is having issue.
Signed-off-by: Boon Khai Ng boon.khai.ng@intel.com --- drivers/net/dwc_eth_xgmac.c | 82 +++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 30 deletions(-)
diff --git a/drivers/net/dwc_eth_xgmac.c b/drivers/net/dwc_eth_xgmac.c index d3e5f9255f..cf8227b1b4 100644 --- a/drivers/net/dwc_eth_xgmac.c +++ b/drivers/net/dwc_eth_xgmac.c @@ -152,7 +152,9 @@ static int xgmac_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) { - pr_err("MDIO not idle at entry: %d\n", ret); + pr_err("%s MDIO not idle at entry: %d\n", + xgmac->dev->name, ret); + return ret; }
@@ -172,7 +174,9 @@ static int xgmac_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) { - pr_err("MDIO not idle at entry: %d\n", ret); + pr_err("%s MDIO not idle at entry: %d\n", + xgmac->dev->name, ret); + return ret; }
@@ -181,7 +185,9 @@ static int xgmac_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) { - pr_err("MDIO read didn't complete: %d\n", ret); + pr_err("%s MDIO read didn't complete: %d\n", + xgmac->dev->name, ret); + return ret; }
@@ -206,7 +212,9 @@ static int xgmac_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) { - pr_err("MDIO not idle at entry: %d\n", ret); + pr_err("%s MDIO not idle at entry: %d\n", + xgmac->dev->name, ret); + return ret; }
@@ -229,7 +237,9 @@ static int xgmac_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) { - pr_err("MDIO not idle at entry: %d\n", ret); + pr_err("%s MDIO not idle at entry: %d\n", + xgmac->dev->name, ret); + return ret; }
@@ -238,7 +248,9 @@ static int xgmac_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) { - pr_err("MDIO write didn't complete: %d\n", ret); + pr_err("%s MDIO write didn't complete: %d\n", + xgmac->dev->name, ret); + return ret; }
@@ -323,7 +335,7 @@ static int xgmac_adjust_link(struct udevice *dev) else ret = xgmac_set_half_duplex(dev); if (ret < 0) { - pr_err("xgmac_set_*_duplex() failed: %d\n", ret); + pr_err("%s xgmac_set_*_duplex() failed: %d\n", dev->name, ret); return ret; }
@@ -341,26 +353,28 @@ static int xgmac_adjust_link(struct udevice *dev) ret = xgmac_set_mii_speed_10(dev); break; default: - pr_err("invalid speed %d\n", xgmac->phy->speed); + pr_err("%s invalid speed %d\n", dev->name, xgmac->phy->speed); return -EINVAL; } if (ret < 0) { - pr_err("xgmac_set_*mii_speed*() failed: %d\n", ret); + pr_err("%s xgmac_set_*mii_speed*() failed: %d\n", dev->name, ret); return ret; }
if (en_calibration) { ret = xgmac->config->ops->xgmac_calibrate_pads(dev); if (ret < 0) { - pr_err("xgmac_calibrate_pads() failed: %d\n", - ret); + pr_err("%s xgmac_calibrate_pads() failed: %d\n", + dev->name, ret); + return ret; } } else { ret = xgmac->config->ops->xgmac_disable_calibration(dev); if (ret < 0) { - pr_err("xgmac_disable_calibration() failed: %d\n", - ret); + pr_err("%s xgmac_disable_calibration() failed: %d\n", + dev->name, ret); + return ret; } } @@ -456,7 +470,7 @@ static int xgmac_start(struct udevice *dev)
ret = xgmac->config->ops->xgmac_start_resets(dev); if (ret < 0) { - pr_err("xgmac_start_resets() failed: %d\n", ret); + pr_err("%s xgmac_start_resets() failed: %d\n", dev->name, ret); goto err; }
@@ -466,13 +480,13 @@ static int xgmac_start(struct udevice *dev) XGMAC_DMA_MODE_SWR, false, xgmac->config->swr_wait, false); if (ret) { - pr_err("XGMAC_DMA_MODE_SWR stuck: %d\n", ret); + pr_err("%s XGMAC_DMA_MODE_SWR stuck: %d\n", dev->name, ret); goto err_stop_resets; }
ret = xgmac->config->ops->xgmac_calibrate_pads(dev); if (ret < 0) { - pr_err("xgmac_calibrate_pads() failed: %d\n", ret); + pr_err("%s xgmac_calibrate_pads() failed: %d\n", dev->name, ret); goto err_stop_resets; }
@@ -485,14 +499,16 @@ static int xgmac_start(struct udevice *dev) xgmac->phy = phy_connect(xgmac->mii, addr, dev, xgmac->config->interface(dev)); if (!xgmac->phy) { - pr_err("phy_connect() failed\n"); + pr_err("%s phy_connect() failed\n", dev->name); goto err_stop_resets; }
if (xgmac->max_speed) { ret = phy_set_supported(xgmac->phy, xgmac->max_speed); if (ret) { - pr_err("phy_set_supported() failed: %d\n", ret); + pr_err("%s phy_set_supported() failed: %d\n", + dev->name, ret); + goto err_shutdown_phy; } } @@ -500,25 +516,25 @@ static int xgmac_start(struct udevice *dev) xgmac->phy->node = xgmac->phy_of_node; ret = phy_config(xgmac->phy); if (ret < 0) { - pr_err("phy_config() failed: %d\n", ret); + pr_err("%s phy_config() failed: %d\n", dev->name, ret); goto err_shutdown_phy; } }
ret = phy_startup(xgmac->phy); if (ret < 0) { - pr_err("phy_startup() failed: %d\n", ret); + pr_err("%s phy_startup() failed: %d\n", dev->name, ret); goto err_shutdown_phy; }
if (!xgmac->phy->link) { - pr_err("No link\n"); + pr_err("%s No link\n", dev->name); goto err_shutdown_phy; }
ret = xgmac_adjust_link(dev); if (ret < 0) { - pr_err("xgmac_adjust_link() failed: %d\n", ret); + pr_err("%s xgmac_adjust_link() failed: %d\n", dev->name, ret); goto err_shutdown_phy; }
@@ -611,7 +627,7 @@ static int xgmac_start(struct udevice *dev)
ret = xgmac_write_hwaddr(dev); if (ret < 0) { - pr_err("xgmac_write_hwaddr() failed: %d\n", ret); + pr_err("%s xgmac_write_hwaddr() failed: %d\n", dev->name, ret); goto err; }
@@ -738,7 +754,7 @@ err_shutdown_phy: err_stop_resets: xgmac->config->ops->xgmac_stop_resets(dev); err: - pr_err("FAILED: %d\n", ret); + pr_err("%s FAILED: %d\n", dev->name, ret); return ret; }
@@ -1047,7 +1063,7 @@ static int xgmac_probe(struct udevice *dev)
xgmac->regs = dev_read_addr(dev); if (xgmac->regs == FDT_ADDR_T_NONE) { - pr_err("dev_read_addr() failed\n"); + pr_err("%s dev_read_addr() failed\n", dev->name); return -ENODEV; } xgmac->mac_regs = (void *)(xgmac->regs + XGMAC_MAC_REGS_BASE); @@ -1058,19 +1074,23 @@ static int xgmac_probe(struct udevice *dev)
ret = xgmac_probe_resources_core(dev); if (ret < 0) { - pr_err("xgmac_probe_resources_core() failed: %d\n", ret); + pr_err("%s xgmac_probe_resources_core() failed: %d\n", + dev->name, ret); + return ret; }
ret = xgmac->config->ops->xgmac_probe_resources(dev); if (ret < 0) { - pr_err("xgmac_probe_resources() failed: %d\n", ret); + pr_err("%s xgmac_probe_resources() failed: %d\n", + dev->name, ret); + goto err_remove_resources_core; }
ret = xgmac->config->ops->xgmac_start_clks(dev); if (ret < 0) { - pr_err("xgmac_start_clks() failed: %d\n", ret); + pr_err("%s xgmac_start_clks() failed: %d\n", dev->name, ret); return ret; }
@@ -1080,7 +1100,7 @@ static int xgmac_probe(struct udevice *dev) if (!xgmac->mii) { xgmac->mii = mdio_alloc(); if (!xgmac->mii) { - pr_err("mdio_alloc() failed\n"); + pr_err("%s mdio_alloc() failed\n", dev->name); ret = -ENOMEM; goto err_stop_clks; } @@ -1091,7 +1111,9 @@ static int xgmac_probe(struct udevice *dev)
ret = mdio_register(xgmac->mii); if (ret < 0) { - pr_err("mdio_register() failed: %d\n", ret); + pr_err("%s mdio_register() failed: %d\n", + dev->name, ret); + goto err_free_mdio; } }

-----Original Message----- From: Ng, Boon Khai boon.khai.ng@intel.com Sent: Friday, January 17, 2025 2:48 PM To: Uboot Open List u-boot@lists.denx.de Cc: Chee, Tien Fong tien.fong.chee@intel.com; Hea, Kok Kiang kok.kiang.hea@intel.com; Maniyam, Dinesh dinesh.maniyam@intel.com; Yuslaimi, Alif Zakuan alif.zakuan.yuslaimi@intel.com; Zamri, Muhammad Hazim Izzat muhammad.hazim.izzat.zamri@intel.com; Tien Fong Chee tien.fong.chee@altera.com; Kok Kiang Hea kok.kiang.hea@altera.com; Dinesh Maniyam dinesh.maniyam@altera.com; Alif Zakuan alif.zakuan.yuslaimi@altera.com; Boon Khai Ng boon.khai.ng@altera.com; Muhammad Hazim muhammad.hazim.izzat.zamri@altera.com; Joe Hershberger joe.hershberger@ni.com; Ramon Fried rfried.dev@gmail.com; Tom Rini trini@konsulko.com; Ng, Boon Khai boon.khai.ng@intel.com Subject: [XGMAC error message v1 1/1] net: dwc_eth_xgmac: Add device name for the error message.
Agilex5 having several ethernet instance, adding the device name at the error message to differentiate between which instance is having issue.
Signed-off-by: Boon Khai Ng boon.khai.ng@intel.com
drivers/net/dwc_eth_xgmac.c | 82 +++++++++++++++++++++++-------------
1 file changed, 52 insertions(+), 30 deletions(-)
diff --git a/drivers/net/dwc_eth_xgmac.c b/drivers/net/dwc_eth_xgmac.c index d3e5f9255f..cf8227b1b4 100644 --- a/drivers/net/dwc_eth_xgmac.c +++ b/drivers/net/dwc_eth_xgmac.c @@ -152,7 +152,9 @@ static int xgmac_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) {
pr_err("MDIO not idle at entry: %d\n", ret);
pr_err("%s MDIO not idle at entry: %d\n",
xgmac->dev->name, ret);
- return ret; }
@@ -172,7 +174,9 @@ static int xgmac_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) {
pr_err("MDIO not idle at entry: %d\n", ret);
pr_err("%s MDIO not idle at entry: %d\n",
xgmac->dev->name, ret);
- return ret; }
@@ -181,7 +185,9 @@ static int xgmac_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) {
pr_err("MDIO read didn't complete: %d\n", ret);
pr_err("%s MDIO read didn't complete: %d\n",
xgmac->dev->name, ret);
- return ret; }
@@ -206,7 +212,9 @@ static int xgmac_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) {
pr_err("MDIO not idle at entry: %d\n", ret);
pr_err("%s MDIO not idle at entry: %d\n",
xgmac->dev->name, ret);
- return ret; }
@@ -229,7 +237,9 @@ static int xgmac_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) {
pr_err("MDIO not idle at entry: %d\n", ret);
pr_err("%s MDIO not idle at entry: %d\n",
xgmac->dev->name, ret);
- return ret; }
@@ -238,7 +248,9 @@ static int xgmac_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad,
ret = xgmac_mdio_wait_idle(xgmac); if (ret) {
pr_err("MDIO write didn't complete: %d\n", ret);
pr_err("%s MDIO write didn't complete: %d\n",
xgmac->dev->name, ret);
- return ret; }
@@ -323,7 +335,7 @@ static int xgmac_adjust_link(struct udevice *dev) else ret = xgmac_set_half_duplex(dev); if (ret < 0) {
pr_err("xgmac_set_*_duplex() failed: %d\n", ret);
pr_err("%s xgmac_set_*_duplex() failed: %d\n", dev->name,
ret); return ret; }
@@ -341,26 +353,28 @@ static int xgmac_adjust_link(struct udevice *dev) ret = xgmac_set_mii_speed_10(dev); break; default:
pr_err("invalid speed %d\n", xgmac->phy->speed);
pr_err("%s invalid speed %d\n", dev->name, xgmac->phy-
speed);
return -EINVAL;
} if (ret < 0) {
pr_err("xgmac_set_*mii_speed*() failed: %d\n", ret);
pr_err("%s xgmac_set_*mii_speed*() failed: %d\n", dev-
name, ret);
return ret;
}
if (en_calibration) { ret = xgmac->config->ops->xgmac_calibrate_pads(dev); if (ret < 0) {
pr_err("xgmac_calibrate_pads() failed: %d\n",
ret);
pr_err("%s xgmac_calibrate_pads() failed: %d\n",
dev->name, ret);
} } else { ret = xgmac->config->ops->xgmac_disable_calibration(dev); if (ret < 0) {return ret;
pr_err("xgmac_disable_calibration() failed: %d\n",
ret);
pr_err("%s xgmac_disable_calibration() failed: %d\n",
dev->name, ret);
} }return ret;
@@ -456,7 +470,7 @@ static int xgmac_start(struct udevice *dev)
ret = xgmac->config->ops->xgmac_start_resets(dev); if (ret < 0) {
pr_err("xgmac_start_resets() failed: %d\n", ret);
pr_err("%s xgmac_start_resets() failed: %d\n", dev->name,
ret); goto err; }
@@ -466,13 +480,13 @@ static int xgmac_start(struct udevice *dev) XGMAC_DMA_MODE_SWR, false, xgmac->config->swr_wait, false); if (ret) {
pr_err("XGMAC_DMA_MODE_SWR stuck: %d\n", ret);
pr_err("%s XGMAC_DMA_MODE_SWR stuck: %d\n", dev-
name, ret);
goto err_stop_resets;
}
ret = xgmac->config->ops->xgmac_calibrate_pads(dev); if (ret < 0) {
pr_err("xgmac_calibrate_pads() failed: %d\n", ret);
pr_err("%s xgmac_calibrate_pads() failed: %d\n", dev-
name, ret);
goto err_stop_resets;
}
@@ -485,14 +499,16 @@ static int xgmac_start(struct udevice *dev) xgmac->phy = phy_connect(xgmac->mii, addr, dev, xgmac->config->interface(dev)); if (!xgmac->phy) {
pr_err("phy_connect() failed\n");
pr_err("%s phy_connect() failed\n", dev->name); goto err_stop_resets;
}
if (xgmac->max_speed) { ret = phy_set_supported(xgmac->phy, xgmac-
max_speed);
if (ret) {
pr_err("phy_set_supported() failed: %d\n",
ret);
pr_err("%s phy_set_supported()
failed: %d\n",
dev->name, ret);
}goto err_shutdown_phy; }
@@ -500,25 +516,25 @@ static int xgmac_start(struct udevice *dev) xgmac->phy->node = xgmac->phy_of_node; ret = phy_config(xgmac->phy); if (ret < 0) {
pr_err("phy_config() failed: %d\n", ret);
pr_err("%s phy_config() failed: %d\n", dev->name,
ret); goto err_shutdown_phy; } }
ret = phy_startup(xgmac->phy); if (ret < 0) {
pr_err("phy_startup() failed: %d\n", ret);
pr_err("%s phy_startup() failed: %d\n", dev->name, ret);
goto err_shutdown_phy; }
if (!xgmac->phy->link) {
pr_err("No link\n");
pr_err("%s No link\n", dev->name);
goto err_shutdown_phy; }
ret = xgmac_adjust_link(dev); if (ret < 0) {
pr_err("xgmac_adjust_link() failed: %d\n", ret);
pr_err("%s xgmac_adjust_link() failed: %d\n", dev->name,
ret); goto err_shutdown_phy; }
@@ -611,7 +627,7 @@ static int xgmac_start(struct udevice *dev)
ret = xgmac_write_hwaddr(dev); if (ret < 0) {
pr_err("xgmac_write_hwaddr() failed: %d\n", ret);
pr_err("%s xgmac_write_hwaddr() failed: %d\n", dev-
name, ret);
goto err;
}
@@ -738,7 +754,7 @@ err_shutdown_phy: err_stop_resets: xgmac->config->ops->xgmac_stop_resets(dev); err:
- pr_err("FAILED: %d\n", ret);
- pr_err("%s FAILED: %d\n", dev->name, ret); return ret;
}
@@ -1047,7 +1063,7 @@ static int xgmac_probe(struct udevice *dev)
xgmac->regs = dev_read_addr(dev); if (xgmac->regs == FDT_ADDR_T_NONE) {
pr_err("dev_read_addr() failed\n");
return -ENODEV; } xgmac->mac_regs = (void *)(xgmac->regs +pr_err("%s dev_read_addr() failed\n", dev->name);
XGMAC_MAC_REGS_BASE); @@ -1058,19 +1074,23 @@ static int xgmac_probe(struct udevice *dev)
ret = xgmac_probe_resources_core(dev); if (ret < 0) {
pr_err("xgmac_probe_resources_core() failed: %d\n", ret);
pr_err("%s xgmac_probe_resources_core() failed: %d\n",
dev->name, ret);
return ret; }
ret = xgmac->config->ops->xgmac_probe_resources(dev); if (ret < 0) {
pr_err("xgmac_probe_resources() failed: %d\n", ret);
pr_err("%s xgmac_probe_resources() failed: %d\n",
dev->name, ret);
goto err_remove_resources_core; }
ret = xgmac->config->ops->xgmac_start_clks(dev); if (ret < 0) {
pr_err("xgmac_start_clks() failed: %d\n", ret);
pr_err("%s xgmac_start_clks() failed: %d\n", dev->name,
ret); return ret; }
@@ -1080,7 +1100,7 @@ static int xgmac_probe(struct udevice *dev) if (!xgmac->mii) { xgmac->mii = mdio_alloc(); if (!xgmac->mii) {
pr_err("mdio_alloc() failed\n");
}pr_err("%s mdio_alloc() failed\n", dev->name); ret = -ENOMEM; goto err_stop_clks;
@@ -1091,7 +1111,9 @@ static int xgmac_probe(struct udevice *dev)
ret = mdio_register(xgmac->mii); if (ret < 0) {
pr_err("mdio_register() failed: %d\n", ret);
pr_err("%s mdio_register() failed: %d\n",
dev->name, ret);
} }goto err_free_mdio;
-- 2.26.2
Reviewed-by: Tien Fong Chee tien.fong.chee@intel.com
Best regards, Tien Fong
participants (2)
-
Boon Khai Ng
-
Chee, Tien Fong