Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp183088lqr; Wed, 5 Jun 2024 02:54:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXfLkVTNLVxcxwdh6XHSEwP+vBxaYh2KSAema9/WdfSTILTuw/ADLcQACMXcUjL2UiwZ8/Z338tlHjeIVWOJv1qHc/dvuu84P4DUqFdA== X-Google-Smtp-Source: AGHT+IGXGlbRGP2EpGM8Fu/gjTMJHemt4MDQVcW1f3jc1CkzUVDxKCxbHFlyKjeFe4sliPoyVO7A X-Received: by 2002:a50:d6de:0:b0:57a:3366:d750 with SMTP id 4fb4d7f45d1cf-57a8b6ac741mr1785440a12.14.1717581269516; Wed, 05 Jun 2024 02:54:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717581269; cv=pass; d=google.com; s=arc-20160816; b=dgeaeI+Nlfw2U3GzC5bQQR+t+30zf113UFdFMd0gDoaO52HdKPOeyIJXcTXDx7p5ED e4VhMm6RwzllSLljStUvGlV49afjnWy8+AciI7I2XZoCY/1mtDeZMI8t+EmCOY9C0o7o 0VhyVvQFYetX+uBd9yNKeIUninusznNlN+SuzWRyoFrhh+xjAYbeGa6p8f1hwcXBiql6 /i7zf4+awgENblUnNkvhrIIeLFg8hnHpnlDs3b5Jd+NDP6Oce7BnqgHfacA5KUeLjrMQ q6BxY2rRjTKhcZJPp/CIruCV128Bkxli6hOFaIn06GfIy4OCuWCYBPDPVtadkwnUVMMs ziXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Lu9R3HFjqY+joNvpPu5u8Mxhs9oQxQ+UkNosv0uJ7MQ=; fh=bmyqGAgTe+x84EN2m1EHI7B5oXKxOQhXDjQUtNuUWNg=; b=gGzt6iWwDFwSfqcFLQBRcB5GxKSqqd0K9RBZJV6JMAm1tkyzC4eOykM+qhBISoDqwS V2vL3R2VnDq+rKj8HPe+/X1UuEC+LZk6MLrTeaxsd/PVNhvcUdAkt4RBkkY1lF3Bhyms t2AniQxlQUHfCSD7z3UIb0i1V+297c7Xmj9pb/qS9auHG1MnLzKJhAfLsoQIebjIkbQf d3HHbAIZBI8enptk338jBX2gQQ6GIW/vZL65Nx2MruNNEvwHyVIHA9nUeN45J9kkKYZT 3N6CthkYF233C9jki1utYFRlu9bOcl6WsBYYEtxK9pN+doU1Vw17IBfvg/T9MJsO4cQe UV5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wCABgHQV; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-202148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c7776csi6164786a12.435.2024.06.05.02.54.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 02:54:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wCABgHQV; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-202148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 807C61F223EB for ; Wed, 5 Jun 2024 09:53:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7335618FDC7; Wed, 5 Jun 2024 09:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="wCABgHQV" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B39844963B; Wed, 5 Jun 2024 09:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717581179; cv=none; b=dGruKXRIEC41mvelG0GmU1HBEEIpMPjQYwW+QbFLSegQe7WvOoOBF2WWMJ+LIN8DMJEfjMlRtJtoUnviOM9uC9qBMr8YwuOQ3zHyw0gi83IqM3+Et6PA97zO4mFxWwFnhfK0wDCyhW67Y9Lw+LPyDkved0+DE13FALhXgscnNKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717581179; c=relaxed/simple; bh=jnPNWF3YKGeMoyAAOvnWraIw8XgcXsBn2MIusN1qEFM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=nP0Qb2TtKRVbWyoaLl5dSyxe738LW6gDQyghGrBjnwP3FTXOHMetHyxa+dux+qy0VZTXQdQbr+ngGsogiv5HZeg5x9ayJ68eTh5YuTPOOoFyMosQKFd+CHrEyptFyooLHi/w+eQZe/hI9LzBRqhJB+qwtNuAJjDRREmOpaOKae0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=wCABgHQV; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4559qRcc088771; Wed, 5 Jun 2024 04:52:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717581147; bh=Lu9R3HFjqY+joNvpPu5u8Mxhs9oQxQ+UkNosv0uJ7MQ=; h=From:To:CC:Subject:Date; b=wCABgHQVPsy3QQ29+qc+Y1qhzRIREdqRaH4ZfUOSzn+UdOIZ1XvFHU3p7FUn3mkr9 VS+suMSB4w5mwDJwX5C0RC2MytpZLHLaW8v+wcSXH7ZNvs7XYK9LR0UfE1CihDfV6H qcO5lxRVZ0mbEWFf5P4zaNSb9bdb+nfQdTgC2i/A= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4559qRfU017863 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 5 Jun 2024 04:52:27 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 5 Jun 2024 04:52:27 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE102.ent.ti.com (10.64.6.23) 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; Wed, 5 Jun 2024 04:52:26 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4559qQAg046363; Wed, 5 Jun 2024 04:52:26 -0500 Received: from localhost (danish-tpc.dhcp.ti.com [10.24.69.25]) by fllv0122.itg.ti.com (8.14.7/8.14.7) with ESMTP id 4559qPmu012064; Wed, 5 Jun 2024 04:52:26 -0500 From: MD Danish Anwar To: Dan Carpenter , Jan Kiszka , Diogo Ivo , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" CC: , , , , Vignesh Raghavendra , Roger Quadros , MD Danish Anwar , Wojciech Drewek Subject: [PATCH net-next v3] net: ti: icssg-prueth: Add multicast filtering support Date: Wed, 5 Jun 2024 15:22:23 +0530 Message-ID: <20240605095223.2556963-1-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Add multicast filtering support for ICSSG Driver. Multicast addresses will be updated by __dev_mc_sync() API. icssg_prueth_add_macst () and icssg_prueth_del_mcast() will be sync and unsync APIs for the driver respectively. To add a mac_address for a port, driver needs to call icssg_fdb_add_del() and pass the mac_address and BIT(port_id) to the API. The ICSSG firmware will then configure the rules and allow filtering. If a mac_address is added to port0 and the same mac_address needs to be added for port1, driver needs to pass BIT(port0) | BIT(port1) to the icssg_fdb_add_del() API. If driver just pass BIT(port1) then the entry for port0 will be overwritten / lost. This is a design constraint on the firmware side. To overcome this in the driver, to add any mac_address for let's say portX driver first checks if the same mac_address is already added for any other port. If yes driver calls icssg_fdb_add_del() with BIT(portX) | BIT(other_existing_port). If not, driver calls icssg_fdb_add_del() with BIT(portX). The same thing is applicable for deleting mac_addresses as well. This logic is in icssg_prueth_add_mcast / icssg_prueth_del_mcast APIs. Signed-off-by: MD Danish Anwar --- Cc: Wojciech Drewek v2 -> v3: *) Using __dev_mc_sync() instead of __hw_addr_sync_dev(). *) Stopped keeping local copy of multicast list as pointed out by Wojciech Drewek v1 -> v2: *) Rebased on latest net-next/main. NOTE: This series can be applied cleanly on the tip of net-next/main. This series doesn't depend on any other ICSSG driver related series that is floating around in netdev. v1 https://lore.kernel.org/all/20240516091752.2969092-1-danishanwar@ti.com/ v2 https://lore.kernel.org/all/20240604114402.1835973-1-danishanwar@ti.com/ drivers/net/ethernet/ti/icssg/icssg_prueth.c | 38 +++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 6e65aa0977d4..e13835100754 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -439,6 +439,37 @@ const struct icss_iep_clockops prueth_iep_clockops = { .perout_enable = prueth_perout_enable, }; +static int icssg_prueth_add_mcast(struct net_device *ndev, const u8 *addr) +{ + struct prueth_emac *emac = netdev_priv(ndev); + int port_mask = BIT(emac->port_id); + + port_mask |= icssg_fdb_lookup(emac, addr, 0); + icssg_fdb_add_del(emac, addr, 0, port_mask, true); + icssg_vtbl_modify(emac, 0, port_mask, port_mask, true); + + return 0; +} + +static int icssg_prueth_del_mcast(struct net_device *ndev, const u8 *addr) +{ + struct prueth_emac *emac = netdev_priv(ndev); + int port_mask = BIT(emac->port_id); + int other_port_mask; + + other_port_mask = port_mask ^ icssg_fdb_lookup(emac, addr, 0); + + icssg_fdb_add_del(emac, addr, 0, port_mask, false); + icssg_vtbl_modify(emac, 0, port_mask, port_mask, false); + + if (other_port_mask) { + icssg_fdb_add_del(emac, addr, 0, other_port_mask, true); + icssg_vtbl_modify(emac, 0, other_port_mask, other_port_mask, true); + } + + return 0; +} + /** * emac_ndo_open - EMAC device open * @ndev: network adapter device @@ -599,6 +630,8 @@ static int emac_ndo_stop(struct net_device *ndev) icssg_class_disable(prueth->miig_rt, prueth_emac_slice(emac)); + __dev_mc_unsync(ndev, icssg_prueth_del_mcast); + atomic_set(&emac->tdown_cnt, emac->tx_ch_num); /* ensure new tdown_cnt value is visible */ smp_mb__after_atomic(); @@ -675,10 +708,7 @@ static void emac_ndo_set_rx_mode_work(struct work_struct *work) return; } - if (!netdev_mc_empty(ndev)) { - emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); - return; - } + __dev_mc_sync(ndev, icssg_prueth_add_mcast, icssg_prueth_del_mcast); } /** base-commit: fd70f0443e24c3888bf4b7f198df6d705c9b8ab2 -- 2.34.1