Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp167930rdf; Mon, 20 Nov 2023 21:39:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHC6HUACdRWshuo6zGwQRZBOmmxuo2XBQcwymAne6Ap09a0w4H2f5aOhgYhT/5Xa8L3nvys X-Received: by 2002:a17:90b:1b01:b0:280:2652:d43 with SMTP id nu1-20020a17090b1b0100b0028026520d43mr7507686pjb.17.1700545175835; Mon, 20 Nov 2023 21:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700545175; cv=none; d=google.com; s=arc-20160816; b=rjOrvJnjnjVFVIIdGUtXbLLW3rMWBoCUAF/EZRVLvtLuw4NtcR/pi2tNOB7PwitZhZ ZHJ2PbqDKF24whRx3xzxh6emUiNHDRUjw1vQOfvCwDxP9Y5rPcp4WyCxZkj0ocoeCwSD 9g6r13n4E5PDad1e+MD4OM7xjEwzSC+9/j5aGPpGr8oFo+4dFPs+GLWNTRj2ZTQ9HL3b riY59k4N5BpIAaa1OAQDhY1cniPyYyMZzQ6Z8tcutYJ9JO+vVGwgb8wxlB2gyLRttf1b FOLVZJXxbhFyffJkImMwYNRVOl4IXya7B9Wm2lWb7c0ZDr7MIr8Xfnf0NKavnEqSk6pa Gmkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=LQW7rDZHLAHednjr6CwLp35/rfKTZz098y7kYIUqRsg=; fh=W1zNdNDjVv29IkMwuYMi9mZYm1fbKvygh5gYD8qDsZ0=; b=MCGNge/em3Uh5rGmEunmXaRtUtHUayHo1WhN6/a4x+U86yTyy6fZb1jZbiMpqKA5LH QA8XLwC2sch73eirqWCjiAnTBCaJMg/eZga73IZb/5kgAXq6d/d7UYt79FshoxlF+ese iBZfu4znLOkhz0EXbKFTnzh4ol4TTm3FyjbZFsKsi7LOm6Lx63QJErXOE1UyyLQ0fBC8 HgXj8s08r4TebgEvicC5lW71n8XyD5yC9tTVdl2V5Xln2aEeV/YWif5TdfddzSljsIOi jA2Zdei9xxN5VDvhVwx8RJ1EHF4Q9oNBGybm8Nsg4lBo1LY/QI1uKRt96hKXBbIMT8uq PFtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MZqcj5sn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e6-20020a17090301c600b001cf5193b180si7019969plh.399.2023.11.20.21.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 21:39:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MZqcj5sn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 404EC809841E; Mon, 20 Nov 2023 21:38:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbjKUFi2 (ORCPT + 99 others); Tue, 21 Nov 2023 00:38:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbjKUFiP (ORCPT ); Tue, 21 Nov 2023 00:38:15 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C801212E; Mon, 20 Nov 2023 21:38:11 -0800 (PST) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3AL5bvtx076380; Mon, 20 Nov 2023 23:37:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1700545078; bh=LQW7rDZHLAHednjr6CwLp35/rfKTZz098y7kYIUqRsg=; h=From:To:CC:Subject:Date; b=MZqcj5snYR+Bf6uYiQ5tvwgM95jtUMzhRfC6imY5ponno8qN1B8Zv/lK7Gd7SKwC1 fbdZGAr8XegxVOb/t/G/ILObwDTh/bQCGr1hSWp8wyDfwBh+f3ubf6bTpDpzOlbJgs qlH8lZ+BLEh8iIHKtjaM2/H0z7KXYwoPlJOyMSj0= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3AL5bvF7125153 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Nov 2023 23:37:57 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 20 Nov 2023 23:37:57 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 20 Nov 2023 23:37:57 -0600 Received: from uda0500640.dal.design.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3AL5br7S084679; Mon, 20 Nov 2023 23:37:54 -0600 From: Ravi Gunasekaran To: , , , , CC: , , , , , Subject: [PATCH net-next v2] net: hsr: Add support for MC filtering at the slave device Date: Tue, 21 Nov 2023 11:07:53 +0530 Message-ID: <20231121053753.32738-1-r-gunasekaran@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Mon, 20 Nov 2023 21:38:38 -0800 (PST) From: Murali Karicheri When MC (multicast) list is updated by the networking layer due to a user command and as well as when allmulti flag is set, it needs to be passed to the enslaved Ethernet devices. This patch allows this to happen by implementing ndo_change_rx_flags() and ndo_set_rx_mode() API calls that in turns pass it to the slave devices using existing API calls. Signed-off-by: Murali Karicheri Signed-off-by: Ravi Gunasekaran Reviewed-by: Wojciech Drewek --- Changes since v1: * Renamed "hsr_ndo_set_rx_mode" to "hsr_set_rx_mode" based on Wojciech's comment * Picked up Wojciech's Reviewed-by tag from v1 * Rebased to tip of linux-next v1: https://lore.kernel.org/netdev/20231120110105.18416-1-r-gunasekaran@ti.com/ net/hsr/hsr_device.c | 67 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 306f942c3b28..7ceb9ac6e730 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -173,7 +173,24 @@ static int hsr_dev_open(struct net_device *dev) static int hsr_dev_close(struct net_device *dev) { - /* Nothing to do here. */ + struct hsr_port *port; + struct hsr_priv *hsr; + + hsr = netdev_priv(dev); + hsr_for_each_port(hsr, port) { + if (port->type == HSR_PT_MASTER) + continue; + switch (port->type) { + case HSR_PT_SLAVE_A: + case HSR_PT_SLAVE_B: + dev_uc_unsync(port->dev, dev); + dev_mc_unsync(port->dev, dev); + break; + default: + break; + } + } + return 0; } @@ -404,12 +421,60 @@ void hsr_del_ports(struct hsr_priv *hsr) hsr_del_port(port); } +static void hsr_set_rx_mode(struct net_device *dev) +{ + struct hsr_port *port; + struct hsr_priv *hsr; + + hsr = netdev_priv(dev); + + hsr_for_each_port(hsr, port) { + if (port->type == HSR_PT_MASTER) + continue; + switch (port->type) { + case HSR_PT_SLAVE_A: + case HSR_PT_SLAVE_B: + dev_mc_sync_multiple(port->dev, dev); + dev_uc_sync_multiple(port->dev, dev); + break; + default: + break; + } + } +} + +static void hsr_change_rx_flags(struct net_device *dev, int change) +{ + struct hsr_port *port; + struct hsr_priv *hsr; + + hsr = netdev_priv(dev); + + hsr_for_each_port(hsr, port) { + if (port->type == HSR_PT_MASTER) + continue; + switch (port->type) { + case HSR_PT_SLAVE_A: + case HSR_PT_SLAVE_B: + if (change & IFF_ALLMULTI) + dev_set_allmulti(port->dev, + dev->flags & + IFF_ALLMULTI ? 1 : -1); + break; + default: + break; + } + } +} + static const struct net_device_ops hsr_device_ops = { .ndo_change_mtu = hsr_dev_change_mtu, .ndo_open = hsr_dev_open, .ndo_stop = hsr_dev_close, .ndo_start_xmit = hsr_dev_xmit, + .ndo_change_rx_flags = hsr_change_rx_flags, .ndo_fix_features = hsr_fix_features, + .ndo_set_rx_mode = hsr_set_rx_mode, }; static struct device_type hsr_type = { base-commit: 07b677953b9dca02928be323e2db853511305fa9 -- 2.17.1