Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 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; |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 27 | struct list_head sb_list; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 28 | struct list_head dpipe_table_list; |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 29 | struct list_head resource_list; |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 30 | struct list_head param_list; |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 31 | struct list_head region_list; |
Alex Vesker | ccadfa4 | 2018-07-12 15:13:09 +0300 | [diff] [blame] | 32 | u32 snapshot_id; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 33 | struct devlink_dpipe_headers *dpipe_headers; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 34 | const struct devlink_ops *ops; |
| 35 | struct device *dev; |
| 36 | possible_net_t _net; |
Arkadi Sharshevsky | 2406e7e | 2018-01-15 08:59:02 +0100 | [diff] [blame] | 37 | struct mutex lock; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 38 | char priv[0] __aligned(NETDEV_ALIGN); |
| 39 | }; |
| 40 | |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 41 | struct devlink_port_attrs { |
| 42 | bool set; |
Jiri Pirko | 5ec1380 | 2018-05-18 09:29:01 +0200 | [diff] [blame] | 43 | enum devlink_port_flavour flavour; |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 44 | u32 port_number; /* same value as "split group" */ |
| 45 | bool split; |
| 46 | u32 split_subport_number; |
| 47 | }; |
| 48 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 49 | struct devlink_port { |
| 50 | struct list_head list; |
Vasundhara Volam | 39e6160 | 2019-01-28 18:00:20 +0530 | [diff] [blame] | 51 | struct list_head param_list; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 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; |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 58 | struct devlink_port_attrs attrs; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 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 | |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 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 |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 194 | * @counters_enabled: indicates if counters are active |
| 195 | * @counter_control_extern: indicates if counter control is in dpipe or |
| 196 | * external tool |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 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 |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 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; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 207 | bool counters_enabled; |
| 208 | bool counter_control_extern; |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 209 | bool resource_valid; |
| 210 | u64 resource_id; |
| 211 | u64 resource_units; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 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 |
Arkadi Sharshevsky | ffd3cdc | 2017-08-24 08:40:02 +0200 | [diff] [blame] | 224 | * @size_get - get size |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 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); |
Arkadi Sharshevsky | ffd3cdc | 2017-08-24 08:40:02 +0200 | [diff] [blame] | 232 | u64 (*size_get)(void *priv); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 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 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 245 | /** |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 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 | |
Jiri Pirko | 77d2709 | 2018-02-28 13:12:09 +0100 | [diff] [blame] | 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 | |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 271 | typedef u64 devlink_resource_occ_get_t(void *priv); |
| 272 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 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 |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 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; |
Jiri Pirko | 77d2709 | 2018-02-28 13:12:09 +0100 | [diff] [blame] | 293 | struct devlink_resource_size_params size_params; |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 294 | struct list_head list; |
| 295 | struct list_head resource_list; |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 296 | devlink_resource_occ_get_t *occ_get; |
| 297 | void *occ_get_priv; |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 298 | }; |
| 299 | |
| 300 | #define DEVLINK_RESOURCE_ID_PARENT_TOP 0 |
| 301 | |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 302 | #define __DEVLINK_PARAM_MAX_STRING_VALUE 32 |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 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; |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 315 | char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE]; |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 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 |
Moshe Shemesh | e3b7ca1 | 2018-07-04 14:30:30 +0300 | [diff] [blame] | 334 | * @validate: validate input value is applicable (within value range, etc.) |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 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); |
Moshe Shemesh | e3b7ca1 | 2018-07-04 14:30:30 +0300 | [diff] [blame] | 349 | int (*validate)(struct devlink *devlink, u32 id, |
| 350 | union devlink_param_value val, |
| 351 | struct netlink_ext_ack *extack); |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 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 { |
Moshe Shemesh | 036467c | 2018-07-04 14:30:33 +0300 | [diff] [blame] | 362 | DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, |
| 363 | DEVLINK_PARAM_GENERIC_ID_MAX_MACS, |
Vasundhara Volam | f567bcd | 2018-07-04 14:30:36 +0300 | [diff] [blame] | 364 | DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, |
Alex Vesker | f6a69885 | 2018-07-12 15:13:17 +0300 | [diff] [blame] | 365 | DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, |
Vasundhara Volam | e3b5106 | 2018-10-04 11:13:44 +0530 | [diff] [blame] | 366 | DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, |
Vasundhara Volam | f61cba4 | 2018-10-04 11:13:45 +0530 | [diff] [blame] | 367 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, |
Vasundhara Volam | 1651178 | 2018-10-04 11:13:46 +0530 | [diff] [blame] | 368 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, |
Shalom Toledo | 846e980 | 2018-12-03 07:58:59 +0000 | [diff] [blame] | 369 | DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, |
Vasundhara Volam | b639583 | 2019-01-28 18:00:26 +0530 | [diff] [blame] | 370 | DEVLINK_PARAM_GENERIC_ID_WOL, |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 371 | |
| 372 | /* add new param generic ids above here*/ |
| 373 | __DEVLINK_PARAM_GENERIC_ID_MAX, |
| 374 | DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, |
| 375 | }; |
| 376 | |
Vasundhara Volam | b639583 | 2019-01-28 18:00:26 +0530 | [diff] [blame] | 377 | enum devlink_param_wol_types { |
| 378 | DEVLINK_PARAM_WAKE_MAGIC = (1 << 0), |
| 379 | }; |
| 380 | |
Moshe Shemesh | 036467c | 2018-07-04 14:30:33 +0300 | [diff] [blame] | 381 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" |
| 382 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 383 | |
| 384 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" |
| 385 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 |
| 386 | |
Vasundhara Volam | f567bcd | 2018-07-04 14:30:36 +0300 | [diff] [blame] | 387 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" |
| 388 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 389 | |
Alex Vesker | f6a69885 | 2018-07-12 15:13:17 +0300 | [diff] [blame] | 390 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" |
| 391 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 392 | |
Vasundhara Volam | e3b5106 | 2018-10-04 11:13:44 +0530 | [diff] [blame] | 393 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" |
| 394 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 395 | |
Vasundhara Volam | f61cba4 | 2018-10-04 11:13:45 +0530 | [diff] [blame] | 396 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" |
| 397 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 |
| 398 | |
Vasundhara Volam | 1651178 | 2018-10-04 11:13:46 +0530 | [diff] [blame] | 399 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" |
| 400 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 |
| 401 | |
Shalom Toledo | 846e980 | 2018-12-03 07:58:59 +0000 | [diff] [blame] | 402 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy" |
| 403 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8 |
| 404 | |
Vasundhara Volam | b639583 | 2019-01-28 18:00:26 +0530 | [diff] [blame] | 405 | #define DEVLINK_PARAM_GENERIC_WOL_NAME "wake_on_lan" |
| 406 | #define DEVLINK_PARAM_GENERIC_WOL_TYPE DEVLINK_PARAM_TYPE_U8 |
| 407 | |
Moshe Shemesh | 036467c | 2018-07-04 14:30:33 +0300 | [diff] [blame] | 408 | #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ |
| 409 | { \ |
| 410 | .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ |
| 411 | .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ |
| 412 | .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ |
| 413 | .generic = true, \ |
| 414 | .supported_cmodes = _cmodes, \ |
| 415 | .get = _get, \ |
| 416 | .set = _set, \ |
| 417 | .validate = _validate, \ |
| 418 | } |
| 419 | |
| 420 | #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ |
| 421 | { \ |
| 422 | .id = _id, \ |
| 423 | .name = _name, \ |
| 424 | .type = _type, \ |
| 425 | .supported_cmodes = _cmodes, \ |
| 426 | .get = _get, \ |
| 427 | .set = _set, \ |
| 428 | .validate = _validate, \ |
| 429 | } |
| 430 | |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 431 | struct devlink_region; |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 432 | struct devlink_info_req; |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 433 | |
Alex Vesker | d7e5272 | 2018-07-12 15:13:10 +0300 | [diff] [blame] | 434 | typedef void devlink_snapshot_data_dest_t(const void *data); |
| 435 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 436 | struct devlink_ops { |
David Ahern | ac0fc8a | 2018-06-05 08:14:09 -0700 | [diff] [blame] | 437 | int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack); |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 438 | int (*port_type_set)(struct devlink_port *devlink_port, |
| 439 | enum devlink_port_type port_type); |
| 440 | int (*port_split)(struct devlink *devlink, unsigned int port_index, |
David Ahern | ac0fc8a | 2018-06-05 08:14:09 -0700 | [diff] [blame] | 441 | unsigned int count, struct netlink_ext_ack *extack); |
| 442 | int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, |
| 443 | struct netlink_ext_ack *extack); |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 444 | int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, |
| 445 | u16 pool_index, |
| 446 | struct devlink_sb_pool_info *pool_info); |
| 447 | int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, |
| 448 | u16 pool_index, u32 size, |
| 449 | enum devlink_sb_threshold_type threshold_type); |
| 450 | int (*sb_port_pool_get)(struct devlink_port *devlink_port, |
| 451 | unsigned int sb_index, u16 pool_index, |
| 452 | u32 *p_threshold); |
| 453 | int (*sb_port_pool_set)(struct devlink_port *devlink_port, |
| 454 | unsigned int sb_index, u16 pool_index, |
| 455 | u32 threshold); |
| 456 | int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, |
| 457 | unsigned int sb_index, |
| 458 | u16 tc_index, |
| 459 | enum devlink_sb_pool_type pool_type, |
| 460 | u16 *p_pool_index, u32 *p_threshold); |
| 461 | int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, |
| 462 | unsigned int sb_index, |
| 463 | u16 tc_index, |
| 464 | enum devlink_sb_pool_type pool_type, |
| 465 | u16 pool_index, u32 threshold); |
Jiri Pirko | df38daf | 2016-04-14 18:19:14 +0200 | [diff] [blame] | 466 | int (*sb_occ_snapshot)(struct devlink *devlink, |
| 467 | unsigned int sb_index); |
| 468 | int (*sb_occ_max_clear)(struct devlink *devlink, |
| 469 | unsigned int sb_index); |
| 470 | int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, |
| 471 | unsigned int sb_index, u16 pool_index, |
| 472 | u32 *p_cur, u32 *p_max); |
| 473 | int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, |
| 474 | unsigned int sb_index, |
| 475 | u16 tc_index, |
| 476 | enum devlink_sb_pool_type pool_type, |
| 477 | u32 *p_cur, u32 *p_max); |
Or Gerlitz | 08f4b59 | 2016-07-01 14:51:01 +0300 | [diff] [blame] | 478 | |
| 479 | int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); |
Eli Britstein | db7ff19 | 2018-08-15 16:02:18 +0300 | [diff] [blame] | 480 | int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, |
| 481 | struct netlink_ext_ack *extack); |
Roi Dayan | 59bfde0 | 2016-11-22 23:09:57 +0200 | [diff] [blame] | 482 | int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); |
Eli Britstein | db7ff19 | 2018-08-15 16:02:18 +0300 | [diff] [blame] | 483 | int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, |
| 484 | struct netlink_ext_ack *extack); |
Roi Dayan | f43e9b0 | 2016-09-25 13:52:44 +0300 | [diff] [blame] | 485 | int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode); |
Eli Britstein | db7ff19 | 2018-08-15 16:02:18 +0300 | [diff] [blame] | 486 | int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode, |
| 487 | struct netlink_ext_ack *extack); |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 488 | int (*info_get)(struct devlink *devlink, struct devlink_info_req *req, |
| 489 | struct netlink_ext_ack *extack); |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 490 | }; |
| 491 | |
| 492 | static inline void *devlink_priv(struct devlink *devlink) |
| 493 | { |
| 494 | BUG_ON(!devlink); |
| 495 | return &devlink->priv; |
| 496 | } |
| 497 | |
| 498 | static inline struct devlink *priv_to_devlink(void *priv) |
| 499 | { |
| 500 | BUG_ON(!priv); |
| 501 | return container_of(priv, struct devlink, priv); |
| 502 | } |
| 503 | |
| 504 | struct ib_device; |
| 505 | |
| 506 | #if IS_ENABLED(CONFIG_NET_DEVLINK) |
| 507 | |
| 508 | struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); |
| 509 | int devlink_register(struct devlink *devlink, struct device *dev); |
| 510 | void devlink_unregister(struct devlink *devlink); |
| 511 | void devlink_free(struct devlink *devlink); |
| 512 | int devlink_port_register(struct devlink *devlink, |
| 513 | struct devlink_port *devlink_port, |
| 514 | unsigned int port_index); |
| 515 | void devlink_port_unregister(struct devlink_port *devlink_port); |
| 516 | void devlink_port_type_eth_set(struct devlink_port *devlink_port, |
| 517 | struct net_device *netdev); |
| 518 | void devlink_port_type_ib_set(struct devlink_port *devlink_port, |
| 519 | struct ib_device *ibdev); |
| 520 | void devlink_port_type_clear(struct devlink_port *devlink_port); |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 521 | void devlink_port_attrs_set(struct devlink_port *devlink_port, |
Jiri Pirko | 5ec1380 | 2018-05-18 09:29:01 +0200 | [diff] [blame] | 522 | enum devlink_port_flavour flavour, |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 523 | u32 port_number, bool split, |
| 524 | u32 split_subport_number); |
Jiri Pirko | 08474c1 | 2018-05-18 09:29:02 +0200 | [diff] [blame] | 525 | int devlink_port_get_phys_port_name(struct devlink_port *devlink_port, |
| 526 | char *name, size_t len); |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 527 | int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, |
| 528 | u32 size, u16 ingress_pools_count, |
| 529 | u16 egress_pools_count, u16 ingress_tc_count, |
| 530 | u16 egress_tc_count); |
| 531 | void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 532 | int devlink_dpipe_table_register(struct devlink *devlink, |
| 533 | const char *table_name, |
| 534 | struct devlink_dpipe_table_ops *table_ops, |
Arkadi Sharshevsky | ffd3cdc | 2017-08-24 08:40:02 +0200 | [diff] [blame] | 535 | void *priv, bool counter_control_extern); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 536 | void devlink_dpipe_table_unregister(struct devlink *devlink, |
| 537 | const char *table_name); |
| 538 | int devlink_dpipe_headers_register(struct devlink *devlink, |
| 539 | struct devlink_dpipe_headers *dpipe_headers); |
| 540 | void devlink_dpipe_headers_unregister(struct devlink *devlink); |
| 541 | bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, |
| 542 | const char *table_name); |
| 543 | int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); |
| 544 | int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, |
| 545 | struct devlink_dpipe_entry *entry); |
| 546 | int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx); |
Arkadi Sharshevsky | 3580732 | 2017-08-24 08:40:03 +0200 | [diff] [blame] | 547 | void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 548 | int devlink_dpipe_action_put(struct sk_buff *skb, |
| 549 | struct devlink_dpipe_action *action); |
| 550 | int devlink_dpipe_match_put(struct sk_buff *skb, |
| 551 | struct devlink_dpipe_match *match); |
Arkadi Sharshevsky | 1177009 | 2017-08-24 08:39:59 +0200 | [diff] [blame] | 552 | extern struct devlink_dpipe_header devlink_dpipe_header_ethernet; |
Arkadi Sharshevsky | 3fb886e | 2017-08-24 08:40:00 +0200 | [diff] [blame] | 553 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv4; |
Arkadi Sharshevsky | 1797f5b | 2017-08-31 17:59:12 +0200 | [diff] [blame] | 554 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv6; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 555 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 556 | int devlink_resource_register(struct devlink *devlink, |
| 557 | const char *resource_name, |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 558 | u64 resource_size, |
| 559 | u64 resource_id, |
| 560 | u64 parent_resource_id, |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 561 | const struct devlink_resource_size_params *size_params); |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 562 | void devlink_resources_unregister(struct devlink *devlink, |
| 563 | struct devlink_resource *resource); |
| 564 | int devlink_resource_size_get(struct devlink *devlink, |
| 565 | u64 resource_id, |
| 566 | u64 *p_resource_size); |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 567 | int devlink_dpipe_table_resource_set(struct devlink *devlink, |
| 568 | const char *table_name, u64 resource_id, |
| 569 | u64 resource_units); |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 570 | void devlink_resource_occ_get_register(struct devlink *devlink, |
| 571 | u64 resource_id, |
| 572 | devlink_resource_occ_get_t *occ_get, |
| 573 | void *occ_get_priv); |
| 574 | void devlink_resource_occ_get_unregister(struct devlink *devlink, |
| 575 | u64 resource_id); |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 576 | int devlink_params_register(struct devlink *devlink, |
| 577 | const struct devlink_param *params, |
| 578 | size_t params_count); |
| 579 | void devlink_params_unregister(struct devlink *devlink, |
| 580 | const struct devlink_param *params, |
| 581 | size_t params_count); |
Vasundhara Volam | 39e6160 | 2019-01-28 18:00:20 +0530 | [diff] [blame] | 582 | int devlink_port_params_register(struct devlink_port *devlink_port, |
| 583 | const struct devlink_param *params, |
| 584 | size_t params_count); |
| 585 | void devlink_port_params_unregister(struct devlink_port *devlink_port, |
| 586 | const struct devlink_param *params, |
| 587 | size_t params_count); |
Moshe Shemesh | ec01aeb | 2018-07-04 14:30:31 +0300 | [diff] [blame] | 588 | int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, |
| 589 | union devlink_param_value *init_val); |
| 590 | int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, |
| 591 | union devlink_param_value init_val); |
Vasundhara Volam | ffd19b9 | 2019-01-28 18:00:23 +0530 | [diff] [blame] | 592 | int |
| 593 | devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port, |
| 594 | u32 param_id, |
| 595 | union devlink_param_value *init_val); |
Vasundhara Volam | 5473a7b | 2019-01-28 18:00:24 +0530 | [diff] [blame] | 596 | int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port, |
| 597 | u32 param_id, |
| 598 | union devlink_param_value init_val); |
Moshe Shemesh | ea601e1 | 2018-07-04 14:30:32 +0300 | [diff] [blame] | 599 | void devlink_param_value_changed(struct devlink *devlink, u32 param_id); |
Vasundhara Volam | c1e5786d | 2019-01-28 18:00:25 +0530 | [diff] [blame] | 600 | void devlink_port_param_value_changed(struct devlink_port *devlink_port, |
| 601 | u32 param_id); |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 602 | void devlink_param_value_str_fill(union devlink_param_value *dst_val, |
| 603 | const char *src); |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 604 | struct devlink_region *devlink_region_create(struct devlink *devlink, |
| 605 | const char *region_name, |
| 606 | u32 region_max_snapshots, |
| 607 | u64 region_size); |
| 608 | void devlink_region_destroy(struct devlink_region *region); |
Alex Vesker | ccadfa4 | 2018-07-12 15:13:09 +0300 | [diff] [blame] | 609 | u32 devlink_region_shapshot_id_get(struct devlink *devlink); |
Alex Vesker | d7e5272 | 2018-07-12 15:13:10 +0300 | [diff] [blame] | 610 | int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, |
| 611 | u8 *data, u32 snapshot_id, |
| 612 | devlink_snapshot_data_dest_t *data_destructor); |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 613 | int devlink_info_serial_number_put(struct devlink_info_req *req, |
| 614 | const char *sn); |
| 615 | int devlink_info_driver_name_put(struct devlink_info_req *req, |
| 616 | const char *name); |
Jakub Kicinski | fc6fae7 | 2019-01-31 10:50:41 -0800 | [diff] [blame^] | 617 | int devlink_info_version_fixed_put(struct devlink_info_req *req, |
| 618 | const char *version_name, |
| 619 | const char *version_value); |
| 620 | int devlink_info_version_stored_put(struct devlink_info_req *req, |
| 621 | const char *version_name, |
| 622 | const char *version_value); |
| 623 | int devlink_info_version_running_put(struct devlink_info_req *req, |
| 624 | const char *version_name, |
| 625 | const char *version_value); |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 626 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 627 | #else |
| 628 | |
| 629 | static inline struct devlink *devlink_alloc(const struct devlink_ops *ops, |
| 630 | size_t priv_size) |
| 631 | { |
| 632 | return kzalloc(sizeof(struct devlink) + priv_size, GFP_KERNEL); |
| 633 | } |
| 634 | |
| 635 | static inline int devlink_register(struct devlink *devlink, struct device *dev) |
| 636 | { |
| 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | static inline void devlink_unregister(struct devlink *devlink) |
| 641 | { |
| 642 | } |
| 643 | |
| 644 | static inline void devlink_free(struct devlink *devlink) |
| 645 | { |
| 646 | kfree(devlink); |
| 647 | } |
| 648 | |
| 649 | static inline int devlink_port_register(struct devlink *devlink, |
| 650 | struct devlink_port *devlink_port, |
| 651 | unsigned int port_index) |
| 652 | { |
| 653 | return 0; |
| 654 | } |
| 655 | |
| 656 | static inline void devlink_port_unregister(struct devlink_port *devlink_port) |
| 657 | { |
| 658 | } |
| 659 | |
| 660 | static inline void devlink_port_type_eth_set(struct devlink_port *devlink_port, |
| 661 | struct net_device *netdev) |
| 662 | { |
| 663 | } |
| 664 | |
| 665 | static inline void devlink_port_type_ib_set(struct devlink_port *devlink_port, |
| 666 | struct ib_device *ibdev) |
| 667 | { |
| 668 | } |
| 669 | |
| 670 | static inline void devlink_port_type_clear(struct devlink_port *devlink_port) |
| 671 | { |
| 672 | } |
| 673 | |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 674 | static inline void devlink_port_attrs_set(struct devlink_port *devlink_port, |
Jiri Pirko | 5ec1380 | 2018-05-18 09:29:01 +0200 | [diff] [blame] | 675 | enum devlink_port_flavour flavour, |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 676 | u32 port_number, bool split, |
| 677 | u32 split_subport_number) |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 678 | { |
| 679 | } |
| 680 | |
Jiri Pirko | 08474c1 | 2018-05-18 09:29:02 +0200 | [diff] [blame] | 681 | static inline int |
| 682 | devlink_port_get_phys_port_name(struct devlink_port *devlink_port, |
| 683 | char *name, size_t len) |
| 684 | { |
| 685 | return -EOPNOTSUPP; |
| 686 | } |
| 687 | |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 688 | static inline int devlink_sb_register(struct devlink *devlink, |
| 689 | unsigned int sb_index, u32 size, |
| 690 | u16 ingress_pools_count, |
Jiri Pirko | de33efd | 2016-04-15 09:17:08 +0200 | [diff] [blame] | 691 | u16 egress_pools_count, |
| 692 | u16 ingress_tc_count, |
| 693 | u16 egress_tc_count) |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 694 | { |
| 695 | return 0; |
| 696 | } |
| 697 | |
| 698 | static inline void devlink_sb_unregister(struct devlink *devlink, |
| 699 | unsigned int sb_index) |
| 700 | { |
| 701 | } |
| 702 | |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 703 | static inline int |
| 704 | devlink_dpipe_table_register(struct devlink *devlink, |
| 705 | const char *table_name, |
| 706 | struct devlink_dpipe_table_ops *table_ops, |
David S. Miller | 790c605 | 2017-08-24 18:10:46 -0700 | [diff] [blame] | 707 | void *priv, bool counter_control_extern) |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 708 | { |
| 709 | return 0; |
| 710 | } |
| 711 | |
| 712 | static inline void devlink_dpipe_table_unregister(struct devlink *devlink, |
| 713 | const char *table_name) |
| 714 | { |
| 715 | } |
| 716 | |
| 717 | static inline int devlink_dpipe_headers_register(struct devlink *devlink, |
| 718 | struct devlink_dpipe_headers * |
| 719 | dpipe_headers) |
| 720 | { |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | static inline void devlink_dpipe_headers_unregister(struct devlink *devlink) |
| 725 | { |
| 726 | } |
| 727 | |
| 728 | static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, |
| 729 | const char *table_name) |
| 730 | { |
| 731 | return false; |
| 732 | } |
| 733 | |
| 734 | static inline int |
| 735 | devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx) |
| 736 | { |
| 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | static inline int |
| 741 | devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, |
| 742 | struct devlink_dpipe_entry *entry) |
| 743 | { |
| 744 | return 0; |
| 745 | } |
| 746 | |
| 747 | static inline int |
| 748 | devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx) |
| 749 | { |
| 750 | return 0; |
| 751 | } |
| 752 | |
Arkadi Sharshevsky | 3580732 | 2017-08-24 08:40:03 +0200 | [diff] [blame] | 753 | static inline void |
| 754 | devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry) |
| 755 | { |
| 756 | } |
| 757 | |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 758 | static inline int |
| 759 | devlink_dpipe_action_put(struct sk_buff *skb, |
| 760 | struct devlink_dpipe_action *action) |
| 761 | { |
| 762 | return 0; |
| 763 | } |
| 764 | |
| 765 | static inline int |
| 766 | devlink_dpipe_match_put(struct sk_buff *skb, |
| 767 | struct devlink_dpipe_match *match) |
| 768 | { |
| 769 | return 0; |
| 770 | } |
| 771 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 772 | static inline int |
| 773 | devlink_resource_register(struct devlink *devlink, |
| 774 | const char *resource_name, |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 775 | u64 resource_size, |
| 776 | u64 resource_id, |
| 777 | u64 parent_resource_id, |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 778 | const struct devlink_resource_size_params *size_params) |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 779 | { |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | static inline void |
| 784 | devlink_resources_unregister(struct devlink *devlink, |
| 785 | struct devlink_resource *resource) |
| 786 | { |
| 787 | } |
| 788 | |
| 789 | static inline int |
| 790 | devlink_resource_size_get(struct devlink *devlink, u64 resource_id, |
| 791 | u64 *p_resource_size) |
| 792 | { |
| 793 | return -EOPNOTSUPP; |
| 794 | } |
| 795 | |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 796 | static inline int |
| 797 | devlink_dpipe_table_resource_set(struct devlink *devlink, |
| 798 | const char *table_name, u64 resource_id, |
| 799 | u64 resource_units) |
| 800 | { |
| 801 | return -EOPNOTSUPP; |
| 802 | } |
| 803 | |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 804 | static inline void |
| 805 | devlink_resource_occ_get_register(struct devlink *devlink, |
| 806 | u64 resource_id, |
| 807 | devlink_resource_occ_get_t *occ_get, |
| 808 | void *occ_get_priv) |
| 809 | { |
| 810 | } |
| 811 | |
| 812 | static inline void |
| 813 | devlink_resource_occ_get_unregister(struct devlink *devlink, |
| 814 | u64 resource_id) |
| 815 | { |
| 816 | } |
| 817 | |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 818 | static inline int |
| 819 | devlink_params_register(struct devlink *devlink, |
| 820 | const struct devlink_param *params, |
| 821 | size_t params_count) |
| 822 | { |
| 823 | return 0; |
| 824 | } |
| 825 | |
| 826 | static inline void |
| 827 | devlink_params_unregister(struct devlink *devlink, |
| 828 | const struct devlink_param *params, |
| 829 | size_t params_count) |
| 830 | { |
| 831 | |
| 832 | } |
| 833 | |
Moshe Shemesh | ec01aeb | 2018-07-04 14:30:31 +0300 | [diff] [blame] | 834 | static inline int |
Vasundhara Volam | 39e6160 | 2019-01-28 18:00:20 +0530 | [diff] [blame] | 835 | devlink_port_params_register(struct devlink_port *devlink_port, |
| 836 | const struct devlink_param *params, |
| 837 | size_t params_count) |
| 838 | { |
| 839 | return 0; |
| 840 | } |
| 841 | |
| 842 | static inline void |
| 843 | devlink_port_params_unregister(struct devlink_port *devlink_port, |
| 844 | const struct devlink_param *params, |
| 845 | size_t params_count) |
| 846 | { |
| 847 | } |
| 848 | |
| 849 | static inline int |
Moshe Shemesh | ec01aeb | 2018-07-04 14:30:31 +0300 | [diff] [blame] | 850 | devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, |
| 851 | union devlink_param_value *init_val) |
| 852 | { |
| 853 | return -EOPNOTSUPP; |
| 854 | } |
| 855 | |
| 856 | static inline int |
| 857 | devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, |
| 858 | union devlink_param_value init_val) |
| 859 | { |
| 860 | return -EOPNOTSUPP; |
| 861 | } |
| 862 | |
Vasundhara Volam | ffd19b9 | 2019-01-28 18:00:23 +0530 | [diff] [blame] | 863 | static inline int |
| 864 | devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port, |
| 865 | u32 param_id, |
| 866 | union devlink_param_value *init_val) |
| 867 | { |
| 868 | return -EOPNOTSUPP; |
| 869 | } |
| 870 | |
Vasundhara Volam | 5473a7b | 2019-01-28 18:00:24 +0530 | [diff] [blame] | 871 | static inline int |
| 872 | devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port, |
| 873 | u32 param_id, |
| 874 | union devlink_param_value init_val) |
| 875 | { |
| 876 | return -EOPNOTSUPP; |
| 877 | } |
| 878 | |
Moshe Shemesh | ea601e1 | 2018-07-04 14:30:32 +0300 | [diff] [blame] | 879 | static inline void |
| 880 | devlink_param_value_changed(struct devlink *devlink, u32 param_id) |
| 881 | { |
Moshe Shemesh | ea601e1 | 2018-07-04 14:30:32 +0300 | [diff] [blame] | 882 | } |
| 883 | |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 884 | static inline void |
Vasundhara Volam | c1e5786d | 2019-01-28 18:00:25 +0530 | [diff] [blame] | 885 | devlink_port_param_value_changed(struct devlink_port *devlink_port, |
| 886 | u32 param_id) |
| 887 | { |
| 888 | } |
| 889 | |
| 890 | static inline void |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 891 | devlink_param_value_str_fill(union devlink_param_value *dst_val, |
| 892 | const char *src) |
| 893 | { |
| 894 | } |
| 895 | |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 896 | static inline struct devlink_region * |
| 897 | devlink_region_create(struct devlink *devlink, |
| 898 | const char *region_name, |
| 899 | u32 region_max_snapshots, |
| 900 | u64 region_size) |
| 901 | { |
| 902 | return NULL; |
| 903 | } |
| 904 | |
| 905 | static inline void |
| 906 | devlink_region_destroy(struct devlink_region *region) |
| 907 | { |
| 908 | } |
| 909 | |
Alex Vesker | ccadfa4 | 2018-07-12 15:13:09 +0300 | [diff] [blame] | 910 | static inline u32 |
| 911 | devlink_region_shapshot_id_get(struct devlink *devlink) |
| 912 | { |
| 913 | return 0; |
| 914 | } |
| 915 | |
Alex Vesker | d7e5272 | 2018-07-12 15:13:10 +0300 | [diff] [blame] | 916 | static inline int |
| 917 | devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, |
| 918 | u8 *data, u32 snapshot_id, |
| 919 | devlink_snapshot_data_dest_t *data_destructor) |
| 920 | { |
| 921 | return 0; |
| 922 | } |
| 923 | |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 924 | static inline int |
| 925 | devlink_info_driver_name_put(struct devlink_info_req *req, const char *name) |
| 926 | { |
| 927 | return 0; |
| 928 | } |
| 929 | |
| 930 | static inline int |
| 931 | devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn) |
| 932 | { |
| 933 | return 0; |
| 934 | } |
Jakub Kicinski | fc6fae7 | 2019-01-31 10:50:41 -0800 | [diff] [blame^] | 935 | |
| 936 | static inline int |
| 937 | devlink_info_version_fixed_put(struct devlink_info_req *req, |
| 938 | const char *version_name, |
| 939 | const char *version_value) |
| 940 | { |
| 941 | return 0; |
| 942 | } |
| 943 | |
| 944 | static inline int |
| 945 | devlink_info_version_stored_put(struct devlink_info_req *req, |
| 946 | const char *version_name, |
| 947 | const char *version_value) |
| 948 | { |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | static inline int |
| 953 | devlink_info_version_running_put(struct devlink_info_req *req, |
| 954 | const char *version_name, |
| 955 | const char *version_value) |
| 956 | { |
| 957 | return 0; |
| 958 | } |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 959 | #endif |
| 960 | |
| 961 | #endif /* _NET_DEVLINK_H_ */ |