aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-01-31 13:50:40 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-01 18:30:30 -0500
commitf9cf22882c606f3ffe06f620bb6d03b9eff18d3d (patch)
tree0e02436128b6a603f57e8bb26622921e21d64332 /include
parent26281e2c83e5536dc7ceea7da774107ca45c4e67 (diff)
devlink: add device information API
ethtool -i has served us well for a long time, but its showing its limitations more and more. The device information should also be reported per device not per-netdev. Lay foundation for a simple devlink-based way of reading device info. Add driver name and device serial number as initial pieces of information exposed via this new API. v3: - rename helpers (Jiri); - rename driver name attr (Jiri); - remove double spacing in commit message (Jiri). RFC v2: - wrap the skb into an opaque structure (Jiri); - allow the serial number of be any length (Jiri & Andrew); - add driver name (Jonathan). Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/devlink.h18
-rw-r--r--include/uapi/linux/devlink.h5
2 files changed, 23 insertions, 0 deletions
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 85c9eabaf056..a6d0a530483d 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -429,6 +429,7 @@ enum devlink_param_wol_types {
429} 429}
430 430
431struct devlink_region; 431struct devlink_region;
432struct devlink_info_req;
432 433
433typedef void devlink_snapshot_data_dest_t(const void *data); 434typedef void devlink_snapshot_data_dest_t(const void *data);
434 435
@@ -484,6 +485,8 @@ struct devlink_ops {
484 int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode); 485 int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode);
485 int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode, 486 int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode,
486 struct netlink_ext_ack *extack); 487 struct netlink_ext_ack *extack);
488 int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
489 struct netlink_ext_ack *extack);
487}; 490};
488 491
489static inline void *devlink_priv(struct devlink *devlink) 492static inline void *devlink_priv(struct devlink *devlink)
@@ -607,6 +610,10 @@ u32 devlink_region_shapshot_id_get(struct devlink *devlink);
607int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, 610int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
608 u8 *data, u32 snapshot_id, 611 u8 *data, u32 snapshot_id,
609 devlink_snapshot_data_dest_t *data_destructor); 612 devlink_snapshot_data_dest_t *data_destructor);
613int devlink_info_serial_number_put(struct devlink_info_req *req,
614 const char *sn);
615int devlink_info_driver_name_put(struct devlink_info_req *req,
616 const char *name);
610 617
611#else 618#else
612 619
@@ -905,6 +912,17 @@ devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
905 return 0; 912 return 0;
906} 913}
907 914
915static inline int
916devlink_info_driver_name_put(struct devlink_info_req *req, const char *name)
917{
918 return 0;
919}
920
921static inline int
922devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn)
923{
924 return 0;
925}
908#endif 926#endif
909 927
910#endif /* _NET_DEVLINK_H_ */ 928#endif /* _NET_DEVLINK_H_ */
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 61b4447a6c5b..142710d45093 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -94,6 +94,8 @@ enum devlink_command {
94 DEVLINK_CMD_PORT_PARAM_NEW, 94 DEVLINK_CMD_PORT_PARAM_NEW,
95 DEVLINK_CMD_PORT_PARAM_DEL, 95 DEVLINK_CMD_PORT_PARAM_DEL,
96 96
97 DEVLINK_CMD_INFO_GET, /* can dump */
98
97 /* add new commands above here */ 99 /* add new commands above here */
98 __DEVLINK_CMD_MAX, 100 __DEVLINK_CMD_MAX,
99 DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 101 DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
@@ -290,6 +292,9 @@ enum devlink_attr {
290 DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */ 292 DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */
291 DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */ 293 DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */
292 294
295 DEVLINK_ATTR_INFO_DRIVER_NAME, /* string */
296 DEVLINK_ATTR_INFO_SERIAL_NUMBER, /* string */
297
293 /* add new attributes above here, update the policy in devlink.c */ 298 /* add new attributes above here, update the policy in devlink.c */
294 299
295 __DEVLINK_ATTR_MAX, 300 __DEVLINK_ATTR_MAX,