lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240509.195906.2304840489846825725.fujita.tomonori@gmail.com>
Date: Thu, 09 May 2024 19:59:06 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: hfdevel@....net
Cc: andrew@...n.ch, fujita.tomonori@...il.com, netdev@...r.kernel.org,
 horms@...nel.org, kuba@...nel.org, jiri@...nulli.us, pabeni@...hat.com
Subject: Re: [PATCH net-next v5 5/6] net: tn40xx: add mdio bus support

Hi,

On Thu, 9 May 2024 11:52:46 +0200
Hans-Frieder Vogt <hfdevel@....net> wrote:

> A small addition here:
> digging through an old Tehuti linux river for the TN30xx (revision
> 7.33.5.1) I found revealing comments:
> in bdx_mdio_read:
>         /* Write read command */
>         writel(MDIO_CMD_STAT_VAL(1, device, port), regs +
> regMDIO_CMD_STAT);
> in bdx_mdio_write:
>         /* Write write command */
>         writel(MDIO_CMD_STAT_VAL(0, device, port), regs +
> regMDIO_CMD_STAT);
> 
> The CMD register has a different layout in the TN40xx, but the logic
> is
> similar.
> Therefore, I conclude now that the value (1 << 15)  is in fact a read
> flag. Maybe it could be defined like:
> 
> #define TN40_MDIO_READ    BIT(15)

Thanks a lot!

So worth adding MDIO_CMD_STAT_VAL macro and TN40_MDIO_CMD_READ
definition?


diff --git a/drivers/net/ethernet/tehuti/tn40_mdio.c b/drivers/net/ethernet/tehuti/tn40_mdio.c
index 64ef7f40f25d..d2e4b4d5ee9a 100644
--- a/drivers/net/ethernet/tehuti/tn40_mdio.c
+++ b/drivers/net/ethernet/tehuti/tn40_mdio.c
@@ -7,6 +7,10 @@
 
 #include "tn40.h"
 
+#define TN40_MDIO_CMD_STAT_VAL(device, port) \
+	(((device) & MDIO_PHY_ID_DEVAD) | (((port) << 5) & MDIO_PHY_ID_PRTAD))
+#define TN40_MDIO_CMD_READ BIT(15)
+
 static void tn40_mdio_set_speed(struct tn40_priv *priv, u32 speed)
 {
 	void __iomem *regs = priv->regs;
@@ -48,13 +52,13 @@ static int tn40_mdio_read(struct tn40_priv *priv, int port, int device,
 	if (tn40_mdio_get(priv, NULL))
 		return -EIO;
 
-	i = ((device & 0x1F) | ((port & 0x1F) << 5));
+	i = TN40_MDIO_CMD_STAT_VAL(device, port);
 	writel(i, regs + TN40_REG_MDIO_CMD);
 	writel((u32)regnum, regs + TN40_REG_MDIO_ADDR);
 	if (tn40_mdio_get(priv, NULL))
 		return -EIO;
 
-	writel(((1 << 15) | i), regs + TN40_REG_MDIO_CMD);
+	writel(TN40_MDIO_CMD_READ | i, regs + TN40_REG_MDIO_CMD);
 	/* read CMD_STAT until not busy */
 	if (tn40_mdio_get(priv, NULL))
 		return -EIO;
@@ -73,8 +77,7 @@ static int tn40_mdio_write(struct tn40_priv *priv, int port, int device,
 	/* wait until MDIO is not busy */
 	if (tn40_mdio_get(priv, NULL))
 		return -EIO;
-	writel(((device & 0x1F) | ((port & 0x1F) << 5)),
-	       regs + TN40_REG_MDIO_CMD);
+	writel(TN40_MDIO_CMD_STAT_VAL(device, port), regs + TN40_REG_MDIO_CMD);
 	writel((u32)regnum, regs + TN40_REG_MDIO_ADDR);
 	if (tn40_mdio_get(priv, NULL))
 		return -EIO;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ