Re: [PATCH net v6 5/6] net: marvell: prestera: Add Switchdev driver implementation

From: Vadym Kochan
Date: Fri Sep 04 2020 - 05:35:04 EST


On Thu, Sep 03, 2020 at 07:18:59PM +0200, Willem de Bruijn wrote:
> On Wed, Sep 2, 2020 at 5:07 PM Vadym Kochan <vadym.kochan@xxxxxxxxxxx> 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
> >
> > Co-developed-by: Serhiy Boiko <serhiy.boiko@xxxxxxxxxxx>
> > Signed-off-by: Serhiy Boiko <serhiy.boiko@xxxxxxxxxxx>
> > Co-developed-by: Serhiy Pshyk <serhiy.pshyk@xxxxxxxxxxx>
> > Signed-off-by: Serhiy Pshyk <serhiy.pshyk@xxxxxxxxxxx>
> > Co-developed-by: Taras Chornyi <taras.chornyi@xxxxxxxxxxx>
> > Signed-off-by: Taras Chornyi <taras.chornyi@xxxxxxxxxxx>
> > Signed-off-by: Vadym Kochan <vadym.kochan@xxxxxxxxxxx>
>
>
> > +int prestera_switchdev_init(struct prestera_switch *sw)
> > +{
> > + struct prestera_switchdev *swdev;
> > + int err;
> > +
> > + swdev = kzalloc(sizeof(*swdev), GFP_KERNEL);
> > + if (!swdev)
> > + return -ENOMEM;
> > +
> > + sw->swdev = swdev;
> > + swdev->sw = sw;
> > +
> > + INIT_LIST_HEAD(&swdev->bridge_list);
> > +
> > + swdev_wq = alloc_ordered_workqueue("%s_ordered", 0, "prestera_br");
> > + if (!swdev_wq) {
> > + err = -ENOMEM;
> > + goto err_alloc_wq;
> > + }
> > +
> > + err = prestera_switchdev_handler_init(swdev);
> > + if (err)
> > + goto err_swdev_init;
> > +
> > + err = prestera_fdb_init(sw);
> > + if (err)
> > + goto err_fdb_init;
> > +
> > + return 0;
> > +
> > +err_fdb_init:
> > +err_swdev_init:
> > +err_alloc_wq:
> > + kfree(swdev);
> > +
> > + return err;
> > +}
> > +
> > +void prestera_switchdev_fini(struct prestera_switch *sw)
> > +{
> > + struct prestera_switchdev *swdev = sw->swdev;
> > +
> > + prestera_fdb_fini(sw);
> > + prestera_switchdev_handler_fini(swdev);
> > + destroy_workqueue(swdev_wq);
>
> this cleanup is also needed on the error path of prestera_switchdev_init
>

Thanks! I will fix it.

> > + kfree(swdev);
> > +}