From patchwork Tue Jun 2 20:54:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1302625 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=jTozFGWV; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49c47K2VSzz9sPF for ; Wed, 3 Jun 2020 06:55:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728170AbgFBUzX (ORCPT ); Tue, 2 Jun 2020 16:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbgFBUzW (ORCPT ); Tue, 2 Jun 2020 16:55:22 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A32AC08C5C0 for ; Tue, 2 Jun 2020 13:55:22 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id z9so3663080ljh.13 for ; Tue, 02 Jun 2020 13:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jKxxfCElY4JBNjmwH0hEmddihO+ZHnX/coZuCbJ7oDg=; b=jTozFGWVI0IuzVb/q2ygZpVR0HycWSXRTpx3e2btZ0wpxtfXokrUx72JefMVOJ4Sn3 meIRAS+9QAu08r+/HmXjLlJySvj9EIc1TpqvZTRb5N18RN6Nb6cI0L/F1ApBIXVSaoyS FHoyCsimpfdoAvlFKUnyqySmNIHa/9esVEBWNYhHZT5BULOQ3IU/Cx/QzfEuEVkorBhL tHiXXTLrLObv+c6W+5AXuwvk378/nYfQpkmXsX+u3Ys9ZlpoLW23CYyz60PiWoywGRj+ /oZv/cQMkzv3n4+VelDjw+aeg0+TZuGhn3peP9nmmiL8Hjy1YVDhLdbc7IVWFZDPKARa Mxkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jKxxfCElY4JBNjmwH0hEmddihO+ZHnX/coZuCbJ7oDg=; b=Uy1U5qUAXyF5G8vUu4nidOkYio6TOxBZHqw5V18cdACZBa2WuHYM0n7qpwHmvjjk7z xGdp0NepFnINfgUJ0wRPN+jxAtd/6WA1FK48yUHuWmiQkQ98p9i1dJE54o51sjxTfwH7 9n4vJkSG2e/L5z+2a5wdcrtW+ymDJwn83uX5LKucdHnYQC5EcIDH1uzjQPvEbdcBtz6Z efQmfk9JhLxVnwUXSGjF8x4lBjQBYtmj4gKsbSnXp8qeAVuh+11OHznk5bgbkMbHhzIB YtghzyYyxf5d8JtX1FMnugsZas3pm2zn8SCgu/B15bGPt2ZgVBmbZhp4cVR7zwagUxRh Ay0Q== X-Gm-Message-State: AOAM533non7/zxjkrPMMWuRdAL5Y0RehuTSIRqDfhQVU1+azXwPAHYnT qMYpf5/eKTTeCjvyJsNhXMgaeA== X-Google-Smtp-Source: ABdhPJzTT3TlmKEc5DLyoMGAOC/j51E0MVFbDcp3trX+FW0mibKqFJOjrXXBRvyXay7WfX6rPoPIgQ== X-Received: by 2002:a05:651c:512:: with SMTP id o18mr486096ljp.226.1591131320697; Tue, 02 Jun 2020 13:55:20 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-8cdb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.219.140]) by smtp.gmail.com with ESMTPSA id t5sm41962lff.39.2020.06.02.13.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 13:55:20 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, Linus Walleij , DENG Qingfang Subject: [net-next PATCH 1/5] net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag Date: Tue, 2 Jun 2020 22:54:52 +0200 Message-Id: <20200602205456.2392024-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This implements the known parts of the Realtek 4 byte tag protocol version 0xA, as found in the RTL8366RB DSA switch. It is designated as protocol version 0xA as a different Realtek 4 byte tag format with protocol version 0x9 is known to exist in the Realtek RTL8306 chips. The tag and switch chip lacks public documentation, so the tag format has been reverse-engineered from packet dumps. As only ingress traffic has been available for analysis an egress tag has not been possible to develop (even using educated guesses about bit fields) so this is as far as it gets. It is not know if the switch even supports egress tagging. Using these ingress tags however, the switch functionality is vastly improved and the packets find their way into the destination port without any tricky configuration. On the D-Link DIR-685 the LAN ports now come up and respond to ping without any command line configuration so this is a real improvement for users. Egress packets need to be restricted to the proper target ports using VLAN, which the DSA switch driver already sets up. Cc: DENG Qingfang Signed-off-by: Linus Walleij --- include/net/dsa.h | 2 + net/dsa/Kconfig | 7 +++ net/dsa/Makefile | 1 + net/dsa/tag_rtl4_a.c | 134 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 net/dsa/tag_rtl4_a.c diff --git a/include/net/dsa.h b/include/net/dsa.h index fb3f9222f2a1..7a6a922a509e 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -44,6 +44,7 @@ struct phylink_link_state; #define DSA_TAG_PROTO_KSZ8795_VALUE 14 #define DSA_TAG_PROTO_OCELOT_VALUE 15 #define DSA_TAG_PROTO_AR9331_VALUE 16 +#define DSA_TAG_PROTO_RTL4_A_VALUE 17 enum dsa_tag_protocol { DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE, @@ -63,6 +64,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_KSZ8795 = DSA_TAG_PROTO_KSZ8795_VALUE, DSA_TAG_PROTO_OCELOT = DSA_TAG_PROTO_OCELOT_VALUE, DSA_TAG_PROTO_AR9331 = DSA_TAG_PROTO_AR9331_VALUE, + DSA_TAG_PROTO_RTL4_A = DSA_TAG_PROTO_RTL4_A_VALUE, }; struct packet_type; diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index 92663dcb3aa2..0ec29e49683f 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig @@ -85,6 +85,13 @@ config NET_DSA_TAG_KSZ Say Y if you want to enable support for tagging frames for the Microchip 8795/9477/9893 families of switches. +config NET_DSA_TAG_RTL4_A + tristate "Tag driver for Realtek 4 byte protocol A tags" + help + Say Y or M if you want to enable support for tagging frames for the + Realtek switches with 4 byte protocol A tags, sich as found in + the Realtek RTL8366RB. + config NET_DSA_TAG_OCELOT tristate "Tag driver for Ocelot family of switches" select PACKING diff --git a/net/dsa/Makefile b/net/dsa/Makefile index 108486cfdeef..4f47b2025ff5 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o +obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o diff --git a/net/dsa/tag_rtl4_a.c b/net/dsa/tag_rtl4_a.c new file mode 100644 index 000000000000..45f24e5cdde2 --- /dev/null +++ b/net/dsa/tag_rtl4_a.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Handler for Realtek 4 byte DSA switch tags + * Currently only supports protocol "A" found in RTL8366RB + * Copyright (c) 2020 Linus Walleij + * + * This "proprietary tag" header looks like so: + * + * ------------------------------------------------- + * | MAC DA | MAC SA | 0x8899 | 2 bytes tag | Type | + * ------------------------------------------------- + * + * The 2 bytes tag form a 16 bit big endian word. The exact + * meaning has been guess from packet dumps from ingress + * frames, as no working egress traffic has been available + * we do not know the format of the egress tags or if they + * are even supported. + */ + +#include +#include + +#include "dsa_priv.h" + +#define RTL4_A_HDR_LEN 4 +#define RTL4_A_ETHERTYPE 0x8899 +#define RTL4_A_PROTOCOL_SHIFT 12 +/* + * 0x1 = Realtek Remote Control protocol (RRCP) + * 0x2/0x3 seems to be used for loopback testing + * 0x9 = RTL8306 DSA protocol + * 0xa = RTL8366RB DSA protocol + */ +#define RTL4_A_PROTOCOL_RTL8366RB 0xa + +static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + /* + * Just let it pass thru, we don't know if it is possible + * to tag a frame with the 0x8899 ethertype and direct it + * to a specific port, all attempts at reverse-engineering have + * ended up with the frames getting dropped. + * + * The VLAN set-up needs to restrict the frames to the right port. + * + * If you have documentation on the tagging format for RTL8366RB + * (tag type A) then please contribute. + */ + return skb; +} + +static struct sk_buff *rtl4a_tag_rcv(struct sk_buff *skb, + struct net_device *dev, + struct packet_type *pt) +{ + u16 protport; + __be16 *p; + u16 etype; + u8 flags; + u8 *tag; + u8 prot; + u8 port; + + if (unlikely(!pskb_may_pull(skb, RTL4_A_HDR_LEN))) + return NULL; + + /* The RTL4 header has its own custom Ethertype 0x8899 and that + * starts right at the beginning of the packet, after the src + * ethernet addr. Apparantly skb->data always points 2 bytes in, + * behind the Ethertype. + */ + tag = skb->data - 2; + p = (__be16 *)tag; + etype = ntohs(*p); + if (etype != RTL4_A_ETHERTYPE) { + /* Not custom, just pass through */ + netdev_dbg(dev, "non-realtek ethertype 0x%04x\n", etype); + return skb; + } + p = (__be16 *)(tag + 2); + protport = ntohs(*p); + /* The 4 upper bits are the protocol */ + prot = (protport >> RTL4_A_PROTOCOL_SHIFT) & 0x0f; + if (prot != RTL4_A_PROTOCOL_RTL8366RB) { + netdev_err(dev, "unknown realtek protocol 0x%01x\n", prot); + return NULL; + } + netdev_dbg(dev, "realtek protocol 0x%02x\n", prot); + port = protport & 0xff; + netdev_dbg(dev, "realtek port origin 0x%02x\n", port); + + /* Remove RTL4 tag and recalculate checksum */ + skb_pull_rcsum(skb, RTL4_A_HDR_LEN); + + /* Move ethernet DA and SA in front of the data */ + memmove(skb->data - ETH_HLEN, + skb->data - ETH_HLEN - RTL4_A_HDR_LEN, + 2 * ETH_ALEN); + + skb->dev = dsa_master_find_slave(dev, 0, port); + if (!skb->dev) { + netdev_dbg(dev, "could not find slave for port %d\n", port); + return NULL; + } + netdev_dbg(skb->dev, "forwarded packet to slave port %d\n", port); + + skb->offload_fwd_mark = 1; + + return skb; +} + +static int rtl4a_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) +{ + *offset = RTL4_A_HDR_LEN; + /* Skip past the tag and fetch the encapsulated Ethertype */ + *proto = ((__be16 *)skb->data)[1]; + + return 0; +} + +static const struct dsa_device_ops rtl4a_netdev_ops = { + .name = "rtl4a", + .proto = DSA_TAG_PROTO_RTL4_A, + .xmit = rtl4a_tag_xmit, + .rcv = rtl4a_tag_rcv, + .flow_dissect = rtl4a_tag_flow_dissect, + .overhead = RTL4_A_HDR_LEN, +}; +module_dsa_tag_driver(rtl4a_netdev_ops); + +MODULE_LICENSE("GPL"); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_RTL4_A); From patchwork Tue Jun 2 20:54:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1302626 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=CYlPDe5z; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49c47M0N4Kz9sPF for ; Wed, 3 Jun 2020 06:55:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728256AbgFBUz0 (ORCPT ); Tue, 2 Jun 2020 16:55:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727795AbgFBUzZ (ORCPT ); Tue, 2 Jun 2020 16:55:25 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F8DC08C5C0 for ; Tue, 2 Jun 2020 13:55:25 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id w15so7007018lfe.11 for ; Tue, 02 Jun 2020 13:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mSZdHFH4Bx0kIRim8XPkE3hmIfXGRjFDDYswlMmM/WE=; b=CYlPDe5zKmPnSuADU51Lo9aFvDegDXUS635rDXYbsA3DCd+cbpDubEUrcfwL22O1w2 xC2ng04rB7MZ6O34hCBDQGN4OtNxqKI1jsRtMyQPOZJFhsHt4nBLfs4tAaRy1DUgW40P //3z/GX5op6ky0gMf4OA24WAINxli6zOQMmw4c/fWFBZ6Gsv1x172AMqTwdnWoIk1peM 9Lm158ZFMkFy1TAyXsft3N9sryllo4GzPBHJzHxSm8hB6jlxlVebdb6lfDZw3Srjez3m zq3lIEYRlgGS8994k59X8QhBouaEn/rbFNeYxqLR+Cudv+Fl0xtnsLULz6Fh0i6pjvPh gvhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mSZdHFH4Bx0kIRim8XPkE3hmIfXGRjFDDYswlMmM/WE=; b=SexbMWH07x5FdvH0AyImd4TbpQ9C2utCgqrtaDS0rE48o+RERzr3TX9sn1D4g1Oq/W N+hmUkyPSpWms6vqE1by2TZ6FIrRn1dl9xRQHDgiqCU/czYYHkQP+KRKu/wN7rvqYl3P 6XxyhfvroZg2BodHarWdDRFjkxUjMHg1JMyAP4Ef+nli/zGDs7mxIS2+UrWyCrFwNv7s 2KntPaE1mSBed5fc+eHB/cCKejxjQ0mLiKPpBqB95H1s2AKnotNOuGS2P8ZMapev4LBY /gkJpcJ4gszZ/cXb16j2OJXol1ndhoxVtbtAccRMyM4mGNiIFdYDPDGFJp0n2FI52oEz KGvQ== X-Gm-Message-State: AOAM531jWkCuD4mkKtPEBdqCUtASiEIfwNKEH+Ht58qd/3kNGBj4WyPr UrJXYxQcrJTOVUaoLUt6JpD21Q== X-Google-Smtp-Source: ABdhPJzgg4vDjuyM1nULWi0wN5qNgf8AWay5c19LIbOMWBOLIltlvAqQ40lH7hz6pMIcCf0ZTCqeLg== X-Received: by 2002:ac2:4a75:: with SMTP id q21mr607210lfp.190.1591131323574; Tue, 02 Jun 2020 13:55:23 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-8cdb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.219.140]) by smtp.gmail.com with ESMTPSA id t5sm41962lff.39.2020.06.02.13.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 13:55:22 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, Linus Walleij , DENG Qingfang Subject: [net-next PATCH 2/5] net: dsa: rtl8366rb: Support the CPU DSA tag Date: Tue, 2 Jun 2020 22:54:53 +0200 Message-Id: <20200602205456.2392024-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602205456.2392024-1-linus.walleij@linaro.org> References: <20200602205456.2392024-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This activates the support to use the CPU tag to properly direct ingress traffic to the right port. After this e.g. ping works out-of-the-box with the RTL8366RB. Cc: DENG Qingfang Signed-off-by: Linus Walleij --- drivers/net/dsa/Kconfig | 1 + drivers/net/dsa/rtl8366rb.c | 31 ++++++++----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig index 2d38dbc9dd8c..3a4485651f1d 100644 --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig @@ -70,6 +70,7 @@ config NET_DSA_QCA8K config NET_DSA_REALTEK_SMI tristate "Realtek SMI Ethernet switch family support" depends on NET_DSA + select NET_DSA_TAG_RTL4_A select FIXED_PHY select IRQ_DOMAIN select REALTEK_PHY diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index fd1977590cb4..48f1ff746799 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -109,8 +109,8 @@ /* CPU port control reg */ #define RTL8368RB_CPU_CTRL_REG 0x0061 #define RTL8368RB_CPU_PORTS_MSK 0x00FF -/* Enables inserting custom tag length/type 0x8899 */ -#define RTL8368RB_CPU_INSTAG BIT(15) +/* Disables inserting custom tag length/type 0x8899 */ +#define RTL8368RB_CPU_NO_TAG BIT(15) #define RTL8366RB_SMAR0 0x0070 /* bits 0..15 */ #define RTL8366RB_SMAR1 0x0071 /* bits 16..31 */ @@ -844,16 +844,14 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; - /* Enable CPU port and enable inserting CPU tag + /* Enable CPU port with custom DSA tag 8899. * - * Disabling RTL8368RB_CPU_INSTAG here will change the behaviour - * of the switch totally and it will start talking Realtek RRCP - * internally. It is probably possible to experiment with this, - * but then the kernel needs to understand and handle RRCP first. + * If you set RTL8368RB_CPU_NO_TAG (bit 15) in this registers + * the custom tag is turned off. */ ret = regmap_update_bits(smi->map, RTL8368RB_CPU_CTRL_REG, 0xFFFF, - RTL8368RB_CPU_INSTAG | BIT(smi->cpu_port)); + BIT(smi->cpu_port)); if (ret) return ret; @@ -967,21 +965,8 @@ static enum dsa_tag_protocol rtl8366_get_tag_protocol(struct dsa_switch *ds, int port, enum dsa_tag_protocol mp) { - /* For now, the RTL switches are handled without any custom tags. - * - * It is possible to turn on "custom tags" by removing the - * RTL8368RB_CPU_INSTAG flag when enabling the port but what it - * does is unfamiliar to DSA: ethernet frames of type 8899, the Realtek - * Remote Control Protocol (RRCP) start to appear on the CPU port of - * the device. So this is not the ordinary few extra bytes in the - * frame. Instead it appears that the switch starts to talk Realtek - * RRCP internally which means a pretty complex RRCP implementation - * decoding and responding the RRCP protocol is needed to exploit this. - * - * The OpenRRCP project (dormant since 2009) have reverse-egineered - * parts of the protocol. - */ - return DSA_TAG_PROTO_NONE; + /* This switch uses the 4 byte protocol A Realtek DSA tag */ + return DSA_TAG_PROTO_RTL4_A; } static void rtl8366rb_adjust_link(struct dsa_switch *ds, int port, From patchwork Tue Jun 2 20:54:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1302627 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=CDJajuO0; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49c47R75Hsz9sPF for ; Wed, 3 Jun 2020 06:55:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728361AbgFBUza (ORCPT ); Tue, 2 Jun 2020 16:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727795AbgFBUz3 (ORCPT ); Tue, 2 Jun 2020 16:55:29 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00247C08C5C0 for ; Tue, 2 Jun 2020 13:55:27 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id n24so3779720lji.10 for ; Tue, 02 Jun 2020 13:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YD7hNiI0BkgOn2LYxPlMALflk0oZVF+W4LlCRqaBQAk=; b=CDJajuO0aYEL4USSj+tqMIFQwVgT8t+p/UV9hjvEB/pWxx+744kzngnZEtbrnIZOUN YD0bmzWkHywR2MyIJ5yGgeyj65g6+A0AGUUFYvsb3or+izKQxvbmclLiNa6FiHOOYfAu XgPPTF/l6Rr7iW/nbsK0gKXdzBSyMJolqhxqlLGKp2jMRHDj7soePUwhG7YwnTHD1EN9 5CV3mogUfjQfPCrxPzwy0vRwmtaQCjnnEye87CbST96O8OL3GeOmCHFV3xCFLRAKVHJx 2s7uAYKxBvhRpPiPwyJwY7CmKW7yRbnbD9bJcm/Hs7DNfu6N4dpTvguXWVhGq/EYK+fr 2Z1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YD7hNiI0BkgOn2LYxPlMALflk0oZVF+W4LlCRqaBQAk=; b=SLkmjSdYZAC0nT8nXD3CPHOGqrk9tzuiD/V3JeI1Gw/IjRKqAGk4feCte6qLtPizUL ERw5Rcinr+mMeVF3aAHQikbhu1cK5LiJXfFl9BhxodAZgey285K+VpSrvsvLs3/P4ixM D+4UMKoQVzEVUcZ63YmXPve2z3a4YtT3Am8EAMfXRnWJmfqPw/cBcFtIzVGTep3spubm L1g3aOxCm3ytOitRKlwCtPjUHnW1IN66bHtr3qZrz5Vh7SjbbM8N7vALVgPunwHzWPjb hAVrOTizpxQsotfmXs/R8iM4jZnqYPKjul3ywtTMiiGNrJuZtl4gEHQDTYW4Lq0zdujr QaEw== X-Gm-Message-State: AOAM530KOcN/kY2/yVEQ3BIOuQ3WsuP5awXtawNYA1EFYofscQtAWVqt YhH14mpjjJ4yWMLJLc802OI94Q== X-Google-Smtp-Source: ABdhPJyTmlgliUfj4x0srWtRjzrLG7HimqPkUUQuYnM199j9Cl9TXU9LPj76cJ42zTRpu/nZc77uwQ== X-Received: by 2002:a2e:87da:: with SMTP id v26mr446078ljj.14.1591131326379; Tue, 02 Jun 2020 13:55:26 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-8cdb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.219.140]) by smtp.gmail.com with ESMTPSA id t5sm41962lff.39.2020.06.02.13.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 13:55:25 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, Linus Walleij , DENG Qingfang Subject: [net-next PATCH 3/5] net: dsa: rtl8366: Split out default VLAN config Date: Tue, 2 Jun 2020 22:54:54 +0200 Message-Id: <20200602205456.2392024-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602205456.2392024-1-linus.walleij@linaro.org> References: <20200602205456.2392024-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We loop over the ports to initialize the default VLAN and PVID for each port. As we need to reuse the code to reinitialize a single port, break out the function rtl8366_set_default_vlan_and_pvid(). Cc: DENG Qingfang Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 70 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index ac88caca5ad4..66bd1241204c 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -253,6 +253,48 @@ int rtl8366_reset_vlan(struct realtek_smi *smi) } EXPORT_SYMBOL_GPL(rtl8366_reset_vlan); +static int rtl8366_set_default_vlan_and_pvid(struct realtek_smi *smi, + int port) +{ + u32 mask; + u16 vid; + int ret; + + /* This is the reserved default VLAN for this port */ + vid = port + 1; + + if (port == smi->cpu_port) + /* For the CPU port, make all ports members of this + * VLAN. + */ + mask = GENMASK(smi->num_ports - 1, 0); + else + /* For all other ports, enable itself plus the + * CPU port. + */ + mask = BIT(port) | BIT(smi->cpu_port); + + /* For each port, set the port as member of VLAN (port+1) + * and untagged, except for the CPU port: the CPU port (5) is + * member of VLAN 6 and so are ALL the other ports as well. + * Use filter 0 (no filter). + */ + dev_info(smi->dev, "Set VLAN %04x portmask to %08x (port %d %s)\n", + vid, mask, port, (port == smi->cpu_port) ? + "CPU PORT and all other ports" : "and CPU port"); + ret = rtl8366_set_vlan(smi, vid, mask, mask, 0); + if (ret) + return ret; + + dev_info(smi->dev, "Set PVID %04x on port %d\n", + vid, port); + ret = rtl8366_set_pvid(smi, port, vid); + if (ret) + return ret; + + return 0; +} + int rtl8366_init_vlan(struct realtek_smi *smi) { int port; @@ -266,33 +308,7 @@ int rtl8366_init_vlan(struct realtek_smi *smi) * it with the VLAN (port+1) */ for (port = 0; port < smi->num_ports; port++) { - u32 mask; - - if (port == smi->cpu_port) - /* For the CPU port, make all ports members of this - * VLAN. - */ - mask = GENMASK(smi->num_ports - 1, 0); - else - /* For all other ports, enable itself plus the - * CPU port. - */ - mask = BIT(port) | BIT(smi->cpu_port); - - /* For each port, set the port as member of VLAN (port+1) - * and untagged, except for the CPU port: the CPU port (5) is - * member of VLAN 6 and so are ALL the other ports as well. - * Use filter 0 (no filter). - */ - dev_info(smi->dev, "VLAN%d port mask for port %d, %08x\n", - (port + 1), port, mask); - ret = rtl8366_set_vlan(smi, (port + 1), mask, mask, 0); - if (ret) - return ret; - - dev_info(smi->dev, "VLAN%d port %d, PVID set to %d\n", - (port + 1), port, (port + 1)); - ret = rtl8366_set_pvid(smi, port, (port + 1)); + ret = rtl8366_set_default_vlan_and_pvid(smi, port); if (ret) return ret; } From patchwork Tue Jun 2 20:54:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1302628 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ic1iGGw3; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49c47T22F6z9sPF for ; Wed, 3 Jun 2020 06:55:33 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728371AbgFBUzc (ORCPT ); Tue, 2 Jun 2020 16:55:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728344AbgFBUza (ORCPT ); Tue, 2 Jun 2020 16:55:30 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92140C08C5C1 for ; Tue, 2 Jun 2020 13:55:29 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id x27so7026681lfg.9 for ; Tue, 02 Jun 2020 13:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DAGbGvKTFRgsrcbWvEMabetSYmagh9X/tluny71DaEI=; b=ic1iGGw3YK+VZfTt6Cvec421xVeXIIukkEJqi6yfGCu19J6bYL1UHgU5xcoULsdj1q e+ta8yutZwixinlgzNjn+MfT4w7B6omeSUpLDUykcZ2p9FhBaa0Ej61XeSV9Nxpf2ipL wnP03n8OTVVqmhzTenEE8Lxg0r01ieFEZNFvffw0kOAlAzJwooaNlFSc7XSDBwiQRw0X UZeJS63ckco6/0VuJ3lng9tUivoUFKTzv0k57Q0zbFPk6tWipBOd3dib+s5awXzRot/e zom+KFHhTb0C2Ul+UzfXH0Ws21AmHAusKkyVJ5X2r6EKh2Kh99rlF0JM94KcIiTcKNEk dfOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DAGbGvKTFRgsrcbWvEMabetSYmagh9X/tluny71DaEI=; b=s48vVm4YEieAYlzEYerNJyNxglWOWB68drG0TqPYeFPI5jQzUfR/8O0Kvt1MdfG02y LSawQaDmWB+2IWSyOT6vPmkDZuCPTY8QUK826APr7Bdqk2K8ZC/owyXxlHj9zaICN0GV sodxxf/xZZ+ORpb5Ngz7om/A0BT/h89pT/gqLG/7rVX42e9Q+3AcMuqM78TnhgDsCDTO r/jI5xq4Mwcd0AfMzrOKaQtDkv8YW7VXelKU0xXXL856FZN5WH4Nh2rSl+H32BcjAJtA qJ6dsFGa5W7PGTeGNtlrd7um7SIMu5WS2wA/9iMksfBQbkxPoVSmX45YFHvY8zCO22MO h4jg== X-Gm-Message-State: AOAM531UtRPGm5H6oWJRbQT5tJV1z6wYpyvZ8nxtTTCWdRomyzKrN+EV iGY0YFuk2klmo71w0l989hikfQ== X-Google-Smtp-Source: ABdhPJyLY5SxKgpXxKFBFP37u12X4ZqV98OZnkLlWvWljVY4M/Q/9fzU2aEZRYZS+IqLqiPumPJ9fg== X-Received: by 2002:ac2:5466:: with SMTP id e6mr592690lfn.175.1591131328012; Tue, 02 Jun 2020 13:55:28 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-8cdb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.219.140]) by smtp.gmail.com with ESMTPSA id t5sm41962lff.39.2020.06.02.13.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 13:55:27 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, Linus Walleij , DENG Qingfang Subject: [net-next PATCH 4/5] net: dsa: rtl8366: VLAN 0 as disable tagging Date: Tue, 2 Jun 2020 22:54:55 +0200 Message-Id: <20200602205456.2392024-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602205456.2392024-1-linus.walleij@linaro.org> References: <20200602205456.2392024-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The code in net/8021q/vlan.c, vlan_device_event() sets VLAN 0 for a VLAN-capable ethernet device when it comes up. Since the RTL8366 DSA switches must have a VLAN and PVID set up for any packets to come through we have already set up default VLAN for each port as part of bringing the switch online. Make sure that setting VLAN 0 has the same effect and does not try to actually tell the hardware to use VLAN 0 on the port because that will not work. Cc: DENG Qingfang Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 65 +++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 66bd1241204c..7f0691a6da13 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -355,15 +355,25 @@ int rtl8366_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { struct realtek_smi *smi = ds->priv; + u16 vid_begin = vlan->vid_begin; + u16 vid_end = vlan->vid_end; u16 vid; int ret; - for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++) + if (vid_begin == 0) { + dev_info(smi->dev, "prepare VLAN 0 - ignored\n"); + if (vid_end == 0) + return 0; + /* Skip VLAN 0 and start with VLAN 1 */ + vid_begin = 1; + } + + for (vid = vid_begin; vid < vid_end; vid++) if (!smi->ops->is_vlan_valid(smi, vid)) return -EINVAL; dev_info(smi->dev, "prepare VLANs %04x..%04x\n", - vlan->vid_begin, vlan->vid_end); + vid_begin, vid_end); /* Enable VLAN in the hardware * FIXME: what's with this 4k business? @@ -383,27 +393,46 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port, bool untagged = !!(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED); bool pvid = !!(vlan->flags & BRIDGE_VLAN_INFO_PVID); struct realtek_smi *smi = ds->priv; + u16 vid_begin = vlan->vid_begin; + u16 vid_end = vlan->vid_end; u32 member = 0; u32 untag = 0; u16 vid; int ret; - for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++) - if (!smi->ops->is_vlan_valid(smi, vid)) + if (vid_begin == 0) { + dev_info(smi->dev, "set VLAN 0 on port %d = default VLAN\n", + port); + /* Set up default tagging */ + ret = rtl8366_set_default_vlan_and_pvid(smi, port); + if (ret) { + dev_err(smi->dev, + "error setting default VLAN on port %d\n", + port); return; + } + if (vid_end == 0) + return; + /* Skip VLAN 0 and start with VLAN 1 */ + vid_begin = 1; + } - dev_info(smi->dev, "add VLAN on port %d, %s, %s\n", - port, - untagged ? "untagged" : "tagged", - pvid ? " PVID" : "no PVID"); + for (vid = vid_begin; vid < vid_end; vid++) + if (!smi->ops->is_vlan_valid(smi, vid)) + return; if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) dev_err(smi->dev, "port is DSA or CPU port\n"); - for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { + for (vid = vid_begin; vid <= vid_end; ++vid) { int pvid_val = 0; - dev_info(smi->dev, "add VLAN %04x\n", vid); + dev_info(smi->dev, "add VLAN %04x to port %d, %s, %s\n", + vid, + port, + untagged ? "untagged" : "tagged", + pvid ? " PVID" : "no PVID"); + member |= BIT(port); if (untagged) @@ -437,15 +466,25 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { struct realtek_smi *smi = ds->priv; + u16 vid_begin = vlan->vid_begin; + u16 vid_end = vlan->vid_end; u16 vid; int ret; - dev_info(smi->dev, "del VLAN on port %d\n", port); + if (vid_begin == 0) { + dev_info(smi->dev, "remove port %d from VLAN 0 (no-op)\n", + port); + if (vid_end == 0) + return 0; + /* Skip VLAN 0 and start with VLAN 1 */ + vid_begin = 1; + } - for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { + for (vid = vid_begin; vid <= vid_end; ++vid) { int i; - dev_info(smi->dev, "del VLAN %04x\n", vid); + dev_info(smi->dev, "remove VLAN %04x from port %d\n", + vid, port); for (i = 0; i < smi->num_vlan_mc; i++) { struct rtl8366_vlan_mc vlanmc; From patchwork Tue Jun 2 20:54:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1302629 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ciTdLXtt; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49c47W2xRKz9sPF for ; Wed, 3 Jun 2020 06:55:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728380AbgFBUze (ORCPT ); Tue, 2 Jun 2020 16:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728344AbgFBUzc (ORCPT ); Tue, 2 Jun 2020 16:55:32 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1135AC08C5C0 for ; Tue, 2 Jun 2020 13:55:31 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id o9so14324317ljj.6 for ; Tue, 02 Jun 2020 13:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hm5lfx1+p9LZFBPWiYoySZYVMdJDqNUBSnzCSIT3LW0=; b=ciTdLXttCx2ZgfgwevVus/XZs4lybsIgYV3SSLzK6Z/8guZwkbqcwt9u9HQdLaF/9Q oOMMiorGT4g0izG3AIgo41UtgKzV/E+qGD/XBheEca3qZJk8y+Q0bwaBUF2KH3ViQrp9 fDScQ2l7rA2g8RVpP/nGpbHLrhOc2lYXbk7+rOIRf/dA1vO33bu/wT9voMy9AjH2bGbx kjt3c/yMnUH4x4OYhaQhZSvjKJvpyf6Nc6EN8vHnV84ztqUouYdGkRIPwqBJyflewq8l Nqjq8s1pcEqfkTYrLfuAW/mD2/PFNJBiFZPdu0Th8n0ydIgS/PVflZnxASOrnfOB8WqL DUOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hm5lfx1+p9LZFBPWiYoySZYVMdJDqNUBSnzCSIT3LW0=; b=cy6ccpve+BdrhHjO1oFa0zvtG72Gt6c5jt7dNoY3F/LCMW1X59VgdZjxLlSZZw0c4A vSNYpmRcEiU9AVJ8jQS3cgkQL3TfWdkANrU52nfu/yXj2uM8H5cEYDiSrWKGieJaG4uG qIri6zYTLfVuJpc3HG2mD4KHL1vgH0spCyiRndzS4P55S6mw2zPZxlvZC6AqkkT2HEDh ii09SrfjFTLetHFjA687kqDm4UCSY9iDxbkT7MiaNKp6UfSsA96sdaK64n/XEPAD8T3A u6cTZw2Ryxw9QBjdYclGQ71vG20NM/4kDhwBlOJd7BMm+qjI4gXi4tWD/d7j8bBAmczK 7rqw== X-Gm-Message-State: AOAM532GSIki5YvqqaulbhHCEo+f3h+BBf3ppGE4z3QcOcWpWvw5OiPD Y0OH6mUBYOE1z1RyqTLhEETE4w== X-Google-Smtp-Source: ABdhPJxss376tMIW1Cm//hbmjPgOcSJqlHsP1ZkXZCP2L5G3i82Sor0DB+IWHVedRP7BKXbjEpvNFw== X-Received: by 2002:a2e:a48d:: with SMTP id h13mr457150lji.120.1591131329540; Tue, 02 Jun 2020 13:55:29 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-8cdb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.219.140]) by smtp.gmail.com with ESMTPSA id t5sm41962lff.39.2020.06.02.13.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 13:55:29 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, Linus Walleij , DENG Qingfang Subject: [net-next PATCH 5/5] net: dsa: rtl8366: Use top VLANs for default Date: Tue, 2 Jun 2020 22:54:56 +0200 Message-Id: <20200602205456.2392024-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602205456.2392024-1-linus.walleij@linaro.org> References: <20200602205456.2392024-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The RTL8366 DSA switches will not work unless we set up a default VLAN for each port. We are currently using e.g. VLAN 1..6 for a 5-port switch as default VLANs. This is not very helpful for users, move it to allocate the top VLANs for default instead, for example on RTL8366RB there are 16 VLANs so instead of using VLAN 1..6 as default use VLAN 10..15 so VLAN 1 thru VLAN 9 is available for users. Cc: DENG Qingfang Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 7f0691a6da13..4e7562b41598 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -260,8 +260,8 @@ static int rtl8366_set_default_vlan_and_pvid(struct realtek_smi *smi, u16 vid; int ret; - /* This is the reserved default VLAN for this port */ - vid = port + 1; + /* Use the top VLANs for per-port default VLAN */ + vid = smi->num_vlan_mc - smi->num_ports + port; if (port == smi->cpu_port) /* For the CPU port, make all ports members of this