Commit | Line | Data |
---|---|---|
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 | 18 | #include <net/net_namespace.h> |
5a2e106c | 19 | #include <net/flow_offload.h> |
bfcd3a46 | 20 | #include <uapi/linux/devlink.h> |
12102436 | 21 | #include <linux/xarray.h> |
bfcd3a46 JP |
22 | |
23 | struct devlink_ops; | |
24 | ||
25 | struct devlink { | |
26 | struct list_head list; | |
27 | struct list_head port_list; | |
bf797471 | 28 | struct list_head sb_list; |
1555d204 | 29 | struct list_head dpipe_table_list; |
d9f9b9a4 | 30 | struct list_head resource_list; |
eabaef18 | 31 | struct list_head param_list; |
b16ebe92 | 32 | struct list_head region_list; |
a0bdcc59 | 33 | struct list_head reporter_list; |
b587bdaf | 34 | struct mutex reporters_lock; /* protects reporter_list */ |
1555d204 | 35 | struct devlink_dpipe_headers *dpipe_headers; |
0f420b6c IS |
36 | struct list_head trap_list; |
37 | struct list_head trap_group_list; | |
1e8c6619 | 38 | struct list_head trap_policer_list; |
bfcd3a46 | 39 | const struct devlink_ops *ops; |
12102436 | 40 | struct xarray snapshot_ids; |
bfcd3a46 JP |
41 | struct device *dev; |
42 | possible_net_t _net; | |
336ce1c9 PP |
43 | struct mutex lock; /* Serializes access to devlink instance specific objects such as |
44 | * port, sb, dpipe, resource, params, region, traps and more. | |
45 | */ | |
a0c76345 JP |
46 | u8 reload_failed:1, |
47 | reload_enabled:1, | |
48 | registered:1; | |
bfcd3a46 JP |
49 | char priv[0] __aligned(NETDEV_ALIGN); |
50 | }; | |
51 | ||
378ef01b PP |
52 | struct devlink_port_phys_attrs { |
53 | u32 port_number; /* Same value as "split group". | |
54 | * A physical port which is visible to the user | |
55 | * for a given port flavour. | |
56 | */ | |
71ad8d55 | 57 | u32 split_subport_number; /* If the port is split, this is the number of subport. */ |
378ef01b PP |
58 | }; |
59 | ||
ff03e63a PP |
60 | /** |
61 | * struct devlink_port_pci_pf_attrs - devlink port's PCI PF attributes | |
3a2d9588 | 62 | * @controller: Associated controller number |
ff03e63a | 63 | * @pf: Associated PCI PF number for this port. |
05b595e9 | 64 | * @external: when set, indicates if a port is for an external controller |
ff03e63a | 65 | */ |
98fd2d65 | 66 | struct devlink_port_pci_pf_attrs { |
3a2d9588 | 67 | u32 controller; |
ff03e63a | 68 | u16 pf; |
05b595e9 | 69 | u8 external:1; |
98fd2d65 PP |
70 | }; |
71 | ||
ff03e63a PP |
72 | /** |
73 | * struct devlink_port_pci_vf_attrs - devlink port's PCI VF attributes | |
3a2d9588 | 74 | * @controller: Associated controller number |
ff03e63a PP |
75 | * @pf: Associated PCI PF number for this port. |
76 | * @vf: Associated PCI VF for of the PCI PF for this port. | |
05b595e9 | 77 | * @external: when set, indicates if a port is for an external controller |
ff03e63a | 78 | */ |
e41b6bf3 | 79 | struct devlink_port_pci_vf_attrs { |
3a2d9588 | 80 | u32 controller; |
ff03e63a PP |
81 | u16 pf; |
82 | u16 vf; | |
05b595e9 | 83 | u8 external:1; |
e41b6bf3 PP |
84 | }; |
85 | ||
71ad8d55 DR |
86 | /** |
87 | * struct devlink_port_attrs - devlink port object | |
88 | * @flavour: flavour of the port | |
89 | * @split: indicates if this is split port | |
a0f49b54 | 90 | * @splittable: indicates if the port can be split. |
a21cf0a8 | 91 | * @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink. |
71ad8d55 | 92 | * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL |
2efbe6ae PP |
93 | * @phys: physical port attributes |
94 | * @pci_pf: PCI PF port attributes | |
95 | * @pci_vf: PCI VF port attributes | |
71ad8d55 | 96 | */ |
b9ffcbaf | 97 | struct devlink_port_attrs { |
a0f49b54 DR |
98 | u8 split:1, |
99 | splittable:1; | |
a21cf0a8 | 100 | u32 lanes; |
5ec1380a | 101 | enum devlink_port_flavour flavour; |
bec5267c | 102 | struct netdev_phys_item_id switch_id; |
378ef01b PP |
103 | union { |
104 | struct devlink_port_phys_attrs phys; | |
98fd2d65 | 105 | struct devlink_port_pci_pf_attrs pci_pf; |
e41b6bf3 | 106 | struct devlink_port_pci_vf_attrs pci_vf; |
378ef01b | 107 | }; |
b9ffcbaf JP |
108 | }; |
109 | ||
bfcd3a46 JP |
110 | struct devlink_port { |
111 | struct list_head list; | |
39e6160e | 112 | struct list_head param_list; |
bfcd3a46 | 113 | struct devlink *devlink; |
c7282b50 | 114 | unsigned int index; |
bfcd3a46 | 115 | bool registered; |
b8f97554 JP |
116 | spinlock_t type_lock; /* Protects type and type_dev |
117 | * pointer consistency. | |
118 | */ | |
bfcd3a46 JP |
119 | enum devlink_port_type type; |
120 | enum devlink_port_type desired_type; | |
121 | void *type_dev; | |
b9ffcbaf | 122 | struct devlink_port_attrs attrs; |
46737a19 DR |
123 | u8 attrs_set:1, |
124 | switch_port:1; | |
136bf27f | 125 | struct delayed_work type_warn_dw; |
f4f54166 VT |
126 | struct list_head reporter_list; |
127 | struct mutex reporters_lock; /* Protects reporter_list */ | |
bfcd3a46 JP |
128 | }; |
129 | ||
bf797471 JP |
130 | struct devlink_sb_pool_info { |
131 | enum devlink_sb_pool_type pool_type; | |
132 | u32 size; | |
133 | enum devlink_sb_threshold_type threshold_type; | |
bff5731d | 134 | u32 cell_size; |
bf797471 JP |
135 | }; |
136 | ||
1555d204 AS |
137 | /** |
138 | * struct devlink_dpipe_field - dpipe field object | |
139 | * @name: field name | |
140 | * @id: index inside the headers field array | |
141 | * @bitwidth: bitwidth | |
142 | * @mapping_type: mapping type | |
143 | */ | |
144 | struct devlink_dpipe_field { | |
145 | const char *name; | |
146 | unsigned int id; | |
147 | unsigned int bitwidth; | |
148 | enum devlink_dpipe_field_mapping_type mapping_type; | |
149 | }; | |
150 | ||
151 | /** | |
152 | * struct devlink_dpipe_header - dpipe header object | |
153 | * @name: header name | |
154 | * @id: index, global/local detrmined by global bit | |
155 | * @fields: fields | |
156 | * @fields_count: number of fields | |
157 | * @global: indicates if header is shared like most protocol header | |
158 | * or driver specific | |
159 | */ | |
160 | struct devlink_dpipe_header { | |
161 | const char *name; | |
162 | unsigned int id; | |
163 | struct devlink_dpipe_field *fields; | |
164 | unsigned int fields_count; | |
165 | bool global; | |
166 | }; | |
167 | ||
168 | /** | |
169 | * struct devlink_dpipe_match - represents match operation | |
170 | * @type: type of match | |
171 | * @header_index: header index (packets can have several headers of same | |
172 | * type like in case of tunnels) | |
173 | * @header: header | |
174 | * @fieled_id: field index | |
175 | */ | |
176 | struct devlink_dpipe_match { | |
177 | enum devlink_dpipe_match_type type; | |
178 | unsigned int header_index; | |
179 | struct devlink_dpipe_header *header; | |
180 | unsigned int field_id; | |
181 | }; | |
182 | ||
183 | /** | |
184 | * struct devlink_dpipe_action - represents action operation | |
185 | * @type: type of action | |
186 | * @header_index: header index (packets can have several headers of same | |
187 | * type like in case of tunnels) | |
188 | * @header: header | |
189 | * @fieled_id: field index | |
190 | */ | |
191 | struct devlink_dpipe_action { | |
192 | enum devlink_dpipe_action_type type; | |
193 | unsigned int header_index; | |
194 | struct devlink_dpipe_header *header; | |
195 | unsigned int field_id; | |
196 | }; | |
197 | ||
198 | /** | |
199 | * struct devlink_dpipe_value - represents value of match/action | |
200 | * @action: action | |
201 | * @match: match | |
202 | * @mapping_value: in case the field has some mapping this value | |
203 | * specified the mapping value | |
204 | * @mapping_valid: specify if mapping value is valid | |
205 | * @value_size: value size | |
206 | * @value: value | |
207 | * @mask: bit mask | |
208 | */ | |
209 | struct devlink_dpipe_value { | |
210 | union { | |
211 | struct devlink_dpipe_action *action; | |
212 | struct devlink_dpipe_match *match; | |
213 | }; | |
214 | unsigned int mapping_value; | |
215 | bool mapping_valid; | |
216 | unsigned int value_size; | |
217 | void *value; | |
218 | void *mask; | |
219 | }; | |
220 | ||
221 | /** | |
222 | * struct devlink_dpipe_entry - table entry object | |
223 | * @index: index of the entry in the table | |
224 | * @match_values: match values | |
225 | * @matche_values_count: count of matches tuples | |
226 | * @action_values: actions values | |
227 | * @action_values_count: count of actions values | |
228 | * @counter: value of counter | |
229 | * @counter_valid: Specify if value is valid from hardware | |
230 | */ | |
231 | struct devlink_dpipe_entry { | |
232 | u64 index; | |
233 | struct devlink_dpipe_value *match_values; | |
234 | unsigned int match_values_count; | |
235 | struct devlink_dpipe_value *action_values; | |
236 | unsigned int action_values_count; | |
237 | u64 counter; | |
238 | bool counter_valid; | |
239 | }; | |
240 | ||
241 | /** | |
242 | * struct devlink_dpipe_dump_ctx - context provided to driver in order | |
243 | * to dump | |
244 | * @info: info | |
245 | * @cmd: devlink command | |
246 | * @skb: skb | |
247 | * @nest: top attribute | |
248 | * @hdr: hdr | |
249 | */ | |
250 | struct devlink_dpipe_dump_ctx { | |
251 | struct genl_info *info; | |
252 | enum devlink_command cmd; | |
253 | struct sk_buff *skb; | |
254 | struct nlattr *nest; | |
255 | void *hdr; | |
256 | }; | |
257 | ||
258 | struct devlink_dpipe_table_ops; | |
259 | ||
260 | /** | |
261 | * struct devlink_dpipe_table - table object | |
262 | * @priv: private | |
263 | * @name: table name | |
1555d204 AS |
264 | * @counters_enabled: indicates if counters are active |
265 | * @counter_control_extern: indicates if counter control is in dpipe or | |
266 | * external tool | |
56dc7cd0 AS |
267 | * @resource_valid: Indicate that the resource id is valid |
268 | * @resource_id: relative resource this table is related to | |
269 | * @resource_units: number of resource's unit consumed per table's entry | |
1555d204 AS |
270 | * @table_ops: table operations |
271 | * @rcu: rcu | |
272 | */ | |
273 | struct devlink_dpipe_table { | |
274 | void *priv; | |
275 | struct list_head list; | |
276 | const char *name; | |
1555d204 AS |
277 | bool counters_enabled; |
278 | bool counter_control_extern; | |
56dc7cd0 AS |
279 | bool resource_valid; |
280 | u64 resource_id; | |
281 | u64 resource_units; | |
1555d204 AS |
282 | struct devlink_dpipe_table_ops *table_ops; |
283 | struct rcu_head rcu; | |
284 | }; | |
285 | ||
286 | /** | |
287 | * struct devlink_dpipe_table_ops - dpipe_table ops | |
288 | * @actions_dump - dumps all tables actions | |
289 | * @matches_dump - dumps all tables matches | |
290 | * @entries_dump - dumps all active entries in the table | |
291 | * @counters_set_update - when changing the counter status hardware sync | |
292 | * maybe needed to allocate/free counter related | |
293 | * resources | |
ffd3cdcc | 294 | * @size_get - get size |
1555d204 AS |
295 | */ |
296 | struct devlink_dpipe_table_ops { | |
297 | int (*actions_dump)(void *priv, struct sk_buff *skb); | |
298 | int (*matches_dump)(void *priv, struct sk_buff *skb); | |
299 | int (*entries_dump)(void *priv, bool counters_enabled, | |
300 | struct devlink_dpipe_dump_ctx *dump_ctx); | |
301 | int (*counters_set_update)(void *priv, bool enable); | |
ffd3cdcc | 302 | u64 (*size_get)(void *priv); |
1555d204 AS |
303 | }; |
304 | ||
305 | /** | |
306 | * struct devlink_dpipe_headers - dpipe headers | |
307 | * @headers - header array can be shared (global bit) or driver specific | |
308 | * @headers_count - count of headers | |
309 | */ | |
310 | struct devlink_dpipe_headers { | |
311 | struct devlink_dpipe_header **headers; | |
312 | unsigned int headers_count; | |
313 | }; | |
314 | ||
d9f9b9a4 AS |
315 | /** |
316 | * struct devlink_resource_size_params - resource's size parameters | |
317 | * @size_min: minimum size which can be set | |
318 | * @size_max: maximum size which can be set | |
319 | * @size_granularity: size granularity | |
320 | * @size_unit: resource's basic unit | |
321 | */ | |
322 | struct devlink_resource_size_params { | |
323 | u64 size_min; | |
324 | u64 size_max; | |
325 | u64 size_granularity; | |
326 | enum devlink_resource_unit unit; | |
327 | }; | |
328 | ||
77d27096 JP |
329 | static inline void |
330 | devlink_resource_size_params_init(struct devlink_resource_size_params *size_params, | |
331 | u64 size_min, u64 size_max, | |
332 | u64 size_granularity, | |
333 | enum devlink_resource_unit unit) | |
334 | { | |
335 | size_params->size_min = size_min; | |
336 | size_params->size_max = size_max; | |
337 | size_params->size_granularity = size_granularity; | |
338 | size_params->unit = unit; | |
339 | } | |
340 | ||
fc56be47 JP |
341 | typedef u64 devlink_resource_occ_get_t(void *priv); |
342 | ||
d9f9b9a4 AS |
343 | /** |
344 | * struct devlink_resource - devlink resource | |
345 | * @name: name of the resource | |
346 | * @id: id, per devlink instance | |
347 | * @size: size of the resource | |
348 | * @size_new: updated size of the resource, reload is needed | |
349 | * @size_valid: valid in case the total size of the resource is valid | |
350 | * including its children | |
351 | * @parent: parent resource | |
352 | * @size_params: size parameters | |
353 | * @list: parent list | |
354 | * @resource_list: list of child resources | |
d9f9b9a4 AS |
355 | */ |
356 | struct devlink_resource { | |
357 | const char *name; | |
358 | u64 id; | |
359 | u64 size; | |
360 | u64 size_new; | |
361 | bool size_valid; | |
362 | struct devlink_resource *parent; | |
77d27096 | 363 | struct devlink_resource_size_params size_params; |
d9f9b9a4 AS |
364 | struct list_head list; |
365 | struct list_head resource_list; | |
fc56be47 JP |
366 | devlink_resource_occ_get_t *occ_get; |
367 | void *occ_get_priv; | |
d9f9b9a4 AS |
368 | }; |
369 | ||
370 | #define DEVLINK_RESOURCE_ID_PARENT_TOP 0 | |
371 | ||
bde74ad1 | 372 | #define __DEVLINK_PARAM_MAX_STRING_VALUE 32 |
eabaef18 MS |
373 | enum devlink_param_type { |
374 | DEVLINK_PARAM_TYPE_U8, | |
375 | DEVLINK_PARAM_TYPE_U16, | |
376 | DEVLINK_PARAM_TYPE_U32, | |
377 | DEVLINK_PARAM_TYPE_STRING, | |
378 | DEVLINK_PARAM_TYPE_BOOL, | |
379 | }; | |
380 | ||
381 | union devlink_param_value { | |
382 | u8 vu8; | |
383 | u16 vu16; | |
384 | u32 vu32; | |
bde74ad1 | 385 | char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE]; |
eabaef18 MS |
386 | bool vbool; |
387 | }; | |
388 | ||
389 | struct devlink_param_gset_ctx { | |
390 | union devlink_param_value val; | |
391 | enum devlink_param_cmode cmode; | |
392 | }; | |
393 | ||
6700acc5 SN |
394 | /** |
395 | * struct devlink_flash_notify - devlink dev flash notify data | |
396 | * @status_msg: current status string | |
397 | * @component: firmware component being updated | |
398 | * @done: amount of work completed of total amount | |
399 | * @total: amount of work expected to be done | |
400 | * @timeout: expected max timeout in seconds | |
401 | * | |
402 | * These are values to be given to userland to be displayed in order | |
403 | * to show current activity in a firmware update process. | |
404 | */ | |
405 | struct devlink_flash_notify { | |
406 | const char *status_msg; | |
407 | const char *component; | |
408 | unsigned long done; | |
409 | unsigned long total; | |
410 | unsigned long timeout; | |
411 | }; | |
412 | ||
eabaef18 MS |
413 | /** |
414 | * struct devlink_param - devlink configuration parameter data | |
415 | * @name: name of the parameter | |
416 | * @generic: indicates if the parameter is generic or driver specific | |
417 | * @type: parameter type | |
418 | * @supported_cmodes: bitmap of supported configuration modes | |
419 | * @get: get parameter value, used for runtime and permanent | |
420 | * configuration modes | |
421 | * @set: set parameter value, used for runtime and permanent | |
422 | * configuration modes | |
e3b7ca18 | 423 | * @validate: validate input value is applicable (within value range, etc.) |
eabaef18 MS |
424 | * |
425 | * This struct should be used by the driver to fill the data for | |
426 | * a parameter it registers. | |
427 | */ | |
428 | struct devlink_param { | |
429 | u32 id; | |
430 | const char *name; | |
431 | bool generic; | |
432 | enum devlink_param_type type; | |
433 | unsigned long supported_cmodes; | |
434 | int (*get)(struct devlink *devlink, u32 id, | |
435 | struct devlink_param_gset_ctx *ctx); | |
436 | int (*set)(struct devlink *devlink, u32 id, | |
437 | struct devlink_param_gset_ctx *ctx); | |
e3b7ca18 MS |
438 | int (*validate)(struct devlink *devlink, u32 id, |
439 | union devlink_param_value val, | |
440 | struct netlink_ext_ack *extack); | |
eabaef18 MS |
441 | }; |
442 | ||
443 | struct devlink_param_item { | |
444 | struct list_head list; | |
445 | const struct devlink_param *param; | |
446 | union devlink_param_value driverinit_value; | |
447 | bool driverinit_value_valid; | |
7c62cfb8 | 448 | bool published; |
eabaef18 MS |
449 | }; |
450 | ||
451 | enum devlink_param_generic_id { | |
036467c3 MS |
452 | DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, |
453 | DEVLINK_PARAM_GENERIC_ID_MAX_MACS, | |
f567bcda | 454 | DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, |
f6a69885 | 455 | DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, |
e3b51061 | 456 | DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, |
f61cba42 | 457 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, |
16511789 | 458 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, |
846e980a | 459 | DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, |
5bbd21df | 460 | DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE, |
6c7295e1 | 461 | DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, |
eabaef18 MS |
462 | |
463 | /* add new param generic ids above here*/ | |
464 | __DEVLINK_PARAM_GENERIC_ID_MAX, | |
465 | DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, | |
466 | }; | |
467 | ||
036467c3 MS |
468 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" |
469 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL | |
470 | ||
471 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" | |
472 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 | |
473 | ||
f567bcda VV |
474 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" |
475 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL | |
476 | ||
f6a69885 AV |
477 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" |
478 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL | |
479 | ||
e3b51061 VV |
480 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" |
481 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL | |
482 | ||
f61cba42 VV |
483 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" |
484 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 | |
485 | ||
16511789 VV |
486 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" |
487 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 | |
488 | ||
846e980a ST |
489 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy" |
490 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8 | |
491 | ||
5bbd21df DM |
492 | #define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_NAME \ |
493 | "reset_dev_on_drv_probe" | |
494 | #define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_TYPE DEVLINK_PARAM_TYPE_U8 | |
495 | ||
6c7295e1 MG |
496 | #define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME "enable_roce" |
497 | #define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE DEVLINK_PARAM_TYPE_BOOL | |
498 | ||
036467c3 MS |
499 | #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ |
500 | { \ | |
501 | .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ | |
502 | .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ | |
503 | .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ | |
504 | .generic = true, \ | |
505 | .supported_cmodes = _cmodes, \ | |
506 | .get = _get, \ | |
507 | .set = _set, \ | |
508 | .validate = _validate, \ | |
509 | } | |
510 | ||
511 | #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ | |
512 | { \ | |
513 | .id = _id, \ | |
514 | .name = _name, \ | |
515 | .type = _type, \ | |
516 | .supported_cmodes = _cmodes, \ | |
517 | .get = _get, \ | |
518 | .set = _set, \ | |
519 | .validate = _validate, \ | |
520 | } | |
521 | ||
785bd550 JK |
522 | /* Part number, identifier of board design */ |
523 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id" | |
524 | /* Revision of board design */ | |
525 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev" | |
14fd1901 JK |
526 | /* Maker of the board */ |
527 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture" | |
785bd550 | 528 | |
7d5aa9a5 SN |
529 | /* Part number, identifier of asic design */ |
530 | #define DEVLINK_INFO_VERSION_GENERIC_ASIC_ID "asic.id" | |
531 | /* Revision of asic design */ | |
532 | #define DEVLINK_INFO_VERSION_GENERIC_ASIC_REV "asic.rev" | |
533 | ||
534 | /* Overall FW version */ | |
535 | #define DEVLINK_INFO_VERSION_GENERIC_FW "fw" | |
785bd550 JK |
536 | /* Control processor FW version */ |
537 | #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt" | |
2d9eade8 VV |
538 | /* FW interface specification version */ |
539 | #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API "fw.mgmt.api" | |
785bd550 JK |
540 | /* Data path microcode controlling high-speed packet processing */ |
541 | #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app" | |
542 | /* UNDI software version */ | |
543 | #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi" | |
544 | /* NCSI support/handler version */ | |
545 | #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi" | |
468672b2 JK |
546 | /* FW parameter set id */ |
547 | #define DEVLINK_INFO_VERSION_GENERIC_FW_PSID "fw.psid" | |
41c0d917 VV |
548 | /* RoCE FW version */ |
549 | #define DEVLINK_INFO_VERSION_GENERIC_FW_ROCE "fw.roce" | |
c90977a3 JK |
550 | /* Firmware bundle identifier */ |
551 | #define DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID "fw.bundle_id" | |
785bd550 | 552 | |
22ec3d23 JK |
553 | #define DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT BIT(0) |
554 | ||
b16ebe92 | 555 | struct devlink_region; |
f9cf2288 | 556 | struct devlink_info_req; |
b16ebe92 | 557 | |
e8937681 JK |
558 | /** |
559 | * struct devlink_region_ops - Region operations | |
560 | * @name: region name | |
a0a09f6b | 561 | * @destructor: callback used to free snapshot memory when deleting |
b9a17abf JK |
562 | * @snapshot: callback to request an immediate snapshot. On success, |
563 | * the data variable must be updated to point to the snapshot data. | |
564 | * The function will be called while the devlink instance lock is | |
565 | * held. | |
e14e05e7 | 566 | * @priv: Pointer to driver private data for the region operation |
e8937681 JK |
567 | */ |
568 | struct devlink_region_ops { | |
569 | const char *name; | |
a0a09f6b | 570 | void (*destructor)(const void *data); |
d4602a9f AL |
571 | int (*snapshot)(struct devlink *devlink, |
572 | const struct devlink_region_ops *ops, | |
573 | struct netlink_ext_ack *extack, | |
b9a17abf | 574 | u8 **data); |
e14e05e7 | 575 | void *priv; |
e8937681 JK |
576 | }; |
577 | ||
1db64e87 | 578 | struct devlink_fmsg; |
a0bdcc59 EBE |
579 | struct devlink_health_reporter; |
580 | ||
3167b27a EBE |
581 | enum devlink_health_reporter_state { |
582 | DEVLINK_HEALTH_REPORTER_STATE_HEALTHY, | |
583 | DEVLINK_HEALTH_REPORTER_STATE_ERROR, | |
584 | }; | |
585 | ||
a0bdcc59 EBE |
586 | /** |
587 | * struct devlink_health_reporter_ops - Reporter operations | |
588 | * @name: reporter name | |
589 | * @recover: callback to recover from reported error | |
590 | * if priv_ctx is NULL, run a full recover | |
591 | * @dump: callback to dump an object | |
592 | * if priv_ctx is NULL, run a full dump | |
593 | * @diagnose: callback to diagnose the current status | |
e2ce94dc | 594 | * @test: callback to trigger a test event |
a0bdcc59 EBE |
595 | */ |
596 | ||
597 | struct devlink_health_reporter_ops { | |
598 | char *name; | |
599 | int (*recover)(struct devlink_health_reporter *reporter, | |
e7a98105 | 600 | void *priv_ctx, struct netlink_ext_ack *extack); |
a0bdcc59 | 601 | int (*dump)(struct devlink_health_reporter *reporter, |
e7a98105 JP |
602 | struct devlink_fmsg *fmsg, void *priv_ctx, |
603 | struct netlink_ext_ack *extack); | |
a0bdcc59 | 604 | int (*diagnose)(struct devlink_health_reporter *reporter, |
e7a98105 JP |
605 | struct devlink_fmsg *fmsg, |
606 | struct netlink_ext_ack *extack); | |
e2ce94dc JP |
607 | int (*test)(struct devlink_health_reporter *reporter, |
608 | struct netlink_ext_ack *extack); | |
a0bdcc59 | 609 | }; |
1db64e87 | 610 | |
1e8c6619 IS |
611 | /** |
612 | * struct devlink_trap_policer - Immutable packet trap policer attributes. | |
613 | * @id: Policer identifier. | |
614 | * @init_rate: Initial rate in packets / sec. | |
615 | * @init_burst: Initial burst size in packets. | |
616 | * @max_rate: Maximum rate. | |
617 | * @min_rate: Minimum rate. | |
618 | * @max_burst: Maximum burst size. | |
619 | * @min_burst: Minimum burst size. | |
620 | * | |
621 | * Describes immutable attributes of packet trap policers that drivers register | |
622 | * with devlink. | |
623 | */ | |
624 | struct devlink_trap_policer { | |
625 | u32 id; | |
626 | u64 init_rate; | |
627 | u64 init_burst; | |
628 | u64 max_rate; | |
629 | u64 min_rate; | |
630 | u64 max_burst; | |
631 | u64 min_burst; | |
632 | }; | |
633 | ||
0f420b6c IS |
634 | /** |
635 | * struct devlink_trap_group - Immutable packet trap group attributes. | |
636 | * @name: Trap group name. | |
637 | * @id: Trap group identifier. | |
638 | * @generic: Whether the trap group is generic or not. | |
f9f54392 | 639 | * @init_policer_id: Initial policer identifier. |
0f420b6c IS |
640 | * |
641 | * Describes immutable attributes of packet trap groups that drivers register | |
642 | * with devlink. | |
643 | */ | |
644 | struct devlink_trap_group { | |
645 | const char *name; | |
646 | u16 id; | |
647 | bool generic; | |
f9f54392 | 648 | u32 init_policer_id; |
0f420b6c IS |
649 | }; |
650 | ||
651 | #define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT BIT(0) | |
85b0589e | 652 | #define DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE BIT(1) |
0f420b6c IS |
653 | |
654 | /** | |
655 | * struct devlink_trap - Immutable packet trap attributes. | |
656 | * @type: Trap type. | |
657 | * @init_action: Initial trap action. | |
658 | * @generic: Whether the trap is generic or not. | |
659 | * @id: Trap identifier. | |
660 | * @name: Trap name. | |
107f1678 | 661 | * @init_group_id: Initial group identifier. |
0f420b6c IS |
662 | * @metadata_cap: Metadata types that can be provided by the trap. |
663 | * | |
664 | * Describes immutable attributes of packet traps that drivers register with | |
665 | * devlink. | |
666 | */ | |
667 | struct devlink_trap { | |
668 | enum devlink_trap_type type; | |
669 | enum devlink_trap_action init_action; | |
670 | bool generic; | |
671 | u16 id; | |
672 | const char *name; | |
107f1678 | 673 | u16 init_group_id; |
0f420b6c IS |
674 | u32 metadata_cap; |
675 | }; | |
676 | ||
f3047ca0 | 677 | /* All traps must be documented in |
f4bdd710 | 678 | * Documentation/networking/devlink/devlink-trap.rst |
f3047ca0 | 679 | */ |
0f420b6c | 680 | enum devlink_trap_generic_id { |
391203ab IS |
681 | DEVLINK_TRAP_GENERIC_ID_SMAC_MC, |
682 | DEVLINK_TRAP_GENERIC_ID_VLAN_TAG_MISMATCH, | |
683 | DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER, | |
684 | DEVLINK_TRAP_GENERIC_ID_INGRESS_STP_FILTER, | |
685 | DEVLINK_TRAP_GENERIC_ID_EMPTY_TX_LIST, | |
686 | DEVLINK_TRAP_GENERIC_ID_PORT_LOOPBACK_FILTER, | |
687 | DEVLINK_TRAP_GENERIC_ID_BLACKHOLE_ROUTE, | |
688 | DEVLINK_TRAP_GENERIC_ID_TTL_ERROR, | |
689 | DEVLINK_TRAP_GENERIC_ID_TAIL_DROP, | |
6896cc4d AC |
690 | DEVLINK_TRAP_GENERIC_ID_NON_IP_PACKET, |
691 | DEVLINK_TRAP_GENERIC_ID_UC_DIP_MC_DMAC, | |
692 | DEVLINK_TRAP_GENERIC_ID_DIP_LB, | |
693 | DEVLINK_TRAP_GENERIC_ID_SIP_MC, | |
694 | DEVLINK_TRAP_GENERIC_ID_SIP_LB, | |
695 | DEVLINK_TRAP_GENERIC_ID_CORRUPTED_IP_HDR, | |
696 | DEVLINK_TRAP_GENERIC_ID_IPV4_SIP_BC, | |
697 | DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_RESERVED_SCOPE, | |
698 | DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE, | |
3b063ae5 AC |
699 | DEVLINK_TRAP_GENERIC_ID_MTU_ERROR, |
700 | DEVLINK_TRAP_GENERIC_ID_UNRESOLVED_NEIGH, | |
701 | DEVLINK_TRAP_GENERIC_ID_RPF, | |
702 | DEVLINK_TRAP_GENERIC_ID_REJECT_ROUTE, | |
703 | DEVLINK_TRAP_GENERIC_ID_IPV4_LPM_UNICAST_MISS, | |
704 | DEVLINK_TRAP_GENERIC_ID_IPV6_LPM_UNICAST_MISS, | |
95f0ead8 | 705 | DEVLINK_TRAP_GENERIC_ID_NON_ROUTABLE, |
13c056ec | 706 | DEVLINK_TRAP_GENERIC_ID_DECAP_ERROR, |
c3cae491 | 707 | DEVLINK_TRAP_GENERIC_ID_OVERLAY_SMAC_MC, |
ecd942a0 JP |
708 | DEVLINK_TRAP_GENERIC_ID_INGRESS_FLOW_ACTION_DROP, |
709 | DEVLINK_TRAP_GENERIC_ID_EGRESS_FLOW_ACTION_DROP, | |
515eac67 IS |
710 | DEVLINK_TRAP_GENERIC_ID_STP, |
711 | DEVLINK_TRAP_GENERIC_ID_LACP, | |
712 | DEVLINK_TRAP_GENERIC_ID_LLDP, | |
713 | DEVLINK_TRAP_GENERIC_ID_IGMP_QUERY, | |
714 | DEVLINK_TRAP_GENERIC_ID_IGMP_V1_REPORT, | |
715 | DEVLINK_TRAP_GENERIC_ID_IGMP_V2_REPORT, | |
716 | DEVLINK_TRAP_GENERIC_ID_IGMP_V3_REPORT, | |
717 | DEVLINK_TRAP_GENERIC_ID_IGMP_V2_LEAVE, | |
718 | DEVLINK_TRAP_GENERIC_ID_MLD_QUERY, | |
719 | DEVLINK_TRAP_GENERIC_ID_MLD_V1_REPORT, | |
720 | DEVLINK_TRAP_GENERIC_ID_MLD_V2_REPORT, | |
721 | DEVLINK_TRAP_GENERIC_ID_MLD_V1_DONE, | |
d77cfd16 IS |
722 | DEVLINK_TRAP_GENERIC_ID_IPV4_DHCP, |
723 | DEVLINK_TRAP_GENERIC_ID_IPV6_DHCP, | |
724 | DEVLINK_TRAP_GENERIC_ID_ARP_REQUEST, | |
725 | DEVLINK_TRAP_GENERIC_ID_ARP_RESPONSE, | |
726 | DEVLINK_TRAP_GENERIC_ID_ARP_OVERLAY, | |
727 | DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_SOLICIT, | |
728 | DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_ADVERT, | |
729 | DEVLINK_TRAP_GENERIC_ID_IPV4_BFD, | |
730 | DEVLINK_TRAP_GENERIC_ID_IPV6_BFD, | |
731 | DEVLINK_TRAP_GENERIC_ID_IPV4_OSPF, | |
732 | DEVLINK_TRAP_GENERIC_ID_IPV6_OSPF, | |
733 | DEVLINK_TRAP_GENERIC_ID_IPV4_BGP, | |
734 | DEVLINK_TRAP_GENERIC_ID_IPV6_BGP, | |
735 | DEVLINK_TRAP_GENERIC_ID_IPV4_VRRP, | |
736 | DEVLINK_TRAP_GENERIC_ID_IPV6_VRRP, | |
737 | DEVLINK_TRAP_GENERIC_ID_IPV4_PIM, | |
738 | DEVLINK_TRAP_GENERIC_ID_IPV6_PIM, | |
739 | DEVLINK_TRAP_GENERIC_ID_UC_LB, | |
740 | DEVLINK_TRAP_GENERIC_ID_LOCAL_ROUTE, | |
741 | DEVLINK_TRAP_GENERIC_ID_EXTERNAL_ROUTE, | |
742 | DEVLINK_TRAP_GENERIC_ID_IPV6_UC_DIP_LINK_LOCAL_SCOPE, | |
743 | DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_NODES, | |
744 | DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_ROUTERS, | |
745 | DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_SOLICIT, | |
746 | DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ADVERT, | |
747 | DEVLINK_TRAP_GENERIC_ID_IPV6_REDIRECT, | |
748 | DEVLINK_TRAP_GENERIC_ID_IPV4_ROUTER_ALERT, | |
749 | DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ALERT, | |
750 | DEVLINK_TRAP_GENERIC_ID_PTP_EVENT, | |
751 | DEVLINK_TRAP_GENERIC_ID_PTP_GENERAL, | |
5eb18a2b IS |
752 | DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE, |
753 | DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP, | |
08e335f6 | 754 | DEVLINK_TRAP_GENERIC_ID_EARLY_DROP, |
391203ab | 755 | |
0f420b6c IS |
756 | /* Add new generic trap IDs above */ |
757 | __DEVLINK_TRAP_GENERIC_ID_MAX, | |
758 | DEVLINK_TRAP_GENERIC_ID_MAX = __DEVLINK_TRAP_GENERIC_ID_MAX - 1, | |
759 | }; | |
760 | ||
f3047ca0 | 761 | /* All trap groups must be documented in |
f4bdd710 | 762 | * Documentation/networking/devlink/devlink-trap.rst |
f3047ca0 | 763 | */ |
0f420b6c | 764 | enum devlink_trap_group_generic_id { |
391203ab IS |
765 | DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS, |
766 | DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS, | |
678eb199 | 767 | DEVLINK_TRAP_GROUP_GENERIC_ID_L3_EXCEPTIONS, |
391203ab | 768 | DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS, |
13c056ec | 769 | DEVLINK_TRAP_GROUP_GENERIC_ID_TUNNEL_DROPS, |
ecd942a0 | 770 | DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_DROPS, |
515eac67 IS |
771 | DEVLINK_TRAP_GROUP_GENERIC_ID_STP, |
772 | DEVLINK_TRAP_GROUP_GENERIC_ID_LACP, | |
773 | DEVLINK_TRAP_GROUP_GENERIC_ID_LLDP, | |
774 | DEVLINK_TRAP_GROUP_GENERIC_ID_MC_SNOOPING, | |
d77cfd16 IS |
775 | DEVLINK_TRAP_GROUP_GENERIC_ID_DHCP, |
776 | DEVLINK_TRAP_GROUP_GENERIC_ID_NEIGH_DISCOVERY, | |
777 | DEVLINK_TRAP_GROUP_GENERIC_ID_BFD, | |
778 | DEVLINK_TRAP_GROUP_GENERIC_ID_OSPF, | |
779 | DEVLINK_TRAP_GROUP_GENERIC_ID_BGP, | |
780 | DEVLINK_TRAP_GROUP_GENERIC_ID_VRRP, | |
781 | DEVLINK_TRAP_GROUP_GENERIC_ID_PIM, | |
782 | DEVLINK_TRAP_GROUP_GENERIC_ID_UC_LB, | |
783 | DEVLINK_TRAP_GROUP_GENERIC_ID_LOCAL_DELIVERY, | |
ec4f5b36 | 784 | DEVLINK_TRAP_GROUP_GENERIC_ID_EXTERNAL_DELIVERY, |
d77cfd16 IS |
785 | DEVLINK_TRAP_GROUP_GENERIC_ID_IPV6, |
786 | DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_EVENT, | |
787 | DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_GENERAL, | |
5eb18a2b IS |
788 | DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_SAMPLE, |
789 | DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_TRAP, | |
391203ab | 790 | |
0f420b6c IS |
791 | /* Add new generic trap group IDs above */ |
792 | __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX, | |
793 | DEVLINK_TRAP_GROUP_GENERIC_ID_MAX = | |
794 | __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX - 1, | |
795 | }; | |
796 | ||
391203ab IS |
797 | #define DEVLINK_TRAP_GENERIC_NAME_SMAC_MC \ |
798 | "source_mac_is_multicast" | |
799 | #define DEVLINK_TRAP_GENERIC_NAME_VLAN_TAG_MISMATCH \ | |
800 | "vlan_tag_mismatch" | |
801 | #define DEVLINK_TRAP_GENERIC_NAME_INGRESS_VLAN_FILTER \ | |
802 | "ingress_vlan_filter" | |
803 | #define DEVLINK_TRAP_GENERIC_NAME_INGRESS_STP_FILTER \ | |
804 | "ingress_spanning_tree_filter" | |
805 | #define DEVLINK_TRAP_GENERIC_NAME_EMPTY_TX_LIST \ | |
806 | "port_list_is_empty" | |
807 | #define DEVLINK_TRAP_GENERIC_NAME_PORT_LOOPBACK_FILTER \ | |
808 | "port_loopback_filter" | |
809 | #define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_ROUTE \ | |
810 | "blackhole_route" | |
811 | #define DEVLINK_TRAP_GENERIC_NAME_TTL_ERROR \ | |
812 | "ttl_value_is_too_small" | |
813 | #define DEVLINK_TRAP_GENERIC_NAME_TAIL_DROP \ | |
814 | "tail_drop" | |
6896cc4d AC |
815 | #define DEVLINK_TRAP_GENERIC_NAME_NON_IP_PACKET \ |
816 | "non_ip" | |
817 | #define DEVLINK_TRAP_GENERIC_NAME_UC_DIP_MC_DMAC \ | |
818 | "uc_dip_over_mc_dmac" | |
819 | #define DEVLINK_TRAP_GENERIC_NAME_DIP_LB \ | |
820 | "dip_is_loopback_address" | |
821 | #define DEVLINK_TRAP_GENERIC_NAME_SIP_MC \ | |
822 | "sip_is_mc" | |
823 | #define DEVLINK_TRAP_GENERIC_NAME_SIP_LB \ | |
824 | "sip_is_loopback_address" | |
825 | #define DEVLINK_TRAP_GENERIC_NAME_CORRUPTED_IP_HDR \ | |
826 | "ip_header_corrupted" | |
827 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_SIP_BC \ | |
828 | "ipv4_sip_is_limited_bc" | |
829 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_RESERVED_SCOPE \ | |
830 | "ipv6_mc_dip_reserved_scope" | |
831 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE \ | |
832 | "ipv6_mc_dip_interface_local_scope" | |
3b063ae5 AC |
833 | #define DEVLINK_TRAP_GENERIC_NAME_MTU_ERROR \ |
834 | "mtu_value_is_too_small" | |
835 | #define DEVLINK_TRAP_GENERIC_NAME_UNRESOLVED_NEIGH \ | |
836 | "unresolved_neigh" | |
837 | #define DEVLINK_TRAP_GENERIC_NAME_RPF \ | |
838 | "mc_reverse_path_forwarding" | |
839 | #define DEVLINK_TRAP_GENERIC_NAME_REJECT_ROUTE \ | |
840 | "reject_route" | |
841 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_LPM_UNICAST_MISS \ | |
842 | "ipv4_lpm_miss" | |
843 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_LPM_UNICAST_MISS \ | |
844 | "ipv6_lpm_miss" | |
95f0ead8 AC |
845 | #define DEVLINK_TRAP_GENERIC_NAME_NON_ROUTABLE \ |
846 | "non_routable_packet" | |
13c056ec AC |
847 | #define DEVLINK_TRAP_GENERIC_NAME_DECAP_ERROR \ |
848 | "decap_error" | |
c3cae491 AC |
849 | #define DEVLINK_TRAP_GENERIC_NAME_OVERLAY_SMAC_MC \ |
850 | "overlay_smac_is_mc" | |
ecd942a0 JP |
851 | #define DEVLINK_TRAP_GENERIC_NAME_INGRESS_FLOW_ACTION_DROP \ |
852 | "ingress_flow_action_drop" | |
853 | #define DEVLINK_TRAP_GENERIC_NAME_EGRESS_FLOW_ACTION_DROP \ | |
854 | "egress_flow_action_drop" | |
515eac67 IS |
855 | #define DEVLINK_TRAP_GENERIC_NAME_STP \ |
856 | "stp" | |
857 | #define DEVLINK_TRAP_GENERIC_NAME_LACP \ | |
858 | "lacp" | |
859 | #define DEVLINK_TRAP_GENERIC_NAME_LLDP \ | |
860 | "lldp" | |
861 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_QUERY \ | |
862 | "igmp_query" | |
863 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V1_REPORT \ | |
864 | "igmp_v1_report" | |
865 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_REPORT \ | |
866 | "igmp_v2_report" | |
867 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V3_REPORT \ | |
868 | "igmp_v3_report" | |
869 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_LEAVE \ | |
870 | "igmp_v2_leave" | |
871 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_QUERY \ | |
872 | "mld_query" | |
873 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_REPORT \ | |
874 | "mld_v1_report" | |
875 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_V2_REPORT \ | |
876 | "mld_v2_report" | |
877 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_DONE \ | |
878 | "mld_v1_done" | |
d77cfd16 IS |
879 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_DHCP \ |
880 | "ipv4_dhcp" | |
881 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_DHCP \ | |
882 | "ipv6_dhcp" | |
883 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_REQUEST \ | |
884 | "arp_request" | |
885 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_RESPONSE \ | |
886 | "arp_response" | |
887 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_OVERLAY \ | |
888 | "arp_overlay" | |
889 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_SOLICIT \ | |
890 | "ipv6_neigh_solicit" | |
891 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_ADVERT \ | |
892 | "ipv6_neigh_advert" | |
893 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_BFD \ | |
894 | "ipv4_bfd" | |
895 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_BFD \ | |
896 | "ipv6_bfd" | |
897 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_OSPF \ | |
898 | "ipv4_ospf" | |
899 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_OSPF \ | |
900 | "ipv6_ospf" | |
901 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_BGP \ | |
902 | "ipv4_bgp" | |
903 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_BGP \ | |
904 | "ipv6_bgp" | |
905 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_VRRP \ | |
906 | "ipv4_vrrp" | |
907 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_VRRP \ | |
908 | "ipv6_vrrp" | |
909 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_PIM \ | |
910 | "ipv4_pim" | |
911 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_PIM \ | |
912 | "ipv6_pim" | |
913 | #define DEVLINK_TRAP_GENERIC_NAME_UC_LB \ | |
914 | "uc_loopback" | |
915 | #define DEVLINK_TRAP_GENERIC_NAME_LOCAL_ROUTE \ | |
916 | "local_route" | |
917 | #define DEVLINK_TRAP_GENERIC_NAME_EXTERNAL_ROUTE \ | |
918 | "external_route" | |
919 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_UC_DIP_LINK_LOCAL_SCOPE \ | |
920 | "ipv6_uc_dip_link_local_scope" | |
921 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_NODES \ | |
922 | "ipv6_dip_all_nodes" | |
923 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_ROUTERS \ | |
924 | "ipv6_dip_all_routers" | |
925 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_SOLICIT \ | |
926 | "ipv6_router_solicit" | |
927 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ADVERT \ | |
928 | "ipv6_router_advert" | |
929 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_REDIRECT \ | |
930 | "ipv6_redirect" | |
931 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_ROUTER_ALERT \ | |
932 | "ipv4_router_alert" | |
933 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ALERT \ | |
934 | "ipv6_router_alert" | |
935 | #define DEVLINK_TRAP_GENERIC_NAME_PTP_EVENT \ | |
936 | "ptp_event" | |
937 | #define DEVLINK_TRAP_GENERIC_NAME_PTP_GENERAL \ | |
938 | "ptp_general" | |
5eb18a2b IS |
939 | #define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_SAMPLE \ |
940 | "flow_action_sample" | |
941 | #define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP \ | |
942 | "flow_action_trap" | |
08e335f6 AC |
943 | #define DEVLINK_TRAP_GENERIC_NAME_EARLY_DROP \ |
944 | "early_drop" | |
391203ab IS |
945 | |
946 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \ | |
947 | "l2_drops" | |
948 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS \ | |
949 | "l3_drops" | |
678eb199 IS |
950 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_EXCEPTIONS \ |
951 | "l3_exceptions" | |
391203ab IS |
952 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS \ |
953 | "buffer_drops" | |
13c056ec AC |
954 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_TUNNEL_DROPS \ |
955 | "tunnel_drops" | |
ecd942a0 JP |
956 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_DROPS \ |
957 | "acl_drops" | |
515eac67 IS |
958 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_STP \ |
959 | "stp" | |
960 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_LACP \ | |
961 | "lacp" | |
962 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_LLDP \ | |
963 | "lldp" | |
964 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_MC_SNOOPING \ | |
965 | "mc_snooping" | |
d77cfd16 IS |
966 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_DHCP \ |
967 | "dhcp" | |
968 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_NEIGH_DISCOVERY \ | |
969 | "neigh_discovery" | |
970 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BFD \ | |
971 | "bfd" | |
972 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_OSPF \ | |
973 | "ospf" | |
974 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BGP \ | |
975 | "bgp" | |
976 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_VRRP \ | |
977 | "vrrp" | |
978 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PIM \ | |
979 | "pim" | |
980 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_UC_LB \ | |
981 | "uc_loopback" | |
982 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_LOCAL_DELIVERY \ | |
983 | "local_delivery" | |
ec4f5b36 IS |
984 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_EXTERNAL_DELIVERY \ |
985 | "external_delivery" | |
d77cfd16 IS |
986 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_IPV6 \ |
987 | "ipv6" | |
988 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_EVENT \ | |
989 | "ptp_event" | |
990 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_GENERAL \ | |
991 | "ptp_general" | |
5eb18a2b IS |
992 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_SAMPLE \ |
993 | "acl_sample" | |
994 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_TRAP \ | |
995 | "acl_trap" | |
391203ab | 996 | |
107f1678 IS |
997 | #define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id, \ |
998 | _metadata_cap) \ | |
0f420b6c IS |
999 | { \ |
1000 | .type = DEVLINK_TRAP_TYPE_##_type, \ | |
1001 | .init_action = DEVLINK_TRAP_ACTION_##_init_action, \ | |
1002 | .generic = true, \ | |
1003 | .id = DEVLINK_TRAP_GENERIC_ID_##_id, \ | |
1004 | .name = DEVLINK_TRAP_GENERIC_NAME_##_id, \ | |
107f1678 | 1005 | .init_group_id = _group_id, \ |
0f420b6c IS |
1006 | .metadata_cap = _metadata_cap, \ |
1007 | } | |
1008 | ||
107f1678 | 1009 | #define DEVLINK_TRAP_DRIVER(_type, _init_action, _id, _name, _group_id, \ |
0f420b6c IS |
1010 | _metadata_cap) \ |
1011 | { \ | |
1012 | .type = DEVLINK_TRAP_TYPE_##_type, \ | |
1013 | .init_action = DEVLINK_TRAP_ACTION_##_init_action, \ | |
1014 | .generic = false, \ | |
1015 | .id = _id, \ | |
1016 | .name = _name, \ | |
107f1678 | 1017 | .init_group_id = _group_id, \ |
0f420b6c IS |
1018 | .metadata_cap = _metadata_cap, \ |
1019 | } | |
1020 | ||
f9f54392 | 1021 | #define DEVLINK_TRAP_GROUP_GENERIC(_id, _policer_id) \ |
0f420b6c IS |
1022 | { \ |
1023 | .name = DEVLINK_TRAP_GROUP_GENERIC_NAME_##_id, \ | |
1024 | .id = DEVLINK_TRAP_GROUP_GENERIC_ID_##_id, \ | |
1025 | .generic = true, \ | |
f9f54392 | 1026 | .init_policer_id = _policer_id, \ |
0f420b6c IS |
1027 | } |
1028 | ||
1e8c6619 IS |
1029 | #define DEVLINK_TRAP_POLICER(_id, _rate, _burst, _max_rate, _min_rate, \ |
1030 | _max_burst, _min_burst) \ | |
1031 | { \ | |
1032 | .id = _id, \ | |
1033 | .init_rate = _rate, \ | |
1034 | .init_burst = _burst, \ | |
1035 | .max_rate = _max_rate, \ | |
1036 | .min_rate = _min_rate, \ | |
1037 | .max_burst = _max_burst, \ | |
1038 | .min_burst = _min_burst, \ | |
1039 | } | |
1040 | ||
bfcd3a46 | 1041 | struct devlink_ops { |
22ec3d23 JK |
1042 | /** |
1043 | * @supported_flash_update_params: | |
1044 | * mask of parameters supported by the driver's .flash_update | |
1045 | * implemementation. | |
1046 | */ | |
1047 | u32 supported_flash_update_params; | |
070c63f2 | 1048 | int (*reload_down)(struct devlink *devlink, bool netns_change, |
97691069 JP |
1049 | struct netlink_ext_ack *extack); |
1050 | int (*reload_up)(struct devlink *devlink, | |
1051 | struct netlink_ext_ack *extack); | |
bfcd3a46 JP |
1052 | int (*port_type_set)(struct devlink_port *devlink_port, |
1053 | enum devlink_port_type port_type); | |
1054 | int (*port_split)(struct devlink *devlink, unsigned int port_index, | |
ac0fc8a1 DA |
1055 | unsigned int count, struct netlink_ext_ack *extack); |
1056 | int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, | |
1057 | struct netlink_ext_ack *extack); | |
bf797471 JP |
1058 | int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, |
1059 | u16 pool_index, | |
1060 | struct devlink_sb_pool_info *pool_info); | |
1061 | int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, | |
1062 | u16 pool_index, u32 size, | |
f2ad1a52 IS |
1063 | enum devlink_sb_threshold_type threshold_type, |
1064 | struct netlink_ext_ack *extack); | |
bf797471 JP |
1065 | int (*sb_port_pool_get)(struct devlink_port *devlink_port, |
1066 | unsigned int sb_index, u16 pool_index, | |
1067 | u32 *p_threshold); | |
1068 | int (*sb_port_pool_set)(struct devlink_port *devlink_port, | |
1069 | unsigned int sb_index, u16 pool_index, | |
f2ad1a52 | 1070 | u32 threshold, struct netlink_ext_ack *extack); |
bf797471 JP |
1071 | int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, |
1072 | unsigned int sb_index, | |
1073 | u16 tc_index, | |
1074 | enum devlink_sb_pool_type pool_type, | |
1075 | u16 *p_pool_index, u32 *p_threshold); | |
1076 | int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, | |
1077 | unsigned int sb_index, | |
1078 | u16 tc_index, | |
1079 | enum devlink_sb_pool_type pool_type, | |
f2ad1a52 IS |
1080 | u16 pool_index, u32 threshold, |
1081 | struct netlink_ext_ack *extack); | |
df38dafd JP |
1082 | int (*sb_occ_snapshot)(struct devlink *devlink, |
1083 | unsigned int sb_index); | |
1084 | int (*sb_occ_max_clear)(struct devlink *devlink, | |
1085 | unsigned int sb_index); | |
1086 | int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, | |
1087 | unsigned int sb_index, u16 pool_index, | |
1088 | u32 *p_cur, u32 *p_max); | |
1089 | int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, | |
1090 | unsigned int sb_index, | |
1091 | u16 tc_index, | |
1092 | enum devlink_sb_pool_type pool_type, | |
1093 | u32 *p_cur, u32 *p_max); | |
08f4b591 OG |
1094 | |
1095 | int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); | |
db7ff19e EB |
1096 | int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, |
1097 | struct netlink_ext_ack *extack); | |
59bfde01 | 1098 | int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); |
db7ff19e EB |
1099 | int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, |
1100 | struct netlink_ext_ack *extack); | |
98fdbea5 LR |
1101 | int (*eswitch_encap_mode_get)(struct devlink *devlink, |
1102 | enum devlink_eswitch_encap_mode *p_encap_mode); | |
1103 | int (*eswitch_encap_mode_set)(struct devlink *devlink, | |
1104 | enum devlink_eswitch_encap_mode encap_mode, | |
db7ff19e | 1105 | struct netlink_ext_ack *extack); |
f9cf2288 JK |
1106 | int (*info_get)(struct devlink *devlink, struct devlink_info_req *req, |
1107 | struct netlink_ext_ack *extack); | |
22ec3d23 JK |
1108 | /** |
1109 | * @flash_update: Device flash update function | |
1110 | * | |
1111 | * Used to perform a flash update for the device. The set of | |
1112 | * parameters supported by the driver should be set in | |
1113 | * supported_flash_update_params. | |
1114 | */ | |
76726ccb JK |
1115 | int (*flash_update)(struct devlink *devlink, const char *file_name, |
1116 | const char *component, | |
1117 | struct netlink_ext_ack *extack); | |
0f420b6c IS |
1118 | /** |
1119 | * @trap_init: Trap initialization function. | |
1120 | * | |
1121 | * Should be used by device drivers to initialize the trap in the | |
1122 | * underlying device. Drivers should also store the provided trap | |
1123 | * context, so that they could efficiently pass it to | |
1124 | * devlink_trap_report() when the trap is triggered. | |
1125 | */ | |
1126 | int (*trap_init)(struct devlink *devlink, | |
1127 | const struct devlink_trap *trap, void *trap_ctx); | |
1128 | /** | |
1129 | * @trap_fini: Trap de-initialization function. | |
1130 | * | |
1131 | * Should be used by device drivers to de-initialize the trap in the | |
1132 | * underlying device. | |
1133 | */ | |
1134 | void (*trap_fini)(struct devlink *devlink, | |
1135 | const struct devlink_trap *trap, void *trap_ctx); | |
1136 | /** | |
1137 | * @trap_action_set: Trap action set function. | |
1138 | */ | |
1139 | int (*trap_action_set)(struct devlink *devlink, | |
1140 | const struct devlink_trap *trap, | |
c88e11e0 IS |
1141 | enum devlink_trap_action action, |
1142 | struct netlink_ext_ack *extack); | |
0f420b6c IS |
1143 | /** |
1144 | * @trap_group_init: Trap group initialization function. | |
1145 | * | |
1146 | * Should be used by device drivers to initialize the trap group in the | |
1147 | * underlying device. | |
1148 | */ | |
1149 | int (*trap_group_init)(struct devlink *devlink, | |
1150 | const struct devlink_trap_group *group); | |
c064875a IS |
1151 | /** |
1152 | * @trap_group_set: Trap group parameters set function. | |
1153 | * | |
1154 | * Note: @policer can be NULL when a policer is being unbound from | |
1155 | * @group. | |
1156 | */ | |
1157 | int (*trap_group_set)(struct devlink *devlink, | |
1158 | const struct devlink_trap_group *group, | |
c88e11e0 IS |
1159 | const struct devlink_trap_policer *policer, |
1160 | struct netlink_ext_ack *extack); | |
1e8c6619 IS |
1161 | /** |
1162 | * @trap_policer_init: Trap policer initialization function. | |
1163 | * | |
1164 | * Should be used by device drivers to initialize the trap policer in | |
1165 | * the underlying device. | |
1166 | */ | |
1167 | int (*trap_policer_init)(struct devlink *devlink, | |
1168 | const struct devlink_trap_policer *policer); | |
1169 | /** | |
1170 | * @trap_policer_fini: Trap policer de-initialization function. | |
1171 | * | |
1172 | * Should be used by device drivers to de-initialize the trap policer | |
1173 | * in the underlying device. | |
1174 | */ | |
1175 | void (*trap_policer_fini)(struct devlink *devlink, | |
1176 | const struct devlink_trap_policer *policer); | |
1177 | /** | |
1178 | * @trap_policer_set: Trap policer parameters set function. | |
1179 | */ | |
1180 | int (*trap_policer_set)(struct devlink *devlink, | |
1181 | const struct devlink_trap_policer *policer, | |
1182 | u64 rate, u64 burst, | |
1183 | struct netlink_ext_ack *extack); | |
1184 | /** | |
1185 | * @trap_policer_counter_get: Trap policer counter get function. | |
1186 | * | |
1187 | * Should be used by device drivers to report number of packets dropped | |
1188 | * by the policer. | |
1189 | */ | |
1190 | int (*trap_policer_counter_get)(struct devlink *devlink, | |
1191 | const struct devlink_trap_policer *policer, | |
1192 | u64 *p_drops); | |
2a916ecc PP |
1193 | /** |
1194 | * @port_function_hw_addr_get: Port function's hardware address get function. | |
1195 | * | |
1196 | * Should be used by device drivers to report the hardware address of a function managed | |
1197 | * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port | |
1198 | * function handling for a particular port. | |
1199 | * | |
1200 | * Note: @extack can be NULL when port notifier queries the port function. | |
1201 | */ | |
1202 | int (*port_function_hw_addr_get)(struct devlink *devlink, struct devlink_port *port, | |
1203 | u8 *hw_addr, int *hw_addr_len, | |
1204 | struct netlink_ext_ack *extack); | |
a1e8ae90 PP |
1205 | /** |
1206 | * @port_function_hw_addr_set: Port function's hardware address set function. | |
1207 | * | |
1208 | * Should be used by device drivers to set the hardware address of a function managed | |
1209 | * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port | |
1210 | * function handling for a particular port. | |
1211 | */ | |
1212 | int (*port_function_hw_addr_set)(struct devlink *devlink, struct devlink_port *port, | |
1213 | const u8 *hw_addr, int hw_addr_len, | |
1214 | struct netlink_ext_ack *extack); | |
bfcd3a46 JP |
1215 | }; |
1216 | ||
1217 | static inline void *devlink_priv(struct devlink *devlink) | |
1218 | { | |
1219 | BUG_ON(!devlink); | |
1220 | return &devlink->priv; | |
1221 | } | |
1222 | ||
1223 | static inline struct devlink *priv_to_devlink(void *priv) | |
1224 | { | |
1225 | BUG_ON(!priv); | |
1226 | return container_of(priv, struct devlink, priv); | |
1227 | } | |
1228 | ||
5dc37bb9 JP |
1229 | static inline struct devlink_port * |
1230 | netdev_to_devlink_port(struct net_device *dev) | |
1231 | { | |
1232 | if (dev->netdev_ops->ndo_get_devlink_port) | |
1233 | return dev->netdev_ops->ndo_get_devlink_port(dev); | |
1234 | return NULL; | |
1235 | } | |
1236 | ||
b473b0d2 JK |
1237 | static inline struct devlink *netdev_to_devlink(struct net_device *dev) |
1238 | { | |
5dc37bb9 JP |
1239 | struct devlink_port *devlink_port = netdev_to_devlink_port(dev); |
1240 | ||
1241 | if (devlink_port) | |
1242 | return devlink_port->devlink; | |
b473b0d2 JK |
1243 | return NULL; |
1244 | } | |
1245 | ||
bfcd3a46 JP |
1246 | struct ib_device; |
1247 | ||
471f894f | 1248 | struct net *devlink_net(const struct devlink *devlink); |
8273fd84 | 1249 | void devlink_net_set(struct devlink *devlink, struct net *net); |
bfcd3a46 JP |
1250 | struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); |
1251 | int devlink_register(struct devlink *devlink, struct device *dev); | |
1252 | void devlink_unregister(struct devlink *devlink); | |
a0c76345 JP |
1253 | void devlink_reload_enable(struct devlink *devlink); |
1254 | void devlink_reload_disable(struct devlink *devlink); | |
bfcd3a46 JP |
1255 | void devlink_free(struct devlink *devlink); |
1256 | int devlink_port_register(struct devlink *devlink, | |
1257 | struct devlink_port *devlink_port, | |
1258 | unsigned int port_index); | |
1259 | void devlink_port_unregister(struct devlink_port *devlink_port); | |
1260 | void devlink_port_type_eth_set(struct devlink_port *devlink_port, | |
1261 | struct net_device *netdev); | |
1262 | void devlink_port_type_ib_set(struct devlink_port *devlink_port, | |
1263 | struct ib_device *ibdev); | |
1264 | void devlink_port_type_clear(struct devlink_port *devlink_port); | |
b9ffcbaf | 1265 | void devlink_port_attrs_set(struct devlink_port *devlink_port, |
71ad8d55 | 1266 | struct devlink_port_attrs *devlink_port_attrs); |
3a2d9588 PP |
1267 | void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 controller, |
1268 | u16 pf, bool external); | |
1269 | void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller, | |
05b595e9 | 1270 | u16 pf, u16 vf, bool external); |
bf797471 JP |
1271 | int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, |
1272 | u32 size, u16 ingress_pools_count, | |
1273 | u16 egress_pools_count, u16 ingress_tc_count, | |
1274 | u16 egress_tc_count); | |
1275 | void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); | |
1555d204 AS |
1276 | int devlink_dpipe_table_register(struct devlink *devlink, |
1277 | const char *table_name, | |
1278 | struct devlink_dpipe_table_ops *table_ops, | |
ffd3cdcc | 1279 | void *priv, bool counter_control_extern); |
1555d204 AS |
1280 | void devlink_dpipe_table_unregister(struct devlink *devlink, |
1281 | const char *table_name); | |
1282 | int devlink_dpipe_headers_register(struct devlink *devlink, | |
1283 | struct devlink_dpipe_headers *dpipe_headers); | |
1284 | void devlink_dpipe_headers_unregister(struct devlink *devlink); | |
1285 | bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, | |
1286 | const char *table_name); | |
1287 | int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); | |
1288 | int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, | |
1289 | struct devlink_dpipe_entry *entry); | |
1290 | int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx); | |
35807324 | 1291 | void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); |
1555d204 AS |
1292 | int devlink_dpipe_action_put(struct sk_buff *skb, |
1293 | struct devlink_dpipe_action *action); | |
1294 | int devlink_dpipe_match_put(struct sk_buff *skb, | |
1295 | struct devlink_dpipe_match *match); | |
11770091 | 1296 | extern struct devlink_dpipe_header devlink_dpipe_header_ethernet; |
3fb886ec | 1297 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv4; |
1797f5b3 | 1298 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv6; |
bfcd3a46 | 1299 | |
d9f9b9a4 AS |
1300 | int devlink_resource_register(struct devlink *devlink, |
1301 | const char *resource_name, | |
d9f9b9a4 AS |
1302 | u64 resource_size, |
1303 | u64 resource_id, | |
1304 | u64 parent_resource_id, | |
fc56be47 | 1305 | const struct devlink_resource_size_params *size_params); |
d9f9b9a4 AS |
1306 | void devlink_resources_unregister(struct devlink *devlink, |
1307 | struct devlink_resource *resource); | |
1308 | int devlink_resource_size_get(struct devlink *devlink, | |
1309 | u64 resource_id, | |
1310 | u64 *p_resource_size); | |
56dc7cd0 AS |
1311 | int devlink_dpipe_table_resource_set(struct devlink *devlink, |
1312 | const char *table_name, u64 resource_id, | |
1313 | u64 resource_units); | |
fc56be47 JP |
1314 | void devlink_resource_occ_get_register(struct devlink *devlink, |
1315 | u64 resource_id, | |
1316 | devlink_resource_occ_get_t *occ_get, | |
1317 | void *occ_get_priv); | |
1318 | void devlink_resource_occ_get_unregister(struct devlink *devlink, | |
1319 | u64 resource_id); | |
eabaef18 MS |
1320 | int devlink_params_register(struct devlink *devlink, |
1321 | const struct devlink_param *params, | |
1322 | size_t params_count); | |
1323 | void devlink_params_unregister(struct devlink *devlink, | |
1324 | const struct devlink_param *params, | |
1325 | size_t params_count); | |
7c62cfb8 JP |
1326 | void devlink_params_publish(struct devlink *devlink); |
1327 | void devlink_params_unpublish(struct devlink *devlink); | |
39e6160e VV |
1328 | int devlink_port_params_register(struct devlink_port *devlink_port, |
1329 | const struct devlink_param *params, | |
1330 | size_t params_count); | |
1331 | void devlink_port_params_unregister(struct devlink_port *devlink_port, | |
1332 | const struct devlink_param *params, | |
1333 | size_t params_count); | |
ec01aeb1 MS |
1334 | int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, |
1335 | union devlink_param_value *init_val); | |
1336 | int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, | |
1337 | union devlink_param_value init_val); | |
ffd19b9a VV |
1338 | int |
1339 | devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port, | |
1340 | u32 param_id, | |
1341 | union devlink_param_value *init_val); | |
5473a7bd VV |
1342 | int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port, |
1343 | u32 param_id, | |
1344 | union devlink_param_value init_val); | |
ea601e17 | 1345 | void devlink_param_value_changed(struct devlink *devlink, u32 param_id); |
c1e5786d VV |
1346 | void devlink_port_param_value_changed(struct devlink_port *devlink_port, |
1347 | u32 param_id); | |
bde74ad1 MS |
1348 | void devlink_param_value_str_fill(union devlink_param_value *dst_val, |
1349 | const char *src); | |
e8937681 JK |
1350 | struct devlink_region * |
1351 | devlink_region_create(struct devlink *devlink, | |
1352 | const struct devlink_region_ops *ops, | |
1353 | u32 region_max_snapshots, u64 region_size); | |
b16ebe92 | 1354 | void devlink_region_destroy(struct devlink_region *region); |
7ef19d3b | 1355 | int devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id); |
12102436 | 1356 | void devlink_region_snapshot_id_put(struct devlink *devlink, u32 id); |
3a5e5234 | 1357 | int devlink_region_snapshot_create(struct devlink_region *region, |
a0a09f6b | 1358 | u8 *data, u32 snapshot_id); |
f9cf2288 JK |
1359 | int devlink_info_serial_number_put(struct devlink_info_req *req, |
1360 | const char *sn); | |
1361 | int devlink_info_driver_name_put(struct devlink_info_req *req, | |
1362 | const char *name); | |
b5872cd0 VV |
1363 | int devlink_info_board_serial_number_put(struct devlink_info_req *req, |
1364 | const char *bsn); | |
fc6fae7d JK |
1365 | int devlink_info_version_fixed_put(struct devlink_info_req *req, |
1366 | const char *version_name, | |
1367 | const char *version_value); | |
1368 | int devlink_info_version_stored_put(struct devlink_info_req *req, | |
1369 | const char *version_name, | |
1370 | const char *version_value); | |
1371 | int devlink_info_version_running_put(struct devlink_info_req *req, | |
1372 | const char *version_name, | |
1373 | const char *version_value); | |
d9f9b9a4 | 1374 | |
1db64e87 EBE |
1375 | int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg); |
1376 | int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg); | |
1377 | ||
1378 | int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name); | |
1379 | int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg); | |
1380 | ||
1381 | int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg, | |
1382 | const char *name); | |
1383 | int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg); | |
573ed90a AL |
1384 | int devlink_fmsg_binary_pair_nest_start(struct devlink_fmsg *fmsg, |
1385 | const char *name); | |
1386 | int devlink_fmsg_binary_pair_nest_end(struct devlink_fmsg *fmsg); | |
1db64e87 EBE |
1387 | |
1388 | int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value); | |
1389 | int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value); | |
1390 | int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value); | |
1391 | int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value); | |
1392 | int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value); | |
573ed90a AL |
1393 | int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, |
1394 | u16 value_len); | |
1db64e87 EBE |
1395 | |
1396 | int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, | |
1397 | bool value); | |
1398 | int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name, | |
1399 | u8 value); | |
1400 | int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name, | |
1401 | u32 value); | |
1402 | int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name, | |
1403 | u64 value); | |
1404 | int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name, | |
1405 | const char *value); | |
1406 | int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, | |
e2cde864 | 1407 | const void *value, u32 value_len); |
1db64e87 | 1408 | |
a0bdcc59 EBE |
1409 | struct devlink_health_reporter * |
1410 | devlink_health_reporter_create(struct devlink *devlink, | |
1411 | const struct devlink_health_reporter_ops *ops, | |
ba7d16c7 | 1412 | u64 graceful_period, void *priv); |
15c724b9 VT |
1413 | |
1414 | struct devlink_health_reporter * | |
1415 | devlink_port_health_reporter_create(struct devlink_port *port, | |
1416 | const struct devlink_health_reporter_ops *ops, | |
1417 | u64 graceful_period, void *priv); | |
1418 | ||
a0bdcc59 EBE |
1419 | void |
1420 | devlink_health_reporter_destroy(struct devlink_health_reporter *reporter); | |
1421 | ||
15c724b9 VT |
1422 | void |
1423 | devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter); | |
1424 | ||
a0bdcc59 EBE |
1425 | void * |
1426 | devlink_health_reporter_priv(struct devlink_health_reporter *reporter); | |
c8e1da0b EBE |
1427 | int devlink_health_report(struct devlink_health_reporter *reporter, |
1428 | const char *msg, void *priv_ctx); | |
3167b27a EBE |
1429 | void |
1430 | devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, | |
1431 | enum devlink_health_reporter_state state); | |
6181e5cb VG |
1432 | void |
1433 | devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter); | |
a0bdcc59 | 1434 | |
2670ac26 JP |
1435 | bool devlink_is_reload_failed(const struct devlink *devlink); |
1436 | ||
191ed202 JP |
1437 | void devlink_flash_update_begin_notify(struct devlink *devlink); |
1438 | void devlink_flash_update_end_notify(struct devlink *devlink); | |
1439 | void devlink_flash_update_status_notify(struct devlink *devlink, | |
1440 | const char *status_msg, | |
1441 | const char *component, | |
1442 | unsigned long done, | |
1443 | unsigned long total); | |
f92970c6 SN |
1444 | void devlink_flash_update_timeout_notify(struct devlink *devlink, |
1445 | const char *status_msg, | |
1446 | const char *component, | |
1447 | unsigned long timeout); | |
191ed202 | 1448 | |
0f420b6c IS |
1449 | int devlink_traps_register(struct devlink *devlink, |
1450 | const struct devlink_trap *traps, | |
1451 | size_t traps_count, void *priv); | |
1452 | void devlink_traps_unregister(struct devlink *devlink, | |
1453 | const struct devlink_trap *traps, | |
1454 | size_t traps_count); | |
5a2e106c JP |
1455 | void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, |
1456 | void *trap_ctx, struct devlink_port *in_devlink_port, | |
1457 | const struct flow_action_cookie *fa_cookie); | |
0f420b6c | 1458 | void *devlink_trap_ctx_priv(void *trap_ctx); |
95ad9555 IS |
1459 | int devlink_trap_groups_register(struct devlink *devlink, |
1460 | const struct devlink_trap_group *groups, | |
1461 | size_t groups_count); | |
1462 | void devlink_trap_groups_unregister(struct devlink *devlink, | |
1463 | const struct devlink_trap_group *groups, | |
1464 | size_t groups_count); | |
1e8c6619 IS |
1465 | int |
1466 | devlink_trap_policers_register(struct devlink *devlink, | |
1467 | const struct devlink_trap_policer *policers, | |
1468 | size_t policers_count); | |
1469 | void | |
1470 | devlink_trap_policers_unregister(struct devlink *devlink, | |
1471 | const struct devlink_trap_policer *policers, | |
1472 | size_t policers_count); | |
0f420b6c | 1473 | |
f6b19b35 JP |
1474 | #if IS_ENABLED(CONFIG_NET_DEVLINK) |
1475 | ||
f4b6bcc7 JK |
1476 | void devlink_compat_running_version(struct net_device *dev, |
1477 | char *buf, size_t len); | |
1478 | int devlink_compat_flash_update(struct net_device *dev, const char *file_name); | |
af3836df JP |
1479 | int devlink_compat_phys_port_name_get(struct net_device *dev, |
1480 | char *name, size_t len); | |
7e1146e8 JP |
1481 | int devlink_compat_switch_id_get(struct net_device *dev, |
1482 | struct netdev_phys_item_id *ppid); | |
f4b6bcc7 | 1483 | |
bfcd3a46 JP |
1484 | #else |
1485 | ||
ddb6e99e JK |
1486 | static inline void |
1487 | devlink_compat_running_version(struct net_device *dev, char *buf, size_t len) | |
1488 | { | |
1489 | } | |
4eceba17 JK |
1490 | |
1491 | static inline int | |
1492 | devlink_compat_flash_update(struct net_device *dev, const char *file_name) | |
1493 | { | |
1494 | return -EOPNOTSUPP; | |
1495 | } | |
f6b19b35 | 1496 | |
af3836df JP |
1497 | static inline int |
1498 | devlink_compat_phys_port_name_get(struct net_device *dev, | |
1499 | char *name, size_t len) | |
1500 | { | |
1501 | return -EOPNOTSUPP; | |
1502 | } | |
1503 | ||
7e1146e8 JP |
1504 | static inline int |
1505 | devlink_compat_switch_id_get(struct net_device *dev, | |
1506 | struct netdev_phys_item_id *ppid) | |
1507 | { | |
1508 | return -EOPNOTSUPP; | |
1509 | } | |
1510 | ||
ddb6e99e JK |
1511 | #endif |
1512 | ||
bfcd3a46 | 1513 | #endif /* _NET_DEVLINK_H_ */ |