1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * include/net/devlink.h - Network physical device Netlink interface
4 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
5 * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
7 #ifndef _NET_DEVLINK_H_
8 #define _NET_DEVLINK_H_
10 #include <linux/device.h>
11 #include <linux/slab.h>
12 #include <linux/gfp.h>
13 #include <linux/list.h>
14 #include <linux/netdevice.h>
15 #include <linux/spinlock.h>
16 #include <linux/workqueue.h>
17 #include <net/net_namespace.h>
18 #include <uapi/linux/devlink.h>
23 struct list_head list;
24 struct list_head port_list;
25 struct list_head sb_list;
26 struct list_head dpipe_table_list;
27 struct list_head resource_list;
28 struct list_head param_list;
29 struct list_head region_list;
31 struct list_head reporter_list;
32 struct mutex reporters_lock; /* protects reporter_list */
33 struct devlink_dpipe_headers *dpipe_headers;
34 const struct devlink_ops *ops;
38 char priv[0] __aligned(NETDEV_ALIGN);
41 struct devlink_port_phys_attrs {
42 u32 port_number; /* Same value as "split group".
43 * A physical port which is visible to the user
44 * for a given port flavour.
46 u32 split_subport_number;
49 struct devlink_port_pci_pf_attrs {
50 u16 pf; /* Associated PCI PF for this port. */
53 struct devlink_port_pci_vf_attrs {
54 u16 pf; /* Associated PCI PF for this port. */
55 u16 vf; /* Associated PCI VF for of the PCI PF for this port. */
58 struct devlink_port_attrs {
62 enum devlink_port_flavour flavour;
63 struct netdev_phys_item_id switch_id;
65 struct devlink_port_phys_attrs phys;
66 struct devlink_port_pci_pf_attrs pci_pf;
67 struct devlink_port_pci_vf_attrs pci_vf;
72 struct list_head list;
73 struct list_head param_list;
74 struct devlink *devlink;
77 spinlock_t type_lock; /* Protects type and type_dev
78 * pointer consistency.
80 enum devlink_port_type type;
81 enum devlink_port_type desired_type;
83 struct devlink_port_attrs attrs;
84 struct delayed_work type_warn_dw;
87 struct devlink_sb_pool_info {
88 enum devlink_sb_pool_type pool_type;
90 enum devlink_sb_threshold_type threshold_type;
95 * struct devlink_dpipe_field - dpipe field object
97 * @id: index inside the headers field array
99 * @mapping_type: mapping type
101 struct devlink_dpipe_field {
104 unsigned int bitwidth;
105 enum devlink_dpipe_field_mapping_type mapping_type;
109 * struct devlink_dpipe_header - dpipe header object
111 * @id: index, global/local detrmined by global bit
113 * @fields_count: number of fields
114 * @global: indicates if header is shared like most protocol header
117 struct devlink_dpipe_header {
120 struct devlink_dpipe_field *fields;
121 unsigned int fields_count;
126 * struct devlink_dpipe_match - represents match operation
127 * @type: type of match
128 * @header_index: header index (packets can have several headers of same
129 * type like in case of tunnels)
131 * @fieled_id: field index
133 struct devlink_dpipe_match {
134 enum devlink_dpipe_match_type type;
135 unsigned int header_index;
136 struct devlink_dpipe_header *header;
137 unsigned int field_id;
141 * struct devlink_dpipe_action - represents action operation
142 * @type: type of action
143 * @header_index: header index (packets can have several headers of same
144 * type like in case of tunnels)
146 * @fieled_id: field index
148 struct devlink_dpipe_action {
149 enum devlink_dpipe_action_type type;
150 unsigned int header_index;
151 struct devlink_dpipe_header *header;
152 unsigned int field_id;
156 * struct devlink_dpipe_value - represents value of match/action
159 * @mapping_value: in case the field has some mapping this value
160 * specified the mapping value
161 * @mapping_valid: specify if mapping value is valid
162 * @value_size: value size
166 struct devlink_dpipe_value {
168 struct devlink_dpipe_action *action;
169 struct devlink_dpipe_match *match;
171 unsigned int mapping_value;
173 unsigned int value_size;
179 * struct devlink_dpipe_entry - table entry object
180 * @index: index of the entry in the table
181 * @match_values: match values
182 * @matche_values_count: count of matches tuples
183 * @action_values: actions values
184 * @action_values_count: count of actions values
185 * @counter: value of counter
186 * @counter_valid: Specify if value is valid from hardware
188 struct devlink_dpipe_entry {
190 struct devlink_dpipe_value *match_values;
191 unsigned int match_values_count;
192 struct devlink_dpipe_value *action_values;
193 unsigned int action_values_count;
199 * struct devlink_dpipe_dump_ctx - context provided to driver in order
202 * @cmd: devlink command
204 * @nest: top attribute
207 struct devlink_dpipe_dump_ctx {
208 struct genl_info *info;
209 enum devlink_command cmd;
215 struct devlink_dpipe_table_ops;
218 * struct devlink_dpipe_table - table object
221 * @counters_enabled: indicates if counters are active
222 * @counter_control_extern: indicates if counter control is in dpipe or
224 * @resource_valid: Indicate that the resource id is valid
225 * @resource_id: relative resource this table is related to
226 * @resource_units: number of resource's unit consumed per table's entry
227 * @table_ops: table operations
230 struct devlink_dpipe_table {
232 struct list_head list;
234 bool counters_enabled;
235 bool counter_control_extern;
239 struct devlink_dpipe_table_ops *table_ops;
244 * struct devlink_dpipe_table_ops - dpipe_table ops
245 * @actions_dump - dumps all tables actions
246 * @matches_dump - dumps all tables matches
247 * @entries_dump - dumps all active entries in the table
248 * @counters_set_update - when changing the counter status hardware sync
249 * maybe needed to allocate/free counter related
251 * @size_get - get size
253 struct devlink_dpipe_table_ops {
254 int (*actions_dump)(void *priv, struct sk_buff *skb);
255 int (*matches_dump)(void *priv, struct sk_buff *skb);
256 int (*entries_dump)(void *priv, bool counters_enabled,
257 struct devlink_dpipe_dump_ctx *dump_ctx);
258 int (*counters_set_update)(void *priv, bool enable);
259 u64 (*size_get)(void *priv);
263 * struct devlink_dpipe_headers - dpipe headers
264 * @headers - header array can be shared (global bit) or driver specific
265 * @headers_count - count of headers
267 struct devlink_dpipe_headers {
268 struct devlink_dpipe_header **headers;
269 unsigned int headers_count;
273 * struct devlink_resource_size_params - resource's size parameters
274 * @size_min: minimum size which can be set
275 * @size_max: maximum size which can be set
276 * @size_granularity: size granularity
277 * @size_unit: resource's basic unit
279 struct devlink_resource_size_params {
282 u64 size_granularity;
283 enum devlink_resource_unit unit;
287 devlink_resource_size_params_init(struct devlink_resource_size_params *size_params,
288 u64 size_min, u64 size_max,
289 u64 size_granularity,
290 enum devlink_resource_unit unit)
292 size_params->size_min = size_min;
293 size_params->size_max = size_max;
294 size_params->size_granularity = size_granularity;
295 size_params->unit = unit;
298 typedef u64 devlink_resource_occ_get_t(void *priv);
301 * struct devlink_resource - devlink resource
302 * @name: name of the resource
303 * @id: id, per devlink instance
304 * @size: size of the resource
305 * @size_new: updated size of the resource, reload is needed
306 * @size_valid: valid in case the total size of the resource is valid
307 * including its children
308 * @parent: parent resource
309 * @size_params: size parameters
311 * @resource_list: list of child resources
313 struct devlink_resource {
319 struct devlink_resource *parent;
320 struct devlink_resource_size_params size_params;
321 struct list_head list;
322 struct list_head resource_list;
323 devlink_resource_occ_get_t *occ_get;
327 #define DEVLINK_RESOURCE_ID_PARENT_TOP 0
329 #define __DEVLINK_PARAM_MAX_STRING_VALUE 32
330 enum devlink_param_type {
331 DEVLINK_PARAM_TYPE_U8,
332 DEVLINK_PARAM_TYPE_U16,
333 DEVLINK_PARAM_TYPE_U32,
334 DEVLINK_PARAM_TYPE_STRING,
335 DEVLINK_PARAM_TYPE_BOOL,
338 union devlink_param_value {
342 char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE];
346 struct devlink_param_gset_ctx {
347 union devlink_param_value val;
348 enum devlink_param_cmode cmode;
352 * struct devlink_param - devlink configuration parameter data
353 * @name: name of the parameter
354 * @generic: indicates if the parameter is generic or driver specific
355 * @type: parameter type
356 * @supported_cmodes: bitmap of supported configuration modes
357 * @get: get parameter value, used for runtime and permanent
358 * configuration modes
359 * @set: set parameter value, used for runtime and permanent
360 * configuration modes
361 * @validate: validate input value is applicable (within value range, etc.)
363 * This struct should be used by the driver to fill the data for
364 * a parameter it registers.
366 struct devlink_param {
370 enum devlink_param_type type;
371 unsigned long supported_cmodes;
372 int (*get)(struct devlink *devlink, u32 id,
373 struct devlink_param_gset_ctx *ctx);
374 int (*set)(struct devlink *devlink, u32 id,
375 struct devlink_param_gset_ctx *ctx);
376 int (*validate)(struct devlink *devlink, u32 id,
377 union devlink_param_value val,
378 struct netlink_ext_ack *extack);
381 struct devlink_param_item {
382 struct list_head list;
383 const struct devlink_param *param;
384 union devlink_param_value driverinit_value;
385 bool driverinit_value_valid;
389 enum devlink_param_generic_id {
390 DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
391 DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
392 DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
393 DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
394 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
395 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
396 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
397 DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
399 /* add new param generic ids above here*/
400 __DEVLINK_PARAM_GENERIC_ID_MAX,
401 DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1,
404 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset"
405 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL
407 #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs"
408 #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32
410 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov"
411 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL
413 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
414 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
416 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
417 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
419 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
420 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
422 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
423 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
425 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy"
426 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8
428 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
430 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
431 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \
432 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \
434 .supported_cmodes = _cmodes, \
437 .validate = _validate, \
440 #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \
445 .supported_cmodes = _cmodes, \
448 .validate = _validate, \
451 /* Part number, identifier of board design */
452 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
453 /* Revision of board design */
454 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
455 /* Maker of the board */
456 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
458 /* Control processor FW version */
459 #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"
460 /* Data path microcode controlling high-speed packet processing */
461 #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app"
462 /* UNDI software version */
463 #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi"
464 /* NCSI support/handler version */
465 #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi"
467 struct devlink_region;
468 struct devlink_info_req;
470 typedef void devlink_snapshot_data_dest_t(const void *data);
473 struct devlink_health_reporter;
475 enum devlink_health_reporter_state {
476 DEVLINK_HEALTH_REPORTER_STATE_HEALTHY,
477 DEVLINK_HEALTH_REPORTER_STATE_ERROR,
481 * struct devlink_health_reporter_ops - Reporter operations
482 * @name: reporter name
483 * @recover: callback to recover from reported error
484 * if priv_ctx is NULL, run a full recover
485 * @dump: callback to dump an object
486 * if priv_ctx is NULL, run a full dump
487 * @diagnose: callback to diagnose the current status
490 struct devlink_health_reporter_ops {
492 int (*recover)(struct devlink_health_reporter *reporter,
494 int (*dump)(struct devlink_health_reporter *reporter,
495 struct devlink_fmsg *fmsg, void *priv_ctx);
496 int (*diagnose)(struct devlink_health_reporter *reporter,
497 struct devlink_fmsg *fmsg);
501 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
502 int (*port_type_set)(struct devlink_port *devlink_port,
503 enum devlink_port_type port_type);
504 int (*port_split)(struct devlink *devlink, unsigned int port_index,
505 unsigned int count, struct netlink_ext_ack *extack);
506 int (*port_unsplit)(struct devlink *devlink, unsigned int port_index,
507 struct netlink_ext_ack *extack);
508 int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index,
510 struct devlink_sb_pool_info *pool_info);
511 int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index,
512 u16 pool_index, u32 size,
513 enum devlink_sb_threshold_type threshold_type,
514 struct netlink_ext_ack *extack);
515 int (*sb_port_pool_get)(struct devlink_port *devlink_port,
516 unsigned int sb_index, u16 pool_index,
518 int (*sb_port_pool_set)(struct devlink_port *devlink_port,
519 unsigned int sb_index, u16 pool_index,
520 u32 threshold, struct netlink_ext_ack *extack);
521 int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port,
522 unsigned int sb_index,
524 enum devlink_sb_pool_type pool_type,
525 u16 *p_pool_index, u32 *p_threshold);
526 int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port,
527 unsigned int sb_index,
529 enum devlink_sb_pool_type pool_type,
530 u16 pool_index, u32 threshold,
531 struct netlink_ext_ack *extack);
532 int (*sb_occ_snapshot)(struct devlink *devlink,
533 unsigned int sb_index);
534 int (*sb_occ_max_clear)(struct devlink *devlink,
535 unsigned int sb_index);
536 int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port,
537 unsigned int sb_index, u16 pool_index,
538 u32 *p_cur, u32 *p_max);
539 int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port,
540 unsigned int sb_index,
542 enum devlink_sb_pool_type pool_type,
543 u32 *p_cur, u32 *p_max);
545 int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode);
546 int (*eswitch_mode_set)(struct devlink *devlink, u16 mode,
547 struct netlink_ext_ack *extack);
548 int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
549 int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode,
550 struct netlink_ext_ack *extack);
551 int (*eswitch_encap_mode_get)(struct devlink *devlink,
552 enum devlink_eswitch_encap_mode *p_encap_mode);
553 int (*eswitch_encap_mode_set)(struct devlink *devlink,
554 enum devlink_eswitch_encap_mode encap_mode,
555 struct netlink_ext_ack *extack);
556 int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
557 struct netlink_ext_ack *extack);
558 int (*flash_update)(struct devlink *devlink, const char *file_name,
559 const char *component,
560 struct netlink_ext_ack *extack);
563 static inline void *devlink_priv(struct devlink *devlink)
566 return &devlink->priv;
569 static inline struct devlink *priv_to_devlink(void *priv)
572 return container_of(priv, struct devlink, priv);
575 static inline struct devlink_port *
576 netdev_to_devlink_port(struct net_device *dev)
578 if (dev->netdev_ops->ndo_get_devlink_port)
579 return dev->netdev_ops->ndo_get_devlink_port(dev);
583 static inline struct devlink *netdev_to_devlink(struct net_device *dev)
585 struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
588 return devlink_port->devlink;
594 struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
595 int devlink_register(struct devlink *devlink, struct device *dev);
596 void devlink_unregister(struct devlink *devlink);
597 void devlink_free(struct devlink *devlink);
598 int devlink_port_register(struct devlink *devlink,
599 struct devlink_port *devlink_port,
600 unsigned int port_index);
601 void devlink_port_unregister(struct devlink_port *devlink_port);
602 void devlink_port_type_eth_set(struct devlink_port *devlink_port,
603 struct net_device *netdev);
604 void devlink_port_type_ib_set(struct devlink_port *devlink_port,
605 struct ib_device *ibdev);
606 void devlink_port_type_clear(struct devlink_port *devlink_port);
607 void devlink_port_attrs_set(struct devlink_port *devlink_port,
608 enum devlink_port_flavour flavour,
609 u32 port_number, bool split,
610 u32 split_subport_number,
611 const unsigned char *switch_id,
612 unsigned char switch_id_len);
613 void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port,
614 const unsigned char *switch_id,
615 unsigned char switch_id_len, u16 pf);
616 void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port,
617 const unsigned char *switch_id,
618 unsigned char switch_id_len,
620 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
621 u32 size, u16 ingress_pools_count,
622 u16 egress_pools_count, u16 ingress_tc_count,
623 u16 egress_tc_count);
624 void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
625 int devlink_dpipe_table_register(struct devlink *devlink,
626 const char *table_name,
627 struct devlink_dpipe_table_ops *table_ops,
628 void *priv, bool counter_control_extern);
629 void devlink_dpipe_table_unregister(struct devlink *devlink,
630 const char *table_name);
631 int devlink_dpipe_headers_register(struct devlink *devlink,
632 struct devlink_dpipe_headers *dpipe_headers);
633 void devlink_dpipe_headers_unregister(struct devlink *devlink);
634 bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
635 const char *table_name);
636 int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
637 int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
638 struct devlink_dpipe_entry *entry);
639 int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
640 void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
641 int devlink_dpipe_action_put(struct sk_buff *skb,
642 struct devlink_dpipe_action *action);
643 int devlink_dpipe_match_put(struct sk_buff *skb,
644 struct devlink_dpipe_match *match);
645 extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
646 extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
647 extern struct devlink_dpipe_header devlink_dpipe_header_ipv6;
649 int devlink_resource_register(struct devlink *devlink,
650 const char *resource_name,
653 u64 parent_resource_id,
654 const struct devlink_resource_size_params *size_params);
655 void devlink_resources_unregister(struct devlink *devlink,
656 struct devlink_resource *resource);
657 int devlink_resource_size_get(struct devlink *devlink,
659 u64 *p_resource_size);
660 int devlink_dpipe_table_resource_set(struct devlink *devlink,
661 const char *table_name, u64 resource_id,
663 void devlink_resource_occ_get_register(struct devlink *devlink,
665 devlink_resource_occ_get_t *occ_get,
667 void devlink_resource_occ_get_unregister(struct devlink *devlink,
669 int devlink_params_register(struct devlink *devlink,
670 const struct devlink_param *params,
671 size_t params_count);
672 void devlink_params_unregister(struct devlink *devlink,
673 const struct devlink_param *params,
674 size_t params_count);
675 void devlink_params_publish(struct devlink *devlink);
676 void devlink_params_unpublish(struct devlink *devlink);
677 int devlink_port_params_register(struct devlink_port *devlink_port,
678 const struct devlink_param *params,
679 size_t params_count);
680 void devlink_port_params_unregister(struct devlink_port *devlink_port,
681 const struct devlink_param *params,
682 size_t params_count);
683 int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
684 union devlink_param_value *init_val);
685 int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
686 union devlink_param_value init_val);
688 devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
690 union devlink_param_value *init_val);
691 int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
693 union devlink_param_value init_val);
694 void devlink_param_value_changed(struct devlink *devlink, u32 param_id);
695 void devlink_port_param_value_changed(struct devlink_port *devlink_port,
697 void devlink_param_value_str_fill(union devlink_param_value *dst_val,
699 struct devlink_region *devlink_region_create(struct devlink *devlink,
700 const char *region_name,
701 u32 region_max_snapshots,
703 void devlink_region_destroy(struct devlink_region *region);
704 u32 devlink_region_shapshot_id_get(struct devlink *devlink);
705 int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
706 u8 *data, u32 snapshot_id,
707 devlink_snapshot_data_dest_t *data_destructor);
708 int devlink_info_serial_number_put(struct devlink_info_req *req,
710 int devlink_info_driver_name_put(struct devlink_info_req *req,
712 int devlink_info_version_fixed_put(struct devlink_info_req *req,
713 const char *version_name,
714 const char *version_value);
715 int devlink_info_version_stored_put(struct devlink_info_req *req,
716 const char *version_name,
717 const char *version_value);
718 int devlink_info_version_running_put(struct devlink_info_req *req,
719 const char *version_name,
720 const char *version_value);
722 int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
723 int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);
725 int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
726 int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);
728 int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
730 int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
732 int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value);
733 int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value);
734 int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
735 int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value);
736 int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
737 int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
740 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
742 int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
744 int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
746 int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
748 int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
750 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
751 const void *value, u16 value_len);
753 struct devlink_health_reporter *
754 devlink_health_reporter_create(struct devlink *devlink,
755 const struct devlink_health_reporter_ops *ops,
756 u64 graceful_period, bool auto_recover,
759 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);
762 devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
763 int devlink_health_report(struct devlink_health_reporter *reporter,
764 const char *msg, void *priv_ctx);
766 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
767 enum devlink_health_reporter_state state);
769 void devlink_flash_update_begin_notify(struct devlink *devlink);
770 void devlink_flash_update_end_notify(struct devlink *devlink);
771 void devlink_flash_update_status_notify(struct devlink *devlink,
772 const char *status_msg,
773 const char *component,
775 unsigned long total);
777 #if IS_ENABLED(CONFIG_NET_DEVLINK)
779 void devlink_compat_running_version(struct net_device *dev,
780 char *buf, size_t len);
781 int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
782 int devlink_compat_phys_port_name_get(struct net_device *dev,
783 char *name, size_t len);
784 int devlink_compat_switch_id_get(struct net_device *dev,
785 struct netdev_phys_item_id *ppid);
790 devlink_compat_running_version(struct net_device *dev, char *buf, size_t len)
795 devlink_compat_flash_update(struct net_device *dev, const char *file_name)
801 devlink_compat_phys_port_name_get(struct net_device *dev,
802 char *name, size_t len)
808 devlink_compat_switch_id_get(struct net_device *dev,
809 struct netdev_phys_item_id *ppid)
816 #endif /* _NET_DEVLINK_H_ */