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 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, 366 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, 367 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, 368 369 /* add new param generic ids above here*/ 370 __DEVLINK_PARAM_GENERIC_ID_MAX, 371 DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, 372 }; 373 374 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" 375 #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL 376 377 #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" 378 #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 379 380 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" 381 #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL 382 383 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" 384 #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL 385 386 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" 387 #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL 388 389 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" 390 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 391 392 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" 393 #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 394 395 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ 396 { \ 397 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ 398 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ 399 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ 400 .generic = true, \ 401 .supported_cmodes = _cmodes, \ 402 .get = _get, \ 403 .set = _set, \ 404 .validate = _validate, \ 405 } 406 407 #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ 408 { \ 409 .id = _id, \ 410 .name = _name, \ 411 .type = _type, \ 412 .supported_cmodes = _cmodes, \ 413 .get = _get, \ 414 .set = _set, \ 415 .validate = _validate, \ 416 } 417 418 struct devlink_region; 419 420 typedef void devlink_snapshot_data_dest_t(const void *data); 421 422 struct devlink_ops { 423 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack); 424 int (*port_type_set)(struct devlink_port *devlink_port, 425 enum devlink_port_type port_type); 426 int (*port_split)(struct devlink *devlink, unsigned int port_index, 427 unsigned int count, struct netlink_ext_ack *extack); 428 int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, 429 struct netlink_ext_ack *extack); 430 int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, 431 u16 pool_index, 432 struct devlink_sb_pool_info *pool_info); 433 int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, 434 u16 pool_index, u32 size, 435 enum devlink_sb_threshold_type threshold_type); 436 int (*sb_port_pool_get)(struct devlink_port *devlink_port, 437 unsigned int sb_index, u16 pool_index, 438 u32 *p_threshold); 439 int (*sb_port_pool_set)(struct devlink_port *devlink_port, 440 unsigned int sb_index, u16 pool_index, 441 u32 threshold); 442 int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, 443 unsigned int sb_index, 444 u16 tc_index, 445 enum devlink_sb_pool_type pool_type, 446 u16 *p_pool_index, u32 *p_threshold); 447 int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, 448 unsigned int sb_index, 449 u16 tc_index, 450 enum devlink_sb_pool_type pool_type, 451 u16 pool_index, u32 threshold); 452 int (*sb_occ_snapshot)(struct devlink *devlink, 453 unsigned int sb_index); 454 int (*sb_occ_max_clear)(struct devlink *devlink, 455 unsigned int sb_index); 456 int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, 457 unsigned int sb_index, u16 pool_index, 458 u32 *p_cur, u32 *p_max); 459 int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, 460 unsigned int sb_index, 461 u16 tc_index, 462 enum devlink_sb_pool_type pool_type, 463 u32 *p_cur, u32 *p_max); 464 465 int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); 466 int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, 467 struct netlink_ext_ack *extack); 468 int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); 469 int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, 470 struct netlink_ext_ack *extack); 471 int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode); 472 int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode, 473 struct netlink_ext_ack *extack); 474 }; 475 476 static inline void *devlink_priv(struct devlink *devlink) 477 { 478 BUG_ON(!devlink); 479 return &devlink->priv; 480 } 481 482 static inline struct devlink *priv_to_devlink(void *priv) 483 { 484 BUG_ON(!priv); 485 return container_of(priv, struct devlink, priv); 486 } 487 488 struct ib_device; 489 490 #if IS_ENABLED(CONFIG_NET_DEVLINK) 491 492 struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); 493 int devlink_register(struct devlink *devlink, struct device *dev); 494 void devlink_unregister(struct devlink *devlink); 495 void devlink_free(struct devlink *devlink); 496 int devlink_port_register(struct devlink *devlink, 497 struct devlink_port *devlink_port, 498 unsigned int port_index); 499 void devlink_port_unregister(struct devlink_port *devlink_port); 500 void devlink_port_type_eth_set(struct devlink_port *devlink_port, 501 struct net_device *netdev); 502 void devlink_port_type_ib_set(struct devlink_port *devlink_port, 503 struct ib_device *ibdev); 504 void devlink_port_type_clear(struct devlink_port *devlink_port); 505 void devlink_port_attrs_set(struct devlink_port *devlink_port, 506 enum devlink_port_flavour flavour, 507 u32 port_number, bool split, 508 u32 split_subport_number); 509 int devlink_port_get_phys_port_name(struct devlink_port *devlink_port, 510 char *name, size_t len); 511 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, 512 u32 size, u16 ingress_pools_count, 513 u16 egress_pools_count, u16 ingress_tc_count, 514 u16 egress_tc_count); 515 void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); 516 int devlink_dpipe_table_register(struct devlink *devlink, 517 const char *table_name, 518 struct devlink_dpipe_table_ops *table_ops, 519 void *priv, bool counter_control_extern); 520 void devlink_dpipe_table_unregister(struct devlink *devlink, 521 const char *table_name); 522 int devlink_dpipe_headers_register(struct devlink *devlink, 523 struct devlink_dpipe_headers *dpipe_headers); 524 void devlink_dpipe_headers_unregister(struct devlink *devlink); 525 bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, 526 const char *table_name); 527 int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); 528 int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, 529 struct devlink_dpipe_entry *entry); 530 int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx); 531 void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); 532 int devlink_dpipe_action_put(struct sk_buff *skb, 533 struct devlink_dpipe_action *action); 534 int devlink_dpipe_match_put(struct sk_buff *skb, 535 struct devlink_dpipe_match *match); 536 extern struct devlink_dpipe_header devlink_dpipe_header_ethernet; 537 extern struct devlink_dpipe_header devlink_dpipe_header_ipv4; 538 extern struct devlink_dpipe_header devlink_dpipe_header_ipv6; 539 540 int devlink_resource_register(struct devlink *devlink, 541 const char *resource_name, 542 u64 resource_size, 543 u64 resource_id, 544 u64 parent_resource_id, 545 const struct devlink_resource_size_params *size_params); 546 void devlink_resources_unregister(struct devlink *devlink, 547 struct devlink_resource *resource); 548 int devlink_resource_size_get(struct devlink *devlink, 549 u64 resource_id, 550 u64 *p_resource_size); 551 int devlink_dpipe_table_resource_set(struct devlink *devlink, 552 const char *table_name, u64 resource_id, 553 u64 resource_units); 554 void devlink_resource_occ_get_register(struct devlink *devlink, 555 u64 resource_id, 556 devlink_resource_occ_get_t *occ_get, 557 void *occ_get_priv); 558 void devlink_resource_occ_get_unregister(struct devlink *devlink, 559 u64 resource_id); 560 int devlink_params_register(struct devlink *devlink, 561 const struct devlink_param *params, 562 size_t params_count); 563 void devlink_params_unregister(struct devlink *devlink, 564 const struct devlink_param *params, 565 size_t params_count); 566 int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, 567 union devlink_param_value *init_val); 568 int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, 569 union devlink_param_value init_val); 570 void devlink_param_value_changed(struct devlink *devlink, u32 param_id); 571 struct devlink_region *devlink_region_create(struct devlink *devlink, 572 const char *region_name, 573 u32 region_max_snapshots, 574 u64 region_size); 575 void devlink_region_destroy(struct devlink_region *region); 576 u32 devlink_region_shapshot_id_get(struct devlink *devlink); 577 int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, 578 u8 *data, u32 snapshot_id, 579 devlink_snapshot_data_dest_t *data_destructor); 580 581 #else 582 583 static inline struct devlink *devlink_alloc(const struct devlink_ops *ops, 584 size_t priv_size) 585 { 586 return kzalloc(sizeof(struct devlink) + priv_size, GFP_KERNEL); 587 } 588 589 static inline int devlink_register(struct devlink *devlink, struct device *dev) 590 { 591 return 0; 592 } 593 594 static inline void devlink_unregister(struct devlink *devlink) 595 { 596 } 597 598 static inline void devlink_free(struct devlink *devlink) 599 { 600 kfree(devlink); 601 } 602 603 static inline int devlink_port_register(struct devlink *devlink, 604 struct devlink_port *devlink_port, 605 unsigned int port_index) 606 { 607 return 0; 608 } 609 610 static inline void devlink_port_unregister(struct devlink_port *devlink_port) 611 { 612 } 613 614 static inline void devlink_port_type_eth_set(struct devlink_port *devlink_port, 615 struct net_device *netdev) 616 { 617 } 618 619 static inline void devlink_port_type_ib_set(struct devlink_port *devlink_port, 620 struct ib_device *ibdev) 621 { 622 } 623 624 static inline void devlink_port_type_clear(struct devlink_port *devlink_port) 625 { 626 } 627 628 static inline void devlink_port_attrs_set(struct devlink_port *devlink_port, 629 enum devlink_port_flavour flavour, 630 u32 port_number, bool split, 631 u32 split_subport_number) 632 { 633 } 634 635 static inline int 636 devlink_port_get_phys_port_name(struct devlink_port *devlink_port, 637 char *name, size_t len) 638 { 639 return -EOPNOTSUPP; 640 } 641 642 static inline int devlink_sb_register(struct devlink *devlink, 643 unsigned int sb_index, u32 size, 644 u16 ingress_pools_count, 645 u16 egress_pools_count, 646 u16 ingress_tc_count, 647 u16 egress_tc_count) 648 { 649 return 0; 650 } 651 652 static inline void devlink_sb_unregister(struct devlink *devlink, 653 unsigned int sb_index) 654 { 655 } 656 657 static inline int 658 devlink_dpipe_table_register(struct devlink *devlink, 659 const char *table_name, 660 struct devlink_dpipe_table_ops *table_ops, 661 void *priv, bool counter_control_extern) 662 { 663 return 0; 664 } 665 666 static inline void devlink_dpipe_table_unregister(struct devlink *devlink, 667 const char *table_name) 668 { 669 } 670 671 static inline int devlink_dpipe_headers_register(struct devlink *devlink, 672 struct devlink_dpipe_headers * 673 dpipe_headers) 674 { 675 return 0; 676 } 677 678 static inline void devlink_dpipe_headers_unregister(struct devlink *devlink) 679 { 680 } 681 682 static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, 683 const char *table_name) 684 { 685 return false; 686 } 687 688 static inline int 689 devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx) 690 { 691 return 0; 692 } 693 694 static inline int 695 devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, 696 struct devlink_dpipe_entry *entry) 697 { 698 return 0; 699 } 700 701 static inline int 702 devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx) 703 { 704 return 0; 705 } 706 707 static inline void 708 devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry) 709 { 710 } 711 712 static inline int 713 devlink_dpipe_action_put(struct sk_buff *skb, 714 struct devlink_dpipe_action *action) 715 { 716 return 0; 717 } 718 719 static inline int 720 devlink_dpipe_match_put(struct sk_buff *skb, 721 struct devlink_dpipe_match *match) 722 { 723 return 0; 724 } 725 726 static inline int 727 devlink_resource_register(struct devlink *devlink, 728 const char *resource_name, 729 u64 resource_size, 730 u64 resource_id, 731 u64 parent_resource_id, 732 const struct devlink_resource_size_params *size_params) 733 { 734 return 0; 735 } 736 737 static inline void 738 devlink_resources_unregister(struct devlink *devlink, 739 struct devlink_resource *resource) 740 { 741 } 742 743 static inline int 744 devlink_resource_size_get(struct devlink *devlink, u64 resource_id, 745 u64 *p_resource_size) 746 { 747 return -EOPNOTSUPP; 748 } 749 750 static inline int 751 devlink_dpipe_table_resource_set(struct devlink *devlink, 752 const char *table_name, u64 resource_id, 753 u64 resource_units) 754 { 755 return -EOPNOTSUPP; 756 } 757 758 static inline void 759 devlink_resource_occ_get_register(struct devlink *devlink, 760 u64 resource_id, 761 devlink_resource_occ_get_t *occ_get, 762 void *occ_get_priv) 763 { 764 } 765 766 static inline void 767 devlink_resource_occ_get_unregister(struct devlink *devlink, 768 u64 resource_id) 769 { 770 } 771 772 static inline int 773 devlink_params_register(struct devlink *devlink, 774 const struct devlink_param *params, 775 size_t params_count) 776 { 777 return 0; 778 } 779 780 static inline void 781 devlink_params_unregister(struct devlink *devlink, 782 const struct devlink_param *params, 783 size_t params_count) 784 { 785 786 } 787 788 static inline int 789 devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, 790 union devlink_param_value *init_val) 791 { 792 return -EOPNOTSUPP; 793 } 794 795 static inline int 796 devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, 797 union devlink_param_value init_val) 798 { 799 return -EOPNOTSUPP; 800 } 801 802 static inline void 803 devlink_param_value_changed(struct devlink *devlink, u32 param_id) 804 { 805 } 806 807 static inline struct devlink_region * 808 devlink_region_create(struct devlink *devlink, 809 const char *region_name, 810 u32 region_max_snapshots, 811 u64 region_size) 812 { 813 return NULL; 814 } 815 816 static inline void 817 devlink_region_destroy(struct devlink_region *region) 818 { 819 } 820 821 static inline u32 822 devlink_region_shapshot_id_get(struct devlink *devlink) 823 { 824 return 0; 825 } 826 827 static inline int 828 devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, 829 u8 *data, u32 snapshot_id, 830 devlink_snapshot_data_dest_t *data_destructor) 831 { 832 return 0; 833 } 834 835 #endif 836 837 #endif /* _NET_DEVLINK_H_ */ 838