From: Vladimir Oltean <olteanv@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Vivien Didelot <vivien.didelot@gmail.com>, Florian Fainelli <f.fainelli@gmail.com>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Roopa Prabhu <roopa@nvidia.com>, Nikolay Aleksandrov <nikolay@nvidia.com>, "David S. Miller" <davem@davemloft.net> Cc: DENG Qingfang <dqfext@gmail.com>, Tobias Waldekranz <tobias@waldekranz.com>, Marek Behun <marek.behun@nic.cz>, Russell King - ARM Linux admin <linux@armlinux.org.uk>, Alexandra Winter <wintera@linux.ibm.com>, Jiri Pirko <jiri@resnulli.us>, Ido Schimmel <idosch@idosch.org>, Claudiu Manoil <claudiu.manoil@nxp.com>, UNGLinuxDriver@microchip.com Subject: [PATCH v4 net-next 4/7] net: dsa: move switchdev event implementation under the same switch/case statement Date: Wed, 6 Jan 2021 11:51:33 +0200 [thread overview] Message-ID: <20210106095136.224739-5-olteanv@gmail.com> (raw) In-Reply-To: <20210106095136.224739-1-olteanv@gmail.com> From: Vladimir Oltean <vladimir.oltean@nxp.com> We'll need to start listening to SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE events even for interfaces where dsa_slave_dev_check returns false, so we need that check inside the switch-case statement for SWITCHDEV_FDB_*. This movement also avoids a useless allocation / free of switchdev_work on the untreated "default event" case. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes in v4: None. Changes in v3: None. Changes in v2: None. net/dsa/slave.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 5e4fb44c2820..42ec18a4c7ba 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2119,31 +2119,29 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, struct dsa_port *dp; int err; - if (event == SWITCHDEV_PORT_ATTR_SET) { + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: err = switchdev_handle_port_attr_set(dev, ptr, dsa_slave_dev_check, dsa_slave_port_attr_set); return notifier_from_errno(err); - } - - if (!dsa_slave_dev_check(dev)) - return NOTIFY_DONE; + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + if (!dsa_slave_dev_check(dev)) + return NOTIFY_DONE; - dp = dsa_slave_to_port(dev); + dp = dsa_slave_to_port(dev); - switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); - if (!switchdev_work) - return NOTIFY_BAD; + switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + if (!switchdev_work) + return NOTIFY_BAD; - INIT_WORK(&switchdev_work->work, - dsa_slave_switchdev_event_work); - switchdev_work->ds = dp->ds; - switchdev_work->port = dp->index; - switchdev_work->event = event; + INIT_WORK(&switchdev_work->work, + dsa_slave_switchdev_event_work); + switchdev_work->ds = dp->ds; + switchdev_work->port = dp->index; + switchdev_work->event = event; - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: fdb_info = ptr; if (!fdb_info->added_by_user) { @@ -2156,13 +2154,12 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, switchdev_work->vid = fdb_info->vid; dev_hold(dev); + dsa_schedule_work(&switchdev_work->work); break; default: - kfree(switchdev_work); return NOTIFY_DONE; } - dsa_schedule_work(&switchdev_work->work); return NOTIFY_OK; } -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Oltean <olteanv@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Vivien Didelot <vivien.didelot@gmail.com>, Florian Fainelli <f.fainelli@gmail.com>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Roopa Prabhu <roopa@nvidia.com>, Nikolay Aleksandrov <nikolay@nvidia.com>, "David S. Miller" <davem@davemloft.net> Cc: Jiri Pirko <jiri@resnulli.us>, Alexandra Winter <wintera@linux.ibm.com>, Ido Schimmel <idosch@idosch.org>, Russell King - ARM Linux admin <linux@armlinux.org.uk>, Marek Behun <marek.behun@nic.cz>, DENG Qingfang <dqfext@gmail.com>, Claudiu Manoil <claudiu.manoil@nxp.com>, UNGLinuxDriver@microchip.com, Tobias Waldekranz <tobias@waldekranz.com> Subject: [Bridge] [PATCH v4 net-next 4/7] net: dsa: move switchdev event implementation under the same switch/case statement Date: Wed, 6 Jan 2021 11:51:33 +0200 [thread overview] Message-ID: <20210106095136.224739-5-olteanv@gmail.com> (raw) In-Reply-To: <20210106095136.224739-1-olteanv@gmail.com> From: Vladimir Oltean <vladimir.oltean@nxp.com> We'll need to start listening to SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE events even for interfaces where dsa_slave_dev_check returns false, so we need that check inside the switch-case statement for SWITCHDEV_FDB_*. This movement also avoids a useless allocation / free of switchdev_work on the untreated "default event" case. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes in v4: None. Changes in v3: None. Changes in v2: None. net/dsa/slave.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 5e4fb44c2820..42ec18a4c7ba 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2119,31 +2119,29 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, struct dsa_port *dp; int err; - if (event == SWITCHDEV_PORT_ATTR_SET) { + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: err = switchdev_handle_port_attr_set(dev, ptr, dsa_slave_dev_check, dsa_slave_port_attr_set); return notifier_from_errno(err); - } - - if (!dsa_slave_dev_check(dev)) - return NOTIFY_DONE; + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + if (!dsa_slave_dev_check(dev)) + return NOTIFY_DONE; - dp = dsa_slave_to_port(dev); + dp = dsa_slave_to_port(dev); - switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); - if (!switchdev_work) - return NOTIFY_BAD; + switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + if (!switchdev_work) + return NOTIFY_BAD; - INIT_WORK(&switchdev_work->work, - dsa_slave_switchdev_event_work); - switchdev_work->ds = dp->ds; - switchdev_work->port = dp->index; - switchdev_work->event = event; + INIT_WORK(&switchdev_work->work, + dsa_slave_switchdev_event_work); + switchdev_work->ds = dp->ds; + switchdev_work->port = dp->index; + switchdev_work->event = event; - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: fdb_info = ptr; if (!fdb_info->added_by_user) { @@ -2156,13 +2154,12 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, switchdev_work->vid = fdb_info->vid; dev_hold(dev); + dsa_schedule_work(&switchdev_work->work); break; default: - kfree(switchdev_work); return NOTIFY_DONE; } - dsa_schedule_work(&switchdev_work->work); return NOTIFY_OK; } -- 2.25.1
next prev parent reply other threads:[~2021-01-06 9:53 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-06 9:51 [PATCH v4 net-next 0/7] Offload software learnt bridge addresses to DSA Vladimir Oltean 2021-01-06 9:51 ` [Bridge] " Vladimir Oltean 2021-01-06 9:51 ` [PATCH v4 net-next 1/7] net: bridge: notify switchdev of disappearance of old FDB entry upon migration Vladimir Oltean 2021-01-06 9:51 ` [Bridge] " Vladimir Oltean 2021-01-06 17:43 ` Florian Fainelli 2021-01-06 17:43 ` [Bridge] " Florian Fainelli 2021-01-06 9:51 ` [PATCH v4 net-next 2/7] net: dsa: be louder when a non-legacy FDB operation fails Vladimir Oltean 2021-01-06 9:51 ` [Bridge] " Vladimir Oltean 2021-01-06 17:44 ` Florian Fainelli 2021-01-06 17:44 ` [Bridge] " Florian Fainelli 2021-01-06 9:51 ` [PATCH v4 net-next 3/7] net: dsa: don't use switchdev_notifier_fdb_info in dsa_switchdev_event_work Vladimir Oltean 2021-01-06 9:51 ` [Bridge] " Vladimir Oltean 2021-01-06 9:51 ` Vladimir Oltean [this message] 2021-01-06 9:51 ` [Bridge] [PATCH v4 net-next 4/7] net: dsa: move switchdev event implementation under the same switch/case statement Vladimir Oltean 2021-01-06 9:51 ` [PATCH v4 net-next 5/7] net: dsa: exit early in dsa_slave_switchdev_event if we can't program the FDB Vladimir Oltean 2021-01-06 9:51 ` [Bridge] " Vladimir Oltean 2021-01-06 9:51 ` [PATCH v4 net-next 6/7] net: dsa: listen for SWITCHDEV_{FDB,DEL}_ADD_TO_DEVICE on foreign bridge neighbors Vladimir Oltean 2021-01-06 9:51 ` [Bridge] [PATCH v4 net-next 6/7] net: dsa: listen for SWITCHDEV_{FDB, DEL}_ADD_TO_DEVICE " Vladimir Oltean 2021-01-06 9:51 ` [PATCH v4 net-next 7/7] net: dsa: ocelot: request DSA to fix up lack of address learning on CPU port Vladimir Oltean 2021-01-06 9:51 ` [Bridge] " Vladimir Oltean 2021-01-07 23:50 ` [PATCH v4 net-next 0/7] Offload software learnt bridge addresses to DSA patchwork-bot+netdevbpf 2021-01-07 23:50 ` [Bridge] " patchwork-bot+netdevbpf
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210106095136.224739-5-olteanv@gmail.com \ --to=olteanv@gmail.com \ --cc=UNGLinuxDriver@microchip.com \ --cc=andrew@lunn.ch \ --cc=bridge@lists.linux-foundation.org \ --cc=claudiu.manoil@nxp.com \ --cc=davem@davemloft.net \ --cc=dqfext@gmail.com \ --cc=f.fainelli@gmail.com \ --cc=idosch@idosch.org \ --cc=jiri@resnulli.us \ --cc=kuba@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=marek.behun@nic.cz \ --cc=netdev@vger.kernel.org \ --cc=nikolay@nvidia.com \ --cc=roopa@nvidia.com \ --cc=tobias@waldekranz.com \ --cc=vivien.didelot@gmail.com \ --cc=wintera@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.