From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, michael.chan@broadcom.com,
ioana.ciornei@nxp.com, dmichail@fungible.com,
jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com,
tchornyi@marvell.com, tariqt@nvidia.com, saeedm@nvidia.com,
leon@kernel.org, idosch@nvidia.com, petrm@nvidia.com,
vladimir.oltean@nxp.com, claudiu.manoil@nxp.com,
alexandre.belloni@bootlin.com, simon.horman@corigine.com,
shannon.nelson@amd.com, brett.creeley@amd.com
Subject: [patch net-next 2/8] netdevsim: call devl_port_register/unregister() on registered instance
Date: Mon, 5 Dec 2022 16:22:51 +0100 [thread overview]
Message-ID: <20221205152257.454610-3-jiri@resnulli.us> (raw)
In-Reply-To: <20221205152257.454610-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
Move the code so devl_port_register/unregister() are called only
then devlink is registered.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
RFC->v1:
- shortened patch subject
---
drivers/net/netdevsim/dev.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index b962fc8e1397..8ed235ac986f 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -949,6 +949,7 @@ static void nsim_dev_traps_exit(struct devlink *devlink)
static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
struct netlink_ext_ack *extack);
+static void nsim_dev_reload_ports_destroy(struct nsim_dev *nsim_dev);
static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev);
static int nsim_dev_reload_down(struct devlink *devlink, bool netns_change,
@@ -965,6 +966,7 @@ static int nsim_dev_reload_down(struct devlink *devlink, bool netns_change,
return -EOPNOTSUPP;
}
+ nsim_dev_reload_ports_destroy(nsim_dev);
nsim_dev_reload_destroy(nsim_dev);
return 0;
}
@@ -1600,17 +1602,22 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
if (err)
goto err_psample_exit;
- err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
- if (err)
- goto err_hwstats_exit;
-
nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY;
devlink_set_features(devlink, DEVLINK_F_RELOAD);
devl_unlock(devlink);
devlink_register(devlink);
+
+ devl_lock(devlink);
+ err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
+ devl_unlock(devlink);
+ if (err)
+ goto err_devlink_unregister;
+
return 0;
-err_hwstats_exit:
+err_devlink_unregister:
+ devlink_unregister(devlink);
+ devl_lock(devlink);
nsim_dev_hwstats_exit(nsim_dev);
err_psample_exit:
nsim_dev_psample_exit(nsim_dev);
@@ -1640,6 +1647,15 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
return err;
}
+static void nsim_dev_reload_ports_destroy(struct nsim_dev *nsim_dev)
+{
+ struct devlink *devlink = priv_to_devlink(nsim_dev);
+
+ if (devlink_is_reload_failed(devlink))
+ return;
+ nsim_dev_port_del_all(nsim_dev);
+}
+
static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
{
struct devlink *devlink = priv_to_devlink(nsim_dev);
@@ -1654,7 +1670,6 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
nsim_esw_legacy_enable(nsim_dev, NULL);
}
- nsim_dev_port_del_all(nsim_dev);
nsim_dev_hwstats_exit(nsim_dev);
nsim_dev_psample_exit(nsim_dev);
nsim_dev_health_exit(nsim_dev);
@@ -1668,6 +1683,10 @@ void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev)
struct nsim_dev *nsim_dev = dev_get_drvdata(&nsim_bus_dev->dev);
struct devlink *devlink = priv_to_devlink(nsim_dev);
+ devl_lock(devlink);
+ nsim_dev_reload_ports_destroy(nsim_dev);
+ devl_unlock(devlink);
+
devlink_unregister(devlink);
devl_lock(devlink);
nsim_dev_reload_destroy(nsim_dev);
--
2.37.3
next prev parent reply other threads:[~2022-12-05 15:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 15:22 [patch net-next 0/8] devlink: make sure devlink port registers/unregisters only for registered instance Jiri Pirko
2022-12-05 15:22 ` [patch net-next 1/8] devlink: call devlink_port_register/unregister() on " Jiri Pirko
2022-12-05 23:55 ` Shannon Nelson
2022-12-06 7:41 ` Jiri Pirko
2022-12-06 7:56 ` Leon Romanovsky
2022-12-06 17:35 ` Shannon Nelson
2022-12-07 13:27 ` Jiri Pirko
2022-12-07 19:45 ` Shannon Nelson
2022-12-05 15:22 ` Jiri Pirko [this message]
2022-12-05 15:22 ` [patch net-next 3/8] mlxsw: call devl_port_register/unregister() " Jiri Pirko
2022-12-05 15:22 ` [patch net-next 4/8] nfp: " Jiri Pirko
2022-12-05 15:22 ` [patch net-next 5/8] mlx4: " Jiri Pirko
2022-12-05 15:22 ` [patch net-next 6/8] mlx5: " Jiri Pirko
2022-12-05 15:22 ` [patch net-next 7/8] devlink: assert if devl_port_register/unregister() is called on unregistered devlink instance Jiri Pirko
2022-12-05 15:22 ` [patch net-next 8/8] devlink: remove port notifications from devlink_register/unregister() Jiri Pirko
2022-12-06 1:08 ` [patch net-next 0/8] devlink: make sure devlink port registers/unregisters only for registered instance Jakub Kicinski
2022-12-06 7:44 ` Jiri Pirko
2022-12-06 20:12 ` Jakub Kicinski
2022-12-07 13:28 ` 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=20221205152257.454610-3-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=alexandre.belloni@bootlin.com \
--cc=anthony.l.nguyen@intel.com \
--cc=brett.creeley@amd.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=dmichail@fungible.com \
--cc=edumazet@google.com \
--cc=idosch@nvidia.com \
--cc=ioana.ciornei@nxp.com \
--cc=jesse.brandeburg@intel.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=shannon.nelson@amd.com \
--cc=simon.horman@corigine.com \
--cc=tariqt@nvidia.com \
--cc=tchornyi@marvell.com \
--cc=vladimir.oltean@nxp.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).