[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1547795385-12354-6-git-send-email-vasundhara-v.volam@broadcom.com>
Date: Fri, 18 Jan 2019 12:39:42 +0530
From: Vasundhara Volam <vasundhara-v.volam@...adcom.com>
To: davem@...emloft.net
Cc: michael.chan@...adcom.com, jiri@...lanox.com,
jakub.kicinski@...ronome.com, mkubecek@...e.cz,
netdev@...r.kernel.org
Subject: [PATCH net-next v7 5/8] devlink: Add support for driverinit set value for devlink_port
Add support for "driverinit" configuration mode value for devlink_port
configuration parameters. Add devlink_port_param_driverinit_value_set()
function to help the driver set the value to devlink_port.
Also, move the common code to __devlink_param_driverinit_value_set()
to be used by both device and port params.
Cc: Jiri Pirko <jiri@...lanox.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@...adcom.com>
---
include/net/devlink.h | 11 +++++++++
net/core/devlink.c | 64 +++++++++++++++++++++++++++++++++++++++------------
2 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 09f3f43..f78cb8d 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -581,6 +581,9 @@ int devlink_port_params_register(struct devlink_port *devlink_port,
void devlink_port_params_unregister(struct devlink_port *devlink_port,
const struct devlink_param *params,
size_t params_count);
+int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
+ u32 param_id,
+ union devlink_param_value init_val);
struct devlink_region *devlink_region_create(struct devlink *devlink,
const char *region_name,
u32 region_max_snapshots,
@@ -846,6 +849,14 @@ static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
return -EOPNOTSUPP;
}
+static inline int
+devlink_port_param_driverinit_value_set(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 53755ff..8ea5a67 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4722,24 +4722,15 @@ int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
}
EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_get);
-/**
- * devlink_param_driverinit_value_set - set value of configuration
- * parameter for driverinit
- * configuration mode
- *
- * @devlink: devlink
- * @param_id: parameter ID
- * @init_val: value of parameter to set for driverinit configuration mode
- *
- * This function should be used by the driver to set driverinit
- * configuration mode default value.
- */
-int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
- union devlink_param_value init_val)
+static int
+__devlink_param_driverinit_value_set(struct devlink *devlink,
+ struct list_head *param_list, u32 param_id,
+ union devlink_param_value init_val,
+ enum devlink_command cmd)
{
struct devlink_param_item *param_item;
- 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;
@@ -4756,6 +4747,27 @@ int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
devlink_param_notify(devlink, param_item, DEVLINK_CMD_PARAM_NEW);
return 0;
}
+
+/**
+ * devlink_param_driverinit_value_set - set value of configuration
+ * parameter for driverinit
+ * configuration mode
+ *
+ * @devlink: devlink
+ * @param_id: parameter ID
+ * @init_val: value of parameter to set for driverinit configuration mode
+ *
+ * This function should be used by the driver to set driverinit
+ * configuration mode default value.
+ */
+int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
+ union devlink_param_value init_val)
+{
+ return __devlink_param_driverinit_value_set(devlink,
+ &devlink->param_list,
+ param_id, init_val,
+ DEVLINK_CMD_PARAM_NEW);
+}
EXPORT_SYMBOL_GPL(devlink_param_driverinit_value_set);
/**
@@ -4862,6 +4874,28 @@ int devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
EXPORT_SYMBOL_GPL(devlink_port_param_driverinit_value_get);
/**
+ * devlink_port_param_driverinit_value_set - set value of configuration
+ * parameter for driverinit
+ * configuration mode
+ *
+ * @devlink_port: devlink_port
+ * @param_id: parameter ID
+ * @init_val: value of parameter to set for driverinit configuration mode
+ *
+ * This function should be used by the driver to set driverinit
+ * configuration mode default value.
+ */
+int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
+ u32 param_id,
+ union devlink_param_value init_val)
+{
+ return __devlink_param_driverinit_value_set(devlink_port->devlink,
+ &devlink_port->param_list,
+ param_id, init_val, 0);
+}
+EXPORT_SYMBOL_GPL(devlink_port_param_driverinit_value_set);
+
+/**
* devlink_region_create - create a new address region
*
* @devlink: devlink
--
1.8.3.1
Powered by blists - more mailing lists