From patchwork Wed Jan 16 20:01:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 1026175 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=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tijxJKAV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43fynz4qg7z9sCh for ; Thu, 17 Jan 2019 07:03:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732311AbfAPUDs (ORCPT ); Wed, 16 Jan 2019 15:03:48 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:43653 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732268AbfAPUDo (ORCPT ); Wed, 16 Jan 2019 15:03:44 -0500 Received: by mail-yw1-f67.google.com with SMTP id n21so2908088ywd.10 for ; Wed, 16 Jan 2019 12:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RXV104XivffX/oUqKPlk/V803i3ijUs034q3KjO8D/o=; b=tijxJKAVrXbFNecEB0S1czkalfAoVsE74XV1Hvxdzsvjlf1xSc+HDpimx9bT/sYDDY ZubCwQrFD45pTnVqZHlA70iXBuSksHOn7VpktzrbNA2V12XK9rwhZrEt3KRmHQAfpOHe ZX4BnbgDGvOdqIiEMknanIXQlWI27qxxkawqgIQX9LKYOfcw6Ah7OjnEApbcUmQUcMz0 xXK+4cQhmQAIcsqKs6OsRfAvbZPFIaWpfhER7Bxgf4vc+9cbWJRLxXH8UKYrxEUMxey3 tmQ5iuIAdszH5vZaRi1xbjYvvfdUJs/XKFwO3922lVim8Igb4IUp98A+Qo/60l4WvaFy DRLQ== 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; bh=RXV104XivffX/oUqKPlk/V803i3ijUs034q3KjO8D/o=; b=ONIKk7krBlL/3TxNx0LblGCGgzFMHRUC9Iw4YTPJm1y2YFxCzpV82K9AOtxfEDfbEg syWWM76z7gZWWyyp87v/ExEXdLsbhpshcpMdGrCxYrkfxlsO8ygydTvb7psgO4qAoSNJ tMjyvpvKzNAcu8Y9SdgUITal2CijK+V5HYTcFFDgvN1hNEVAM8wHecKFP7XTKtu8dZBx jpeBPsXQN7ZmcLzi8iHZ6e2zQOPW5MuI1KKnRU6oa58PX8ybWpzITiORVtZWDxQH9qXU 14opjMAtmqjA1y6ZLK2e5t7bqIVoj3oja00Mk2BXsHGOE8Jo0+lghgFUOE+nshGiYXRd Oqew== X-Gm-Message-State: AJcUukdU30ZUFaR+03DVUsRpXCWS++hkya/lizwttDNmM4VNSvDtZYUB ITKptp05XpJtgpBR80hW2fqfHHGY X-Google-Smtp-Source: ALg8bN5SW12GUbxcVAqmJB02VoEsEcsjDvAr9VKag/YYG254sS075EqRd+quHGtQS0QpbFfP1mdgjg== X-Received: by 2002:a81:f00c:: with SMTP id p12mr9335016ywm.55.1547669022639; Wed, 16 Jan 2019 12:03:42 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id v128sm2475295ywf.44.2019.01.16.12.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:03:41 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , andrew@lunn.ch, vivien.didelot@gmail.com, davem@davemloft.net, idosch@mellanox.com, jiri@mellanox.com, ilias.apalodimas@linaro.org, ivan.khoronzhuk@linaro.org, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com Subject: [PATCH net-next 12/14] net: dsa: Wire up multicast IGMP snooping attribute notification Date: Wed, 16 Jan 2019 12:01:00 -0800 Message-Id: <20190116200102.2749-13-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116200102.2749-1-f.fainelli@gmail.com> References: <20190116200102.2749-1-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The bridge can at runtime be configured with or without IGMP snooping enabled but we were not processing the switchdev attribute that notifies about that toggle, do this now. Signed-off-by: Florian Fainelli --- include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 11 +++++++++++ net/dsa/port.c | 13 +++++++++++++ net/dsa/slave.c | 4 ++++ net/dsa/switch.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index b3eefe8e18fd..11cd4db3bc9e 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -479,6 +479,8 @@ struct dsa_switch_ops { /* * Multicast database */ + int (*port_multicast_toggle)(struct dsa_switch *ds, int port, + bool mc_disabled); int (*port_mdb_prepare)(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb); void (*port_mdb_add)(struct dsa_switch *ds, int port, diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index aad8acc70183..6f7ed2b3494f 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -27,6 +27,7 @@ enum { DSA_NOTIFIER_VLAN_ADD, DSA_NOTIFIER_VLAN_DEL, DSA_NOTIFIER_VLAN_FILTERING, + DSA_NOTIFIER_MC_DISABLED, }; /* DSA_NOTIFIER_AGEING_TIME */ @@ -74,6 +75,14 @@ struct dsa_notifier_vlan_filtering_info { int port; }; +/* DSA_NOTIFIER_MC_DISABLED */ +struct dsa_notifier_mc_disabled_info { + bool mc_disabled; + struct switchdev_trans *trans; + int sw_index; + int port; +}; + struct dsa_slave_priv { /* Copy of CPU port xmit for faster access in slave transmit hot path */ struct sk_buff * (*xmit)(struct sk_buff *skb, @@ -154,6 +163,8 @@ int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy); void dsa_port_disable(struct dsa_port *dp, struct phy_device *phy); int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br); void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br); +int dsa_port_multicast_toggle(struct dsa_port *dp, bool mc_disabled, + struct switchdev_trans *trans); int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, struct switchdev_trans *trans); int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock, diff --git a/net/dsa/port.c b/net/dsa/port.c index d7b057d46460..148458941b51 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -143,6 +143,19 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br) dsa_port_set_state_now(dp, BR_STATE_FORWARDING); } +int dsa_port_multicast_toggle(struct dsa_port *dp, bool mc_disabled, + struct switchdev_trans *trans) +{ + struct dsa_notifier_mc_disabled_info info = { + .sw_index = dp->ds->index, + .port = dp->index, + .trans = trans, + .mc_disabled = mc_disabled, + }; + + return dsa_port_notify(dp, DSA_NOTIFIER_MC_DISABLED, &info); +} + int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, struct switchdev_trans *trans) { diff --git a/net/dsa/slave.c b/net/dsa/slave.c index e266ef329583..acb7f1830e98 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -337,6 +337,10 @@ static int dsa_slave_port_attr_set(struct net_device *dev, case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME: ret = dsa_port_ageing_time(dp, attr->u.ageing_time, trans); break; + case SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED: + ret = dsa_port_multicast_toggle(dp, attr->u.mc_disabled, + trans); + break; default: ret = -EOPNOTSUPP; break; diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 831334dc5e79..e095eb808434 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -261,6 +261,31 @@ static int dsa_switch_vlan_filtering(struct dsa_switch *ds, return 0; } +static int dsa_switch_mc_disabled(struct dsa_switch *ds, + struct dsa_notifier_mc_disabled_info *info) +{ + struct switchdev_trans *trans = info->trans; + bool mc_disabled = info->mc_disabled; + int port = info->port; + int err; + + if (switchdev_trans_ph_prepare(trans)) + return ds->ops->port_multicast_toggle ? 0 : -EOPNOTSUPP; + + /* Build a mask of port members */ + bitmap_zero(ds->bitmap, ds->num_ports); + if (ds->index == info->sw_index) + set_bit(port, ds->bitmap); + + for_each_set_bit(port, ds->bitmap, ds->num_ports) { + err = ds->ops->port_multicast_toggle(ds, port, mc_disabled); + if (err) + return err; + } + + return 0; +} + static int dsa_switch_event(struct notifier_block *nb, unsigned long event, void *info) { @@ -298,6 +323,9 @@ static int dsa_switch_event(struct notifier_block *nb, case DSA_NOTIFIER_VLAN_FILTERING: err = dsa_switch_vlan_filtering(ds, info); break; + case DSA_NOTIFIER_MC_DISABLED: + err = dsa_switch_mc_disabled(ds, info); + break; default: err = -EOPNOTSUPP; break;