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]
Date: Fri, 8 Mar 2024 14:33:12 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Parthiban.Veerasooran@...rochip.com
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, horms@...nel.org, saeedm@...dia.com,
	anthony.l.nguyen@...el.com, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, corbet@....net,
	linux-doc@...r.kernel.org, robh+dt@...nel.org,
	krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
	devicetree@...r.kernel.org, Horatiu.Vultur@...rochip.com,
	ruanjinjie@...wei.com, Steen.Hegelund@...rochip.com,
	vladimir.oltean@....com, UNGLinuxDriver@...rochip.com,
	Thorsten.Kummermehr@...rochip.com, Pier.Beruto@...emi.com,
	Selvamani.Rajagopal@...emi.com, Nicolas.Ferre@...rochip.com,
	benjamin.bigler@...nformulastudent.ch
Subject: Re: [PATCH net-next v3 06/12] net: ethernet: oa_tc6: implement
 internal PHY initialization

> Ok, as per the table 6 in the spec, PHY C45 registers are mapped in the 
> MMS like below,
> 
> PHY – PCS Registers (MMD 3)  --->  MMS 2
> PHY – PMA/PMD Registers (MMD 1)  --->   MMS 3
> PHY – Vendor Specific and PLCA Registers (MMD 31)  --->  MMS 4
> PHY – Auto-Negotiation Registers (MMD 7)  --->  MMS 5
> PHY – Power Unit (MMD 13)  --->  MMS 6
> 
> MMD 13 for PHY - Power Unit is not defined in the mdio.h. So in the 
> below code I have defined it locally (MDIO_MMD_POWER_UNIT). May be 
> needed to do this in the mdio.h file when coming to this patch.

Yes, please add it to mdio.h

> /* PHY – Clause 45 registers memory map selector (MMS) as per table 6 in 
> the OPEN Alliance specification.
>   */
> #define OA_TC6_PHY_PCS_MMS2                     2       /* MMD 3 */
> #define OA_TC6_PHY_PMA_PMD_MMS3                 3       /* MMD 1 */
> #define OA_TC6_PHY_VS_PLCA_MMS4                 4       /* MMD 31 */
> #define OA_TC6_PHY_AUTO_NEG_MMS5                5       /* MMD 7 */
> #define OA_TC6_PHY_POWER_UNIT_MMS6              6       /* MMD 13 */
> 
> /* MDIO Manageable Device (MMD) for PHY Power Unit */
> #define MDIO_MMD_POWER_UNIT                     13      /* PHY Power Unit */
> 
> static int oa_tc6_mdiobus_read_c45(struct mii_bus *bus, int addr, int 
> devnum, int regnum)
> { 
> 
>          struct oa_tc6 *tc6 = bus->priv; 
> 
>          u32 regval; 
> 
>          bool ret; 
> 
>          u32 mms; 
> 
>  
> 
>          if (devnum == MDIO_MMD_PCS) 
> 
>                  mms = OA_TC6_PHY_PCS_MMS2; 
> 
>          else if (devnum == MDIO_MMD_PMAPMD) 
> 
>                  mms = OA_TC6_PHY_PMA_PMD_MMS3; 
> 
>          else if (devnum == MDIO_MMD_VEND2) 
> 
>                  mms = OA_TC6_PHY_VS_PLCA_MMS4; 
> 
>          else if (devnum == MDIO_MMD_AN) 
> 
>                  mms = OA_TC6_PHY_AUTO_NEG_MMS5; 
> 
>          else if (devnum == MDIO_MMD_POWER_UNIT) 
> 
>                  mms = OA_TC6_PHY_POWER_UNIT_MMS6; 

I would probably use a switch statement.

> 
>          else 
> 
>                  return -ENOTSUPP; 

802.3 says:

  If a device supports the MDIO interface it shall respond to all
  possible register addresses for the device and return a value of
  zero for undefined and unsupported registers. Writes to undefined
  registers and read-only registers shall have no effect. The
  operation of an MMD shall not be affected by writes to reserved and
  unsupported register bits, and such register bits shall return a
  value of zero when read.

So maybe return 0. ENOTSUPP is wrong, that is an NFS only error
code. The generic one is EOPNOTSUPP. I would say -EOPNOTSUPP is also
O.K.

>          ret = oa_tc6_read_register(tc6, (mms << 16) | regnum, &regval); 
> 
>          if (ret) 
> 
>                  return -ENODEV; 

oa_tc6_read_register() should return an error code, so return whatever
is returns. Don't overwrite error codes. It makes it harder to track
errors through the call stack.

       Andrew


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ