Re: [RFC net-next 1/6] ethernet: add a helper for assigning port addresses
From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-10-18 14:17:58
Also in:
netdev
On Sun, 17 Oct 2021 18:06:17 +0300 Ido Schimmel wrote:
On Fri, Oct 15, 2021 at 12:38:43PM -0700, Jakub Kicinski wrote:quoted
+/** + * 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?
Let me make it an unsigned int, I had u8 initially because I wasn't planning on doing the wrapping and wanted the compiler to warn.
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.
_______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel