summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEran Ben Elisha <eranbe@mellanox.com>2019-01-17 23:59:10 +0200
committerDavid S. Miller <davem@davemloft.net>2019-01-18 14:51:22 -0800
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;
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_ */
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 {
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,