From patchwork Thu Aug 25 21:44:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 1670394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kgcgGubL; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=walle.cc header.i=@walle.cc header.a=rsa-sha256 header.s=mail2022082101 header.b=XB4NXM87; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MDGjS1mxQz1ygw for ; Fri, 26 Aug 2022 07:45:32 +1000 (AEST) 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DbWpXoQn4xt1FArwcgolBqr8WCbH9G7sa+zgPE6uBVs=; b=kgcgGubLeltrdq Srz3IbrgI7/gdUuirtMqI5O4en2gDVBG51EZRTpWVTgzTHy5Ypz/XsH/tl9Tbvd1lg2tBBsQadIyj Ryc1rfYqWL2/sRrlCf6y7K2bnJVX0ubFc4O8lBadVUPrLwSSBZUvEISot+gpyLJJuz56a5fEtU9DD NCHfiYmS0lOkWIjHL3xZVLniP9C33uZAvDEGhFpLTkx8Yk95daBtJL3lXed6zGeCYMqjIBtRaowqQ JsMPremqUjrDU+CiIQ+uc+vulBWjv5Cl13bXP1DMptARAC2SeGh3JDdNdzaFfmM7mhcK2bObhnkVj k9LnOjvGitZ1oVBszbBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRKen-003XcC-0y; Thu, 25 Aug 2022 21:44:57 +0000 Received: from 0001.3ffe.de ([159.69.201.130] helo=mail.3ffe.de) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRKeW-003XRG-De; Thu, 25 Aug 2022 21:44:41 +0000 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?b?UmFmYcWCIE1pxYJlY2tp?= , "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 X-Spam: Yes X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220825_144440_653041_CF1E0ADC X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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 --- 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