Skip to content

Commit

Permalink
net: devlink: Add support for port regions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Oct 4, 2020
1 parent 3122433 commit 544e7c3
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 26 deletions.
27 changes: 27 additions & 0 deletions include/net/devlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 544e7c3

Please sign in to comment.