Commit cb5ccfbe authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by David S. Miller

devlink: Add health buffer support

Devlink health buffer is a mechanism to pass descriptors between drivers
and devlink. The API allows the driver to add objects, object pair,
value array (nested attributes), value and name.

Driver can use this API to fill the buffers in a format which can be
translated by the devlink to the netlink message.

In order to fulfill it, an internal buffer descriptor is defined. This
will hold the data and metadata per each attribute and by used to pass
actual commands to the netlink.

This mechanism will be later used in devlink health for dump and diagnose
data store by the drivers.
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: default avatarMoshe Shemesh <moshe@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f88c19aa
......@@ -423,6 +423,8 @@ struct devlink_region;
typedef void devlink_snapshot_data_dest_t(const void *data);
struct devlink_health_buffer;
struct devlink_ops {
int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
int (*port_type_set)(struct devlink_port *devlink_port,
......@@ -584,6 +586,22 @@ int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
u8 *data, u32 snapshot_id,
devlink_snapshot_data_dest_t *data_destructor);
int devlink_health_buffer_nest_start(struct devlink_health_buffer *buffer,
int attrtype);
void devlink_health_buffer_nest_end(struct devlink_health_buffer *buffer);
void devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer);
int devlink_health_buffer_put_object_name(struct devlink_health_buffer *buffer,
char *name);
int devlink_health_buffer_put_value_u8(struct devlink_health_buffer *buffer,
u8 value);
int devlink_health_buffer_put_value_u32(struct devlink_health_buffer *buffer,
u32 value);
int devlink_health_buffer_put_value_u64(struct devlink_health_buffer *buffer,
u64 value);
int devlink_health_buffer_put_value_string(struct devlink_health_buffer *buffer,
char *name);
int devlink_health_buffer_put_value_data(struct devlink_health_buffer *buffer,
void *data, int len);
#else
static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
......@@ -844,6 +862,64 @@ devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
return 0;
}
static inline int
devlink_health_buffer_nest_start(struct devlink_health_buffer *buffer,
int attrtype)
{
return 0;
}
static inline void
devlink_health_buffer_nest_end(struct devlink_health_buffer *buffer)
{
}
static inline void
devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer)
{
}
static inline int
devlink_health_buffer_put_object_name(struct devlink_health_buffer *buffer,
char *name)
{
return 0;
}
static inline int
devlink_health_buffer_put_value_u8(struct devlink_health_buffer *buffer,
u8 value)
{
return 0;
}
static inline int
devlink_health_buffer_put_value_u32(struct devlink_health_buffer *buffer,
u32 value)
{
return 0;
}
static inline int
devlink_health_buffer_put_value_u64(struct devlink_health_buffer *buffer,
u64 value)
{
return 0;
}
static inline int
devlink_health_buffer_put_value_string(struct devlink_health_buffer *buffer,
char *name)
{
return 0;
}
static inline int
devlink_health_buffer_put_value_data(struct devlink_health_buffer *buffer,
void *data, int len)
{
return 0;
}
#endif
#endif /* _NET_DEVLINK_H_ */
......@@ -285,6 +285,14 @@ enum devlink_attr {
DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */
DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT, /* nested */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_PAIR, /* nested */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_NAME, /* string */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE, /* nested */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_ARRAY, /* nested */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_TYPE, /* u8 */
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_DATA, /* dynamic */
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment