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