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 <net/net_namespace.h>
17 #include <uapi/linux/devlink.h>
22 struct list_head list
;
23 struct list_head port_list
;
24 struct list_head sb_list
;
25 struct list_head dpipe_table_list
;
26 struct list_head resource_list
;
27 struct list_head param_list
;
28 struct list_head region_list
;
30 struct list_head reporter_list
;
31 struct mutex reporters_lock
; /* protects reporter_list */
32 struct devlink_dpipe_headers
*dpipe_headers
;
33 const struct devlink_ops
*ops
;
37 char priv
[0] __aligned(NETDEV_ALIGN
);
40 struct devlink_port_attrs
{
44 enum devlink_port_flavour flavour
;
45 u32 port_number
; /* same value as "split group" */
46 u32 split_subport_number
;
47 struct netdev_phys_item_id switch_id
;
51 struct list_head list
;
52 struct list_head param_list
;
53 struct devlink
*devlink
;
56 spinlock_t type_lock
; /* Protects type and type_dev
57 * pointer consistency.
59 enum devlink_port_type type
;
60 enum devlink_port_type desired_type
;
62 struct devlink_port_attrs attrs
;
65 struct devlink_sb_pool_info
{
66 enum devlink_sb_pool_type pool_type
;
68 enum devlink_sb_threshold_type threshold_type
;
73 * struct devlink_dpipe_field - dpipe field object
75 * @id: index inside the headers field array
77 * @mapping_type: mapping type
79 struct devlink_dpipe_field
{
82 unsigned int bitwidth
;
83 enum devlink_dpipe_field_mapping_type mapping_type
;
87 * struct devlink_dpipe_header - dpipe header object
89 * @id: index, global/local detrmined by global bit
91 * @fields_count: number of fields
92 * @global: indicates if header is shared like most protocol header
95 struct devlink_dpipe_header
{
98 struct devlink_dpipe_field
*fields
;
99 unsigned int fields_count
;
104 * struct devlink_dpipe_match - represents match operation
105 * @type: type of match
106 * @header_index: header index (packets can have several headers of same
107 * type like in case of tunnels)
109 * @fieled_id: field index
111 struct devlink_dpipe_match
{
112 enum devlink_dpipe_match_type type
;
113 unsigned int header_index
;
114 struct devlink_dpipe_header
*header
;
115 unsigned int field_id
;
119 * struct devlink_dpipe_action - represents action operation
120 * @type: type of action
121 * @header_index: header index (packets can have several headers of same
122 * type like in case of tunnels)
124 * @fieled_id: field index
126 struct devlink_dpipe_action
{
127 enum devlink_dpipe_action_type type
;
128 unsigned int header_index
;
129 struct devlink_dpipe_header
*header
;
130 unsigned int field_id
;
134 * struct devlink_dpipe_value - represents value of match/action
137 * @mapping_value: in case the field has some mapping this value
138 * specified the mapping value
139 * @mapping_valid: specify if mapping value is valid
140 * @value_size: value size
144 struct devlink_dpipe_value
{
146 struct devlink_dpipe_action
*action
;
147 struct devlink_dpipe_match
*match
;
149 unsigned int mapping_value
;
151 unsigned int value_size
;
157 * struct devlink_dpipe_entry - table entry object
158 * @index: index of the entry in the table
159 * @match_values: match values
160 * @matche_values_count: count of matches tuples
161 * @action_values: actions values
162 * @action_values_count: count of actions values
163 * @counter: value of counter
164 * @counter_valid: Specify if value is valid from hardware
166 struct devlink_dpipe_entry
{
168 struct devlink_dpipe_value
*match_values
;
169 unsigned int match_values_count
;
170 struct devlink_dpipe_value
*action_values
;
171 unsigned int action_values_count
;
177 * struct devlink_dpipe_dump_ctx - context provided to driver in order
180 * @cmd: devlink command
182 * @nest: top attribute
185 struct devlink_dpipe_dump_ctx
{
186 struct genl_info
*info
;
187 enum devlink_command cmd
;
193 struct devlink_dpipe_table_ops
;
196 * struct devlink_dpipe_table - table object
199 * @counters_enabled: indicates if counters are active
200 * @counter_control_extern: indicates if counter control is in dpipe or
202 * @resource_valid: Indicate that the resource id is valid
203 * @resource_id: relative resource this table is related to
204 * @resource_units: number of resource's unit consumed per table's entry
205 * @table_ops: table operations
208 struct devlink_dpipe_table
{
210 struct list_head list
;
212 bool counters_enabled
;
213 bool counter_control_extern
;
217 struct devlink_dpipe_table_ops
*table_ops
;
222 * struct devlink_dpipe_table_ops - dpipe_table ops
223 * @actions_dump - dumps all tables actions
224 * @matches_dump - dumps all tables matches
225 * @entries_dump - dumps all active entries in the table
226 * @counters_set_update - when changing the counter status hardware sync
227 * maybe needed to allocate/free counter related
229 * @size_get - get size
231 struct devlink_dpipe_table_ops
{
232 int (*actions_dump
)(void *priv
, struct sk_buff
*skb
);
233 int (*matches_dump
)(void *priv
, struct sk_buff
*skb
);
234 int (*entries_dump
)(void *priv
, bool counters_enabled
,
235 struct devlink_dpipe_dump_ctx
*dump_ctx
);
236 int (*counters_set_update
)(void *priv
, bool enable
);
237 u64 (*size_get
)(void *priv
);
241 * struct devlink_dpipe_headers - dpipe headers
242 * @headers - header array can be shared (global bit) or driver specific
243 * @headers_count - count of headers
245 struct devlink_dpipe_headers
{
246 struct devlink_dpipe_header
**headers
;
247 unsigned int headers_count
;
251 * struct devlink_resource_size_params - resource's size parameters
252 * @size_min: minimum size which can be set
253 * @size_max: maximum size which can be set
254 * @size_granularity: size granularity
255 * @size_unit: resource's basic unit
257 struct devlink_resource_size_params
{
260 u64 size_granularity
;
261 enum devlink_resource_unit unit
;
265 devlink_resource_size_params_init(struct devlink_resource_size_params
*size_params
,
266 u64 size_min
, u64 size_max
,
267 u64 size_granularity
,
268 enum devlink_resource_unit unit
)
270 size_params
->size_min
= size_min
;
271 size_params
->size_max
= size_max
;
272 size_params
->size_granularity
= size_granularity
;
273 size_params
->unit
= unit
;
276 typedef u64
devlink_resource_occ_get_t(void *priv
);
279 * struct devlink_resource - devlink resource
280 * @name: name of the resource
281 * @id: id, per devlink instance
282 * @size: size of the resource
283 * @size_new: updated size of the resource, reload is needed
284 * @size_valid: valid in case the total size of the resource is valid
285 * including its children
286 * @parent: parent resource
287 * @size_params: size parameters
289 * @resource_list: list of child resources
291 struct devlink_resource
{
297 struct devlink_resource
*parent
;
298 struct devlink_resource_size_params size_params
;
299 struct list_head list
;
300 struct list_head resource_list
;
301 devlink_resource_occ_get_t
*occ_get
;
305 #define DEVLINK_RESOURCE_ID_PARENT_TOP 0
307 #define __DEVLINK_PARAM_MAX_STRING_VALUE 32
308 enum devlink_param_type
{
309 DEVLINK_PARAM_TYPE_U8
,
310 DEVLINK_PARAM_TYPE_U16
,
311 DEVLINK_PARAM_TYPE_U32
,
312 DEVLINK_PARAM_TYPE_STRING
,
313 DEVLINK_PARAM_TYPE_BOOL
,
316 union devlink_param_value
{
320 char vstr
[__DEVLINK_PARAM_MAX_STRING_VALUE
];
324 struct devlink_param_gset_ctx
{
325 union devlink_param_value val
;
326 enum devlink_param_cmode cmode
;
330 * struct devlink_param - devlink configuration parameter data
331 * @name: name of the parameter
332 * @generic: indicates if the parameter is generic or driver specific
333 * @type: parameter type
334 * @supported_cmodes: bitmap of supported configuration modes
335 * @get: get parameter value, used for runtime and permanent
336 * configuration modes
337 * @set: set parameter value, used for runtime and permanent
338 * configuration modes
339 * @validate: validate input value is applicable (within value range, etc.)
341 * This struct should be used by the driver to fill the data for
342 * a parameter it registers.
344 struct devlink_param
{
348 enum devlink_param_type type
;
349 unsigned long supported_cmodes
;
350 int (*get
)(struct devlink
*devlink
, u32 id
,
351 struct devlink_param_gset_ctx
*ctx
);
352 int (*set
)(struct devlink
*devlink
, u32 id
,
353 struct devlink_param_gset_ctx
*ctx
);
354 int (*validate
)(struct devlink
*devlink
, u32 id
,
355 union devlink_param_value val
,
356 struct netlink_ext_ack
*extack
);
359 struct devlink_param_item
{
360 struct list_head list
;
361 const struct devlink_param
*param
;
362 union devlink_param_value driverinit_value
;
363 bool driverinit_value_valid
;
367 enum devlink_param_generic_id
{
368 DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET
,
369 DEVLINK_PARAM_GENERIC_ID_MAX_MACS
,
370 DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV
,
371 DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
,
372 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI
,
373 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX
,
374 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN
,
375 DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY
,
377 /* add new param generic ids above here*/
378 __DEVLINK_PARAM_GENERIC_ID_MAX
,
379 DEVLINK_PARAM_GENERIC_ID_MAX
= __DEVLINK_PARAM_GENERIC_ID_MAX
- 1,
382 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset"
383 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL
385 #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs"
386 #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32
388 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov"
389 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL
391 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
392 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
394 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
395 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
397 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
398 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
400 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
401 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
403 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy"
404 #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8
406 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
408 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
409 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \
410 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \
412 .supported_cmodes = _cmodes, \
415 .validate = _validate, \
418 #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \
423 .supported_cmodes = _cmodes, \
426 .validate = _validate, \
429 /* Part number, identifier of board design */
430 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
431 /* Revision of board design */
432 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
433 /* Maker of the board */
434 #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
436 /* Control processor FW version */
437 #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"
438 /* Data path microcode controlling high-speed packet processing */
439 #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app"
440 /* UNDI software version */
441 #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi"
442 /* NCSI support/handler version */
443 #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi"
445 struct devlink_region
;
446 struct devlink_info_req
;
448 typedef void devlink_snapshot_data_dest_t(const void *data
);
451 struct devlink_health_reporter
;
453 enum devlink_health_reporter_state
{
454 DEVLINK_HEALTH_REPORTER_STATE_HEALTHY
,
455 DEVLINK_HEALTH_REPORTER_STATE_ERROR
,
459 * struct devlink_health_reporter_ops - Reporter operations
460 * @name: reporter name
461 * @recover: callback to recover from reported error
462 * if priv_ctx is NULL, run a full recover
463 * @dump: callback to dump an object
464 * if priv_ctx is NULL, run a full dump
465 * @diagnose: callback to diagnose the current status
468 struct devlink_health_reporter_ops
{
470 int (*recover
)(struct devlink_health_reporter
*reporter
,
472 int (*dump
)(struct devlink_health_reporter
*reporter
,
473 struct devlink_fmsg
*fmsg
, void *priv_ctx
);
474 int (*diagnose
)(struct devlink_health_reporter
*reporter
,
475 struct devlink_fmsg
*fmsg
);
479 int (*reload
)(struct devlink
*devlink
, struct netlink_ext_ack
*extack
);
480 int (*port_type_set
)(struct devlink_port
*devlink_port
,
481 enum devlink_port_type port_type
);
482 int (*port_split
)(struct devlink
*devlink
, unsigned int port_index
,
483 unsigned int count
, struct netlink_ext_ack
*extack
);
484 int (*port_unsplit
)(struct devlink
*devlink
, unsigned int port_index
,
485 struct netlink_ext_ack
*extack
);
486 int (*sb_pool_get
)(struct devlink
*devlink
, unsigned int sb_index
,
488 struct devlink_sb_pool_info
*pool_info
);
489 int (*sb_pool_set
)(struct devlink
*devlink
, unsigned int sb_index
,
490 u16 pool_index
, u32 size
,
491 enum devlink_sb_threshold_type threshold_type
,
492 struct netlink_ext_ack
*extack
);
493 int (*sb_port_pool_get
)(struct devlink_port
*devlink_port
,
494 unsigned int sb_index
, u16 pool_index
,
496 int (*sb_port_pool_set
)(struct devlink_port
*devlink_port
,
497 unsigned int sb_index
, u16 pool_index
,
498 u32 threshold
, struct netlink_ext_ack
*extack
);
499 int (*sb_tc_pool_bind_get
)(struct devlink_port
*devlink_port
,
500 unsigned int sb_index
,
502 enum devlink_sb_pool_type pool_type
,
503 u16
*p_pool_index
, u32
*p_threshold
);
504 int (*sb_tc_pool_bind_set
)(struct devlink_port
*devlink_port
,
505 unsigned int sb_index
,
507 enum devlink_sb_pool_type pool_type
,
508 u16 pool_index
, u32 threshold
,
509 struct netlink_ext_ack
*extack
);
510 int (*sb_occ_snapshot
)(struct devlink
*devlink
,
511 unsigned int sb_index
);
512 int (*sb_occ_max_clear
)(struct devlink
*devlink
,
513 unsigned int sb_index
);
514 int (*sb_occ_port_pool_get
)(struct devlink_port
*devlink_port
,
515 unsigned int sb_index
, u16 pool_index
,
516 u32
*p_cur
, u32
*p_max
);
517 int (*sb_occ_tc_port_bind_get
)(struct devlink_port
*devlink_port
,
518 unsigned int sb_index
,
520 enum devlink_sb_pool_type pool_type
,
521 u32
*p_cur
, u32
*p_max
);
523 int (*eswitch_mode_get
)(struct devlink
*devlink
, u16
*p_mode
);
524 int (*eswitch_mode_set
)(struct devlink
*devlink
, u16 mode
,
525 struct netlink_ext_ack
*extack
);
526 int (*eswitch_inline_mode_get
)(struct devlink
*devlink
, u8
*p_inline_mode
);
527 int (*eswitch_inline_mode_set
)(struct devlink
*devlink
, u8 inline_mode
,
528 struct netlink_ext_ack
*extack
);
529 int (*eswitch_encap_mode_get
)(struct devlink
*devlink
, u8
*p_encap_mode
);
530 int (*eswitch_encap_mode_set
)(struct devlink
*devlink
, u8 encap_mode
,
531 struct netlink_ext_ack
*extack
);
532 int (*info_get
)(struct devlink
*devlink
, struct devlink_info_req
*req
,
533 struct netlink_ext_ack
*extack
);
534 int (*flash_update
)(struct devlink
*devlink
, const char *file_name
,
535 const char *component
,
536 struct netlink_ext_ack
*extack
);
539 static inline void *devlink_priv(struct devlink
*devlink
)
542 return &devlink
->priv
;
545 static inline struct devlink
*priv_to_devlink(void *priv
)
548 return container_of(priv
, struct devlink
, priv
);
551 static inline struct devlink_port
*
552 netdev_to_devlink_port(struct net_device
*dev
)
554 if (dev
->netdev_ops
->ndo_get_devlink_port
)
555 return dev
->netdev_ops
->ndo_get_devlink_port(dev
);
559 static inline struct devlink
*netdev_to_devlink(struct net_device
*dev
)
561 struct devlink_port
*devlink_port
= netdev_to_devlink_port(dev
);
564 return devlink_port
->devlink
;
570 struct devlink
*devlink_alloc(const struct devlink_ops
*ops
, size_t priv_size
);
571 int devlink_register(struct devlink
*devlink
, struct device
*dev
);
572 void devlink_unregister(struct devlink
*devlink
);
573 void devlink_free(struct devlink
*devlink
);
574 int devlink_port_register(struct devlink
*devlink
,
575 struct devlink_port
*devlink_port
,
576 unsigned int port_index
);
577 void devlink_port_unregister(struct devlink_port
*devlink_port
);
578 void devlink_port_type_eth_set(struct devlink_port
*devlink_port
,
579 struct net_device
*netdev
);
580 void devlink_port_type_ib_set(struct devlink_port
*devlink_port
,
581 struct ib_device
*ibdev
);
582 void devlink_port_type_clear(struct devlink_port
*devlink_port
);
583 void devlink_port_attrs_set(struct devlink_port
*devlink_port
,
584 enum devlink_port_flavour flavour
,
585 u32 port_number
, bool split
,
586 u32 split_subport_number
,
587 const unsigned char *switch_id
,
588 unsigned char switch_id_len
);
589 int devlink_sb_register(struct devlink
*devlink
, unsigned int sb_index
,
590 u32 size
, u16 ingress_pools_count
,
591 u16 egress_pools_count
, u16 ingress_tc_count
,
592 u16 egress_tc_count
);
593 void devlink_sb_unregister(struct devlink
*devlink
, unsigned int sb_index
);
594 int devlink_dpipe_table_register(struct devlink
*devlink
,
595 const char *table_name
,
596 struct devlink_dpipe_table_ops
*table_ops
,
597 void *priv
, bool counter_control_extern
);
598 void devlink_dpipe_table_unregister(struct devlink
*devlink
,
599 const char *table_name
);
600 int devlink_dpipe_headers_register(struct devlink
*devlink
,
601 struct devlink_dpipe_headers
*dpipe_headers
);
602 void devlink_dpipe_headers_unregister(struct devlink
*devlink
);
603 bool devlink_dpipe_table_counter_enabled(struct devlink
*devlink
,
604 const char *table_name
);
605 int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx
*dump_ctx
);
606 int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx
*dump_ctx
,
607 struct devlink_dpipe_entry
*entry
);
608 int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx
*dump_ctx
);
609 void devlink_dpipe_entry_clear(struct devlink_dpipe_entry
*entry
);
610 int devlink_dpipe_action_put(struct sk_buff
*skb
,
611 struct devlink_dpipe_action
*action
);
612 int devlink_dpipe_match_put(struct sk_buff
*skb
,
613 struct devlink_dpipe_match
*match
);
614 extern struct devlink_dpipe_header devlink_dpipe_header_ethernet
;
615 extern struct devlink_dpipe_header devlink_dpipe_header_ipv4
;
616 extern struct devlink_dpipe_header devlink_dpipe_header_ipv6
;
618 int devlink_resource_register(struct devlink
*devlink
,
619 const char *resource_name
,
622 u64 parent_resource_id
,
623 const struct devlink_resource_size_params
*size_params
);
624 void devlink_resources_unregister(struct devlink
*devlink
,
625 struct devlink_resource
*resource
);
626 int devlink_resource_size_get(struct devlink
*devlink
,
628 u64
*p_resource_size
);
629 int devlink_dpipe_table_resource_set(struct devlink
*devlink
,
630 const char *table_name
, u64 resource_id
,
632 void devlink_resource_occ_get_register(struct devlink
*devlink
,
634 devlink_resource_occ_get_t
*occ_get
,
636 void devlink_resource_occ_get_unregister(struct devlink
*devlink
,
638 int devlink_params_register(struct devlink
*devlink
,
639 const struct devlink_param
*params
,
640 size_t params_count
);
641 void devlink_params_unregister(struct devlink
*devlink
,
642 const struct devlink_param
*params
,
643 size_t params_count
);
644 void devlink_params_publish(struct devlink
*devlink
);
645 void devlink_params_unpublish(struct devlink
*devlink
);
646 int devlink_port_params_register(struct devlink_port
*devlink_port
,
647 const struct devlink_param
*params
,
648 size_t params_count
);
649 void devlink_port_params_unregister(struct devlink_port
*devlink_port
,
650 const struct devlink_param
*params
,
651 size_t params_count
);
652 int devlink_param_driverinit_value_get(struct devlink
*devlink
, u32 param_id
,
653 union devlink_param_value
*init_val
);
654 int devlink_param_driverinit_value_set(struct devlink
*devlink
, u32 param_id
,
655 union devlink_param_value init_val
);
657 devlink_port_param_driverinit_value_get(struct devlink_port
*devlink_port
,
659 union devlink_param_value
*init_val
);
660 int devlink_port_param_driverinit_value_set(struct devlink_port
*devlink_port
,
662 union devlink_param_value init_val
);
663 void devlink_param_value_changed(struct devlink
*devlink
, u32 param_id
);
664 void devlink_port_param_value_changed(struct devlink_port
*devlink_port
,
666 void devlink_param_value_str_fill(union devlink_param_value
*dst_val
,
668 struct devlink_region
*devlink_region_create(struct devlink
*devlink
,
669 const char *region_name
,
670 u32 region_max_snapshots
,
672 void devlink_region_destroy(struct devlink_region
*region
);
673 u32
devlink_region_shapshot_id_get(struct devlink
*devlink
);
674 int devlink_region_snapshot_create(struct devlink_region
*region
, u64 data_len
,
675 u8
*data
, u32 snapshot_id
,
676 devlink_snapshot_data_dest_t
*data_destructor
);
677 int devlink_info_serial_number_put(struct devlink_info_req
*req
,
679 int devlink_info_driver_name_put(struct devlink_info_req
*req
,
681 int devlink_info_version_fixed_put(struct devlink_info_req
*req
,
682 const char *version_name
,
683 const char *version_value
);
684 int devlink_info_version_stored_put(struct devlink_info_req
*req
,
685 const char *version_name
,
686 const char *version_value
);
687 int devlink_info_version_running_put(struct devlink_info_req
*req
,
688 const char *version_name
,
689 const char *version_value
);
691 int devlink_fmsg_obj_nest_start(struct devlink_fmsg
*fmsg
);
692 int devlink_fmsg_obj_nest_end(struct devlink_fmsg
*fmsg
);
694 int devlink_fmsg_pair_nest_start(struct devlink_fmsg
*fmsg
, const char *name
);
695 int devlink_fmsg_pair_nest_end(struct devlink_fmsg
*fmsg
);
697 int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg
*fmsg
,
699 int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg
*fmsg
);
701 int devlink_fmsg_bool_put(struct devlink_fmsg
*fmsg
, bool value
);
702 int devlink_fmsg_u8_put(struct devlink_fmsg
*fmsg
, u8 value
);
703 int devlink_fmsg_u32_put(struct devlink_fmsg
*fmsg
, u32 value
);
704 int devlink_fmsg_u64_put(struct devlink_fmsg
*fmsg
, u64 value
);
705 int devlink_fmsg_string_put(struct devlink_fmsg
*fmsg
, const char *value
);
706 int devlink_fmsg_binary_put(struct devlink_fmsg
*fmsg
, const void *value
,
709 int devlink_fmsg_bool_pair_put(struct devlink_fmsg
*fmsg
, const char *name
,
711 int devlink_fmsg_u8_pair_put(struct devlink_fmsg
*fmsg
, const char *name
,
713 int devlink_fmsg_u32_pair_put(struct devlink_fmsg
*fmsg
, const char *name
,
715 int devlink_fmsg_u64_pair_put(struct devlink_fmsg
*fmsg
, const char *name
,
717 int devlink_fmsg_string_pair_put(struct devlink_fmsg
*fmsg
, const char *name
,
719 int devlink_fmsg_binary_pair_put(struct devlink_fmsg
*fmsg
, const char *name
,
720 const void *value
, u16 value_len
);
722 struct devlink_health_reporter
*
723 devlink_health_reporter_create(struct devlink
*devlink
,
724 const struct devlink_health_reporter_ops
*ops
,
725 u64 graceful_period
, bool auto_recover
,
728 devlink_health_reporter_destroy(struct devlink_health_reporter
*reporter
);
731 devlink_health_reporter_priv(struct devlink_health_reporter
*reporter
);
732 int devlink_health_report(struct devlink_health_reporter
*reporter
,
733 const char *msg
, void *priv_ctx
);
735 devlink_health_reporter_state_update(struct devlink_health_reporter
*reporter
,
736 enum devlink_health_reporter_state state
);
738 #if IS_ENABLED(CONFIG_NET_DEVLINK)
740 void devlink_compat_running_version(struct net_device
*dev
,
741 char *buf
, size_t len
);
742 int devlink_compat_flash_update(struct net_device
*dev
, const char *file_name
);
743 int devlink_compat_phys_port_name_get(struct net_device
*dev
,
744 char *name
, size_t len
);
745 int devlink_compat_switch_id_get(struct net_device
*dev
,
746 struct netdev_phys_item_id
*ppid
);
751 devlink_compat_running_version(struct net_device
*dev
, char *buf
, size_t len
)
756 devlink_compat_flash_update(struct net_device
*dev
, const char *file_name
)
762 devlink_compat_phys_port_name_get(struct net_device
*dev
,
763 char *name
, size_t len
)
769 devlink_compat_switch_id_get(struct net_device
*dev
,
770 struct netdev_phys_item_id
*ppid
)
777 #endif /* _NET_DEVLINK_H_ */