Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2668885rdb; Tue, 12 Sep 2023 08:39:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWtjZvVPjd650SdYUNv5jdBkWCwA4rv6Aq3d2cUxH37xuGGGvoEqMErM9Ye8/tOV0yyir8 X-Received: by 2002:a05:6a20:a104:b0:14c:6404:7c5e with SMTP id q4-20020a056a20a10400b0014c64047c5emr13708848pzk.24.1694533174039; Tue, 12 Sep 2023 08:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694533174; cv=none; d=google.com; s=arc-20160816; b=eMB32R4oqhR7QoqlL5mUTobus7VolvMrzaclxEx3Ezlk0vwiw54elDBXiHPWY6D2OO PMmTynpkBXv+A2o8kw6VJ7gWPhiI5Z/5fCRAIrN1251znt3Ri5d8rzYyjR/zlMbpSO6y mwrw7Fb6M9aK5llKr6D2DCQLYiXru804nvj1CmJNO94EATjDJKOTAF0drfP6I572lSje CUTrAvoUUW5ozEkjPjIwcld9h6XJ0azxTS7wuxds+yK+xnkU57ChVBc0dsjcgqGZskU0 kxFG508fTr2alZxFodT4F9KSF7f4aTtFJqa31KYp/RhsfJ6l232EWQO18AW7qV6xWUPk sqQw== 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=HgSiRWdgC/hwg8MbvdGK6CbTNx/MfKCBd8+7AqLBFRs=; fh=7pT+hAKdFm8SgkIrQfctQAWhXj//sVAB1OFY1O6ncNU=; b=twCmCkLi0al1m/TFVT9VFHE0yPuuNHlpfz4yd35PRkyafSpFiazWg06vPGUhBJJ0xq SVf7nJAltwQD9vL8c7bj8P3iaREaPQ4znMaZvBlNTXGXSG0px5hgyIkTsZ723p32nILR 0O3YSOwHc9TbouxvPxTqGfFJUTW801Gz+SpVQO5KItAvGOlwIWCkEAX75ZYZt4LslKaU 7LurA/HA0ybWenPBGxxUaQby2IqczSGpw92NJcEeItQo8PfPyo4kzOxGWmDp+NnudWyg hmnayLe+7CGWOIefjDgqoBtJdkvXGWlCTKGhe+oceR7A/CuEw/+6dzGoEY2jVyYaZW44 IzTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DBrGfpj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k14-20020aa788ce000000b0068e35157c11si8169346pff.112.2023.09.12.08.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:39:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DBrGfpj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8CFF781E5D34; Tue, 12 Sep 2023 05:27:46 -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 S235332AbjILM1j (ORCPT + 99 others); Tue, 12 Sep 2023 08:27:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235173AbjILM1C (ORCPT ); Tue, 12 Sep 2023 08:27:02 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D12510DC; Tue, 12 Sep 2023 05:26:57 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so94669131fa.2; Tue, 12 Sep 2023 05:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694521615; x=1695126415; darn=vger.kernel.org; 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=HgSiRWdgC/hwg8MbvdGK6CbTNx/MfKCBd8+7AqLBFRs=; b=DBrGfpj0YAPt07jvbvXQLELOhfXIg+GNvApcKL5krt20XHcuLrl6vLY7HbCG2zEDLb glXZOArZvJ7WRF0lLJknFLW2eyFabvp+fLxZgO2OMwdgD/4CsKu4MS7MfmqWXxuOFmNx PrLtSNzu+e23NbKwQoEEB3xfkFmaB689C2i5TFuxS6ENipsoHFnKubxZHbntL9LstDL+ 8EjU8KJvWXqgt33GcGRXCpbgNIxRL9amSit73dOdduFM10UePeZKR3n+EA5HojjRmw6n AE9ZHaWo+a4LQIiAQgp5tdjapuLKw/9wZRnRc6imJ82YZ6YJiauMtOJYBEg/rBkDHOfD RsDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694521615; x=1695126415; 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=HgSiRWdgC/hwg8MbvdGK6CbTNx/MfKCBd8+7AqLBFRs=; b=Z2qcqwou0lcaMUq60S31vuRIQ2NH+BqNNGD6nXM/FW0gcZ1RvMFydP0tPoI8TjF4Wa 7w5pMAFiPJQF3/yCFHJ+Pn0/KHN/YxnfcA2BOb1ONCFNyvhlR3eQOBgHBAgTpc00x4dt VL6uy362JDM3zufOy2DqKUTze/BaCX/+8ebduVY+oMJITGiF9fjzBRjMuHhDxdtOOT6m FRw1Q5Rep5riURfurI7aqARgHf0/sclmEnRvoU65L9MiE1hu5vK9SPVS3gC34k3ZtBaa J99rXK/e8xX92p2EVAgjiRp9FIFp77KPNJ74tTM3LaGUIomvKKcsWeNqRd7N+qOZS2xn x3ag== X-Gm-Message-State: AOJu0YyZ9Gul2twK2otTFaJWDG3+AZk0xiSdNvscQGtG+jPA8pYd8f9+ 49sPGuwgABBqycLQdjhvxz/mJXNENn4AaQ== X-Received: by 2002:a19:8c4b:0:b0:500:d8d6:fbe4 with SMTP id i11-20020a198c4b000000b00500d8d6fbe4mr9195198lfj.49.1694521615356; Tue, 12 Sep 2023 05:26:55 -0700 (PDT) Received: from WBEC325.dom.local ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g21-20020ac25395000000b004fe333128c0sm1737327lfh.242.2023.09.12.05.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:26:55 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Dan Carpenter , Simon Horman , Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 7/8] net: dsa: vsc73xx: Implement vsc73xx 8021q tagger Date: Tue, 12 Sep 2023 14:22:01 +0200 Message-Id: <20230912122201.3752918-8-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912122201.3752918-1-paweldembicki@gmail.com> References: <20230912122201.3752918-1-paweldembicki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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]); Tue, 12 Sep 2023 05:27:46 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 This patch is a simple implementation of 802.1q tagging in the vsc73xx driver. Currently, devices with DSA_TAG_PROTO_NONE are not functional. The VSC73XX family doesn't provide any tag support for external Ethernet ports. The only option available is VLAN-based tagging, which requires constant hardware VLAN filtering. While the VSC73XX family supports provider bridging, it only supports QinQ without full implementation of 802.1AD. This means it only allows the doubled 0x8100 TPID. In the simple port mode, QinQ is enabled to preserve forwarding of VLAN-tagged frames. The tag driver introduces the most basic functionality required for proper tagging support. Signed-off-by: Pawel Dembicki --- v3: - Split tagger and tag implementation into separate commits drivers/net/dsa/Kconfig | 2 +- drivers/net/dsa/vitesse-vsc73xx-core.c | 48 +++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig index f8c1d73b251d..120bc3ded9f2 100644 --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig @@ -126,7 +126,7 @@ config NET_DSA_SMSC_LAN9303_MDIO config NET_DSA_VITESSE_VSC73XX tristate - select NET_DSA_TAG_NONE + select NET_DSA_TAG_VSC73XX_8021Q select FIXED_PHY select VITESSE_PHY select GPIOLIB diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index d9a6eac1fcce..bf903502bac1 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -589,7 +590,7 @@ static enum dsa_tag_protocol vsc73xx_get_tag_protocol(struct dsa_switch *ds, * cannot access the tag. (See "Internal frame header" section * 3.9.1 in the manual.) */ - return DSA_TAG_PROTO_NONE; + return DSA_TAG_PROTO_VSC73XX_8021Q; } static int vsc73xx_setup(struct dsa_switch *ds) @@ -664,6 +665,12 @@ static int vsc73xx_setup(struct dsa_switch *ds) mdelay(50); + rtnl_lock(); + ret = dsa_tag_8021q_register(ds, htons(ETH_P_8021Q)); + rtnl_unlock(); + if (ret) + return ret; + /* Release reset from the internal PHYs */ vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET, VSC73XX_GLORESET_PHY_RESET); @@ -1412,6 +1419,43 @@ static int vsc73xx_port_vlan_del(struct dsa_switch *ds, int port, return 0; } +static int vsc73xx_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, + u16 flags) +{ + bool untagged = flags & BRIDGE_VLAN_INFO_UNTAGGED; + bool pvid = flags & BRIDGE_VLAN_INFO_PVID; + struct vsc73xx *vsc = ds->priv; + int ret; + + if (untagged) { + if (!dsa_port_is_vlan_filtering(dsa_to_port(ds, port))) { + ret = vsc73xx_vlan_set_untagged(ds, port, vid, false); + if (ret) + return ret; + } else { + vsc->untagged_storage[port] = vid; + } + } + if (pvid) { + if (!dsa_port_is_vlan_filtering(dsa_to_port(ds, port))) { + ret = vsc73xx_vlan_set_pvid(ds, port, vid, false); + if (ret) + return ret; + } else { + vsc->pvid_storage[port] = vid; + } + } + + return vsc73xx_update_vlan_table(vsc, port, vid, 1); +} + +static int vsc73xx_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) +{ + struct vsc73xx *vsc = ds->priv; + + return vsc73xx_update_vlan_table(vsc, port, vid, 0); +} + static int vsc73xx_port_setup(struct dsa_switch *ds, int port) { struct vsc73xx *vsc = ds->priv; @@ -1519,6 +1563,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .port_vlan_filtering = vsc73xx_port_vlan_filtering, .port_vlan_add = vsc73xx_port_vlan_add, .port_vlan_del = vsc73xx_port_vlan_del, + .tag_8021q_vlan_add = vsc73xx_tag_8021q_vlan_add, + .tag_8021q_vlan_del = vsc73xx_tag_8021q_vlan_del, }; static int vsc73xx_gpio_get(struct gpio_chip *chip, unsigned int offset) -- 2.34.1