aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEran Ben Elisha <eranbe@mellanox.com>2019-01-17 16:59:10 -0500
committerDavid S. Miller <davem@davemloft.net>2019-01-18 17:51:22 -0500
commitcb5ccfbe73b389470e1dc11061bb185ef4bc9aec (patch)
tree2eaba2908349449e7dd19b71589a228b5ce74d46 /include
parentf88c19aab5f34835f1ba467c5b508ec4f782f07f (diff)
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>
Diffstat (limited to 'include')
-rw-r--r--include/net/devlink.h76
-rw-r--r--include/uapi/linux/devlink.h8
2 files changed, 84 insertions, 0 deletions
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 67f4293bc970..77c77319290a 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -423,6 +423,8 @@ struct devlink_region;
423 423
424typedef void devlink_snapshot_data_dest_t(const void *data); 424typedef void devlink_snapshot_data_dest_t(const void *data);
425 425
426struct devlink_health_buffer;
427
426struct devlink_ops { 428struct devlink_ops {
427 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack); 429 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
428 int (*port_type_set)(struct devlink_port *devlink_port, 430 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,
584 u8 *data, u32 snapshot_id, 586 u8 *data, u32 snapshot_id,
585 devlink_snapshot_data_dest_t *data_destructor); 587 devlink_snapshot_data_dest_t *data_destructor);
586 588
589int devlink_health_buffer_nest_start(struct devlink_health_buffer *buffer,
590 int attrtype);
591void devlink_health_buffer_nest_end(struct devlink_health_buffer *buffer);
592void devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer);
593int devlink_health_buffer_put_object_name(struct devlink_health_buffer *buffer,
594 char *name);
595int devlink_health_buffer_put_value_u8(struct devlink_health_buffer *buffer,
596 u8 value);
597int devlink_health_buffer_put_value_u32(struct devlink_health_buffer *buffer,
598 u32 value);
599int devlink_health_buffer_put_value_u64(struct devlink_health_buffer *buffer,
600 u64 value);
601int devlink_health_buffer_put_value_string(struct devlink_health_buffer *buffer,
602 char *name);
603int devlink_health_buffer_put_value_data(struct devlink_health_buffer *buffer,
604 void *data, int len);
587#else 605#else
588 606
589static inline struct devlink *devlink_alloc(const struct devlink_ops *ops, 607static 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,
844 return 0; 862 return 0;
845} 863}
846 864
865static inline int
866devlink_health_buffer_nest_start(struct devlink_health_buffer *buffer,
867 int attrtype)
868{
869 return 0;
870}
871
872static inline void
873devlink_health_buffer_nest_end(struct devlink_health_buffer *buffer)
874{
875}
876
877static inline void
878devlink_health_buffer_nest_cancel(struct devlink_health_buffer *buffer)
879{
880}
881
882static inline int
883devlink_health_buffer_put_object_name(struct devlink_health_buffer *buffer,
884 char *name)
885{
886 return 0;
887}
888
889static inline int
890devlink_health_buffer_put_value_u8(struct devlink_health_buffer *buffer,
891 u8 value)
892{
893 return 0;
894}
895
896static inline int
897devlink_health_buffer_put_value_u32(struct devlink_health_buffer *buffer,
898 u32 value)
899{
900 return 0;
901}
902
903static inline int
904devlink_health_buffer_put_value_u64(struct devlink_health_buffer *buffer,
905 u64 value)
906{
907 return 0;
908}
909
910static inline int
911devlink_health_buffer_put_value_string(struct devlink_health_buffer *buffer,
912 char *name)
913{
914 return 0;
915}
916
917static inline int
918devlink_health_buffer_put_value_data(struct devlink_health_buffer *buffer,
919 void *data, int len)
920{
921 return 0;
922}
847#endif 923#endif
848 924
849#endif /* _NET_DEVLINK_H_ */ 925#endif /* _NET_DEVLINK_H_ */
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 6e52d3660654..cff0e0cb5ac2 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -285,6 +285,14 @@ enum devlink_attr {
285 DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */ 285 DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */
286 DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */ 286 DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */
287 287
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
288 /* add new attributes above here, update the policy in devlink.c */ 296 /* add new attributes above here, update the policy in devlink.c */
289 297
290 __DEVLINK_ATTR_MAX, 298 __DEVLINK_ATTR_MAX,