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: <056164ec-3525-479b-3b71-834af48d323c@gmail.com>
Date:   Fri, 29 Jul 2022 10:19:54 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Maxime Chevallier <maxime.chevallier@...tlin.com>,
        davem@...emloft.net, Rob Herring <robh+dt@...nel.org>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        devicetree@...r.kernel.org, thomas.petazzoni@...tlin.com,
        Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        linux-arm-kernel@...ts.infradead.org,
        Richard Cochran <richardcochran@...il.com>,
        Horatiu.Vultur@...rochip.com, Allan.Nielsen@...rochip.com,
        UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH net-next v3 3/4] net: phy: Add helper to derive the number
 of ports from a phy mode

On 7/29/22 08:33, Maxime Chevallier wrote:
> Some phy modes such as QSGMII multiplex several MAC<->PHY links on one
> single physical interface. QSGMII used to be the only one supported, but
> other modes such as QUSGMII also carry multiple links.
> 
> This helper allows getting the number of links that are multiplexed
> on a given interface.
> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@...tlin.com>
> ---
> V1->V2 : New patch
> V2->V3 : Made PHY_INTERFACE_MODE_INTERNAL 1 port, and added the MAX
> case.
> 
>  drivers/net/phy/phy-core.c | 52 ++++++++++++++++++++++++++++++++++++++
>  include/linux/phy.h        |  2 ++
>  2 files changed, 54 insertions(+)
> 
> diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
> index 1f2531a1a876..f8ec12d3d6ae 100644
> --- a/drivers/net/phy/phy-core.c
> +++ b/drivers/net/phy/phy-core.c
> @@ -74,6 +74,58 @@ const char *phy_duplex_to_str(unsigned int duplex)
>  }
>  EXPORT_SYMBOL_GPL(phy_duplex_to_str);
>  
> +/**
> + * phy_interface_num_ports - Return the number of links that can be carried by
> + *			     a given MAC-PHY physical link. Returns 0 if this is
> + *			     unknown, the number of links else.
> + *
> + * @interface: The interface mode we want to get the number of ports
> + */
> +int phy_interface_num_ports(phy_interface_t interface)
> +{
> +	switch (interface) {
> +	case PHY_INTERFACE_MODE_NA:
> +		return 0;
> +	case PHY_INTERFACE_MODE_INTERNAL:

Maybe this was covered in the previous iteration, but cannot the default case return 1, and all of the cases that need an explicit non-1 return value are handled? Enumeration all of those that do need to return 1 does not really scale.
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ