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