Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2975181imm; Sun, 24 Jun 2018 08:34:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKlVh6myeozFMejy5jU052hF64Wh4LVruAaljX7SBwcVEpjma6fur6bzw5MMz41J92ZchQ7 X-Received: by 2002:a17:902:a610:: with SMTP id u16-v6mr9086766plq.195.1529854486637; Sun, 24 Jun 2018 08:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529854486; cv=none; d=google.com; s=arc-20160816; b=qEoiHnJPEf/vSEQ8ryKwVmbIq3O5gPF575ID7Mo/UlwLftMWUrRTg4stw43rRxEbPZ v9bLDLHGlF0xrQleQHa436ti87ydLyebZTBB8l11Bo1SVt8IzAG0UGuPXDPwlAv1p6cJ hPSCBlYYLgjWSuNFowr/JgKQMQChidUCe6/1fJQhk5he9rV6YhVclCLJOhRHul8oT2Kr jGT0YBCwC/gI7PoESFQiAMgrD1tS/pkJ4imQXiW6C+WiUBehZzna2fjVgezKij/AaCcm yAGexpc80q5Q2uli3tERJmYGJRewJN8jI8B3fC3LrXmjTsDxNDTMbUCVn/mmdZ+d9pHL mxNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/U7L7gIAMgtnKQQawaeDuUVHIW9fT7Cfx88aBkBM2Y8=; b=X8ptQVFG4/piWNLlN5vDI9SU99eOzlU1W5jdH9eanlocIEPQgafow0uA9syw3gZR9X QQ8UEEjEg7tfxy9kOdgQ+W1ARVFUv+nwSUTVgcGDdYYcEZrK1hgOsBL1vy/HcBsgMGC3 gp7UNLg/NtKSJgQvjRe4xQLJbNRjFgwRKkvC4x8ro+ukYXNTRtCtR8YTanaQbSEklvDB ldIMVsHwevyn4QgiMuBWIEaSgVTHkHZBFEOQHvc5cHvH1XU1ht7+dYezCmv0IhUU3uYI Bra0PaXVQC7NxlB6739NMJuli/WEW/DpySPNDNByaIt/Xlw+dRVZf0tpITZGtXOTAZfr wF0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B8RkWGie; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si11796466pld.189.2018.06.24.08.34.32; Sun, 24 Jun 2018 08:34:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B8RkWGie; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1755128AbeFXPdt (ORCPT + 99 others); Sun, 24 Jun 2018 11:33:49 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:41121 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754958AbeFXPdp (ORCPT ); Sun, 24 Jun 2018 11:33:45 -0400 Received: by mail-qt0-f196.google.com with SMTP id y20-v6so9996889qto.8; Sun, 24 Jun 2018 08:33:45 -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; bh=/U7L7gIAMgtnKQQawaeDuUVHIW9fT7Cfx88aBkBM2Y8=; b=B8RkWGielEYB7nh8QsqpE4idXpuPSee4E7wsO7eU1gdTmmYBa37LemCOjsG6phTM5M 6Km3hGOvj7f7qzXHy017Hyz5tmaoOOB7EDthx5x9aG6NP4Gmsv+ZL1d8A9Te4J3YG4yz M97cJG4CLvAw8/m8YZGrXUN6LRzjnG7iA7voxS4Fn1ynVSF83NQVqW6q5vHf5CRFzUKx 5/o9m6lBhrus0CXR2Bfuzzh4TPZ3ZeVuiX4YfStwXK6LwtpyrqpeXIOe2n0h4/7p0xeR eIJ6ucax/13nJmVr2MrLdNZlTeGVIKQapVet4cNzPxmvnXYN/iLknwu34P77aQssr9u9 EDEQ== 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; bh=/U7L7gIAMgtnKQQawaeDuUVHIW9fT7Cfx88aBkBM2Y8=; b=Lt5UppVCux1QMENbG0PZAj7gvtTyfb9QhQYfRxjhezGyE/eJYgcr/kRMuP6s/qytO1 OCXdL2OomkxMdvtvYQZsUbpJ/1T1g2sR1Gjei6c3OzBRWFrRcSddlhlLXmv9PhR/KCWh 4od6R8ke8Y5KDAGKCRREPIctAereB+VoHZB/HaOHm0FKdRQ3h3ylFDoGwkoMu7wJMY6U TXvC8GU2wVt8QQldLE7XOtc1lW77/1sILbSiUys2QVJdPKBqapYZiZLOuihvXUQQwpFf 1Iz2CRIdLnn8yVAtsbBOZWBjt/EMgkpBAVFRxWLSAj1ae9xr5uuutbQPQHqv1iOP5Dhu VG1g== X-Gm-Message-State: APt69E2WKsNw0Hm/ZZrXglPQtlcbLw/o9Vy5usQhEhrW4NtQ21M612k9 qexZstO7O0iCF4mb2KmcK8EkgKL0 X-Received: by 2002:ac8:25f2:: with SMTP id f47-v6mr8220742qtf.12.1529854424359; Sun, 24 Jun 2018 08:33:44 -0700 (PDT) Received: from cox.net ([192.19.218.250]) by smtp.gmail.com with ESMTPSA id m128-v6sm9155700qkd.33.2018.06.24.08.33.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jun 2018 08:33:43 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: petrm@mellanox.com, jiri@mellanox.com, ilias.apalodimas@linaro.org, Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH RFT] net: dsa: Allow configuring CPU port VLANs Date: Sun, 24 Jun 2018 08:33:39 -0700 Message-Id: <20180624153339.13572-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Up until now there was no way to specifically target the VLAN attributes and membership of the CPU port of a DSA switch. This forced drivers to either always have the CPU port be "VLAN tagged" (b53) in every VLAN that gets added to the front-panel/user facing ports, or when the switch supports it, use an "unmodified" semantic (mv88e6xxx). This is less than ideal because there are cases where we might not even want to have the CPU port be part of the same VLAN than its user facing ports, e.g: to isolate a group of noisy stations. There are also cases where we want to control exactly how the CPU port receives VLAN traffic such that proper separation/identification can occur. Make this possible by flagging events targeting an orig_dev which is a bridge master and using that as a hint to mean that we want to configure the CPU/management port. This is compatible with multiple bridges over the same switch in that, an user still has the responsibility to create separate broadcast domains with separate VLAN databases/IDs per bridge. Signed-off-by: Florian Fainelli --- Andrew, Vivien, Could you test this on mv88e6xxx to make sure there is no regression? Thanks net/dsa/port.c | 4 ++-- net/dsa/switch.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index ed0595459df1..37385e491117 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -253,7 +253,7 @@ int dsa_port_vlan_add(struct dsa_port *dp, }; if (netif_is_bridge_master(vlan->obj.orig_dev)) - return -EOPNOTSUPP; + info.port = dp->cpu_dp->index; if (br_vlan_enabled(dp->bridge_dev)) return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info); @@ -271,7 +271,7 @@ int dsa_port_vlan_del(struct dsa_port *dp, }; if (netif_is_bridge_master(vlan->obj.orig_dev)) - return -EOPNOTSUPP; + info.port = dp->cpu_dp->index; if (br_vlan_enabled(dp->bridge_dev)) return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info); diff --git a/net/dsa/switch.c b/net/dsa/switch.c index b93511726069..d69bcc8f9ba2 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -211,8 +211,11 @@ static int dsa_switch_vlan_add(struct dsa_switch *ds, bitmap_zero(members, ds->num_ports); if (ds->index == info->sw_index) set_bit(info->port, members); + /* CPU port is configured via dsa_port_vlan_add() with events + * targeting the bridge device + */ for (port = 0; port < ds->num_ports; port++) - if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) + if (dsa_is_dsa_port(ds, port)) set_bit(port, members); if (switchdev_trans_ph_prepare(trans)) -- 2.14.1