Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1252858rwe; Thu, 1 Sep 2022 15:23:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR5il+TY2H+ORijgLHFgfE6muy9+7RnBCst761kN/FTTy1aMt9RRH3zlZs8nZu+zjABskgor X-Received: by 2002:a05:6402:2751:b0:443:d90a:43d4 with SMTP id z17-20020a056402275100b00443d90a43d4mr31400369edd.368.1662070985763; Thu, 01 Sep 2022 15:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662070985; cv=none; d=google.com; s=arc-20160816; b=P6YBWnC97FXi9/ga7IW+BdzPRQlvSc8AS3HGAdc7mfuDs8B18cOFLXSXjBAc4CmR1b wmHRZE3KsjElIBqadxGuJ1Bj5hG1jqYmEcERkuaToGxmlAfWWyhVEZ/djxyz3PzWC8jT tzMjjWTdWOpGaLSZecVqMfXQncwhdSly3KRwU6Nltljot9WnFv+YCUZ3tR4iAx9kPFmg +nMXmKgLHbYcbunH38t3RqlC3Qa4tcBVoPVR9Vv6W8FhPUFWiqDFpv34Wu+P44wTQnsk U2171v793kzEc8095HlE87wCF1B5uP118q9ZtGSC1tIARUSr1gYCPlX1hkth3BOJyFiK iHkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wdjSL3TiHg3qFpviZsE8DP2S5RzCHH4DKzPfG+JMhKc=; b=EfcK9goGcBCSUO3CNKc5KCbRnNFzq8HnODUJsSppXgzz5tiZ9PaorbdDalLh14cNjN 0+c8isERwAQaHetP/yLNgDAlDNRETLfGbr6IgFKelULOddJhhQrYQg9EXTYHPLziznjJ 8FzHsGGeOICWi2gtetqAPC1IPMpFTklXBDEzwf1qpZwqq3TSa35duKdNj+r0G+jmvPl1 KmZsted3tt4YyMduAJZw7Hj3K944poOS9IqN0CaDMoJWVt4nq7S3v6t+2dyqcQP7aGqd VG1zpkueaaei5fn+fVz7cokaPg/FA83HDvKq63lmVWqD06rhERij5egES4aWM8z3QSma fxjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=MD31gvVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs7-20020a1709072d0700b00741a18d4a5asi345582ejc.994.2022.09.01.15.22.39; Thu, 01 Sep 2022 15:23:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=MD31gvVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235207AbiIAWVL (ORCPT + 99 others); Thu, 1 Sep 2022 18:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235093AbiIAWUn (ORCPT ); Thu, 1 Sep 2022 18:20:43 -0400 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55043A1A63; Thu, 1 Sep 2022 15:19:10 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id DCC132010; Fri, 2 Sep 2022 00:19:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1662070748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wdjSL3TiHg3qFpviZsE8DP2S5RzCHH4DKzPfG+JMhKc=; b=MD31gvVbYo7tM0nTjHtSpj+l08HOGGoGiWF6xKQiUjq68ekoSRL++w3Q4T1lJIaMTgX8hF Dn5laG5VT2yoyNqpvBuuHnH9UOkfphV5B+jn0SWPSEQtuzaNQTUyx3LpNFWg6BdLDALDWL A35GGTTMPmhrr+ZwOnXXjVOnOkOGIPwDvNC8lubbocR1C/eu341/xSUSvXzs9SI37y9Icj LdLR/xMA+hRltry8fFAP7sKWHQhGLw1QJFAlpuMEyC9B7I5guVEGlhF+7zdY9BWGl04QW8 QVlnsB1qZcsPx+iuszGFE1ezn0hgNlyShJPek5X4+3wRG6nVgHKYv+2Kp27+cw== From: Michael Walle To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Shawn Guo , Li Yang , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Frank Rowand Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ahmad Fatoum , Philipp Zabel , Michael Walle , Andrew Lunn , Jakub Kicinski Subject: [PATCH v2 01/20] net: add helper eth_addr_add() Date: Fri, 2 Sep 2022 00:18:38 +0200 Message-Id: <20220901221857.2600340-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220901221857.2600340-1-michael@walle.cc> References: <20220901221857.2600340-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper to add an offset to a ethernet address. This comes in handy if you have a base ethernet address for multiple interfaces. Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn Acked-by: Jakub Kicinski --- changes since v1: - none include/linux/etherdevice.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index a541f0c4f146..f144cadbe99d 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -507,6 +507,20 @@ static inline void eth_addr_inc(u8 *addr) u64_to_ether_addr(u, addr); } +/** + * eth_addr_add() - Add (or subtract) and offset to/from the given MAC address. + * + * @offset: Offset to add. + * @addr: Pointer to a six-byte array containing Ethernet address to increment. + */ +static inline void eth_addr_add(u8 *addr, long offset) +{ + u64 u = ether_addr_to_u64(addr); + + u += offset; + u64_to_ether_addr(u, addr); +} + /** * is_etherdev_addr - Tell if given Ethernet address belongs to the device. * @dev: Pointer to a device structure -- 2.30.2