Skip to content

Commit 544e7c3

Browse files
lunndavem330
authored andcommitted
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 <[email protected]> Tested-by: Vladimir Oltean <[email protected]> Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3122433 commit 544e7c3

File tree

2 files changed

+251
-26
lines changed

2 files changed

+251
-26
lines changed

include/net/devlink.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct devlink_port_attrs {
110110
struct devlink_port {
111111
struct list_head list;
112112
struct list_head param_list;
113+
struct list_head region_list;
113114
struct devlink *devlink;
114115
unsigned int index;
115116
bool registered;
@@ -591,6 +592,26 @@ struct devlink_region_ops {
591592
void *priv;
592593
};
593594

595+
/**
596+
* struct devlink_port_region_ops - Region operations for a port
597+
* @name: region name
598+
* @destructor: callback used to free snapshot memory when deleting
599+
* @snapshot: callback to request an immediate snapshot. On success,
600+
* the data variable must be updated to point to the snapshot data.
601+
* The function will be called while the devlink instance lock is
602+
* held.
603+
* @priv: Pointer to driver private data for the region operation
604+
*/
605+
struct devlink_port_region_ops {
606+
const char *name;
607+
void (*destructor)(const void *data);
608+
int (*snapshot)(struct devlink_port *port,
609+
const struct devlink_port_region_ops *ops,
610+
struct netlink_ext_ack *extack,
611+
u8 **data);
612+
void *priv;
613+
};
614+
594615
struct devlink_fmsg;
595616
struct devlink_health_reporter;
596617

@@ -1445,7 +1466,13 @@ struct devlink_region *
14451466
devlink_region_create(struct devlink *devlink,
14461467
const struct devlink_region_ops *ops,
14471468
u32 region_max_snapshots, u64 region_size);
1469+
struct devlink_region *
1470+
devlink_port_region_create(struct devlink_port *port,
1471+
const struct devlink_port_region_ops *ops,
1472+
u32 region_max_snapshots, u64 region_size);
14481473
void devlink_region_destroy(struct devlink_region *region);
1474+
void devlink_port_region_destroy(struct devlink_region *region);
1475+
14491476
int devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id);
14501477
void devlink_region_snapshot_id_put(struct devlink *devlink, u32 id);
14511478
int devlink_region_snapshot_create(struct devlink_region *region,

0 commit comments

Comments
 (0)