From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
To: Jiri Pirko <jiri@resnulli.us>, netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com,
sfeldma@gmail.com, f.fainelli@gmail.com, linux@roeck-us.net,
vivien.didelot@savoirfairelinux.com, andrew@lunn.ch,
john.fastabend@gmail.com, David.Laight@ACULAB.COM,
stephen@networkplumber.org
Subject: Re: [patch net-next v2 4/7] switchdev: introduce possibility to defer obj_add/del
Date: Mon, 12 Oct 2015 16:34:25 +0200 [thread overview]
Message-ID: <561BC4F1.5080005@cumulusnetworks.com> (raw)
In-Reply-To: <1444655710-8279-5-git-send-email-jiri@resnulli.us>
On 10/12/2015 03:15 PM, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
>
> Similar to the attr usecase, the caller knows if he is holding RTNL and is
> in atomic section. So let the called to decide the correct call variant.
>
> This allows drivers to sleep inside their ops and wait for hw to get the
> operation status. Then the status is propagated into switchdev core.
> This avoids silent errors in drivers.
>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
> include/net/switchdev.h | 1 +
> net/switchdev/switchdev.c | 137 +++++++++++++++++++++++++++++++++++++---------
> 2 files changed, 112 insertions(+), 26 deletions(-)
>
[snip]
> +
> +struct switchdev_obj_work {
> + struct work_struct work;
> + struct net_device *dev;
> + struct switchdev_obj obj;
> + bool add; /* add of del */
s/of/or/ ? :-)
> +};
> +
> +static void switchdev_port_obj_work(struct work_struct *work)
> +{
> + struct switchdev_obj_work *ow =
> + container_of(work, struct switchdev_obj_work, work);
> + bool rtnl_locked = rtnl_is_locked();
> + int err;
> +
> + if (!rtnl_locked)
> + rtnl_lock();
> + if (ow->add)
> + err = switchdev_port_obj_add_now(ow->dev, &ow->obj);
> + else
> + err = switchdev_port_obj_del_now(ow->dev, &ow->obj);
> + if (err && err != -EOPNOTSUPP)
> + netdev_err(ow->dev, "failed (err=%d) to %s object (id=%d)\n",
> + err, ow->add ? "add" : "del", ow->obj.id);
> + if (!rtnl_locked)
> + rtnl_unlock();
> +
> + dev_put(ow->dev);
> + kfree(ow);
> +}
> +
> +static int switchdev_port_obj_work_schedule(struct net_device *dev,
> + const struct switchdev_obj *obj,
> + bool add)
> +{
> + struct switchdev_obj_work *ow;
> +
> + ow = kmalloc(sizeof(*ow), GFP_ATOMIC);
> + if (!ow)
> + return -ENOMEM;
> +
> + INIT_WORK(&ow->work, switchdev_port_obj_work);
> +
This can be called without rtnl, what stops the device from disappearing
between the above and the hold below ?
> + dev_hold(dev);
> + ow->dev = dev;
> + memcpy(&ow->obj, obj, sizeof(ow->obj));
> + ow->add = add;
> +
> + queue_work(switchdev_wq, &ow->work);
> + return 0;
> +}
> +
[snip]
next prev parent reply other threads:[~2015-10-12 14:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 13:15 [patch net-next v2 0/7] switchdev: change locking Jiri Pirko
2015-10-12 13:15 ` [patch net-next v2 1/7] switchdev: introduce switchdev workqueue Jiri Pirko
2015-10-12 13:15 ` [patch net-next v2 2/7] switchdev: allow caller to explicitly request attr_set as deferred Jiri Pirko
2015-10-12 13:15 ` [patch net-next v2 3/7] switchdev: remove pointers from switchdev objects Jiri Pirko
2015-10-12 13:15 ` [patch net-next v2 4/7] switchdev: introduce possibility to defer obj_add/del Jiri Pirko
2015-10-12 14:34 ` Nikolay Aleksandrov [this message]
2015-10-12 14:42 ` Nikolay Aleksandrov
2015-10-12 14:57 ` Jiri Pirko
2015-10-12 14:44 ` Jiri Pirko
2015-10-12 14:46 ` Nikolay Aleksandrov
2015-10-12 13:15 ` [patch net-next v2 5/7] bridge: defer switchdev fdb del call in fdb_del_external_learn Jiri Pirko
2015-10-12 13:15 ` [patch net-next v2 6/7] rocker: remove nowait from switchdev callbacks Jiri Pirko
2015-10-12 13:15 ` [patch net-next v2 7/7] switchdev: assert rtnl mutex when going over lower netdevs Jiri Pirko
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=561BC4F1.5080005@cumulusnetworks.com \
--to=nikolay@cumulusnetworks.com \
--cc=David.Laight@ACULAB.COM \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=eladr@mellanox.com \
--cc=f.fainelli@gmail.com \
--cc=idosch@mellanox.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=sfeldma@gmail.com \
--cc=stephen@networkplumber.org \
--cc=vivien.didelot@savoirfairelinux.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: 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).