From patchwork Mon Sep 13 14:42:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509789 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp668779jao; Mon, 13 Sep 2021 08:34:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8d4cIUgyu7ZZqGeeaIXvPu310/dXzt6YVxpl6gWtr8xuTr45I9+XVpKUbvmqf+esb5vQs X-Received: by 2002:a05:6402:897:: with SMTP id e23mr13750168edy.366.1631547261531; Mon, 13 Sep 2021 08:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547261; cv=none; d=google.com; s=arc-20160816; b=EUws1e4tbRxfhQahcx0wZMqqYAJm78lMj+1H1WeZv2vMUkMamtK89VRQ3qC3SUZP0m XCVc+Dufu8EuqCaCVe89vMT0smTIDMA76/ch7G/tXtQS6lvjXmronNwmVBra293Hm+Ef 7q3THUalMWRAJ6ASvwgt9fL0ZXJiD27z2p0thsvfc2wxDBH7DUcW0vvLFjU+XzR2LzAi mYX6XT8QgjdPTkPuh+WHIWZ25UrgboX+aZGxPOnKD7h/oFZCvGi6oODGBWFWa1/T17PL 6iBs/tPyGhZS0TycAs+CjeTjYDMYXw6zgZxvwiC6w8/+oQxnIBNrhnAzJOqla2KNYA57 /gDw== 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=Segi0yvuz1/GUUIwrgvIqZ9jyUD+kdlugOeE72ywQP4=; b=LulhOIiO/RUruWt/ATkV6H4iE8lZJueVxVw/FXmNJYT+M5/PfquvngrrguZwWETnQ0 yDlXofO5ApYVDnahVQjoOxU92NL1Kc0z5lLqlEXzGkYDiX+3u4s1O4B2nWioQaBCJSh7 py1uQvpsir4id+9O8brLGAZ3KTVRkl3/QivDMeYCi+/1NP5IyBk1ErPcuTY5IQZ5dPq6 boDBNufO0x4VZs9/o8R+e6Ssjgjzlpml9xdnlD0m5iRStkZwjVTZVN+98i81guMxQoLp Yxh7V/evzvGSpHwOnCllGIFIk3Z2+8PEg6gNYSu/pgZ8hntKsEdE/cvRtiQUhbKCqQp2 49+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZPqE+Ves; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.21; Mon, 13 Sep 2021 08:34:21 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZPqE+Ves; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbhIMPff (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230080AbhIMPfZ (ORCPT ); Mon, 13 Sep 2021 11:35:25 -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 24984C12C745 for ; Mon, 13 Sep 2021 07:45:34 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id s3so17751419ljp.11 for ; Mon, 13 Sep 2021 07:45:34 -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=Segi0yvuz1/GUUIwrgvIqZ9jyUD+kdlugOeE72ywQP4=; b=ZPqE+VesFGU6Kly9pwUykJzXtz7ZqXStgDc/yREvjXjs98yrdH5KPrkzZqaVbs1BP6 dQgBPFO3zQ+u3jS8pn2AeK+r8dOcXhf/Ag0m3/4cmf02LPiEyxu6RREufd4qONmbMSjH d8qAiCpzH4X/mxUA3yN9SySgs0boVMh+0VGX2scocDT3s/0g+C8P9I2ZdHSIchQVtTUB Wnpn9zOpJGOUR4JbH6cKpjULif7B0LYPggL9KVjRld1hhi/MVQy1BrLbULeJEuwd7mvD Vsebtd5oz6mbtpcQPondaKWbcXYM4YRoO7/7dhxJ5Guol2CNKmnY7UWNUxEhZ1igLUpy 54yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Segi0yvuz1/GUUIwrgvIqZ9jyUD+kdlugOeE72ywQP4=; b=apfYAEWmpn9kOfuy/x//WS189VXY5RUN3u/nGAHpKheW3SsjYm6fgXlqmJTCO0oqSx g04Na1wHm3zbn3bP86yPulhG/LSCcsacckmoe970ughsPoXucvokJY8EGeu0SyUUO/w7 g25ksdhjJU4Q9/x849gVsx+itdNiW9OXB+/o5c4+KctNdzIX88I3ln19R0kuU0QjnJm1 DDCdyqOjj1SfVhVtev5S4a48JkUYh/EgoUgVZne5vIla3Rh6IohsUK8kMTcwIckcAUxr y9KoFJUGLovV0SKpGlgAZgJLpw3sfRgMbRc8CoU7p5l3qcKZFC/S9elTR3cuY6mwDcOa EE3w== X-Gm-Message-State: AOAM532l1qzYDW+TRa/wKPwSm2kYGK7bk1V4hbBo8hfUkR1rUnmMxFu/ Jc/6XIt1RNYhoZ+gNfmPuD1lgg== X-Received: by 2002:a2e:7d13:: with SMTP id y19mr10818111ljc.344.1631544332462; Mon, 13 Sep 2021 07:45:32 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:31 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, DENG Qingfang , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , Linus Walleij Subject: [PATCH net-next 1/8] net: dsa: rtl8366rb: Support bridge offloading Date: Mon, 13 Sep 2021 16:42:53 +0200 Message-Id: <20210913144300.1265143-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: DENG Qingfang Use port isolation registers to configure bridge offloading. Tested on the D-Link DIR-685, switching between ports and sniffing ports to make sure no packets leak. Cc: Vladimir Oltean Cc: Mauri Sandberg Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli Signed-off-by: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Fix a bug where I managed to mask off the CPU port from the ports we could access leading to numb bridge. - Reword some comments. ChangeLog v2->v3: - Parens around the (pmask) in the port isolation macro. - Do not exit join/leave functions on regmap failures, print an error and continue. - Clarify comments around the port in join/leave functions. ChangeLog v1->v2: - introduce RTL8366RB_PORT_ISO_PORTS() to shift the port mask into place so we are not confused by the enable bit. - Use this with dsa_user_ports() to isolate the CPU port from itself. --- drivers/net/dsa/rtl8366rb.c | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) -- 2.31.1 diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a89093bc6c6a..b930050cfd1b 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -300,6 +300,13 @@ #define RTL8366RB_INTERRUPT_STATUS_REG 0x0442 #define RTL8366RB_NUM_INTERRUPT 14 /* 0..13 */ +/* Port isolation registers */ +#define RTL8366RB_PORT_ISO_BASE 0x0F08 +#define RTL8366RB_PORT_ISO(pnum) (RTL8366RB_PORT_ISO_BASE + (pnum)) +#define RTL8366RB_PORT_ISO_EN BIT(0) +#define RTL8366RB_PORT_ISO_PORTS_MASK GENMASK(7, 1) +#define RTL8366RB_PORT_ISO_PORTS(pmask) ((pmask) << 1) + /* bits 0..5 enable force when cleared */ #define RTL8366RB_MAC_FORCE_CTRL_REG 0x0F11 @@ -835,6 +842,21 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; + /* Isolate all user ports so they can only send packets to itself and the CPU port */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + ret = regmap_write(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_PORTS(BIT(RTL8366RB_PORT_NUM_CPU)) | + RTL8366RB_PORT_ISO_EN); + if (ret) + return ret; + } + /* CPU port can send packets to all ports */ + ret = regmap_write(smi->map, RTL8366RB_PORT_ISO(RTL8366RB_PORT_NUM_CPU), + RTL8366RB_PORT_ISO_PORTS(dsa_user_ports(ds)) | + RTL8366RB_PORT_ISO_EN); + if (ret) + return ret; + /* Set up the "green ethernet" feature */ ret = rtl8366rb_jam_table(rtl8366rb_green_jam, ARRAY_SIZE(rtl8366rb_green_jam), smi, false); @@ -1127,6 +1149,68 @@ rtl8366rb_port_disable(struct dsa_switch *ds, int port) rb8366rb_set_port_led(smi, port, false); } +static int +rtl8366rb_port_bridge_join(struct dsa_switch *ds, int port, + struct net_device *bridge) +{ + struct realtek_smi *smi = ds->priv; + unsigned int port_bitmap = 0; + int ret, i; + + /* Loop over all other ports than the current one */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + /* Current port handled last */ + if (i == port) + continue; + /* Not on this bridge */ + if (dsa_to_port(ds, i)->bridge_dev != bridge) + continue; + /* Join this port to each other port on the bridge */ + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_PORTS(BIT(port)), + RTL8366RB_PORT_ISO_PORTS(BIT(port))); + if (ret) + dev_err(smi->dev, "failed to join port %d\n", port); + + port_bitmap |= BIT(i); + } + + /* Set the bits for the ports we can access */ + return regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(port), + RTL8366RB_PORT_ISO_PORTS(port_bitmap), + RTL8366RB_PORT_ISO_PORTS(port_bitmap)); +} + +static void +rtl8366rb_port_bridge_leave(struct dsa_switch *ds, int port, + struct net_device *bridge) +{ + struct realtek_smi *smi = ds->priv; + unsigned int port_bitmap = 0; + int ret, i; + + /* Loop over all other ports than this one */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + /* Current port handled last */ + if (i == port) + continue; + /* Not on this bridge */ + if (dsa_to_port(ds, i)->bridge_dev != bridge) + continue; + /* Remove this port from any other port on the bridge */ + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_PORTS(BIT(port)), 0); + if (ret) + dev_err(smi->dev, "failed to leave port %d\n", port); + + port_bitmap |= BIT(i); + } + + /* Clear the bits for the ports we can not access, leave ourselves */ + regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(port), + RTL8366RB_PORT_ISO_PORTS(port_bitmap), 0); +} + static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct realtek_smi *smi = ds->priv; @@ -1510,6 +1594,8 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .get_strings = rtl8366_get_strings, .get_ethtool_stats = rtl8366_get_ethtool_stats, .get_sset_count = rtl8366_get_sset_count, + .port_bridge_join = rtl8366rb_port_bridge_join, + .port_bridge_leave = rtl8366rb_port_bridge_leave, .port_vlan_filtering = rtl8366_vlan_filtering, .port_vlan_add = rtl8366_vlan_add, .port_vlan_del = rtl8366_vlan_del, From patchwork Mon Sep 13 14:42:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509790 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp668788jao; Mon, 13 Sep 2021 08:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPZlque5pujGedS1MlQEQ/6NUs9pUyUhxVS0+tFkwZ0sRg42WfRISEUDjwkbxFLk6vIvsr X-Received: by 2002:a05:6402:14c3:: with SMTP id f3mr14010166edx.312.1631547262568; Mon, 13 Sep 2021 08:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547262; cv=none; d=google.com; s=arc-20160816; b=rU9JX2Wv+bUPrr9meuw9/pnhm636STXOFVSbtvFQgBilCP28C+fcsCSOHc4h4grJZv mvSpF2jGPQCNQsrBmsG2GbCnM79Tbup8LwypVOiNnpzn2OuJysjBYnH5Gq3QCHFhmmKw HlOllheCTbgxnLeeDwhrFhNvLVqROk+P6uGC09/2+m+u/LAMbZqyxCVhlBWo7vuitDsv 1PdeI+p9MINQKOhYao5YUV1777zr2UGQxGtNd50W8RTLtsbVZe+fUDqyFQicirhSphzF pWhU9X/nALYzAplTJ7t4sUkEUjzD1eaLFCCzydbsNi/7wBnfVw0tv1R4e/4NLVcOWjWz 40ZQ== 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=YNvGPe0Dq+6R5la8j1qftPJtr3gJu4sNPynYBEMsuh0=; b=JDYBB/VDRpAzIxpVLva6rS1bo2nxtwOkit3ZITQjEC16Vtv7zI8/Cz60T5C5Y9P5ea WgNLNZB1z4IFzWlfQWA35iRQIGxttVsMXxlMjYbM/zFA5Uc+Q3ThDsTIzHzKQmgFWNWy +UBNHeRqqi1LD42ShVvdqlbIfPeZbtx04eLsLPi3qNUFCsD2u2GCmilkRYFvRtH+m9bk phLNCUSxFudGqG4YzTXnRjUzPhlRz21znwT5N+gJzQKSC6NIp9/5XjRIAC2m/PbMy93p SWYbiPynQtWO9/JMdGwB/FChCAjQ/dvxEXucNf+zY3u97Px5JT16lRoNuSqI23S2SiD2 GTGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmYBJUcX; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.22; Mon, 13 Sep 2021 08:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmYBJUcX; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240932AbhIMPfh (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233162AbhIMPf0 (ORCPT ); Mon, 13 Sep 2021 11:35:26 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6672EC12C74C for ; Mon, 13 Sep 2021 07:45:36 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id s12so17845609ljg.0 for ; Mon, 13 Sep 2021 07:45:36 -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=YNvGPe0Dq+6R5la8j1qftPJtr3gJu4sNPynYBEMsuh0=; b=EmYBJUcXWwb3PoCDeCt8UrFdPtMwJ9RW5MD/Kdz37bvUEcrNFPvZ9KFgNvSSDufN9l PCBc9iN09/6aGspKx1kbSlW6EKkUbbL3wlGL7x+A552PWbBTK8iM3CYXckh/8lBWA9GM 8efrVIKiWKNM5HsHi/9U/8OKJ2Uhxw1hBeSL30SuDD2tgaNMBFiBxLcJS9mw8Kd5aCP0 aI+xItrm148Aq8LWcs5R4Y6p2gLNYDIW6Novj7/AP5PpPijpT73t1TK/gJK6ROuHA0Nu YQ8fWTKoXPpLxgwNF1LS2Lf5S0YYn47SnJwFiXT11GQak43hc8TKkAHD4NMlMNDRiuVo VNnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YNvGPe0Dq+6R5la8j1qftPJtr3gJu4sNPynYBEMsuh0=; b=6G6yCIdPJrAy/OSJQV0EK96rIJo6d8jGI67+Ic2uwW4mX/GAHnFTT7nsCepjm3dPkq wTbooz9gZBaGeTSOGCyzqKSeeskDpstEj1HTnZ/0/mUaw3GimZ+CnoxTI8K4+BihjcPv 9fvU8yLMMWssKC9hVf9dAF0z3GldSHDF77/GfnERgBMorpfA0N0a0RhKsr271BEqRr0z QOBG6yjeIvpOtjYSW3FuoOjLHkJ27u+dYMhVpUIBxLRr2+JilicjoKUIiE/ESBisA4P5 yMC4C0qKDQ7+8SEJKYu+VF7YXT4C0NqTvPhegrivdruhS3Zq3Z8loXfMv0eU+e7i9pAP 8Cvg== X-Gm-Message-State: AOAM5335fcuMJr+PqTwOseg1VRPaWbcwFGD+6DSEhOwORdu95d3YCZ2A GQP+8TWMInq9qQ3udOB8+zAvVw== X-Received: by 2002:a2e:9549:: with SMTP id t9mr10789580ljh.404.1631544334724; Mon, 13 Sep 2021 07:45:34 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:34 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , DENG Qingfang , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next 2/8] net: dsa: rtl8366: Drop custom VLAN set-up Date: Mon, 13 Sep 2021 16:42:54 +0200 Message-Id: <20210913144300.1265143-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This hacky default VLAN setup was done in order to direct packets to the right ports and provide port isolation, both which we now support properly using custom tags and proper bridge port isolation. We can drop the custom VLAN code and leave all VLAN handling alone, as users expect things to be. We can also drop ds->configure_vlan_while_not_filtering = false; and let the core deal with any VLANs it wants. Cc: Mauri Sandberg Cc: DENG Qingfang Reviewed-by: Vladimir Oltean Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - No changes ChangeLog v2->v3: - Collect a bunch of reviewed-by tags ChangeLog v1->v2: - No changes. --- drivers/net/dsa/realtek-smi-core.h | 1 - drivers/net/dsa/rtl8366.c | 48 ------------------------------ drivers/net/dsa/rtl8366rb.c | 4 +-- 3 files changed, 1 insertion(+), 52 deletions(-) -- 2.31.1 diff --git a/drivers/net/dsa/realtek-smi-core.h b/drivers/net/dsa/realtek-smi-core.h index fcf465f7f922..c8fbd7b9fd0b 100644 --- a/drivers/net/dsa/realtek-smi-core.h +++ b/drivers/net/dsa/realtek-smi-core.h @@ -129,7 +129,6 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port, int rtl8366_enable_vlan4k(struct realtek_smi *smi, bool enable); int rtl8366_enable_vlan(struct realtek_smi *smi, bool enable); int rtl8366_reset_vlan(struct realtek_smi *smi); -int rtl8366_init_vlan(struct realtek_smi *smi); int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, struct netlink_ext_ack *extack); int rtl8366_vlan_add(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 75897a369096..59c5bc4f7b71 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -292,54 +292,6 @@ int rtl8366_reset_vlan(struct realtek_smi *smi) } EXPORT_SYMBOL_GPL(rtl8366_reset_vlan); -int rtl8366_init_vlan(struct realtek_smi *smi) -{ - int port; - int ret; - - ret = rtl8366_reset_vlan(smi); - if (ret) - return ret; - - /* Loop over the available ports, for each port, associate - * 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((int)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)); - if (ret) - return ret; - } - - return rtl8366_enable_vlan(smi, true); -} -EXPORT_SYMBOL_GPL(rtl8366_init_vlan); - int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, struct netlink_ext_ack *extack) { diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index b930050cfd1b..a5b7d7ff8884 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -985,7 +985,7 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return ret; } - ret = rtl8366_init_vlan(smi); + ret = rtl8366_reset_vlan(smi); if (ret) return ret; @@ -999,8 +999,6 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return -ENODEV; } - ds->configure_vlan_while_not_filtering = false; - return 0; } From patchwork Mon Sep 13 14:42:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509791 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp668845jao; Mon, 13 Sep 2021 08:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpfNVdNsh08TmvBQ2WtBFtNd0pg2BIkFlkr4gM7vvp2vmnES6PLMrnf+ep0oEc09aqP2fM X-Received: by 2002:a17:906:56cc:: with SMTP id an12mr13377481ejc.456.1631547266716; Mon, 13 Sep 2021 08:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547266; cv=none; d=google.com; s=arc-20160816; b=y+w5oNPjJg9mMTlD0FGydJfj8dn/hEf2xtN2lsPiR7JwqagoJEJDCPRtZVDXScA2nV XV4g69kCfPSJ5/asfh5uJCvD1H2cmOvRFLsuRY4jrnNszkF/oVHzWbQwwIUpxJa97dDC Y2MYIAYFBdUil3ZKMT3rIvoaUfMlf6mRNjIH19kv/0fwjUbMBpAdamYpe4mv4/RFxmP9 +3qIbH7oF7UJgRma0zXEUVV0HAW1JboAM52UxgvIzu5yjVNAYAaB6N1+v54H27RqwQoK jl/fAd1aCTGmpHZ6HT9ZDTkz4TqL/TvnhuEDEkOXmEksrn6z3Ien44OH1PEpc7L2RPLg 6yoQ== 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=SCiUagspf3BSHg075BuKPVGIKuOKVCl19l+q5xDaUhI=; b=p+K6FPTs1YZRaNHsNwfHm5jp5sR2rNXLkIAe8pdH9SKS+cBBJLttDd5jNNwZjcdnqN hqdVvu48dFw0byK5+JcN9YWXsZ1Ph+COUYU1QOPun6c1npVGGd7ExutQ3IoHiYednajI kwzg66Ucvg3lPyRKvlbWb0xsRp+IgL/SIr8GKRX6UIHStihuB9gu5/CC7Hual8rkjDu+ ndezn5GVRMVxg2hchCFOOQL6rgZ9SYZ7o1yapFK+6hnxIHZ/i+0c4OErZL2gLfNqa1Zg hRl6dZvtpukO7pMyzV4uB2voLZt0eCLR25z6R9G7LIMq1Wode5T6bHT8AydqM2tjKOuu uDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yfmwa744; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.26; Mon, 13 Sep 2021 08:34:26 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yfmwa744; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242049AbhIMPfk (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235053AbhIMPf1 (ORCPT ); Mon, 13 Sep 2021 11:35:27 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8795C12C750 for ; Mon, 13 Sep 2021 07:45:37 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id q21so17790047ljj.6 for ; Mon, 13 Sep 2021 07:45:37 -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=SCiUagspf3BSHg075BuKPVGIKuOKVCl19l+q5xDaUhI=; b=Yfmwa744j9NOqudlSNaUEbZ+2fNINnDndc4f/C+7ndyDdf5a7jb6fp1jahmd8S4Krz CwGGsevt5uzsxG4RqfNddlGdGpHFCuOEKfw2avsqpbXeQxN1FQa7qb8OIWRH1Dw4kZZ4 TQPks7zP8uwBliHDOPjM5v1PHt4CuLE8Na4oyPEDRLNS0FvwsZRZg7DNuXJuWHqueP8O snusl5+uhOD0idQajGtfrynpM8v1YAUh8XU8eUjWv80Oou0UoHKTr3J/06IALmB429In Ng8cyDNpti+fc/SXZOb0pJ2vKI7jcWDiN0xoossChuMosdCpJxbGtfAWTY7CXg/+NNhe M9sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SCiUagspf3BSHg075BuKPVGIKuOKVCl19l+q5xDaUhI=; b=wbJk9wZOa7mX66ieAEWXmgRgn4dpla/MWQqpwOUutwww9Yxhhx+Po3qwbduHBS96hy YNPDhcNJ5CL2qgbrZe13taCcZlOPHINsBWk9EZAR5BKutEfMi01nQqL88TDaRLIIgrsS BFZL/jDOGkuv3ShzX7Btv1vU/Z6m7ZA/pSCy2SySfz2bUEQhP0Snp5deJcMEnvlLAUpF zTocyw6nJogWfVefPkvlt9SQSvMxZ+5lbioNjGKvZIxgaaU1YWw9zdg3+PqptVYgYQZX VDxXnK2qsZxHZkr2DWyYtGNvQEGdG9CcpscbQHMiOM3o56dRHU2vMWRqLLF2SenXLQ2S Q9jQ== X-Gm-Message-State: AOAM530Xy+YJhfrAwNRgcUZ9e6zKiV7ZF6z34Y//sylI4LrHWxWtT9OM ZFM4Ghr5iEEy5/iMQHQ9cUj2uA== X-Received: by 2002:a2e:bc1a:: with SMTP id b26mr11010558ljf.218.1631544336152; Mon, 13 Sep 2021 07:45:36 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:35 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , DENG Qingfang Subject: [PATCH net-next 3/8] net: dsa: rtl8366rb: Rewrite weird VLAN filering enablement Date: Mon, 13 Sep 2021 16:42:55 +0200 Message-Id: <20210913144300.1265143-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org While we were defining one VLAN per port for isolating the ports the port_vlan_filtering() callback was implemented to enable a VLAN on the port + 1. This function makes no sense, not only is it incomplete as it only enables the VLAN, it doesn't do what the callback is supposed to do, which is to selectively enable and disable filtering on a certain port. Implement the correct callback: we have two registers dealing with filtering on the RTL9366RB, so we implement an ASIC-specific callback, describe these and activate both. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Alvin Šipraga Cc: Florian Fainelli Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v4: - New patch after discovering that this weirdness of mine is causing problems. --- drivers/net/dsa/realtek-smi-core.h | 2 -- drivers/net/dsa/rtl8366.c | 35 ----------------------------- drivers/net/dsa/rtl8366rb.c | 36 +++++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 43 deletions(-) -- 2.31.1 diff --git a/drivers/net/dsa/realtek-smi-core.h b/drivers/net/dsa/realtek-smi-core.h index c8fbd7b9fd0b..214f710d7dd5 100644 --- a/drivers/net/dsa/realtek-smi-core.h +++ b/drivers/net/dsa/realtek-smi-core.h @@ -129,8 +129,6 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port, int rtl8366_enable_vlan4k(struct realtek_smi *smi, bool enable); int rtl8366_enable_vlan(struct realtek_smi *smi, bool enable); int rtl8366_reset_vlan(struct realtek_smi *smi); -int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, - struct netlink_ext_ack *extack); int rtl8366_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack); diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 59c5bc4f7b71..0672dd56c698 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -292,41 +292,6 @@ int rtl8366_reset_vlan(struct realtek_smi *smi) } EXPORT_SYMBOL_GPL(rtl8366_reset_vlan); -int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, - struct netlink_ext_ack *extack) -{ - struct realtek_smi *smi = ds->priv; - struct rtl8366_vlan_4k vlan4k; - int ret; - - /* Use VLAN nr port + 1 since VLAN0 is not valid */ - if (!smi->ops->is_vlan_valid(smi, port + 1)) - return -EINVAL; - - dev_info(smi->dev, "%s filtering on port %d\n", - vlan_filtering ? "enable" : "disable", - port); - - /* TODO: - * The hardware support filter ID (FID) 0..7, I have no clue how to - * support this in the driver when the callback only says on/off. - */ - ret = smi->ops->get_vlan_4k(smi, port + 1, &vlan4k); - if (ret) - return ret; - - /* Just set the filter to FID 1 for now then */ - ret = rtl8366_set_vlan(smi, port + 1, - vlan4k.member, - vlan4k.untag, - 1); - if (ret) - return ret; - - return 0; -} -EXPORT_SYMBOL_GPL(rtl8366_vlan_filtering); - int rtl8366_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a5b7d7ff8884..6c35e1ed49aa 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -143,6 +143,8 @@ #define RTL8366RB_PHY_NO_OFFSET 9 #define RTL8366RB_PHY_NO_MASK (0x1f << 9) +/* VLAN Ingress Control Register */ +#define RTL8366RB_VLAN_INGRESS_CTRL1_REG 0x037E #define RTL8366RB_VLAN_INGRESS_CTRL2_REG 0x037f /* LED control registers */ @@ -933,11 +935,13 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; - /* Discard VLAN tagged packets if the port is not a member of - * the VLAN with which the packets is associated. - */ + /* Accept all packets by default, we enable filtering on-demand */ + ret = regmap_write(smi->map, RTL8366RB_VLAN_INGRESS_CTRL1_REG, + 0); + if (ret) + return ret; ret = regmap_write(smi->map, RTL8366RB_VLAN_INGRESS_CTRL2_REG, - RTL8366RB_PORT_ALL); + 0); if (ret) return ret; @@ -1209,6 +1213,26 @@ rtl8366rb_port_bridge_leave(struct dsa_switch *ds, int port, RTL8366RB_PORT_ISO_PORTS(port_bitmap), 0); } +static int rtl8366rb_vlan_filtering(struct dsa_switch *ds, int port, + bool vlan_filtering, + struct netlink_ext_ack *extack) +{ + struct realtek_smi *smi = ds->priv; + int ret; + + dev_dbg(smi->dev, "port %d: %s VLAN filtering\n", port, + vlan_filtering ? "enable" : "disable"); + + /* Any incoming frames without VID (untagged) will be dropped */ + ret = regmap_update_bits(smi->map, RTL8366RB_VLAN_INGRESS_CTRL1_REG, + BIT(port), vlan_filtering ? BIT(port) : 0); + if (ret) + return ret; + /* If the port is not in the member set, the frame will be dropped */ + return regmap_update_bits(smi->map, RTL8366RB_VLAN_INGRESS_CTRL2_REG, + BIT(port), vlan_filtering ? BIT(port) : 0); +} + static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct realtek_smi *smi = ds->priv; @@ -1437,7 +1461,7 @@ static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan) if (smi->vlan4k_enabled) max = RTL8366RB_NUM_VIDS - 1; - if (vlan == 0 || vlan > max) + if (vlan > max) return false; return true; @@ -1594,7 +1618,7 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .get_sset_count = rtl8366_get_sset_count, .port_bridge_join = rtl8366rb_port_bridge_join, .port_bridge_leave = rtl8366rb_port_bridge_leave, - .port_vlan_filtering = rtl8366_vlan_filtering, + .port_vlan_filtering = rtl8366rb_vlan_filtering, .port_vlan_add = rtl8366_vlan_add, .port_vlan_del = rtl8366_vlan_del, .port_enable = rtl8366rb_port_enable, From patchwork Mon Sep 13 14:42:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509792 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp668865jao; Mon, 13 Sep 2021 08:34:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxObstdazf5LQ799Zh/a95umndBZpBYa2ho7AWLUw6oi4H2MPceE75r7M04YNKwGtdVe6Ln X-Received: by 2002:a17:906:f11:: with SMTP id z17mr13550826eji.385.1631547268623; Mon, 13 Sep 2021 08:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547268; cv=none; d=google.com; s=arc-20160816; b=CZHUkq5I+MH88hzjTixVavcFtT2bnIWEaMskSucV8NOJUBlSMFFiMH4CfwSqjPo2Gs 38pS1QHx1IK0745qMeGxzfPSAujx6NSnpWKf7tHaNQd1S4yZcxkBT54SiHsPjQIqFqyA Iru8rr+fpSHBv38jg5npIFbdupsvP0YhjGgRcpACwgp7Ej/8nOiwBe3eqwo7dQp0qB6/ qSLZyjS47AVM5J+5J3FqS0d6uPlPDySG20L9xX6BIkXurbbjtuwv8dVkz6ftsydU9m2y hEBhKZ4hWlCSnRTqP5fMDRdMbaqJciYlrKutWTdof1W/ZwtS2m8/Gv8yqgncTeOLzAaj DtHQ== 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=rl1GbWjgXVNoK+lm+llrr8EUhw0/WxVcLR5JyBH74Jo=; b=vH0ZMwj2F+sMifZtlvBvH+7Zk5qp9+HDjtmH3xjq9MdAIE0YqCPPQ89CWffKuEFC94 nvbZy2tV/dIrH37+Awx3aqzSd/PetZXYfOOSt16CFKcL3mEy8pGjykYzIWEGBxM55JlY l++2Xgu5jVyo0mSuqisJ0ikVjAD1Qoh9UCsLSkhOcSNX2GsD9FmZ30oivado0PEnsxfq 6SxbCRVFLojDs2ufaMDz6aWEEnehCHaaHi9blCQiR6CIEsgBPFVB1z1Z0VTck2IfQ+P1 Mspg2+AsUoasz55bKmLLbqawSE6mPzFJ6PW++lcPUb3AUwx8nOQUoOEMZrtamedN8MCR 93tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fvBbLhTm; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.28; Mon, 13 Sep 2021 08:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fvBbLhTm; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242298AbhIMPfn (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237922AbhIMPf2 (ORCPT ); Mon, 13 Sep 2021 11:35:28 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E82D6C028BEC for ; Mon, 13 Sep 2021 07:45:40 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id s10so21623203lfr.11 for ; Mon, 13 Sep 2021 07:45:40 -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=rl1GbWjgXVNoK+lm+llrr8EUhw0/WxVcLR5JyBH74Jo=; b=fvBbLhTmvrjsv6008yISDXLZ8bxvuq5Z1YRK4b1wu4yXmtYLvjZ9CGr56IRUKVrmIx mMtElrRHZm3wGcUpt2R4A3VF5h2XPGB1g5B6BmWI5cYnuITAfKcJWFjTcBFmAPFW7f2b CwOKS4ePguXVXeQQ5tynnbWphorBjrAEIjK2puk+y1LaN7adH1pyF+aWQ7jwRaQhddSG zEMt8E7W1CN7ffpdZ58+Oc3RisSTL2UlUsSvcg84m5pBeZn6wAOT/GooLEWC3RgG+l1G /ZwH6ufgsO7DsYGYvrKOfIGF7cuA8qSU7zk2BMCi2uDonxxeYJSp6XvK3/xjw39MMAay aa7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rl1GbWjgXVNoK+lm+llrr8EUhw0/WxVcLR5JyBH74Jo=; b=kaGKjiRT7n4P0FbAf8NAKYUxbSY7r5q9Oy+fhdhPf9SJZqk7nwF73Li4ZQKyg+Eyf2 qob4pWiNXqFnjRnM3Cxt2r8gXoaPqx4PXAW/Xlc83lpMpRAAr3GymQqpfe6cq8CfW0J2 s7hZG+7prcObAbLuEcxEAyVkk+Uazxyx7R9oCfuV6brugBCCRvsSfFKGcxj3azknW9Y2 8JllMHeUugIWlkBKy0Z8Dw4GSkF7TYk1TL6zNp/Wh+K1QNg/RKmy9zfGbgi57ysgY4C9 4TY8oT9O0FytJ6LO4vf4qaiOstwr0vlxgZs2VjjJLr85hnvlY4wkixXh7UX4HnRaNlsv 7BKA== X-Gm-Message-State: AOAM5321HeIpE8MzslxAPMrP59c6Vt6fNL+1ZDHE/6cl3LlRwK7hXXTx Y/k7sNs/RJ7xcIlmCvYIIBG5LQ== X-Received: by 2002:ac2:599b:: with SMTP id w27mr9224290lfn.0.1631544337834; Mon, 13 Sep 2021 07:45:37 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:37 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , DENG Qingfang Subject: [PATCH net-next 4/8] net: dsa: rtl8366rb: Always treat VLAN 0 as untagged Date: Mon, 13 Sep 2021 16:42:56 +0200 Message-Id: <20210913144300.1265143-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org VLAN 0 shall always be treated as untagged, as per example from other drivers (I guess from the spec). Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Alvin Šipraga Cc: Florian Fainelli Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v4: - New patch after noting that other drivers always sets VLAN 0 as untagged. --- drivers/net/dsa/rtl8366.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.31.1 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 0672dd56c698..fae14c448fe4 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -308,6 +308,11 @@ int rtl8366_vlan_add(struct dsa_switch *ds, int port, return -EINVAL; } + /* Note that VLAN 0 shall always be treated as untagged */ + if (vlan->vid == 0) + untagged = true; + + /* Enable VLAN in the hardware * FIXME: what's with this 4k business? * Just rtl8366_enable_vlan() seems inconclusive. From patchwork Mon Sep 13 14:42:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509793 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp668896jao; Mon, 13 Sep 2021 08:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOB7pTwPChlZg9pUEUp0+OTt2BYvexI+Xhf7/x0F+JGPeNH0bu4d6DtLduidNoA0E+3ZYM X-Received: by 2002:a17:906:38db:: with SMTP id r27mr13421813ejd.338.1631547270334; Mon, 13 Sep 2021 08:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547270; cv=none; d=google.com; s=arc-20160816; b=FSiCbC34cgiUiPdCn/vW+0WB8foDi0VmAAVKcL9TdCc+POWSOHeFEeZN1XevwavaaY JwGJ8OlrNevNNdUVFZlkD1mLTGf4J/i2msIVVDcZzBthhxAKUaDIP4TJ5CuFiagQhXBM SvarzROu8R76Hcn4EdnKvMWhji34aZ69ccJ/GjgK70S4i1zj+cwitQFAKrwla6ABT/24 hVjGMno+r3s4DZUOgzDWNL0xfHoXK9R2njK8gzZakle4h0g4OQaxtDzdMEBwrBCkKlZ8 k4Icnh/HoPTtSpzKJFLyIO9uxKAq6NaFe3fMhETzFDOXBWM6CjbkCplefvKcCLKXXeCX vi2A== 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=xd3umkjYwct/iEHcKdn/6TrUhyPynjPbO3LzmHR3PlQ=; b=Jv1AzZIGsaa8Ufd48dh6LAXIsbjDJKFAmaGk6qmwrEcaQA5Bm8HR75PQgA4O24d5M2 xps4PqH7wY9QXR/PPP/YZOF+IRzGVWY20zBxICUoWjmWVKt66Z2zpbhqKMsx2IwZuUxK jcu027nN00QglNuFe/XbXrscHrrlZVH4Fn/I4KgVhs06gJ/nr990nZKvn2fQd2WRPeE2 nKMRAyvZ5XJqE0RrwQWjNIHHnrM5tj8uA4GdzdEiptLhE54J8RI1pzcKxyuFwD2ZjFbD BT5veK2f66U5AUFd+JTcT5QUTCVCAVqMWm9vTmljcYw1z3PilsNx8y4gEcQ+jgtChlp1 pHpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FGJxvDqc; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.30; Mon, 13 Sep 2021 08:34:30 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FGJxvDqc; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbhIMPfo (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239310AbhIMPf2 (ORCPT ); Mon, 13 Sep 2021 11:35:28 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D52C12C757 for ; Mon, 13 Sep 2021 07:45:41 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id g1so10172539lfj.12 for ; Mon, 13 Sep 2021 07:45:41 -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=xd3umkjYwct/iEHcKdn/6TrUhyPynjPbO3LzmHR3PlQ=; b=FGJxvDqcWqiPbYFwhIrJ0dK0VR2FrCiR+FMhJpzBxx3KpTQ92J+P+Btd9IX3iHDpKN XNd0A3/tcrxnrP6AZ6y0w33syHd1m9xwQFg/nx2tsJwlGc0pB3YPr2TnFiEVNeWpG6ML 6Ub+akRJbSUbNlpwl/U8ALkJvRNGLg8LDO1NTe3fI/Wn5LJXxKTsMph97Nptg8euRCXA Q2LrJ8vh9xuFkjAw7ss4ICmkkCSIiUWzv/1WcFGkZqv7XBRBovLZC1bmHML27nnTElh4 mSS6H51EWXevgXJaV4EQM+np1tMbfkav1yCEqIKwwfWfN6u/f9arviRwo4KiNmajtX0P 55eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xd3umkjYwct/iEHcKdn/6TrUhyPynjPbO3LzmHR3PlQ=; b=0uaTSwLRX1cEuENM+BAERymul+qKmUHnwahcDS/zFZf+SqNDdV+t4rx7ZlIIvJ7t4C BwDw7w9E2MprRmvVI/JsXxKwafpdMOuXOxtr0S5Fmm85m8zYR/59SQ+VukrCNwufxG0n dG+q/sZ7pvAT/hWB8IiuQqdn1DPjvIXLvPRqRaVy8se36XXzFdWYBCB1Xos8Y7UqRAua DDTvlv442ZBpixiLA0woU/G3aQbKbmoPRdxIhOHVDqyGF9bF0hDk1eUNR/ZgX/vgcuuG 16xpZ3KIsVw1dh1m3ud3/ztfuEv8ziPDgAf2CDVo5RvCOTpqIEUz5tOdYwB/ovD23Lk4 MUHw== X-Gm-Message-State: AOAM533jsXNP3lkeQ8A4959+BlN+IxEeeTirRmIgIUaxBCwd8EESgZbM dYFqt/3kyEP7QrK5F82nrwD1Sg== X-Received: by 2002:a19:c145:: with SMTP id r66mr9687199lff.563.1631544339476; Mon, 13 Sep 2021 07:45:39 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:39 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , DENG Qingfang Subject: [PATCH net-next 5/8] net: dsa: rtl8366: Disable "4K" VLANs Date: Mon, 13 Sep 2021 16:42:57 +0200 Message-Id: <20210913144300.1265143-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I have to disable this feature to have working VLANs on the RTL8366RB at least, probably on all of them. It appears that the very custom VLAN set-up was using this feature by setting up one VLAN per port for a reason: when using "4K" VLAN, every frame transmitted by the switch MUST have a VLAN tag. This is the reason that every port had its own VLAN, including the CPU port, and all of them had PVID turned on: this way every frame going in or out of the switch will indeed have a VLAN tag. However the way Linux userspace like to use VLANs such as by default assigning all ports on a bridge to the same VLAN this does not work at all because PVID is not set for these, and all packets get lost. Therefore we have to do with 16 VLAN for now, the "4K" 4096 VLAN feature is clearly only for switches in environments where everything is a VLAN. This was discovered when testing with OpenWrt that join the LAN ports lan0 ... lan3 into a bridge and then assign each of them into VLAN 1 with PVID set on each port: without this patch this will not work and the bridge goes numb. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Alvin Šipraga Cc: Florian Fainelli Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v4: - New patch after discovering that the VLAN configuration in OpenWrt was not working. --- drivers/net/dsa/rtl8366.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.31.1 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index fae14c448fe4..9652323167c2 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -313,13 +313,15 @@ int rtl8366_vlan_add(struct dsa_switch *ds, int port, untagged = true; - /* Enable VLAN in the hardware - * FIXME: what's with this 4k business? - * Just rtl8366_enable_vlan() seems inconclusive. + /* Enable VLAN in the hardware, do NOT enable VLAN4K, because the + * 4K VLAN will activate a 4096 entries VID table, but has the side + * effect that every processed frame MUST have a VID, meaning non-VLAN + * traffic will now work at all. So we will let the 16 VLAN entries + * suffice. */ - ret = rtl8366_enable_vlan4k(smi, true); + ret = rtl8366_enable_vlan(smi, true); if (ret) { - NL_SET_ERR_MSG_MOD(extack, "Failed to enable VLAN 4K"); + NL_SET_ERR_MSG_MOD(extack, "Failed to enable VLAN"); return ret; } From patchwork Mon Sep 13 14:42:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509795 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp669145jao; Mon, 13 Sep 2021 08:34:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyghnhAq4KuA2YoKeVosIOaEQkcEvCc1E7tqgwoXpbU6HpHR7UqUsI4O9i0kux90a2gpE/A X-Received: by 2002:a05:6402:350d:: with SMTP id b13mr13729103edd.1.1631547289116; Mon, 13 Sep 2021 08:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547289; cv=none; d=google.com; s=arc-20160816; b=gR//g83giLG2jZUXYlrn+pByohLgprVUrbk7PGftIvBC6ZB8YfSja2HhqPOXB3b76E KXPfDfqdTS60PQybyHgz7e4u5Ho0bKGuStGkpHQ1u8tNaIDEIP1frhPQrV2l8Spay1KH ZRSNcEtxu9gyInI5KwpgLp6PQR7Ok0Z7rPsJjOK7pZ14ngvLIh3dL+TRgDf3ssSZhRtS YmNVewHBRWZoeAIF90EUp98hWxJ3yYFwVd0tFrz5uHF+J7CAfDgJe49lQGwigUjqVHX6 n0pruuXr2UGl37Z2zHLGQ6IsSqobmuxxKQLiduQ3QSw04QDyjgYsxgMinnFRK9SDRioQ Ru5g== 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=LYtrDDoObxsNg9Qa7tHy5LD0Y+VUcx6GaTlCkfBdhkQ=; b=lN1xRTNbqLqD9/NISO1BlOzXDiTW7Y5zNjgC8tgyL9QTYTzoP/WpeXwVENG+sHPKLL Q1EqC9CNWmvDUE2sdQcBHNJYdp5ZgZ9BFzmYY0I2rVjJawjpRxomN9Ea4r+9Z+eFeddL Npy/9XoGbQvb6q64Hzwp2ZxE02NarTcZ4JS0vzWzZRTPUGO2QKIlRfORxFzGpaaiTe53 SfI8Mss/z8YPPjcVzgAlSgLKGP1XPjT3Ls0ck3ntmVdg8rYB51hverhD0gMsDpcVk68B hdpjjkgkTxfRpHQYpuRV7H34kRDmljUHkSRXZ8NnIvXYVs37O8mNTxUzYGXj+frQXthf DYoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YL6zKWNz; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.48; Mon, 13 Sep 2021 08:34:49 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YL6zKWNz; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231605AbhIMPf4 (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240718AbhIMPfa (ORCPT ); Mon, 13 Sep 2021 11:35:30 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB50C12C75A for ; Mon, 13 Sep 2021 07:45:44 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id a4so21636812lfg.8 for ; Mon, 13 Sep 2021 07:45:44 -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=LYtrDDoObxsNg9Qa7tHy5LD0Y+VUcx6GaTlCkfBdhkQ=; b=YL6zKWNz3wU/ISXiZadwLvMF586w0XIR0RTFi2tr9IPTOGvvOrF2Gt+TWW3RuXQvRR eobC2QEIK+DsCqtLcXgf+a2B28zMC5vOP/E0P4f0kvWkvFNfqyDwssQ/USmSfBik5XAH IU8Cys0uNY/eY11UFlDlDCuVsge/sK5iS/QexhK7jJ9ukkFSUMHs/8LlZZBlyJjoFNkh OxCfb6OZQsNXN4U2wm0OeQUy0D/WZHbWIkH+xp1ghf0Im7dWbQlRODEtQroqsLV2tXzC 0DUqU5LVebvRzg04aJ6+6zrZfSYaptMMqrsUF1sJRUvUnjJXHbjCjzmgydVA7GOtKPuG 5n0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LYtrDDoObxsNg9Qa7tHy5LD0Y+VUcx6GaTlCkfBdhkQ=; b=Xadlf0LmuMpOFmUyjywc1Be6/aJcVk96Sd1nid0D07cCO/zK1X67HsuphLSF1qFGy+ /f2WdGskjfDaDNoVv3EHvZoSOPYKmvS+hc462mdQThCP4oN7cySBuovXUNGlHSzsPc/s s4WVh/mRKw84v5cbPDMfEOPoGQWsaMTFtYV4p2tmv444BqUjLV5Z/bifQnZ/KRmdz80F Wg2/iXPKG3XhOC1QOdyegTmz+a/vSW809PIJUIgP05Wz0ftUd0erJgq4f8vMP7Np/2KP du3qTXRLIsZM9MQZSmZDk5Cr8oSlUHyINKZ8YkWJrwvLESOZHy9EHXfcJjpDILX10yR8 h7Jg== X-Gm-Message-State: AOAM530TnkV0fIPoT0IXDbdKR38X54Eq6mz2HHDD5G5Zoqqk/0Ee3I+J VJkkd0i6B654Pa7T9CW1Vl1kCw== X-Received: by 2002:a05:6512:903:: with SMTP id e3mr7707690lft.668.1631544341227; Mon, 13 Sep 2021 07:45:41 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:40 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , DENG Qingfang Subject: [PATCH net-next 6/8] net: dsa: rtl8366rb: Fix off-by-one bug Date: Mon, 13 Sep 2021 16:42:58 +0200 Message-Id: <20210913144300.1265143-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The max VLAN number with non-4K VLAN activated is 15, and the range is 0..15. Not 16. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Alvin Šipraga Cc: Florian Fainelli Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v4: - New patch for a bug discovered when fixing the other issues. --- drivers/net/dsa/rtl8366rb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.31.1 diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index 6c35e1ed49aa..dfc8ef470972 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -1456,7 +1456,7 @@ static int rtl8366rb_set_mc_index(struct realtek_smi *smi, int port, int index) static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan) { - unsigned int max = RTL8366RB_NUM_VLANS; + unsigned int max = RTL8366RB_NUM_VLANS - 1; if (smi->vlan4k_enabled) max = RTL8366RB_NUM_VIDS - 1; From patchwork Mon Sep 13 14:42:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509794 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp668929jao; Mon, 13 Sep 2021 08:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlaFieeElbPARfryShjd++2jsPP+qnLN8ZKuqaPsOUv19ToYv5WDEF8GXZNhvtXVvPZz7W X-Received: by 2002:aa7:d796:: with SMTP id s22mr13812545edq.244.1631547272947; Mon, 13 Sep 2021 08:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547272; cv=none; d=google.com; s=arc-20160816; b=j2L5OAb9qnUnoENUwiSWruxAQCcWYg9kgTj0+GhFeDSYN4UOMOOa/Ls/67mRMQGiv9 fvpF78q7QGTnER1KqchM3ZDMz8wiEFnz6E43kFIIpL1mssL1enOEFhvKN2GABSz4P1d9 NfyLVvP0esIOcFG1rafdqV0HnWEC7GgrqQ6PdAngKr1pHmdFGTZhPr/JP38pojlcE8Pe 8stcy6TprlzeUmsJaQ9GZkizp8wpcAxPE2rhCmIGAwkDZ4Cd1mR//5P1m5F+SQkX8+gN ZzG/KdclF0YMONMfd/0kFnnxOCtcD8hZlNy+010EqDlAvdz5QdFCthTn/RfPUasggYrC Smag== 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=Q6DknvnoVKlTPBFZkTxYtBHHlx7PNAbFfx/QOOMrkiY=; b=ltRe9xUFnBdRiMeq0ORGb0sd6+afd/VpEnhkwfSwIFb/kI4uMYULXckicA3dlRcY/U zbYrvoDWRdVFJ7bPlCPQF+HbD5y0ovHwquo2X1RVinwfQbGjayTTTuuOOK8xFqRmDOdb m76QPqeJxYsx+DLXtQXEbuJTsugUaursbn8wMMTHpkLDfxhcWGHEDBelg/BAnjFUfsrw J+Mdem51JQOruqP1g0J8GpNwY8V1zkEDK7nsH/ybcHvxFD+Oqq1ob5h0+7BJUOruTxro VIdG8ea/Nj4w84V+1gLZZOSHYG5/tkYTt/tBt63L8MTzdppqtSb31SPeYtNwUAY0cT2G f9UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tz76PsDP; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.34.32; Mon, 13 Sep 2021 08:34:32 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tz76PsDP; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242915AbhIMPfq (ORCPT + 8 others); Mon, 13 Sep 2021 11:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240150AbhIMPf3 (ORCPT ); Mon, 13 Sep 2021 11:35:29 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3465DC12C759 for ; Mon, 13 Sep 2021 07:45:44 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id g1so10172854lfj.12 for ; Mon, 13 Sep 2021 07:45:44 -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=Q6DknvnoVKlTPBFZkTxYtBHHlx7PNAbFfx/QOOMrkiY=; b=tz76PsDPS/GBTheceLTNvLVr1mWNVaT16nZlLvPlXVgnkDFqIv0CRujkHgmMQPPxIO ADACAfjP4v4fYePWjCNR2759Sxum4IO7vudVpR8z7fiEj+iVHcYLyiAal0l42PfS4z2Q J9aJBii6/ixwr0B85V0wOaHTjvdILL01NucMUUtkEYHYlB6rp+Dw/fYr80LYmILqQDts C9SZIC06RFSX+2SaxOxte5ILdj9yqcHuZJELqyV5CxqdYcDXHwZ5MjD6XyB7wC0BTHqh afINBfIzNIBogLAXh4V0fPC/Ego2y+Fj/xjICOEDplt2sMHt+nxxehD0bbBS7W7Aawqx eg1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q6DknvnoVKlTPBFZkTxYtBHHlx7PNAbFfx/QOOMrkiY=; b=PQcZ7mD2S3qvWAxteDWrLQDywGu3VewQGmB90gNFv0EdvwCoNV7skkyDF77oYh3Us+ RZ4wi4bGEj2Fx92kjKJGLcaBCv7eny52A90vDLwEXkjiZkSWOZ+PH649wqjS8OnjzWey bV3bXkh3r7brr+p+8Mom3pWP4xkJa43eTtz/DYYqU4tK/vf9fd+rktCFKHtkNEVrFScu FKWoBXSa6MQ99dBdjnlmePWmg6a1RTku2XZjYz6k6/LIzVTWbFjKHaxicG+sJ9WTtkIu vahZ/5wskoN5Zvv2i704sDsqv1e9/dXNUQGcjRB/Ucx500QUrQs3hYR/ZJ9Di+nbEveN Nbmw== X-Gm-Message-State: AOAM532+VOOC9IeO4C5bkx8JUnVKgzqSNTz1cezEO3SCvaIaV7m99A7o DFmhzmzphS8eMVEjuJaQEknqVQ== X-Received: by 2002:a05:6512:982:: with SMTP id w2mr9642502lft.112.1631544342603; Mon, 13 Sep 2021 07:45:42 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:42 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , DENG Qingfang Subject: [PATCH net-next 7/8] net: dsa: rtl8366: Fix a bug in deleting VLANs Date: Mon, 13 Sep 2021 16:42:59 +0200 Message-Id: <20210913144300.1265143-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We were checking that the MC (member config) was != 0 for some reason, all we need to check is that the config has no ports, i.e. no members. Then it can be recycled. This must be some misunderstanding. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Alvin Šipraga Cc: Florian Fainelli Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v4: - New patch for a bug found while fixing the other issues. --- drivers/net/dsa/rtl8366.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.31.1 Reviewed-by: Florian Fainelli diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 9652323167c2..fd725cfa18e7 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -381,7 +381,7 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port, * anymore then clear the whole member * config so it can be reused. */ - if (!vlanmc.member && vlanmc.untag) { + if (!vlanmc.member) { vlanmc.vid = 0; vlanmc.priority = 0; vlanmc.fid = 0; From patchwork Mon Sep 13 14:43:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 509796 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp669334jao; Mon, 13 Sep 2021 08:35:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvxCJtVeoUA3/OfyNV3BhsiCg/ZEzruwWySPlZKawTHv1mA5/Ob1K+hSVRk8ONiF6etnJJ X-Received: by 2002:a17:906:39cb:: with SMTP id i11mr12501392eje.168.1631547300773; Mon, 13 Sep 2021 08:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631547300; cv=none; d=google.com; s=arc-20160816; b=uOYO9YFsP6Oyo6+nCkw/Cu1O54+v/Cz91fUjCbIjtMuECV/JEBkgaseSueE0ClYtxI ZhXP5vy+LOy9rbTbSTl8b9Efnar/7RB7z9H3AqSuAomAWH7IlUn2H4vYqWW2pjD8u2hs 7DPSksSCelsnlRvqYz0txfTFOx0qu+hu6hs429tc/w7UPo0H3qqPqii4x6S36kg6U989 ef/MbtaGJSxhNYfNcybFcm3VCYJt8+OubGCrELahkzVPREiKiJEVKhaMxD3/HTxkEYjH VjbRC73KJYJIUXEzQEp48vCt9e8kDWUwvOM7EBfT0qhi258UYKixVeyO9iv68T0fvryV 8yAw== 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=TW72UxNYbzv4qy0lUe963kdNXAzTIo48VP5lfoV3wMY=; b=fK2daE7SQRWBUO7aIrPQLK/j6BzZzd22IM+6POqAl9vbiQqnVGAWZ10IxYSFANlO+w NILTUMAvu9FWWvmOBcbq72fRxi2h41Wq8uFtBJzOwTpKOgvnzsbkvXBXw67A4aAq/7YD TbXrC6KovOu8Hzu4GhU/2C8FCve8A+YP0U1NNxSIKermZdu0LVhcFaq2KdOdzgpGsAtE o6F0+lcq132Huq3K1EvdLrw4jG5cw5H334Yhb/oi61k0S5QoHxmcFsK3rsRE8ubUz1RA crNqQSr7BZND6LKJFOtEMUwn+SUptmXoWFHOuvkuHq/IRllMKprmpsFGbu7e4NQpmHpS Mzpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D6tgEkIX; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7844974eji.452.2021.09.13.08.35.00; Mon, 13 Sep 2021 08:35:00 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D6tgEkIX; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232830AbhIMPgL (ORCPT + 8 others); Mon, 13 Sep 2021 11:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241181AbhIMPfa (ORCPT ); Mon, 13 Sep 2021 11:35:30 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A874C12C75D for ; Mon, 13 Sep 2021 07:45:45 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id bq5so21629068lfb.9 for ; Mon, 13 Sep 2021 07:45:45 -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=TW72UxNYbzv4qy0lUe963kdNXAzTIo48VP5lfoV3wMY=; b=D6tgEkIXRm/WemOYu7la3Im2tL8nIEMHEpcTJD/ZI4zbaFdyNpKjcqIjwLE+408xe9 DK8lwxI01vyfBTT3sYWa8tmfQk7Rd2tv1CyHu0CRTmJoBcQaSmZVc5rDPU3VW7qN1BYq 5Ls5O7P/XhcnV8wfEW10uH4S2OGzeriH/s54KHKsUo8ih/WpyNhRKnBK60h4q7mW9miw O0YVk8yMGc5iUFvpGtJBZoIx48yn7weCp1Gnva37+EuXcbHaHHo5DwSSuYFRl3EpJI7h HTLWFUKL8lLjH/SD9XPo0xP0OSyPXTHAdDt8vfI3YLJ4n7tNKEZ7XO5HQM9ewlhYtT11 eLrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TW72UxNYbzv4qy0lUe963kdNXAzTIo48VP5lfoV3wMY=; b=wE2535mBnvLOE6jZN4ZOMPeSBZW/hY88++AUHPnlqGPg9/PMWwl0nh5rIsR8u1wpIl OS/40BibnmUQmB55/ZYYWrhPlb9slsIFPYwBet2VpfgJi/xOQhNQqJIIWNo/oIbQjWUS 7I1zbo8VTzu3WTodVxuoXODPPRus89/Is0BDxSOrPGGaOjkD/wQUdCwsE5fZvxXWGZHJ 0z+CjBbDvNYaJ8C/w0S6VNlE7+qS3Z/u8FQXxQK6q9sNWzoe56NuSXzLrQQ/wDF/ZhaI 4TiQ6mOei9WjF0vBz0+L1L3fu5W0VtUFrLOuqowVGQn17oN33NLD9TaIY/Yrbr1h6qWs PkeA== X-Gm-Message-State: AOAM531GV/sloJwLhQkttbEdhUkwNu5Yr7G2VUJaucTbc/ITeOpYamwE nRYe9xqV75axKR7hgJEK2ItPHQ== X-Received: by 2002:a05:6512:2213:: with SMTP id h19mr9371515lfu.598.1631544343759; Mon, 13 Sep 2021 07:45:43 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id i12sm849825lfb.301.2021.09.13.07.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 07:45:43 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , DENG Qingfang Subject: [PATCH net-next 8/8] net: dsa: rtl8366: Drop and depromote pointless prints Date: Mon, 13 Sep 2021 16:43:00 +0200 Message-Id: <20210913144300.1265143-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913144300.1265143-1-linus.walleij@linaro.org> References: <20210913144300.1265143-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We don't need a message for every VLAN association, dbg is fine. The message about adding the DSA or CPU port to a VLAN is directly misleading, this is perfectly fine. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Alvin Šipraga Cc: Florian Fainelli Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v4: - New patch to deal with confusing messages and too talkative DSA bridge. --- drivers/net/dsa/rtl8366.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.31.1 Reviewed-by: Florian Fainelli diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index fd725cfa18e7..cf2e9d91d62d 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -325,12 +325,9 @@ int rtl8366_vlan_add(struct dsa_switch *ds, int port, return ret; } - dev_info(smi->dev, "add VLAN %d on port %d, %s, %s\n", - vlan->vid, port, untagged ? "untagged" : "tagged", - pvid ? " PVID" : "no PVID"); - - if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) - dev_err(smi->dev, "port is DSA or CPU port\n"); + dev_dbg(smi->dev, "add VLAN %d on port %d, %s, %s\n", + vlan->vid, port, untagged ? "untagged" : "tagged", + pvid ? " PVID" : "no PVID"); member |= BIT(port); @@ -363,7 +360,7 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port, struct realtek_smi *smi = ds->priv; int ret, i; - dev_info(smi->dev, "del VLAN %04x on port %d\n", vlan->vid, port); + dev_dbg(smi->dev, "del VLAN %d on port %d\n", vlan->vid, port); for (i = 0; i < smi->num_vlan_mc; i++) { struct rtl8366_vlan_mc vlanmc;