From: Jiri Pirko <jiri@resnulli.us>
To: Vadym Kochan <vadym.kochan@plvision.eu>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@mellanox.com>,
Ido Schimmel <idosch@mellanox.com>, Andrew Lunn <andrew@lunn.ch>,
Oleksandr Mazur <oleksandr.mazur@plvision.eu>,
Serhiy Boiko <serhiy.boiko@plvision.eu>,
Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
Taras Chornyi <taras.chornyi@plvision.eu>,
Andrii Savka <andrii.savka@plvision.eu>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Mickey Rachamim <mickeyr@marvell.com>
Subject: Re: [net-next v3 5/6] net: marvell: prestera: Add Switchdev driver implementation
Date: Sun, 26 Jul 2020 10:34:14 +0200 [thread overview]
Message-ID: <20200726083414.GD2216@nanopsycho> (raw)
In-Reply-To: <20200725150651.17029-6-vadym.kochan@plvision.eu>
Sat, Jul 25, 2020 at 05:06:50PM CEST, vadym.kochan@plvision.eu wrote:
>The following features are supported:
>
> - VLAN-aware bridge offloading
> - VLAN-unaware bridge offloading
> - FDB offloading (learning, ageing)
> - Switchport configuration
>
>Currently there are some limitations like:
>
> - Only 1 VLAN-aware bridge instance supported
> - FDB ageing timeout parameter is set globally per device
>
>Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
>Signed-off-by: Serhiy Pshyk <serhiy.pshyk@plvision.eu>
>Signed-off-by: Taras Chornyi <taras.chornyi@plvision.eu>
>Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
>---
[...]
>+static void prestera_fdb_event_work(struct work_struct *work)
>+{
>+ struct switchdev_notifier_fdb_info *fdb_info;
>+ struct prestera_fdb_event_work *swdev_work;
>+ struct prestera_port *port;
>+ struct net_device *dev;
>+ int err = 0;
>+
>+ swdev_work = container_of(work, struct prestera_fdb_event_work, work);
>+ dev = swdev_work->dev;
>+
>+ rtnl_lock();
>+
>+ port = prestera_port_dev_lower_find(dev);
>+ if (!port)
>+ goto out;
>+
>+ switch (swdev_work->event) {
>+ case SWITCHDEV_FDB_ADD_TO_DEVICE:
>+ fdb_info = &swdev_work->fdb_info;
>+ if (!fdb_info->added_by_user)
>+ break;
>+
>+ err = prestera_port_fdb_set(port, fdb_info, true);
>+ if (err)
>+ break;
>+
>+ prestera_fdb_offload_notify(port, fdb_info);
>+ break;
>+
>+ case SWITCHDEV_FDB_DEL_TO_DEVICE:
>+ fdb_info = &swdev_work->fdb_info;
>+ prestera_port_fdb_set(port, fdb_info, false);
>+ break;
>+ }
>+
>+out:
>+ rtnl_unlock();
>+
>+ kfree(swdev_work->fdb_info.addr);
>+ kfree(swdev_work);
>+ dev_put(dev);
>+}
>+
>+static int prestera_switchdev_event(struct notifier_block *unused,
>+ unsigned long event, void *ptr)
>+{
>+ struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
>+ struct switchdev_notifier_fdb_info *fdb_info;
>+ struct switchdev_notifier_info *info = ptr;
>+ struct prestera_fdb_event_work *swdev_work;
>+ struct net_device *upper;
>+ int err = 0;
>+
>+ if (event == SWITCHDEV_PORT_ATTR_SET) {
>+ err = switchdev_handle_port_attr_set(dev, ptr,
>+ prestera_netdev_check,
>+ prestera_port_obj_attr_set);
>+ return notifier_from_errno(err);
>+ }
>+
>+ upper = netdev_master_upper_dev_get_rcu(dev);
>+ if (!upper)
>+ return NOTIFY_DONE;
>+
>+ if (!netif_is_bridge_master(upper))
>+ return NOTIFY_DONE;
Okay, you support upper bridge. Of which interface? I believe you should
put prestera_netdev_check(dev) check here and avoid the lookup in the
work. Otherwise any chain of intermediate lower devices would be
supported, which is wrong.
>+
>+ swdev_work = kzalloc(sizeof(*swdev_work), GFP_ATOMIC);
>+ if (!swdev_work)
>+ return NOTIFY_BAD;
>+
>+ swdev_work->event = event;
>+ swdev_work->dev = dev;
>+
>+ switch (event) {
>+ case SWITCHDEV_FDB_ADD_TO_DEVICE:
>+ case SWITCHDEV_FDB_DEL_TO_DEVICE:
>+ fdb_info = container_of(info,
>+ struct switchdev_notifier_fdb_info,
>+ info);
>+
>+ INIT_WORK(&swdev_work->work, prestera_fdb_event_work);
>+ memcpy(&swdev_work->fdb_info, ptr,
>+ sizeof(swdev_work->fdb_info));
>+
>+ swdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);
>+ if (!swdev_work->fdb_info.addr)
>+ goto out;
>+
>+ ether_addr_copy((u8 *)swdev_work->fdb_info.addr,
>+ fdb_info->addr);
>+ dev_hold(dev);
>+
>+ break;
>+
>+ default:
>+ kfree(swdev_work);
>+ return NOTIFY_DONE;
>+ }
>+
>+ queue_work(swdev_wq, &swdev_work->work);
>+ return NOTIFY_DONE;
>+out:
>+ kfree(swdev_work);
>+ return NOTIFY_BAD;
>+}
[...]
next prev parent reply other threads:[~2020-07-26 8:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-25 15:06 [net-next v3 0/6] net: marvell: prestera: Add Switchdev driver for Prestera family ASIC device 98DX326x (AC3x) Vadym Kochan
2020-07-25 15:06 ` [net-next v3 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices Vadym Kochan
2020-07-26 8:35 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 2/6] net: marvell: prestera: Add PCI interface support Vadym Kochan
2020-07-26 9:51 ` Jiri Pirko
2020-07-26 10:32 ` Andy Shevchenko
2020-07-26 22:55 ` Vadym Kochan
2020-07-27 8:04 ` Andy Shevchenko
2020-07-27 9:34 ` Vadym Kochan
2020-07-27 11:05 ` Andy Shevchenko
2020-07-25 15:06 ` [net-next v3 3/6] net: marvell: prestera: Add basic devlink support Vadym Kochan
2020-07-26 9:20 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 4/6] net: marvell: prestera: Add ethtool interface support Vadym Kochan
2020-07-26 9:46 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 5/6] net: marvell: prestera: Add Switchdev driver implementation Vadym Kochan
2020-07-26 8:34 ` Jiri Pirko [this message]
2020-07-25 15:06 ` [net-next v3 6/6] dt-bindings: marvell,prestera: Add description for device-tree bindings Vadym Kochan
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=20200726083414.GD2216@nanopsycho \
--to=jiri@resnulli.us \
--cc=andrew@lunn.ch \
--cc=andrii.savka@plvision.eu \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mickeyr@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=oleksandr.mazur@plvision.eu \
--cc=serhiy.boiko@plvision.eu \
--cc=serhiy.pshyk@plvision.eu \
--cc=taras.chornyi@plvision.eu \
--cc=vadym.kochan@plvision.eu \
--cc=volodymyr.mytnyk@plvision.eu \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).