From patchwork Sun Jul 30 07:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1438158vqg; Sun, 30 Jul 2023 03:53:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlG3pbo8KUENHUNf7Ya2XnvpZqqYZh31A13Ah7bexeOKZjVSZZhzHpsp9BvmbgHtx5qDNKH9 X-Received: by 2002:a05:6a20:258a:b0:12e:44:a1a6 with SMTP id k10-20020a056a20258a00b0012e0044a1a6mr7748476pzd.11.1690714381017; Sun, 30 Jul 2023 03:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690714381; cv=none; d=google.com; s=arc-20160816; b=UTBo22/RtrHW58hbhxGU+/6AiU7E4T29UnEccSeiUtMoIHBwAgAa4oNHHTxg83Ct7o s2sE08reF6WSZ/YPFoKne3j9c7MyLBsLWBJ8iOrjQ8mrZ6L03Emvr/AkNCjCO/C9CfyE 6Wk8NOb05m2Y8lQhxjKXLepi7ELcYrxcEYo67RZRaXk9LTVr4y7di0llI6kc/7Ian677 VzdbzjSP2UulWjyuHKTlTXTRmHN0DGPcI50NsqmIRn3l81bFZ6G3fspDuZiJ0fbw184f aZHmL/f+qGQKH1tlL967YmrVqa4qkgmif16egice36iqmXHoGWO3F0HqeKCcTGhouBR5 jxlw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MRAG2y5s5jsU57Ef4re95fs4ggBIVFmrGwBiaiHU1mc=; fh=4Kg3l5zis6WIABGLRaUIw3JMQczAglYDh1n+zAW+gtc=; b=KOUXUoyHdJiGJr4sIcYlYcsUjeh3x19HuD3/Eg/g09J+24gIqS1HZT2JmqqvKIhUix JBMX7C8ZtATJxWEDRxgmet5ncmWAzujx5ySmXA3kiY7r6MVdxJ47KulzrHfKyn0lJ/gg Kn9u6MDq7jsFjKcog5TIZ1pyxLrlf9Bmk6FfF3m52rTYEctSXVj6N+PklyS1eoVN/dwi luvH5bXz3zZmufk0o8z+JCbYKvjDaObi1t4Jeis1NiORyjP8KesNYyYlkXcCL5f25MZh pO7EUXGYDSsGOIACjTd/Y3dR4htnPf5g3UTsBYeAIp0ETPatcMH0uRsZHgb8QTuPCysc +GFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=s3ymq2gE; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be15-20020a056a001f0f00b00682ad23bb40si3943744pfb.251.2023.07.30.03.52.47; Sun, 30 Jul 2023 03:53:00 -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=@gmail.com header.s=20221208 header.b=s3ymq2gE; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjG3Jj4 (ORCPT + 99 others); Sun, 30 Jul 2023 05:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjG3Jjy (ORCPT ); Sun, 30 Jul 2023 05:39:54 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF48A1BDA; Sun, 30 Jul 2023 02:39:52 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-307d58b3efbso3159550f8f.0; Sun, 30 Jul 2023 02:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709991; x=1691314791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MRAG2y5s5jsU57Ef4re95fs4ggBIVFmrGwBiaiHU1mc=; b=s3ymq2gEh2sqzFH6eqK2NbhQ/Qz5ntzHr8uZDZKVNQKk3orQ9D+ZJj8CdbFWvcgGFP lcP4q446xVKGTZAYMyFLyr8kUufoq4COJyzqm9jbRxgAP0PntzFddF2mrEaYTvnW1KrS axFJm/Y6NX5gR73g5JJPKTo8gjF1xHw8fg5JLBmfhK5H7Im9UDMgK3DI6loXO9XUEqTQ DBGjGmTH/YqmUvrIhP3O5o9G+ROPVdcAFCCezifE+9h0kuxxxQjwlEWlH43QYCpxfHty U6Y5u+8vdRU2/+eeN8Y9j/DO+rm+685K70BbRzEzqSmFz33otwp03iTbj445QB9ikyoY he8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709991; x=1691314791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MRAG2y5s5jsU57Ef4re95fs4ggBIVFmrGwBiaiHU1mc=; b=AhrJ8qWaH7BUdEUdcnCVl/Q72hkbVPMdxlXXZHWz470jlYUWoARAIecwwm0lqCcb3c aiuEvcI7I7ySLnLIV1APzDlqZp76MNrx6jYoHe5CI5kaqFTDDO7m95TUd7M7PdOAQPIz CWv9KopuJ4QZ6BJfBEPC861oG9OtKOkk3ZtssxUD/lqTIPew/ww5K6PRmVuOe9dMwy64 jS8lOz98VEObOX/ahHJCcZeIvD5yV+E0UbSnrU45sAqfRKJ4gcmopJgvUwtdA1KVtRb0 iY2xkPEiZ3yTxC30JHSsgoY4BtI20W34FkEpcdRkcBvg1qbM8bphmKTr3WmKyuutS6tw fHvQ== X-Gm-Message-State: ABy/qLZM2/QIx+Rnub0dxng2PntZVcQqtmFjXyPWYacNOL2DK4wXTKNB q8v2vXMUwHQzGVRZrQKjgY0= X-Received: by 2002:a5d:4f05:0:b0:317:66c0:9d82 with SMTP id c5-20020a5d4f05000000b0031766c09d82mr4471002wru.64.1690709991021; Sun, 30 Jul 2023 02:39:51 -0700 (PDT) Received: from localhost.localdomain (host-87-11-86-47.retail.telecomitalia.it. [87.11.86.47]) by smtp.googlemail.com with ESMTPSA id h16-20020adffa90000000b0031423a8f4f7sm9574599wrr.56.2023.07.30.02.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:39:50 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Yang Yingliang , "Russell King (Oracle)" , Atin Bainada , Michal Kubiak , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Simon Horman , Florian Fainelli Subject: [net-next PATCH v3 1/5] net: dsa: tag_qca: return early if dev is not found Date: Sun, 30 Jul 2023 09:41:09 +0200 Message-Id: <20230730074113.21889-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772842522679680461 X-GMAIL-MSGID: 1772842522679680461 Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev. To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway. Signed-off-by: Christian Marangi Reviewed-by: Simon Horman Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- changes v2: - Add review tag net/dsa/tag_qca.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index e757c8de06f1..e5ff7c34e577 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -75,10 +75,6 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) return NULL; } - /* Remove QCA tag and recalculate checksum */ - skb_pull_rcsum(skb, QCA_HDR_LEN); - dsa_strip_etype_header(skb, QCA_HDR_LEN); - /* Get source port information */ port = FIELD_GET(QCA_HDR_RECV_SOURCE_PORT, hdr); @@ -86,6 +82,10 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) if (!skb->dev) return NULL; + /* Remove QCA tag and recalculate checksum */ + skb_pull_rcsum(skb, QCA_HDR_LEN); + dsa_strip_etype_header(skb, QCA_HDR_LEN); + return skb; } From patchwork Sun Jul 30 07:41:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1442079vqg; Sun, 30 Jul 2023 04:04:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlEglzI0n0NeDApGDVDsrTpgIbpfPWoHKGg8YO+Go1YzwNova9Boi2H+eu8mg4pYkWErUShc X-Received: by 2002:a5d:5948:0:b0:311:1b8a:b70e with SMTP id e8-20020a5d5948000000b003111b8ab70emr5969282wri.66.1690715070541; Sun, 30 Jul 2023 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690715070; cv=none; d=google.com; s=arc-20160816; b=rop+lIAvSh/xBlIYf5DPmu6zS56a9wqCABVlE4KeDZ1wZ9peikqrG4NYCe/QdGPOqe tnts5+LL8HARMoT8IXEeyE/ilD5KZMP2pthqMrnkFfMy/W6dbkg6SRT9e8w1OZM+C43z iyFv6vtKwsnl6CAGPTdPF4XNHtMf4jLj+QHzCunRFFphvawCEU3DeXevKXF1f44KBRLB tw5jkvMUhn40DpRhjPfDAxrhFFJDRx/tihWv+/dN7w1u+Us68jJ9qtEJL7LqHOXt1LyM Km0mZ0RH8+z21FTTOGT+C2SEiAqijZg+q+LekpifcavgC7++RRBheGJNGtxP7j5TDfHb F24Q== 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=xVvb7llve9pJsIAfqXRB6HIfyDuylIO0ZQ0la81l44g=; fh=ea7CumSSnJaAY48iIZdqPfSxI8sbCL+f5t7srqFiIwA=; b=mVEqVfF0KvXKNMB6laqml8HhUd2ZEt/w19YmAHH37UWRhE3b+1ueLRfm8atRZ8SKKS CLlt2jn0VRjG5ppLgp045Pnd1v5hpMuTYS+E75YSubbmjv4vDimzw6KLz7oSyNKzdfn5 iyp9aEm86Gk4ak0J7sPPr4sNlhrmGIR+FcLnUEgbp7JEiLmP1//mP+9H+OnjGt5t6oTq LAGz1V3/X33PSKcZqEbwsVynA3wPlNrjDruQqlQxu/un0/H78Zri8C43UueOjEGUy32V uT89otzSMig6+gfzcvOdqEemksZI0Rh2w7C2ySxJx/c+2YRgKUOQpIwEjxaw8jf1ifUk EaVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BlMKD5Ce; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020aa7dad1000000b005218cf5ed80si5318573eds.439.2023.07.30.04.04.06; Sun, 30 Jul 2023 04:04:30 -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=@gmail.com header.s=20221208 header.b=BlMKD5Ce; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbjG3Jj7 (ORCPT + 99 others); Sun, 30 Jul 2023 05:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjG3Jjz (ORCPT ); Sun, 30 Jul 2023 05:39:55 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817701BDC; Sun, 30 Jul 2023 02:39:54 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31783d02093so3157121f8f.0; Sun, 30 Jul 2023 02:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709993; x=1691314793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xVvb7llve9pJsIAfqXRB6HIfyDuylIO0ZQ0la81l44g=; b=BlMKD5Cew4zlPpXl/ocIrOS5kdJwUJWm+yxbb+4l2Cb4UUmmRx1VkU+fBU+qNm6oIw CocroWdcv8AOYZy5rMG9w6dcyl6xYwwjdxghopNf5f/oBnWdE8xNFGCx8oQ3spxtQPr1 ouDwWQHdUQEHlRtpvsLs0eLHr8of5wfbF1dhoojn8n+dxLX1Chd2CsPzqaoMtlMGAuFA ymt67C8pJsyShJQ8tpP1ZHUmLfMuSSVN5HTiqGn198I4XFpYpMTqC2lgAGzLxNq3KdCg GtT4gtm9/SLPKjZJAX41TLszWyP9RTatVDNmVGFfUNk9+PXxGOMnUFNdxuIdsXlW00Bv ERqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709993; x=1691314793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xVvb7llve9pJsIAfqXRB6HIfyDuylIO0ZQ0la81l44g=; b=CzCXfhelWWybs7wlMoopFr1QQyCJ6duSjAihyWC12Oob7Wp4+CaptOiDCEeTFcHY/m rum/Otnfkrgq5G/JTYjWLqQSGYabPogJNv8b3r0QnMii+iR4LQr+KCyxY8gVJ6fnaY9N qX7qavt9LpJX7Sn8pOhzGHuDH1r3MNRcW5CbK68VdTn3QMxbbyZEZ00scecpIl4ysdaw r0Hqr22raHqDGNUq79OL2x7anEb5nY/RCtWe1/rS150Kf+/w8woBtRbtypkQCWoEnpg5 OM0UcYPRk5u35ua722V2DPBdOSDQRsAyMjHzijdXb8Cy7I4pEbO8LOHX01itq/8/YkZJ H5PQ== X-Gm-Message-State: ABy/qLZj+Afz5ZTlPRwqPtaAY2PCs+uC1C+v8kwwm33cfHcsj3tfSPf/ Imb/XN8leymM8rbEBMjIV94= X-Received: by 2002:a5d:548b:0:b0:316:fc86:28ae with SMTP id h11-20020a5d548b000000b00316fc8628aemr6491695wrv.15.1690709992651; Sun, 30 Jul 2023 02:39:52 -0700 (PDT) Received: from localhost.localdomain (host-87-11-86-47.retail.telecomitalia.it. [87.11.86.47]) by smtp.googlemail.com with ESMTPSA id h16-20020adffa90000000b0031423a8f4f7sm9574599wrr.56.2023.07.30.02.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:39:52 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Yang Yingliang , "Russell King (Oracle)" , Atin Bainada , Michal Kubiak , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Florian Fainelli Subject: [net-next PATCH v3 2/5] net: dsa: qca8k: make learning configurable and keep off if standalone Date: Sun, 30 Jul 2023 09:41:10 +0200 Message-Id: <20230730074113.21889-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230730074113.21889-1-ansuelsmth@gmail.com> References: <20230730074113.21889-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772843245969290386 X-GMAIL-MSGID: 1772843245969290386 Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via ds->ops->port_bridge_flags(). Currently this is not the case for qca8k where learning is enabled unconditionally in qca8k_setup for every user port. Handle ports configured in standalone mode by making the learning configurable and not enabling it by default. Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode. Signed-off-by: Christian Marangi Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- changes v2: - Add review tag - Change qca8k_port_bridge_flags to be more explicit with flag handling as suggested by Vladimir drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++-- drivers/net/dsa/qca/qca8k-common.c | 48 ++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 6 ++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index ae088a4df794..31552853fdd4 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -1870,9 +1870,8 @@ qca8k_setup(struct dsa_switch *ds) if (ret) return ret; - /* Enable ARP Auto-learning by default */ - ret = regmap_set_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(i), - QCA8K_PORT_LOOKUP_LEARN); + ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(i), + QCA8K_PORT_LOOKUP_LEARN); if (ret) return ret; @@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_change_mtu = qca8k_port_change_mtu, .port_max_mtu = qca8k_port_max_mtu, .port_stp_state_set = qca8k_port_stp_state_set, + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, + .port_bridge_flags = qca8k_port_bridge_flags, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, .port_fast_age = qca8k_port_fast_age, diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c index 13b8452ce5b2..fce04ce12cf9 100644 --- a/drivers/net/dsa/qca/qca8k-common.c +++ b/drivers/net/dsa/qca/qca8k-common.c @@ -565,9 +565,26 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, return 0; } +static int qca8k_port_configure_learning(struct dsa_switch *ds, int port, + bool learning) +{ + struct qca8k_priv *priv = ds->priv; + + if (learning) + return regmap_set_bits(priv->regmap, + QCA8K_PORT_LOOKUP_CTRL(port), + QCA8K_PORT_LOOKUP_LEARN); + else + return regmap_clear_bits(priv->regmap, + QCA8K_PORT_LOOKUP_CTRL(port), + QCA8K_PORT_LOOKUP_LEARN); +} + void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) { + struct dsa_port *dp = dsa_to_port(ds, port); struct qca8k_priv *priv = ds->priv; + bool learning = false; u32 stp_state; switch (state) { @@ -582,8 +599,11 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) break; case BR_STATE_LEARNING: stp_state = QCA8K_PORT_LOOKUP_STATE_LEARNING; + learning = dp->learning; break; case BR_STATE_FORWARDING: + learning = dp->learning; + fallthrough; default: stp_state = QCA8K_PORT_LOOKUP_STATE_FORWARD; break; @@ -591,6 +611,34 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port), QCA8K_PORT_LOOKUP_STATE_MASK, stp_state); + + qca8k_port_configure_learning(ds, port, learning); +} + +int qca8k_port_pre_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + if (flags.mask & ~BR_LEARNING) + return -EINVAL; + + return 0; +} + +int qca8k_port_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + int ret; + + if (flags.mask & BR_LEARNING) { + ret = qca8k_port_configure_learning(ds, port, + flags.val & BR_LEARNING); + if (ret) + return ret; + } + + return 0; } int qca8k_port_bridge_join(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h index c5cc8a172d65..8f88b7db384d 100644 --- a/drivers/net/dsa/qca/qca8k.h +++ b/drivers/net/dsa/qca/qca8k.h @@ -522,6 +522,12 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e); /* Common bridge function */ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state); +int qca8k_port_pre_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack); +int qca8k_port_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack); int qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, bool *tx_fwd_offload, From patchwork Sun Jul 30 07:41:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1508698vqg; Sun, 30 Jul 2023 06:45:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmUCWAas5THCvbvMIR1t/JRaQQDW9/sSm3eY+cDBB4OnDO8ZoFG0GqC1NFBhx1JIbhxHZn X-Received: by 2002:a05:6a00:2d23:b0:67f:d4e2:3dd7 with SMTP id fa35-20020a056a002d2300b0067fd4e23dd7mr8388166pfb.21.1690724754502; Sun, 30 Jul 2023 06:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690724754; cv=none; d=google.com; s=arc-20160816; b=I0aQ016S0G7PV+i2iWIWZesLCaBwjEvQpAsSYuB6RyuKcvPoPD97sFdaf1/haJFoS/ 0D7bZVqLJK+tY77A+Zl9HYwq6pM4RIi8Jjsn+yJh3kiC8w0Z+8WtFq5UmlVxXmcy00wM PQD1z99NLPIUURNLfDkclUCGkx/YtDdcz0YZ6KWmFj8aPrDZu6mOwM+8l3k7gkPCdLXt AwQJYP4d4+S6gbdbSnwo/ioOHNSDiNi/yK3PuC3ZKZOLqBfdo1C7UHhcBuYrqPgz9RJZ Bh10PHDUmxTCcz7KH5ZlFg8/wXzetqXx4Ee8wEGuEGl160ozoSU+sZLUL3fCHR21lEil +5+Q== 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=f0o7VzxAYYYRY+ih+jmVhcGfTwDx92myBTFzgRxJi4g=; fh=4Kg3l5zis6WIABGLRaUIw3JMQczAglYDh1n+zAW+gtc=; b=OAbVg+fWED6GSqcKQ9FpDaynjLTGBwfswcX5JiZ/KRLKfrdDKU6FsxsWppAYTS806+ mK82m9tLiFbJOPILs8rr9tRDYevGhOwkZ5I1E9j9gXaFyBsyndvnre4R2Hps7yJYEyPt 5VbSb2y0BqdqNzVJKSp9O2LIf3Cm0o4c9M+rHEMiNUIptyY/CvqHX1i+70v96Dvzpx/Y OwljtHnalZgftrBhLLx0DdRJfNlTYRFbJaBDt+Cd4Z8aUGV/XxmMQwOOq4mwfDAkznSj 68b9HfYIi1e/rD2o9khD0GxTXAbaXU/acoxBox6Oc0LE4d2J0bdgaTqv0dPj/WnotB3/ aCsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eDCyRE4P; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br7-20020a056a00440700b006872a5420ecsi1404393pfb.81.2023.07.30.06.45.40; Sun, 30 Jul 2023 06:45:54 -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=@gmail.com header.s=20221208 header.b=eDCyRE4P; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229853AbjG3JkD (ORCPT + 99 others); Sun, 30 Jul 2023 05:40:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjG3Jj5 (ORCPT ); Sun, 30 Jul 2023 05:39:57 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F27E1BDA; Sun, 30 Jul 2023 02:39:56 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-317715ec496so3845921f8f.3; Sun, 30 Jul 2023 02:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709994; x=1691314794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f0o7VzxAYYYRY+ih+jmVhcGfTwDx92myBTFzgRxJi4g=; b=eDCyRE4PUu0oXJ4JpVM96uLRV/9x/dZihtzq8iNCND0fPYQ7XiGgVSsUwPvayG7ORH M9gHKOw62H/RVqC3WhXKNb3CP1ErlLFJc9vgv7s0WiKz1VQlN0B738hwQT3MW2idV4h/ tHXHDmT2dCpQu8WFQV9M4nw3jaUxHAfMs8ViaCwwxvI0TNu8eDuyfwGYL34dJiir7wDF xRsZ9fzVsqk3DSRuVVFoxzwwDYzMlkjNKAR3Z1ZZ2oEQm38tAnlApt/9mJNnQfgtHs/I MWXSVoIcF/rzOex8A1LpqamC2yzD0ajLWR02k49C7BX3aD2FbadZztHWYy5wV5G0zROl ZmTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709994; x=1691314794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f0o7VzxAYYYRY+ih+jmVhcGfTwDx92myBTFzgRxJi4g=; b=ZrwwsKLtYoVddDuN7Crq2oHUCbkWuGKXlrShJ5rKTzzZ09KFCONXP1j90+Z1zmKeMy uPT2MdcfNEvm0xKZH6k5oIrpzMwUV49NL5vu/06lYxP05svKSn3WO7cpgP0hnepVQCR8 AawBuqlb2URHp1OaJI6EMQqm5cKbCv69L1LwFaNy+l/I01CzqQI9P5aDDdOYfc7nWp+g XTmJ1QI7cs3erEvJl1ahzbOP89VVXmUFyjDQ+Lx0IppmzbH/CkH7YPqRQz3ImXFOgj5m X14xV1JMu9ZbWq78dINEcAXvo83J6kpuqiSBD4pPz8NSxYbX10Uv31DGLwHmLHB64C0E EtcA== X-Gm-Message-State: ABy/qLbIdzFqqUPdbyYC5IgXrKCzbl0qUArpXHrG17ACcU9O5Q4KWYA4 Bxs4HxP+nglX94kSY5ZEuY4= X-Received: by 2002:a5d:4746:0:b0:314:2e77:afec with SMTP id o6-20020a5d4746000000b003142e77afecmr6107859wrs.57.1690709994376; Sun, 30 Jul 2023 02:39:54 -0700 (PDT) Received: from localhost.localdomain (host-87-11-86-47.retail.telecomitalia.it. [87.11.86.47]) by smtp.googlemail.com with ESMTPSA id h16-20020adffa90000000b0031423a8f4f7sm9574599wrr.56.2023.07.30.02.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:39:54 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Yang Yingliang , "Russell King (Oracle)" , Atin Bainada , Michal Kubiak , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Simon Horman , Florian Fainelli Subject: [net-next PATCH v3 3/5] net: dsa: qca8k: limit user ports access to the first CPU port on setup Date: Sun, 30 Jul 2023 09:41:11 +0200 Message-Id: <20230730074113.21889-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230730074113.21889-1-ansuelsmth@gmail.com> References: <20230730074113.21889-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772853400264601341 X-GMAIL-MSGID: 1772853400264601341 In preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port. This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports. Secondary CPU port LOOKUP MEMBER mask will be setup later when port_change_master will be implemented. Signed-off-by: Christian Marangi Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- changes v2: - Add review tag drivers/net/dsa/qca/qca8k-8xxx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 31552853fdd4..6286a64a2fe3 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -1850,18 +1850,16 @@ qca8k_setup(struct dsa_switch *ds) if (ret) return ret; + /* CPU port gets connected to all user ports of the switch */ + ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(cpu_port), + QCA8K_PORT_LOOKUP_MEMBER, dsa_user_ports(ds)); + if (ret) + return ret; + /* Setup connection between CPU port & user ports * Configure specific switch configuration for ports */ for (i = 0; i < QCA8K_NUM_PORTS; i++) { - /* CPU port gets connected to all user ports of the switch */ - if (dsa_is_cpu_port(ds, i)) { - ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i), - QCA8K_PORT_LOOKUP_MEMBER, dsa_user_ports(ds)); - if (ret) - return ret; - } - /* Individual user ports get connected to CPU port only */ if (dsa_is_user_port(ds, i)) { ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i), From patchwork Sun Jul 30 07:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1446515vqg; Sun, 30 Jul 2023 04:16:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrMAyciQkeMmXiNic79y2FPQKZzqxFSB/52UB5ShM9cSmvUI/ly6lRA91PWt624fG1Vtj3 X-Received: by 2002:a05:6a20:2455:b0:137:a3c9:aa99 with SMTP id t21-20020a056a20245500b00137a3c9aa99mr8004739pzc.30.1690715775306; Sun, 30 Jul 2023 04:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690715775; cv=none; d=google.com; s=arc-20160816; b=H48y6gbiRKuM2HXaoU5ruJuPdfcFry8TdOaXyHxUTOjGpCK6D7zywlziga27RdG4D+ nwOP1n/eJ42Kutqrjl1Rcd0pA8/E9b1P/NpW4Ne726r9lY9PWnYZ3JEp2ztKFaOXX7vG TfYcG7/z/bb7cLnv+2cUXTz9mr/lN9DdlxeKTF8SHZ7zpdFcGVhVnSFMmud753ZnxbdW yZpVJDhdJPn0ghDnqgOumhmwzWn6PGY4HFyj+zjpAbJTzdJ21ys/Gz+NA6sO2F5XLEnj rX5X4pg8AHA2jHWPU5F5bv6+8/egHlPpH7cJuiQHlHkr2ClHyR40GvXT4MK2jvZo1nhW 7pIA== 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:to:from :dkim-signature; bh=DfBFXLrOBDfsMdVxv/cKnvMiArytdOBrw7zZET7q5qM=; fh=7sOYHgu0pN5zSVFumfFdjBeJQkcX72mmi36ylTBtv5k=; b=sUipWHXrcJgt8dsz5SVSrsQFoyGCdDEQ5rQxmmMUwkYveLa7UOGJoOSM9FC1MY0lZS l6QF2Q4PtDjkQqbNHPGjz9yKgsFDGk0gFUCYVfOJfTapNr1lNhgV22y43uVATJddcyGL CYCRD5CK1vhl2wAlT3PHKL3iKzW7RihXkqZY0MpyX2P/YVGM4QyJ+ObEv0H18UvbCUCo c20hoOpb4jM1c+3owDVBtKf6zS4UeLO21L3Q50JDcXKkIGMfLNWWrldTPjMnCWWBnKBs Y1dnSJlPQiKAulscRWQ0BpFO+MAAZ45ihnqg4BIOQhJimWp0kLUarIQsMqqZWZ8LcL2t ef3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=C7czUkMx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p19-20020a056a000b5300b006871bf45857si2430744pfo.401.2023.07.30.04.16.02; Sun, 30 Jul 2023 04:16:15 -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=@gmail.com header.s=20221208 header.b=C7czUkMx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbjG3JkG (ORCPT + 99 others); Sun, 30 Jul 2023 05:40:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjG3Jj7 (ORCPT ); Sun, 30 Jul 2023 05:39:59 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D4791BDF; Sun, 30 Jul 2023 02:39:57 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbc77e76abso33243725e9.1; Sun, 30 Jul 2023 02:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709996; x=1691314796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DfBFXLrOBDfsMdVxv/cKnvMiArytdOBrw7zZET7q5qM=; b=C7czUkMxxa8NUewFli3hgwg9AMhey5n+tjTIhq9QOmXrA1EB0FOi1uG/AoMutOvUja oK3aAnKLZnfKt9zZkA7FHSFmw1a+rErLpA4qROO9ib4CXnMhF1GLu1346+W39QRaMAe5 oMFeXKCGGbSmBE2RWrHlEtt1xCXHIZ7nv5EFFQg6R7aiRmKFE6u+q6JN/qm3LDqcSH9k sPDUPVTtngAfi5vEpkPCnkc1ML06Ll9/xYe097rPvdMbf7nUv7CY3vCBgSAIn6iiOpP6 iYKpGiCvTbo8feQEsyvecw1i6kIDCx5FH60QfRpKTUaHZmfvEye0XjomO/wD8Uz+KRCm 0z0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709996; x=1691314796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DfBFXLrOBDfsMdVxv/cKnvMiArytdOBrw7zZET7q5qM=; b=N84Q7OL08MuSm+5PKdzYOIQCDTOiQ5qyBtm2CmNYSyP1oaIiJeQp4fCY1mprGwpD2b d9OukV6zVpvoNhmOG6xfY4/HOoR2CJxdxKlNWsGlsBX42Q51IK1ghlusNmcz6MqO0LuW odd+HGKCWreU3AMdiRAvU6Xx2N0Vi6u83rCs/0gBWhW5hQM2qFBzXG+a3O1+p6oMEEjE yc54+Ko1wkW/wwdZUCHJI1f1UNvbhtgJDsvFpgNcKDS9nWfBelZSDuWOj9gCuRlQidkT nCx1VFx579/OvO9QFLngBYPbcwSGwp1VYEZDEGUNjIi3jY/JuK6qhO9qskQqh4gXd9u2 Bz1A== X-Gm-Message-State: ABy/qLb74FjJ4k9T+6NLBGw25PRUYYJzhKg3QePKBVbS8Mp8lba7jkwe w01DAZXsCQQUI+ivKKcK2h8= X-Received: by 2002:a7b:c453:0:b0:3fb:f926:4937 with SMTP id l19-20020a7bc453000000b003fbf9264937mr4280394wmi.31.1690709995979; Sun, 30 Jul 2023 02:39:55 -0700 (PDT) Received: from localhost.localdomain (host-87-11-86-47.retail.telecomitalia.it. [87.11.86.47]) by smtp.googlemail.com with ESMTPSA id h16-20020adffa90000000b0031423a8f4f7sm9574599wrr.56.2023.07.30.02.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:39:55 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Yang Yingliang , "Russell King (Oracle)" , Atin Bainada , Michal Kubiak , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v3 4/5] net: dsa: qca8k: move qca8xxx hol fixup to separate function Date: Sun, 30 Jul 2023 09:41:12 +0200 Message-Id: <20230730074113.21889-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230730074113.21889-1-ansuelsmth@gmail.com> References: <20230730074113.21889-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772843984579977122 X-GMAIL-MSGID: 1772843984579977122 Move qca8xxx hol fixup to separate function to tidy things up and to permit using a more efficent loop in future patch. Signed-off-by: Christian Marangi Reviewed-by: Florian Fainelli --- drivers/net/dsa/qca/qca8k-8xxx.c | 78 +++++++++++++++++--------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 6286a64a2fe3..81c6fab0a01b 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -1756,6 +1756,46 @@ static int qca8k_connect_tag_protocol(struct dsa_switch *ds, return 0; } +static void qca8k_setup_hol_fixup(struct qca8k_priv *priv, int port) +{ + u32 mask; + + switch (port) { + /* The 2 CPU port and port 5 requires some different + * priority than any other ports. + */ + case 0: + case 5: + case 6: + mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) | + QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) | + QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x4) | + QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x4) | + QCA8K_PORT_HOL_CTRL0_EG_PRI4(0x6) | + QCA8K_PORT_HOL_CTRL0_EG_PRI5(0x8) | + QCA8K_PORT_HOL_CTRL0_EG_PORT(0x1e); + break; + default: + mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) | + QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) | + QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x6) | + QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x8) | + QCA8K_PORT_HOL_CTRL0_EG_PORT(0x19); + } + regmap_write(priv->regmap, QCA8K_REG_PORT_HOL_CTRL0(port), mask); + + mask = QCA8K_PORT_HOL_CTRL1_ING(0x6) | + QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | + QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | + QCA8K_PORT_HOL_CTRL1_WRED_EN; + regmap_update_bits(priv->regmap, QCA8K_REG_PORT_HOL_CTRL1(port), + QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK | + QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | + QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | + QCA8K_PORT_HOL_CTRL1_WRED_EN, + mask); +} + static int qca8k_setup(struct dsa_switch *ds) { @@ -1895,42 +1935,8 @@ qca8k_setup(struct dsa_switch *ds) * missing settings to improve switch stability under load condition. * This problem is limited to qca8337 and other qca8k switch are not affected. */ - if (priv->switch_id == QCA8K_ID_QCA8337) { - switch (i) { - /* The 2 CPU port and port 5 requires some different - * priority than any other ports. - */ - case 0: - case 5: - case 6: - mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) | - QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) | - QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x4) | - QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x4) | - QCA8K_PORT_HOL_CTRL0_EG_PRI4(0x6) | - QCA8K_PORT_HOL_CTRL0_EG_PRI5(0x8) | - QCA8K_PORT_HOL_CTRL0_EG_PORT(0x1e); - break; - default: - mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) | - QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) | - QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x6) | - QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x8) | - QCA8K_PORT_HOL_CTRL0_EG_PORT(0x19); - } - qca8k_write(priv, QCA8K_REG_PORT_HOL_CTRL0(i), mask); - - mask = QCA8K_PORT_HOL_CTRL1_ING(0x6) | - QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | - QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | - QCA8K_PORT_HOL_CTRL1_WRED_EN; - qca8k_rmw(priv, QCA8K_REG_PORT_HOL_CTRL1(i), - QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK | - QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | - QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | - QCA8K_PORT_HOL_CTRL1_WRED_EN, - mask); - } + if (priv->switch_id == QCA8K_ID_QCA8337) + qca8k_setup_hol_fixup(priv, i); } /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */ From patchwork Sun Jul 30 07:41:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1503493vqg; Sun, 30 Jul 2023 06:32:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlE1C0I1FTZwV6zgXKp6D60rvvlgdYMq//fgTlSPvWRBs9RY2O+2x4ZfxRM1yvS9cjAkAtJJ X-Received: by 2002:a17:906:3f1e:b0:99b:574f:d201 with SMTP id c30-20020a1709063f1e00b0099b574fd201mr4779290ejj.40.1690723945648; Sun, 30 Jul 2023 06:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690723945; cv=none; d=google.com; s=arc-20160816; b=sme0H+bTj2CA3bV5MEx9uptJM0dEGX+z875NUeH3j7aneSzCrtqJXrg9rrJjwSf/8X 2xVlNkxsiRgCIJa68/Jdq2VObCOLZMuuxmprJMfqxwkE+pk5hw06tLZlCGZ8JS/+vuZH IX+4SkwqLX3G+vkeCxHjz/KwBPH20DUkYketuonXesxADikY7NkFPdrEbg//xFUQLDJU Wq2kvtDzFVjXAZxhtjUR45MKocCHVX5u+TutNWuxVdt0EBIQPl+jFXrLmski0WXIiyD4 5BO1Uh5KzEllkqUSypPSl6VJons8SU/W2HCGHG0By/QDfOK1tGY7DqfrJJUJl0hX57VZ Pz7Q== 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:to:from :dkim-signature; bh=5Rk7t1E5DhGQ1pORnpZFlzRE4LWcZ9ydkNYKXYDX32o=; fh=7sOYHgu0pN5zSVFumfFdjBeJQkcX72mmi36ylTBtv5k=; b=mP33BYlT7iv141J9bwAD4nWG4SpJQDRWkbVg8OFx6MLCk38G4dWjZsZTezRR0sVc5f sCc1eFNrifkalUebfEwsSeg8ilLskt3mvXX0JKMuC8urrtN48m7pAXqhqLd1INNp5ErD pQcTh63sMoVu3stq0HhfUeO8ARpvKaD9kHSMtRhLOuqenOVnCgfZvpXkI0f72q1llxho 9tmhmDd2wv7DY54iMRRwFKzn3LJ8sZUPWBPcyjFrmRwewFYCaefcg/qGxWqF4/Eu8UmN 7k9miPWvt7DCcRyJZDFkPbza+iGUtzoVPYJrAwCYJnXurbbNFQhgwboWtRxSH+UcLaVs LMUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DU50+8ij; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w24-20020a17090652d800b0099845f657a8si1389710ejn.616.2023.07.30.06.32.01; Sun, 30 Jul 2023 06:32:25 -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=@gmail.com header.s=20221208 header.b=DU50+8ij; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjG3JkJ (ORCPT + 99 others); Sun, 30 Jul 2023 05:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjG3JkA (ORCPT ); Sun, 30 Jul 2023 05:40:00 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E161BE5; Sun, 30 Jul 2023 02:39:59 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc54cab6fso33518065e9.0; Sun, 30 Jul 2023 02:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709997; x=1691314797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5Rk7t1E5DhGQ1pORnpZFlzRE4LWcZ9ydkNYKXYDX32o=; b=DU50+8ijaCum0qT6GV+BHzU8I6sQEAdqXZmT1iI7+9pCysXpKGr/gI20kvpbGLhDpc +yRHN+5wZLbl3fK76BtNqXxEJdaVDgd5W/I5vtvJ/1i2jqrRIaVUm6JZ6jsZiyeCTzjp SX6/3j5o0kxw9TyIGF/N0zqTdsKdCWi3pQPcCwOVpui/TAy26aKQwbIscdY5BOnVkGi3 H2BvctKPYOqtonmttjuqY8zWr6916377V53pOhFEYhxgBb8bFeXHK+rsDGPG0CvTBop0 jAI4GwkPkjqEEalLCw3EHaesWUGOqzxStjBNOS8ZhSYmKTINdZsoFoXBEuITq/ioHgDi Coog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709997; x=1691314797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Rk7t1E5DhGQ1pORnpZFlzRE4LWcZ9ydkNYKXYDX32o=; b=Tzni7VmSjYNtjTvKhRFeCPQTynlhHbmQPGNbRwz+UNePXSkigV2tbobD1Vvt8ghJSk bvk3J+mwUOtsN8Ol0CxVPqYLMkADE0P7zECpuyqDvNo+qEVw6VEIYtI5j+tN6vOJjdWf oqFMctpZuUwK3ofpSitPYOSTFo75AfWQCjvwsHzR3VWtQDmitkSGDO5KQJMWgf98dMAP MMc8wwF8RsDTc3K01BQlHGdZDPMCz+PK+IvQCTP73TAKY78jqT1UsNuyzwmJryDM2JDZ oWnD/jjXmb+XuYEN6yllOqf5UBuXJv9nEW3tjlM/LguLuRLIlc9bv8h4iFB16eRWZPYT KnOw== X-Gm-Message-State: ABy/qLYvFtW5dCMu8tf43IfLzFRsnOY3ZHf9MQ7n2/NivChm1yHh26Mh Np5q9NSp7HcAeSP4OMXqSlI= X-Received: by 2002:adf:fc10:0:b0:317:6459:e3ae with SMTP id i16-20020adffc10000000b003176459e3aemr4560322wrr.68.1690709997542; Sun, 30 Jul 2023 02:39:57 -0700 (PDT) Received: from localhost.localdomain (host-87-11-86-47.retail.telecomitalia.it. [87.11.86.47]) by smtp.googlemail.com with ESMTPSA id h16-20020adffa90000000b0031423a8f4f7sm9574599wrr.56.2023.07.30.02.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:39:57 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Yang Yingliang , "Russell King (Oracle)" , Atin Bainada , Michal Kubiak , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v3 5/5] net: dsa: qca8k: use dsa_for_each macro instead of for loop Date: Sun, 30 Jul 2023 09:41:13 +0200 Message-Id: <20230730074113.21889-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230730074113.21889-1-ansuelsmth@gmail.com> References: <20230730074113.21889-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772852552145399465 X-GMAIL-MSGID: 1772852552145399465 Convert for loop to dsa_for_each macro to save some redundant write on unconnected/unused port and tidy things up. Signed-off-by: Christian Marangi Reviewed-by: Florian Fainelli --- changes v3: - Fix compilation error with unfinished patch in v2 drivers/net/dsa/qca/qca8k-8xxx.c | 107 ++++++++++++++++--------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 81c6fab0a01b..f8a573679101 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -1800,7 +1800,8 @@ static int qca8k_setup(struct dsa_switch *ds) { struct qca8k_priv *priv = ds->priv; - int cpu_port, ret, i; + struct dsa_port *dp; + int cpu_port, ret; u32 mask; cpu_port = qca8k_find_cpu_port(ds); @@ -1855,27 +1856,27 @@ qca8k_setup(struct dsa_switch *ds) dev_warn(priv->dev, "mib init failed"); /* Initial setup of all ports */ - for (i = 0; i < QCA8K_NUM_PORTS; i++) { + dsa_switch_for_each_port(dp, ds) { /* Disable forwarding by default on all ports */ - ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i), + ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(dp->index), QCA8K_PORT_LOOKUP_MEMBER, 0); if (ret) return ret; + } - /* Enable QCA header mode on all cpu ports */ - if (dsa_is_cpu_port(ds, i)) { - ret = qca8k_write(priv, QCA8K_REG_PORT_HDR_CTRL(i), - FIELD_PREP(QCA8K_PORT_HDR_CTRL_TX_MASK, QCA8K_PORT_HDR_CTRL_ALL) | - FIELD_PREP(QCA8K_PORT_HDR_CTRL_RX_MASK, QCA8K_PORT_HDR_CTRL_ALL)); - if (ret) { - dev_err(priv->dev, "failed enabling QCA header mode"); - return ret; - } + /* Disable MAC by default on all user ports */ + dsa_switch_for_each_user_port(dp, ds) + qca8k_port_set_status(priv, dp->index, 0); + + /* Enable QCA header mode on all cpu ports */ + dsa_switch_for_each_cpu_port(dp, ds) { + ret = qca8k_write(priv, QCA8K_REG_PORT_HDR_CTRL(dp->index), + FIELD_PREP(QCA8K_PORT_HDR_CTRL_TX_MASK, QCA8K_PORT_HDR_CTRL_ALL) | + FIELD_PREP(QCA8K_PORT_HDR_CTRL_RX_MASK, QCA8K_PORT_HDR_CTRL_ALL)); + if (ret) { + dev_err(priv->dev, "failed enabling QCA header mode on port %d", dp->index); + return ret; } - - /* Disable MAC by default on all user ports */ - if (dsa_is_user_port(ds, i)) - qca8k_port_set_status(priv, i, 0); } /* Forward all unknown frames to CPU port for Linux processing @@ -1897,48 +1898,48 @@ qca8k_setup(struct dsa_switch *ds) return ret; /* Setup connection between CPU port & user ports - * Configure specific switch configuration for ports + * Individual user ports get connected to CPU port only */ - for (i = 0; i < QCA8K_NUM_PORTS; i++) { - /* Individual user ports get connected to CPU port only */ - if (dsa_is_user_port(ds, i)) { - ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i), - QCA8K_PORT_LOOKUP_MEMBER, - BIT(cpu_port)); - if (ret) - return ret; - - ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(i), - QCA8K_PORT_LOOKUP_LEARN); - if (ret) - return ret; - - /* For port based vlans to work we need to set the - * default egress vid - */ - ret = qca8k_rmw(priv, QCA8K_EGRESS_VLAN(i), - QCA8K_EGREES_VLAN_PORT_MASK(i), - QCA8K_EGREES_VLAN_PORT(i, QCA8K_PORT_VID_DEF)); - if (ret) - return ret; - - ret = qca8k_write(priv, QCA8K_REG_PORT_VLAN_CTRL0(i), - QCA8K_PORT_VLAN_CVID(QCA8K_PORT_VID_DEF) | - QCA8K_PORT_VLAN_SVID(QCA8K_PORT_VID_DEF)); - if (ret) - return ret; - } + dsa_switch_for_each_user_port(dp, ds) { + u8 port = dp->index; + + ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port), + QCA8K_PORT_LOOKUP_MEMBER, + BIT(cpu_port)); + if (ret) + return ret; + + ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port), + QCA8K_PORT_LOOKUP_LEARN); + if (ret) + return ret; - /* The port 5 of the qca8337 have some problem in flood condition. The - * original legacy driver had some specific buffer and priority settings - * for the different port suggested by the QCA switch team. Add this - * missing settings to improve switch stability under load condition. - * This problem is limited to qca8337 and other qca8k switch are not affected. + /* For port based vlans to work we need to set the + * default egress vid */ - if (priv->switch_id == QCA8K_ID_QCA8337) - qca8k_setup_hol_fixup(priv, i); + ret = qca8k_rmw(priv, QCA8K_EGRESS_VLAN(port), + QCA8K_EGREES_VLAN_PORT_MASK(port), + QCA8K_EGREES_VLAN_PORT(port, QCA8K_PORT_VID_DEF)); + if (ret) + return ret; + + ret = qca8k_write(priv, QCA8K_REG_PORT_VLAN_CTRL0(port), + QCA8K_PORT_VLAN_CVID(QCA8K_PORT_VID_DEF) | + QCA8K_PORT_VLAN_SVID(QCA8K_PORT_VID_DEF)); + if (ret) + return ret; } + /* The port 5 of the qca8337 have some problem in flood condition. The + * original legacy driver had some specific buffer and priority settings + * for the different port suggested by the QCA switch team. Add this + * missing settings to improve switch stability under load condition. + * This problem is limited to qca8337 and other qca8k switch are not affected. + */ + if (priv->switch_id == QCA8K_ID_QCA8337) + dsa_switch_for_each_available_port(dp, ds) + qca8k_setup_hol_fixup(priv, dp->index); + /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */ if (priv->switch_id == QCA8K_ID_QCA8327) { mask = QCA8K_GLOBAL_FC_GOL_XON_THRES(288) |