Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp517231rwe; Fri, 26 Aug 2022 09:06:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Qvbg9jJZAuv9O02f77/IiuUMYL+2lSn9BoDihjtu3JcfnazJilOiqhguEHCjXQnKO42Cd X-Received: by 2002:a17:903:31cc:b0:172:cad5:6b4 with SMTP id v12-20020a17090331cc00b00172cad506b4mr4347010ple.115.1661529966390; Fri, 26 Aug 2022 09:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661529966; cv=none; d=google.com; s=arc-20160816; b=AtnbEt5ya/kpdla/bEfkcUFumnzVb2GSImG7BAGStRw7TxeXJVGqxFuR2VEH0drEl6 3zb+qvNQ3LFtzTu22E/dLlmW2ZBGMivpxPyq+kdsUBlMoL3vVr9eUbz/7mSZ62un1H+4 KLno3oMa2CnZLqRoAc2FwmxezEsmF1z3Di1t/OmUSLNzj4yQKWeXdzgexyox4jN5ZwDR vocq+e6yMZBXl03wGEMFiJrwU4OGUQymoGqtk4oubkzRExrf/fAgTbI9/63lNO78VQmR 5Mat/AQK7siJkhrlU3AR4Y10vWCAXThw5BdjoK47/Lzj+SblnuND5UzQ46Np7A/mp5GA 3Gcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eZr0J8+qb/Ei8PXAx8Ykb6vJ8WCaimAPLNHVD8qujUc=; b=Kaa+ABLqVyCu/JXweq6Dt+kc5EKp72R/Ucmn5pOl9oiwyrdhokNgIGH+/OxpoBuXEU XxS3Dg8m22otssVQlIZjyafoqWZzkAXEX5l9NbT67ZE613hTqSeC0xD0ByiBhXGR6ezh orPfRsRHDVl5M0za00g2mwZUqzY4RdUnfBaqBpHTyymVH+xga4BR8o7CZ+TuoKjmnEjP EtR4CV4e5EV4G45o2GTnX+oJVksfesQEcLP8Iv4FdE98q2LsAWQMQQop9T17yHCH3JlY 3xj+Bb8BfpSn+ZURggjIbaTKYNzmeVmYpkOEU5vqKgj++Gq6KnYpGbrPWto+RQeCBQ4o 2rUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=M5Dglmes; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u142-20020a627994000000b00525b292ccf0si1848046pfc.124.2022.08.26.09.05.54; Fri, 26 Aug 2022 09:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=M5Dglmes; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344631AbiHZPrr (ORCPT + 99 others); Fri, 26 Aug 2022 11:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344463AbiHZPrF (ORCPT ); Fri, 26 Aug 2022 11:47:05 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 898B17E802; Fri, 26 Aug 2022 08:47:03 -0700 (PDT) Received: (Authenticated sender: maxime.chevallier@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 2406C1BF212; Fri, 26 Aug 2022 15:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1661528820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eZr0J8+qb/Ei8PXAx8Ykb6vJ8WCaimAPLNHVD8qujUc=; b=M5DglmesfBVtZsZJdqGDI1cvDySNlpAbAGRqzajXwNCmuv2nkxrMxAXCGUBavEzT87Fypi 4HJJqc08zxg/hgqaDL3YqIMpYeiaL2oFaSe3xwftPWeseqn5sLgbeGnOiNkvkBs5/Fc1j8 5yliAS/2GjkJ+IKdycN7mMTEhR6yO1QNDvDI7jo8nwWYBoUR/BzCevzxhbllKPmdpkOWvu WU+KwJdQbA9nBOf+3SiQosozX2vhF9Kj89RyN+Zol/q0cIyDkKuX7drtEP1O90Xepm3GJf G3ND/gEVXqmiqbqSOKneteUFhUfTRI0xbV0fZ6INNXL8824j8c0WCwbW6tvZ5A== From: Maxime Chevallier To: davem@davemloft.net, Rob Herring Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Vladimir Oltean , Luka Perkov , Robert Marko Subject: [PATCH net-next v3 3/5] net: ipqess: Add out-of-band DSA tagging support Date: Fri, 26 Aug 2022 17:46:48 +0200 Message-Id: <20220826154650.615582-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826154650.615582-1-maxime.chevallier@bootlin.com> References: <20220826154650.615582-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On the IPQ4019, there's an 5 ports switch connected to the CPU through the IPQESS Ethernet controller. The way the DSA tag is sent-out to that switch is through the DMA descriptor, due to how tightly it is integrated with the switch. This commit uses the out-of-band tagging protocol by getting the source port from the descriptor, push it into the skb, and have the tagger pull it to infer the destination netdev. The reverse process is done on the TX side, where the driver pulls the tag from the skb and builds the descriptor accordingly. Signed-off-by: Maxime Chevallier --- V2->V3: - No changes V1->V2: - Use the new tagger, and the dsa_oob_tag_* helpers drivers/net/ethernet/qualcomm/Kconfig | 3 ++- drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig index a723ddbea248..eeb2c608d6b9 100644 --- a/drivers/net/ethernet/qualcomm/Kconfig +++ b/drivers/net/ethernet/qualcomm/Kconfig @@ -62,8 +62,9 @@ config QCOM_EMAC config QCOM_IPQ4019_ESS_EDMA tristate "Qualcomm Atheros IPQ4019 ESS EDMA support" - depends on OF + depends on OF && NET_DSA select PHYLINK + select NET_DSA_TAG_OOB help This driver supports the Qualcomm Atheros IPQ40xx built-in ESS EDMA ethernet controller. diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c index 2783b4d66d45..da0d735342aa 100644 --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include #include "ipqess.h" @@ -330,6 +332,7 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget) tail &= IPQESS_RFD_CONS_IDX_MASK; while (done < budget) { + struct dsa_oob_tag_info tag_info; struct ipqess_rx_desc *rd; struct sk_buff *skb; @@ -409,6 +412,12 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget) __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021AD), rd->rrd4); + if (netdev_uses_dsa(rx_ring->ess->netdev)) { + tag_info.dp = FIELD_GET(IPQESS_RRD_PORT_ID_MASK, rd->rrd1); + tag_info.proto = DSA_TAG_PROTO_OOB; + dsa_oob_tag_push(skb, &tag_info); + } + napi_gro_receive(&rx_ring->napi_rx, skb); rx_ring->ess->stats.rx_packets++; @@ -713,6 +722,22 @@ static void ipqess_rollback_tx(struct ipqess *eth, tx_ring->head = start_index; } +static void ipqess_process_dsa_tag_sh(struct ipqess *ess, struct sk_buff *skb, + u32 *word3) +{ + struct dsa_oob_tag_info tag_info; + + if (!netdev_uses_dsa(ess->netdev)) + return; + + if (dsa_oob_tag_pop(skb, &tag_info)) + return; + + *word3 |= tag_info.dp << IPQESS_TPD_PORT_BITMAP_SHIFT; + *word3 |= BIT(IPQESS_TPD_FROM_CPU_SHIFT); + *word3 |= 0x3e << IPQESS_TPD_PORT_BITMAP_SHIFT; +} + static int ipqess_tx_map_and_fill(struct ipqess_tx_ring *tx_ring, struct sk_buff *skb) { @@ -723,6 +748,8 @@ static int ipqess_tx_map_and_fill(struct ipqess_tx_ring *tx_ring, u16 len; int i; + ipqess_process_dsa_tag_sh(tx_ring->ess, skb, &word3); + if (skb_is_gso(skb)) { if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) { lso_word1 |= IPQESS_TPD_IPV4_EN; -- 2.37.2