From: Vadym Kochan <vadym.kochan@plvision.eu>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
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>,
Jiri Pirko <jiri@mellanox.com>,
Ido Schimmel <idosch@mellanox.com>, Andrew Lunn <andrew@lunn.ch>,
Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Subject: Re: [RFC next-next v2 1/5] net: marvell: prestera: Add driver for Prestera family ASIC devices
Date: Tue, 12 May 2020 17:53:52 +0300 [thread overview]
Message-ID: <20200512145352.GC31516@plvision.eu> (raw)
In-Reply-To: <20200511103222.GF2245@nanopsycho>
On Mon, May 11, 2020 at 12:32:22PM +0200, Jiri Pirko wrote:
[...]
>
> This is RCU list. Treat it accordingly.
>
>
> >+ spin_unlock(&sw->ports_lock);
>
> I don't follow, why do you need to protect the list by spinlock here?
> More to that, why do you need the port_list reader-writer
> protected (by rcu)? Is is possible that you add/remove port in the same
> time packets are flying in?
>
> If yes, you need to ensure the structs are in the memory (free_rcu,
> synchronize_rcu). But I believe that you should disable that from
> happening in HW.
>
>
> >+
[...]
> >+
> >+static int prestera_switch_init(struct prestera_switch *sw)
> >+{
> >+ int err;
> >+
> >+ err = prestera_hw_switch_init(sw);
> >+ if (err) {
> >+ dev_err(prestera_dev(sw), "Failed to init Switch device\n");
> >+ return err;
> >+ }
> >+
> >+ memcpy(sw->base_mac, base_mac_addr, sizeof(sw->base_mac));
> >+ spin_lock_init(&sw->ports_lock);
> >+ INIT_LIST_HEAD(&sw->port_list);
> >+
> >+ err = prestera_hw_switch_mac_set(sw, sw->base_mac);
> >+ if (err)
> >+ return err;
> >+
> >+ err = prestera_rxtx_switch_init(sw);
> >+ if (err)
> >+ return err;
> >+
> >+ err = prestera_event_handlers_register(sw);
> >+ if (err)
> >+ goto err_evt_handlers;
> >+
> >+ err = prestera_create_ports(sw);
> >+ if (err)
> >+ goto err_ports_create;
> >+
> >+ return 0;
> >+
> >+err_ports_create:
>
> You are missing prestera_event_handlers_unregister(sw); call here.
>
it is handled below in prestera_switch_fini().
>
> >+err_evt_handlers:
> >+ prestera_rxtx_switch_fini(sw);
> >+
> >+ return err;
> >+}
> >+
> >+static void prestera_switch_fini(struct prestera_switch *sw)
> >+{
> >+ prestera_destroy_ports(sw);
> >+ prestera_event_handlers_unregister(sw);
> >+ prestera_rxtx_switch_fini(sw);
> >+}
> >+
> >+int prestera_device_register(struct prestera_device *dev)
> >+{
> >+ struct prestera_switch *sw;
> >+ int err;
> >+
> >+ sw = kzalloc(sizeof(*sw), GFP_KERNEL);
> >+ if (!sw)
> >+ return -ENOMEM;
> >+
> >+ dev->priv = sw;
> >+ sw->dev = dev;
> >+
> >+ err = prestera_switch_init(sw);
> >+ if (err) {
> >+ kfree(sw);
> >+ return err;
> >+ }
> >+
> >+ registered_switch = sw;
> >+ return 0;
> >+}
> >+EXPORT_SYMBOL(prestera_device_register);
> >+
> >+void prestera_device_unregister(struct prestera_device *dev)
> >+{
> >+ struct prestera_switch *sw = dev->priv;
> >+
> >+ registered_switch = NULL;
> >+ prestera_switch_fini(sw);
> >+ kfree(sw);
> >+}
> >+EXPORT_SYMBOL(prestera_device_unregister);
> >+
> >+static int __init prestera_module_init(void)
> >+{
> >+ if (!base_mac) {
> >+ pr_err("[base_mac] parameter must be specified\n");
> >+ return -EINVAL;
> >+ }
> >+ if (!mac_pton(base_mac, base_mac_addr)) {
> >+ pr_err("[base_mac] parameter has invalid format\n");
> >+ return -EINVAL;
> >+ }
> >+
> >+ prestera_wq = alloc_workqueue("prestera", 0, 0);
> >+ if (!prestera_wq)
> >+ return -ENOMEM;
> >+
> >+ return 0;
> >+}
> >+
> >+static void __exit prestera_module_exit(void)
> >+{
> >+ destroy_workqueue(prestera_wq);
> >+}
> >+
> >+module_init(prestera_module_init);
> >+module_exit(prestera_module_exit);
> >+
> >+MODULE_AUTHOR("Marvell Semi.");
> >+MODULE_LICENSE("Dual BSD/GPL");
> >+MODULE_DESCRIPTION("Marvell Prestera switch driver");
> >+
> >+module_param(base_mac, charp, 0);
>
> No please.
>
>
> [..]
>
next prev parent reply other threads:[~2020-05-12 14:54 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-30 23:20 [RFC next-next v2 0/5] net: marvell: prestera: Add Switchdev driver for Prestera family ASIC device 98DX326x (AC3x) Vadym Kochan
2020-04-30 23:20 ` [RFC next-next v2 1/5] net: marvell: prestera: Add driver for Prestera family ASIC devices Vadym Kochan
2020-05-11 10:32 ` Jiri Pirko
2020-05-11 11:11 ` Vadym Kochan
2020-05-11 11:29 ` Jiri Pirko
2020-05-11 12:42 ` Andrew Lunn
2020-05-11 13:02 ` Vadym Kochan
2020-05-11 13:53 ` Andrew Lunn
2020-05-11 14:11 ` Vadym Kochan
2020-05-11 15:32 ` Jiri Pirko
2020-05-11 16:43 ` Andrew Lunn
2020-05-11 17:24 ` Jiri Pirko
2020-05-12 14:53 ` Vadym Kochan [this message]
2020-05-12 15:03 ` Jiri Pirko
2020-05-12 15:07 ` Vadym Kochan
2020-05-12 15:21 ` Jiri Pirko
2020-05-11 12:57 ` Jiri Pirko
2020-05-11 19:24 ` Vadym Kochan
2020-05-12 5:55 ` Jiri Pirko
2020-05-12 7:15 ` Vadym Kochan
2020-05-12 11:13 ` Jiri Pirko
2020-05-12 14:50 ` Vadym Kochan
2020-05-12 15:02 ` Jiri Pirko
2020-04-30 23:20 ` [RFC next-next v2 2/5] net: marvell: prestera: Add PCI interface support Vadym Kochan
2020-05-01 0:00 ` Andrew Lunn
2020-05-01 6:22 ` Vadym Kochan
2020-05-01 13:25 ` Andrew Lunn
2020-05-11 11:23 ` Jiri Pirko
2020-05-26 16:26 ` Vadym Kochan
2020-05-27 5:53 ` Jiri Pirko
2020-05-27 8:55 ` Vadym Kochan
2020-05-27 12:01 ` Mickey Rachamim
2020-05-28 10:29 ` Jiri Pirko
2020-04-30 23:20 ` [RFC next-next v2 3/5] net: marvell: prestera: Add ethtool " Vadym Kochan
2020-05-11 17:31 ` Jiri Pirko
2020-04-30 23:20 ` [RFC next-next v2 4/5] net: marvell: prestera: Add Switchdev driver implementation Vadym Kochan
2020-04-30 23:20 ` [RFC next-next v2 5/5] dt-bindings: marvell,prestera: Add address mapping for Prestera Switchdev PCIe driver Vadym Kochan
2020-05-01 0:01 ` Andrew Lunn
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=20200512145352.GC31516@plvision.eu \
--to=vadym.kochan@plvision.eu \
--cc=Chris.Packham@alliedtelesis.co.nz \
--cc=andrew@lunn.ch \
--cc=andrii.savka@plvision.eu \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=jiri@resnulli.us \
--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=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).