Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2996672rdb; Fri, 22 Sep 2023 14:49:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiujekPJsZ+YGpGziujV3cwD3oJvzRgumzoAE9eUKXKbLtYN5qSi5pXuz+qvhNwCCWDwqs X-Received: by 2002:a17:90b:4a4b:b0:26d:49c8:76d8 with SMTP id lb11-20020a17090b4a4b00b0026d49c876d8mr866338pjb.18.1695419398487; Fri, 22 Sep 2023 14:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695419398; cv=none; d=google.com; s=arc-20160816; b=ziz6D4qztOpnKFAG2/PY04D94sM6ohQx71kT5+uIM/ab3drjIJvjOZ6uzHSCTmpQRU GOXQdhNjtw3iXDC1VwUgteHe/LUuv3umeFVVIacNUcjqJB8OZtfEwVhRgNubsosAEMPn 0+tI2OJomyDNISfHEIYd7R4lzW6u4+flM2vjoeVbiCcOYzDnpYzOLCm7wKWK9dstCXtt /wbb3mRH8laCVc6XUxVnm8PQQ0DCbmVI0B96wQTcWwaAILWde1cyMDQ9vskGxNj8L6xS 9wqhKu+ZTiyYNS6LsQ08ifLdb4YQajTNpkMtrdebVbfKpDxAu+rIENwBeUFFMdoyTuFy fnRg== 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=vmNuVlqmEFXjO6DC8o8YTxJvDDK3OrOeO1xwI+V/cgE=; fh=pS1C7Vbe/+UXtC8+indT5iG8c7LzMoOEoDfoWy8vSDc=; b=eczWz3pSP0uoZFOTkJWsazMf1E6HEQPrOWoYVp3ajnk5t4yoEcyyASGDpC5h3RrcsQ vO0ok/FMLFU+PYbcL5aOGmRmB4rkQPBQopvMd+Xe2DXdcEtXKdX04HXk3syosPYouq/n AiuLkpXxSuoHlZd6Y0T/a75atNwPCQj0C3Z4Nqwi756xGtuV3rTtwgrKSC9zCMxsXP40 qxb64mVHydjakWVMfQUirqzoaSrNfqzu+FzcnZowbZwKsaLcV4yj9fVQ73DsyDGBzMbc 9qri4nsdvg69SPSUU6Pj4dPM3Z3lKTZA0PSK4s7/DHFrgFaR7mCBBd1nQQIMI/2HhslZ FXHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=FxL5MQHq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j6-20020a170902c3c600b001c5f0d8f2e5si1229337plj.32.2023.09.22.14.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 14:49:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=FxL5MQHq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E5F2D80677C4; Fri, 22 Sep 2023 06:31:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234104AbjIVNbn (ORCPT + 99 others); Fri, 22 Sep 2023 09:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234076AbjIVNbi (ORCPT ); Fri, 22 Sep 2023 09:31:38 -0400 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D88A2CE; Fri, 22 Sep 2023 06:31:30 -0700 (PDT) Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2EA498641B; Fri, 22 Sep 2023 15:31:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1695389489; bh=vmNuVlqmEFXjO6DC8o8YTxJvDDK3OrOeO1xwI+V/cgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxL5MQHqGuWEup0bG/OLgUuVLV2gnj/kwBJidjetD7K50dp15z6zxvsjP1T2u4LKt S6vBSEtxxt1M5ihjluf1gfJmWrAinKWkzxnz+ST2fSA9Qb9SfcuIUdbBgU0qZ8QrRi k5o5pXW2fZPnjgcRAYEaecQiZKnPPW18d5dRW2kZTrlXAtSXW717TZzafYlKG1PynQ aE95s7+k370mP0OKz+M1NK6hYZkYQWG6ZvIQPsYCABJ5uMS1KqKj5P4mBCpr7TTbak 1DM71VvJEaMkv+WZe9Goi7ZVEEcdanchQty4aoKjp0+nMPaMOWwBZ1otXHQM+uUr3m N8ePwr0uivYcw== From: Lukasz Majewski To: Tristram.Ha@microchip.com, Eric Dumazet , Andrew Lunn , davem@davemloft.net, Woojung Huh , Vladimir Oltean , Oleksij Rempel Cc: Florian Fainelli , Jakub Kicinski , Paolo Abeni , UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Oltean , Lukasz Majewski , Florian Fainelli Subject: [PATCH v6 net-next 2/5] net: dsa: notify drivers of MAC address changes on user ports Date: Fri, 22 Sep 2023 15:31:05 +0200 Message-Id: <20230922133108.2090612-3-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922133108.2090612-1-lukma@denx.de> References: <20230922133108.2090612-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 06:31:46 -0700 (PDT) From: Vladimir Oltean In some cases, drivers may need to veto the changing of a MAC address on a user port. Such is the case with KSZ9477 when it offloads a HSR device, because it programs the MAC address of multiple ports to a shared hardware register. Those ports need to have equal MAC addresses for the lifetime of the HSR offload. Signed-off-by: Vladimir Oltean Signed-off-by: Lukasz Majewski Reviewed-by: Florian Fainelli --- Changes for v5: - New patch Changes for v6: - None --- include/net/dsa.h | 10 ++++++++++ net/dsa/slave.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 426724808e76..d98439ea6146 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -969,6 +969,16 @@ struct dsa_switch_ops { struct phy_device *phy); void (*port_disable)(struct dsa_switch *ds, int port); + + /* + * Notification for MAC address changes on user ports. Drivers can + * currently only veto operations. They should not use the method to + * program the hardware, since the operation is not rolled back in case + * of other errors. + */ + int (*port_set_mac_address)(struct dsa_switch *ds, int port, + const unsigned char *addr); + /* * Compatibility between device trees defining multiple CPU ports and * drivers which are not OK to use by default the numerically smallest diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 2b3d89b77121..4c3e502d7e16 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -457,6 +457,13 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; + if (ds->ops->port_set_mac_address) { + err = ds->ops->port_set_mac_address(ds, dp->index, + addr->sa_data); + if (err) + return err; + } + /* If the port is down, the address isn't synced yet to hardware or * to the DSA master, so there is nothing to change. */ -- 2.20.1