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] [day] [month] [year] [list]
Date: Thu, 09 May 2024 20:25:18 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: hfdevel@....net
Cc: fujita.tomonori@...il.com, andrew@...n.ch, 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 13:16:11 +0200
Hans-Frieder Vogt <hfdevel@....net> wrote:

> On 09.05.2024 12.59, FUJITA Tomonori wrote:
>> 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))
> 
> As Andrew pointed out, using the definitions from uapi/linux/mdio.h is
> a
> bad idea, because it is just a coincidence that the definitions work
> in
> this case.

Ah, I misunderstood.


> So it is better to use specific defines for TN40xx, for example:
> 
> #define TN40_MDIO_DEVAD_MASK    0x001f
> #define TN40_MDIO_PRTAD_MASK    0x03e0
> #define TN40_MDIO_CMD_VAL(device, port) \
>         (((device) & TN40_MDIO_DEVAD_MASK( | (((port) << 5) &
> TN40_MDIO_PRTAD_MASK))
>
> note that I left out the _STAT_ from the TN40_MDIO_CMD_VAL, because in
> TN40xx the CMD and STAT registers are separate (different from the
> TN30xx example).

makes sense.

I'll add the followings:

#define TN40_MDIO_DEVAD_MASK GENMASK(4, 0)
#define TN40_MDIO_PRTAD_MASK GENMASK(9, 5)
#define TN40_MDIO_CMD_VAL(device, port) \
	(((device) & TN40_MDIO_DEVAD_MASK) | (FIELD_PREP(TN40_MDIO_PRTAD_MASK, (port))))
#define TN40_MDIO_CMD_READ BIT(15)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ