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