Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1102121rwe; Thu, 25 Aug 2022 15:46:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR681tBv0G6asciBICd34vts6QWKQ7m2wrY7YJfwTrxK+G4qRXqmiQc3d7nYerDayivWb4rB X-Received: by 2002:a17:907:7388:b0:73d:c311:2f3e with SMTP id er8-20020a170907738800b0073dc3112f3emr3725972ejc.158.1661467559852; Thu, 25 Aug 2022 15:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661467559; cv=none; d=google.com; s=arc-20160816; b=K/82UocoFHdojvt2fy56ctey357adq9c7BLwnQGFqpAdiGQhvg9O915IDNMbdlJfNe patc4tkEN4npT8ygVMx3soanCaTRfw6/NsIGyqU3BbN4XTWeIMVUx2VpfHerE//dOSv6 REoBP+P3i1IymKW4KL5h98CZLHzvAE4B9tN3eGm3a2tX6x1IE9ukI8qIRwV10QnnBLpD csaV+77azezNCFJM5qVX4HM8rQygOU4jGw98wXec2nBWCBkPoejZPGAbAMvRtraNMPo9 yObiKrXoV9MEE7Vwq7H6uUOfUWdvkaR/jDnTkU9jHBGHzzY2pynyUBePFUwEZQC6rxwz MO/g== 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=5zX8TjV8dOnJxKMl5NAJkTUty3DOJ6KEgZ/kYBbKIV8=; b=pUvsQeWxq1MfDA1sygfF4NupEzoumkAFZyiN8e2Q9N0Dvalx/MQgkU38EPHlCN2tuR 4QlpbFVMI8wmU1H+UlhibSt7jxvTezTvNej0vBpuP/jMmeLPZiHVeyJ7QV2zzD/MspMR 9YIG/CAMZDQdAQtiMqk9n0f7jqKoJyvk3vnBQh6M1x/zMC2jSXkzrf5iLsvBE6/4GYh2 5onQ2NNI7IrNYuMLzbi4g2oBc5rWOHojdurO29iT/E294vb0DuuysizM65d7QQ5HUKP4 WfpRwNcboQLppDlB7+9VhusnZ2aat/HlYwZovAEU7XnAUAF6AXB9yn0hF9EGX7oTHzH1 zYcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=XB4NXM87; 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 wv2-20020a170907080200b0073e214e7ec5si315047ejb.94.2022.08.25.15.45.34; Thu, 25 Aug 2022 15:45:59 -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=XB4NXM87; 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 S244061AbiHYVpB (ORCPT + 99 others); Thu, 25 Aug 2022 17:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244001AbiHYVou (ORCPT ); Thu, 25 Aug 2022 17:44:50 -0400 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F044AC22B7; Thu, 25 Aug 2022 14:44:40 -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 161817F2E; Thu, 25 Aug 2022 23:44:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1661463876; 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=5zX8TjV8dOnJxKMl5NAJkTUty3DOJ6KEgZ/kYBbKIV8=; b=XB4NXM872kGcTLCruhp6Nxw8vdVKpW5vwcqPrnH+OYu9aer1qGfz9rzEpjs1Crf2KUV/Qm FOCV8bfXuLjziajVsbUgw0I2d1nBm5dDWGTNmrUf9jOlHfwjUrXUETkUiZ6ZsPutscxK/P oYXnPf3S3zwyW2XCRVXGEvWwa+L3lY1R6Z7AOUe/YeICN0Z/5KfCORfonTzK878knZ1cYb TbPl0A0Ax0+uiMmaCn/mTIPCTV7Y12/JB0NntKeuzVXIkwMWalRaTwarHT2fYO3XIujh9M iujJat5JCbPNiNnCUXu65BFQztrE8u7JoaHIrOKLPIImJjtkQ9ng5wEGF6uyyQ== 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?= , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Frank Rowand Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Ahmad Fatoum , Michael Walle Subject: [PATCH v1 01/14] net: add helper eth_addr_add() Date: Thu, 25 Aug 2022 23:44:10 +0200 Message-Id: <20220825214423.903672-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220825214423.903672-1-michael@walle.cc> References: <20220825214423.903672-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,URIBL_BLOCKED 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 --- include/linux/etherdevice.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 92b10e67d5f8..d1be5ca4d5cb 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -485,6 +485,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