From: Jakub Kicinski <kuba@kernel.org>
To: leon@kernel.org, idosch@idosch.org
Cc: edwin.peer@broadcom.com, jiri@resnulli.us,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [RFC 4/5] netdevsim: minor code move
Date: Sat, 30 Oct 2021 16:12:53 -0700 [thread overview]
Message-ID: <20211030231254.2477599-5-kuba@kernel.org> (raw)
In-Reply-To: <20211030231254.2477599-1-kuba@kernel.org>
Move the port add/del helpers
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/netdevsim/dev.c | 54 ++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 28 deletions(-)
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 5db40d713d2a..b15763a8e89a 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -567,7 +567,32 @@ static void nsim_dev_dummy_region_exit(struct nsim_dev *nsim_dev)
devlink_region_destroy(nsim_dev->dummy_region);
}
-static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port);
+static struct nsim_dev_port *
+__nsim_dev_port_lookup(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
+ unsigned int port_index)
+{
+ struct nsim_dev_port *nsim_dev_port;
+
+ port_index = nsim_dev_port_index(type, port_index);
+ list_for_each_entry(nsim_dev_port, &nsim_dev->port_list, list)
+ if (nsim_dev_port->port_index == port_index)
+ return nsim_dev_port;
+ return NULL;
+}
+
+static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port)
+{
+ struct devlink_port *devlink_port = &nsim_dev_port->devlink_port;
+
+ list_del(&nsim_dev_port->list);
+ if (nsim_dev_port_is_vf(nsim_dev_port))
+ devlink_rate_leaf_destroy(&nsim_dev_port->devlink_port);
+ devlink_port_type_clear(devlink_port);
+ nsim_destroy(nsim_dev_port->ns);
+ nsim_dev_port_debugfs_exit(nsim_dev_port);
+ devlink_port_unregister(devlink_port);
+ kfree(nsim_dev_port);
+}
static int nsim_esw_legacy_enable(struct nsim_dev *nsim_dev,
struct netlink_ext_ack *extack)
@@ -1418,20 +1443,6 @@ static int __nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_typ
return err;
}
-static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port)
-{
- struct devlink_port *devlink_port = &nsim_dev_port->devlink_port;
-
- list_del(&nsim_dev_port->list);
- if (nsim_dev_port_is_vf(nsim_dev_port))
- devlink_rate_leaf_destroy(&nsim_dev_port->devlink_port);
- devlink_port_type_clear(devlink_port);
- nsim_destroy(nsim_dev_port->ns);
- nsim_dev_port_debugfs_exit(nsim_dev_port);
- devlink_port_unregister(devlink_port);
- kfree(nsim_dev_port);
-}
-
static void nsim_dev_port_del_all(struct nsim_dev *nsim_dev)
{
struct nsim_dev_port *nsim_dev_port, *tmp;
@@ -1674,19 +1685,6 @@ void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev)
dev_set_drvdata(&nsim_bus_dev->dev, NULL);
}
-static struct nsim_dev_port *
-__nsim_dev_port_lookup(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
- unsigned int port_index)
-{
- struct nsim_dev_port *nsim_dev_port;
-
- port_index = nsim_dev_port_index(type, port_index);
- list_for_each_entry(nsim_dev_port, &nsim_dev->port_list, list)
- if (nsim_dev_port->port_index == port_index)
- return nsim_dev_port;
- return NULL;
-}
-
int nsim_drv_port_add(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type type,
unsigned int port_index)
{
--
2.31.1
next prev parent reply other threads:[~2021-10-30 23:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-30 23:12 [RFC 0/5] devlink: add an explicit locking API Jakub Kicinski
2021-10-30 23:12 ` [RFC 1/5] devlink: add unlocked APIs Jakub Kicinski
2021-10-30 23:12 ` [RFC 2/5] devlink: add API for explicit locking Jakub Kicinski
2021-10-30 23:12 ` [RFC 3/5] devlink: allow locking of all ops Jakub Kicinski
2021-10-30 23:12 ` Jakub Kicinski [this message]
2021-10-30 23:12 ` [RFC 5/5] netdevsim: use devlink locking Jakub Kicinski
2021-10-31 7:23 ` [RFC 0/5] devlink: add an explicit locking API Leon Romanovsky
2021-11-01 14:32 ` Jakub Kicinski
2021-11-01 18:36 ` Leon Romanovsky
2021-11-01 21:16 ` Jakub Kicinski
2021-11-02 8:08 ` Leon Romanovsky
2021-11-02 15:14 ` Jakub Kicinski
2021-11-02 18:14 ` Leon Romanovsky
2021-11-03 0:05 ` Jakub Kicinski
2021-11-03 7:23 ` Leon Romanovsky
2021-11-03 14:12 ` Jakub Kicinski
2021-11-01 20:04 ` Edwin Peer
2021-11-02 7:44 ` Leon Romanovsky
2021-11-02 15:16 ` Jakub Kicinski
2021-11-02 17:50 ` Leon Romanovsky
2021-11-03 9:03 ` Jiri Pirko
2021-11-03 14:52 ` Jakub Kicinski
2021-11-03 19:19 ` 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=20211030231254.2477599-5-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=edwin.peer@broadcom.com \
--cc=idosch@idosch.org \
--cc=jiri@resnulli.us \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
/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).