Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7769528rwb; Wed, 23 Nov 2022 10:28:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4QDWVVdYm+At4A+CTt+NH6+/gurw6AfN11PTLEkpT2Z3J8sZBGdvPa7z6xm9Ca7Z8YZE0n X-Received: by 2002:a17:902:8548:b0:188:6300:57ad with SMTP id d8-20020a170902854800b00188630057admr16472055plo.7.1669228096321; Wed, 23 Nov 2022 10:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669228096; cv=none; d=google.com; s=arc-20160816; b=BHsq6pLnHK2x3BOBbI4UqiPISLNsWRCqtd0J/k66Frjp6dCEhfH9idozd+621D23aQ 5ZbwN7ymAMp8HKzU9MqWyo3d8vFUx/HD/vW+HdIYDsiRAAh835qqXC9Ma87f1FVH7K3z rM0NZ+BBXrx44+QWxzzJN+4eubXZEYUg/FIZBefERaDgGBkRQD6ldedOQtWnyQ6oCnEw iBcbTIpkHmbCAJ4B1FZu8hH12G/VXIpqrHvef+51uE/I0ntwJI0j8pyJYUgFeUlUFGiQ IigjZ4ek20IRNxlbXBiJkexKTbwcrgEmMwc0t1uikD0pwpxW4z//ZvgkL1/C87D5I96H LLJA== 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=8sjjk67lYXsbZ+8cTcOR9HPiqjFzaTQLO5gq3X9c4IA=; b=houj/tp2kQgibY+Xq8JadLReikrniSO1vu2i6UcAXqu86fFwffHdWKCtgplJyjAxzk 1jK1izDuo3cyGsF5+EZEvBuqV2UfwqJPyrekGN96i+zbufUUnIRmuWOEIdPQbnHS9lGR Z0/zDxAJS3IveaH8XKZsWOoU60P8Nm5PaYwzj1vC87stRv75pUiH9pXW8zLJYdTfk0bB nHVHLGpSLxLmZC6mBLkF+TdWyuO4TF7qnmXeuZXxyui3AfEKgD2CTpTx9vyi3m/ZinfW a56acc8Mzizx7AvhulMDirKyRa/T7iOf52Ua9eTxsrMrBOhH/W3Z8mgZ07UKqePNCyXp EHLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=zeAXKIkh; 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 p1-20020a056a000a0100b0056dde9895e1si18161687pfh.46.2022.11.23.10.28.04; Wed, 23 Nov 2022 10:28:16 -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=zeAXKIkh; 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 S239496AbiKWSDL (ORCPT + 88 others); Wed, 23 Nov 2022 13:03:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239365AbiKWSCV (ORCPT ); Wed, 23 Nov 2022 13:02:21 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4B1E93700; Wed, 23 Nov 2022 10:02:20 -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 59D7C27B2; Wed, 23 Nov 2022 19:02:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226538; 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=8sjjk67lYXsbZ+8cTcOR9HPiqjFzaTQLO5gq3X9c4IA=; b=zeAXKIkh1NfD6yON6Wk9huqk9GL/RNNI0wcW3b+xZN/jZNrEJoLcYjTEq9j4Ei5Q8OHFU8 H/a+SvAyy9EIJtraA9MccxRXjPdez1bvmYjbK0qoUTnfBjtC+nTKjVg26J022Nzn7lLD3o t1ZSX8SOaqfRgO6+D+DZB8XHvNSMGp3Vc/QdG4DP8kwEHHvLh8yElLsp8DN82kS7XmzLW3 Nfe2yxX2UAR7Z+7vV8GfV6dv24MeKJr/CyEeg0lLrF4HQJ9xhreMlvdcOpTt9r0olAMoMM J7C5evjwohYhc8R7fAUtXjczWJNuOzCB5YJAQ7eyIKZ87Tl9o2QpK/Rz+V3c9w== 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 , Andrew Lunn , Jakub Kicinski Subject: [PATCH v4 01/20] net: add helper eth_addr_add() Date: Wed, 23 Nov 2022 19:01:32 +0100 Message-Id: <20221123180151.2160033-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-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 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