Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1554300rdb; Wed, 20 Sep 2023 12:25:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9LZlHWYMT3fkYkH9baEerpbjGtaYJyYrunyHv7CJefENdlO1MGtfbf5w8cNGVLp3PQVQV X-Received: by 2002:a05:6870:8a0f:b0:1bb:c50d:7451 with SMTP id p15-20020a0568708a0f00b001bbc50d7451mr4261562oaq.46.1695237922976; Wed, 20 Sep 2023 12:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695237922; cv=none; d=google.com; s=arc-20160816; b=iWlTaxPxCFS+qLsHILK1QbnD0fu5x5CylNasw1uRNMXZNIs8cDwvTSnfQ+8/Sehv7I CX2IjxqRXDSaDX6M2Cs0l/z6kSZv33ZUb5LakNyUNJHT052lcsV4alOLNB9zcffI+4fL L2CVx/URGugzfvzVm8vlMDUnfjS+tSAroeJ4kKX6pLKcdNvKiXxUwQKfzt7CTJWolP/P LkHtziBuFR3mVZyjsXYPQypG2oSbxeRP4n6kh/gl6BE5rqTSsH026xj8erN9Qs8g/brb ZApKp6L5UDbRSq6x7wxrbgwb6x91Y2VekyoO9psLAZaGjg1GUuNcVLEYLdb0rne5MM3o XbbA== 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=vFPC4EiLCUTFUWbe59gLsrG1YBY4uTMUwAsCR3vkdZs=; fh=Jfg3FS8fsRNBkvUGwLEW6Abzb8InqsTQ+ekYW23wRXI=; b=tr5fXGuRcXwEtUSXu2olJ5u3803G0kswWQOr5aAGPSNbPulcc3AJQgj/W6Mklzq8li lpnBILHyWzVZPeLQz8/hoRYE4ZEtZU8k1RV9HSHKndMrNQH9SAJIOmwOpEo6Q6e0Pvr3 sRDDfqC7+uxDWhy/iDeMcE82G+f3FKpjWB4Jxgy023gwyhvhaWygcMtN6JL1Ulv9Da4u vVbDc8xNpNDUw0in8Oedypz9zMRcsnyeuMRbhPRBEXt4+3ksA1VePlaCQU80pqpgvuIM qed3Eep8KkrJmb+b+uRT8cldJPYJCMVphCuyu+bzGhlyZodtFPMU7k0p0Z2pyztQ/KS8 si6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=S7hvlXFf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id w8-20020a63f508000000b00578d71884b4si2556217pgh.194.2023.09.20.12.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=S7hvlXFf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D3B94825F173; Wed, 20 Sep 2023 04:44:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234484AbjITLoQ (ORCPT + 99 others); Wed, 20 Sep 2023 07:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234427AbjITLoL (ORCPT ); Wed, 20 Sep 2023 07:44:11 -0400 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEC45CF; Wed, 20 Sep 2023 04:44:02 -0700 (PDT) Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2918086AA5; Wed, 20 Sep 2023 13:44:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1695210240; bh=vFPC4EiLCUTFUWbe59gLsrG1YBY4uTMUwAsCR3vkdZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7hvlXFfU15ZfVmeLMVsoMbU+MVAJpc5tWjxrp3jL133TawNM4vXx7jlM0Iv2xN6d 89vral4FAv8FtD3daHX89J8aEEsZD9jRRYhJd89p57ZxI5iEP04JS/DVNBX5XnebYa CFUz5wrBG1qp8oLEcCLExkYSeTEO93jIqgf7sPxU5ku3iTgMNSayRQU/AxyHylL7t8 6bR389mt4B1Ih50+Cmq77UD2RtT/+0/C4J425ft/aFCcaPI0h6AKSeSHeTrW40ukWT eLSsmN/lRleqCpnCbqLN2fs5oAK9tXhaW4rlC8PKY2/FMDyqWh3fvK+7ieMg4wx2BQ slOwZ7U9t8gqA== From: Lukasz Majewski To: Tristram.Ha@microchip.com, Eric Dumazet , Andrew Lunn , davem@davemloft.net, Woojung Huh , Vladimir Oltean , Oleksij Rempel Cc: Florian Fainelli , Jakub Kicinski , Paolo Abeni , UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH v5 net-next 3/5] net: dsa: tag_ksz: Extend ksz9477_xmit() for HSR frame duplication Date: Wed, 20 Sep 2023 13:43:41 +0200 Message-Id: <20230920114343.1979843-4-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230920114343.1979843-1-lukma@denx.de> References: <20230920114343.1979843-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 20 Sep 2023 04:44:21 -0700 (PDT) The KSZ9477 has support for HSR (High-Availability Seamless Redundancy). One of its offloading (i.e. performed in the switch IC hardware) features is to duplicate received frame to both HSR aware switch ports. To achieve this goal - the tail TAG needs to be modified. To be more specific, both ports must be marked as destination (egress) ones. The NETIF_F_HW_HSR_DUP flag indicates that the device supports HSR and assures (in HSR core code) that frame is sent only once from HOST to switch with tail tag indicating both ports. Signed-off-by: Lukasz Majewski --- Changes for v2: - Use ksz_hsr_get_ports() to obtain the bits values corresponding to HSR aware ports Changes for v3: - None Changes for v4: - Iterate over switch ports to find ones supporting HSR. Comparing to v3, where caching of egress tag bits were used, no noticeable performance regression has been observed. Changes for v5: - None --- net/dsa/tag_ksz.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index ea100bd25939..3632e47dea9e 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -293,6 +293,14 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb, if (is_link_local_ether_addr(hdr->h_dest)) val |= KSZ9477_TAIL_TAG_OVERRIDE; + if (dev->features & NETIF_F_HW_HSR_DUP) { + struct net_device *hsr_dev = dp->hsr_dev; + struct dsa_port *other_dp; + + dsa_hsr_foreach_port(other_dp, dp->ds, hsr_dev) + val |= BIT(other_dp->index); + } + *tag = cpu_to_be16(val); return ksz_defer_xmit(dp, skb); -- 2.20.1