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: <YWw76V/UfJm3yM2t@shredder>
Date:   Sun, 17 Oct 2021 18:06:17 +0300
From:   Ido Schimmel <idosch@...sch.org>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, olteanv@...il.com, andrew@...n.ch,
        f.fainelli@...il.com, jiri@...dia.com, idosch@...dia.com,
        lars.povlsen@...rochip.com, Steen.Hegelund@...rochip.com,
        UNGLinuxDriver@...rochip.com, bjarni.jonasson@...rochip.com,
        linux-arm-kernel@...ts.infradead.org, qiangqing.zhang@....com,
        vkochan@...vell.com, tchornyi@...vell.com, vladimir.oltean@....com,
        claudiu.manoil@....com, alexandre.belloni@...tlin.com
Subject: Re: [RFC net-next 1/6] ethernet: add a helper for assigning port
 addresses

On Fri, Oct 15, 2021 at 12:38:43PM -0700, Jakub Kicinski wrote:
> +/**
> + * eth_hw_addr_set_port - Generate and assign Ethernet address to a port
> + * @dev: pointer to port's net_device structure
> + * @base_addr: base Ethernet address
> + * @id: offset to add to the base address
> + *
> + * Assign a MAC address to the net_device using a base address and an offset.
> + * Commonly used by switch drivers which need to compute addresses for all
> + * their ports. addr_assign_type is not changed.
> + */
> +static inline void eth_hw_addr_set_port(struct net_device *dev,
> +					const u8 *base_addr, u8 id)

If necessary, would it be possible to change 'id' to u16?

I'm asking because currently in mlxsw we set the MAC of each netdev to
'base_mac + local_port' where 'local_port' is u8. In Spectrum-4 we are
going to have more than 256 logical ports, so 'local_port' becomes u16.

Regarding the naming, eth_hw_addr_gen() sounds good to me.

Thanks for working on this

> +{
> +	u64 u = ether_addr_to_u64(base_addr);
> +	u8 addr[ETH_ALEN];
> +
> +	u += id;
> +	u64_to_ether_addr(u, addr);
> +	eth_hw_addr_set(dev, addr);
> +}
> +
>  /**
>   * eth_skb_pad - Pad buffer to mininum number of octets for Ethernet frame
>   * @skb: Buffer to pad
> -- 
> 2.31.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ