Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2623050lqz; Wed, 3 Apr 2024 03:58:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYUNMOYYfK7qteZwsZCY+dqkin9LTJxb7KPs4VzQlXJ1lqyGjbgPIf2KWVhkC8m3gxROuJOQR8mFwJX8ozQRNA3k+YqKihumsSbkW1ww== X-Google-Smtp-Source: AGHT+IFWn5hdqR4zP/nMhMLdcq56RXNGSR+oQvOJQANzGzbjJ1+Ub0y/RX4Hf6fL1tn1ZBVMsAfq X-Received: by 2002:a17:907:77cb:b0:a47:46d7:a89f with SMTP id kz11-20020a17090777cb00b00a4746d7a89fmr8763534ejc.30.1712141931530; Wed, 03 Apr 2024 03:58:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712141931; cv=pass; d=google.com; s=arc-20160816; b=GYknTp19koqYAyGKg7t2Hk86EMOhgw7u55t8XHEkjNlhdoEH/U7cSRcC9CwxbsQ2yb bbUSY5XmrU59DO7VUGHA2xFzWms8taXKjM+MnmEMg75PNKibMHZPyHmNcKKR3mJwmj9+ 6BjZeV0oBi3Ilg1ZBc5q745Qd+mke+6jTKaVYWVvT7eDvaAHq8eNibqDrj2/uQFAnVKg +lLisW5FuK7CD1rHSgzO4nZkCCYf6YaGIwwvrwqx/VblMWi0Db/dcsDzKkQ7CbPhi4/E RrdnDoScqN8QYH2lXWb1b+FFnTpTU1sx1iiWYezV1vQX3paSQhGAsz2reMzQx4cmad7q R4KA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wTbmqZooxysHTZKOHPv1gDt0WmS/83zgiBJ7JzV9ZNU=; fh=r/0lxBXJw3ox93FHLUKAiKQXJw2b9k8rqHj7y7eOe5M=; b=Dw06divCN501SGh0I7VCNw+Cj8odDJUVWPTlt85FIDH+nXQluvKn0yXM7+V5dPr8oT fgY2it0ZV4aEGnGUw+9k/ZWyDKXDCo8wWYyOJ5RnqnveDDGzofexzaTdaq3mDR0HG/Ee aNpBVG860iBVkiWYDgzhlaGtZIR+gRPLqgRhI2cKil/wOVeh/YeEJJv48uApRfgo5Piy bW8cPcXLdEJug3MHjZWI/aa6/KcKnqp6BlZKsgFDCdkrlErOXqp+K3uJ/9Bte9uLt2xG N6e/RIXXBFHX6Omwbmk2msTqGC6l8dqDDqW2lFLFxfPLAbZ8Fowf7L6gLfVyVgbPCb8W jTSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mcPCyzEM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-129582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id sh33-20020a1709076ea100b00a4e2885a118si6505972ejc.995.2024.04.03.03.58.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 03:58:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mcPCyzEM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-129582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7C3A81F2E2D5 for ; Wed, 3 Apr 2024 10:41:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 378D31494A6; Wed, 3 Apr 2024 10:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mcPCyzEM" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BA9C148FF9; Wed, 3 Apr 2024 10:38:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712140714; cv=none; b=bkgUI7PW5pmb3DtY6IxhxK/TavPL8oDbLzAKgJZTrmCqlMU3t9j1ig1pvSX5tPjbolH5BKfzrOGwnlZQGlF/13svQ/EQbpLgCQ0akYYZrJAsjuLQTTmPM952yKq/D2/u3tJtsa//DMPpgGNUkyYyRmsRRU+OIOaIbcu6qgelcZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712140714; c=relaxed/simple; bh=3OB8TQ1rUhMuNxtWAU1N5y3sWwbu3WduaIW8pVqyg/Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mOCcsoAUOYHY30XoL+mmUvVPp0SWD1TgY7aisTssUa1vqtjjMI5+Qbodx9ajvMvL4jdyzc3XEf76zNKeKvr27DVYhVYHA4AEuxeMcM5LZGkgnq+nUcYk6sDE+Iikh5pULAXxwCNlruh1s6I86w7P3IeU6ex/PvB11wGcD22kyc8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mcPCyzEM; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a4e62f3e63dso395270266b.0; Wed, 03 Apr 2024 03:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712140710; x=1712745510; 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=wTbmqZooxysHTZKOHPv1gDt0WmS/83zgiBJ7JzV9ZNU=; b=mcPCyzEMpSGWLWI1ON4nX3jTOf+hguhJK3np18mVPMb6CV/I+P73mmnor+Cu62bEnL Qi5PyiLwjMaY7tntNqoEobuduRt9BB+HReLjXXGdd2+B1JrOQC1RLLz5C7bSd4+0NhSn 7XZN4EQUogycR4NEWI8vQRf2WMM3pHXqCtA+nCU4M7lRvxcud1HdmeFYyczuw+wG7kEM 671yU4XFgyegJ2E7XMyvoAZXGO9URkZxUYN3/fl73mohj2JxBhWbUT90fBjKlJRZcZjh W8bFWRxEcNS7fNEW0+auHb4gHghr2WGn7kwM1aTo1hrZkpcXrwtiV3O/iuMgqjqBRe3A KXfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712140710; x=1712745510; 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=wTbmqZooxysHTZKOHPv1gDt0WmS/83zgiBJ7JzV9ZNU=; b=mNb8Qt9weYcDllriMt1nGPl4DCAHWE1sU8oQEg+Rc4f5yVebdmrYQ18RlTe9e/EL4l zK4O2E2tDQpQ9Km4JkOaBYTZSpfYid0lhb6wmNuz6BvgvV0U3Z+y+BUUS1Tt2QaMxUL2 aQYEW3ep2UcgsoCkz+gUUb/LZBVD4ts/DICSxTlaO8J7PHbUKzkgfTFUf3xLYzN1Mm7s 1nWktulXbgz6nH5FnwUpUpjzhX8gx1iGXad+uv0zDvf5h/5HcPtKBmy1phmHRrUlLWn4 LoU8c+4UOC4RaAXuzozvvO0FYYgMSS7LG6xdtxvaZ8LG1o2ErLBI5M5VW+//Xtkz8oDS ktBw== X-Forwarded-Encrypted: i=1; AJvYcCUgcTwHH/b5z+Vx7COdvxCYwPX18/a8bzDJjb1TV8NUOQe8e82B3weyufJuMeuLqfpiyC4PuojQcoDkd7eNPwhWVauAatAT3uZy5s1I X-Gm-Message-State: AOJu0Yy2FH7BxFcXz8+NkkLV/05z2QhSGX9K9a/aEiuN64p2rPp0TOoa 6vV4QPsxEGh1a9fAERsvWXIjwZ8jFUtnzkGXklCi7JJOXM1m6Mx/6kkiBwtbW+c= X-Received: by 2002:a17:906:27c4:b0:a4e:2e14:f75e with SMTP id k4-20020a17090627c400b00a4e2e14f75emr8269752ejc.77.1712140710580; Wed, 03 Apr 2024 03:38:30 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id xd2-20020a170907078200b00a4e2e16805bsm6858169ejb.11.2024.04.03.03.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 03:38:30 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v8 13/16] net: dsa: vsc73xx: Implement the tag_8021q VLAN operations Date: Wed, 3 Apr 2024 12:37:29 +0200 Message-Id: <20240403103734.3033398-14-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403103734.3033398-1-paweldembicki@gmail.com> References: <20240403103734.3033398-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Pawel Dembicki --- v8: - resend only v7: - adjust tag8021q implementation for vlan filtering implementation changes v6: - resend only v5: - improve commit message v4: - adjust tag8021q implementation for changed untagged vlan storage - minor fixes v3: - Split tagger and tag implementation into separate commits drivers/net/dsa/Kconfig | 2 +- drivers/net/dsa/vitesse-vsc73xx-core.c | 54 +++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig index 3092b391031a..22a04636d09e 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 433ffd4f44fd..d0442ea8a610 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -597,7 +597,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_wait_for_vlan_table_cmd(struct vsc73xx *vsc) @@ -687,7 +687,7 @@ vsc73xx_update_vlan_table(struct vsc73xx *vsc, int port, u16 vid, bool set) static int vsc73xx_setup(struct dsa_switch *ds) { struct vsc73xx *vsc = ds->priv; - int i; + int i, ret; dev_info(vsc->dev, "set up the switch\n"); @@ -756,6 +756,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); @@ -1210,6 +1216,21 @@ static int vsc73xx_vlan_set_untagged_hw(struct vsc73xx *vsc, int port, u16 vid) return vsc73xx_vlan_change_untagged_hw(vsc, port, vid, true); } +static int vsc73xx_vlan_change_untagged_tag_8021q(struct vsc73xx *vsc, int port, + u16 vid, bool valid, + bool operate_on_storage) +{ + struct vsc73xx_portinfo *portinfo = &vsc->portinfo[port]; + + portinfo->untagged_tag_8021q_configured = valid; + portinfo->untagged_tag_8021q = vid; + + if (operate_on_storage) + return 0; + + return vsc73xx_vlan_change_untagged_hw(vsc, port, vid, valid); +} + static int vsc73xx_vlan_change_pvid_hw(struct vsc73xx *vsc, int port, u16 vid, bool set) { @@ -1537,6 +1558,33 @@ 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; + bool operate_on_storage; + + operate_on_storage = !vsc73xx_tag_8021q_active(dsa_to_port(ds, port)); + + if (untagged) + vsc73xx_vlan_change_untagged_tag_8021q(vsc, port, vid, true, + operate_on_storage); + if (pvid) + vsc73xx_vlan_change_pvid(vsc, port, vid, true, + operate_on_storage, true); + + return vsc73xx_update_vlan_table(vsc, port, vid, true); +} + +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, false); +} + static int vsc73xx_port_setup(struct dsa_switch *ds, int port) { struct vsc73xx_portinfo *portinfo; @@ -1667,6 +1715,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .port_vlan_add = vsc73xx_port_vlan_add, .port_vlan_del = vsc73xx_port_vlan_del, .phylink_get_caps = vsc73xx_phylink_get_caps, + .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