From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3BE6C433F5 for ; Sun, 17 Oct 2021 15:08:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B29460FD9 for ; Sun, 17 Oct 2021 15:08:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5B29460FD9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=idosch.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0RBOUZDbDKVBu0k0Tb9aJgn+89zLPQDLmHF6UQGZxdw=; b=wpHXanD0Ap3HDx SuAEmOIIwDlzYX6Fc8N5LT4eWSAl68kfGkziAom38jzvKO5jkAxuEGf2Z4VJ6bvFe4ohn1GrTch+Z g+rpDUprPyXawogy6pv4fLabmEL42oC0jjQcQ3sPC/KSuxK+OfoSUX6g3BxK62AQjVsw90vv+efVB D4T20gwullw7LgZBcyUV1pXEf+CX3uWBCuL6wUwuruWWrJF0SSgq35GMB1l/xKBMPs8fHnx3Mnqyj 7jBWFwAIzgdz4Ja9nOA1/Ssm2j36w4CKn8ljJqZym6H7gNHWIYF6mRJnhRMXFdzIfG7IZE6n55o1U k7libaj4At2Q9beijgqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc7k6-00CpfT-76; Sun, 17 Oct 2021 15:06:30 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc7k2-00Cpes-PZ for linux-arm-kernel@lists.infradead.org; Sun, 17 Oct 2021 15:06:28 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id D5F4658169C; Sun, 17 Oct 2021 11:06:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 17 Oct 2021 11:06:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=5Pe0wu t2jSUUZ3JaYsA7RTwVinQOvg8fx604Qjkaovg=; b=inSrWpuNC5gzL0qgSzdrBn JvcafU+dtnvVGwYRcd1mJ4NVeud4pltocyB1QVuHXEXfs9SuPj7i6CdCB8jEKGo8 W4k+LxYLLfxUzk+mJOxk3Z23PMK/xMD0+hVsUIUqL9F5qYiYJxobfAqQsSxpQds1 p0PrUOeO4Uc3kJsLe7VVl70gzd6pmAgqrq+012yJaIJHWDouUoxp/eqe0frXTrAb S8QrtPujr4MZNc3HPqc1/38LVO/c0sFU9rtM9o8HBOMDrNUI2aSlEkK/SN5OhQ1P aQh7zlp1NkOZ/+Zs8GwKOJQQsLk/IJ58o4i1vTeHkHDoFaNWtl/BHm85is0T+VOg == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddukedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesthdtre dttddtvdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecuggftrfgrthhtvghrnheptdffkeekfeduffevgeeujeffjefhte fgueeugfevtdeiheduueeukefhudehleetnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Oct 2021 11:06:20 -0400 (EDT) Date: Sun, 17 Oct 2021 18:06:17 +0300 From: Ido Schimmel To: Jakub Kicinski 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 Message-ID: References: <20211015193848.779420-1-kuba@kernel.org> <20211015193848.779420-2-kuba@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211015193848.779420-2-kuba@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211017_080626_944496_6ED507DC X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel