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: <c3d46e0b-0b09-42e0-8508-a672296adeb6@oss.nxp.com>
Date: Tue, 15 Apr 2025 13:56:21 +0300
From: Andrei Botila <andrei.botila@....nxp.com>
To: Christian Marangi <ansuelsmth@...il.com>,
 Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
 <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>, Heiner Kallweit <hkallweit1@...il.com>,
 Russell King <linux@...linux.org.uk>,
 Florian Fainelli <florian.fainelli@...adcom.com>,
 Broadcom internal kernel review list
 <bcm-kernel-feedback-list@...adcom.com>, Marek BehĂșn
 <kabel@...nel.org>, Sabrina Dubroca <sd@...asysnail.net>,
 Eric Woudstra <ericwouds@...il.com>, Daniel Golle <daniel@...rotopia.org>,
 netdev@...r.kernel.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.or
Cc: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Subject: Re: [net-next PATCH v7 3/6] net: phy: nxp-c45-tja11xx: simplify
 .match_phy_device OP

On 4/10/2025 12:53 PM, Christian Marangi wrote:
> Simplify .match_phy_device OP by using a generic function and using the
> new phy_id PHY driver info instead of hardcoding the matching PHY ID
> with new variant for macsec and no_macsec PHYs.
> 
> Also make use of PHY_ID_MATCH_MODEL macro and drop PHY_ID_MASK define to
> introduce phy_id and phy_id_mask again in phy_driver struct.
> 
> Reviewed-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
> ---
>  drivers/net/phy/nxp-c45-tja11xx.c | 45 ++++++++++++++-----------------
>  1 file changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
> index bc2b7cc0cebe..8880547c4bfa 100644
> --- a/drivers/net/phy/nxp-c45-tja11xx.c
> +++ b/drivers/net/phy/nxp-c45-tja11xx.c
> @@ -19,7 +19,6 @@
>  
>  #include "nxp-c45-tja11xx.h"
>  
> -#define PHY_ID_MASK			GENMASK(31, 4)
>  /* Same id: TJA1103, TJA1104 */
>  #define PHY_ID_TJA_1103			0x001BB010
>  /* Same id: TJA1120, TJA1121 */
> @@ -1971,32 +1970,24 @@ static int nxp_c45_macsec_ability(struct phy_device *phydev)
>  	return macsec_ability;
>  }
>  
> -static int tja1103_match_phy_device(struct phy_device *phydev,
> -				    const struct phy_driver *phydrv)
> +static int tja11xx_no_macsec_match_phy_device(struct phy_device *phydev,
> +					      const struct phy_driver *phydrv)
>  {
> -	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1103, PHY_ID_MASK) &&
> -	       !nxp_c45_macsec_ability(phydev);
> -}
> +	if (!phy_id_compare(phydev->phy_id, phydrv->phy_id,
> +			    phydrv->phy_id_mask))
> +		return 0;
>  
> -static int tja1104_match_phy_device(struct phy_device *phydev,
> -				    const struct phy_driver *phydrv)
> -{
> -	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1103, PHY_ID_MASK) &&
> -	       nxp_c45_macsec_ability(phydev);
> +	return !nxp_c45_macsec_ability(phydev);
>  }
>  
> -static int tja1120_match_phy_device(struct phy_device *phydev,
> -				    const struct phy_driver *phydrv)
> +static int tja11xx_macsec_match_phy_device(struct phy_device *phydev,
> +					   const struct phy_driver *phydrv)
>  {
> -	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1120, PHY_ID_MASK) &&
> -	       !nxp_c45_macsec_ability(phydev);
> -}
> +	if (!phy_id_compare(phydev->phy_id, phydrv->phy_id,
> +			    phydrv->phy_id_mask))
> +		return 0;
>  
> -static int tja1121_match_phy_device(struct phy_device *phydev,
> -				    const struct phy_driver *phydrv)
> -{
> -	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1120, PHY_ID_MASK) &&
> -	       nxp_c45_macsec_ability(phydev);
> +	return nxp_c45_macsec_ability(phydev);
>  }
>  
>  static const struct nxp_c45_regmap tja1120_regmap = {
> @@ -2069,6 +2060,7 @@ static const struct nxp_c45_phy_data tja1120_phy_data = {
>  
>  static struct phy_driver nxp_c45_driver[] = {
>  	{
> +		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103),
>  		.name			= "NXP C45 TJA1103",
>  		.get_features		= nxp_c45_get_features,
>  		.driver_data		= &tja1103_phy_data,
> @@ -2090,9 +2082,10 @@ static struct phy_driver nxp_c45_driver[] = {
>  		.get_sqi		= nxp_c45_get_sqi,
>  		.get_sqi_max		= nxp_c45_get_sqi_max,
>  		.remove			= nxp_c45_remove,
> -		.match_phy_device	= tja1103_match_phy_device,
> +		.match_phy_device	= tja11xx_no_macsec_match_phy_device,
>  	},
>  	{
> +		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103),
>  		.name			= "NXP C45 TJA1104",
>  		.get_features		= nxp_c45_get_features,
>  		.driver_data		= &tja1103_phy_data,
> @@ -2114,9 +2107,10 @@ static struct phy_driver nxp_c45_driver[] = {
>  		.get_sqi		= nxp_c45_get_sqi,
>  		.get_sqi_max		= nxp_c45_get_sqi_max,
>  		.remove			= nxp_c45_remove,
> -		.match_phy_device	= tja1104_match_phy_device,
> +		.match_phy_device	= tja11xx_macsec_match_phy_device,
>  	},
>  	{
> +		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1120),
>  		.name			= "NXP C45 TJA1120",
>  		.get_features		= nxp_c45_get_features,
>  		.driver_data		= &tja1120_phy_data,
> @@ -2139,9 +2133,10 @@ static struct phy_driver nxp_c45_driver[] = {
>  		.get_sqi		= nxp_c45_get_sqi,
>  		.get_sqi_max		= nxp_c45_get_sqi_max,
>  		.remove			= nxp_c45_remove,
> -		.match_phy_device	= tja1120_match_phy_device,
> +		.match_phy_device	= tja11xx_no_macsec_match_phy_device,
>  	},
>  	{
> +		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1120),
>  		.name			= "NXP C45 TJA1121",
>  		.get_features		= nxp_c45_get_features,
>  		.driver_data		= &tja1120_phy_data,
> @@ -2164,7 +2159,7 @@ static struct phy_driver nxp_c45_driver[] = {
>  		.get_sqi		= nxp_c45_get_sqi,
>  		.get_sqi_max		= nxp_c45_get_sqi_max,
>  		.remove			= nxp_c45_remove,
> -		.match_phy_device	= tja1121_match_phy_device,
> +		.match_phy_device	= tja11xx_macsec_match_phy_device,
>  	},
>  };
>  

Reviewed-by: Andrei Botila <andrei.botila@....nxp.com>
Tested-by: Andrei Botila <andrei.botila@....nxp.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ