netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <dlinkin@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <jiri@nvidia.com>,
	<stephen@networkplumber.org>, <dsahern@gmail.com>,
	<vladbu@nvidia.com>, <parav@nvidia.com>, <huyn@nvidia.com>,
	Dmytro Linkin <dlinkin@nvidia.com>
Subject: [PATCH RESEND net-next v3 02/18] netdevsim: Disable VFs on nsim_dev_reload_destroy() call
Date: Wed, 2 Jun 2021 15:17:15 +0300	[thread overview]
Message-ID: <1622636251-29892-3-git-send-email-dlinkin@nvidia.com> (raw)
In-Reply-To: <1622636251-29892-1-git-send-email-dlinkin@nvidia.com>

From: Dmytro Linkin <dlinkin@nvidia.com>

Move VFs disabling from device release() to nsim_dev_reload_destroy() to
make VFs disabling and ports removal simultaneous.
This is a requirement for VFs ports implemented in next patches.

Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 drivers/net/netdevsim/bus.c       | 5 +----
 drivers/net/netdevsim/dev.c       | 6 ++++++
 drivers/net/netdevsim/netdevsim.h | 1 +
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
index 4bd7ef3c..d5c547c 100644
--- a/drivers/net/netdevsim/bus.c
+++ b/drivers/net/netdevsim/bus.c
@@ -37,7 +37,7 @@ static int nsim_bus_dev_vfs_enable(struct nsim_bus_dev *nsim_bus_dev,
 	return 0;
 }
 
-static void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev)
+void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev)
 {
 	nsim_bus_dev->num_vfs = 0;
 }
@@ -233,9 +233,6 @@ ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 
 static void nsim_bus_dev_release(struct device *dev)
 {
-	struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev);
-
-	nsim_bus_dev_vfs_disable(nsim_bus_dev);
 }
 
 static struct device_type nsim_bus_dev_type = {
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 12df93a..cd50c05 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -1182,6 +1182,12 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
 	if (devlink_is_reload_failed(devlink))
 		return;
 	debugfs_remove(nsim_dev->take_snapshot);
+
+	mutex_lock(&nsim_dev->nsim_bus_dev->vfs_lock);
+	if (nsim_dev->nsim_bus_dev->num_vfs)
+		nsim_bus_dev_vfs_disable(nsim_dev->nsim_bus_dev);
+	mutex_unlock(&nsim_dev->nsim_bus_dev->vfs_lock);
+
 	nsim_dev_port_del_all(nsim_dev);
 	nsim_dev_psample_exit(nsim_dev);
 	nsim_dev_health_exit(nsim_dev);
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index 12f56f2..a1b49c8 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -276,6 +276,7 @@ ssize_t nsim_bus_dev_max_vfs_read(struct file *file,
 ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 				   const char __user *data,
 				   size_t count, loff_t *ppos);
+void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev);
 
 #if IS_ENABLED(CONFIG_XFRM_OFFLOAD)
 void nsim_ipsec_init(struct netdevsim *ns);
-- 
1.8.3.1


  parent reply	other threads:[~2021-06-02 12:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 12:17 [PATCH RESEND net-next v3 00/18] devlink: rate objects API dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 01/18] netdevsim: Add max_vfs to bus_dev dlinkin
2021-06-02 12:17 ` dlinkin [this message]
2021-06-02 12:17 ` [PATCH RESEND net-next v3 03/18] netdevsim: Implement port types and indexing dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 04/18] netdevsim: Implement VFs dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 05/18] netdevsim: Implement legacy/switchdev mode for VFs dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 06/18] devlink: Introduce rate object dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 07/18] netdevsim: Register devlink rate leaf objects per VF dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 08/18] selftest: netdevsim: Add devlink rate test dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 09/18] devlink: Allow setting tx rate for devlink rate leaf objects dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 10/18] netdevsim: Implement devlink rate leafs tx rate support dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 11/18] selftest: netdevsim: Add devlink port shared/max tx rate test dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 12/18] devlink: Introduce rate nodes dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 13/18] netdevsim: Implement support for devlink " dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 14/18] selftest: netdevsim: Add devlink rate nodes test dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 15/18] devlink: Allow setting parent node of rate objects dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 16/18] netdevsim: " dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 17/18] selftest: netdevsim: Add devlink rate grouping test dlinkin
2021-06-02 12:17 ` [PATCH RESEND net-next v3 18/18] Documentation: devlink rate objects dlinkin
2021-06-02 12:31 ` [PATCH RESEND iproute2 net-next 0/4] devlink rate support Dmytro Linkin
2021-06-02 12:31   ` [PATCH RESEND iproute2 net-next 1/4] uapi: update devlink kernel header Dmytro Linkin
2021-06-02 12:31   ` [PATCH RESEND iproute2 net-next 2/4] devlink: Add helper function to validate object handler Dmytro Linkin
2021-06-02 12:31   ` [PATCH RESEND iproute2 net-next 3/4] devlink: Add port func rate support Dmytro Linkin
2021-06-02 12:31   ` [PATCH RESEND iproute2 net-next 4/4] devlink: Add ISO/IEC switch Dmytro Linkin
2021-06-02 16:58 ` [PATCH RESEND net-next v3 00/18] devlink: rate objects API Jakub Kicinski
2021-06-03  8:53   ` Dmytro Linkin
2021-06-04  1:59   ` Yunsheng Lin

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=1622636251-29892-3-git-send-email-dlinkin@nvidia.com \
    --to=dlinkin@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=huyn@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=parav@nvidia.com \
    --cc=stephen@networkplumber.org \
    --cc=vladbu@nvidia.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).