From patchwork Wed Jan 17 16:14:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522003 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 D43E7C47DA9 for ; Wed, 17 Jan 2024 16:16:57 +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:References:In-Reply-To: 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: List-Owner; bh=CtaIphNUvNRq5MZf6RtxcdNcESaxsdGcendoXG9lPQA=; b=ozYE84nSi7EWCB bxwp47YWFEsG+SPUevxccjxkynn0U+DpSoosu58pYS6EcgiXjfhSrQaVOuFXE+q4cztlD/0Xh4RGl AvJWj35h4pY21jFbiA25pTk9jAFfMIx8Snq2KZHCJWJG06FS5+Yasqxu1IlnXLpKNWiJLqZgfRPEA r3RF0eADHKbwPdsEmX3NIXZMRlzN0Fkf+6zVLVbwWwlz0GUSwNttmc9RczjEREoJmbL9Gsn77lDFR /B4MkYZW6eF1haPPnrsBmjBwlhrvSUpXMqwi5xu1coQ60hCKkSW0hEVlB2u4IgKjoFuApKNHlusXE 0Ih8CDnoAA3gvK4UU/+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aX-0001ca-1t; Wed, 17 Jan 2024 16:16:26 +0000 Received: from mta-64-227.siemens.flowmailer.net ([185.136.64.227]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aS-0001Yn-2d for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:23 +0000 Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 20240117161614e34ceea4fc280bab09 for ; Wed, 17 Jan 2024 17:16:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=V3s9GK0OAb3raYOYAIncj1wCgS57eQxkjBGUikPp6W0=; b=RB4sQcLSvKLe8EBRQL3S8i2ZZjm5pTE+r05xsWSijLbO0i4/k8v+bl4TkMe6T67cBAkQ12 u9f9/jTJdrW5nPd0YwJ7LTl1U04OYJ0JlUa6mOkNaUgDgPFoNN1diKnupv9HOWtu0Tji3yTl ONJfs9/tv/BSNEqbFbXMU+/BCgzwI=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 1/8] dt-bindings: net: Add support for AM65x SR1.0 in ICSSG Date: Wed, 17 Jan 2024 16:14:55 +0000 Message-ID: <20240117161602.153233-2-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081621_629488_5A2CD056 X-CRM114-Status: UNSURE ( 9.16 ) X-CRM114-Notice: Please train this message. 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 Silicon Revision 1.0 of the AM65x came with a slightly different ICSSG support: Only 2 PRUs per slice are available and instead 2 additional DMA channels are used for management purposes. We have no restrictions on specified PRUs, but the DMA channels need to be adjusted. Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- Changes in v2: - Removed explicit reference to SR2.0 - Moved sr1 to the SoC name - Expand dma-names list and adjust min/maxItems depending on SR1.0/2.0 .../bindings/net/ti,icssg-prueth.yaml | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml b/Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml index 229c8f32019f..59a3292191d9 100644 --- a/Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml +++ b/Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml @@ -19,8 +19,9 @@ allOf: properties: compatible: enum: - - ti,am642-icssg-prueth # for AM64x SoC family - - ti,am654-icssg-prueth # for AM65x SoC family + - ti,am642-icssg-prueth # for AM64x SoC family + - ti,am654-icssg-prueth # for AM65x SoC family + - ti,am654-sr1-icssg-prueth # for AM65x SoC family, SR1.0 sram: $ref: /schemas/types.yaml#/definitions/phandle @@ -28,8 +29,7 @@ properties: phandle to MSMC SRAM node dmas: - maxItems: 10 - + minItems: 10 dma-names: items: - const: tx0-0 @@ -42,6 +42,8 @@ properties: - const: tx1-3 - const: rx0 - const: rx1 + - const: rxmgm0 + - const: rxmgm1 ti,mii-g-rt: $ref: /schemas/types.yaml#/definitions/phandle @@ -132,6 +134,25 @@ required: - interrupts - interrupt-names +allOf: + - if: + properties: + compatible: + contains: + const: ti,am654-sr1-icssg-prueth + then: + properties: + dmas: + minItems: 12 + dma-names: + minItems: 12 + else: + properties: + dmas: + maxItems: 10 + dma-names: + maxItems: 10 + unevaluatedProperties: false examples: From patchwork Wed Jan 17 16:14:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522006 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 CD6D5C47DA9 for ; Wed, 17 Jan 2024 16:17:02 +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:References:In-Reply-To: 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: List-Owner; bh=KCR+NQIaZ8Y+l/n7W2Y1c/b6F4txu+rJM4qOUwzz/3E=; b=td/51JGOYn0nhv F/WByLDW9tWBGyRsYoJeHhTi4lNLjsKa+gKa6M7jBW/8sb7AqBn/FCiMQMhVm863c3EY+KxgZsVq0 ma9K3lr67r4jKeG6SFyYeqRgTdH5LdwYKrrQJ6jWo8NGatRMIZDArvKHl9pQ1K61ZqqBaZrvyb2vE GNlFcqvx/Ply46pLn42szJEvcvckJNUgtaXBDKNucVD9CLEosmM0SqPJY8filDEgzi8VqrFlm7U5q Y0ccwzt07t5DYEQugk863szF54g17LR3e4FOPJuq8L9ZRf/3hhdzcSaZhHdJ5JBq2wLPH8CCsr0Op fS7Mef9Dmg7vU9PYoVyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8ab-0001f6-2T; Wed, 17 Jan 2024 16:16:30 +0000 Received: from mta-64-228.siemens.flowmailer.net ([185.136.64.228]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aV-0001Zf-12 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:25 +0000 Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 2024011716161810772221f69dec050c for ; Wed, 17 Jan 2024 17:16:18 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=8sQbeCmWiLFomVY+kxivPzriHLrsmhcfUL/M14qU9XY=; b=D+xPTTq+kJgdiDaBd/RCyNFUCHCybBewfRG1z/fBApLFIhTmLhoXZm4c3v5Mzle0BA0VW5 hNRQ2J8IRR/MmLAtI5Ud/WdRBb6cTB70Tjs/VS8meckoXIHRwzv+/8C25oVE+obsBz1gpRfP 8b69oi04Ot4vHol2GolTqyP4tU9eM=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, grygorii.strashko@ti.com, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 3/8] net: ti: icssg-prueth: add SR1.0-specific configuration bits Date: Wed, 17 Jan 2024 16:14:57 +0000 Message-ID: <20240117161602.153233-4-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081623_509784_73B1B8C9 X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. 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 Add fields to differentiate between SR1.0 and SR2.0 in the driver as well as the structures necessary to program SR1.0. Based on the work of Roger Quadros in TI's 5.10 SDK [1]. [1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- drivers/net/ethernet/ti/icssg/icssg_prueth.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h index 8b6d6b497010..1bdd3d301fde 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -127,6 +127,7 @@ struct prueth_rx_chn { /* data for each emac port */ struct prueth_emac { + bool is_sr1; bool fw_running; struct prueth *prueth; struct net_device *ndev; @@ -155,6 +156,10 @@ struct prueth_emac { int rx_flow_id_base; int tx_ch_num; + /* SR1.0 Management channel */ + struct prueth_rx_chn rx_mgm_chn; + int rx_mgm_flow_id_base; + spinlock_t lock; /* serialize access */ /* TX HW Timestamping */ @@ -182,10 +187,12 @@ struct prueth_emac { * struct prueth_pdata - PRUeth platform data * @fdqring_mode: Free desc queue mode * @quirk_10m_link_issue: 10M link detect errata + * @is_sr1: device is SR1.0 */ struct prueth_pdata { enum k3_ring_mode fdqring_mode; u32 quirk_10m_link_issue:1; + u32 is_sr1:1; }; /** @@ -224,6 +231,7 @@ struct prueth { struct device_node *eth_node[PRUETH_NUM_MACS]; struct prueth_emac *emac[PRUETH_NUM_MACS]; struct net_device *registered_netdevs[PRUETH_NUM_MACS]; + struct icssg_config_sr1 config[PRUSS_NUM_PRUS]; struct regmap *miig_rt; struct regmap *mii_rt; @@ -236,6 +244,13 @@ struct prueth { struct icss_iep *iep1; }; +struct emac_tx_ts_response_sr1 { + u32 lo_ts; + u32 hi_ts; + u32 reserved; + u32 cookie; +}; + struct emac_tx_ts_response { u32 reserved[2]; u32 cookie; From patchwork Wed Jan 17 16:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522007 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 62F9EC47DA2 for ; Wed, 17 Jan 2024 16:17: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:References:In-Reply-To: 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: List-Owner; bh=vNQzAoOKn99LVfgBNtDDHX4gdBNYm/banTMOdiyuda8=; b=t/8WkIFhOOWAQy LT150I1MZfJi9M+DOD/WZ4trfiTfrABG3N+FSMQz70cQrqyVG2feLCKt11C1bs4xSbKTtAG4qfkQ3 gBTMcDZxnU4Amb5zopcJNn0USCEBE7gEgqGmNMZBVXCRFfKFr3LGTJtTQYeeXrpC1fq1y2R1sBnYn RRTxGeUanOtx6tHXdfEOaJ7WkKc+KHSTtMGLsYzubGxlNKHUQ8AmRbtPFE/PrhEXrVnXW66lpxq0O t2iIRLJT9VtAcU7R3sLn6+Xz0Hex/8kMNZmfXEhDf83DCmUkyzK9qUEoMYIG6zgX1+ukjh5rlugfw oKpPiRTgs+Xu5hYYPfXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8ar-0001oX-1D; Wed, 17 Jan 2024 16:16:45 +0000 Received: from mta-64-225.siemens.flowmailer.net ([185.136.64.225]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aY-0001aI-23 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:28 +0000 Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 202401171616191969275e712eb62c84 for ; Wed, 17 Jan 2024 17:16:20 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=FfaY2isOcT5G3JXOnrGsX+gaw/DEMT/l1TS+2QrUgVE=; b=mNgbX6YuN2+q7lWAmrfE3Jn5yBnGTzwGWnoFrLrHEBO76y0W/5MxuXkPBh8FgPu3oCRRf7 8+Wpm8E0BqvbaaA1+HoySx6WkRaBwM/C5PDoeOaXsjhtzhiA6B5HYEHeLIttASaSVI6wXOlu vt2//7sWeOqMur6U1MW789wmwMQE8=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, dan.carpenter@linaro.org, robh@kernel.org, grygorii.strashko@ti.com, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 4/8] net: ti: icssg-classifier: Add support for SR1.0 Date: Wed, 17 Jan 2024 16:14:58 +0000 Message-ID: <20240117161602.153233-5-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081626_838242_F1CD209A X-CRM114-Status: GOOD ( 18.30 ) 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 Add the functions to program the SR1.0 packet classifier. Based on the work of Roger Quadros in TI's 5.10 SDK [1]. [1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- .../net/ethernet/ti/icssg/icssg_classifier.c | 113 ++++++++++++++++-- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 2 +- drivers/net/ethernet/ti/icssg/icssg_prueth.h | 6 +- 3 files changed, 110 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_classifier.c b/drivers/net/ethernet/ti/icssg/icssg_classifier.c index 6df53ab17fbc..d7288eb6c0fd 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_classifier.c +++ b/drivers/net/ethernet/ti/icssg/icssg_classifier.c @@ -274,6 +274,16 @@ static void rx_class_set_or(struct regmap *miig_rt, int slice, int n, regmap_write(miig_rt, offset, data); } +static u32 rx_class_get_or(struct regmap *miig_rt, int slice, int n) +{ + u32 offset, val; + + offset = RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN); + regmap_read(miig_rt, offset, &val); + + return val; +} + void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac) { regmap_write(miig_rt, MAC_INTERFACE_0, (u32)(mac[0] | mac[1] << 8 | @@ -288,6 +298,26 @@ void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac) regmap_write(miig_rt, offs[slice].mac1, (u32)(mac[4] | mac[5] << 8)); } +static void icssg_class_ft1_add_mcast(struct regmap *miig_rt, int slice, + int slot, const u8 *addr, const u8 *mask) +{ + int i; + u32 val; + + WARN(slot >= FT1_NUM_SLOTS, "invalid slot: %d\n", slot); + + rx_class_ft1_set_da(miig_rt, slice, slot, addr); + rx_class_ft1_set_da_mask(miig_rt, slice, slot, mask); + rx_class_ft1_cfg_set_type(miig_rt, slice, slot, FT1_CFG_TYPE_EQ); + + /* Enable the FT1 slot in OR enable for all classifiers */ + for (i = 0; i < ICSSG_NUM_CLASSIFIERS_IN_USE; i++) { + val = rx_class_get_or(miig_rt, slice, i); + val |= RX_CLASS_FT_FT1_MATCH(slot); + rx_class_set_or(miig_rt, slice, i, val); + } +} + /* disable all RX traffic */ void icssg_class_disable(struct regmap *miig_rt, int slice) { @@ -331,30 +361,95 @@ void icssg_class_disable(struct regmap *miig_rt, int slice) regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0); } -void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti) +void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti, + bool is_sr1) { + int classifiers_in_use = is_sr1 ? ICSSG_NUM_CLASSIFIERS_IN_USE : 1; u32 data; + int n; /* defaults */ icssg_class_disable(miig_rt, slice); /* Setup Classifier */ - /* match on Broadcast or MAC_PRU address */ - data = RX_CLASS_FT_BC | RX_CLASS_FT_DA_P; + for (n = 0; n < classifiers_in_use; n++) { + /* match on Broadcast or MAC_PRU address */ + data = RX_CLASS_FT_BC | RX_CLASS_FT_DA_P; - /* multicast */ - if (allmulti) - data |= RX_CLASS_FT_MC; + /* multicast */ + if (allmulti) + data |= RX_CLASS_FT_MC; - rx_class_set_or(miig_rt, slice, 0, data); + rx_class_set_or(miig_rt, slice, n, data); - /* set CFG1 for OR_OR_AND for classifier */ - rx_class_sel_set_type(miig_rt, slice, 0, RX_CLASS_SEL_TYPE_OR_OR_AND); + /* set CFG1 for OR_OR_AND for classifier */ + rx_class_sel_set_type(miig_rt, slice, n, + RX_CLASS_SEL_TYPE_OR_OR_AND); + } /* clear CFG2 */ regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0); } +void icssg_class_promiscuous_sr1(struct regmap *miig_rt, int slice) +{ + u32 data, offset; + int n; + + /* defaults */ + icssg_class_disable(miig_rt, slice); + + /* Setup Classifier */ + for (n = 0; n < ICSSG_NUM_CLASSIFIERS_IN_USE; n++) { + /* set RAW_MASK to bypass filters */ + offset = RX_CLASS_GATES_N_REG(slice, n); + regmap_read(miig_rt, offset, &data); + data |= RX_CLASS_GATES_RAW_MASK; + regmap_write(miig_rt, offset, data); + } +} + +void icssg_class_add_mcast_sr1(struct regmap *miig_rt, int slice, + struct net_device *ndev) +{ + u8 sr_addr[6] = { 0x01, 0x80, 0xc2, 0, 0, 0 }; + u8 cb_addr[6] = { 0x01, 0x00, 0x5e, 0, 0, 0 }; + u8 mask_addr[6] = { 0, 0, 0, 0, 0, 0xff }; + struct netdev_hw_addr *ha; + int slot = 2; + + rx_class_ft1_set_start_len(miig_rt, slice, 0, 6); + /* reserve first 2 slots for + * 1) 01-80-C2-00-00-XX Known Service Ethernet Multicast addresses + * 2) 01-00-5e-00-00-XX Local Network Control Block + * (224.0.0.0 - 224.0.0.255 (224.0.0/24)) + */ + icssg_class_ft1_add_mcast(miig_rt, slice, 0, sr_addr, mask_addr); + icssg_class_ft1_add_mcast(miig_rt, slice, 1, cb_addr, mask_addr); + mask_addr[5] = 0; + netdev_for_each_mc_addr(ha, ndev) { + /* skip addresses matching reserved slots */ + if (!memcmp(sr_addr, ha->addr, 5) || + !memcmp(cb_addr, ha->addr, 5)) { + netdev_dbg(ndev, "mcast skip %pM\n", ha->addr); + continue; + } + + if (slot >= FT1_NUM_SLOTS) { + netdev_dbg(ndev, + "can't add more than %d MC addresses, enabling allmulti\n", + FT1_NUM_SLOTS); + icssg_class_default(miig_rt, slice, 1, true); + break; + } + + netdev_dbg(ndev, "mcast add %pM\n", ha->addr); + icssg_class_ft1_add_mcast(miig_rt, slice, slot, + ha->addr, mask_addr); + slot++; + } +} + /* required for SAV check */ void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr) { diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 411898a4f38c..5ec2cdc16c51 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1329,7 +1329,7 @@ static int emac_ndo_open(struct net_device *ndev) icssg_class_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); icssg_ft1_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); - icssg_class_default(prueth->miig_rt, slice, 0); + icssg_class_default(prueth->miig_rt, slice, 0, emac->is_sr1); /* Notify the stack of the actual queue counts. */ ret = netif_set_real_num_tx_queues(ndev, num_data_chn); diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h index 1bdd3d301fde..c2221db25950 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -277,7 +277,11 @@ extern const struct ethtool_ops icssg_ethtool_ops; void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac); void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac); void icssg_class_disable(struct regmap *miig_rt, int slice); -void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti); +void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti, + bool is_sr1); +void icssg_class_promiscuous_sr1(struct regmap *miig_rt, int slice); +void icssg_class_add_mcast_sr1(struct regmap *miig_rt, int slice, + struct net_device *ndev); void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr); /* config helpers */ From patchwork Wed Jan 17 16:14:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522010 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 76350C47258 for ; Wed, 17 Jan 2024 16:17:20 +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:References:In-Reply-To: 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: List-Owner; bh=8wedIYg2fINLWA9EnExt7+A8CWQr5ffvdc46O7BiWK0=; b=ikZTv2ziGzdfuc hmWVGrWignu+g2DyprOEGuuaIvoh3kIPuDvPE6jOAZlLTHaPaosaw52zRYRwVwz6WmwryUwzUapvm zj8Nw6dmZRwLrY2wL4cCOped+ked0zrFDbubEsST46HLF1wvb0CvGcwGr8r2hRZ+cP7BIduc1wH3T zuTmna2ngA4wse10CcEVaPoS46LanXBVc08Y+WWMERYQVJDmrvW2urQqcvWEfkwtNkWUt+BNH8X13 BnvJp35o3cpJEUeMRG4un+jDBxCjs9G9z2Q466pS29c3NPQjDJ5tm0g7l39X4z2ss6KNxsWYbOjF9 PrWXP6fF9xnpPZJqhh0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8as-0001p5-0I; Wed, 17 Jan 2024 16:16:46 +0000 Received: from mta-65-227.siemens.flowmailer.net ([185.136.65.227]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aZ-0001b6-2j for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:30 +0000 Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 20240117161621b1db1c6b4d713819f4 for ; Wed, 17 Jan 2024 17:16:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=oEAvIuPcXWGB92RZhAfW/QaF1dMHzyGJuC3Be3ErKg4=; b=dS/irmAUsACM9eSfTZ7GSgvsOqr9ZmhGQ1/JxmytNnvOyTAEI6WQ50LRVz9b4iWH76RstU cSPWgdAJBWx/fNjVVLvTcUKtWfSIGvKcZ9nQUkQK5WR+01Lr5HPr8HsPsux3pRZO53wXzfaC RJ4SWyCh5HioCEhKd/EbGIGw4kMYo=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, jacob.e.keller@intel.com, grygorii.strashko@ti.com, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 5/8] net: ti: icssg-config: Add SR1.0 configuration functions Date: Wed, 17 Jan 2024 16:14:59 +0000 Message-ID: <20240117161602.153233-6-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081628_039495_D67ABBC3 X-CRM114-Status: GOOD ( 18.23 ) 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 SR1.0 firmware needs to configured differently from the current SR2.0 firmware. Add the necessary functions. Based on the work of Roger Quadros, Vignesh Raghavendra and Grygorii Strashko in TI's 5.10 SDK [1]. [1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- Changes in v2: - Removed explicit references to SR2.0 - Added static keyword to icssg_config_sr1() drivers/net/ethernet/ti/icssg/icssg_config.c | 86 ++++++++++++++++++-- 1 file changed, 81 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_config.c b/drivers/net/ethernet/ti/icssg/icssg_config.c index 99de8a40ed60..34bc16599a2d 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_config.c +++ b/drivers/net/ethernet/ti/icssg/icssg_config.c @@ -18,6 +18,8 @@ */ /* IPG is in core_clk cycles */ +#define MII_RT_TX_IPG_100M_SR1 0x166 +#define MII_RT_TX_IPG_1G_SR1 0x1a #define MII_RT_TX_IPG_100M 0x17 #define MII_RT_TX_IPG_1G 0xb @@ -205,14 +207,20 @@ void icssg_config_ipg(struct prueth_emac *emac) switch (emac->speed) { case SPEED_1000: - icssg_mii_update_ipg(prueth->mii_rt, slice, MII_RT_TX_IPG_1G); + icssg_mii_update_ipg(prueth->mii_rt, slice, + prueth->pdata.is_sr1 ? + MII_RT_TX_IPG_1G_SR1 : MII_RT_TX_IPG_1G); break; case SPEED_100: - icssg_mii_update_ipg(prueth->mii_rt, slice, MII_RT_TX_IPG_100M); + icssg_mii_update_ipg(prueth->mii_rt, slice, + prueth->pdata.is_sr1 ? + MII_RT_TX_IPG_100M_SR1 : MII_RT_TX_IPG_100M); break; case SPEED_10: - /* IPG for 10M is same as 100M */ - icssg_mii_update_ipg(prueth->mii_rt, slice, MII_RT_TX_IPG_100M); + /* Firmware hardcodes IPG for SR1. SR2 same as 100M */ + if (!prueth->pdata.is_sr1) + icssg_mii_update_ipg(prueth->mii_rt, slice, + MII_RT_TX_IPG_100M); break; default: /* Other links speeds not supported */ @@ -221,6 +229,56 @@ void icssg_config_ipg(struct prueth_emac *emac) } } +/* SR1: Set buffer sizes for the pools. There are 8 internal queues + * implemented in firmware, but only 4 tx channels/threads in the Egress + * direction to firmware. Need a high priority queue for management + * messages since they shouldn't be blocked even during high traffic + * situation. So use Q0-Q2 as data queues and Q3 as management queue + * in the max case. However for ease of configuration, use the max + * data queue + 1 for management message if we are not using max + * case. + * + * Allocate 4 MTU buffers per data queue. Firmware requires + * pool sizes to be set for internal queues. Set the upper 5 queue + * pool size to min size of 128 bytes since there are only 3 tx + * data channels and management queue requires only minimum buffer. + * i.e lower queues are used by driver and highest priority queue + * from that is used for management message. + */ + +static int emac_egress_buf_pool_size[] = { + PRUETH_EMAC_BUF_POOL_SIZE_SR1, PRUETH_EMAC_BUF_POOL_SIZE_SR1, + PRUETH_EMAC_BUF_POOL_SIZE_SR1, PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1, + PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1, PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1, + PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1, PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1}; + +static void icssg_config_sr1(struct prueth *prueth, struct prueth_emac *emac, + int slice) +{ + struct icssg_config_sr1 *config; + void __iomem *va; + int i, index; + + va = prueth->shram.va + slice * ICSSG_CONFIG_OFFSET_SLICE1; + config = &prueth->config[slice]; + memset(config, 0, sizeof(*config)); + config->addr_lo = cpu_to_le32(lower_32_bits(prueth->msmcram.pa)); + config->addr_hi = cpu_to_le32(upper_32_bits(prueth->msmcram.pa)); + config->num_tx_threads = 0; + config->rx_flow_id = emac->rx_flow_id_base; /* flow id for host port */ + config->rx_mgr_flow_id = emac->rx_mgm_flow_id_base; /* for mgm ch */ + config->rand_seed = get_random_u32(); + + for (i = PRUETH_EMAC_BUF_POOL_START_SR1; i < PRUETH_NUM_BUF_POOLS_SR1; i++) { + index = i - PRUETH_EMAC_BUF_POOL_START_SR1; + config->tx_buf_sz[i] = cpu_to_le32(emac_egress_buf_pool_size[index]); + } + + memcpy_toio(va, &prueth->config[slice], sizeof(prueth->config[slice])); + + emac->speed = SPEED_1000; +} + static void emac_r30_cmd_init(struct prueth_emac *emac) { struct icssg_r30_cmd __iomem *p; @@ -331,6 +389,11 @@ int icssg_config(struct prueth *prueth, struct prueth_emac *emac, int slice) struct icssg_flow_cfg __iomem *flow_cfg; int ret; + if (prueth->pdata.is_sr1) { + icssg_config_sr1(prueth, emac, slice); + return 0; + } + icssg_init_emac_mode(prueth); memset_io(config, 0, TAS_GATE_MASK_LIST0); @@ -435,19 +498,32 @@ int emac_set_port_state(struct prueth_emac *emac, void icssg_config_half_duplex(struct prueth_emac *emac) { + struct icssg_config_sr1 *config; + void __iomem *va; + int slice; u32 val; if (!emac->half_duplex) return; val = get_random_u32(); - writel(val, emac->dram.va + HD_RAND_SEED_OFFSET); + if (emac->is_sr1) { + slice = prueth_emac_slice(emac); + va = emac->prueth->shram.va + slice * ICSSG_CONFIG_OFFSET_SLICE1; + config = (struct icssg_config_sr1 *)va; + writel(val, &config->rand_seed); + } else { + writel(val, emac->dram.va + HD_RAND_SEED_OFFSET); + } } void icssg_config_set_speed(struct prueth_emac *emac) { u8 fw_speed; + if (emac->is_sr1) + return; + switch (emac->speed) { case SPEED_1000: fw_speed = FW_LINK_SPEED_1G; From patchwork Wed Jan 17 16:15:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522008 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 250B9C47258 for ; Wed, 17 Jan 2024 16:17:14 +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:References:In-Reply-To: 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: List-Owner; bh=2BR81zXsLR5UvCTcXMXMcfxZvK0qjSjQU2wZOIuNl3U=; b=CZB0OuUUeOtlaC hpmgF0SOCB3Q7wX6fRQAzELARf/vfxguUvY26WhIfgCaWRLht9wGuaQZeFTdJpxEEKmGOnp02dPyJ c4Q85rIf8xlW5VyjAl8eJF9B6rb5TAR9BTfgUIyUOGsS9QFmZ6x5NhR6T03Yav3Zp2DLvQZeelvN9 WlxiulAOlI+MeySwyzNxPUK3GRe1oe5sEmd+Mvwp/NsVApZLzeqt7EEtwfe7IPDMz52x9xpFl+Fq1 s0zGIMRFrVF2tFhLfvzH7gK/uN6aRfX0yICpo8HIb9Vr1BjRW/86FogmPcnSxPsBcsq7my/EDKIX9 FvxddpA39GFeMT7GQDBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aq-0001oC-2P; Wed, 17 Jan 2024 16:16:44 +0000 Received: from mta-64-225.siemens.flowmailer.net ([185.136.64.225]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aY-0001bH-1y for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:28 +0000 Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 202401171616225cb723581c7a781cc8 for ; Wed, 17 Jan 2024 17:16:22 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=YA9kxXyTpKbUvAn5fk/7icCgdnpCMYJTim3PliscYAY=; b=SbZgm6XaDYngAg9dwufQISnkeojje0ki1FWT3za0KTqSUUw68s4j5eqlJw7gDXjhfAQpbj kLyM3Ym6857simGsmM5aRYrIVRXySxvpNVeknHl8A4GV4YaHrqqmlu1a3UackqDaThmBRvp/ BjY0hasNxsfkZjokV3McFCs8r4xD0=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, grygorii.strashko@ti.com, andrew@lunn.ch, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 6/8] net: ti: icssg-ethtool: Adjust channel count for SR1.0 Date: Wed, 17 Jan 2024 16:15:00 +0000 Message-ID: <20240117161602.153233-7-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081626_841686_C424374B X-CRM114-Status: GOOD ( 10.39 ) 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 SR1.0 uses the highest priority channel to transmit control messages to the firmware. Take this into account when computing channels. Based on the work of Roger Quadros in TI's 5.10 SDK [1]. [1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- drivers/net/ethernet/ti/icssg/icssg_ethtool.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c index a27ec1dcc8d5..29e67526fa22 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c +++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c @@ -141,6 +141,9 @@ static int emac_set_channels(struct net_device *ndev, return -EBUSY; emac->tx_ch_num = ch->tx_count; + /* highest channel number for management messaging on SR1 */ + if (emac->is_sr1) + emac->tx_ch_num++; return 0; } @@ -151,9 +154,12 @@ static void emac_get_channels(struct net_device *ndev, struct prueth_emac *emac = netdev_priv(ndev); ch->max_rx = 1; - ch->max_tx = PRUETH_MAX_TX_QUEUES; + /* SR1 use high priority channel for management messages */ + ch->max_tx = emac->is_sr1 ? PRUETH_MAX_TX_QUEUES - 1 : + PRUETH_MAX_TX_QUEUES; ch->rx_count = 1; - ch->tx_count = emac->tx_ch_num; + ch->tx_count = emac->is_sr1 ? emac->tx_ch_num - 1 : + emac->tx_ch_num; } static const struct ethtool_rmon_hist_range emac_rmon_ranges[] = { From patchwork Wed Jan 17 16:15:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522005 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 AF55EC47258 for ; Wed, 17 Jan 2024 16:17:01 +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:References:In-Reply-To: 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: List-Owner; bh=EDTyjUACpJjvzjhfWmoqNFFgCAZn/2v9MFegMEuc+yM=; b=pH5smtHqWVnIXZ +isKQhTKCsJaewR4jWysFevi+R6uzHMgSo/rgLVQV+fE0lkTPxymgs5lOuJIwpv2elwhackUVJEVC Ye1g0Ox7O3KI5mJEQGDFmTg5GhnEOaaYUxO96JStRMpd55d5NburTnrvT8cXkCOESkxmCz3RhSOFQ z/GPKbgobRcGB28NZ5zUtZ18t27EBDdQB/EH5KO2gpkLqtgxugAmm0lqoXpCu47tTxLNfpvQRZU/0 AI0w5pUQQ08AXB/nLDsrgPxQpYHnthQEQncIHYSmSQ/5UT7H2AG4YC3vUocgr8UzrrXT+2fxUrB2T c2VkTE6SVN1LL7JqPBmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8ae-0001gN-1Z; Wed, 17 Jan 2024 16:16:32 +0000 Received: from mta-64-227.siemens.flowmailer.net ([185.136.64.227]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aW-0001Yn-2y for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:27 +0000 Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202401171616230f71876dfaef5bdf95 for ; Wed, 17 Jan 2024 17:16:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=EEwZrH5Feku4V3FDACLnjgOFKj5BNY9868YFvEGGx/w=; b=AV6fFSL1c3mAYsYNlZm1SHUJ0+VwViX0QiolCnjJoJlIM+561gmi1HLW3kWMjJcKzYgeRq w+b8Iy+p1t1WDJPZQc8pJS9EIJRIYTaWdbWm0pZibRD1WtLXo05diA3wMwVyA5pUMdyz5zrX cvhMec6rHZ/VlZydq4E4wslq8w7Ac=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, dan.carpenter@linaro.org, robh@kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 7/8] net: ti: iccsg-prueth: Add necessary functions for SR1.0 support Date: Wed, 17 Jan 2024 16:15:01 +0000 Message-ID: <20240117161602.153233-8-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081625_104787_E035411F X-CRM114-Status: GOOD ( 19.35 ) 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 Add functions required to correctly program the SR1.0 firmware for network operation. Based on the work of Roger Quadros, Vignesh Raghavendra and Grygorii Strashko in TI's 5.10 SDK [1]. [1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 255 +++++++++++++++++++ 1 file changed, 255 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 5ec2cdc16c51..db15c8680741 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -616,6 +616,101 @@ static int emac_get_tx_ts(struct prueth_emac *emac, return 0; } +static int emac_send_command_sr1(struct prueth_emac *emac, u32 cmd) +{ + dma_addr_t desc_dma, buf_dma; + struct prueth_tx_chn *tx_chn; + struct cppi5_host_desc_t *first_desc; + u32 *data = emac->cmd_data; + u32 pkt_len = sizeof(emac->cmd_data); + void **swdata; + int ret = 0; + u32 *epib; + + netdev_dbg(emac->ndev, "Sending cmd %x\n", cmd); + + /* only one command at a time allowed to firmware */ + mutex_lock(&emac->cmd_lock); + data[0] = cpu_to_le32(cmd); + + /* highest priority channel for management messages */ + tx_chn = &emac->tx_chns[emac->tx_ch_num - 1]; + + /* Map the linear buffer */ + buf_dma = dma_map_single(tx_chn->dma_dev, data, pkt_len, DMA_TO_DEVICE); + if (dma_mapping_error(tx_chn->dma_dev, buf_dma)) { + netdev_err(emac->ndev, "cmd %x: failed to map cmd buffer\n", cmd); + ret = -EINVAL; + goto err_unlock; + } + + first_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool); + if (!first_desc) { + netdev_err(emac->ndev, "cmd %x: failed to allocate descriptor\n", cmd); + dma_unmap_single(tx_chn->dma_dev, buf_dma, pkt_len, DMA_TO_DEVICE); + ret = -ENOMEM; + goto err_unlock; + } + + cppi5_hdesc_init(first_desc, CPPI5_INFO0_HDESC_EPIB_PRESENT, + PRUETH_NAV_PS_DATA_SIZE); + cppi5_hdesc_set_pkttype(first_desc, PRUETH_PKT_TYPE_CMD); + epib = first_desc->epib; + epib[0] = 0; + epib[1] = 0; + + cppi5_hdesc_attach_buf(first_desc, buf_dma, pkt_len, buf_dma, pkt_len); + swdata = cppi5_hdesc_get_swdata(first_desc); + *swdata = data; + + cppi5_hdesc_set_pktlen(first_desc, pkt_len); + desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); + + /* send command */ + reinit_completion(&emac->cmd_complete); + ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); + if (ret) { + netdev_err(emac->ndev, "cmd %x: push failed: %d\n", cmd, ret); + goto free_desc; + } + ret = wait_for_completion_timeout(&emac->cmd_complete, msecs_to_jiffies(100)); + if (!ret) + netdev_err(emac->ndev, "cmd %x: completion timeout\n", cmd); + + mutex_unlock(&emac->cmd_lock); + + return ret; +free_desc: + prueth_xmit_free(tx_chn, first_desc); +err_unlock: + mutex_unlock(&emac->cmd_lock); + + return ret; +} + +static void emac_change_port_speed_duplex_sr1(struct prueth_emac *emac) +{ + u32 cmd = ICSSG_PSTATE_SPEED_DUPLEX_CMD, val; + struct prueth *prueth = emac->prueth; + int slice = prueth_emac_slice(emac); + + /* only full duplex supported for now */ + if (emac->duplex != DUPLEX_FULL) + return; + + val = icssg_rgmii_get_speed(prueth->miig_rt, slice); + /* firmware expects full duplex settings in bit 2-1 */ + val <<= 1; + cmd |= val; + + val = icssg_rgmii_get_fullduplex(prueth->miig_rt, slice); + /* firmware expects full duplex settings in bit 3 */ + val <<= 3; + cmd |= val; + + emac_send_command_sr1(emac, cmd); +} + static void tx_ts_work(struct prueth_emac *emac) { struct skb_shared_hwtstamps ssh; @@ -873,6 +968,141 @@ static irqreturn_t prueth_tx_ts_irq(int irq, void *dev_id) return IRQ_HANDLED; } +/* get one packet from requested flow_id + * + * Returns skb pointer if packet found else NULL + * Caller must free the returned skb. + */ +static struct sk_buff *prueth_process_rx_mgm(struct prueth_emac *emac, + u32 flow_id) +{ + struct prueth_rx_chn *rx_chn = &emac->rx_mgm_chn; + struct net_device *ndev = emac->ndev; + struct cppi5_host_desc_t *desc_rx; + struct sk_buff *skb, *new_skb; + dma_addr_t desc_dma, buf_dma; + u32 buf_dma_len, pkt_len; + void **swdata; + int ret; + + ret = k3_udma_glue_pop_rx_chn(rx_chn->rx_chn, flow_id, &desc_dma); + if (ret) { + if (ret != -ENODATA) + netdev_err(ndev, "rx mgm pop: failed: %d\n", ret); + return NULL; + } + + if (cppi5_desc_is_tdcm(desc_dma)) /* Teardown */ + return NULL; + + desc_rx = k3_cppi_desc_pool_dma2virt(rx_chn->desc_pool, desc_dma); + + /* Fix FW bug about incorrect PSDATA size */ + if (cppi5_hdesc_get_psdata_size(desc_rx) != PRUETH_NAV_PS_DATA_SIZE) { + cppi5_hdesc_update_psdata_size(desc_rx, + PRUETH_NAV_PS_DATA_SIZE); + } + + swdata = cppi5_hdesc_get_swdata(desc_rx); + skb = *swdata; + cppi5_hdesc_get_obuf(desc_rx, &buf_dma, &buf_dma_len); + pkt_len = cppi5_hdesc_get_pktlen(desc_rx); + + dma_unmap_single(rx_chn->dma_dev, buf_dma, buf_dma_len, DMA_FROM_DEVICE); + k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx); + + new_skb = netdev_alloc_skb_ip_align(ndev, PRUETH_MAX_PKT_SIZE); + /* if allocation fails we drop the packet but push the + * descriptor back to the ring with old skb to prevent a stall + */ + if (!new_skb) { + netdev_err(ndev, + "skb alloc failed, dropped mgm pkt from flow %d\n", + flow_id); + new_skb = skb; + skb = NULL; /* return NULL */ + } else { + /* return the filled skb */ + skb_put(skb, pkt_len); + } + + /* queue another DMA */ + ret = prueth_dma_rx_push(emac, new_skb, &emac->rx_mgm_chn); + if (WARN_ON(ret < 0)) + dev_kfree_skb_any(new_skb); + + return skb; +} + +static void prueth_tx_ts_sr1(struct prueth_emac *emac, + struct emac_tx_ts_response_sr1 *tsr) +{ + u64 ns; + struct skb_shared_hwtstamps ssh; + struct sk_buff *skb; + + ns = (u64)tsr->hi_ts << 32 | tsr->lo_ts; + + if (tsr->cookie >= PRUETH_MAX_TX_TS_REQUESTS) { + netdev_dbg(emac->ndev, "Invalid TX TS cookie 0x%x\n", + tsr->cookie); + return; + } + + skb = emac->tx_ts_skb[tsr->cookie]; + emac->tx_ts_skb[tsr->cookie] = NULL; /* free slot */ + + memset(&ssh, 0, sizeof(ssh)); + ssh.hwtstamp = ns_to_ktime(ns); + + skb_tstamp_tx(skb, &ssh); + dev_consume_skb_any(skb); +} + +static irqreturn_t prueth_rx_mgm_ts_thread_sr1(int irq, void *dev_id) +{ + struct prueth_emac *emac = dev_id; + struct sk_buff *skb; + + skb = prueth_process_rx_mgm(emac, PRUETH_RX_MGM_FLOW_TIMESTAMP); + if (!skb) + return IRQ_NONE; + + prueth_tx_ts_sr1(emac, (void *)skb->data); + dev_kfree_skb_any(skb); + + return IRQ_HANDLED; +} + +static irqreturn_t prueth_rx_mgm_rsp_thread(int irq, void *dev_id) +{ + struct prueth_emac *emac = dev_id; + struct sk_buff *skb; + u32 rsp; + + skb = prueth_process_rx_mgm(emac, PRUETH_RX_MGM_FLOW_RESPONSE); + if (!skb) + return IRQ_NONE; + + /* Process command response */ + rsp = le32_to_cpu(*(u32 *)skb->data); + if ((rsp & 0xffff0000) == ICSSG_SHUTDOWN_CMD) { + netdev_dbg(emac->ndev, + "f/w Shutdown cmd resp %x\n", rsp); + complete(&emac->cmd_complete); + } else if ((rsp & 0xffff0000) == + ICSSG_PSTATE_SPEED_DUPLEX_CMD) { + netdev_dbg(emac->ndev, + "f/w Speed/Duplex cmd rsp %x\n", + rsp); + complete(&emac->cmd_complete); + } + + dev_kfree_skb_any(skb); + + return IRQ_HANDLED; +} + static irqreturn_t prueth_rx_irq(int irq, void *dev_id) { struct prueth_emac *emac = dev_id; @@ -1517,6 +1747,31 @@ static void emac_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue) ndev->stats.tx_errors++; } +static void emac_ndo_set_rx_mode_sr1(struct net_device *ndev) +{ + struct prueth_emac *emac = netdev_priv(ndev); + struct prueth *prueth = emac->prueth; + int slice = prueth_emac_slice(emac); + bool promisc = ndev->flags & IFF_PROMISC; + bool allmulti = ndev->flags & IFF_ALLMULTI; + + if (promisc) { + icssg_class_promiscuous_sr1(prueth->miig_rt, slice); + return; + } + + if (allmulti) { + icssg_class_default(prueth->miig_rt, slice, 1, true); + return; + } + + icssg_class_default(prueth->miig_rt, slice, 0, true); + if (!netdev_mc_empty(ndev)) { + /* program multicast address list into Classifier */ + icssg_class_add_mcast_sr1(prueth->miig_rt, slice, ndev); + } +} + static void emac_ndo_set_rx_mode_work(struct work_struct *work) { struct prueth_emac *emac = container_of(work, struct prueth_emac, rx_mode_work); From patchwork Wed Jan 17 16:15:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13522009 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 E9EFCC47DA2 for ; Wed, 17 Jan 2024 16:17:18 +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:References:In-Reply-To: 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: List-Owner; bh=v+A+JA69pWL+7ucgkNtZc2dShfmpZXtBx/xe3Yrnwrw=; b=Zs5Ko2Ua+2ZVUg VpTZfghh4V6hU6ynFLB5eYMSTGI1BkeUofj2P/UuGitdOij+TdRjgBkxq+nUHqiyunden/LgbTG29 Vep6mB4huo85Phkx+s73uio8nCQMbXca2myT7C0j6mYn4kIIYqQcKTtJU4zyOUxJJd9hCAL67busz TToQ8kAt11bG2yacNN9E8N/e05kM4cjEMQEKWgVKsNnhP9BkdKISiYx68bjrPqG859vv3Ns4k7m7I 9rwYTYAvcZK4tZNIUAd0W02n8ZeNrmN0qRPXyPOvcwUvf5qFkCQ8eLP/PT80rD2Z/sgSCXKw79Gim vuF/0mUGanu7MwNdexhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8as-0001pS-2S; Wed, 17 Jan 2024 16:16:46 +0000 Received: from mta-64-228.siemens.flowmailer.net ([185.136.64.228]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ8aZ-0001cQ-2f for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 16:16:31 +0000 Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 202401171616243dcd43c20b3f5cf443 for ; Wed, 17 Jan 2024 17:16:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=vknBMSGqxm7QwJKb4mgufGpfTitGC/9Oh3kfUHYDmXY=; b=Y65dHWy239h1+Z3Ul3Fhzoym6/R3GEPzbtEqDE2EJnevioA6pszPgFGiEu+nsvf05/SpQu IrdTVPt8wW76VlPRP+A9Yiw7Xnhl8wczMlCmj78SZjr4eoeg0kN2obVNoWAqtecnMFHf/x14 +xPPoRrQDtMEgr4r4dvq9OqX76S8w=; From: Diogo Ivo To: danishanwar@ti.com, rogerq@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, dan.carpenter@linaro.org, robh@kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Diogo Ivo , Jan Kiszka Subject: [PATCH v2 8/8] net: ti: icssg-prueth: Wire up support for SR1.0 Date: Wed, 17 Jan 2024 16:15:02 +0000 Message-ID: <20240117161602.153233-9-diogo.ivo@siemens.com> In-Reply-To: <20240117161602.153233-1-diogo.ivo@siemens.com> References: <20240117161602.153233-1-diogo.ivo@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_081628_155771_B4728E7C X-CRM114-Status: GOOD ( 20.96 ) 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 Add the function calls to enable operation for SR1.0. Based on the work of Roger Quadros, Vignesh Raghavendra and Grygorii Strashko in TI's 5.10 SDK [1]. [1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y Co-developed-by: Jan Kiszka Signed-off-by: Jan Kiszka Signed-off-by: Diogo Ivo --- Changes in v2: - Removed explicit references to SR2.0 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 299 +++++++++++++++---- 1 file changed, 239 insertions(+), 60 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index db15c8680741..352fb1cb3aba 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -169,6 +169,13 @@ static int emac_tx_complete_packets(struct prueth_emac *emac, int chn, desc_dma); swdata = cppi5_hdesc_get_swdata(desc_tx); + /* was this command's TX complete? */ + if (emac->is_sr1 && *(swdata) == emac->cmd_data) { + prueth_xmit_free(tx_chn, desc_tx); + budget++; /* not a data packet */ + continue; + } + skb = *(swdata); prueth_xmit_free(tx_chn, desc_tx); @@ -344,6 +351,7 @@ static int prueth_init_rx_chns(struct prueth_emac *emac, struct net_device *ndev = emac->ndev; u32 fdqring_id, hdesc_size; int i, ret = 0, slice; + int flow_id_base; slice = prueth_emac_slice(emac); if (slice < 0) @@ -384,8 +392,14 @@ static int prueth_init_rx_chns(struct prueth_emac *emac, goto fail; } - emac->rx_flow_id_base = k3_udma_glue_rx_get_flow_id_base(rx_chn->rx_chn); - netdev_dbg(ndev, "flow id base = %d\n", emac->rx_flow_id_base); + flow_id_base = k3_udma_glue_rx_get_flow_id_base(rx_chn->rx_chn); + if (!strcmp(name, "rxmgm")) { + emac->rx_mgm_flow_id_base = flow_id_base; + netdev_dbg(ndev, "mgm flow id base = %d\n", flow_id_base); + } else { + emac->rx_flow_id_base = flow_id_base; + netdev_dbg(ndev, "flow id base = %d\n", flow_id_base); + } fdqring_id = K3_RINGACC_RING_ID_ANY; for (i = 0; i < rx_cfg.flow_id_num; i++) { @@ -494,10 +508,14 @@ static void emac_rx_timestamp(struct prueth_emac *emac, struct skb_shared_hwtstamps *ssh; u64 ns; - u32 hi_sw = readl(emac->prueth->shram.va + - TIMESYNC_FW_WC_COUNT_HI_SW_OFFSET_OFFSET); - ns = icssg_ts_to_ns(hi_sw, psdata[1], psdata[0], - IEP_DEFAULT_CYCLE_TIME_NS); + if (emac->is_sr1) { + ns = (u64)psdata[1] << 32 | psdata[0]; + } else { + u32 hi_sw = readl(emac->prueth->shram.va + + TIMESYNC_FW_WC_COUNT_HI_SW_OFFSET_OFFSET); + ns = icssg_ts_to_ns(hi_sw, psdata[1], psdata[0], + IEP_DEFAULT_CYCLE_TIME_NS); + } ssh = skb_hwtstamps(skb); memset(ssh, 0, sizeof(*ssh)); @@ -1119,6 +1137,17 @@ struct icssg_firmwares { char *txpru; }; +static struct icssg_firmwares icssg_emac_firmwares_sr1[] = { + { + .pru = "ti-pruss/am65x-pru0-prueth-fw.elf", + .rtu = "ti-pruss/am65x-rtu0-prueth-fw.elf", + }, + { + .pru = "ti-pruss/am65x-pru1-prueth-fw.elf", + .rtu = "ti-pruss/am65x-rtu1-prueth-fw.elf", + } +}; + static struct icssg_firmwares icssg_emac_firmwares[] = { { .pru = "ti-pruss/am65x-sr2-pru0-prueth-fw.elf", @@ -1138,7 +1167,8 @@ static int prueth_emac_start(struct prueth *prueth, struct prueth_emac *emac) struct device *dev = prueth->dev; int slice, ret; - firmwares = icssg_emac_firmwares; + firmwares = prueth->pdata.is_sr1 ? icssg_emac_firmwares_sr1 + : icssg_emac_firmwares; slice = prueth_emac_slice(emac); if (slice < 0) { @@ -1164,11 +1194,15 @@ static int prueth_emac_start(struct prueth *prueth, struct prueth_emac *emac) goto halt_pru; } - ret = rproc_set_firmware(prueth->txpru[slice], firmwares[slice].txpru); - ret = rproc_boot(prueth->txpru[slice]); - if (ret) { - dev_err(dev, "failed to boot TX_PRU%d: %d\n", slice, ret); - goto halt_rtu; + if (!emac->is_sr1) { + ret = rproc_set_firmware(prueth->txpru[slice], + firmwares[slice].txpru); + ret = rproc_boot(prueth->txpru[slice]); + if (ret) { + dev_err(dev, "failed to boot TX_PRU%d: %d\n", + slice, ret); + goto halt_rtu; + } } emac->fw_running = 1; @@ -1201,7 +1235,8 @@ static void prueth_emac_stop(struct prueth_emac *emac) } emac->fw_running = 0; - rproc_shutdown(prueth->txpru[slice]); + if (!emac->is_sr1) + rproc_shutdown(prueth->txpru[slice]); rproc_shutdown(prueth->rtu[slice]); rproc_shutdown(prueth->pru[slice]); } @@ -1269,11 +1304,15 @@ static void emac_adjust_link(struct net_device *ndev) icssg_config_ipg(emac); spin_unlock_irqrestore(&emac->lock, flags); icssg_config_set_speed(emac); - emac_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD); + if (!emac->is_sr1) + emac_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD); - } else { + } else if (!emac->is_sr1) { emac_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE); } + + if (emac->is_sr1 && emac->link) + emac_change_port_speed_duplex_sr1(emac); } if (emac->link) { @@ -1288,8 +1327,10 @@ static void emac_adjust_link(struct net_device *ndev) static int emac_napi_rx_poll(struct napi_struct *napi_rx, int budget) { struct prueth_emac *emac = prueth_napi_to_emac(napi_rx); - int rx_flow = PRUETH_RX_FLOW_DATA; - int flow = PRUETH_MAX_RX_FLOWS; + int rx_flow = emac->is_sr1 ? + PRUETH_RX_FLOW_DATA_SR1 : PRUETH_RX_FLOW_DATA; + int flow = emac->is_sr1 ? + PRUETH_MAX_RX_FLOWS_SR1 : PRUETH_MAX_RX_FLOWS; int num_rx = 0; int cur_budget; int ret; @@ -1553,11 +1594,19 @@ static int emac_ndo_open(struct net_device *ndev) memset_io(prueth->shram.va, 0, ICSSG_CONFIG_OFFSET_SLICE1 * PRUETH_NUM_MACS); } + if (emac->is_sr1) { + /* For SR1, high priority channel is used exclusively for + * management messages. Do reduce number of data channels. + */ + num_data_chn--; + } + /* set h/w MAC as user might have re-configured */ ether_addr_copy(emac->mac_addr, ndev->dev_addr); icssg_class_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); - icssg_ft1_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); + if (!emac->is_sr1) + icssg_ft1_set_mac_addr(prueth->miig_rt, slice, emac->mac_addr); icssg_class_default(prueth->miig_rt, slice, 0, emac->is_sr1); @@ -1575,7 +1624,8 @@ static int emac_ndo_open(struct net_device *ndev) return ret; } - max_rx_flows = PRUETH_MAX_RX_FLOWS; + max_rx_flows = emac->is_sr1 ? + PRUETH_MAX_RX_FLOWS_SR1 : PRUETH_MAX_RX_FLOWS; ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx", max_rx_flows, PRUETH_MAX_RX_DESC); if (ret) { @@ -1583,12 +1633,24 @@ static int emac_ndo_open(struct net_device *ndev) goto cleanup_tx; } + if (emac->is_sr1) { + ret = prueth_init_rx_chns(emac, &emac->rx_mgm_chn, "rxmgm", + PRUETH_MAX_RX_MGM_FLOWS, + PRUETH_MAX_RX_MGM_DESC); + if (ret) { + dev_err(dev, "failed to init rx mgmt channel: %d\n", + ret); + goto cleanup_rx; + } + } + ret = prueth_ndev_add_tx_napi(emac); if (ret) - goto cleanup_rx; + goto cleanup_rx_mgm; /* we use only the highest priority flow for now i.e. @irq[3] */ - rx_flow = PRUETH_RX_FLOW_DATA; + rx_flow = emac->is_sr1 ? + PRUETH_RX_FLOW_DATA_SR1 : PRUETH_RX_FLOW_DATA; ret = request_irq(emac->rx_chns.irq[rx_flow], prueth_rx_irq, IRQF_TRIGGER_HIGH, dev_name(dev), emac); if (ret) { @@ -1596,31 +1658,66 @@ static int emac_ndo_open(struct net_device *ndev) goto cleanup_napi; } + if (!emac->is_sr1) + goto skip_mgm_irq; + + ret = request_threaded_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_RESPONSE], + NULL, prueth_rx_mgm_rsp_thread, + IRQF_ONESHOT | IRQF_TRIGGER_HIGH, + dev_name(dev), emac); + if (ret) { + dev_err(dev, "unable to request RX Management RSP IRQ\n"); + goto free_rx_irq; + } + + ret = request_threaded_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_TIMESTAMP], + NULL, prueth_rx_mgm_ts_thread_sr1, + IRQF_ONESHOT | IRQF_TRIGGER_HIGH, + dev_name(dev), emac); + if (ret) { + dev_err(dev, "unable to request RX Management TS IRQ\n"); + goto free_rx_mgm_rsp_irq; + } + +skip_mgm_irq: /* reset and start PRU firmware */ ret = prueth_emac_start(prueth, emac); if (ret) - goto free_rx_irq; + goto free_rx_mgmt_ts_irq; icssg_mii_update_mtu(prueth->mii_rt, slice, ndev->max_mtu); - if (!prueth->emacs_initialized) { + if (!emac->is_sr1 && !prueth->emacs_initialized) { ret = icss_iep_init(emac->iep, &prueth_iep_clockops, emac, IEP_DEFAULT_CYCLE_TIME_NS); } - ret = request_threaded_irq(emac->tx_ts_irq, NULL, prueth_tx_ts_irq, - IRQF_ONESHOT, dev_name(dev), emac); - if (ret) - goto stop; + if (!emac->is_sr1) { + ret = request_threaded_irq(emac->tx_ts_irq, NULL, + prueth_tx_ts_irq, IRQF_ONESHOT, + dev_name(dev), emac); + if (ret) + goto stop; + } /* Prepare RX */ ret = prueth_prepare_rx_chan(emac, &emac->rx_chns, PRUETH_MAX_PKT_SIZE); if (ret) goto free_tx_ts_irq; + if (emac->is_sr1) { + ret = prueth_prepare_rx_chan(emac, &emac->rx_mgm_chn, 64); + if (ret) + goto reset_rx_chn; + + ret = k3_udma_glue_enable_rx_chn(emac->rx_mgm_chn.rx_chn); + if (ret) + goto reset_rx_chn; + } + ret = k3_udma_glue_enable_rx_chn(emac->rx_chns.rx_chn); if (ret) - goto reset_rx_chn; + goto reset_rx_mgm_chn; for (i = 0; i < emac->tx_ch_num; i++) { ret = k3_udma_glue_enable_tx_chn(emac->tx_chns[i].tx_chn); @@ -1647,16 +1744,33 @@ static int emac_ndo_open(struct net_device *ndev) * any SKB for completion. So set false to free_skb */ prueth_reset_tx_chan(emac, i, false); +reset_rx_mgm_chn: + if (emac->is_sr1) + prueth_reset_rx_chan(&emac->rx_mgm_chn, + PRUETH_MAX_RX_MGM_FLOWS, true); reset_rx_chn: prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, false); free_tx_ts_irq: - free_irq(emac->tx_ts_irq, emac); + if (!emac->is_sr1) + free_irq(emac->tx_ts_irq, emac); stop: prueth_emac_stop(emac); +free_rx_mgmt_ts_irq: + if (emac->is_sr1) + free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_TIMESTAMP], + emac); +free_rx_mgm_rsp_irq: + if (emac->is_sr1) + free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_RESPONSE], + emac); free_rx_irq: free_irq(emac->rx_chns.irq[rx_flow], emac); cleanup_napi: prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); +cleanup_rx_mgm: + if (emac->is_sr1) + prueth_cleanup_rx_chns(emac, &emac->rx_mgm_chn, + PRUETH_MAX_RX_MGM_FLOWS); cleanup_rx: prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); cleanup_tx: @@ -1677,7 +1791,8 @@ static int emac_ndo_stop(struct net_device *ndev) { struct prueth_emac *emac = netdev_priv(ndev); struct prueth *prueth = emac->prueth; - int rx_flow = PRUETH_RX_FLOW_DATA; + int rx_flow = emac->is_sr1 ? PRUETH_RX_FLOW_DATA_SR1 : + PRUETH_RX_FLOW_DATA; int max_rx_flows; int ret, i; @@ -1690,6 +1805,9 @@ static int emac_ndo_stop(struct net_device *ndev) icssg_class_disable(prueth->miig_rt, prueth_emac_slice(emac)); + if (emac->is_sr1) + emac_send_command_sr1(emac, ICSSG_SHUTDOWN_CMD); + atomic_set(&emac->tdown_cnt, emac->tx_ch_num); /* ensure new tdown_cnt value is visible */ smp_mb__after_atomic(); @@ -1707,10 +1825,17 @@ static int emac_ndo_stop(struct net_device *ndev) for (i = 0; i < emac->tx_ch_num; i++) napi_disable(&emac->tx_chns[i].napi_tx); - max_rx_flows = PRUETH_MAX_RX_FLOWS; + max_rx_flows = emac->is_sr1 ? + PRUETH_MAX_RX_FLOWS_SR1 : PRUETH_MAX_RX_FLOWS; k3_udma_glue_tdown_rx_chn(emac->rx_chns.rx_chn, true); prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, true); + if (emac->is_sr1) { + /* Teardown RX MGM channel */ + k3_udma_glue_tdown_rx_chn(emac->rx_mgm_chn.rx_chn, true); + prueth_reset_rx_chan(&emac->rx_mgm_chn, + PRUETH_MAX_RX_MGM_FLOWS, true); + } napi_disable(&emac->napi_rx); @@ -1722,18 +1847,28 @@ static int emac_ndo_stop(struct net_device *ndev) /* stop PRUs */ prueth_emac_stop(emac); - if (prueth->emacs_initialized == 1) + if (!emac->is_sr1 && prueth->emacs_initialized == 1) icss_iep_exit(emac->iep); /* stop PRUs */ prueth_emac_stop(emac); - free_irq(emac->tx_ts_irq, emac); + if (!emac->is_sr1) + free_irq(emac->tx_ts_irq, emac); + if (emac->is_sr1) { + free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_TIMESTAMP], + emac); + free_irq(emac->rx_mgm_chn.irq[PRUETH_RX_MGM_FLOW_RESPONSE], + emac); + } free_irq(emac->rx_chns.irq[rx_flow], emac); prueth_ndev_del_tx_napi(emac, emac->tx_ch_num); prueth_cleanup_tx_chns(emac); + if (emac->is_sr1) + prueth_cleanup_rx_chns(emac, &emac->rx_mgm_chn, + PRUETH_MAX_RX_MGM_FLOWS); prueth_cleanup_rx_chns(emac, &emac->rx_chns, max_rx_flows); prueth_cleanup_tx_chns(emac); @@ -1814,7 +1949,10 @@ static void emac_ndo_set_rx_mode(struct net_device *ndev) { struct prueth_emac *emac = netdev_priv(ndev); - queue_work(emac->cmd_wq, &emac->rx_mode_work); + if (emac->is_sr1) + emac_ndo_set_rx_mode_sr1(ndev); + else + queue_work(emac->cmd_wq, &emac->rx_mode_work); } static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr) @@ -1994,6 +2132,10 @@ static int prueth_netdev_init(struct prueth *prueth, if (mac == PRUETH_MAC_INVALID) return -EINVAL; + /* Use 1 channel for management messages on SR1 */ + if (prueth->pdata.is_sr1) + num_tx_chn--; + ndev = alloc_etherdev_mq(sizeof(*emac), num_tx_chn); if (!ndev) return -ENOMEM; @@ -2021,7 +2163,15 @@ static int prueth_netdev_init(struct prueth *prueth, goto free_wq; } + emac->is_sr1 = prueth->pdata.is_sr1; emac->tx_ch_num = 1; + if (emac->is_sr1) { + /* use a dedicated high priority channel for management + * messages which is +1 of highest priority data channel. + */ + emac->tx_ch_num++; + goto skip_irq; + } irq_name = "tx_ts0"; if (emac->port_id == PRUETH_PORT_MII1) @@ -2032,6 +2182,7 @@ static int prueth_netdev_init(struct prueth *prueth, goto free; } +skip_irq: SET_NETDEV_DEV(ndev, prueth->dev); spin_lock_init(&emac->lock); mutex_init(&emac->cmd_lock); @@ -2158,7 +2309,7 @@ static int prueth_get_cores(struct prueth *prueth, int slice) idx = 0; break; case ICSS_SLICE1: - idx = 3; + idx = prueth->pdata.is_sr1 ? 2 : 3; break; default: return -EINVAL; @@ -2180,6 +2331,9 @@ static int prueth_get_cores(struct prueth *prueth, int slice) return dev_err_probe(dev, ret, "unable to get RTU%d\n", slice); } + if (prueth->pdata.is_sr1) + return 0; + idx++; prueth->txpru[slice] = pru_rproc_get(np, idx, NULL); if (IS_ERR(prueth->txpru[slice])) { @@ -2329,14 +2483,20 @@ static int prueth_probe(struct platform_device *pdev) goto put_mem; } - msmc_ram_size = MSMC_RAM_SIZE; + msmc_ram_size = prueth->pdata.is_sr1 ? MSMC_RAM_SIZE_SR1 : MSMC_RAM_SIZE; - /* NOTE: FW bug needs buffer base to be 64KB aligned */ - prueth->msmcram.va = - (void __iomem *)gen_pool_alloc_algo(prueth->sram_pool, - msmc_ram_size, - gen_pool_first_fit_align, - &gp_data); + if (prueth->pdata.is_sr1) { + prueth->msmcram.va = + (void __iomem *)gen_pool_alloc(prueth->sram_pool, + msmc_ram_size); + } else { + /* NOTE: FW bug needs buffer base to be 64KB aligned */ + prueth->msmcram.va = + (void __iomem *)gen_pool_alloc_algo(prueth->sram_pool, + msmc_ram_size, + gen_pool_first_fit_align, + &gp_data); + } if (!prueth->msmcram.va) { ret = -ENOMEM; @@ -2350,17 +2510,19 @@ static int prueth_probe(struct platform_device *pdev) dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa, prueth->msmcram.va, prueth->msmcram.size); - prueth->iep0 = icss_iep_get_idx(np, 0); - if (IS_ERR(prueth->iep0)) { - ret = dev_err_probe(dev, PTR_ERR(prueth->iep0), "iep0 get failed\n"); - prueth->iep0 = NULL; - goto free_pool; - } + if (!prueth->pdata.is_sr1) { + prueth->iep0 = icss_iep_get_idx(np, 0); + if (IS_ERR(prueth->iep0)) { + ret = dev_err_probe(dev, PTR_ERR(prueth->iep0), "iep0 get failed\n"); + prueth->iep0 = NULL; + goto free_pool; + } - prueth->iep1 = icss_iep_get_idx(np, 1); - if (IS_ERR(prueth->iep1)) { - ret = dev_err_probe(dev, PTR_ERR(prueth->iep1), "iep1 get failed\n"); - goto put_iep0; + prueth->iep1 = icss_iep_get_idx(np, 1); + if (IS_ERR(prueth->iep1)) { + ret = dev_err_probe(dev, PTR_ERR(prueth->iep1), "iep1 get failed\n"); + goto put_iep0; + } } if (prueth->pdata.quirk_10m_link_issue) { @@ -2382,7 +2544,8 @@ static int prueth_probe(struct platform_device *pdev) if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL)) prueth->emac[PRUETH_MAC0]->half_duplex = 1; - prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; + if (!prueth->pdata.is_sr1) + prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; } if (eth1_node) { @@ -2396,7 +2559,8 @@ static int prueth_probe(struct platform_device *pdev) if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL)) prueth->emac[PRUETH_MAC1]->half_duplex = 1; - prueth->emac[PRUETH_MAC1]->iep = prueth->iep0; + if (!prueth->pdata.is_sr1) + prueth->emac[PRUETH_MAC1]->iep = prueth->iep0; } /* register the network devices */ @@ -2457,10 +2621,13 @@ static int prueth_probe(struct platform_device *pdev) exit_iep: if (prueth->pdata.quirk_10m_link_issue) icss_iep_exit_fw(prueth->iep1); - icss_iep_put(prueth->iep1); + + if (!prueth->pdata.is_sr1) + icss_iep_put(prueth->iep1); put_iep0: - icss_iep_put(prueth->iep0); + if (!prueth->pdata.is_sr1) + icss_iep_put(prueth->iep0); prueth->iep0 = NULL; prueth->iep1 = NULL; @@ -2511,15 +2678,21 @@ static void prueth_remove(struct platform_device *pdev) prueth_netdev_exit(prueth, eth_node); } - if (prueth->pdata.quirk_10m_link_issue) + if (prueth->pdata.is_sr1) { + icss_iep_exit(prueth->iep1); + icss_iep_exit(prueth->iep0); + } else if (prueth->pdata.quirk_10m_link_issue) { icss_iep_exit_fw(prueth->iep1); + } - icss_iep_put(prueth->iep1); - icss_iep_put(prueth->iep0); + if (!prueth->pdata.is_sr1) { + icss_iep_put(prueth->iep1); + icss_iep_put(prueth->iep0); + } gen_pool_free(prueth->sram_pool, (unsigned long)prueth->msmcram.va, - MSMC_RAM_SIZE); + prueth->pdata.is_sr1 ? MSMC_RAM_SIZE_SR1 : MSMC_RAM_SIZE); pruss_release_mem_region(prueth->pruss, &prueth->shram); @@ -2588,6 +2761,11 @@ static const struct dev_pm_ops prueth_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(prueth_suspend, prueth_resume) }; +static const struct prueth_pdata am654_icssg_pdata_sr1 = { + .fdqring_mode = K3_RINGACC_RING_MODE_MESSAGE, + .is_sr1 = 1, +}; + static const struct prueth_pdata am654_icssg_pdata = { .fdqring_mode = K3_RINGACC_RING_MODE_MESSAGE, .quirk_10m_link_issue = 1, @@ -2598,6 +2776,7 @@ static const struct prueth_pdata am64x_icssg_pdata = { }; static const struct of_device_id prueth_dt_match[] = { + { .compatible = "ti,am654-sr1-icssg-prueth", .data = &am654_icssg_pdata_sr1 }, { .compatible = "ti,am654-icssg-prueth", .data = &am654_icssg_pdata }, { .compatible = "ti,am642-icssg-prueth", .data = &am64x_icssg_pdata }, { /* sentinel */ }