Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp965242pxb; Fri, 22 Apr 2022 15:29:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWS9DeMI7cIoKXd5e3t9p+lBRt9dtfYdXZrPi8994q2l6+REdjl9/EbqjnboHkKrWEJiNM X-Received: by 2002:a05:6a00:158d:b0:50c:df7b:ca25 with SMTP id u13-20020a056a00158d00b0050cdf7bca25mr7155746pfk.27.1650666543592; Fri, 22 Apr 2022 15:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650666543; cv=none; d=google.com; s=arc-20160816; b=oNFCHOtLIAlHreLDft7Ezv+iIi1dU+S5HQt/zEDbM3NpnrHNcHAuCkuoGaGJy002wL 0UYFZAKfI/+7A7rsrqE2O9DDkiq65gEcpYt53pWhNA1QkOGrei3olC2gs3Url4O1CSvs 6jVerpLirgxo3kJEnxqsUCOn9TWU+pZUYa9XuSanrvxYp+ptsEdhzABZ/jLmbzjAln3e R4ocKlUFD3C6Ps+davB3c0ln6cI/4Qi11NDnosyqif7KPn8/7L0N1OVKyBFClUGlUo3k deFzey3qaqX/EvJ8tfDqRQk3tyuomlC8ZpCccX3tQk0yqvESkdfD5vQcWvn6PKN5h/XF 0vnA== 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=3JC08cZE+VNj3BTHyjNtYZ6pb37MrGbgGzOGxJdRevQ=; b=dMAZHbIFWJLEMnd52I/+Lvhd1s6ZAwrhr9ZnnWzxNCSJMgf5WneNMvOaEJIjRYjD2Y bnK/KewuwCDQ+/Vv8aODWgw0aGUTYOmv2KTAn/nC00iEfR7FuW0gkIhtl0PNC/GpxLub V7DHKqOLMs8/wflBH8qFhvo85yqQMboTF2lAURu+2HJYal4o2wDDaVPTQwhXjrhuzzFG hIHU8HhWMP74yymtZ0ry1no828daesOm1+21mjAkKC/Iok1QDYWSIWL4XmrG6U330bMA MW0GOZc99I37X4frSEk5B44aQmkDFc85xbkSrVh9c4XH3DPjppR/m7jR0wi5iS7u2Ay1 Bcvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iYvPTy5J; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k6-20020a170902760600b00156a95ac6efsi9139989pll.611.2022.04.22.15.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:29:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iYvPTy5J; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 516E629ADCA; Fri, 22 Apr 2022 13:36:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234424AbiDVSIe (ORCPT + 99 others); Fri, 22 Apr 2022 14:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237275AbiDVSGr (ORCPT ); Fri, 22 Apr 2022 14:06:47 -0400 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C72C74A9; Fri, 22 Apr 2022 11:03:52 -0700 (PDT) Received: from relay2-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::222]) by mslow1.mail.gandi.net (Postfix) with ESMTP id E14BDC3B70; Fri, 22 Apr 2022 18:03:35 +0000 (UTC) Received: (Authenticated sender: maxime.chevallier@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 874E24000A; Fri, 22 Apr 2022 18:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1650650595; 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=3JC08cZE+VNj3BTHyjNtYZ6pb37MrGbgGzOGxJdRevQ=; b=iYvPTy5JGGsMZSmUu4ROU/+a5G0T0F0ogIXw6HukaSktm+bKMSBd4lY7fOJQpnKsT0PQlA Q0fUpPtNxdeXypCw1ThOPMA97qS0GCznn8FtGopIa9qcEAL/KapFK+/a8OxMQ+7dtLQsyP 4VNnrVrbjt0vg4rwIOSfT5XTGIJZqr8Q7bEkw4hkIGLqBpA0C271xDKgSS7pZVyAoe8949 WYh9pSJzrRFRTDnUCBqvo1SMP8ycdqrcxqM9bGI9TlztwH9Qol/XMlMd7u/Hbj6TaftPWx b2heQ4MQ7R/x9xVrgA0IAOgVft80kSGZMezwlR0yIeaDlhktV7QSgb6ZKSWiyA== 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 3/5] net: ipqess: Add out-of-band DSA tagging support Date: Fri, 22 Apr 2022 20:03:03 +0200 Message-Id: <20220422180305.301882-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422180305.301882-1-maxime.chevallier@bootlin.com> References: <20220422180305.301882-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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 to get the outgoing port index for each SKB, and reports it back in the skb->shinfo on the RX side based on information located in the descriptor. Signed-off-by: Maxime Chevallier --- drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c index 4ecb8c65417b..32a5cdd1c063 100644 --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "ipqess.h" @@ -399,6 +400,11 @@ static int ipqess_rx_poll(struct ipqess_rx_ring *rx_ring, int budget) skb->protocol = eth_type_trans(skb, rx_ring->ess->netdev); skb_record_rx_queue(skb, rx_ring->ring_id); + if (netdev_uses_dsa(rx_ring->ess->netdev)) { + skb_shinfo(skb)->dsa_tag_info.dp = + FIELD_GET(IPQESS_RRD_PORT_ID_MASK, rd->rrd1); + } + if (rd->rrd6 & IPQESS_RRD_CSUM_FAIL_MASK) skb_checksum_none_assert(skb); else @@ -706,6 +712,21 @@ 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 skb_shared_info *shinfo = skb_shinfo(skb); + struct dsa_tag_info *tag_info = &shinfo->dsa_tag_info; + + if (!netdev_uses_dsa(ess->netdev) || + tag_info->proto != DSA_TAG_PROTO_OOB) + 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) { @@ -716,6 +737,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.35.1