selftests: devlink_trap_l3_drops: Add test cases of irif and erif disabled
[linux-block.git] / include / net / devlink.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
bfcd3a46
JP
2/*
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>
bfcd3a46
JP
6 */
7#ifndef _NET_DEVLINK_H_
8#define _NET_DEVLINK_H_
9
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>
b8f97554 15#include <linux/spinlock.h>
136bf27f 16#include <linux/workqueue.h>
0f420b6c 17#include <linux/refcount.h>
bfcd3a46
JP
18#include <net/net_namespace.h>
19#include <uapi/linux/devlink.h>
20
21struct devlink_ops;
22
23struct devlink {
24 struct list_head list;
25 struct list_head port_list;
bf797471 26 struct list_head sb_list;
1555d204 27 struct list_head dpipe_table_list;
d9f9b9a4 28 struct list_head resource_list;
eabaef18 29 struct list_head param_list;
b16ebe92 30 struct list_head region_list;
ccadfa44 31 u32 snapshot_id;
a0bdcc59 32 struct list_head reporter_list;
b587bdaf 33 struct mutex reporters_lock; /* protects reporter_list */
1555d204 34 struct devlink_dpipe_headers *dpipe_headers;
0f420b6c
IS
35 struct list_head trap_list;
36 struct list_head trap_group_list;
bfcd3a46
JP
37 const struct devlink_ops *ops;
38 struct device *dev;
39 possible_net_t _net;
2406e7e5 40 struct mutex lock;
a0c76345
JP
41 u8 reload_failed:1,
42 reload_enabled:1,
43 registered:1;
bfcd3a46
JP
44 char priv[0] __aligned(NETDEV_ALIGN);
45};
46
378ef01b
PP
47struct devlink_port_phys_attrs {
48 u32 port_number; /* Same value as "split group".
49 * A physical port which is visible to the user
50 * for a given port flavour.
51 */
52 u32 split_subport_number;
53};
54
98fd2d65
PP
55struct devlink_port_pci_pf_attrs {
56 u16 pf; /* Associated PCI PF for this port. */
57};
58
e41b6bf3
PP
59struct devlink_port_pci_vf_attrs {
60 u16 pf; /* Associated PCI PF for this port. */
61 u16 vf; /* Associated PCI VF for of the PCI PF for this port. */
62};
63
b9ffcbaf 64struct devlink_port_attrs {
407dd706 65 u8 set:1,
bec5267c
JP
66 split:1,
67 switch_port:1;
5ec1380a 68 enum devlink_port_flavour flavour;
bec5267c 69 struct netdev_phys_item_id switch_id;
378ef01b
PP
70 union {
71 struct devlink_port_phys_attrs phys;
98fd2d65 72 struct devlink_port_pci_pf_attrs pci_pf;
e41b6bf3 73 struct devlink_port_pci_vf_attrs pci_vf;
378ef01b 74 };
b9ffcbaf
JP
75};
76
bfcd3a46
JP
77struct devlink_port {
78 struct list_head list;
39e6160e 79 struct list_head param_list;
bfcd3a46 80 struct devlink *devlink;
c7282b50 81 unsigned int index;
bfcd3a46 82 bool registered;
b8f97554
JP
83 spinlock_t type_lock; /* Protects type and type_dev
84 * pointer consistency.
85 */
bfcd3a46
JP
86 enum devlink_port_type type;
87 enum devlink_port_type desired_type;
88 void *type_dev;
b9ffcbaf 89 struct devlink_port_attrs attrs;
136bf27f 90 struct delayed_work type_warn_dw;
bfcd3a46
JP
91};
92
bf797471
JP
93struct devlink_sb_pool_info {
94 enum devlink_sb_pool_type pool_type;
95 u32 size;
96 enum devlink_sb_threshold_type threshold_type;
bff5731d 97 u32 cell_size;
bf797471
JP
98};
99
1555d204
AS
100/**
101 * struct devlink_dpipe_field - dpipe field object
102 * @name: field name
103 * @id: index inside the headers field array
104 * @bitwidth: bitwidth
105 * @mapping_type: mapping type
106 */
107struct devlink_dpipe_field {
108 const char *name;
109 unsigned int id;
110 unsigned int bitwidth;
111 enum devlink_dpipe_field_mapping_type mapping_type;
112};
113
114/**
115 * struct devlink_dpipe_header - dpipe header object
116 * @name: header name
117 * @id: index, global/local detrmined by global bit
118 * @fields: fields
119 * @fields_count: number of fields
120 * @global: indicates if header is shared like most protocol header
121 * or driver specific
122 */
123struct devlink_dpipe_header {
124 const char *name;
125 unsigned int id;
126 struct devlink_dpipe_field *fields;
127 unsigned int fields_count;
128 bool global;
129};
130
131/**
132 * struct devlink_dpipe_match - represents match operation
133 * @type: type of match
134 * @header_index: header index (packets can have several headers of same
135 * type like in case of tunnels)
136 * @header: header
137 * @fieled_id: field index
138 */
139struct devlink_dpipe_match {
140 enum devlink_dpipe_match_type type;
141 unsigned int header_index;
142 struct devlink_dpipe_header *header;
143 unsigned int field_id;
144};
145
146/**
147 * struct devlink_dpipe_action - represents action operation
148 * @type: type of action
149 * @header_index: header index (packets can have several headers of same
150 * type like in case of tunnels)
151 * @header: header
152 * @fieled_id: field index
153 */
154struct devlink_dpipe_action {
155 enum devlink_dpipe_action_type type;
156 unsigned int header_index;
157 struct devlink_dpipe_header *header;
158 unsigned int field_id;
159};
160
161/**
162 * struct devlink_dpipe_value - represents value of match/action
163 * @action: action
164 * @match: match
165 * @mapping_value: in case the field has some mapping this value
166 * specified the mapping value
167 * @mapping_valid: specify if mapping value is valid
168 * @value_size: value size
169 * @value: value
170 * @mask: bit mask
171 */
172struct devlink_dpipe_value {
173 union {
174 struct devlink_dpipe_action *action;
175 struct devlink_dpipe_match *match;
176 };
177 unsigned int mapping_value;
178 bool mapping_valid;
179 unsigned int value_size;
180 void *value;
181 void *mask;
182};
183
184/**
185 * struct devlink_dpipe_entry - table entry object
186 * @index: index of the entry in the table
187 * @match_values: match values
188 * @matche_values_count: count of matches tuples
189 * @action_values: actions values
190 * @action_values_count: count of actions values
191 * @counter: value of counter
192 * @counter_valid: Specify if value is valid from hardware
193 */
194struct devlink_dpipe_entry {
195 u64 index;
196 struct devlink_dpipe_value *match_values;
197 unsigned int match_values_count;
198 struct devlink_dpipe_value *action_values;
199 unsigned int action_values_count;
200 u64 counter;
201 bool counter_valid;
202};
203
204/**
205 * struct devlink_dpipe_dump_ctx - context provided to driver in order
206 * to dump
207 * @info: info
208 * @cmd: devlink command
209 * @skb: skb
210 * @nest: top attribute
211 * @hdr: hdr
212 */
213struct devlink_dpipe_dump_ctx {
214 struct genl_info *info;
215 enum devlink_command cmd;
216 struct sk_buff *skb;
217 struct nlattr *nest;
218 void *hdr;
219};
220
221struct devlink_dpipe_table_ops;
222
223/**
224 * struct devlink_dpipe_table - table object
225 * @priv: private
226 * @name: table name
1555d204
AS
227 * @counters_enabled: indicates if counters are active
228 * @counter_control_extern: indicates if counter control is in dpipe or
229 * external tool
56dc7cd0
AS
230 * @resource_valid: Indicate that the resource id is valid
231 * @resource_id: relative resource this table is related to
232 * @resource_units: number of resource's unit consumed per table's entry
1555d204
AS
233 * @table_ops: table operations
234 * @rcu: rcu
235 */
236struct devlink_dpipe_table {
237 void *priv;
238 struct list_head list;
239 const char *name;
1555d204
AS
240 bool counters_enabled;
241 bool counter_control_extern;
56dc7cd0
AS
242 bool resource_valid;
243 u64 resource_id;
244 u64 resource_units;
1555d204
AS
245 struct devlink_dpipe_table_ops *table_ops;
246 struct rcu_head rcu;
247};
248
249/**
250 * struct devlink_dpipe_table_ops - dpipe_table ops
251 * @actions_dump - dumps all tables actions
252 * @matches_dump - dumps all tables matches
253 * @entries_dump - dumps all active entries in the table
254 * @counters_set_update - when changing the counter status hardware sync
255 * maybe needed to allocate/free counter related
256 * resources
ffd3cdcc 257 * @size_get - get size
1555d204
AS
258 */
259struct devlink_dpipe_table_ops {
260 int (*actions_dump)(void *priv, struct sk_buff *skb);
261 int (*matches_dump)(void *priv, struct sk_buff *skb);
262 int (*entries_dump)(void *priv, bool counters_enabled,
263 struct devlink_dpipe_dump_ctx *dump_ctx);
264 int (*counters_set_update)(void *priv, bool enable);
ffd3cdcc 265 u64 (*size_get)(void *priv);
1555d204
AS
266};
267
268/**
269 * struct devlink_dpipe_headers - dpipe headers
270 * @headers - header array can be shared (global bit) or driver specific
271 * @headers_count - count of headers
272 */
273struct devlink_dpipe_headers {
274 struct devlink_dpipe_header **headers;
275 unsigned int headers_count;
276};
277
d9f9b9a4
AS
278/**
279 * struct devlink_resource_size_params - resource's size parameters
280 * @size_min: minimum size which can be set
281 * @size_max: maximum size which can be set
282 * @size_granularity: size granularity
283 * @size_unit: resource's basic unit
284 */
285struct devlink_resource_size_params {
286 u64 size_min;
287 u64 size_max;
288 u64 size_granularity;
289 enum devlink_resource_unit unit;
290};
291
77d27096
JP
292static inline void
293devlink_resource_size_params_init(struct devlink_resource_size_params *size_params,
294 u64 size_min, u64 size_max,
295 u64 size_granularity,
296 enum devlink_resource_unit unit)
297{
298 size_params->size_min = size_min;
299 size_params->size_max = size_max;
300 size_params->size_granularity = size_granularity;
301 size_params->unit = unit;
302}
303
fc56be47
JP
304typedef u64 devlink_resource_occ_get_t(void *priv);
305
d9f9b9a4
AS
306/**
307 * struct devlink_resource - devlink resource
308 * @name: name of the resource
309 * @id: id, per devlink instance
310 * @size: size of the resource
311 * @size_new: updated size of the resource, reload is needed
312 * @size_valid: valid in case the total size of the resource is valid
313 * including its children
314 * @parent: parent resource
315 * @size_params: size parameters
316 * @list: parent list
317 * @resource_list: list of child resources
d9f9b9a4
AS
318 */
319struct devlink_resource {
320 const char *name;
321 u64 id;
322 u64 size;
323 u64 size_new;
324 bool size_valid;
325 struct devlink_resource *parent;
77d27096 326 struct devlink_resource_size_params size_params;
d9f9b9a4
AS
327 struct list_head list;
328 struct list_head resource_list;
fc56be47
JP
329 devlink_resource_occ_get_t *occ_get;
330 void *occ_get_priv;
d9f9b9a4
AS
331};
332
333#define DEVLINK_RESOURCE_ID_PARENT_TOP 0
334
bde74ad1 335#define __DEVLINK_PARAM_MAX_STRING_VALUE 32
eabaef18
MS
336enum devlink_param_type {
337 DEVLINK_PARAM_TYPE_U8,
338 DEVLINK_PARAM_TYPE_U16,
339 DEVLINK_PARAM_TYPE_U32,
340 DEVLINK_PARAM_TYPE_STRING,
341 DEVLINK_PARAM_TYPE_BOOL,
342};
343
344union devlink_param_value {
345 u8 vu8;
346 u16 vu16;
347 u32 vu32;
bde74ad1 348 char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE];
eabaef18
MS
349 bool vbool;
350};
351
352struct devlink_param_gset_ctx {
353 union devlink_param_value val;
354 enum devlink_param_cmode cmode;
355};
356
357/**
358 * struct devlink_param - devlink configuration parameter data
359 * @name: name of the parameter
360 * @generic: indicates if the parameter is generic or driver specific
361 * @type: parameter type
362 * @supported_cmodes: bitmap of supported configuration modes
363 * @get: get parameter value, used for runtime and permanent
364 * configuration modes
365 * @set: set parameter value, used for runtime and permanent
366 * configuration modes
e3b7ca18 367 * @validate: validate input value is applicable (within value range, etc.)
eabaef18
MS
368 *
369 * This struct should be used by the driver to fill the data for
370 * a parameter it registers.
371 */
372struct devlink_param {
373 u32 id;
374 const char *name;
375 bool generic;
376 enum devlink_param_type type;
377 unsigned long supported_cmodes;
378 int (*get)(struct devlink *devlink, u32 id,
379 struct devlink_param_gset_ctx *ctx);
380 int (*set)(struct devlink *devlink, u32 id,
381 struct devlink_param_gset_ctx *ctx);
e3b7ca18
MS
382 int (*validate)(struct devlink *devlink, u32 id,
383 union devlink_param_value val,
384 struct netlink_ext_ack *extack);
eabaef18
MS
385};
386
387struct devlink_param_item {
388 struct list_head list;
389 const struct devlink_param *param;
390 union devlink_param_value driverinit_value;
391 bool driverinit_value_valid;
7c62cfb8 392 bool published;
eabaef18
MS
393};
394
395enum devlink_param_generic_id {
036467c3
MS
396 DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
397 DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
f567bcda 398 DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
f6a69885 399 DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
e3b51061 400 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
f61cba42 401 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
16511789 402 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
846e980a 403 DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
5bbd21df 404 DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE,
6c7295e1 405 DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE,
eabaef18
MS
406
407 /* add new param generic ids above here*/
408 __DEVLINK_PARAM_GENERIC_ID_MAX,
409 DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1,
410};
411
036467c3
MS
412#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset"
413#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL
414
415#define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs"
416#define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32
417
f567bcda
VV
418#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov"
419#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL
420
f6a69885
AV
421#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
422#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
423
e3b51061
VV
424#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
425#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
426
f61cba42
VV
427#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
428#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
429
16511789
VV
430#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
431#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
432
846e980a
ST
433#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy"
434#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8
435
5bbd21df
DM
436#define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_NAME \
437 "reset_dev_on_drv_probe"
438#define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_TYPE DEVLINK_PARAM_TYPE_U8
439
6c7295e1
MG
440#define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME "enable_roce"
441#define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE DEVLINK_PARAM_TYPE_BOOL
442
036467c3
MS
443#define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
444{ \
445 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
446 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \
447 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \
448 .generic = true, \
449 .supported_cmodes = _cmodes, \
450 .get = _get, \
451 .set = _set, \
452 .validate = _validate, \
453}
454
455#define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \
456{ \
457 .id = _id, \
458 .name = _name, \
459 .type = _type, \
460 .supported_cmodes = _cmodes, \
461 .get = _get, \
462 .set = _set, \
463 .validate = _validate, \
464}
465
785bd550
JK
466/* Part number, identifier of board design */
467#define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
468/* Revision of board design */
469#define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
14fd1901
JK
470/* Maker of the board */
471#define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
785bd550 472
7d5aa9a5
SN
473/* Part number, identifier of asic design */
474#define DEVLINK_INFO_VERSION_GENERIC_ASIC_ID "asic.id"
475/* Revision of asic design */
476#define DEVLINK_INFO_VERSION_GENERIC_ASIC_REV "asic.rev"
477
478/* Overall FW version */
479#define DEVLINK_INFO_VERSION_GENERIC_FW "fw"
785bd550
JK
480/* Control processor FW version */
481#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"
482/* Data path microcode controlling high-speed packet processing */
483#define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app"
484/* UNDI software version */
485#define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi"
486/* NCSI support/handler version */
487#define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi"
468672b2
JK
488/* FW parameter set id */
489#define DEVLINK_INFO_VERSION_GENERIC_FW_PSID "fw.psid"
785bd550 490
b16ebe92 491struct devlink_region;
f9cf2288 492struct devlink_info_req;
b16ebe92 493
d7e52722
AV
494typedef void devlink_snapshot_data_dest_t(const void *data);
495
1db64e87 496struct devlink_fmsg;
a0bdcc59
EBE
497struct devlink_health_reporter;
498
3167b27a
EBE
499enum devlink_health_reporter_state {
500 DEVLINK_HEALTH_REPORTER_STATE_HEALTHY,
501 DEVLINK_HEALTH_REPORTER_STATE_ERROR,
502};
503
a0bdcc59
EBE
504/**
505 * struct devlink_health_reporter_ops - Reporter operations
506 * @name: reporter name
507 * @recover: callback to recover from reported error
508 * if priv_ctx is NULL, run a full recover
509 * @dump: callback to dump an object
510 * if priv_ctx is NULL, run a full dump
511 * @diagnose: callback to diagnose the current status
512 */
513
514struct devlink_health_reporter_ops {
515 char *name;
516 int (*recover)(struct devlink_health_reporter *reporter,
e7a98105 517 void *priv_ctx, struct netlink_ext_ack *extack);
a0bdcc59 518 int (*dump)(struct devlink_health_reporter *reporter,
e7a98105
JP
519 struct devlink_fmsg *fmsg, void *priv_ctx,
520 struct netlink_ext_ack *extack);
a0bdcc59 521 int (*diagnose)(struct devlink_health_reporter *reporter,
e7a98105
JP
522 struct devlink_fmsg *fmsg,
523 struct netlink_ext_ack *extack);
a0bdcc59 524};
1db64e87 525
0f420b6c
IS
526/**
527 * struct devlink_trap_group - Immutable packet trap group attributes.
528 * @name: Trap group name.
529 * @id: Trap group identifier.
530 * @generic: Whether the trap group is generic or not.
531 *
532 * Describes immutable attributes of packet trap groups that drivers register
533 * with devlink.
534 */
535struct devlink_trap_group {
536 const char *name;
537 u16 id;
538 bool generic;
539};
540
541#define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT BIT(0)
542
543/**
544 * struct devlink_trap - Immutable packet trap attributes.
545 * @type: Trap type.
546 * @init_action: Initial trap action.
547 * @generic: Whether the trap is generic or not.
548 * @id: Trap identifier.
549 * @name: Trap name.
550 * @group: Immutable packet trap group attributes.
551 * @metadata_cap: Metadata types that can be provided by the trap.
552 *
553 * Describes immutable attributes of packet traps that drivers register with
554 * devlink.
555 */
556struct devlink_trap {
557 enum devlink_trap_type type;
558 enum devlink_trap_action init_action;
559 bool generic;
560 u16 id;
561 const char *name;
562 struct devlink_trap_group group;
563 u32 metadata_cap;
564};
565
f3047ca0 566/* All traps must be documented in
f4bdd710 567 * Documentation/networking/devlink/devlink-trap.rst
f3047ca0 568 */
0f420b6c 569enum devlink_trap_generic_id {
391203ab
IS
570 DEVLINK_TRAP_GENERIC_ID_SMAC_MC,
571 DEVLINK_TRAP_GENERIC_ID_VLAN_TAG_MISMATCH,
572 DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER,
573 DEVLINK_TRAP_GENERIC_ID_INGRESS_STP_FILTER,
574 DEVLINK_TRAP_GENERIC_ID_EMPTY_TX_LIST,
575 DEVLINK_TRAP_GENERIC_ID_PORT_LOOPBACK_FILTER,
576 DEVLINK_TRAP_GENERIC_ID_BLACKHOLE_ROUTE,
577 DEVLINK_TRAP_GENERIC_ID_TTL_ERROR,
578 DEVLINK_TRAP_GENERIC_ID_TAIL_DROP,
6896cc4d
AC
579 DEVLINK_TRAP_GENERIC_ID_NON_IP_PACKET,
580 DEVLINK_TRAP_GENERIC_ID_UC_DIP_MC_DMAC,
581 DEVLINK_TRAP_GENERIC_ID_DIP_LB,
582 DEVLINK_TRAP_GENERIC_ID_SIP_MC,
583 DEVLINK_TRAP_GENERIC_ID_SIP_LB,
584 DEVLINK_TRAP_GENERIC_ID_CORRUPTED_IP_HDR,
585 DEVLINK_TRAP_GENERIC_ID_IPV4_SIP_BC,
586 DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_RESERVED_SCOPE,
587 DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE,
3b063ae5
AC
588 DEVLINK_TRAP_GENERIC_ID_MTU_ERROR,
589 DEVLINK_TRAP_GENERIC_ID_UNRESOLVED_NEIGH,
590 DEVLINK_TRAP_GENERIC_ID_RPF,
591 DEVLINK_TRAP_GENERIC_ID_REJECT_ROUTE,
592 DEVLINK_TRAP_GENERIC_ID_IPV4_LPM_UNICAST_MISS,
593 DEVLINK_TRAP_GENERIC_ID_IPV6_LPM_UNICAST_MISS,
391203ab 594
0f420b6c
IS
595 /* Add new generic trap IDs above */
596 __DEVLINK_TRAP_GENERIC_ID_MAX,
597 DEVLINK_TRAP_GENERIC_ID_MAX = __DEVLINK_TRAP_GENERIC_ID_MAX - 1,
598};
599
f3047ca0 600/* All trap groups must be documented in
f4bdd710 601 * Documentation/networking/devlink/devlink-trap.rst
f3047ca0 602 */
0f420b6c 603enum devlink_trap_group_generic_id {
391203ab
IS
604 DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS,
605 DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS,
606 DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS,
607
0f420b6c
IS
608 /* Add new generic trap group IDs above */
609 __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX,
610 DEVLINK_TRAP_GROUP_GENERIC_ID_MAX =
611 __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX - 1,
612};
613
391203ab
IS
614#define DEVLINK_TRAP_GENERIC_NAME_SMAC_MC \
615 "source_mac_is_multicast"
616#define DEVLINK_TRAP_GENERIC_NAME_VLAN_TAG_MISMATCH \
617 "vlan_tag_mismatch"
618#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_VLAN_FILTER \
619 "ingress_vlan_filter"
620#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_STP_FILTER \
621 "ingress_spanning_tree_filter"
622#define DEVLINK_TRAP_GENERIC_NAME_EMPTY_TX_LIST \
623 "port_list_is_empty"
624#define DEVLINK_TRAP_GENERIC_NAME_PORT_LOOPBACK_FILTER \
625 "port_loopback_filter"
626#define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_ROUTE \
627 "blackhole_route"
628#define DEVLINK_TRAP_GENERIC_NAME_TTL_ERROR \
629 "ttl_value_is_too_small"
630#define DEVLINK_TRAP_GENERIC_NAME_TAIL_DROP \
631 "tail_drop"
6896cc4d
AC
632#define DEVLINK_TRAP_GENERIC_NAME_NON_IP_PACKET \
633 "non_ip"
634#define DEVLINK_TRAP_GENERIC_NAME_UC_DIP_MC_DMAC \
635 "uc_dip_over_mc_dmac"
636#define DEVLINK_TRAP_GENERIC_NAME_DIP_LB \
637 "dip_is_loopback_address"
638#define DEVLINK_TRAP_GENERIC_NAME_SIP_MC \
639 "sip_is_mc"
640#define DEVLINK_TRAP_GENERIC_NAME_SIP_LB \
641 "sip_is_loopback_address"
642#define DEVLINK_TRAP_GENERIC_NAME_CORRUPTED_IP_HDR \
643 "ip_header_corrupted"
644#define DEVLINK_TRAP_GENERIC_NAME_IPV4_SIP_BC \
645 "ipv4_sip_is_limited_bc"
646#define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_RESERVED_SCOPE \
647 "ipv6_mc_dip_reserved_scope"
648#define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE \
649 "ipv6_mc_dip_interface_local_scope"
3b063ae5
AC
650#define DEVLINK_TRAP_GENERIC_NAME_MTU_ERROR \
651 "mtu_value_is_too_small"
652#define DEVLINK_TRAP_GENERIC_NAME_UNRESOLVED_NEIGH \
653 "unresolved_neigh"
654#define DEVLINK_TRAP_GENERIC_NAME_RPF \
655 "mc_reverse_path_forwarding"
656#define DEVLINK_TRAP_GENERIC_NAME_REJECT_ROUTE \
657 "reject_route"
658#define DEVLINK_TRAP_GENERIC_NAME_IPV4_LPM_UNICAST_MISS \
659 "ipv4_lpm_miss"
660#define DEVLINK_TRAP_GENERIC_NAME_IPV6_LPM_UNICAST_MISS \
661 "ipv6_lpm_miss"
391203ab
IS
662
663#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \
664 "l2_drops"
665#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS \
666 "l3_drops"
667#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS \
668 "buffer_drops"
669
0f420b6c
IS
670#define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group, _metadata_cap) \
671 { \
672 .type = DEVLINK_TRAP_TYPE_##_type, \
673 .init_action = DEVLINK_TRAP_ACTION_##_init_action, \
674 .generic = true, \
675 .id = DEVLINK_TRAP_GENERIC_ID_##_id, \
676 .name = DEVLINK_TRAP_GENERIC_NAME_##_id, \
677 .group = _group, \
678 .metadata_cap = _metadata_cap, \
679 }
680
681#define DEVLINK_TRAP_DRIVER(_type, _init_action, _id, _name, _group, \
682 _metadata_cap) \
683 { \
684 .type = DEVLINK_TRAP_TYPE_##_type, \
685 .init_action = DEVLINK_TRAP_ACTION_##_init_action, \
686 .generic = false, \
687 .id = _id, \
688 .name = _name, \
689 .group = _group, \
690 .metadata_cap = _metadata_cap, \
691 }
692
693#define DEVLINK_TRAP_GROUP_GENERIC(_id) \
694 { \
695 .name = DEVLINK_TRAP_GROUP_GENERIC_NAME_##_id, \
696 .id = DEVLINK_TRAP_GROUP_GENERIC_ID_##_id, \
697 .generic = true, \
698 }
699
bfcd3a46 700struct devlink_ops {
070c63f2 701 int (*reload_down)(struct devlink *devlink, bool netns_change,
97691069
JP
702 struct netlink_ext_ack *extack);
703 int (*reload_up)(struct devlink *devlink,
704 struct netlink_ext_ack *extack);
bfcd3a46
JP
705 int (*port_type_set)(struct devlink_port *devlink_port,
706 enum devlink_port_type port_type);
707 int (*port_split)(struct devlink *devlink, unsigned int port_index,
ac0fc8a1
DA
708 unsigned int count, struct netlink_ext_ack *extack);
709 int (*port_unsplit)(struct devlink *devlink, unsigned int port_index,
710 struct netlink_ext_ack *extack);
bf797471
JP
711 int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index,
712 u16 pool_index,
713 struct devlink_sb_pool_info *pool_info);
714 int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index,
715 u16 pool_index, u32 size,
f2ad1a52
IS
716 enum devlink_sb_threshold_type threshold_type,
717 struct netlink_ext_ack *extack);
bf797471
JP
718 int (*sb_port_pool_get)(struct devlink_port *devlink_port,
719 unsigned int sb_index, u16 pool_index,
720 u32 *p_threshold);
721 int (*sb_port_pool_set)(struct devlink_port *devlink_port,
722 unsigned int sb_index, u16 pool_index,
f2ad1a52 723 u32 threshold, struct netlink_ext_ack *extack);
bf797471
JP
724 int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port,
725 unsigned int sb_index,
726 u16 tc_index,
727 enum devlink_sb_pool_type pool_type,
728 u16 *p_pool_index, u32 *p_threshold);
729 int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port,
730 unsigned int sb_index,
731 u16 tc_index,
732 enum devlink_sb_pool_type pool_type,
f2ad1a52
IS
733 u16 pool_index, u32 threshold,
734 struct netlink_ext_ack *extack);
df38dafd
JP
735 int (*sb_occ_snapshot)(struct devlink *devlink,
736 unsigned int sb_index);
737 int (*sb_occ_max_clear)(struct devlink *devlink,
738 unsigned int sb_index);
739 int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port,
740 unsigned int sb_index, u16 pool_index,
741 u32 *p_cur, u32 *p_max);
742 int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port,
743 unsigned int sb_index,
744 u16 tc_index,
745 enum devlink_sb_pool_type pool_type,
746 u32 *p_cur, u32 *p_max);
08f4b591
OG
747
748 int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode);
db7ff19e
EB
749 int (*eswitch_mode_set)(struct devlink *devlink, u16 mode,
750 struct netlink_ext_ack *extack);
59bfde01 751 int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
db7ff19e
EB
752 int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode,
753 struct netlink_ext_ack *extack);
98fdbea5
LR
754 int (*eswitch_encap_mode_get)(struct devlink *devlink,
755 enum devlink_eswitch_encap_mode *p_encap_mode);
756 int (*eswitch_encap_mode_set)(struct devlink *devlink,
757 enum devlink_eswitch_encap_mode encap_mode,
db7ff19e 758 struct netlink_ext_ack *extack);
f9cf2288
JK
759 int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
760 struct netlink_ext_ack *extack);
76726ccb
JK
761 int (*flash_update)(struct devlink *devlink, const char *file_name,
762 const char *component,
763 struct netlink_ext_ack *extack);
0f420b6c
IS
764 /**
765 * @trap_init: Trap initialization function.
766 *
767 * Should be used by device drivers to initialize the trap in the
768 * underlying device. Drivers should also store the provided trap
769 * context, so that they could efficiently pass it to
770 * devlink_trap_report() when the trap is triggered.
771 */
772 int (*trap_init)(struct devlink *devlink,
773 const struct devlink_trap *trap, void *trap_ctx);
774 /**
775 * @trap_fini: Trap de-initialization function.
776 *
777 * Should be used by device drivers to de-initialize the trap in the
778 * underlying device.
779 */
780 void (*trap_fini)(struct devlink *devlink,
781 const struct devlink_trap *trap, void *trap_ctx);
782 /**
783 * @trap_action_set: Trap action set function.
784 */
785 int (*trap_action_set)(struct devlink *devlink,
786 const struct devlink_trap *trap,
787 enum devlink_trap_action action);
788 /**
789 * @trap_group_init: Trap group initialization function.
790 *
791 * Should be used by device drivers to initialize the trap group in the
792 * underlying device.
793 */
794 int (*trap_group_init)(struct devlink *devlink,
795 const struct devlink_trap_group *group);
bfcd3a46
JP
796};
797
798static inline void *devlink_priv(struct devlink *devlink)
799{
800 BUG_ON(!devlink);
801 return &devlink->priv;
802}
803
804static inline struct devlink *priv_to_devlink(void *priv)
805{
806 BUG_ON(!priv);
807 return container_of(priv, struct devlink, priv);
808}
809
5dc37bb9
JP
810static inline struct devlink_port *
811netdev_to_devlink_port(struct net_device *dev)
812{
813 if (dev->netdev_ops->ndo_get_devlink_port)
814 return dev->netdev_ops->ndo_get_devlink_port(dev);
815 return NULL;
816}
817
b473b0d2
JK
818static inline struct devlink *netdev_to_devlink(struct net_device *dev)
819{
5dc37bb9
JP
820 struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
821
822 if (devlink_port)
823 return devlink_port->devlink;
b473b0d2
JK
824 return NULL;
825}
826
bfcd3a46
JP
827struct ib_device;
828
471f894f 829struct net *devlink_net(const struct devlink *devlink);
8273fd84 830void devlink_net_set(struct devlink *devlink, struct net *net);
bfcd3a46
JP
831struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
832int devlink_register(struct devlink *devlink, struct device *dev);
833void devlink_unregister(struct devlink *devlink);
a0c76345
JP
834void devlink_reload_enable(struct devlink *devlink);
835void devlink_reload_disable(struct devlink *devlink);
bfcd3a46
JP
836void devlink_free(struct devlink *devlink);
837int devlink_port_register(struct devlink *devlink,
838 struct devlink_port *devlink_port,
839 unsigned int port_index);
840void devlink_port_unregister(struct devlink_port *devlink_port);
841void devlink_port_type_eth_set(struct devlink_port *devlink_port,
842 struct net_device *netdev);
843void devlink_port_type_ib_set(struct devlink_port *devlink_port,
844 struct ib_device *ibdev);
845void devlink_port_type_clear(struct devlink_port *devlink_port);
b9ffcbaf 846void devlink_port_attrs_set(struct devlink_port *devlink_port,
5ec1380a 847 enum devlink_port_flavour flavour,
b9ffcbaf 848 u32 port_number, bool split,
bec5267c
JP
849 u32 split_subport_number,
850 const unsigned char *switch_id,
851 unsigned char switch_id_len);
98fd2d65
PP
852void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port,
853 const unsigned char *switch_id,
854 unsigned char switch_id_len, u16 pf);
e41b6bf3
PP
855void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port,
856 const unsigned char *switch_id,
857 unsigned char switch_id_len,
858 u16 pf, u16 vf);
bf797471
JP
859int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
860 u32 size, u16 ingress_pools_count,
861 u16 egress_pools_count, u16 ingress_tc_count,
862 u16 egress_tc_count);
863void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
1555d204
AS
864int devlink_dpipe_table_register(struct devlink *devlink,
865 const char *table_name,
866 struct devlink_dpipe_table_ops *table_ops,
ffd3cdcc 867 void *priv, bool counter_control_extern);
1555d204
AS
868void devlink_dpipe_table_unregister(struct devlink *devlink,
869 const char *table_name);
870int devlink_dpipe_headers_register(struct devlink *devlink,
871 struct devlink_dpipe_headers *dpipe_headers);
872void devlink_dpipe_headers_unregister(struct devlink *devlink);
873bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
874 const char *table_name);
875int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
876int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
877 struct devlink_dpipe_entry *entry);
878int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
35807324 879void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
1555d204
AS
880int devlink_dpipe_action_put(struct sk_buff *skb,
881 struct devlink_dpipe_action *action);
882int devlink_dpipe_match_put(struct sk_buff *skb,
883 struct devlink_dpipe_match *match);
11770091 884extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
3fb886ec 885extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
1797f5b3 886extern struct devlink_dpipe_header devlink_dpipe_header_ipv6;
bfcd3a46 887
d9f9b9a4
AS
888int devlink_resource_register(struct devlink *devlink,
889 const char *resource_name,
d9f9b9a4
AS
890 u64 resource_size,
891 u64 resource_id,
892 u64 parent_resource_id,
fc56be47 893 const struct devlink_resource_size_params *size_params);
d9f9b9a4
AS
894void devlink_resources_unregister(struct devlink *devlink,
895 struct devlink_resource *resource);
896int devlink_resource_size_get(struct devlink *devlink,
897 u64 resource_id,
898 u64 *p_resource_size);
56dc7cd0
AS
899int devlink_dpipe_table_resource_set(struct devlink *devlink,
900 const char *table_name, u64 resource_id,
901 u64 resource_units);
fc56be47
JP
902void devlink_resource_occ_get_register(struct devlink *devlink,
903 u64 resource_id,
904 devlink_resource_occ_get_t *occ_get,
905 void *occ_get_priv);
906void devlink_resource_occ_get_unregister(struct devlink *devlink,
907 u64 resource_id);
eabaef18
MS
908int devlink_params_register(struct devlink *devlink,
909 const struct devlink_param *params,
910 size_t params_count);
911void devlink_params_unregister(struct devlink *devlink,
912 const struct devlink_param *params,
913 size_t params_count);
7c62cfb8
JP
914void devlink_params_publish(struct devlink *devlink);
915void devlink_params_unpublish(struct devlink *devlink);
39e6160e
VV
916int devlink_port_params_register(struct devlink_port *devlink_port,
917 const struct devlink_param *params,
918 size_t params_count);
919void devlink_port_params_unregister(struct devlink_port *devlink_port,
920 const struct devlink_param *params,
921 size_t params_count);
ec01aeb1
MS
922int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
923 union devlink_param_value *init_val);
924int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
925 union devlink_param_value init_val);
ffd19b9a
VV
926int
927devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
928 u32 param_id,
929 union devlink_param_value *init_val);
5473a7bd
VV
930int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
931 u32 param_id,
932 union devlink_param_value init_val);
ea601e17 933void devlink_param_value_changed(struct devlink *devlink, u32 param_id);
c1e5786d
VV
934void devlink_port_param_value_changed(struct devlink_port *devlink_port,
935 u32 param_id);
bde74ad1
MS
936void devlink_param_value_str_fill(union devlink_param_value *dst_val,
937 const char *src);
b16ebe92
AV
938struct devlink_region *devlink_region_create(struct devlink *devlink,
939 const char *region_name,
940 u32 region_max_snapshots,
941 u64 region_size);
942void devlink_region_destroy(struct devlink_region *region);
ccadfa44 943u32 devlink_region_shapshot_id_get(struct devlink *devlink);
3a5e5234 944int devlink_region_snapshot_create(struct devlink_region *region,
d7e52722
AV
945 u8 *data, u32 snapshot_id,
946 devlink_snapshot_data_dest_t *data_destructor);
f9cf2288
JK
947int devlink_info_serial_number_put(struct devlink_info_req *req,
948 const char *sn);
949int devlink_info_driver_name_put(struct devlink_info_req *req,
950 const char *name);
fc6fae7d
JK
951int devlink_info_version_fixed_put(struct devlink_info_req *req,
952 const char *version_name,
953 const char *version_value);
954int devlink_info_version_stored_put(struct devlink_info_req *req,
955 const char *version_name,
956 const char *version_value);
957int devlink_info_version_running_put(struct devlink_info_req *req,
958 const char *version_name,
959 const char *version_value);
d9f9b9a4 960
1db64e87
EBE
961int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
962int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);
963
964int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
965int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);
966
967int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
968 const char *name);
969int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
970
971int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value);
972int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value);
973int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
974int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value);
975int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
1db64e87
EBE
976
977int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
978 bool value);
979int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
980 u8 value);
981int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
982 u32 value);
983int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
984 u64 value);
985int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
986 const char *value);
987int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
e2cde864 988 const void *value, u32 value_len);
1db64e87 989
a0bdcc59
EBE
990struct devlink_health_reporter *
991devlink_health_reporter_create(struct devlink *devlink,
992 const struct devlink_health_reporter_ops *ops,
993 u64 graceful_period, bool auto_recover,
994 void *priv);
995void
996devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);
997
998void *
999devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
c8e1da0b
EBE
1000int devlink_health_report(struct devlink_health_reporter *reporter,
1001 const char *msg, void *priv_ctx);
3167b27a
EBE
1002void
1003devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
1004 enum devlink_health_reporter_state state);
6181e5cb
VG
1005void
1006devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter);
a0bdcc59 1007
2670ac26
JP
1008bool devlink_is_reload_failed(const struct devlink *devlink);
1009
191ed202
JP
1010void devlink_flash_update_begin_notify(struct devlink *devlink);
1011void devlink_flash_update_end_notify(struct devlink *devlink);
1012void devlink_flash_update_status_notify(struct devlink *devlink,
1013 const char *status_msg,
1014 const char *component,
1015 unsigned long done,
1016 unsigned long total);
1017
0f420b6c
IS
1018int devlink_traps_register(struct devlink *devlink,
1019 const struct devlink_trap *traps,
1020 size_t traps_count, void *priv);
1021void devlink_traps_unregister(struct devlink *devlink,
1022 const struct devlink_trap *traps,
1023 size_t traps_count);
1024void devlink_trap_report(struct devlink *devlink,
1025 struct sk_buff *skb, void *trap_ctx,
1026 struct devlink_port *in_devlink_port);
1027void *devlink_trap_ctx_priv(void *trap_ctx);
1028
f6b19b35
JP
1029#if IS_ENABLED(CONFIG_NET_DEVLINK)
1030
f4b6bcc7
JK
1031void devlink_compat_running_version(struct net_device *dev,
1032 char *buf, size_t len);
1033int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
af3836df
JP
1034int devlink_compat_phys_port_name_get(struct net_device *dev,
1035 char *name, size_t len);
7e1146e8
JP
1036int devlink_compat_switch_id_get(struct net_device *dev,
1037 struct netdev_phys_item_id *ppid);
f4b6bcc7 1038
bfcd3a46
JP
1039#else
1040
ddb6e99e
JK
1041static inline void
1042devlink_compat_running_version(struct net_device *dev, char *buf, size_t len)
1043{
1044}
4eceba17
JK
1045
1046static inline int
1047devlink_compat_flash_update(struct net_device *dev, const char *file_name)
1048{
1049 return -EOPNOTSUPP;
1050}
f6b19b35 1051
af3836df
JP
1052static inline int
1053devlink_compat_phys_port_name_get(struct net_device *dev,
1054 char *name, size_t len)
1055{
1056 return -EOPNOTSUPP;
1057}
1058
7e1146e8
JP
1059static inline int
1060devlink_compat_switch_id_get(struct net_device *dev,
1061 struct netdev_phys_item_id *ppid)
1062{
1063 return -EOPNOTSUPP;
1064}
1065
ddb6e99e
JK
1066#endif
1067
bfcd3a46 1068#endif /* _NET_DEVLINK_H_ */