All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next v2 0/3] net: devlink: devl_* cosmetic fixes
@ 2022-07-01 16:40 Jiri Pirko
  2022-07-01 16:40 ` [patch net-next v2 1/3] net: devlink: move unlocked function prototypes alongside the locked ones Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jiri Pirko @ 2022-07-01 16:40 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, mlxsw, saeedm, moshe

From: Jiri Pirko <jiri@nvidia.com>

Hi. This patches just fixes some small cosmetic issues of devl_* related
functions which I found on the way.

Jiri Pirko (3):
  net: devlink: move unlocked function prototypes alongside the locked
    ones
  net: devlink: call lockdep_assert_held() for devlink->lock directly
  net: devlink: fix unlocked vs locked functions descriptions

 include/net/devlink.h | 16 +++++++---------
 net/core/devlink.c    | 42 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 46 insertions(+), 12 deletions(-)

-- 
2.35.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch net-next v2 1/3] net: devlink: move unlocked function prototypes alongside the locked ones
  2022-07-01 16:40 [patch net-next v2 0/3] net: devlink: devl_* cosmetic fixes Jiri Pirko
@ 2022-07-01 16:40 ` Jiri Pirko
  2022-07-01 16:40 ` [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly Jiri Pirko
  2022-07-01 16:40 ` [patch net-next v2 3/3] net: devlink: fix unlocked vs locked functions descriptions Jiri Pirko
  2 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2022-07-01 16:40 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, mlxsw, saeedm, moshe

From: Jiri Pirko <jiri@nvidia.com>

Maintain the same order as it is in devlink.c for function prototypes.
The most of the locked variants would very likely soon be removed
and the unlocked version would be the only one.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 include/net/devlink.h | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index b8f54a8e9c82..edbfe6daa3b5 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -1520,15 +1520,6 @@ void devl_unlock(struct devlink *devlink);
 void devl_assert_locked(struct devlink *devlink);
 bool devl_lock_is_held(struct devlink *devlink);
 
-int devl_port_register(struct devlink *devlink,
-		       struct devlink_port *devlink_port,
-		       unsigned int port_index);
-void devl_port_unregister(struct devlink_port *devlink_port);
-
-int devl_rate_leaf_create(struct devlink_port *port, void *priv);
-void devl_rate_leaf_destroy(struct devlink_port *devlink_port);
-void devl_rate_nodes_destroy(struct devlink *devlink);
-
 struct ib_device;
 
 struct net *devlink_net(const struct devlink *devlink);
@@ -1550,9 +1541,13 @@ void devlink_set_features(struct devlink *devlink, u64 features);
 void devlink_register(struct devlink *devlink);
 void devlink_unregister(struct devlink *devlink);
 void devlink_free(struct devlink *devlink);
+int devl_port_register(struct devlink *devlink,
+		       struct devlink_port *devlink_port,
+		       unsigned int port_index);
 int devlink_port_register(struct devlink *devlink,
 			  struct devlink_port *devlink_port,
 			  unsigned int port_index);
+void devl_port_unregister(struct devlink_port *devlink_port);
 void devlink_port_unregister(struct devlink_port *devlink_port);
 void devlink_port_type_eth_set(struct devlink_port *devlink_port,
 			       struct net_device *netdev);
@@ -1568,8 +1563,11 @@ void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro
 void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port,
 				   u32 controller, u16 pf, u32 sf,
 				   bool external);
+int devl_rate_leaf_create(struct devlink_port *port, void *priv);
 int devlink_rate_leaf_create(struct devlink_port *port, void *priv);
+void devl_rate_leaf_destroy(struct devlink_port *devlink_port);
 void devlink_rate_leaf_destroy(struct devlink_port *devlink_port);
+void devl_rate_nodes_destroy(struct devlink *devlink);
 void devlink_rate_nodes_destroy(struct devlink *devlink);
 void devlink_port_linecard_set(struct devlink_port *devlink_port,
 			       struct devlink_linecard *linecard);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly
  2022-07-01 16:40 [patch net-next v2 0/3] net: devlink: devl_* cosmetic fixes Jiri Pirko
  2022-07-01 16:40 ` [patch net-next v2 1/3] net: devlink: move unlocked function prototypes alongside the locked ones Jiri Pirko
@ 2022-07-01 16:40 ` Jiri Pirko
  2022-07-02  3:10   ` Jakub Kicinski
  2022-07-01 16:40 ` [patch net-next v2 3/3] net: devlink: fix unlocked vs locked functions descriptions Jiri Pirko
  2 siblings, 1 reply; 6+ messages in thread
From: Jiri Pirko @ 2022-07-01 16:40 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, mlxsw, saeedm, moshe

From: Jiri Pirko <jiri@nvidia.com>

In devlink.c there is direct access to whole struct devlink so there is
no need to use helper. So obey the customs and work with lock directly
avoiding helpers which might obfuscate things a bit.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 net/core/devlink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 25b481dd1709..a7477addbd59 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -10185,7 +10185,7 @@ int devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv)
 	struct devlink *devlink = devlink_port->devlink;
 	struct devlink_rate *devlink_rate;
 
-	devl_assert_locked(devlink_port->devlink);
+	lockdep_assert_held(&devlink_port->devlink->lock);
 
 	if (WARN_ON(devlink_port->devlink_rate))
 		return -EBUSY;
@@ -10224,7 +10224,7 @@ void devl_rate_leaf_destroy(struct devlink_port *devlink_port)
 {
 	struct devlink_rate *devlink_rate = devlink_port->devlink_rate;
 
-	devl_assert_locked(devlink_port->devlink);
+	lockdep_assert_held(&devlink_port->devlink->lock);
 	if (!devlink_rate)
 		return;
 
@@ -10270,7 +10270,7 @@ void devl_rate_nodes_destroy(struct devlink *devlink)
 	static struct devlink_rate *devlink_rate, *tmp;
 	const struct devlink_ops *ops = devlink->ops;
 
-	devl_assert_locked(devlink);
+	lockdep_assert_held(&devlink->lock);
 
 	list_for_each_entry(devlink_rate, &devlink->rate_list, list) {
 		if (!devlink_rate->parent)
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch net-next v2 3/3] net: devlink: fix unlocked vs locked functions descriptions
  2022-07-01 16:40 [patch net-next v2 0/3] net: devlink: devl_* cosmetic fixes Jiri Pirko
  2022-07-01 16:40 ` [patch net-next v2 1/3] net: devlink: move unlocked function prototypes alongside the locked ones Jiri Pirko
  2022-07-01 16:40 ` [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly Jiri Pirko
@ 2022-07-01 16:40 ` Jiri Pirko
  2 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2022-07-01 16:40 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, mlxsw, saeedm, moshe

From: Jiri Pirko <jiri@nvidia.com>

To be unified with the rest of the code, the unlocked version (devl_*)
of function should have the same description in documentation as the
locked one. Add the missing documentation. Also, add "Context"
annotation for the locked versions where it is missing.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
v1->v2:
- s/devlink_/devl_/ for unregister comment
- removed tabs
- added ()s
---
 net/core/devlink.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index a7477addbd59..330a7260fae0 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -9877,6 +9877,19 @@ static void devlink_port_type_warn_cancel(struct devlink_port *devlink_port)
 	cancel_delayed_work_sync(&devlink_port->type_warn_dw);
 }
 
+/**
+ * devl_port_register() - Register devlink port
+ *
+ * @devlink: devlink
+ * @devlink_port: devlink port
+ * @port_index: driver-specific numerical identifier of the port
+ *
+ * Register devlink port with provided port index. User can use
+ * any indexing, even hw-related one. devlink_port structure
+ * is convenient to be embedded inside user driver private structure.
+ * Note that the caller should take care of zeroing the devlink_port
+ * structure.
+ */
 int devl_port_register(struct devlink *devlink,
 		       struct devlink_port *devlink_port,
 		       unsigned int port_index)
@@ -9915,6 +9928,8 @@ EXPORT_SYMBOL_GPL(devl_port_register);
  *	is convenient to be embedded inside user driver private structure.
  *	Note that the caller should take care of zeroing the devlink_port
  *	structure.
+ *
+ *	Context: Takes and release devlink->lock <mutex>.
  */
 int devlink_port_register(struct devlink *devlink,
 			  struct devlink_port *devlink_port,
@@ -9929,6 +9944,11 @@ int devlink_port_register(struct devlink *devlink,
 }
 EXPORT_SYMBOL_GPL(devlink_port_register);
 
+/**
+ * devl_port_unregister() - Unregister devlink port
+ *
+ * @devlink_port: devlink port
+ */
 void devl_port_unregister(struct devlink_port *devlink_port)
 {
 	lockdep_assert_held(&devlink_port->devlink->lock);
@@ -9946,6 +9966,8 @@ EXPORT_SYMBOL_GPL(devl_port_unregister);
  *	devlink_port_unregister - Unregister devlink port
  *
  *	@devlink_port: devlink port
+ *
+ *	Context: Takes and release devlink->lock <mutex>.
  */
 void devlink_port_unregister(struct devlink_port *devlink_port)
 {
@@ -10206,6 +10228,15 @@ int devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv)
 }
 EXPORT_SYMBOL_GPL(devl_rate_leaf_create);
 
+/**
+ * devlink_rate_leaf_create - create devlink rate leaf
+ * @devlink_port: devlink port object to create rate object on
+ * @priv: driver private data
+ *
+ * Create devlink rate object of type leaf on provided @devlink_port.
+ *
+ * Context: Takes and release devlink->lock <mutex>.
+ */
 int
 devlink_rate_leaf_create(struct devlink_port *devlink_port, void *priv)
 {
@@ -10220,6 +10251,11 @@ devlink_rate_leaf_create(struct devlink_port *devlink_port, void *priv)
 }
 EXPORT_SYMBOL_GPL(devlink_rate_leaf_create);
 
+/**
+ * devl_rate_leaf_destroy - destroy devlink rate leaf
+ *
+ * @devlink_port: devlink port linked to the rate object
+ */
 void devl_rate_leaf_destroy(struct devlink_port *devlink_port)
 {
 	struct devlink_rate *devlink_rate = devlink_port->devlink_rate;
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly
  2022-07-01 16:40 ` [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly Jiri Pirko
@ 2022-07-02  3:10   ` Jakub Kicinski
  2022-07-02 15:59     ` Jiri Pirko
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2022-07-02  3:10 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, pabeni, edumazet, mlxsw, saeedm, moshe

On Fri,  1 Jul 2022 18:40:06 +0200 Jiri Pirko wrote:
> In devlink.c there is direct access to whole struct devlink so there is
> no need to use helper. So obey the customs and work with lock directly
> avoiding helpers which might obfuscate things a bit.

I think you sent this as / before I replied to all the patches.
Still not sure what the basis for the custom is.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly
  2022-07-02  3:10   ` Jakub Kicinski
@ 2022-07-02 15:59     ` Jiri Pirko
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2022-07-02 15:59 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, davem, pabeni, edumazet, mlxsw, saeedm, moshe

Sat, Jul 02, 2022 at 05:10:21AM CEST, kuba@kernel.org wrote:
>On Fri,  1 Jul 2022 18:40:06 +0200 Jiri Pirko wrote:
>> In devlink.c there is direct access to whole struct devlink so there is
>> no need to use helper. So obey the customs and work with lock directly
>> avoiding helpers which might obfuscate things a bit.
>
>I think you sent this as / before I replied to all the patches.

Sorry.

>Still not sure what the basis for the custom is.

Please see the reply to your comment of this patch in v1. Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-02 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-01 16:40 [patch net-next v2 0/3] net: devlink: devl_* cosmetic fixes Jiri Pirko
2022-07-01 16:40 ` [patch net-next v2 1/3] net: devlink: move unlocked function prototypes alongside the locked ones Jiri Pirko
2022-07-01 16:40 ` [patch net-next v2 2/3] net: devlink: call lockdep_assert_held() for devlink->lock directly Jiri Pirko
2022-07-02  3:10   ` Jakub Kicinski
2022-07-02 15:59     ` Jiri Pirko
2022-07-01 16:40 ` [patch net-next v2 3/3] net: devlink: fix unlocked vs locked functions descriptions Jiri Pirko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.