From patchwork Tue Feb 27 08:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Vadapalli X-Patchwork-Id: 13573347 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 73B3DC54798 for ; Tue, 27 Feb 2024 08:28:56 +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=ARELomv6Ty+XN8rSs//IDdVxZ2MjtnTpTJlH6FT/U/w=; b=hAXPo7mrkEtigP VLL7Da6+HDQmsW+9r36Moxnvnee9Kqx/NG6+E/XNrkxcQqnJKIWfao3JIVUuB7FBcn04MdJfUSb8t wI8jd04lSVE1ivISBVil6K+AjIwlBaQFN9FPxzW4/6PLa1wlwQD9573j1z1ZMUgCD1GuYJEWpcDPz wZT3SdWxP+HXWRPi7lbub7QxB9PYH8S+Sxr3Vpncs8jFgGzTk2N03wHn/3gzWm+TjGXt+DGi9EcKT RReBG6bmTFhZ34BqFxFDpXDbZfUzQpgy9r8Mlht2JAVcRInYoSsVz3AXeqg6FQ9kQhNzlCS9PkQ4j 6L0vrdDZbViI+LjHGu7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1respP-00000004JED-2HSV; Tue, 27 Feb 2024 08:28:43 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1respM-00000004JDG-0zF6 for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2024 08:28:42 +0000 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41R8SL4m016693; Tue, 27 Feb 2024 02:28:21 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1709022501; bh=UvEz58JiJybT1iV4zwOdxj9BOekP3Yr+3ULHGrmn0T8=; h=From:To:CC:Subject:Date; b=VfQGuUZ8330zfn5j095nj7dWo8JP9A6KNzPc4HMsaSZEhlA8J0j7Kq+sjKiQZGNFV FIXS31eTrUvgIKRCraes1LDzLoXUkHFlbuemf77eyEotZh7tsgOKvOQCvgyL5Hi0Nh 7k2YaZnUiIxuZGMvaN3P0HTfaVReW4J7Xdqbs7hc= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41R8SLVL021600 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 27 Feb 2024 02:28:21 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 27 Feb 2024 02:28:21 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE105.ent.ti.com (10.64.6.26) 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, 27 Feb 2024 02:28:21 -0600 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41R8SGWT053517; Tue, 27 Feb 2024 02:28:17 -0600 From: Siddharth Vadapalli To: , , , , , , , , , , CC: , , , , Subject: [PATCH net-next] net: ethernet: ti: am65-cpsw: Add priv-flag for Switch VLAN Aware mode Date: Tue, 27 Feb 2024 13:58:15 +0530 Message-ID: <20240227082815.2073826-1-s-vadapalli@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-20240227_002840_479277_7EF99CD7 X-CRM114-Status: GOOD ( 17.80 ) 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 The CPSW Ethernet Switch on TI's K3 SoCs can be configured to operate in VLAN Aware or VLAN Unaware modes of operation. This is different from the ALE being VLAN Aware and Unaware. The Ethernet Switch being VLAN Aware results in the addition/removal/replacement of VLAN tag of packets during egress as described in section "12.2.1.4.6.4.1 Transmit VLAN Processing" of the AM65x Technical Reference Manual available at: https://www.ti.com/lit/ug/spruid7e/spruid7e.pdf In VLAN Unaware mode, packets remain unmodified on egress. The driver currently configures the Ethernet Switch in VLAN Aware mode by default and there is no support to toggle this capability of the Ethernet Switch at runtime. Thus, add support to toggle the capability by exporting it via the ethtool "priv-flags" interface. Signed-off-by: Siddharth Vadapalli --- Hello, This patch is based on net-next main branch's commit: 55a7246025cd Merge branch 'mptcp-various-small-improvements' Regards, Siddharth. drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 9 ++++++++- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 12 +++++++++--- drivers/net/ethernet/ti/am65-cpsw-nuss.h | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c index d6ce2c9f0a8d..42c317874b75 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c +++ b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c @@ -374,6 +374,8 @@ static const struct am65_cpsw_ethtool_stat am65_slave_stats[] = { static const char am65_cpsw_ethtool_priv_flags[][ETH_GSTRING_LEN] = { #define AM65_CPSW_PRIV_P0_RX_PTYPE_RROBIN BIT(0) "p0-rx-ptype-rrobin", +#define AM65_CPSW_PRIV_VLAN_AWARE BIT(1) + "cpsw-vlan-aware", }; static int am65_cpsw_ethtool_op_begin(struct net_device *ndev) @@ -720,15 +722,19 @@ static u32 am65_cpsw_get_ethtool_priv_flags(struct net_device *ndev) if (common->pf_p0_rx_ptype_rrobin) priv_flags |= AM65_CPSW_PRIV_P0_RX_PTYPE_RROBIN; + if (common->cpsw_vlan_aware) + priv_flags |= AM65_CPSW_PRIV_VLAN_AWARE; + return priv_flags; } static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags) { struct am65_cpsw_common *common = am65_ndev_to_common(ndev); - int rrobin; + int rrobin, cpsw_vlan_aware; rrobin = !!(flags & AM65_CPSW_PRIV_P0_RX_PTYPE_RROBIN); + cpsw_vlan_aware = !!(flags & AM65_CPSW_PRIV_VLAN_AWARE); if (common->usage_count) return -EBUSY; @@ -740,6 +746,7 @@ static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags) } common->pf_p0_rx_ptype_rrobin = rrobin; + common->cpsw_vlan_aware = cpsw_vlan_aware; return 0; } diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 9d2f4ac783e4..fec2a5968a12 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -451,9 +451,14 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) return 0; /* Control register */ - writel(AM65_CPSW_CTL_P0_ENABLE | AM65_CPSW_CTL_P0_TX_CRC_REMOVE | - AM65_CPSW_CTL_VLAN_AWARE | AM65_CPSW_CTL_P0_RX_PAD, - common->cpsw_base + AM65_CPSW_REG_CTL); + val = AM65_CPSW_CTL_P0_ENABLE | AM65_CPSW_CTL_P0_TX_CRC_REMOVE | + AM65_CPSW_CTL_P0_RX_PAD; + + if (common->cpsw_vlan_aware) + val |= AM65_CPSW_CTL_VLAN_AWARE; + + writel(val, common->cpsw_base + AM65_CPSW_REG_CTL); + /* Max length register */ writel(AM65_CPSW_MAX_PACKET_SIZE, host_p->port_base + AM65_CPSW_PORT_REG_RX_MAXLEN); @@ -2977,6 +2982,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) init_completion(&common->tdown_complete); common->tx_ch_num = AM65_CPSW_DEFAULT_TX_CHNS; common->pf_p0_rx_ptype_rrobin = false; + common->cpsw_vlan_aware = true; common->default_vlan = 1; common->ports = devm_kcalloc(dev, common->port_num, diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index 7da0492dc091..91f625ea3859 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -147,6 +147,7 @@ struct am65_cpsw_common { u32 cpsw_ver; unsigned long bus_freq; bool pf_p0_rx_ptype_rrobin; + bool cpsw_vlan_aware; struct am65_cpts *cpts; int est_enabled; bool iet_enabled;