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:   Mon, 10 Oct 2022 21:35:35 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Raju Lakkaraju <Raju.Lakkaraju@...rochip.com>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        linux-kernel@...r.kernel.org, bryan.whitehead@...rochip.com,
        edumazet@...gle.com, pabeni@...hat.com,
        UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH net-next V3] net: lan743x: Add support to SGMII register
 dump for PCI11010/PCI11414 chips

>  static int lan743x_get_regs_len(struct net_device *dev)
>  {
> -	return MAX_LAN743X_ETH_REGS * sizeof(u32);
> +	struct lan743x_adapter *adapter = netdev_priv(dev);
> +	u32 num_regs = MAX_LAN743X_ETH_COMMON_REGS;
> +
> +	if (adapter->is_sgmii_en)
> +		num_regs += MAX_LAN743X_ETH_SGMII_REGS;
> +
> +	return num_regs * sizeof(u32);
>  }
>  
>  static void lan743x_get_regs(struct net_device *dev,
>  			     struct ethtool_regs *regs, void *p)
>  {
> +	struct lan743x_adapter *adapter = netdev_priv(dev);
> +	int regs_len;
> +
> +	regs_len = lan743x_get_regs_len(dev);
> +	memset(p, 0, regs_len);
> +
>  	regs->version = LAN743X_ETH_REG_VERSION;
> +	regs->len = regs_len;
> +
> +	lan743x_common_regs(dev, p);
> +	p = (u32 *)p + MAX_LAN743X_ETH_COMMON_REGS;
>  
> -	lan743x_common_regs(dev, regs, p);
> +	if (adapter->is_sgmii_en) {
> +		lan743x_sgmii_regs(dev, p);
> +		p = (u32 *)p + MAX_LAN743X_ETH_SGMII_REGS;
> +	}

This seems O.K. for the moment, but how does it work when you add the
next set of optional registers? Say you want to add the PTP registers?

One idea might be to use the LAN743X_ETH_REG_VERSION as a
bitfield. Bit 0 indicates the common registers are present. Bit 1
indicates the SGMII registers are present. Bit 2 is for whatever next
set of optional registers you add, say PTP.

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ