2 * include/net/devlink.h - Network physical device Netlink interface
3 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 #ifndef _NET_DEVLINK_H_
12 #define _NET_DEVLINK_H_
14 #include <linux/device.h>
15 #include <linux/slab.h>
16 #include <linux/gfp.h>
17 #include <linux/list.h>
18 #include <linux/netdevice.h>
19 #include <linux/spinlock.h>
20 #include <net/net_namespace.h>
21 #include <uapi/linux/devlink.h>
26 struct list_head list;
27 struct list_head port_list;
28 struct list_head sb_list;
29 struct list_head dpipe_table_list;
30 struct list_head resource_list;
31 struct list_head param_list;
32 struct list_head region_list;
34 struct list_head reporter_list;
35 struct devlink_dpipe_headers *dpipe_headers;
36 const struct devlink_ops *ops;
40 char priv[0] __aligned(NETDEV_ALIGN);
43 struct devlink_port_attrs {
47 enum devlink_port_flavour flavour;
48 u32 port_number; /* same value as "split group" */
49 u32 split_subport_number;
50 struct netdev_phys_item_id switch_id;
54 struct list_head list;
55 struct list_head param_list;
56 struct devlink *devlink;
59 spinlock_t type_lock; /* Protects type and type_dev
60 * pointer consistency.
62 enum devlink_port_type type;
63 enum devlink_port_type desired_type;
65 struct devlink_port_attrs attrs;
68 struct devlink_sb_pool_info {
69 enum devlink_sb_pool_type pool_type;
71 enum devlink_sb_threshold_type threshold_type;
76 * struct devlink_dpipe_field - dpipe field object
78 * @id: index inside the headers field array
80 * @mapping_type: mapping type
82 struct devlink_dpipe_field {
85 unsigned int bitwidth;
86 enum devlink_dpipe_field_mapping_type mapping_type;
90 * struct devlink_dpipe_header - dpipe header object
92 * @id: index, global/local detrmined by global bit
94 * @fields_count: number of fields
95 * @global: indicates if header is shared like most protocol header
98 struct devlink_dpipe_header {
101 struct devlink_dpipe_field *fields;
102 unsigned int fields_count;
107 * struct devlink_dpipe_match - represents match operation
108 * @type: type of match
109 * @header_index: header index (packets can have several headers of same
110 * type like in case of tunnels)
112 * @fieled_id: field index
114 struct devlink_dpipe_match {
115 enum devlink_dpipe_match_type type;
116 unsigned int header_index;
117 struct devlink_dpipe_header *header;
118 unsigned int field_id;
122 * struct devlink_dpipe_action - represents action operation
123 * @type: type of action
124 * @header_index: header index (packets can have several headers of same
125 * type like in case of tunnels)
127 * @fieled_id: field index
129 struct devlink_dpipe_action {
130 enum devlink_dpipe_action_type type;
131 unsigned int header_index;
132 struct devlink_dpipe_header *header;
133 unsigned int field_id;
137 * struct devlink_dpipe_value - represents value of match/action
140 * @mapping_value: in case the field has some mapping this value
141 * specified the mapping value
142 * @mapping_valid: specify if mapping value is valid
143 * @value_size: value size
147 struct devlink_dpipe_value {
149 struct devlink_dpipe_action *action;
150 struct devlink_dpipe_match *match;
152 unsigned int mapping_value;
154 unsigned int value_size;
160 * struct devlink_dpipe_entry - table entry object
161 * @index: index of the entry in the table
162 * @match_values: match values
163 * @matche_values_count: count of matches tuples
164 * @action_values: actions values
165 * @action_values_count: count of actions values
166 * @counter: value of counter
167 * @counter_valid: Specify if value is valid from hardware
169 struct devlink_dpipe_entry {
171 struct devlink_dpipe_value *match_values;
172 unsigned int match_values_count;
173 struct devlink_dpipe_value *action_values;
174 unsigned int action_values_count;
180 * struct devlink_dpipe_dump_ctx - context provided to driver in order
183 * @cmd: devlink command
185 * @nest: top attribute
188 struct devlink_dpipe_dump_ctx {
189 struct genl_info *info;
190 enum devlink_command cmd;
196 struct devlink_dpipe_table_ops;
199 * struct devlink_dpipe_table - table object
202 * @counters_enabled: indicates if counters are active
203 * @counter_control_extern: indicates if counter control is in dpipe or
205 * @resource_valid: Indicate that the resource id is valid
206 * @resource_id: relative resource this table is related to
207 * @resource_units: number of resource's unit consumed per table's entry
208 * @table_ops: table operations
211 struct devlink_dpipe_table {
213 struct list_head list;
215 bool counters_enabled;
216 bool counter_control_extern;
220 struct devlink_dpipe_table_ops *table_ops;
225 * struct devlink_dpipe_table_ops - dpipe_table ops
226 * @actions_dump - dumps all tables actions
227 * @matches_dump - dumps all tables matches
228 * @entries_dump - dumps all active entries in the table
229 * @counters_set_update - when changing the counter status hardware sync
230 * maybe needed to allocate/free counter related
232 * @size_get - get size
234 struct devlink_dpipe_table_ops {
235 int (*actions_dump)(void *priv, struct sk_buff *skb);
236 int (*matches_dump)(void *priv, struct sk_buff *skb);
237 int (*entries_dump)(void *priv, bool counters_enabled,
238 struct devlink_dpipe_dump_ctx *dump_ctx);
239 int (*counters_set_update)(void *priv, bool enable);
240 u64 (*size_get)(void *priv);
244 * struct devlink_dpipe_headers - dpipe headers
245 * @headers - header array can be shared (global bit) or driver specific
246 * @headers_count - count of headers
248 struct devlink_dpipe_headers {
249 struct devlink_dpipe_header **headers;
250 unsigned int headers_count;
254 * struct devlink_resource_size_params - resource's size parameters
255 * @size_min: minimum size which can be set
256 * @size_max: maximum size which can be set
257 * @size_granularity: size granularity
258 * @size_unit: resource's basic unit
260 struct devlink_resource_size_params {
263 u64 size_granularity;
264 enum devlink_resource_unit unit;
268 devlink_resource_size_params_init(struct devlink_resource_size_params *size_params,
269 u64 size_min, u64 size_max,
270 u64 size_granularity,
271 enum devlink_resource_unit unit)
273 size_params->size_min = size_min;
274 size_params->size_max = size_max;
275 size_params->size_granularity = size_granularity;
276 size_params->unit = unit;
279 typedef u64 devlink_resource_occ_get_t(void *priv);
282 * struct devlink_resource - devlink resource
283 * @name: name of the resource
284 * @id: id, per devlink instance
285 * @size: size of the resource
286 * @size_new: updated size of the resource, reload is needed
287 * @size_valid: valid in case the total size of the resource is valid
288 * including its children
289 * @parent: parent resource
290 * @size_params: size parameters
292 * @resource_list: list of child resources
294 struct devlink_resource {
300 struct devlink_resource *parent;
301 struct devlink_resource_size_params size_params;
302 struct list_head list;
303 struct list_head resource_list;
304 devlink_resource_occ_get_t *occ_get;
308 #define DEVLINK_RESOURCE_ID_PARENT_TOP 0
310 #define __DEVLINK_PARAM_MAX_STRING_VALUE 32
311 enum devlink_param_type {
312 DEVLINK_PARAM_TYPE_U8,
313 DEVLINK_PARAM_TYPE_U16,
314 DEVLINK_PARAM_TYPE_U32,
315 DEVLINK_PARAM_TYPE_STRING,
316 DEVLINK_PARAM_TYPE_BOOL,
319 union devlink_param_value {
323 char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE];
327 struct devlink_param_gset_ctx {
328 union devlink_param_value val;
329 enum devlink_param_cmode cmode;
333 * struct devlink_param - devlink configuration parameter data
334 * @name: name of the parameter
335 * @generic: indicates if the parameter is generic or driver specific
336 * @type: parameter type
337 * @supported_cmodes: bitmap of supported configuration modes
338 * @get: get parameter value, used for runtime and permanent
339 * configuration modes
340 * @set: set parameter value, used for runtime and permanent
341 * configuration modes
342 * @validate: validate input value is applicable (within value range, etc.)
344 * This struct should be used by the driver to fill the data for
345 * a parameter it registers.
347 struct devlink_param {
351 enum devlink_param_type type;
352 unsigned long supported_cmodes;
353 int (*get)(struct devlink *devlink, u32 id,
354 struct devlink_param_gset_ctx *ctx);
355 int (*set)(struct devlink *devlink, u32 id,
356 struct devlink_param_gset_ctx *ctx);
357 int (*validate)(struct devlink *devlink, u32 id,
358 union devlink_param_value val,
359 struct netlink_ext_ack *extack);
362 struct devlink_param_item {
363 struct list_head list;
364 const struct devlink_param *param;
365 union devlink_param_value driverinit_value;
366 bool driverinit_value_valid;
370 enum devlink_param_generic_id {
371 DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
372 DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
373 DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
374 DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
375 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
376 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
377 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
378 DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
380 /* add new param generic ids above here*/
381 __DEVLINK_PARAM_GENERIC_ID_MAX,
382 DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1,
385 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset"
386 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL
388 #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs"
389 #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32
391 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov"
392 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL
394 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
395 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
397 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
398 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
400 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
401 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
403 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
404 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
406 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy"
407 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8
409 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
411 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
412 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \
413 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \
415 .supported_cmodes = _cmodes, \
418 .validate = _validate, \
421 #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \
426 .supported_cmodes = _cmodes, \
429 .validate = _validate, \
432 /* Part number, identifier of board design */
433 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
434 /* Revision of board design */
435 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
436 /* Maker of the board */
437 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
439 /* Control processor FW version */
440 #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"
441 /* Data path microcode controlling high-speed packet processing */
442 #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app"
443 /* UNDI software version */
444 #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi"
445 /* NCSI support/handler version */
446 #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi"
448 struct devlink_region;
449 struct devlink_info_req;
451 typedef void devlink_snapshot_data_dest_t(const void *data);
454 struct devlink_health_reporter;
456 enum devlink_health_reporter_state {
457 DEVLINK_HEALTH_REPORTER_STATE_HEALTHY,
458 DEVLINK_HEALTH_REPORTER_STATE_ERROR,
462 * struct devlink_health_reporter_ops - Reporter operations
463 * @name: reporter name
464 * @recover: callback to recover from reported error
465 * if priv_ctx is NULL, run a full recover
466 * @dump: callback to dump an object
467 * if priv_ctx is NULL, run a full dump
468 * @diagnose: callback to diagnose the current status
471 struct devlink_health_reporter_ops {
473 int (*recover)(struct devlink_health_reporter *reporter,
475 int (*dump)(struct devlink_health_reporter *reporter,
476 struct devlink_fmsg *fmsg, void *priv_ctx);
477 int (*diagnose)(struct devlink_health_reporter *reporter,
478 struct devlink_fmsg *fmsg);
482 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
483 int (*port_type_set)(struct devlink_port *devlink_port,
484 enum devlink_port_type port_type);
485 int (*port_split)(struct devlink *devlink, unsigned int port_index,
486 unsigned int count, struct netlink_ext_ack *extack);
487 int (*port_unsplit)(struct devlink *devlink, unsigned int port_index,
488 struct netlink_ext_ack *extack);
489 int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index,
491 struct devlink_sb_pool_info *pool_info);
492 int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index,
493 u16 pool_index, u32 size,
494 enum devlink_sb_threshold_type threshold_type,
495 struct netlink_ext_ack *extack);
496 int (*sb_port_pool_get)(struct devlink_port *devlink_port,
497 unsigned int sb_index, u16 pool_index,
499 int (*sb_port_pool_set)(struct devlink_port *devlink_port,
500 unsigned int sb_index, u16 pool_index,
501 u32 threshold, struct netlink_ext_ack *extack);
502 int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port,
503 unsigned int sb_index,
505 enum devlink_sb_pool_type pool_type,
506 u16 *p_pool_index, u32 *p_threshold);
507 int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port,
508 unsigned int sb_index,
510 enum devlink_sb_pool_type pool_type,
511 u16 pool_index, u32 threshold,
512 struct netlink_ext_ack *extack);
513 int (*sb_occ_snapshot)(struct devlink *devlink,
514 unsigned int sb_index);
515 int (*sb_occ_max_clear)(struct devlink *devlink,
516 unsigned int sb_index);
517 int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port,
518 unsigned int sb_index, u16 pool_index,
519 u32 *p_cur, u32 *p_max);
520 int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port,
521 unsigned int sb_index,
523 enum devlink_sb_pool_type pool_type,
524 u32 *p_cur, u32 *p_max);
526 int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode);
527 int (*eswitch_mode_set)(struct devlink *devlink, u16 mode,
528 struct netlink_ext_ack *extack);
529 int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
530 int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode,
531 struct netlink_ext_ack *extack);
532 int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode);
533 int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode,
534 struct netlink_ext_ack *extack);
535 int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
536 struct netlink_ext_ack *extack);
537 int (*flash_update)(struct devlink *devlink, const char *file_name,
538 const char *component,
539 struct netlink_ext_ack *extack);
542 static inline void *devlink_priv(struct devlink *devlink)
545 return &devlink->priv;
548 static inline struct devlink *priv_to_devlink(void *priv)
551 return container_of(priv, struct devlink, priv);
554 static inline struct devlink_port *
555 netdev_to_devlink_port(struct net_device *dev)
557 if (dev->netdev_ops->ndo_get_devlink_port)
558 return dev->netdev_ops->ndo_get_devlink_port(dev);
562 static inline struct devlink *netdev_to_devlink(struct net_device *dev)
564 struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
567 return devlink_port->devlink;
573 struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
574 int devlink_register(struct devlink *devlink, struct device *dev);
575 void devlink_unregister(struct devlink *devlink);
576 void devlink_free(struct devlink *devlink);
577 int devlink_port_register(struct devlink *devlink,
578 struct devlink_port *devlink_port,
579 unsigned int port_index);
580 void devlink_port_unregister(struct devlink_port *devlink_port);
581 void devlink_port_type_eth_set(struct devlink_port *devlink_port,
582 struct net_device *netdev);
583 void devlink_port_type_ib_set(struct devlink_port *devlink_port,
584 struct ib_device *ibdev);
585 void devlink_port_type_clear(struct devlink_port *devlink_port);
586 void devlink_port_attrs_set(struct devlink_port *devlink_port,
587 enum devlink_port_flavour flavour,
588 u32 port_number, bool split,
589 u32 split_subport_number,
590 const unsigned char *switch_id,
591 unsigned char switch_id_len);
592 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
593 u32 size, u16 ingress_pools_count,
594 u16 egress_pools_count, u16 ingress_tc_count,
595 u16 egress_tc_count);
596 void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
597 int devlink_dpipe_table_register(struct devlink *devlink,
598 const char *table_name,
599 struct devlink_dpipe_table_ops *table_ops,
600 void *priv, bool counter_control_extern);
601 void devlink_dpipe_table_unregister(struct devlink *devlink,
602 const char *table_name);
603 int devlink_dpipe_headers_register(struct devlink *devlink,
604 struct devlink_dpipe_headers *dpipe_headers);
605 void devlink_dpipe_headers_unregister(struct devlink *devlink);
606 bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
607 const char *table_name);
608 int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
609 int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
610 struct devlink_dpipe_entry *entry);
611 int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
612 void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
613 int devlink_dpipe_action_put(struct sk_buff *skb,
614 struct devlink_dpipe_action *action);
615 int devlink_dpipe_match_put(struct sk_buff *skb,
616 struct devlink_dpipe_match *match);
617 extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
618 extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
619 extern struct devlink_dpipe_header devlink_dpipe_header_ipv6;
621 int devlink_resource_register(struct devlink *devlink,
622 const char *resource_name,
625 u64 parent_resource_id,
626 const struct devlink_resource_size_params *size_params);
627 void devlink_resources_unregister(struct devlink *devlink,
628 struct devlink_resource *resource);
629 int devlink_resource_size_get(struct devlink *devlink,
631 u64 *p_resource_size);
632 int devlink_dpipe_table_resource_set(struct devlink *devlink,
633 const char *table_name, u64 resource_id,
635 void devlink_resource_occ_get_register(struct devlink *devlink,
637 devlink_resource_occ_get_t *occ_get,
639 void devlink_resource_occ_get_unregister(struct devlink *devlink,
641 int devlink_params_register(struct devlink *devlink,
642 const struct devlink_param *params,
643 size_t params_count);
644 void devlink_params_unregister(struct devlink *devlink,
645 const struct devlink_param *params,
646 size_t params_count);
647 void devlink_params_publish(struct devlink *devlink);
648 void devlink_params_unpublish(struct devlink *devlink);
649 int devlink_port_params_register(struct devlink_port *devlink_port,
650 const struct devlink_param *params,
651 size_t params_count);
652 void devlink_port_params_unregister(struct devlink_port *devlink_port,
653 const struct devlink_param *params,
654 size_t params_count);
655 int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
656 union devlink_param_value *init_val);
657 int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
658 union devlink_param_value init_val);
660 devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
662 union devlink_param_value *init_val);
663 int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
665 union devlink_param_value init_val);
666 void devlink_param_value_changed(struct devlink *devlink, u32 param_id);
667 void devlink_port_param_value_changed(struct devlink_port *devlink_port,
669 void devlink_param_value_str_fill(union devlink_param_value *dst_val,
671 struct devlink_region *devlink_region_create(struct devlink *devlink,
672 const char *region_name,
673 u32 region_max_snapshots,
675 void devlink_region_destroy(struct devlink_region *region);
676 u32 devlink_region_shapshot_id_get(struct devlink *devlink);
677 int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
678 u8 *data, u32 snapshot_id,
679 devlink_snapshot_data_dest_t *data_destructor);
680 int devlink_info_serial_number_put(struct devlink_info_req *req,
682 int devlink_info_driver_name_put(struct devlink_info_req *req,
684 int devlink_info_version_fixed_put(struct devlink_info_req *req,
685 const char *version_name,
686 const char *version_value);
687 int devlink_info_version_stored_put(struct devlink_info_req *req,
688 const char *version_name,
689 const char *version_value);
690 int devlink_info_version_running_put(struct devlink_info_req *req,
691 const char *version_name,
692 const char *version_value);
694 int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
695 int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);
697 int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
698 int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);
700 int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
702 int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
704 int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value);
705 int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value);
706 int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
707 int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value);
708 int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
709 int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
712 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
714 int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
716 int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
718 int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
720 int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
722 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
723 const void *value, u16 value_len);
725 struct devlink_health_reporter *
726 devlink_health_reporter_create(struct devlink *devlink,
727 const struct devlink_health_reporter_ops *ops,
728 u64 graceful_period, bool auto_recover,
731 devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);
734 devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
735 int devlink_health_report(struct devlink_health_reporter *reporter,
736 const char *msg, void *priv_ctx);
738 devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
739 enum devlink_health_reporter_state state);
741 #if IS_ENABLED(CONFIG_NET_DEVLINK)
743 void devlink_compat_running_version(struct net_device *dev,
744 char *buf, size_t len);
745 int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
746 int devlink_compat_phys_port_name_get(struct net_device *dev,
747 char *name, size_t len);
748 int devlink_compat_switch_id_get(struct net_device *dev,
749 struct netdev_phys_item_id *ppid);
754 devlink_compat_running_version(struct net_device *dev, char *buf, size_t len)
759 devlink_compat_flash_update(struct net_device *dev, const char *file_name)
765 devlink_compat_phys_port_name_get(struct net_device *dev,
766 char *name, size_t len)
772 devlink_compat_switch_id_get(struct net_device *dev,
773 struct netdev_phys_item_id *ppid)
780 #endif /* _NET_DEVLINK_H_ */