Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3462569pxf; Mon, 15 Mar 2021 10:04:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqQ1ulm29d5pvFVmp7GlO/Pkl1OzR86FDhW90fxi1TdDFC61yUDREL4wmgxuSUpVgYhfFf X-Received: by 2002:a17:906:7cc:: with SMTP id m12mr24160871ejc.171.1615827855960; Mon, 15 Mar 2021 10:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615827855; cv=none; d=google.com; s=arc-20160816; b=SAWfZtIgCQQ5fFI+hBDnpXIGf9hMfqGVjHoSGoJpDaum9kqH3ijUbds7QibuycKNXw WZppQUNOESZ8zQhBMpKhyrVX1nR+cUVKLywsC2Z9uhdJpcsUKMvHTWVF+PFGCgFXbhT4 GVQYVbDHMtFvZ7h2KmNlG1/B27Azc/sURYTfKRuZzHjKtBdWSAxJvGbbG0eWA1ZTD8DP 1eou6WMhBit/1/FFPX2tQLLWMd+swWkOK2PFV4x5/eGRm+mKPLmGW4krlB4McEBS2gvy JJhJQezy/54hYtAL1eyrWelfIc6SVlitXFGCZpZom1iQ6Z03FB0LaBVMxaTN1ra7ihy5 NzKQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=P4LvijN3bMifiTb/0lgyYh4xxnVtEvA5pDE32AW+xU0=; b=Jgqk5qXPNAdqRy6284s6VM4jsXAPeuhpC7+IBZog8Bj+3jZ2nxyZfUz/+Moj7yWl8G jRpGO2QXPo6/Enll12AVibWX1F+yYxkmBwQkiCTdq7aUOWIRmZx2ns2736mKdvRWIWc/ qkQqEFWuOfMK0LsXLoU0JH7tn88z+tIN6yh8DhN4CJGZiZjaK3tokYFpDensMi8esPlg 3oq5TkiBJqdV2ekwLKmrfawYjV0TGtK+G8ih6c8Zf/VdWzhXwR46653cARKE5Vz9dGmw g8Z44ACSBpUDwVmHWsu8+6g4IcN10ForDRBZU5aWZXx9VRK4nO/B/fC7rhAAK/H/WDWw JHFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uEQGdwQp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si11801283edc.561.2021.03.15.10.03.48; Mon, 15 Mar 2021 10:04:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=uEQGdwQp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234596AbhCORB5 (ORCPT + 99 others); Mon, 15 Mar 2021 13:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235230AbhCORBx (ORCPT ); Mon, 15 Mar 2021 13:01:53 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3A52C06174A; Mon, 15 Mar 2021 10:01:52 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so14732742pjh.1; Mon, 15 Mar 2021 10:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=P4LvijN3bMifiTb/0lgyYh4xxnVtEvA5pDE32AW+xU0=; b=uEQGdwQp2ak3InwMuxkKEOPJ0WuupFVWKkCc/lpIAOv209E9tvBFpLy4YnQpBc8Tfl eEu8jYzomYxIrhde2wlrgkddZ5Wqn8QjvMMFj4XouSVp+C4G/gx3lPlOAkAJ4ygl1Kj9 2wSAiCviiAp9jX7AJBh/YSZzdwaMxmpdeDKpbywSdeA31LR5FnPwd1XfrktF/U8wghN9 QpzSvrHJBehCJG6RXWiUoTVamAw4tYtB4v82R3HsngO2iluXqpMBOC0D8ibQ5IkHmjf+ HxUgdQ7345vVukw5y+8U6iJU9HkIJlvIX2ILs7X9A8FuB7eMPBU+va5wol/qZzcBQYGw I21Q== 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=P4LvijN3bMifiTb/0lgyYh4xxnVtEvA5pDE32AW+xU0=; b=IyjXWVct+1Iz0Xv2k23Pzus/keAg3DSDAxZFVLw5JhGz7bWpPvcFY9dx0R/3RbCFvM VHEMr9D55D+EcJHb2UfG2V6oSTTcFtBl7lyrre4RTVj9gTfzHCK0PQ9/7li9bw0kx4rV 0lSZD90lLIERsUss123JZRRSyy2dWhdHgWqj9Vv7GElqKq7EI9BJWN1VShNd2rVGhs8Y dCJeq4ZeYWCJORTbNc9ia+3qzaNrlKCIDy/z5bMDwsfvY9TgTu8UQyRC8ugCIjyX7fpj /pYNp9eF2bxKdAF0sFZQPaHA3UDRQ7NVM4nDuP+3gglhGRDkLuMT09ZvLfQqo3aAmhCA 2XVg== X-Gm-Message-State: AOAM531hdQ0au4AUtoyb/FE6mqfj2JqSz7YFqBN1UueVWthrS0U9SvHU 5Wiml2ian3EMtn8UuPHQjZQ= X-Received: by 2002:a17:90a:7103:: with SMTP id h3mr49966pjk.82.1615827712517; Mon, 15 Mar 2021 10:01:52 -0700 (PDT) Received: from localhost.localdomain ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id t6sm176083pjs.26.2021.03.15.10.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 10:01:51 -0700 (PDT) From: LGA1150 To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Russell King , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: DENG Qingfang , Linus Walleij Subject: [PATCH net-next] net: dsa: rtl8366rb: support bridge offloading Date: Tue, 16 Mar 2021 01:01:44 +0800 Message-Id: <20210315170144.2081099-1-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: DENG Qingfang Use port isolation registers to configure bridge offloading. Remove the VLAN init, as we have proper CPU tag and bridge offloading support now. Signed-off-by: DENG Qingfang --- Changes since RFC: Fix build error drivers/net/dsa/rtl8366rb.c | 71 +++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a89093bc6c6a..bbcfdd84f0e9 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -300,6 +300,12 @@ #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) + /* bits 0..5 enable force when cleared */ #define RTL8366RB_MAC_FORCE_CTRL_REG 0x0F11 @@ -835,6 +841,15 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; + /* Isolate user ports */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + ret = regmap_write(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_EN | + BIT(RTL8366RB_PORT_NUM_CPU + 1)); + if (ret) + return ret; + } + /* Set up the "green ethernet" feature */ ret = rtl8366rb_jam_table(rtl8366rb_green_jam, ARRAY_SIZE(rtl8366rb_green_jam), smi, false); @@ -963,10 +978,6 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return ret; } - ret = rtl8366_init_vlan(smi); - if (ret) - return ret; - ret = rtl8366rb_setup_cascaded_irq(smi); if (ret) dev_info(smi->dev, "no interrupt support\n"); @@ -977,8 +988,6 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return -ENODEV; } - ds->configure_vlan_while_not_filtering = false; - return 0; } @@ -1127,6 +1136,54 @@ 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; + + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + if (i == port) + continue; + if (dsa_to_port(ds, i)->bridge_dev != bridge) + continue; + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i), + 0, BIT(port + 1)); + if (ret) + return ret; + + port_bitmap |= BIT(i); + } + + return regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(port), + 0, port_bitmap << 1); +} + +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 i; + + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + if (i == port) + continue; + if (dsa_to_port(ds, i)->bridge_dev != bridge) + continue; + regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i), + BIT(port + 1), 0); + + port_bitmap |= BIT(i); + } + + regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(port), + port_bitmap << 1, 0); +} + static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct realtek_smi *smi = ds->priv; @@ -1510,6 +1567,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, -- 2.25.1