Commit ffd19b9a authored by Vasundhara Volam's avatar Vasundhara Volam Committed by David S. Miller

devlink: Add support for driverinit get value for devlink_port

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.

v7->v8:
-Add the missing devlink_port_param_driverinit_value_get() declaration.
-Also, order devlink_port_param_driverinit_value_get() after
devlink_param_driverinit_value_get/set() calls

Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c54873b
...@@ -578,6 +578,10 @@ int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, ...@@ -578,6 +578,10 @@ int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
union devlink_param_value *init_val); union devlink_param_value *init_val);
int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
union devlink_param_value init_val); union devlink_param_value init_val);
int
devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
u32 param_id,
union devlink_param_value *init_val);
void devlink_param_value_changed(struct devlink *devlink, u32 param_id); void devlink_param_value_changed(struct devlink *devlink, u32 param_id);
void devlink_param_value_str_fill(union devlink_param_value *dst_val, void devlink_param_value_str_fill(union devlink_param_value *dst_val,
const char *src); const char *src);
...@@ -827,6 +831,14 @@ devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, ...@@ -827,6 +831,14 @@ devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
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 void static inline void
devlink_param_value_changed(struct devlink *devlink, u32 param_id) devlink_param_value_changed(struct devlink *devlink, u32 param_id)
{ {
......
...@@ -4714,26 +4714,13 @@ void devlink_port_params_unregister(struct devlink_port *devlink_port, ...@@ -4714,26 +4714,13 @@ void devlink_port_params_unregister(struct devlink_port *devlink_port,
} }
EXPORT_SYMBOL_GPL(devlink_port_params_unregister); EXPORT_SYMBOL_GPL(devlink_port_params_unregister);
/** static int
* devlink_param_driverinit_value_get - get configuration parameter __devlink_param_driverinit_value_get(struct list_head *param_list, u32 param_id,
* 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) union devlink_param_value *init_val)
{ {
struct devlink_param_item *param_item; struct devlink_param_item *param_item;
if (!devlink->ops || !devlink->ops->reload) param_item = devlink_param_find_by_id(param_list, param_id);
return -EOPNOTSUPP;
param_item = devlink_param_find_by_id(&devlink->param_list, param_id);
if (!param_item) if (!param_item)
return -EINVAL; return -EINVAL;
...@@ -4749,6 +4736,27 @@ int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, ...@@ -4749,6 +4736,27 @@ int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
return 0; 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); EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_get);
/** /**
...@@ -4787,6 +4795,31 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, ...@@ -4787,6 +4795,31 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
} }
EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_set); EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_set);
/**
* 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_param_value_changed - notify devlink on a parameter's value * devlink_param_value_changed - notify devlink on a parameter's value
* change. Should be called by the driver * change. Should be called by the driver
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment