summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2020-10-04 18:12:54 +0200
committerDavid S. Miller <davem@davemloft.net>2020-10-04 14:38:53 -0700
commit544e7c33ec2f8077685c254f5e3b03a85c0e62eb (patch)
tree269ed65aa9ca47c2ea5a0fd84bb98c3358ea9417 /include/net
parent3122433eb533aac7d08302ee4b3bd3adfcd280d3 (diff)
downloadlinux-544e7c33ec2f8077685c254f5e3b03a85c0e62eb.tar.bz2
net: devlink: Add support for port regions
Allow regions to be registered to a devlink port. The same netlink API is used, but the port index is provided to indicate when a region is a port region as opposed to a device region. Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Tested-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/devlink.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 89ede1ce3a3a..237ba5e29a3b 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -110,6 +110,7 @@ struct devlink_port_attrs {
struct devlink_port {
struct list_head list;
struct list_head param_list;
+ struct list_head region_list;
struct devlink *devlink;
unsigned int index;
bool registered;
@@ -591,6 +592,26 @@ struct devlink_region_ops {
void *priv;
};
+/**
+ * struct devlink_port_region_ops - Region operations for a port
+ * @name: region name
+ * @destructor: callback used to free snapshot memory when deleting
+ * @snapshot: callback to request an immediate snapshot. On success,
+ * the data variable must be updated to point to the snapshot data.
+ * The function will be called while the devlink instance lock is
+ * held.
+ * @priv: Pointer to driver private data for the region operation
+ */
+struct devlink_port_region_ops {
+ const char *name;
+ void (*destructor)(const void *data);
+ int (*snapshot)(struct devlink_port *port,
+ const struct devlink_port_region_ops *ops,
+ struct netlink_ext_ack *extack,
+ u8 **data);
+ void *priv;
+};
+
struct devlink_fmsg;
struct devlink_health_reporter;
@@ -1445,7 +1466,13 @@ struct devlink_region *
devlink_region_create(struct devlink *devlink,
const struct devlink_region_ops *ops,
u32 region_max_snapshots, u64 region_size);
+struct devlink_region *
+devlink_port_region_create(struct devlink_port *port,
+ const struct devlink_port_region_ops *ops,
+ u32 region_max_snapshots, u64 region_size);
void devlink_region_destroy(struct devlink_region *region);
+void devlink_port_region_destroy(struct devlink_region *region);
+
int devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id);
void devlink_region_snapshot_id_put(struct devlink *devlink, u32 id);
int devlink_region_snapshot_create(struct devlink_region *region,