]>
Commit | Line | Data |
---|---|---|
bfcd3a46 JP |
1 | /* |
2 | * include/net/devlink.h - Network physical device Netlink interface | |
3 | * Copyright (c) 2016 Mellanox Technologies. All rights reserved. | |
4 | * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | */ | |
11 | #ifndef _NET_DEVLINK_H_ | |
12 | #define _NET_DEVLINK_H_ | |
13 | ||
14 | #include <linux/device.h> | |
15 | #include <linux/slab.h> | |
16 | #include <linux/gfp.h> | |
17 | #include <linux/list.h> | |
18 | #include <linux/netdevice.h> | |
19 | #include <net/net_namespace.h> | |
20 | #include <uapi/linux/devlink.h> | |
21 | ||
22 | struct devlink_ops; | |
23 | ||
24 | struct devlink { | |
25 | struct list_head list; | |
26 | struct list_head port_list; | |
bf797471 | 27 | struct list_head sb_list; |
1555d204 | 28 | struct list_head dpipe_table_list; |
d9f9b9a4 | 29 | struct list_head resource_list; |
eabaef18 | 30 | struct list_head param_list; |
b16ebe92 | 31 | struct list_head region_list; |
ccadfa44 | 32 | u32 snapshot_id; |
1555d204 | 33 | struct devlink_dpipe_headers *dpipe_headers; |
bfcd3a46 JP |
34 | const struct devlink_ops *ops; |
35 | struct device *dev; | |
36 | possible_net_t _net; | |
2406e7e5 | 37 | struct mutex lock; |
bfcd3a46 JP |
38 | char priv[0] __aligned(NETDEV_ALIGN); |
39 | }; | |
40 | ||
b9ffcbaf JP |
41 | struct devlink_port_attrs { |
42 | bool set; | |
5ec1380a | 43 | enum devlink_port_flavour flavour; |
b9ffcbaf JP |
44 | u32 port_number; /* same value as "split group" */ |
45 | bool split; | |
46 | u32 split_subport_number; | |
47 | }; | |
48 | ||
bfcd3a46 JP |
49 | struct devlink_port { |
50 | struct list_head list; | |
39e6160e | 51 | struct list_head param_list; |
bfcd3a46 JP |
52 | struct devlink *devlink; |
53 | unsigned index; | |
54 | bool registered; | |
55 | enum devlink_port_type type; | |
56 | enum devlink_port_type desired_type; | |
57 | void *type_dev; | |
b9ffcbaf | 58 | struct devlink_port_attrs attrs; |
bfcd3a46 JP |
59 | }; |
60 | ||
bf797471 JP |
61 | struct devlink_sb_pool_info { |
62 | enum devlink_sb_pool_type pool_type; | |
63 | u32 size; | |
64 | enum devlink_sb_threshold_type threshold_type; | |
65 | }; | |
66 | ||
1555d204 AS |
67 | /** |
68 | * struct devlink_dpipe_field - dpipe field object | |
69 | * @name: field name | |
70 | * @id: index inside the headers field array | |
71 | * @bitwidth: bitwidth | |
72 | * @mapping_type: mapping type | |
73 | */ | |
74 | struct devlink_dpipe_field { | |
75 | const char *name; | |
76 | unsigned int id; | |
77 | unsigned int bitwidth; | |
78 | enum devlink_dpipe_field_mapping_type mapping_type; | |
79 | }; | |
80 | ||
81 | /** | |
82 | * struct devlink_dpipe_header - dpipe header object | |
83 | * @name: header name | |
84 | * @id: index, global/local detrmined by global bit | |
85 | * @fields: fields | |
86 | * @fields_count: number of fields | |
87 | * @global: indicates if header is shared like most protocol header | |
88 | * or driver specific | |
89 | */ | |
90 | struct devlink_dpipe_header { | |
91 | const char *name; | |
92 | unsigned int id; | |
93 | struct devlink_dpipe_field *fields; | |
94 | unsigned int fields_count; | |
95 | bool global; | |
96 | }; | |
97 | ||
98 | /** | |
99 | * struct devlink_dpipe_match - represents match operation | |
100 | * @type: type of match | |
101 | * @header_index: header index (packets can have several headers of same | |
102 | * type like in case of tunnels) | |
103 | * @header: header | |
104 | * @fieled_id: field index | |
105 | */ | |
106 | struct devlink_dpipe_match { | |
107 | enum devlink_dpipe_match_type type; | |
108 | unsigned int header_index; | |
109 | struct devlink_dpipe_header *header; | |
110 | unsigned int field_id; | |
111 | }; | |
112 | ||
113 | /** | |
114 | * struct devlink_dpipe_action - represents action operation | |
115 | * @type: type of action | |
116 | * @header_index: header index (packets can have several headers of same | |
117 | * type like in case of tunnels) | |
118 | * @header: header | |
119 | * @fieled_id: field index | |
120 | */ | |
121 | struct devlink_dpipe_action { | |
122 | enum devlink_dpipe_action_type type; | |
123 | unsigned int header_index; | |
124 | struct devlink_dpipe_header *header; | |
125 | unsigned int field_id; | |
126 | }; | |
127 | ||
128 | /** | |
129 | * struct devlink_dpipe_value - represents value of match/action | |
130 | * @action: action | |
131 | * @match: match | |
132 | * @mapping_value: in case the field has some mapping this value | |
133 | * specified the mapping value | |
134 | * @mapping_valid: specify if mapping value is valid | |
135 | * @value_size: value size | |
136 | * @value: value | |
137 | * @mask: bit mask | |
138 | */ | |
139 | struct devlink_dpipe_value { | |
140 | union { | |
141 | struct devlink_dpipe_action *action; | |
142 | struct devlink_dpipe_match *match; | |
143 | }; | |
144 | unsigned int mapping_value; | |
145 | bool mapping_valid; | |
146 | unsigned int value_size; | |
147 | void *value; | |
148 | void *mask; | |
149 | }; | |
150 | ||
151 | /** | |
152 | * struct devlink_dpipe_entry - table entry object | |
153 | * @index: index of the entry in the table | |
154 | * @match_values: match values | |
155 | * @matche_values_count: count of matches tuples | |
156 | * @action_values: actions values | |
157 | * @action_values_count: count of actions values | |
158 | * @counter: value of counter | |
159 | * @counter_valid: Specify if value is valid from hardware | |
160 | */ | |
161 | struct devlink_dpipe_entry { | |
162 | u64 index; | |
163 | struct devlink_dpipe_value *match_values; | |
164 | unsigned int match_values_count; | |
165 | struct devlink_dpipe_value *action_values; | |
166 | unsigned int action_values_count; | |
167 | u64 counter; | |
168 | bool counter_valid; | |
169 | }; | |
170 | ||
171 | /** | |
172 | * struct devlink_dpipe_dump_ctx - context provided to driver in order | |
173 | * to dump | |
174 | * @info: info | |
175 | * @cmd: devlink command | |
176 | * @skb: skb | |
177 | * @nest: top attribute | |
178 | * @hdr: hdr | |
179 | */ | |
180 | struct devlink_dpipe_dump_ctx { | |
181 | struct genl_info *info; | |
182 | enum devlink_command cmd; | |
183 | struct sk_buff *skb; | |
184 | struct nlattr *nest; | |
185 | void *hdr; | |
186 | }; | |
187 | ||
188 | struct devlink_dpipe_table_ops; | |
189 | ||
190 | /** | |
191 | * struct devlink_dpipe_table - table object | |
192 | * @priv: private | |
193 | * @name: table name | |
1555d204 AS |
194 | * @counters_enabled: indicates if counters are active |
195 | * @counter_control_extern: indicates if counter control is in dpipe or | |
196 | * external tool | |
56dc7cd0 AS |
197 | * @resource_valid: Indicate that the resource id is valid |
198 | * @resource_id: relative resource this table is related to | |
199 | * @resource_units: number of resource's unit consumed per table's entry | |
1555d204 AS |
200 | * @table_ops: table operations |
201 | * @rcu: rcu | |
202 | */ | |
203 | struct devlink_dpipe_table { | |
204 | void *priv; | |
205 | struct list_head list; | |
206 | const char *name; | |
1555d204 AS |
207 | bool counters_enabled; |
208 | bool counter_control_extern; | |
56dc7cd0 AS |
209 | bool resource_valid; |
210 | u64 resource_id; | |
211 | u64 resource_units; | |
1555d204 AS |
212 | struct devlink_dpipe_table_ops *table_ops; |
213 | struct rcu_head rcu; | |
214 | }; | |
215 | ||
216 | /** | |
217 | * struct devlink_dpipe_table_ops - dpipe_table ops | |
218 | * @actions_dump - dumps all tables actions | |
219 | * @matches_dump - dumps all tables matches | |
220 | * @entries_dump - dumps all active entries in the table | |
221 | * @counters_set_update - when changing the counter status hardware sync | |
222 | * maybe needed to allocate/free counter related | |
223 | * resources | |
ffd3cdcc | 224 | * @size_get - get size |
1555d204 AS |
225 | */ |
226 | struct devlink_dpipe_table_ops { | |
227 | int (*actions_dump)(void *priv, struct sk_buff *skb); | |
228 | int (*matches_dump)(void *priv, struct sk_buff *skb); | |
229 | int (*entries_dump)(void *priv, bool counters_enabled, | |
230 | struct devlink_dpipe_dump_ctx *dump_ctx); | |
231 | int (*counters_set_update)(void *priv, bool enable); | |
ffd3cdcc | 232 | u64 (*size_get)(void *priv); |
1555d204 AS |
233 | }; |
234 | ||
235 | /** | |
236 | * struct devlink_dpipe_headers - dpipe headers | |
237 | * @headers - header array can be shared (global bit) or driver specific | |
238 | * @headers_count - count of headers | |
239 | */ | |
240 | struct devlink_dpipe_headers { | |
241 | struct devlink_dpipe_header **headers; | |
242 | unsigned int headers_count; | |
243 | }; | |
244 | ||
d9f9b9a4 AS |
245 | /** |
246 | * struct devlink_resource_size_params - resource's size parameters | |
247 | * @size_min: minimum size which can be set | |
248 | * @size_max: maximum size which can be set | |
249 | * @size_granularity: size granularity | |
250 | * @size_unit: resource's basic unit | |
251 | */ | |
252 | struct devlink_resource_size_params { | |
253 | u64 size_min; | |
254 | u64 size_max; | |
255 | u64 size_granularity; | |
256 | enum devlink_resource_unit unit; | |
257 | }; | |
258 | ||
77d27096 JP |
259 | static inline void |
260 | devlink_resource_size_params_init(struct devlink_resource_size_params *size_params, | |
261 | u64 size_min, u64 size_max, | |
262 | u64 size_granularity, | |
263 | enum devlink_resource_unit unit) | |
264 | { | |
265 | size_params->size_min = size_min; | |
266 | size_params->size_max = size_max; | |
267 | size_params->size_granularity = size_granularity; | |
268 | size_params->unit = unit; | |
269 | } | |
270 | ||
fc56be47 JP |
271 | typedef u64 devlink_resource_occ_get_t(void *priv); |
272 | ||
d9f9b9a4 AS |
273 | /** |
274 | * struct devlink_resource - devlink resource | |
275 | * @name: name of the resource | |
276 | * @id: id, per devlink instance | |
277 | * @size: size of the resource | |
278 | * @size_new: updated size of the resource, reload is needed | |
279 | * @size_valid: valid in case the total size of the resource is valid | |
280 | * including its children | |
281 | * @parent: parent resource | |
282 | * @size_params: size parameters | |
283 | * @list: parent list | |
284 | * @resource_list: list of child resources | |
d9f9b9a4 AS |
285 | */ |
286 | struct devlink_resource { | |
287 | const char *name; | |
288 | u64 id; | |
289 | u64 size; | |
290 | u64 size_new; | |
291 | bool size_valid; | |
292 | struct devlink_resource *parent; | |
77d27096 | 293 | struct devlink_resource_size_params size_params; |
d9f9b9a4 AS |
294 | struct list_head list; |
295 | struct list_head resource_list; | |
fc56be47 JP |
296 | devlink_resource_occ_get_t *occ_get; |
297 | void *occ_get_priv; | |
d9f9b9a4 AS |
298 | }; |
299 | ||
300 | #define DEVLINK_RESOURCE_ID_PARENT_TOP 0 | |
301 | ||
bde74ad1 | 302 | #define __DEVLINK_PARAM_MAX_STRING_VALUE 32 |
eabaef18 MS |
303 | enum devlink_param_type { |
304 | DEVLINK_PARAM_TYPE_U8, | |
305 | DEVLINK_PARAM_TYPE_U16, | |
306 | DEVLINK_PARAM_TYPE_U32, | |
307 | DEVLINK_PARAM_TYPE_STRING, | |
308 | DEVLINK_PARAM_TYPE_BOOL, | |
309 | }; | |
310 | ||
311 | union devlink_param_value { | |
312 | u8 vu8; | |
313 | u16 vu16; | |
314 | u32 vu32; | |
bde74ad1 | 315 | char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE]; |
eabaef18 MS |
316 | bool vbool; |
317 | }; | |
318 | ||
319 | struct devlink_param_gset_ctx { | |
320 | union devlink_param_value val; | |
321 | enum devlink_param_cmode cmode; | |
322 | }; | |
323 | ||
324 | /** | |
325 | * struct devlink_param - devlink configuration parameter data | |
326 | * @name: name of the parameter | |
327 | * @generic: indicates if the parameter is generic or driver specific | |
328 | * @type: parameter type | |
329 | * @supported_cmodes: bitmap of supported configuration modes | |
330 | * @get: get parameter value, used for runtime and permanent | |
331 | * configuration modes | |
332 | * @set: set parameter value, used for runtime and permanent | |
333 | * configuration modes | |
e3b7ca18 | 334 | * @validate: validate input value is applicable (within value range, etc.) |
eabaef18 MS |
335 | * |
336 | * This struct should be used by the driver to fill the data for | |
337 | * a parameter it registers. | |
338 | */ | |
339 | struct devlink_param { | |
340 | u32 id; | |
341 | const char *name; | |
342 | bool generic; | |
343 | enum devlink_param_type type; | |
344 | unsigned long supported_cmodes; | |
345 | int (*get)(struct devlink *devlink, u32 id, | |
346 | struct devlink_param_gset_ctx *ctx); | |
347 | int (*set)(struct devlink *devlink, u32 id, | |
348 | struct devlink_param_gset_ctx *ctx); | |
e3b7ca18 MS |
349 | int (*validate)(struct devlink *devlink, u32 id, |
350 | union devlink_param_value val, | |
351 | struct netlink_ext_ack *extack); | |
eabaef18 MS |
352 | }; |
353 | ||
354 | struct devlink_param_item { | |
355 | struct list_head list; | |
356 | const struct devlink_param *param; | |
357 | union devlink_param_value driverinit_value; | |
358 | bool driverinit_value_valid; | |
359 | }; | |
360 | ||
361 | enum devlink_param_generic_id { | |
036467c3 MS |
362 | DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, |
363 | DEVLINK_PARAM_GENERIC_ID_MAX_MACS, | |
f567bcda | 364 | DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, |
f6a69885 | 365 | DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, |
e3b51061 | 366 | DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, |
f61cba42 | 367 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, |
16511789 | 368 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, |
846e980a | 369 | DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, |
eabaef18 MS |
370 | |
371 | /* add new param generic ids above here*/ | |
372 | __DEVLINK_PARAM_GENERIC_ID_MAX, | |
373 | DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, | |
374 | }; | |
375 | ||
036467c3 MS |
376 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" |
377 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL | |
378 | ||
379 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" | |
380 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 | |
381 | ||
f567bcda VV |
382 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" |
383 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL | |
384 | ||
f6a69885 AV |
385 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" |
386 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL | |
387 | ||
e3b51061 VV |
388 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" |
389 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL | |
390 | ||
f61cba42 VV |
391 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" |
392 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 | |
393 | ||
16511789 VV |
394 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" |
395 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 | |
396 | ||
846e980a ST |
397 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy" |
398 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8 | |
399 | ||
036467c3 MS |
400 | #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ |
401 | { \ | |
402 | .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ | |
403 | .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ | |
404 | .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ | |
405 | .generic = true, \ | |
406 | .supported_cmodes = _cmodes, \ | |
407 | .get = _get, \ | |
408 | .set = _set, \ | |
409 | .validate = _validate, \ | |
410 | } | |
411 | ||
412 | #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ | |
413 | { \ | |
414 | .id = _id, \ | |
415 | .name = _name, \ | |
416 | .type = _type, \ | |
417 | .supported_cmodes = _cmodes, \ | |
418 | .get = _get, \ | |
419 | .set = _set, \ | |
420 | .validate = _validate, \ | |
421 | } | |
422 | ||
b16ebe92 AV |
423 | struct devlink_region; |
424 | ||
d7e52722 AV |
425 | typedef void devlink_snapshot_data_dest_t(const void *data); |
426 | ||
bfcd3a46 | 427 | struct devlink_ops { |
ac0fc8a1 | 428 | int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack); |
bfcd3a46 JP |
429 | int (*port_type_set)(struct devlink_port *devlink_port, |
430 | enum devlink_port_type port_type); | |
431 | int (*port_split)(struct devlink *devlink, unsigned int port_index, | |
ac0fc8a1 DA |
432 | unsigned int count, struct netlink_ext_ack *extack); |
433 | int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, | |
434 | struct netlink_ext_ack *extack); | |
bf797471 JP |
435 | int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, |
436 | u16 pool_index, | |
437 | struct devlink_sb_pool_info *pool_info); | |
438 | int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, | |
439 | u16 pool_index, u32 size, | |
440 | enum devlink_sb_threshold_type threshold_type); | |
441 | int (*sb_port_pool_get)(struct devlink_port *devlink_port, | |
442 | unsigned int sb_index, u16 pool_index, | |
443 | u32 *p_threshold); | |
444 | int (*sb_port_pool_set)(struct devlink_port *devlink_port, | |
445 | unsigned int sb_index, u16 pool_index, | |
446 | u32 threshold); | |
447 | int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, | |
448 | unsigned int sb_index, | |
449 | u16 tc_index, | |
450 | enum devlink_sb_pool_type pool_type, | |
451 | u16 *p_pool_index, u32 *p_threshold); | |
452 | int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, | |
453 | unsigned int sb_index, | |
454 | u16 tc_index, | |
455 | enum devlink_sb_pool_type pool_type, | |
456 | u16 pool_index, u32 threshold); | |
df38dafd JP |
457 | int (*sb_occ_snapshot)(struct devlink *devlink, |
458 | unsigned int sb_index); | |
459 | int (*sb_occ_max_clear)(struct devlink *devlink, | |
460 | unsigned int sb_index); | |
461 | int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, | |
462 | unsigned int sb_index, u16 pool_index, | |
463 | u32 *p_cur, u32 *p_max); | |
464 | int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, | |
465 | unsigned int sb_index, | |
466 | u16 tc_index, | |
467 | enum devlink_sb_pool_type pool_type, | |
468 | u32 *p_cur, u32 *p_max); | |
08f4b591 OG |
469 | |
470 | int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); | |
db7ff19e EB |
471 | int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, |
472 | struct netlink_ext_ack *extack); | |
59bfde01 | 473 | int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); |
db7ff19e EB |
474 | int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, |
475 | struct netlink_ext_ack *extack); | |
f43e9b06 | 476 | int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode); |
db7ff19e EB |
477 | int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode, |
478 | struct netlink_ext_ack *extack); | |
bfcd3a46 JP |
479 | }; |
480 | ||
481 | static inline void *devlink_priv(struct devlink *devlink) | |
482 | { | |
483 | BUG_ON(!devlink); | |
484 | return &devlink->priv; | |
485 | } | |
486 | ||
487 | static inline struct devlink *priv_to_devlink(void *priv) | |
488 | { | |
489 | BUG_ON(!priv); | |
490 | return container_of(priv, struct devlink, priv); | |
491 | } | |
492 | ||
493 | struct ib_device; | |
494 | ||
495 | #if IS_ENABLED(CONFIG_NET_DEVLINK) | |
496 | ||
497 | struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); | |
498 | int devlink_register(struct devlink *devlink, struct device *dev); | |
499 | void devlink_unregister(struct devlink *devlink); | |
500 | void devlink_free(struct devlink *devlink); | |
501 | int devlink_port_register(struct devlink *devlink, | |
502 | struct devlink_port *devlink_port, | |
503 | unsigned int port_index); | |
504 | void devlink_port_unregister(struct devlink_port *devlink_port); | |
505 | void devlink_port_type_eth_set(struct devlink_port *devlink_port, | |
506 | struct net_device *netdev); | |
507 | void devlink_port_type_ib_set(struct devlink_port *devlink_port, | |
508 | struct ib_device *ibdev); | |
509 | void devlink_port_type_clear(struct devlink_port *devlink_port); | |
b9ffcbaf | 510 | void devlink_port_attrs_set(struct devlink_port *devlink_port, |
5ec1380a | 511 | enum devlink_port_flavour flavour, |
b9ffcbaf JP |
512 | u32 port_number, bool split, |
513 | u32 split_subport_number); | |
08474c1a JP |
514 | int devlink_port_get_phys_port_name(struct devlink_port *devlink_port, |
515 | char *name, size_t len); | |
bf797471 JP |
516 | int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, |
517 | u32 size, u16 ingress_pools_count, | |
518 | u16 egress_pools_count, u16 ingress_tc_count, | |
519 | u16 egress_tc_count); | |
520 | void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); | |
1555d204 AS |
521 | int devlink_dpipe_table_register(struct devlink *devlink, |
522 | const char *table_name, | |
523 | struct devlink_dpipe_table_ops *table_ops, | |
ffd3cdcc | 524 | void *priv, bool counter_control_extern); |
1555d204 AS |
525 | void devlink_dpipe_table_unregister(struct devlink *devlink, |
526 | const char *table_name); | |
527 | int devlink_dpipe_headers_register(struct devlink *devlink, | |
528 | struct devlink_dpipe_headers *dpipe_headers); | |
529 | void devlink_dpipe_headers_unregister(struct devlink *devlink); | |
530 | bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, | |
531 | const char *table_name); | |
532 | int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); | |
533 | int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, | |
534 | struct devlink_dpipe_entry *entry); | |
535 | int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx); | |
35807324 | 536 | void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); |
1555d204 AS |
537 | int devlink_dpipe_action_put(struct sk_buff *skb, |
538 | struct devlink_dpipe_action *action); | |
539 | int devlink_dpipe_match_put(struct sk_buff *skb, | |
540 | struct devlink_dpipe_match *match); | |
11770091 | 541 | extern struct devlink_dpipe_header devlink_dpipe_header_ethernet; |
3fb886ec | 542 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv4; |
1797f5b3 | 543 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv6; |
bfcd3a46 | 544 | |
d9f9b9a4 AS |
545 | int devlink_resource_register(struct devlink *devlink, |
546 | const char *resource_name, | |
d9f9b9a4 AS |
547 | u64 resource_size, |
548 | u64 resource_id, | |
549 | u64 parent_resource_id, | |
fc56be47 | 550 | const struct devlink_resource_size_params *size_params); |
d9f9b9a4 AS |
551 | void devlink_resources_unregister(struct devlink *devlink, |
552 | struct devlink_resource *resource); | |
553 | int devlink_resource_size_get(struct devlink *devlink, | |
554 | u64 resource_id, | |
555 | u64 *p_resource_size); | |
56dc7cd0 AS |
556 | int devlink_dpipe_table_resource_set(struct devlink *devlink, |
557 | const char *table_name, u64 resource_id, | |
558 | u64 resource_units); | |
fc56be47 JP |
559 | void devlink_resource_occ_get_register(struct devlink *devlink, |
560 | u64 resource_id, | |
561 | devlink_resource_occ_get_t *occ_get, | |
562 | void *occ_get_priv); | |
563 | void devlink_resource_occ_get_unregister(struct devlink *devlink, | |
564 | u64 resource_id); | |
eabaef18 MS |
565 | int devlink_params_register(struct devlink *devlink, |
566 | const struct devlink_param *params, | |
567 | size_t params_count); | |
568 | void devlink_params_unregister(struct devlink *devlink, | |
569 | const struct devlink_param *params, | |
570 | size_t params_count); | |
39e6160e VV |
571 | int devlink_port_params_register(struct devlink_port *devlink_port, |
572 | const struct devlink_param *params, | |
573 | size_t params_count); | |
574 | void devlink_port_params_unregister(struct devlink_port *devlink_port, | |
575 | const struct devlink_param *params, | |
576 | size_t params_count); | |
ec01aeb1 MS |
577 | int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, |
578 | union devlink_param_value *init_val); | |
579 | int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, | |
580 | union devlink_param_value init_val); | |
ea601e17 | 581 | void devlink_param_value_changed(struct devlink *devlink, u32 param_id); |
bde74ad1 MS |
582 | void devlink_param_value_str_fill(union devlink_param_value *dst_val, |
583 | const char *src); | |
b16ebe92 AV |
584 | struct devlink_region *devlink_region_create(struct devlink *devlink, |
585 | const char *region_name, | |
586 | u32 region_max_snapshots, | |
587 | u64 region_size); | |
588 | void devlink_region_destroy(struct devlink_region *region); | |
ccadfa44 | 589 | u32 devlink_region_shapshot_id_get(struct devlink *devlink); |
d7e52722 AV |
590 | int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, |
591 | u8 *data, u32 snapshot_id, | |
592 | devlink_snapshot_data_dest_t *data_destructor); | |
d9f9b9a4 | 593 | |
bfcd3a46 JP |
594 | #else |
595 | ||
596 | static inline struct devlink *devlink_alloc(const struct devlink_ops *ops, | |
597 | size_t priv_size) | |
598 | { | |
599 | return kzalloc(sizeof(struct devlink) + priv_size, GFP_KERNEL); | |
600 | } | |
601 | ||
602 | static inline int devlink_register(struct devlink *devlink, struct device *dev) | |
603 | { | |
604 | return 0; | |
605 | } | |
606 | ||
607 | static inline void devlink_unregister(struct devlink *devlink) | |
608 | { | |
609 | } | |
610 | ||
611 | static inline void devlink_free(struct devlink *devlink) | |
612 | { | |
613 | kfree(devlink); | |
614 | } | |
615 | ||
616 | static inline int devlink_port_register(struct devlink *devlink, | |
617 | struct devlink_port *devlink_port, | |
618 | unsigned int port_index) | |
619 | { | |
620 | return 0; | |
621 | } | |
622 | ||
623 | static inline void devlink_port_unregister(struct devlink_port *devlink_port) | |
624 | { | |
625 | } | |
626 | ||
627 | static inline void devlink_port_type_eth_set(struct devlink_port *devlink_port, | |
628 | struct net_device *netdev) | |
629 | { | |
630 | } | |
631 | ||
632 | static inline void devlink_port_type_ib_set(struct devlink_port *devlink_port, | |
633 | struct ib_device *ibdev) | |
634 | { | |
635 | } | |
636 | ||
637 | static inline void devlink_port_type_clear(struct devlink_port *devlink_port) | |
638 | { | |
639 | } | |
640 | ||
b9ffcbaf | 641 | static inline void devlink_port_attrs_set(struct devlink_port *devlink_port, |
5ec1380a | 642 | enum devlink_port_flavour flavour, |
b9ffcbaf JP |
643 | u32 port_number, bool split, |
644 | u32 split_subport_number) | |
bfcd3a46 JP |
645 | { |
646 | } | |
647 | ||
08474c1a JP |
648 | static inline int |
649 | devlink_port_get_phys_port_name(struct devlink_port *devlink_port, | |
650 | char *name, size_t len) | |
651 | { | |
652 | return -EOPNOTSUPP; | |
653 | } | |
654 | ||
bf797471 JP |
655 | static inline int devlink_sb_register(struct devlink *devlink, |
656 | unsigned int sb_index, u32 size, | |
657 | u16 ingress_pools_count, | |
de33efd0 JP |
658 | u16 egress_pools_count, |
659 | u16 ingress_tc_count, | |
660 | u16 egress_tc_count) | |
bf797471 JP |
661 | { |
662 | return 0; | |
663 | } | |
664 | ||
665 | static inline void devlink_sb_unregister(struct devlink *devlink, | |
666 | unsigned int sb_index) | |
667 | { | |
668 | } | |
669 | ||
1555d204 AS |
670 | static inline int |
671 | devlink_dpipe_table_register(struct devlink *devlink, | |
672 | const char *table_name, | |
673 | struct devlink_dpipe_table_ops *table_ops, | |
790c6056 | 674 | void *priv, bool counter_control_extern) |
1555d204 AS |
675 | { |
676 | return 0; | |
677 | } | |
678 | ||
679 | static inline void devlink_dpipe_table_unregister(struct devlink *devlink, | |
680 | const char *table_name) | |
681 | { | |
682 | } | |
683 | ||
684 | static inline int devlink_dpipe_headers_register(struct devlink *devlink, | |
685 | struct devlink_dpipe_headers * | |
686 | dpipe_headers) | |
687 | { | |
688 | return 0; | |
689 | } | |
690 | ||
691 | static inline void devlink_dpipe_headers_unregister(struct devlink *devlink) | |
692 | { | |
693 | } | |
694 | ||
695 | static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, | |
696 | const char *table_name) | |
697 | { | |
698 | return false; | |
699 | } | |
700 | ||
701 | static inline int | |
702 | devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx) | |
703 | { | |
704 | return 0; | |
705 | } | |
706 | ||
707 | static inline int | |
708 | devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, | |
709 | struct devlink_dpipe_entry *entry) | |
710 | { | |
711 | return 0; | |
712 | } | |
713 | ||
714 | static inline int | |
715 | devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx) | |
716 | { | |
717 | return 0; | |
718 | } | |
719 | ||
35807324 AS |
720 | static inline void |
721 | devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry) | |
722 | { | |
723 | } | |
724 | ||
1555d204 AS |
725 | static inline int |
726 | devlink_dpipe_action_put(struct sk_buff *skb, | |
727 | struct devlink_dpipe_action *action) | |
728 | { | |
729 | return 0; | |
730 | } | |
731 | ||
732 | static inline int | |
733 | devlink_dpipe_match_put(struct sk_buff *skb, | |
734 | struct devlink_dpipe_match *match) | |
735 | { | |
736 | return 0; | |
737 | } | |
738 | ||
d9f9b9a4 AS |
739 | static inline int |
740 | devlink_resource_register(struct devlink *devlink, | |
741 | const char *resource_name, | |
d9f9b9a4 AS |
742 | u64 resource_size, |
743 | u64 resource_id, | |
744 | u64 parent_resource_id, | |
fc56be47 | 745 | const struct devlink_resource_size_params *size_params) |
d9f9b9a4 AS |
746 | { |
747 | return 0; | |
748 | } | |
749 | ||
750 | static inline void | |
751 | devlink_resources_unregister(struct devlink *devlink, | |
752 | struct devlink_resource *resource) | |
753 | { | |
754 | } | |
755 | ||
756 | static inline int | |
757 | devlink_resource_size_get(struct devlink *devlink, u64 resource_id, | |
758 | u64 *p_resource_size) | |
759 | { | |
760 | return -EOPNOTSUPP; | |
761 | } | |
762 | ||
56dc7cd0 AS |
763 | static inline int |
764 | devlink_dpipe_table_resource_set(struct devlink *devlink, | |
765 | const char *table_name, u64 resource_id, | |
766 | u64 resource_units) | |
767 | { | |
768 | return -EOPNOTSUPP; | |
769 | } | |
770 | ||
fc56be47 JP |
771 | static inline void |
772 | devlink_resource_occ_get_register(struct devlink *devlink, | |
773 | u64 resource_id, | |
774 | devlink_resource_occ_get_t *occ_get, | |
775 | void *occ_get_priv) | |
776 | { | |
777 | } | |
778 | ||
779 | static inline void | |
780 | devlink_resource_occ_get_unregister(struct devlink *devlink, | |
781 | u64 resource_id) | |
782 | { | |
783 | } | |
784 | ||
eabaef18 MS |
785 | static inline int |
786 | devlink_params_register(struct devlink *devlink, | |
787 | const struct devlink_param *params, | |
788 | size_t params_count) | |
789 | { | |
790 | return 0; | |
791 | } | |
792 | ||
793 | static inline void | |
794 | devlink_params_unregister(struct devlink *devlink, | |
795 | const struct devlink_param *params, | |
796 | size_t params_count) | |
797 | { | |
798 | ||
799 | } | |
800 | ||
39e6160e VV |
801 | static inline int |
802 | devlink_port_params_register(struct devlink_port *devlink_port, | |
803 | const struct devlink_param *params, | |
804 | size_t params_count) | |
805 | { | |
806 | return 0; | |
807 | } | |
808 | ||
809 | static inline void | |
810 | devlink_port_params_unregister(struct devlink_port *devlink_port, | |
811 | const struct devlink_param *params, | |
812 | size_t params_count) | |
813 | { | |
814 | } | |
815 | ||
ec01aeb1 MS |
816 | static inline int |
817 | devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, | |
818 | union devlink_param_value *init_val) | |
819 | { | |
820 | return -EOPNOTSUPP; | |
821 | } | |
822 | ||
823 | static inline int | |
824 | devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, | |
825 | union devlink_param_value init_val) | |
826 | { | |
827 | return -EOPNOTSUPP; | |
828 | } | |
829 | ||
ea601e17 MS |
830 | static inline void |
831 | devlink_param_value_changed(struct devlink *devlink, u32 param_id) | |
832 | { | |
ea601e17 MS |
833 | } |
834 | ||
bde74ad1 MS |
835 | static inline void |
836 | devlink_param_value_str_fill(union devlink_param_value *dst_val, | |
837 | const char *src) | |
838 | { | |
839 | } | |
840 | ||
b16ebe92 AV |
841 | static inline struct devlink_region * |
842 | devlink_region_create(struct devlink *devlink, | |
843 | const char *region_name, | |
844 | u32 region_max_snapshots, | |
845 | u64 region_size) | |
846 | { | |
847 | return NULL; | |
848 | } | |
849 | ||
850 | static inline void | |
851 | devlink_region_destroy(struct devlink_region *region) | |
852 | { | |
853 | } | |
854 | ||
ccadfa44 AV |
855 | static inline u32 |
856 | devlink_region_shapshot_id_get(struct devlink *devlink) | |
857 | { | |
858 | return 0; | |
859 | } | |
860 | ||
d7e52722 AV |
861 | static inline int |
862 | devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, | |
863 | u8 *data, u32 snapshot_id, | |
864 | devlink_snapshot_data_dest_t *data_destructor) | |
865 | { | |
866 | return 0; | |
867 | } | |
868 | ||
bfcd3a46 JP |
869 | #endif |
870 | ||
871 | #endif /* _NET_DEVLINK_H_ */ |