From patchwork Fri Nov 4 20:48:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 15791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp632051wru; Fri, 4 Nov 2022 13:52:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM55G6ihZSJIAbrbuS+qMVOtgImp7ZFGN1DCr7sz1E5V17UL8HDoyyxULcy++mWAQMmWfgvI X-Received: by 2002:a63:d043:0:b0:46f:8466:1f78 with SMTP id s3-20020a63d043000000b0046f84661f78mr31006178pgi.119.1667595173239; Fri, 04 Nov 2022 13:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667595173; cv=none; d=google.com; s=arc-20160816; b=vST5lgDNprimwI+PFGUVmHUQIssNCw3d40OuE8H/b771wcqvm472hfPe/c508nWuGk am6C/FDTwbJVgaK9PmO5oOPOTQWuza2k+2qAWG/sPObq3JFtX48/sS2bIaQtm8tbcFDJ 8immV2sxVIdmO/SfwFtc1vFcclQWO8U+aSVSuyVYiKFn33j5aCMesMzcaj3pFgDXjuOG s72GyIpAezE3DH2gf0y2OcmIEha+qspQxT6JpVHPMMFqtNuEa75nENQnQtGvOdhuD6H0 14R15vrWGQOICR9GGzMDj9N/lCe2HBB3THniTx/feaM1aOqrDB29dW6H5EkTJBJnK62F UJiw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=mBvld+GgZuPiLK5vglNTcPwqj1bswkQ3GQEVIj7NMyw=; b=phAL80QvrHz44MZW8DPqkARAEWtUiDrP2MqE6yamW8tBlRMfiXlUYlUiq5jbnq5ds3 Da5StbX3VemXSg1UyQR+f5gpIWTAacxwi54i+48vvNKRBqGzSPcT6hZLaqLi5CqfHuGz 1x7tV8CWL0wmdU3aALEMo4WPqa3JLzttnKEtApJM7sSuLJz4Y5zQh8lNRXRkc/A0D+l/ WQyJNf9Z7wLMK5Y5YtwDm2qpC62iEEm4IaeiLq+t+n7bJ0DrCEjorEd65LYKX8T07oph 9aq2dPERWWVdce3ebBBCM3kG1KLxkMxM0sd3SZqRGgubF+nfWQBJ9qheN9gqnLgvxZDJ DPSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=r8+I9EXL; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p3-20020a056a000a0300b0056bffcfc30csi237492pfh.249.2022.11.04.13.52.40; Fri, 04 Nov 2022 13:52:53 -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=@linux.dev header.s=key1 header.b=r8+I9EXL; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbiKDUtc (ORCPT + 99 others); Fri, 4 Nov 2022 16:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiKDUta (ORCPT ); Fri, 4 Nov 2022 16:49:30 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94EF0A1A1; Fri, 4 Nov 2022 13:49:28 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1667594967; 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; bh=mBvld+GgZuPiLK5vglNTcPwqj1bswkQ3GQEVIj7NMyw=; b=r8+I9EXLydrVa4Wevv5Oq7/afV1wabK2W07ZbKn9WCMjm/0ThRH/GOSlCvPazahHtaWpCN owxNQehsUYm/i5P4Wv1sHSc6kGlWmN9TP1Yit6cooPMxZ0wfC4nOfFMkUi/rJVe6/KMK73 cu0rcoSKVcs888NJ0zEPKBOgm/3/WxQ= From: Roman Gushchin To: netdev@vger.kernel.org, Claudiu Beznea , Nicolas Ferre Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, Roman Gushchin Subject: [PATCH net-next] net: macb: implement live mac addr change Date: Fri, 4 Nov 2022 13:48:37 -0700 Message-Id: <20221104204837.614459-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748600276492029716?= X-GMAIL-MSGID: =?utf-8?q?1748600276492029716?= Implement live mac addr change for the macb ethernet driver. Signed-off-by: Roman Gushchin Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/cadence/macb_main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 4f63f1ba3161..991d5041c836 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2947,6 +2947,18 @@ static int macb_change_mtu(struct net_device *dev, int new_mtu) return 0; } +static int macb_set_mac_addr(struct net_device *dev, void *addr) +{ + int err; + + err = eth_mac_addr(dev, addr); + if (err < 0) + return err; + + macb_set_hwaddr(netdev_priv(dev)); + return 0; +} + static void gem_update_stats(struct macb *bp) { struct macb_queue *queue; @@ -3786,7 +3798,7 @@ static const struct net_device_ops macb_netdev_ops = { .ndo_eth_ioctl = macb_ioctl, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = macb_change_mtu, - .ndo_set_mac_address = eth_mac_addr, + .ndo_set_mac_address = macb_set_mac_addr, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = macb_poll_controller, #endif @@ -4049,6 +4061,8 @@ static int macb_init(struct platform_device *pdev) dev->ethtool_ops = &macb_ethtool_ops; } + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; + /* Set features */ dev->hw_features = NETIF_F_SG;