Skip to content

Commit cb5ccfb

Browse files
Eran Ben Elishadavem330
authored andcommitted
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: Eran Ben Elisha <eranbe@mellanox.com> Reviewed-by: Moshe Shemesh <moshe@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f88c19a commit cb5ccfb

3 files changed

Lines changed: 585 additions & 0 deletions

File tree

‎include/net/devlink.h‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ struct devlink_region;
423423

424424
typedef void devlink_snapshot_data_dest_t(const void *data);
425425

426+
struct devlink_health_buffer;
427+
426428
struct devlink_ops {
427429
int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
428430
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,
584586
u8 *data, u32 snapshot_id,
585587
devlink_snapshot_data_dest_t *data_destructor);
586588

589+
int devlink_health_buffer_nest_start(struct devlink_health_buffer *buffer,
590+
int attrtype);
591+
void devlink_health_buffer_nest_end(struct devlink_health_buffer *buffer);
592+
void devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer);
593+
int devlink_health_buffer_put_object_name(struct devlink_health_buffer *buffer,
594+
char *name);
595+
int devlink_health_buffer_put_value_u8(struct devlink_health_buffer *buffer,
596+
u8 value);
597+
int devlink_health_buffer_put_value_u32(struct devlink_health_buffer *buffer,
598+
u32 value);
599+
int devlink_health_buffer_put_value_u64(struct devlink_health_buffer *buffer,
600+
u64 value);
601+
int devlink_health_buffer_put_value_string(struct devlink_health_buffer *buffer,
602+
char *name);
603+
int devlink_health_buffer_put_value_data(struct devlink_health_buffer *buffer,
604+
void *data, int len);
587605
#else
588606

589607
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,
844862
return 0;
845863
}
846864

865+
static inline int
866+
devlink_health_buffer_nest_start(struct devlink_health_buffer *buffer,
867+
int attrtype)
868+
{
869+
return 0;
870+
}
871+
872+
static inline void
873+
devlink_health_buffer_nest_end(struct devlink_health_buffer *buffer)
874+
{
875+
}
876+
877+
static inline void
878+
devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer)
879+
{
880+
}
881+
882+
static inline int
883+
devlink_health_buffer_put_object_name(struct devlink_health_buffer *buffer,
884+
char *name)
885+
{
886+
return 0;
887+
}
888+
889+
static inline int
890+
devlink_health_buffer_put_value_u8(struct devlink_health_buffer *buffer,
891+
u8 value)
892+
{
893+
return 0;
894+
}
895+
896+
static inline int
897+
devlink_health_buffer_put_value_u32(struct devlink_health_buffer *buffer,
898+
u32 value)
899+
{
900+
return 0;
901+
}
902+
903+
static inline int
904+
devlink_health_buffer_put_value_u64(struct devlink_health_buffer *buffer,
905+
u64 value)
906+
{
907+
return 0;
908+
}
909+
910+
static inline int
911+
devlink_health_buffer_put_value_string(struct devlink_health_buffer *buffer,
912+
char *name)
913+
{
914+
return 0;
915+
}
916+
917+
static inline int
918+
devlink_health_buffer_put_value_data(struct devlink_health_buffer *buffer,
919+
void *data, int len)
920+
{
921+
return 0;
922+
}
847923
#endif
848924

849925
#endif /* _NET_DEVLINK_H_ */

‎include/uapi/linux/devlink.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ enum devlink_attr {
285285
DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */
286286
DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */
287287

288+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT, /* nested */
289+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_PAIR, /* nested */
290+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_NAME, /* string */
291+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE, /* nested */
292+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_ARRAY, /* nested */
293+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_TYPE, /* u8 */
294+
DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_DATA, /* dynamic */
295+
288296
/* add new attributes above here, update the policy in devlink.c */
289297

290298
__DEVLINK_ATTR_MAX,

0 commit comments

Comments
 (0)