[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200109193311.1352330-2-jacob.e.keller@intel.com>
Date: Thu, 9 Jan 2020 11:33:08 -0800
From: Jacob Keller <jacob.e.keller@...el.com>
To: netdev@...r.kernel.org
Cc: valex@...lanox.com, jiri@...nulli.us,
Jacob Keller <jacob.e.keller@...el.com>
Subject: [PATCH v2 1/3] devlink: add callback to trigger region snapshots
Add a trigger_snapshot parameter to the devlink_region_create function.
This is a function pointer that will be used to enable devlink API to
request a snapshot of a region.
Passing NULL is acceptable to indicate the region does not support
triggered snapshots.
Future commits will introduce the new devlink command and modify
netdevsim as an example of how the trigger will work.
Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
---
drivers/net/ethernet/mellanox/mlx4/crdump.c | 4 ++--
drivers/net/netdevsim/dev.c | 3 ++-
include/net/devlink.h | 12 ++++++++----
net/core/devlink.c | 11 +++++++----
4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c
index 64ed725aec28..4b1373414b0b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/crdump.c
+++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c
@@ -207,7 +207,7 @@ int mlx4_crdump_init(struct mlx4_dev *dev)
devlink_region_create(devlink,
region_cr_space_str,
MAX_NUM_OF_DUMPS_TO_STORE,
- pci_resource_len(pdev, 0));
+ pci_resource_len(pdev, 0), NULL);
if (IS_ERR(crdump->region_crspace))
mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
region_cr_space_str,
@@ -218,7 +218,7 @@ int mlx4_crdump_init(struct mlx4_dev *dev)
devlink_region_create(devlink,
region_fw_health_str,
MAX_NUM_OF_DUMPS_TO_STORE,
- HEALTH_BUFFER_SIZE);
+ HEALTH_BUFFER_SIZE, NULL);
if (IS_ERR(crdump->region_fw_health))
mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
region_fw_health_str,
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 4b39aba2e9c4..2af97eeb7ba1 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -248,7 +248,8 @@ static int nsim_dev_dummy_region_init(struct nsim_dev *nsim_dev,
nsim_dev->dummy_region =
devlink_region_create(devlink, "dummy",
NSIM_DEV_DUMMY_REGION_SNAPSHOT_MAX,
- NSIM_DEV_DUMMY_REGION_SIZE);
+ NSIM_DEV_DUMMY_REGION_SIZE,
+ NULL);
return PTR_ERR_OR_ZERO(nsim_dev->dummy_region);
}
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 38b4acb93f74..f93b1a07c9f2 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -491,6 +491,10 @@ struct devlink_info_req;
typedef void devlink_snapshot_data_dest_t(const void *data);
+typedef int devlink_trigger_snapshot_t(struct devlink *devlink,
+ struct devlink_region *region,
+ struct netlink_ext_ack *extack);
+
struct devlink_fmsg;
struct devlink_health_reporter;
@@ -933,10 +937,10 @@ void devlink_port_param_value_changed(struct devlink_port *devlink_port,
u32 param_id);
void devlink_param_value_str_fill(union devlink_param_value *dst_val,
const char *src);
-struct devlink_region *devlink_region_create(struct devlink *devlink,
- const char *region_name,
- u32 region_max_snapshots,
- u64 region_size);
+struct devlink_region *
+devlink_region_create(struct devlink *devlink, const char *region_name,
+ u32 region_max_snapshots, u64 region_size,
+ devlink_trigger_snapshot_t *trigger_snapshot);
void devlink_region_destroy(struct devlink_region *region);
u32 devlink_region_snapshot_id_get(struct devlink *devlink);
int devlink_region_snapshot_create(struct devlink_region *region,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index b6fc67dbd612..e54600afdaf0 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -349,6 +349,7 @@ struct devlink_region {
u32 max_snapshots;
u32 cur_snapshots;
u64 size;
+ devlink_trigger_snapshot_t *trigger_snapshot;
};
struct devlink_snapshot {
@@ -7499,11 +7500,12 @@ EXPORT_SYMBOL_GPL(devlink_param_value_str_fill);
* @region_name: region name
* @region_max_snapshots: Maximum supported number of snapshots for region
* @region_size: size of region
+ * @trigger_snapshot: function to trigger creation of snapshot
*/
-struct devlink_region *devlink_region_create(struct devlink *devlink,
- const char *region_name,
- u32 region_max_snapshots,
- u64 region_size)
+struct devlink_region *
+devlink_region_create(struct devlink *devlink, const char *region_name,
+ u32 region_max_snapshots, u64 region_size,
+ devlink_trigger_snapshot_t *trigger_snapshot)
{
struct devlink_region *region;
int err = 0;
@@ -7525,6 +7527,7 @@ struct devlink_region *devlink_region_create(struct devlink *devlink,
region->max_snapshots = region_max_snapshots;
region->name = region_name;
region->size = region_size;
+ region->trigger_snapshot = trigger_snapshot;
INIT_LIST_HEAD(®ion->snapshot_list);
list_add_tail(®ion->list, &devlink->region_list);
devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW);
--
2.25.0.rc1
Powered by blists - more mailing lists