[net-next,v7,4/8] devlink: Add support for driverinit get value for devlink_port
diff mbox series

Message ID 1547795385-12354-5-git-send-email-vasundhara-v.volam@broadcom.com
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • devlink: Add configuration parameters support for devlink_port
Related show

Commit Message

Vasundhara Volam Jan. 18, 2019, 7:09 a.m. UTC
Add support for "driverinit" configuration mode value for devlink_port
configuration parameters. Add devlink_port_param_driverinit_value_get()
function to help the driver get the value from devlink_port.

Also, move the common code to __devlink_param_driverinit_value_get()
to be used by both device and port params.

Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
---
 include/net/devlink.h |  8 ++++++
 net/core/devlink.c    | 67 ++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 58 insertions(+), 17 deletions(-)

Comments

Jiri Pirko Jan. 23, 2019, 11:08 a.m. UTC | #1
Fri, Jan 18, 2019 at 08:09:41AM CET, vasundhara-v.volam@broadcom.com wrote:
>Add support for "driverinit" configuration mode value for devlink_port
>configuration parameters. Add devlink_port_param_driverinit_value_get()
>function to help the driver get the value from devlink_port.
>
>Also, move the common code to __devlink_param_driverinit_value_get()
>to be used by both device and port params.
>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
>---
> include/net/devlink.h |  8 ++++++
> net/core/devlink.c    | 67 ++++++++++++++++++++++++++++++++++++++-------------
> 2 files changed, 58 insertions(+), 17 deletions(-)
>
>diff --git a/include/net/devlink.h b/include/net/devlink.h
>index 98b8a66..09f3f43 100644
>--- a/include/net/devlink.h
>+++ b/include/net/devlink.h
>@@ -838,6 +838,14 @@ static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
> {
> }
> 
>+static inline int
>+devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
>+					u32 param_id,
>+					union devlink_param_value *init_val)
>+{
>+	return -EOPNOTSUPP;
>+}


You are missing function declaration in case IS_ENABLED(CONFIG_NET_DEVLINK

Otherwise this looks fine.


>+
> static inline struct devlink_region *
> devlink_region_create(struct devlink *devlink,
> 		      const char *region_name,

[...]
Vasundhara Volam Jan. 23, 2019, 11:36 a.m. UTC | #2
On Wed, Jan 23, 2019 at 4:47 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Fri, Jan 18, 2019 at 08:09:41AM CET, vasundhara-v.volam@broadcom.com wrote:
> >Add support for "driverinit" configuration mode value for devlink_port
> >configuration parameters. Add devlink_port_param_driverinit_value_get()
> >function to help the driver get the value from devlink_port.
> >
> >Also, move the common code to __devlink_param_driverinit_value_get()
> >to be used by both device and port params.
> >
> >Cc: Jiri Pirko <jiri@mellanox.com>
> >Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
> >---
> > include/net/devlink.h |  8 ++++++
> > net/core/devlink.c    | 67 ++++++++++++++++++++++++++++++++++++++-------------
> > 2 files changed, 58 insertions(+), 17 deletions(-)
> >
> >diff --git a/include/net/devlink.h b/include/net/devlink.h
> >index 98b8a66..09f3f43 100644
> >--- a/include/net/devlink.h
> >+++ b/include/net/devlink.h
> >@@ -838,6 +838,14 @@ static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
> > {
> > }
> >
> >+static inline int
> >+devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
> >+                                      u32 param_id,
> >+                                      union devlink_param_value *init_val)
> >+{
> >+      return -EOPNOTSUPP;
> >+}
>
>
> You are missing function declaration in case IS_ENABLED(CONFIG_NET_DEVLINK
>
> Otherwise this looks fine.
Thank you for pointing. It is a mistake. I will fix it in next version.
>
>
> >+
> > static inline struct devlink_region *
> > devlink_region_create(struct devlink *devlink,
> >                     const char *region_name,
>
> [...]
>

Patch
diff mbox series

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 98b8a66..09f3f43 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -838,6 +838,14 @@  static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
 {
 }
 
+static inline int
+devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
+					u32 param_id,
+					union devlink_param_value *init_val)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline struct devlink_region *
 devlink_region_create(struct devlink *devlink,
 		      const char *region_name,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index be083a9..53755ff 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4677,26 +4677,13 @@  void devlink_params_unregister(struct devlink *devlink,
 }
 EXPORT_SYMBOL_GPL(devlink_params_unregister);
 
-/**
- *	devlink_param_driverinit_value_get - get configuration parameter
- *					     value for driver initializing
- *
- *	@devlink: devlink
- *	@param_id: parameter ID
- *	@init_val: value of parameter in driverinit configuration mode
- *
- *	This function should be used by the driver to get driverinit
- *	configuration for initialization after reload command.
- */
-int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
-				       union devlink_param_value *init_val)
+static int
+__devlink_param_driverinit_value_get(struct list_head *param_list, u32 param_id,
+				     union devlink_param_value *init_val)
 {
 	struct devlink_param_item *param_item;
 
-	if (!devlink->ops || !devlink->ops->reload)
-		return -EOPNOTSUPP;
-
-	param_item = devlink_param_find_by_id(&devlink->param_list, param_id);
+	param_item = devlink_param_find_by_id(param_list, param_id);
 	if (!param_item)
 		return -EINVAL;
 
@@ -4712,6 +4699,27 @@  int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
 
 	return 0;
 }
+
+/**
+ *	devlink_param_driverinit_value_get - get configuration parameter
+ *					     value for driver initializing
+ *
+ *	@devlink: devlink
+ *	@param_id: parameter ID
+ *	@init_val: value of parameter in driverinit configuration mode
+ *
+ *	This function should be used by the driver to get driverinit
+ *	configuration for initialization after reload command.
+ */
+int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
+				       union devlink_param_value *init_val)
+{
+	if (!devlink->ops || !devlink->ops->reload)
+		return -EOPNOTSUPP;
+
+	return __devlink_param_driverinit_value_get(&devlink->param_list,
+						    param_id, init_val);
+}
 EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_get);
 
 /**
@@ -4829,6 +4837,31 @@  void devlink_port_params_unregister(struct devlink_port *devlink_port,
 EXPORT_SYMBOL_GPL(devlink_port_params_unregister);
 
 /**
+ *	devlink_port_param_driverinit_value_get - get configuration parameter
+ *						value for driver initializing
+ *
+ *	@devlink_port: devlink_port
+ *	@param_id: parameter ID
+ *	@init_val: value of parameter in driverinit configuration mode
+ *
+ *	This function should be used by the driver to get driverinit
+ *	configuration for initialization after reload command.
+ */
+int devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
+					    u32 param_id,
+					    union devlink_param_value *init_val)
+{
+	struct devlink *devlink = devlink_port->devlink;
+
+	if (!devlink->ops || !devlink->ops->reload)
+		return -EOPNOTSUPP;
+
+	return __devlink_param_driverinit_value_get(&devlink_port->param_list,
+						    param_id, init_val);
+}
+EXPORT_SYMBOL_GPL(devlink_port_param_driverinit_value_get);
+
+/**
  *	devlink_region_create - create a new address region
  *
  *	@devlink: devlink