Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7990935rwb; Tue, 6 Dec 2022 12:29:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pHX6kseOhTcNXTw+F3lSV6NRu2hVO4c+rHtFoCOknIUANGQp+dwSqzBzt26Lb10FMgs5n X-Received: by 2002:a17:906:dfe1:b0:7c1:bb5:7757 with SMTP id lc1-20020a170906dfe100b007c10bb57757mr3491159ejc.633.1670358572984; Tue, 06 Dec 2022 12:29:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670358572; cv=none; d=google.com; s=arc-20160816; b=bhnlsB+DZ3lUI+BY6CmoB+Lbf25coJa4jY9ybsYN3rJX+P+Kj3/aZdurj+jFgKrAyH I0DGtWgtgqKj7Sxbw2nv82DBdAPV9lIwp9KfvtdrxQQnx9KRNU/6sfw417BqSI5eJnXS q7/279zE95v6tYCdhNZryi6i10wFTGagEm71F+S9ztlg2oiyKoOC3HaS5Z1TAG9WUDw+ IVl30chJon2daTHdHATyNxqF8qynSwv34h1pAUAqE3D6FvzwlvJQR7NU19/Wp7pPoGa1 dK2DB0bsvXL+OuqejZQVuzPlcxckhLx8Y199h7UvX3ybKuVDYVsdTAXmyKwC85O8QIR8 QJmg== 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=ILxP0jW0nBzAhvh7z1J9P1H1PJrtvXTRHQ4DduPRocE=; b=Kvk8iMXPZqO/iiRA8xNlFmOBnhujWr9WBvJ65jGcYwZHAvUgGWf4vwhdcvVrGsa7bG QShT4YYmajMQEGyjygD+8L0NciG6w9x1F64XjPFZu+slJt2vYJUXeWF3/YxyBXaoFs9J y+cHIe7CwGCSF7tG+I7t0+e0B7NOZzmm9RoN6IqCsIGDeE78S9jS+F55JX+n4EnmyUBX bxUUwE6vWgZs8N5zrVyXtqfqz00N9gEvxewnVLas5hCjd1bPWkx4O/3QWbs2cXYUqpj2 9HpPE59EPG/FgBoCy291IWYGFvHPxlCeu2OM9tnuOmbwxewAW95xKb1tLA6fGYIqeapd mpHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="Q5qPxmm/"; 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 o11-20020a170906974b00b007c0cb3c5a70si9847957ejy.650.2022.12.06.12.29.14; Tue, 06 Dec 2022 12:29:32 -0800 (PST) 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="Q5qPxmm/"; 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 S229699AbiLFUHx (ORCPT + 77 others); Tue, 6 Dec 2022 15:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiLFUHu (ORCPT ); Tue, 6 Dec 2022 15:07:50 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F62CE05; Tue, 6 Dec 2022 12:07:48 -0800 (PST) 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 05674256D; Tue, 6 Dec 2022 21:07:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1670357266; 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=ILxP0jW0nBzAhvh7z1J9P1H1PJrtvXTRHQ4DduPRocE=; b=Q5qPxmm//GWuGUlu28YuGCCZP07ElXzUaoHnPSgrXHcDyHCa2WZcE7jxPiIik1qKI0Iqgh KMJveO7U2Ty0lStusmHGY8dOCKR0XyQpbK29xr/XoAqQafBs7PzHIBduj9TVG2U+Eg5jg2 Z+oF/N7bfk13aGNnL++TvrhJpN/DGKskUQPoUTQM+ycjfETt4ClSZKOeY4NEO64EOOlpVM GhOIx/KDDJieM3CaJ8oVIu6KUambo+SdO58wK1djNdh4qnXZybtKSEYu9LQUQpOfbM+ifc zVjzZ+6aUFnOqOQHlDcJoL7LWM6poTCgv1yIKBVLu/5M9GCmUKijOwkgA3T8SA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle , Dan Carpenter , Andrew Lunn , Jakub Kicinski Subject: [PATCH v5 01/21] net: add helper eth_addr_add() Date: Tue, 6 Dec 2022 21:07:20 +0100 Message-Id: <20221206200740.3567551-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221206200740.3567551-1-michael@walle.cc> References: <20221206200740.3567551-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 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 v4: - none changes since v3: - fix typo s/and/an/ changes since v2: - none 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..224645f17c33 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) an 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