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_attrs {
45 enum devlink_port_flavour flavour;
46 u32 port_number; /* same value as "split group" */
47 u32 split_subport_number;
48 struct netdev_phys_item_id switch_id;
52 struct list_head list;
53 struct list_head param_list;
54 struct devlink *devlink;
57 spinlock_t type_lock; /* Protects type and type_dev
58 * pointer consistency.
60 enum devlink_port_type type;
61 enum devlink_port_type desired_type;
63 struct devlink_port_attrs attrs;
64 struct delayed_work type_warn_dw;
67 struct devlink_sb_pool_info {
68 enum devlink_sb_pool_type pool_type;
70 enum devlink_sb_threshold_type threshold_type;
75 * struct devlink_dpipe_field - dpipe field object
77 * @id: index inside the headers field array
79 * @mapping_type: mapping type
81 struct devlink_dpipe_field {
84 unsigned int bitwidth;
85 enum devlink_dpipe_field_mapping_type mapping_type;
89 * struct devlink_dpipe_header - dpipe header object
91 * @id: index, global/local detrmined by global bit
93 * @fields_count: number of fields
94 * @global: indicates if header is shared like most protocol header
97 struct devlink_dpipe_header {
100 struct devlink_dpipe_field *fields;
101 unsigned int fields_count;
106 * struct devlink_dpipe_match - represents match operation
107 * @type: type of match
108 * @header_index: header index (packets can have several headers of same
109 * type like in case of tunnels)
111 * @fieled_id: field index
113 struct devlink_dpipe_match {
114 enum devlink_dpipe_match_type type;
115 unsigned int header_index;
116 struct devlink_dpipe_header *header;
117 unsigned int field_id;
121 * struct devlink_dpipe_action - represents action operation
122 * @type: type of action
123 * @header_index: header index (packets can have several headers of same
124 * type like in case of tunnels)
126 * @fieled_id: field index
128 struct devlink_dpipe_action {
129 enum devlink_dpipe_action_type type;
130 unsigned int header_index;
131 struct devlink_dpipe_header *header;
132 unsigned int field_id;
136 * struct devlink_dpipe_value - represents value of match/action
139 * @mapping_value: in case the field has some mapping this value
140 * specified the mapping value
141 * @mapping_valid: specify if mapping value is valid
142 * @value_size: value size
146 struct devlink_dpipe_value {
148 struct devlink_dpipe_action *action;
149 struct devlink_dpipe_match *match;
151 unsigned int mapping_value;
153 unsigned int value_size;
159 * struct devlink_dpipe_entry - table entry object
160 * @index: index of the entry in the table
161 * @match_values: match values
162 * @matche_values_count: count of matches tuples
163 * @action_values: actions values
164 * @action_values_count: count of actions values
165 * @counter: value of counter
166 * @counter_valid: Specify if value is valid from hardware
168 struct devlink_dpipe_entry {
170 struct devlink_dpipe_value *match_values;
171 unsigned int match_values_count;
172 struct devlink_dpipe_value *action_values;
173 unsigned int action_values_count;
179 * struct devlink_dpipe_dump_ctx - context provided to driver in order
182 * @cmd: devlink command
184 * @nest: top attribute
187 struct devlink_dpipe_dump_ctx {
188 struct genl_info *info;
189 enum devlink_command cmd;
195 struct devlink_dpipe_table_ops;
198 * struct devlink_dpipe_table - table object
201 * @counters_enabled: indicates if counters are active
202 * @counter_control_extern: indicates if counter control is in dpipe or
204 * @resource_valid: Indicate that the resource id is valid
205 * @resource_id: relative resource this table is related to
206 * @resource_units: number of resource's unit consumed per table's entry
207 * @table_ops: table operations
210 struct devlink_dpipe_table {
212 struct list_head list;
214 bool counters_enabled;
215 bool counter_control_extern;
219 struct devlink_dpipe_table_ops *table_ops;
224 * struct devlink_dpipe_table_ops - dpipe_table ops
225 * @actions_dump - dumps all tables actions
226 * @matches_dump - dumps all tables matches
227 * @entries_dump - dumps all active entries in the table
228 * @counters_set_update - when changing the counter status hardware sync
229 * maybe needed to allocate/free counter related
231 * @size_get - get size
233 struct devlink_dpipe_table_ops {
234 int (*actions_dump)(void *priv, struct sk_buff *skb);
235 int (*matches_dump)(void *priv, struct sk_buff *skb);
236 int (*entries_dump)(void *priv, bool counters_enabled,
237 struct devlink_dpipe_dump_ctx *dump_ctx);
238 int (*counters_set_update)(void *priv, bool enable);
239 u64 (*size_get)(void *priv);
243 * struct devlink_dpipe_headers - dpipe headers
244 * @headers - header array can be shared (global bit) or driver specific
245 * @headers_count - count of headers
247 struct devlink_dpipe_headers {
248 struct devlink_dpipe_header **headers;
249 unsigned int headers_count;
253 * struct devlink_resource_size_params - resource's size parameters
254 * @size_min: minimum size which can be set
255 * @size_max: maximum size which can be set
256 * @size_granularity: size granularity
257 * @size_unit: resource's basic unit
259 struct devlink_resource_size_params {
262 u64 size_granularity;
263 enum devlink_resource_unit unit;
267 devlink_resource_size_params_init(struct devlink_resource_size_params *size_params,
268 u64 size_min, u64 size_max,
269 u64 size_granularity,
270 enum devlink_resource_unit unit)
272 size_params->size_min = size_min;
273 size_params->size_max = size_max;
274 size_params->size_granularity = size_granularity;
275 size_params->unit = unit;
278 typedef u64 devlink_resource_occ_get_t(void *priv);
281 * struct devlink_resource - devlink resource
282 * @name: name of the resource
283 * @id: id, per devlink instance
284 * @size: size of the resource
285 * @size_new: updated size of the resource, reload is needed
286 * @size_valid: valid in case the total size of the resource is valid
287 * including its children
288 * @parent: parent resource
289 * @size_params: size parameters
291 * @resource_list: list of child resources
293 struct devlink_resource {
299 struct devlink_resource *parent;
300 struct devlink_resource_size_params size_params;
301 struct list_head list;
302 struct list_head resource_list;
303 devlink_resource_occ_get_t *occ_get;
307 #define DEVLINK_RESOURCE_ID_PARENT_TOP 0
309 #define __DEVLINK_PARAM_MAX_STRING_VALUE 32
310 enum devlink_param_type {
311 DEVLINK_PARAM_TYPE_U8,
312 DEVLINK_PARAM_TYPE_U16,
313 DEVLINK_PARAM_TYPE_U32,
314 DEVLINK_PARAM_TYPE_STRING,
315 DEVLINK_PARAM_TYPE_BOOL,
318 union devlink_param_value {
322 char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE];
326 struct devlink_param_gset_ctx {
327 union devlink_param_value val;
328 enum devlink_param_cmode cmode;
332 * struct devlink_param - devlink configuration parameter data
333 * @name: name of the parameter
334 * @generic: indicates if the parameter is generic or driver specific
335 * @type: parameter type
336 * @supported_cmodes: bitmap of supported configuration modes
337 * @get: get parameter value, used for runtime and permanent
338 * configuration modes
339 * @set: set parameter value, used for runtime and permanent
340 * configuration modes
341 * @validate: validate input value is applicable (within value range, etc.)
343 * This struct should be used by the driver to fill the data for
344 * a parameter it registers.
346 struct devlink_param {
350 enum devlink_param_type type;
351 unsigned long supported_cmodes;
352 int (*get)(struct devlink *devlink, u32 id,
353 struct devlink_param_gset_ctx *ctx);
354 int (*set)(struct devlink *devlink, u32 id,
355 struct devlink_param_gset_ctx *ctx);
356 int (*validate)(struct devlink *devlink, u32 id,
357 union devlink_param_value val,
358 struct netlink_ext_ack *extack);
361 struct devlink_param_item {
362 struct list_head list;
363 const struct devlink_param *param;
364 union devlink_param_value driverinit_value;
365 bool driverinit_value_valid;
369 enum devlink_param_generic_id {
370 DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
371 DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
372 DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
373 DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
374 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
375 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
376 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
377 DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
379 /* add new param generic ids above here*/
380 __DEVLINK_PARAM_GENERIC_ID_MAX,
381 DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1,
384 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset"
385 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL
387 #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs"
388 #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32
390 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov"
391 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL
393 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
394 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
396 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
397 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
399 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
400 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
402 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
403 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
405 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy"
406 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8
408 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
410 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
411 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \
412 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \
414 .supported_cmodes = _cmodes, \
417 .validate = _validate, \
420 #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \
425 .supported_cmodes = _cmodes, \
428 .validate = _validate, \
431 /* Part number, identifier of board design */
432 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
433 /* Revision of board design */
434 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
435 /* Maker of the board */
436 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
438 /* Control processor FW version */
439 #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"
440 /* Data path microcode controlling high-speed packet processing */
441 #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app"
442 /* UNDI software version */
443 #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi"
444 /* NCSI support/handler version */
445 #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi"
447 struct devlink_region;
448 struct devlink_info_req;
450 typedef void devlink_snapshot_data_dest_t(const void *data);
453 struct devlink_health_reporter;
455 enum devlink_health_reporter_state {
456 DEVLINK_HEALTH_REPORTER_STATE_HEALTHY,
457 DEVLINK_HEALTH_REPORTER_STATE_ERROR,
461 * struct devlink_health_reporter_ops - Reporter operations
462 * @name: reporter name
463 * @recover: callback to recover from reported error
464 * if priv_ctx is NULL, run a full recover
465 * @dump: callback to dump an object
466 * if priv_ctx is NULL, run a full dump
467 * @diagnose: callback to diagnose the current status
470 struct devlink_health_reporter_ops {
472 int (*recover)(struct devlink_health_reporter *reporter,
474 int (*dump)(struct devlink_health_reporter *reporter,
475 struct devlink_fmsg *fmsg, void *priv_ctx);
476 int (*diagnose)(struct devlink_health_reporter *reporter,
477 struct devlink_fmsg *fmsg);
481 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
482 int (*port_type_set)(struct devlink_port *devlink_port,
483 enum devlink_port_type port_type);
484 int (*port_split)(struct devlink *devlink, unsigned int port_index,
485 unsigned int count, struct netlink_ext_ack *extack);
486 int (*port_unsplit)(struct devlink *devlink, unsigned int port_index,
487 struct netlink_ext_ack *extack);
488 int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index,
490 struct devlink_sb_pool_info *pool_info);
491 int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index,
492 u16 pool_index, u32 size,
493 enum devlink_sb_threshold_type threshold_type,
494 struct netlink_ext_ack *extack);
495 int (*sb_port_pool_get)(struct devlink_port *devlink_port,
496 unsigned int sb_index, u16 pool_index,
498 int (*sb_port_pool_set)(struct devlink_port *devlink_port,
499 unsigned int sb_index, u16 pool_index,
500 u32 threshold, struct netlink_ext_ack *extack);
501 int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port,
502 unsigned int sb_index,
504 enum devlink_sb_pool_type pool_type,
505 u16 *p_pool_index, u32 *p_threshold);
506 int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port,
507 unsigned int sb_index,
509 enum devlink_sb_pool_type pool_type,
510 u16 pool_index, u32 threshold,
511 struct netlink_ext_ack *extack);
512 int (*sb_occ_snapshot)(struct devlink *devlink,
513 unsigned int sb_index);
514 int (*sb_occ_max_clear)(struct devlink *devlink,
515 unsigned int sb_index);
516 int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port,
517 unsigned int sb_index, u16 pool_index,
518 u32 *p_cur, u32 *p_max);
519 int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port,
520 unsigned int sb_index,
522 enum devlink_sb_pool_type pool_type,
523 u32 *p_cur, u32 *p_max);
525 int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode);
526 int (*eswitch_mode_set)(struct devlink *devlink, u16 mode,
527 struct netlink_ext_ack *extack);
528 int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
529 int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode,
530 struct netlink_ext_ack *extack);
531 int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode);
532 int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode,
533 struct netlink_ext_ack *extack);
534 int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
535 struct netlink_ext_ack *extack);
536 int (*flash_update)(struct devlink *devlink, const char *file_name,
537 const char *component,
538 struct netlink_ext_ack *extack);
541 static inline void *devlink_priv(struct devlink *devlink)
544 return &devlink->priv;
547 static inline struct devlink *priv_to_devlink(void *priv)
550 return container_of(priv, struct devlink, priv);
553 static inline struct devlink_port *
554 netdev_to_devlink_port(struct net_device *dev)
556 if (dev->netdev_ops->ndo_get_devlink_port)
557 return dev->netdev_ops->ndo_get_devlink_port(dev);
561 static inline struct devlink *netdev_to_devlink(struct net_device *dev)
563 struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
566 return devlink_port->devlink;
572 struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
573 int devlink_register(struct devlink *devlink, struct device *dev);
574 void devlink_unregister(struct devlink *devlink);
575 void devlink_free(struct devlink *devlink);
576 int devlink_port_register(struct devlink *devlink,
577 struct devlink_port *devlink_port,
578 unsigned int port_index);
579 void devlink_port_unregister(struct devlink_port *devlink_port);
580 void devlink_port_type_eth_set(struct devlink_port *devlink_port,
581 struct net_device *netdev);
582 void devlink_port_type_ib_set(struct devlink_port *devlink_port,
583 struct ib_device *ibdev);
584 void devlink_port_type_clear(struct devlink_port *devlink_port);
585 void devlink_port_attrs_set(struct devlink_port *devlink_port,
586 enum devlink_port_flavour flavour,
587 u32 port_number, bool split,
588 u32 split_subport_number,
589 const unsigned char *switch_id,
590 unsigned char switch_id_len);
591 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
592 u32 size, u16 ingress_pools_count,
593 u16 egress_pools_count, u16 ingress_tc_count,
594 u16 egress_tc_count);
595 void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
596 int devlink_dpipe_table_register(struct devlink *devlink,
597 const char *table_name,
598 struct devlink_dpipe_table_ops *table_ops,
599 void *priv, bool counter_control_extern);
600 void devlink_dpipe_table_unregister(struct devlink *devlink,
601 const char *table_name);
602 int devlink_dpipe_headers_register(struct devlink *devlink,
603 struct devlink_dpipe_headers *dpipe_headers);
604 void devlink_dpipe_headers_unregister(struct devlink *devlink);
605 bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
606 const char *table_name);
607 int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
608 int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
609 struct devlink_dpipe_entry *entry);
610 int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
611 void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
612 int devlink_dpipe_action_put(struct sk_buff *skb,
613 struct devlink_dpipe_action *action);
614 int devlink_dpipe_match_put(struct sk_buff *skb,
615 struct devlink_dpipe_match *match);
616 extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
617 extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
618 extern struct devlink_dpipe_header devlink_dpipe_header_ipv6;
620 int devlink_resource_register(struct devlink *devlink,
621 const char *resource_name,
624 u64 parent_resource_id,
625 const struct devlink_resource_size_params *size_params);
626 void devlink_resources_unregister(struct devlink *devlink,
627 struct devlink_resource *resource);
628 int devlink_resource_size_get(struct devlink *devlink,
630 u64 *p_resource_size);
631 int devlink_dpipe_table_resource_set(struct devlink *devlink,
632 const char *table_name, u64 resource_id,
634 void devlink_resource_occ_get_register(struct devlink *devlink,
636 devlink_resource_occ_get_t *occ_get,
638 void devlink_resource_occ_get_unregister(struct devlink *devlink,
640 int devlink_params_register(struct devlink *devlink,
641 const struct devlink_param *params,
642 size_t params_count);
643 void devlink_params_unregister(struct devlink *devlink,
644 const struct devlink_param *params,
645 size_t params_count);
646 void devlink_params_publish(struct devlink *devlink);
647 void devlink_params_unpublish(struct devlink *devlink);
648 int devlink_port_params_register(struct devlink_port *devlink_port,
649 const struct devlink_param *params,
650 size_t params_count);
651 void devlink_port_params_unregister(struct devlink_port *devlink_port,
652 const struct devlink_param *params,
653 size_t params_count);
654 int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
655 union devlink_param_value *init_val);
656 int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
657 union devlink_param_value init_val);
659 devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
661 union devlink_param_value *init_val);
662 int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
664 union devlink_param_value init_val);
665 void devlink_param_value_changed(struct devlink *devlink, u32 param_id);
666 void devlink_port_param_value_changed(struct devlink_port *devlink_port,
668 void devlink_param_value_str_fill(union devlink_param_value *dst_val,
670 struct devlink_region *devlink_region_create(struct devlink *devlink,
671 const char *region_name,
672 u32 region_max_snapshots,
674 void devlink_region_destroy(struct devlink_region *region);
675 u32 devlink_region_shapshot_id_get(struct devlink *devlink);
676 int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
677 u8 *data, u32 snapshot_id,
678 devlink_snapshot_data_dest_t *data_destructor);
679 int devlink_info_serial_number_put(struct devlink_info_req *req,
681 int devlink_info_driver_name_put(struct devlink_info_req *req,
683 int devlink_info_version_fixed_put(struct devlink_info_req *req,
684 const char *version_name,
685 const char *version_value);
686 int devlink_info_version_stored_put(struct devlink_info_req *req,
687 const char *version_name,
688 const char *version_value);
689 int devlink_info_version_running_put(struct devlink_info_req *req,
690 const char *version_name,
691 const char *version_value);
693 int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
694 int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);
696 int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
697 int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);
699 int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
701 int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
703 int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value);
704 int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value);
705 int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
706 int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value);
707 int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
708 int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
711 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
713 int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
715 int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
717 int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
719 int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
721 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
722 const void *value, u16 value_len);
724 struct devlink_health_reporter *
725 devlink_health_reporter_create(struct devlink *devlink,
726 const struct devlink_health_reporter_ops *ops,
727 u64 graceful_period, bool auto_recover,
730 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);
733 devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
734 int devlink_health_report(struct devlink_health_reporter *reporter,
735 const char *msg, void *priv_ctx);
737 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
738 enum devlink_health_reporter_state state);
740 void devlink_flash_update_begin_notify(struct devlink *devlink);
741 void devlink_flash_update_end_notify(struct devlink *devlink);
742 void devlink_flash_update_status_notify(struct devlink *devlink,
743 const char *status_msg,
744 const char *component,
746 unsigned long total);
748 #if IS_ENABLED(CONFIG_NET_DEVLINK)
750 void devlink_compat_running_version(struct net_device *dev,
751 char *buf, size_t len);
752 int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
753 int devlink_compat_phys_port_name_get(struct net_device *dev,
754 char *name, size_t len);
755 int devlink_compat_switch_id_get(struct net_device *dev,
756 struct netdev_phys_item_id *ppid);
761 devlink_compat_running_version(struct net_device *dev, char *buf, size_t len)
766 devlink_compat_flash_update(struct net_device *dev, const char *file_name)
772 devlink_compat_phys_port_name_get(struct net_device *dev,
773 char *name, size_t len)
779 devlink_compat_switch_id_get(struct net_device *dev,
780 struct netdev_phys_item_id *ppid)
787 #endif /* _NET_DEVLINK_H_ */