Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp580459lqg; Fri, 1 Mar 2024 14:21:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgYsAiYU8qMHVL9DvjXVMWCfSWynCyO9+BOvNvIhIddNLT1FpEBOOqDI8m1PkAgnEQ3afoCQp5vzwD642QGwsLGTw7Ks+6O51SSYCTww== X-Google-Smtp-Source: AGHT+IFxzQoSlA5Qe0QzmzymkhisuYGNgY9dc25CPmaHEr4A61IBF73Lgkw0ILfNLi318TigE2jz X-Received: by 2002:a05:6402:37a:b0:566:a384:a6ae with SMTP id s26-20020a056402037a00b00566a384a6aemr2061297edw.33.1709331694474; Fri, 01 Mar 2024 14:21:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331694; cv=pass; d=google.com; s=arc-20160816; b=Q+4FJCnRCwG1ICqm+FGZxhG3gr+O1IGkelDAwItJraQ4ytgzS4ANSz7CJyrEE2WiEU J/LOdc4JzEj9KZJhT2zrCsLB91bGuBREHGcfjF+EdNgwTKtZVYO2ym4WXTPekoBmc9vo DTLxkXHXC87jr0/P8XLLd9Tum05S5MYP+pkfDH1/44OgOrFNwTTmRCxtL1ZCBBgbNLnP QCbIZzM6a6eIid8FLSG8nzJLdLbpUQ/K1apRpZcG3FxKd50W3j5RNfuZBmKmI8duhiOg 9bHAxCtd0AdjNNWH8pdKp1EDvXaCfoVsjIk3ykbgzgSIez/Z6fbef76a15llRSzWxgDp yOmg== 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=Vn4+WllD6JXLNkDjfXdWXQe2i3/2663vlUPRUYagr8w=; fh=3jA4nih41mYdWC+Vys7PG5yjDJYpfW99NK6DZGOAUFw=; b=PCN/BdwSBRRx1L+7Dq/+DbUmLdl3Xg7yfM7wzu8gjvYZCi8LV9dY6O8AKR543HUn21 kDK1FDyNjPFTUjkw0N8hV+gyVuAao5+W2KxnZoAVsQqC4cB5IVK20WGCVcFzaGxmSma2 +7dP5VBv5H5MobfcMZ1J+yQF8ufBsY0mDXsol1FCT31XBisb0O5KjIqusi1fW89GSUWt 4SIrocVv3uH4TT/Qn9crEC3JFhSGGAahGxTdH+6rnBlMfwL7xlYL8eYFIOB5oTojfsjd vvzQusTC+Co8v/ZnteG+lnOCApCEq2Tonz4y1fk0Fxkz5HAy168nnEZVMveb8dov/sBV 8N3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="e23Vp/Ns"; 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-89188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89188-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 c14-20020aa7c74e000000b0056635572f42si1735238eds.588.2024.03.01.14.21.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:21:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89188-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="e23Vp/Ns"; 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-89188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89188-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 DBB1C1F2387D for ; Fri, 1 Mar 2024 22:21:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 076645D73C; Fri, 1 Mar 2024 22:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e23Vp/Ns" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 397DE5D488; Fri, 1 Mar 2024 22:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331498; cv=none; b=JhY2jII6hThkO/uwQX6gh32WBu177O7x79bZ3/hqOi6ai+RjNjuoPr4gYd7P15p5VBz1UVqxo2b56vi2EftnIqnbrl0s3LmR//hem0CsCDNYaOEzxmlsi1/2W9CW5dX6Z7Pbgj2wCRpQX2+SZ0RdQgrP70HcSvp7QGyChJMxumQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331498; c=relaxed/simple; bh=/1F9YYIoPOojx+Y/5PVuMCp5WWB8XjaIlMq3YBpJFJk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=og+tiwoIMWz5r3hNkVtE1Hs7g4VoSx7MkQOr/Kl+D+KBlm4NtzQPQUmGo0WNaDqml8GeCluTv5anLarQiG95KWaRJSW5sOgntg+//u9Q7iLOBx6j2A1sP5GyJCmWa5vj2/2hhML5cGBXyjirJdraTw0YxfANQYpc6TNajsoccv8= 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=e23Vp/Ns; arc=none smtp.client-ip=209.85.208.41 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-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5643ae47cd3so3772387a12.3; Fri, 01 Mar 2024 14:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331494; x=1709936294; 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=Vn4+WllD6JXLNkDjfXdWXQe2i3/2663vlUPRUYagr8w=; b=e23Vp/NskZ/RkTKEw+Mnivzf87CMuVF/vjtJVntVxwOu3rPn9JLQynn/2eQe7GwPKm 7C5m+ZvAiqGD0wYw8ZFPMFxQR8UVPyeopvvmsSvbpIPAweFwWWZmNvV8dKo3TCVcpBNN qRqFadL16UuiKkhzbXag+bAxFkV7qM08d9up1D6EUr+c9nE5M9SyQVQyhl/9cbyAhDTm x7Jd7TiMvFURVC1E7s3j6yzmkQc062sZnC/MOiR5A1M0/FF103KDPNNokPKKcjyHr5hd JLX/1ThCM8lcJU02mh8W9iOAx1tm6NCeAb9Y9qCPu6dsA43ppyt9sFsYd9fq8dSgqFor 8U9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331494; x=1709936294; 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=Vn4+WllD6JXLNkDjfXdWXQe2i3/2663vlUPRUYagr8w=; b=UdljbM3YCIiCC+0WxRlqNU+OPVnNoYV00xR7x9yG3JmCK4JbrXL1UhAsWbcOoS3FdJ FAq02mSlkyhH1irrNwrFgyYPvU3Ntq2lP6JCKHv1Yz+kRCKwlqQHSQWfF8DLPPJw4IIQ 6LTgjLGQdBBo5gka+s4jXx4T6kbNgEWooAaUXxW0kQee5NiBLaHIpd9MMN1GUUbUEapq p1sGGBH0n45prp4xOmxtdSboKYieLYgnCdBV/AlWGSJrfHFEUCTgg8hyzdrNbWO7lGSR BDGIDgM7dtHAnj8zmnCj4W7wOSlIGajJXYeEG0zNIxZNW0t0v2h2Or+o1AHsfqql/v9W nOmQ== X-Forwarded-Encrypted: i=1; AJvYcCWkxMapekGO2Priw8JIwbLRwUwpov07LL/hoGD793bnTlIdVbXH4mUeLTFgyi+7euZFnNrSkqL43CSnDIxxqqTBbuFetpVeSr9CXSZY X-Gm-Message-State: AOJu0YxpxRtlLg7hA0XU4RZ/SdewBYFfiPBX0Ybu5W1EIwiCAy8FT4DH AySf+YkdJEvxmo8/C4t94iyic+cHDidA1vy3cSodDuT0/cD26vBbrT1dUBOjb6U= X-Received: by 2002:a17:906:2b15:b0:a44:56cf:b58e with SMTP id a21-20020a1709062b1500b00a4456cfb58emr2306121ejg.18.1709331494356; Fri, 01 Mar 2024 14:18:14 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:14 -0800 (PST) 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 v6 12/16] net: dsa: vsc73xx: introduce tag 8021q for vsc73xx Date: Fri, 1 Mar 2024 23:16:34 +0100 Message-Id: <20240301221641.159542-13-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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 commit introduces a new tagger based on 802.1q tagging. It's designed for the vsc73xx driver. The VSC73xx family doesn't have any tag support for the RGMII port, but it could be based on VLANs. Signed-off-by: Pawel Dembicki --- v6: - added missing MODULE_DESCRIPTION() v5: - removed skb_vlan_tag_present(skb) checking - use 80 characters per line limit v4: - rebase to net-next/main v3: - Introduce a patch after the tagging patch split include/net/dsa.h | 2 ++ net/dsa/Kconfig | 6 ++++ net/dsa/Makefile | 1 + net/dsa/tag_vsc73xx_8021q.c | 67 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 net/dsa/tag_vsc73xx_8021q.c diff --git a/include/net/dsa.h b/include/net/dsa.h index 7c0da9effe4e..b79e136e4c41 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -56,6 +56,7 @@ struct phylink_link_state; #define DSA_TAG_PROTO_RTL8_4T_VALUE 25 #define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26 #define DSA_TAG_PROTO_LAN937X_VALUE 27 +#define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28 enum dsa_tag_protocol { DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE, @@ -86,6 +87,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_RTL8_4T = DSA_TAG_PROTO_RTL8_4T_VALUE, DSA_TAG_PROTO_RZN1_A5PSW = DSA_TAG_PROTO_RZN1_A5PSW_VALUE, DSA_TAG_PROTO_LAN937X = DSA_TAG_PROTO_LAN937X_VALUE, + DSA_TAG_PROTO_VSC73XX_8021Q = DSA_TAG_PROTO_VSC73XX_8021Q_VALUE, }; struct dsa_switch; diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index 8e698bea99a3..e59360071c67 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig @@ -166,6 +166,12 @@ config NET_DSA_TAG_TRAILER Say Y or M if you want to enable support for tagging frames at with a trailed. e.g. Marvell 88E6060. +config NET_DSA_TAG_VSC73XX_8021Q + tristate "Tag driver for Microchip/Vitesse VSC73xx family of switches, using VLAN" + help + Say Y or M if you want to enable support for tagging frames with a + custom VLAN-based header. + config NET_DSA_TAG_XRS700X tristate "Tag driver for XRS700x switches" help diff --git a/net/dsa/Makefile b/net/dsa/Makefile index 8a1894a42552..555c07cfeb71 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_NET_DSA_TAG_RTL8_4) += tag_rtl8_4.o obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o +obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o # for tracing framework to find trace.h diff --git a/net/dsa/tag_vsc73xx_8021q.c b/net/dsa/tag_vsc73xx_8021q.c new file mode 100644 index 000000000000..f7bc0261d54d --- /dev/null +++ b/net/dsa/tag_vsc73xx_8021q.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* Copyright (C) 2024 Pawel Dembicki + */ +#include + +#include "tag.h" +#include "tag_8021q.h" + +#define VSC73XX_8021Q_NAME "vsc73xx-8021q" + +static struct sk_buff * +vsc73xx_xmit(struct sk_buff *skb, struct net_device *netdev) +{ + struct dsa_port *dp = dsa_user_to_port(netdev); + u16 queue_mapping = skb_get_queue_mapping(skb); + u16 tx_vid = dsa_tag_8021q_standalone_vid(dp); + u8 pcp; + + if (skb->offload_fwd_mark) { + unsigned int bridge_num = dsa_port_bridge_num_get(dp); + struct net_device *br = dsa_port_bridge_dev_get(dp); + + if (br_vlan_enabled(br)) + return skb; + + tx_vid = dsa_tag_8021q_bridge_vid(bridge_num); + } + + pcp = netdev_txq_to_tc(netdev, queue_mapping); + + return dsa_8021q_xmit(skb, netdev, ETH_P_8021Q, + ((pcp << VLAN_PRIO_SHIFT) | tx_vid)); +} + +static struct sk_buff * +vsc73xx_rcv(struct sk_buff *skb, struct net_device *netdev) +{ + int src_port = -1, switch_id = -1, vbid = -1, vid = -1; + + dsa_8021q_rcv(skb, &src_port, &switch_id, &vbid, &vid); + + skb->dev = dsa_tag_8021q_find_user(netdev, src_port, switch_id, + vid, vbid); + if (!skb->dev) { + netdev_warn(netdev, "Couldn't decode source port\n"); + return NULL; + } + + dsa_default_offload_fwd_mark(skb); + + return skb; +} + +static const struct dsa_device_ops vsc73xx_8021q_netdev_ops = { + .name = VSC73XX_8021Q_NAME, + .proto = DSA_TAG_PROTO_VSC73XX_8021Q, + .xmit = vsc73xx_xmit, + .rcv = vsc73xx_rcv, + .needed_headroom = VLAN_HLEN, + .promisc_on_conduit = true, +}; + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("DSA tag driver for VSC73XX family of switches, using VLAN"); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_VSC73XX_8021Q, VSC73XX_8021Q_NAME); + +module_dsa_tag_driver(vsc73xx_8021q_netdev_ops); -- 2.34.1