From patchwork Tue May 28 11:37:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13676513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D64B4C25B78 for ; Tue, 28 May 2024 11:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=qenK3Ckilb+1gKvuZPcQV+79lbzJ5Cx/VjHEOY6JR98=; b=JodR+lcW3s3dHl YVGXuX5A9JAuLt8xcLixwGSEe3O7/gRgWJDxy781OdsAdooN3ANvYdAh5IE8U7HRyrOqZVXWBEtAP F3DzMzDVshzCm9/0Df4MBRcEU8WHGgW4874CJTqB12lA2tWZL0fA6dksiIlX+8efdhJVkqLjgDmDz R3C1u+VJkjVzZKSAYddSyKubp86/IyxzOj68gWKd+2fjLxp87bm9pDIB3cCdrrmzwGnsRx0NUAw63 AX68rcJQ97SLUJwQrVkCrv/y64f3ze0bYEnpIyoRLjxv/saVlvw2hc1qKvNOKCgVOd0TCuXWSGt4W BrxsAIp6iFgw7QGUlYUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBv9O-00000000OFf-0xcY; Tue, 28 May 2024 11:37:54 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBv9K-00000000OEO-1A7H for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2024 11:37:51 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44SBbcBn029369; Tue, 28 May 2024 06:37:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1716896258; bh=PlMtN9GGldukZUavhgPKY/mk0lJcI85tsEjsfxAERq8=; h=From:To:CC:Subject:Date; b=u+x0QwApDHsMHZy7SScnRt4M4WtaOSPczTbTGe5HCuxdGTHgLV50jdZ013oTDE5GU N2JdR/GleUmOTWs7t6unJHlV9bKSlDdkoMyAAiieBdvgOJ6nfqmPQCUmzlXjzNCRFN I+iycxSWBytdbZnHZrJfuwODuhI71Pvnh3zSVR8o= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44SBbcqL055021 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 28 May 2024 06:37:38 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) 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; Tue, 28 May 2024 06:37:37 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE102.ent.ti.com (157.170.170.32) 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; Tue, 28 May 2024 06:37:37 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44SBbbsA083802; Tue, 28 May 2024 06:37:37 -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 44SBbaC7007889; Tue, 28 May 2024 06:37:37 -0500 From: MD Danish Anwar To: Dan Carpenter , Jan Kiszka , Simon Horman , Andrew Lunn , Vladimir Oltean , Wolfram Sang , Niklas Schnelle , Arnd Bergmann , Diogo Ivo , Roger Quadros , MD Danish Anwar , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" CC: , , , , Vignesh Raghavendra Subject: [PATCH net-next v6 0/3] Introduce switch mode support for ICSSG driver Date: Tue, 28 May 2024 17:07:31 +0530 Message-ID: <20240528113734.379422-1-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_043750_427578_E73E9829 X-CRM114-Status: GOOD ( 20.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series adds support for switch-mode for ICSSG driver. This series also introduces helper APIs to configure firmware maintained FDB (Forwarding Database) and VLAN tables. These APIs are later used by ICSSG driver in switch mode. Now the driver will boot by default in dual EMAC mode. When first ICSSG interface is added to bridge driver will still be in EMAC mode. As soon as second ICSSG interface is added to same bridge, switch-mode will be enabled and switch firmwares will be loaded to PRU cores. The driver will remain in dual EMAC mode if ICSSG interfaces are added to two different bridges or if two different interfaces (One ICSSG, one other) is added to the same bridge. We'll only enable is_switch_mode flag when two ICSSG interfaces are added to same bridge. We start in dual MAC mode. Let's say lan0 and lan1 are ICSSG interfaces ip link add name br0 type bridge ip link set lan0 master br0 At this point, we get a CHANGEUPPER event. Only one port is a member of the bridge, so we will still be in dual MAC mode. ip link set lan1 master br0 We get a second CHANGEUPPER event, the second interface lan1 is also ICSSG interface so we will set the is_switch_mode flag and when interfaces are brought up again, ICSSG switch firmwares will be loaded to PRU Cores. There are some other cases to consider as well. ip link add name br0 type bridge ip link add name br1 type bridge ip link set lan0 master br0 ip link set ppp0 master br0 Here we are adding lan0 (ICSSG) and ppp0 (non ICSSG) to same bridge, as they both are not ICSSG, we will still be running in dual EMAC mode. ip link set lan1 master br1 ip link set vpn0 master br1 Here we are adding lan1 (ICSSG) and vpn0 (non ICSSG) to same bridge, as they both are not ICSSG, we will still be running in dual EMAC mode. This is v6 of the series. Changes from v5 to v6: *) Removed __packed from structures in icssg_config.h file. *) Added RB tags of Andrew Lunn to patch 2/3 and patch 3/3 of this series. Changes from v4 to v5: *) Rebased on 6.10-rc1. *) Dropped the RFC tag. Changes from v3 to v4: *) Added RFC tag as net-next is closed now. *) Modified the driver to remove the need of bringing interfaces up / down for enabling / disabling switch mode. Now switch mode can be enabled without bringig interfaces up / down as requested by Andrew Lunn *) Modified commit message of patch 3/3. Changes from v2 to v3: *) Dropped RFC tag. *) Used ether_addr_copy() instead of manually copying mac address using for loop in patch 1/3 as suggested by Andrew Lunn *) Added helper API icssg_fdb_setup() in patch 1/3 to reduce code duplication as suggested by Andrew Lunn *) In prueth_switchdev_stp_state_set() removed BR_STATE_LEARNING as learning without forwarding is not supported by ICSSG firmware. *) Used ether_addr_equal() wherever possible in patch 2/3 as suggested by Andrew Lunn *) Fixed typo "nit: s/prueth_switchdevice_nb/prueth_switchdev_nb/" in patch 2/3 as suggested by Simon Horman *) Squashed "#include "icssg_mii_rt.h" to patch 2/3 from patch 3/3 as suggested by Simon Horman *) Rebased on latest net-next/main. Changes from v1 to v2: *) Removed TAPRIO support patch from this series. *) Stopped using devlink for enabling switch-mode as suggested by Andrew L *) Added read_poll_timeout() in patch 1 / 3 as suggested by Andrew L. v1 https://lore.kernel.org/all/20230830110847.1219515-4-danishanwar@ti.com/ v2 https://lore.kernel.org/all/20240118071005.1514498-1-danishanwar@ti.com/ v3 https://lore.kernel.org/all/20240327114054.1907278-1-danishanwar@ti.com/ v4 https://lore.kernel.org/all/20240515060320.2783244-1-danishanwar@ti.com/ v5 https://lore.kernel.org/all/20240527052738.152821-1-danishanwar@ti.com/ Thanks and Regards, Md Danish Anwar MD Danish Anwar (3): net: ti: icssg-prueth: Add helper functions to configure FDB net: ti: icssg-switch: Add switchdev based driver for ethernet switch support net: ti: icssg-prueth: Add support for ICSSG switch firmware drivers/net/ethernet/ti/Kconfig | 1 + drivers/net/ethernet/ti/Makefile | 3 +- .../net/ethernet/ti/icssg/icssg_classifier.c | 2 +- drivers/net/ethernet/ti/icssg/icssg_common.c | 2 + drivers/net/ethernet/ti/icssg/icssg_config.c | 322 +++++++++++- drivers/net/ethernet/ti/icssg/icssg_config.h | 26 + drivers/net/ethernet/ti/icssg/icssg_prueth.c | 250 ++++++++- drivers/net/ethernet/ti/icssg/icssg_prueth.h | 36 ++ .../net/ethernet/ti/icssg/icssg_switchdev.c | 477 ++++++++++++++++++ .../net/ethernet/ti/icssg/icssg_switchdev.h | 13 + 10 files changed, 1113 insertions(+), 19 deletions(-) create mode 100644 drivers/net/ethernet/ti/icssg/icssg_switchdev.c create mode 100644 drivers/net/ethernet/ti/icssg/icssg_switchdev.h base-commit: 5233a55a5254ea38dcdd8d836a0f9ee886c3df51