netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, olteanv@gmail.com, andrew@lunn.ch,
	f.fainelli@gmail.com, jiri@nvidia.com, idosch@nvidia.com,
	lars.povlsen@microchip.com, Steen.Hegelund@microchip.com,
	UNGLinuxDriver@microchip.com, bjarni.jonasson@microchip.com,
	linux-arm-kernel@lists.infradead.org, qiangqing.zhang@nxp.com,
	vkochan@marvell.com, tchornyi@marvell.com,
	vladimir.oltean@nxp.com, claudiu.manoil@nxp.com,
	alexandre.belloni@bootlin.com
Subject: Re: [RFC net-next 1/6] ethernet: add a helper for assigning port addresses
Date: Sun, 17 Oct 2021 18:06:17 +0300	[thread overview]
Message-ID: <YWw76V/UfJm3yM2t@shredder> (raw)
In-Reply-To: <20211015193848.779420-2-kuba@kernel.org>

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
> 

  parent reply	other threads:[~2021-10-17 15:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 19:38 [RFC net-next 0/6] ethernet: add eth_hw_addr_set_port() Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 1/6] ethernet: add a helper for assigning port addresses Jakub Kicinski
2021-10-15 21:36   ` Shannon Nelson
2021-10-15 22:30     ` Jakub Kicinski
2021-10-15 22:50       ` Vladimir Oltean
2021-10-17 15:06   ` Ido Schimmel [this message]
2021-10-18 14:08     ` Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 2/6] ethernet: ocelot: use eth_hw_addr_set_port() Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 3/6] ethernet: prestera: " Jakub Kicinski
2021-10-15 23:51   ` Vladimir Oltean
2021-10-16  0:17     ` Jakub Kicinski
2021-10-16  0:27       ` Vladimir Oltean
2021-10-18 16:54     ` Taras Chornyi [C]
2021-10-18 17:01       ` Jakub Kicinski
2021-10-18 18:20         ` Taras Chornyi
2021-10-16 21:19   ` Shannon Nelson
2021-10-18 14:19     ` Jakub Kicinski
2021-10-18 16:26       ` Shannon Nelson
2021-10-18 17:33         ` Ido Schimmel
2021-10-18 17:54           ` Shannon Nelson
2021-10-18 19:15             ` Ido Schimmel
2021-10-15 19:38 ` [RFC net-next 4/6] ethernet: fec: " Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 5/6] ethernet: mlxsw: " Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 6/6] ethernet: sparx5: " Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YWw76V/UfJm3yM2t@shredder \
    --to=idosch@idosch.org \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=bjarni.jonasson@microchip.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=qiangqing.zhang@nxp.com \
    --cc=tchornyi@marvell.com \
    --cc=vkochan@marvell.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).