Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 2 | /* |
| 3 | * include/net/devlink.h - Network physical device Netlink interface |
| 4 | * Copyright (c) 2016 Mellanox Technologies. All rights reserved. |
| 5 | * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com> |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 6 | */ |
| 7 | #ifndef _NET_DEVLINK_H_ |
| 8 | #define _NET_DEVLINK_H_ |
| 9 | |
| 10 | #include <linux/device.h> |
| 11 | #include <linux/slab.h> |
| 12 | #include <linux/gfp.h> |
| 13 | #include <linux/list.h> |
| 14 | #include <linux/netdevice.h> |
Jiri Pirko | b8f9755 | 2019-03-24 11:14:37 +0100 | [diff] [blame] | 15 | #include <linux/spinlock.h> |
Jiri Pirko | 136bf27 | 2019-05-23 10:43:35 +0200 | [diff] [blame] | 16 | #include <linux/workqueue.h> |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 17 | #include <net/net_namespace.h> |
| 18 | #include <uapi/linux/devlink.h> |
| 19 | |
| 20 | struct devlink_ops; |
| 21 | |
| 22 | struct devlink { |
| 23 | struct list_head list; |
| 24 | struct list_head port_list; |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 25 | struct list_head sb_list; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 26 | struct list_head dpipe_table_list; |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 27 | struct list_head resource_list; |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 28 | struct list_head param_list; |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 29 | struct list_head region_list; |
Alex Vesker | ccadfa4 | 2018-07-12 15:13:09 +0300 | [diff] [blame] | 30 | u32 snapshot_id; |
Eran Ben Elisha | a0bdcc5 | 2019-02-07 11:36:33 +0200 | [diff] [blame] | 31 | struct list_head reporter_list; |
Moshe Shemesh | b587bda | 2019-04-29 12:41:45 +0300 | [diff] [blame] | 32 | struct mutex reporters_lock; /* protects reporter_list */ |
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 | |
Parav Pandit | 378ef01 | 2019-07-08 23:17:35 -0500 | [diff] [blame^] | 41 | struct devlink_port_phys_attrs { |
| 42 | u32 port_number; /* Same value as "split group". |
| 43 | * A physical port which is visible to the user |
| 44 | * for a given port flavour. |
| 45 | */ |
| 46 | u32 split_subport_number; |
| 47 | }; |
| 48 | |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 49 | struct devlink_port_attrs { |
Jiri Pirko | 407dd70 | 2019-04-03 14:24:15 +0200 | [diff] [blame] | 50 | u8 set:1, |
Jiri Pirko | bec5267 | 2019-04-03 14:24:16 +0200 | [diff] [blame] | 51 | split:1, |
| 52 | switch_port:1; |
Jiri Pirko | 5ec1380 | 2018-05-18 09:29:01 +0200 | [diff] [blame] | 53 | enum devlink_port_flavour flavour; |
Jiri Pirko | bec5267 | 2019-04-03 14:24:16 +0200 | [diff] [blame] | 54 | struct netdev_phys_item_id switch_id; |
Parav Pandit | 378ef01 | 2019-07-08 23:17:35 -0500 | [diff] [blame^] | 55 | union { |
| 56 | struct devlink_port_phys_attrs phys; |
| 57 | }; |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 58 | }; |
| 59 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 60 | struct devlink_port { |
| 61 | struct list_head list; |
Vasundhara Volam | 39e6160 | 2019-01-28 18:00:20 +0530 | [diff] [blame] | 62 | struct list_head param_list; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 63 | struct devlink *devlink; |
| 64 | unsigned index; |
| 65 | bool registered; |
Jiri Pirko | b8f9755 | 2019-03-24 11:14:37 +0100 | [diff] [blame] | 66 | spinlock_t type_lock; /* Protects type and type_dev |
| 67 | * pointer consistency. |
| 68 | */ |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 69 | enum devlink_port_type type; |
| 70 | enum devlink_port_type desired_type; |
| 71 | void *type_dev; |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 72 | struct devlink_port_attrs attrs; |
Jiri Pirko | 136bf27 | 2019-05-23 10:43:35 +0200 | [diff] [blame] | 73 | struct delayed_work type_warn_dw; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 74 | }; |
| 75 | |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 76 | struct devlink_sb_pool_info { |
| 77 | enum devlink_sb_pool_type pool_type; |
| 78 | u32 size; |
| 79 | enum devlink_sb_threshold_type threshold_type; |
Jakub Kicinski | bff5731 | 2019-02-01 17:56:28 -0800 | [diff] [blame] | 80 | u32 cell_size; |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 83 | /** |
| 84 | * struct devlink_dpipe_field - dpipe field object |
| 85 | * @name: field name |
| 86 | * @id: index inside the headers field array |
| 87 | * @bitwidth: bitwidth |
| 88 | * @mapping_type: mapping type |
| 89 | */ |
| 90 | struct devlink_dpipe_field { |
| 91 | const char *name; |
| 92 | unsigned int id; |
| 93 | unsigned int bitwidth; |
| 94 | enum devlink_dpipe_field_mapping_type mapping_type; |
| 95 | }; |
| 96 | |
| 97 | /** |
| 98 | * struct devlink_dpipe_header - dpipe header object |
| 99 | * @name: header name |
| 100 | * @id: index, global/local detrmined by global bit |
| 101 | * @fields: fields |
| 102 | * @fields_count: number of fields |
| 103 | * @global: indicates if header is shared like most protocol header |
| 104 | * or driver specific |
| 105 | */ |
| 106 | struct devlink_dpipe_header { |
| 107 | const char *name; |
| 108 | unsigned int id; |
| 109 | struct devlink_dpipe_field *fields; |
| 110 | unsigned int fields_count; |
| 111 | bool global; |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * struct devlink_dpipe_match - represents match operation |
| 116 | * @type: type of match |
| 117 | * @header_index: header index (packets can have several headers of same |
| 118 | * type like in case of tunnels) |
| 119 | * @header: header |
| 120 | * @fieled_id: field index |
| 121 | */ |
| 122 | struct devlink_dpipe_match { |
| 123 | enum devlink_dpipe_match_type type; |
| 124 | unsigned int header_index; |
| 125 | struct devlink_dpipe_header *header; |
| 126 | unsigned int field_id; |
| 127 | }; |
| 128 | |
| 129 | /** |
| 130 | * struct devlink_dpipe_action - represents action operation |
| 131 | * @type: type of action |
| 132 | * @header_index: header index (packets can have several headers of same |
| 133 | * type like in case of tunnels) |
| 134 | * @header: header |
| 135 | * @fieled_id: field index |
| 136 | */ |
| 137 | struct devlink_dpipe_action { |
| 138 | enum devlink_dpipe_action_type type; |
| 139 | unsigned int header_index; |
| 140 | struct devlink_dpipe_header *header; |
| 141 | unsigned int field_id; |
| 142 | }; |
| 143 | |
| 144 | /** |
| 145 | * struct devlink_dpipe_value - represents value of match/action |
| 146 | * @action: action |
| 147 | * @match: match |
| 148 | * @mapping_value: in case the field has some mapping this value |
| 149 | * specified the mapping value |
| 150 | * @mapping_valid: specify if mapping value is valid |
| 151 | * @value_size: value size |
| 152 | * @value: value |
| 153 | * @mask: bit mask |
| 154 | */ |
| 155 | struct devlink_dpipe_value { |
| 156 | union { |
| 157 | struct devlink_dpipe_action *action; |
| 158 | struct devlink_dpipe_match *match; |
| 159 | }; |
| 160 | unsigned int mapping_value; |
| 161 | bool mapping_valid; |
| 162 | unsigned int value_size; |
| 163 | void *value; |
| 164 | void *mask; |
| 165 | }; |
| 166 | |
| 167 | /** |
| 168 | * struct devlink_dpipe_entry - table entry object |
| 169 | * @index: index of the entry in the table |
| 170 | * @match_values: match values |
| 171 | * @matche_values_count: count of matches tuples |
| 172 | * @action_values: actions values |
| 173 | * @action_values_count: count of actions values |
| 174 | * @counter: value of counter |
| 175 | * @counter_valid: Specify if value is valid from hardware |
| 176 | */ |
| 177 | struct devlink_dpipe_entry { |
| 178 | u64 index; |
| 179 | struct devlink_dpipe_value *match_values; |
| 180 | unsigned int match_values_count; |
| 181 | struct devlink_dpipe_value *action_values; |
| 182 | unsigned int action_values_count; |
| 183 | u64 counter; |
| 184 | bool counter_valid; |
| 185 | }; |
| 186 | |
| 187 | /** |
| 188 | * struct devlink_dpipe_dump_ctx - context provided to driver in order |
| 189 | * to dump |
| 190 | * @info: info |
| 191 | * @cmd: devlink command |
| 192 | * @skb: skb |
| 193 | * @nest: top attribute |
| 194 | * @hdr: hdr |
| 195 | */ |
| 196 | struct devlink_dpipe_dump_ctx { |
| 197 | struct genl_info *info; |
| 198 | enum devlink_command cmd; |
| 199 | struct sk_buff *skb; |
| 200 | struct nlattr *nest; |
| 201 | void *hdr; |
| 202 | }; |
| 203 | |
| 204 | struct devlink_dpipe_table_ops; |
| 205 | |
| 206 | /** |
| 207 | * struct devlink_dpipe_table - table object |
| 208 | * @priv: private |
| 209 | * @name: table name |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 210 | * @counters_enabled: indicates if counters are active |
| 211 | * @counter_control_extern: indicates if counter control is in dpipe or |
| 212 | * external tool |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 213 | * @resource_valid: Indicate that the resource id is valid |
| 214 | * @resource_id: relative resource this table is related to |
| 215 | * @resource_units: number of resource's unit consumed per table's entry |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 216 | * @table_ops: table operations |
| 217 | * @rcu: rcu |
| 218 | */ |
| 219 | struct devlink_dpipe_table { |
| 220 | void *priv; |
| 221 | struct list_head list; |
| 222 | const char *name; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 223 | bool counters_enabled; |
| 224 | bool counter_control_extern; |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 225 | bool resource_valid; |
| 226 | u64 resource_id; |
| 227 | u64 resource_units; |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 228 | struct devlink_dpipe_table_ops *table_ops; |
| 229 | struct rcu_head rcu; |
| 230 | }; |
| 231 | |
| 232 | /** |
| 233 | * struct devlink_dpipe_table_ops - dpipe_table ops |
| 234 | * @actions_dump - dumps all tables actions |
| 235 | * @matches_dump - dumps all tables matches |
| 236 | * @entries_dump - dumps all active entries in the table |
| 237 | * @counters_set_update - when changing the counter status hardware sync |
| 238 | * maybe needed to allocate/free counter related |
| 239 | * resources |
Arkadi Sharshevsky | ffd3cdc | 2017-08-24 08:40:02 +0200 | [diff] [blame] | 240 | * @size_get - get size |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 241 | */ |
| 242 | struct devlink_dpipe_table_ops { |
| 243 | int (*actions_dump)(void *priv, struct sk_buff *skb); |
| 244 | int (*matches_dump)(void *priv, struct sk_buff *skb); |
| 245 | int (*entries_dump)(void *priv, bool counters_enabled, |
| 246 | struct devlink_dpipe_dump_ctx *dump_ctx); |
| 247 | int (*counters_set_update)(void *priv, bool enable); |
Arkadi Sharshevsky | ffd3cdc | 2017-08-24 08:40:02 +0200 | [diff] [blame] | 248 | u64 (*size_get)(void *priv); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 249 | }; |
| 250 | |
| 251 | /** |
| 252 | * struct devlink_dpipe_headers - dpipe headers |
| 253 | * @headers - header array can be shared (global bit) or driver specific |
| 254 | * @headers_count - count of headers |
| 255 | */ |
| 256 | struct devlink_dpipe_headers { |
| 257 | struct devlink_dpipe_header **headers; |
| 258 | unsigned int headers_count; |
| 259 | }; |
| 260 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 261 | /** |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 262 | * struct devlink_resource_size_params - resource's size parameters |
| 263 | * @size_min: minimum size which can be set |
| 264 | * @size_max: maximum size which can be set |
| 265 | * @size_granularity: size granularity |
| 266 | * @size_unit: resource's basic unit |
| 267 | */ |
| 268 | struct devlink_resource_size_params { |
| 269 | u64 size_min; |
| 270 | u64 size_max; |
| 271 | u64 size_granularity; |
| 272 | enum devlink_resource_unit unit; |
| 273 | }; |
| 274 | |
Jiri Pirko | 77d2709 | 2018-02-28 13:12:09 +0100 | [diff] [blame] | 275 | static inline void |
| 276 | devlink_resource_size_params_init(struct devlink_resource_size_params *size_params, |
| 277 | u64 size_min, u64 size_max, |
| 278 | u64 size_granularity, |
| 279 | enum devlink_resource_unit unit) |
| 280 | { |
| 281 | size_params->size_min = size_min; |
| 282 | size_params->size_max = size_max; |
| 283 | size_params->size_granularity = size_granularity; |
| 284 | size_params->unit = unit; |
| 285 | } |
| 286 | |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 287 | typedef u64 devlink_resource_occ_get_t(void *priv); |
| 288 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 289 | /** |
| 290 | * struct devlink_resource - devlink resource |
| 291 | * @name: name of the resource |
| 292 | * @id: id, per devlink instance |
| 293 | * @size: size of the resource |
| 294 | * @size_new: updated size of the resource, reload is needed |
| 295 | * @size_valid: valid in case the total size of the resource is valid |
| 296 | * including its children |
| 297 | * @parent: parent resource |
| 298 | * @size_params: size parameters |
| 299 | * @list: parent list |
| 300 | * @resource_list: list of child resources |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 301 | */ |
| 302 | struct devlink_resource { |
| 303 | const char *name; |
| 304 | u64 id; |
| 305 | u64 size; |
| 306 | u64 size_new; |
| 307 | bool size_valid; |
| 308 | struct devlink_resource *parent; |
Jiri Pirko | 77d2709 | 2018-02-28 13:12:09 +0100 | [diff] [blame] | 309 | struct devlink_resource_size_params size_params; |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 310 | struct list_head list; |
| 311 | struct list_head resource_list; |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 312 | devlink_resource_occ_get_t *occ_get; |
| 313 | void *occ_get_priv; |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 314 | }; |
| 315 | |
| 316 | #define DEVLINK_RESOURCE_ID_PARENT_TOP 0 |
| 317 | |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 318 | #define __DEVLINK_PARAM_MAX_STRING_VALUE 32 |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 319 | enum devlink_param_type { |
| 320 | DEVLINK_PARAM_TYPE_U8, |
| 321 | DEVLINK_PARAM_TYPE_U16, |
| 322 | DEVLINK_PARAM_TYPE_U32, |
| 323 | DEVLINK_PARAM_TYPE_STRING, |
| 324 | DEVLINK_PARAM_TYPE_BOOL, |
| 325 | }; |
| 326 | |
| 327 | union devlink_param_value { |
| 328 | u8 vu8; |
| 329 | u16 vu16; |
| 330 | u32 vu32; |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 331 | char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE]; |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 332 | bool vbool; |
| 333 | }; |
| 334 | |
| 335 | struct devlink_param_gset_ctx { |
| 336 | union devlink_param_value val; |
| 337 | enum devlink_param_cmode cmode; |
| 338 | }; |
| 339 | |
| 340 | /** |
| 341 | * struct devlink_param - devlink configuration parameter data |
| 342 | * @name: name of the parameter |
| 343 | * @generic: indicates if the parameter is generic or driver specific |
| 344 | * @type: parameter type |
| 345 | * @supported_cmodes: bitmap of supported configuration modes |
| 346 | * @get: get parameter value, used for runtime and permanent |
| 347 | * configuration modes |
| 348 | * @set: set parameter value, used for runtime and permanent |
| 349 | * configuration modes |
Moshe Shemesh | e3b7ca1 | 2018-07-04 14:30:30 +0300 | [diff] [blame] | 350 | * @validate: validate input value is applicable (within value range, etc.) |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 351 | * |
| 352 | * This struct should be used by the driver to fill the data for |
| 353 | * a parameter it registers. |
| 354 | */ |
| 355 | struct devlink_param { |
| 356 | u32 id; |
| 357 | const char *name; |
| 358 | bool generic; |
| 359 | enum devlink_param_type type; |
| 360 | unsigned long supported_cmodes; |
| 361 | int (*get)(struct devlink *devlink, u32 id, |
| 362 | struct devlink_param_gset_ctx *ctx); |
| 363 | int (*set)(struct devlink *devlink, u32 id, |
| 364 | struct devlink_param_gset_ctx *ctx); |
Moshe Shemesh | e3b7ca1 | 2018-07-04 14:30:30 +0300 | [diff] [blame] | 365 | int (*validate)(struct devlink *devlink, u32 id, |
| 366 | union devlink_param_value val, |
| 367 | struct netlink_ext_ack *extack); |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 368 | }; |
| 369 | |
| 370 | struct devlink_param_item { |
| 371 | struct list_head list; |
| 372 | const struct devlink_param *param; |
| 373 | union devlink_param_value driverinit_value; |
| 374 | bool driverinit_value_valid; |
Jiri Pirko | 7c62cfb | 2019-02-07 11:22:45 +0000 | [diff] [blame] | 375 | bool published; |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | enum devlink_param_generic_id { |
Moshe Shemesh | 036467c | 2018-07-04 14:30:33 +0300 | [diff] [blame] | 379 | DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, |
| 380 | DEVLINK_PARAM_GENERIC_ID_MAX_MACS, |
Vasundhara Volam | f567bcd | 2018-07-04 14:30:36 +0300 | [diff] [blame] | 381 | DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, |
Alex Vesker | f6a69885 | 2018-07-12 15:13:17 +0300 | [diff] [blame] | 382 | DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, |
Vasundhara Volam | e3b5106 | 2018-10-04 11:13:44 +0530 | [diff] [blame] | 383 | DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, |
Vasundhara Volam | f61cba4 | 2018-10-04 11:13:45 +0530 | [diff] [blame] | 384 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, |
Vasundhara Volam | 1651178 | 2018-10-04 11:13:46 +0530 | [diff] [blame] | 385 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, |
Shalom Toledo | 846e980 | 2018-12-03 07:58:59 +0000 | [diff] [blame] | 386 | DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 387 | |
| 388 | /* add new param generic ids above here*/ |
| 389 | __DEVLINK_PARAM_GENERIC_ID_MAX, |
| 390 | DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, |
| 391 | }; |
| 392 | |
Moshe Shemesh | 036467c | 2018-07-04 14:30:33 +0300 | [diff] [blame] | 393 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" |
| 394 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 395 | |
| 396 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" |
| 397 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 |
| 398 | |
Vasundhara Volam | f567bcd | 2018-07-04 14:30:36 +0300 | [diff] [blame] | 399 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" |
| 400 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 401 | |
Alex Vesker | f6a69885 | 2018-07-12 15:13:17 +0300 | [diff] [blame] | 402 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" |
| 403 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 404 | |
Vasundhara Volam | e3b5106 | 2018-10-04 11:13:44 +0530 | [diff] [blame] | 405 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" |
| 406 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 407 | |
Vasundhara Volam | f61cba4 | 2018-10-04 11:13:45 +0530 | [diff] [blame] | 408 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" |
| 409 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 |
| 410 | |
Vasundhara Volam | 1651178 | 2018-10-04 11:13:46 +0530 | [diff] [blame] | 411 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" |
| 412 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 |
| 413 | |
Shalom Toledo | 846e980 | 2018-12-03 07:58:59 +0000 | [diff] [blame] | 414 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy" |
| 415 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8 |
| 416 | |
Moshe Shemesh | 036467c | 2018-07-04 14:30:33 +0300 | [diff] [blame] | 417 | #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ |
| 418 | { \ |
| 419 | .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ |
| 420 | .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ |
| 421 | .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ |
| 422 | .generic = true, \ |
| 423 | .supported_cmodes = _cmodes, \ |
| 424 | .get = _get, \ |
| 425 | .set = _set, \ |
| 426 | .validate = _validate, \ |
| 427 | } |
| 428 | |
| 429 | #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ |
| 430 | { \ |
| 431 | .id = _id, \ |
| 432 | .name = _name, \ |
| 433 | .type = _type, \ |
| 434 | .supported_cmodes = _cmodes, \ |
| 435 | .get = _get, \ |
| 436 | .set = _set, \ |
| 437 | .validate = _validate, \ |
| 438 | } |
| 439 | |
Jakub Kicinski | 785bd55 | 2019-01-31 10:50:42 -0800 | [diff] [blame] | 440 | /* Part number, identifier of board design */ |
| 441 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id" |
| 442 | /* Revision of board design */ |
| 443 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev" |
Jakub Kicinski | 14fd190 | 2019-02-10 19:35:29 -0800 | [diff] [blame] | 444 | /* Maker of the board */ |
| 445 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture" |
Jakub Kicinski | 785bd55 | 2019-01-31 10:50:42 -0800 | [diff] [blame] | 446 | |
| 447 | /* Control processor FW version */ |
| 448 | #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt" |
| 449 | /* Data path microcode controlling high-speed packet processing */ |
| 450 | #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app" |
| 451 | /* UNDI software version */ |
| 452 | #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi" |
| 453 | /* NCSI support/handler version */ |
| 454 | #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi" |
| 455 | |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 456 | struct devlink_region; |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 457 | struct devlink_info_req; |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 458 | |
Alex Vesker | d7e5272 | 2018-07-12 15:13:10 +0300 | [diff] [blame] | 459 | typedef void devlink_snapshot_data_dest_t(const void *data); |
| 460 | |
Eran Ben Elisha | 1db64e8 | 2019-02-07 11:36:32 +0200 | [diff] [blame] | 461 | struct devlink_fmsg; |
Eran Ben Elisha | a0bdcc5 | 2019-02-07 11:36:33 +0200 | [diff] [blame] | 462 | struct devlink_health_reporter; |
| 463 | |
Eran Ben Elisha | 3167b27 | 2019-03-03 10:57:30 +0200 | [diff] [blame] | 464 | enum devlink_health_reporter_state { |
| 465 | DEVLINK_HEALTH_REPORTER_STATE_HEALTHY, |
| 466 | DEVLINK_HEALTH_REPORTER_STATE_ERROR, |
| 467 | }; |
| 468 | |
Eran Ben Elisha | a0bdcc5 | 2019-02-07 11:36:33 +0200 | [diff] [blame] | 469 | /** |
| 470 | * struct devlink_health_reporter_ops - Reporter operations |
| 471 | * @name: reporter name |
| 472 | * @recover: callback to recover from reported error |
| 473 | * if priv_ctx is NULL, run a full recover |
| 474 | * @dump: callback to dump an object |
| 475 | * if priv_ctx is NULL, run a full dump |
| 476 | * @diagnose: callback to diagnose the current status |
| 477 | */ |
| 478 | |
| 479 | struct devlink_health_reporter_ops { |
| 480 | char *name; |
| 481 | int (*recover)(struct devlink_health_reporter *reporter, |
| 482 | void *priv_ctx); |
| 483 | int (*dump)(struct devlink_health_reporter *reporter, |
| 484 | struct devlink_fmsg *fmsg, void *priv_ctx); |
| 485 | int (*diagnose)(struct devlink_health_reporter *reporter, |
| 486 | struct devlink_fmsg *fmsg); |
| 487 | }; |
Eran Ben Elisha | 1db64e8 | 2019-02-07 11:36:32 +0200 | [diff] [blame] | 488 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 489 | struct devlink_ops { |
David Ahern | ac0fc8a | 2018-06-05 08:14:09 -0700 | [diff] [blame] | 490 | int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack); |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 491 | int (*port_type_set)(struct devlink_port *devlink_port, |
| 492 | enum devlink_port_type port_type); |
| 493 | int (*port_split)(struct devlink *devlink, unsigned int port_index, |
David Ahern | ac0fc8a | 2018-06-05 08:14:09 -0700 | [diff] [blame] | 494 | unsigned int count, struct netlink_ext_ack *extack); |
| 495 | int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, |
| 496 | struct netlink_ext_ack *extack); |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 497 | int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, |
| 498 | u16 pool_index, |
| 499 | struct devlink_sb_pool_info *pool_info); |
| 500 | int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, |
| 501 | u16 pool_index, u32 size, |
Ido Schimmel | f2ad1a5 | 2019-04-22 12:08:39 +0000 | [diff] [blame] | 502 | enum devlink_sb_threshold_type threshold_type, |
| 503 | struct netlink_ext_ack *extack); |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 504 | int (*sb_port_pool_get)(struct devlink_port *devlink_port, |
| 505 | unsigned int sb_index, u16 pool_index, |
| 506 | u32 *p_threshold); |
| 507 | int (*sb_port_pool_set)(struct devlink_port *devlink_port, |
| 508 | unsigned int sb_index, u16 pool_index, |
Ido Schimmel | f2ad1a5 | 2019-04-22 12:08:39 +0000 | [diff] [blame] | 509 | u32 threshold, struct netlink_ext_ack *extack); |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 510 | int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, |
| 511 | unsigned int sb_index, |
| 512 | u16 tc_index, |
| 513 | enum devlink_sb_pool_type pool_type, |
| 514 | u16 *p_pool_index, u32 *p_threshold); |
| 515 | int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, |
| 516 | unsigned int sb_index, |
| 517 | u16 tc_index, |
| 518 | enum devlink_sb_pool_type pool_type, |
Ido Schimmel | f2ad1a5 | 2019-04-22 12:08:39 +0000 | [diff] [blame] | 519 | u16 pool_index, u32 threshold, |
| 520 | struct netlink_ext_ack *extack); |
Jiri Pirko | df38daf | 2016-04-14 18:19:14 +0200 | [diff] [blame] | 521 | int (*sb_occ_snapshot)(struct devlink *devlink, |
| 522 | unsigned int sb_index); |
| 523 | int (*sb_occ_max_clear)(struct devlink *devlink, |
| 524 | unsigned int sb_index); |
| 525 | int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, |
| 526 | unsigned int sb_index, u16 pool_index, |
| 527 | u32 *p_cur, u32 *p_max); |
| 528 | int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, |
| 529 | unsigned int sb_index, |
| 530 | u16 tc_index, |
| 531 | enum devlink_sb_pool_type pool_type, |
| 532 | u32 *p_cur, u32 *p_max); |
Or Gerlitz | 08f4b59 | 2016-07-01 14:51:01 +0300 | [diff] [blame] | 533 | |
| 534 | int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); |
Eli Britstein | db7ff19 | 2018-08-15 16:02:18 +0300 | [diff] [blame] | 535 | int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, |
| 536 | struct netlink_ext_ack *extack); |
Roi Dayan | 59bfde0 | 2016-11-22 23:09:57 +0200 | [diff] [blame] | 537 | int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); |
Eli Britstein | db7ff19 | 2018-08-15 16:02:18 +0300 | [diff] [blame] | 538 | int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, |
| 539 | struct netlink_ext_ack *extack); |
Leon Romanovsky | 98fdbea | 2019-06-12 15:20:11 +0300 | [diff] [blame] | 540 | int (*eswitch_encap_mode_get)(struct devlink *devlink, |
| 541 | enum devlink_eswitch_encap_mode *p_encap_mode); |
| 542 | int (*eswitch_encap_mode_set)(struct devlink *devlink, |
| 543 | enum devlink_eswitch_encap_mode encap_mode, |
Eli Britstein | db7ff19 | 2018-08-15 16:02:18 +0300 | [diff] [blame] | 544 | struct netlink_ext_ack *extack); |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 545 | int (*info_get)(struct devlink *devlink, struct devlink_info_req *req, |
| 546 | struct netlink_ext_ack *extack); |
Jakub Kicinski | 76726cc | 2019-02-14 13:40:44 -0800 | [diff] [blame] | 547 | int (*flash_update)(struct devlink *devlink, const char *file_name, |
| 548 | const char *component, |
| 549 | struct netlink_ext_ack *extack); |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 550 | }; |
| 551 | |
| 552 | static inline void *devlink_priv(struct devlink *devlink) |
| 553 | { |
| 554 | BUG_ON(!devlink); |
| 555 | return &devlink->priv; |
| 556 | } |
| 557 | |
| 558 | static inline struct devlink *priv_to_devlink(void *priv) |
| 559 | { |
| 560 | BUG_ON(!priv); |
| 561 | return container_of(priv, struct devlink, priv); |
| 562 | } |
| 563 | |
Jiri Pirko | 5dc37bb | 2019-03-28 13:56:36 +0100 | [diff] [blame] | 564 | static inline struct devlink_port * |
| 565 | netdev_to_devlink_port(struct net_device *dev) |
| 566 | { |
| 567 | if (dev->netdev_ops->ndo_get_devlink_port) |
| 568 | return dev->netdev_ops->ndo_get_devlink_port(dev); |
| 569 | return NULL; |
| 570 | } |
| 571 | |
Jakub Kicinski | b473b0d | 2019-02-25 19:34:03 -0800 | [diff] [blame] | 572 | static inline struct devlink *netdev_to_devlink(struct net_device *dev) |
| 573 | { |
Jiri Pirko | 5dc37bb | 2019-03-28 13:56:36 +0100 | [diff] [blame] | 574 | struct devlink_port *devlink_port = netdev_to_devlink_port(dev); |
| 575 | |
| 576 | if (devlink_port) |
| 577 | return devlink_port->devlink; |
Jakub Kicinski | b473b0d | 2019-02-25 19:34:03 -0800 | [diff] [blame] | 578 | return NULL; |
| 579 | } |
| 580 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 581 | struct ib_device; |
| 582 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 583 | struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); |
| 584 | int devlink_register(struct devlink *devlink, struct device *dev); |
| 585 | void devlink_unregister(struct devlink *devlink); |
| 586 | void devlink_free(struct devlink *devlink); |
| 587 | int devlink_port_register(struct devlink *devlink, |
| 588 | struct devlink_port *devlink_port, |
| 589 | unsigned int port_index); |
| 590 | void devlink_port_unregister(struct devlink_port *devlink_port); |
| 591 | void devlink_port_type_eth_set(struct devlink_port *devlink_port, |
| 592 | struct net_device *netdev); |
| 593 | void devlink_port_type_ib_set(struct devlink_port *devlink_port, |
| 594 | struct ib_device *ibdev); |
| 595 | void devlink_port_type_clear(struct devlink_port *devlink_port); |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 596 | void devlink_port_attrs_set(struct devlink_port *devlink_port, |
Jiri Pirko | 5ec1380 | 2018-05-18 09:29:01 +0200 | [diff] [blame] | 597 | enum devlink_port_flavour flavour, |
Jiri Pirko | b9ffcba | 2018-05-18 09:29:00 +0200 | [diff] [blame] | 598 | u32 port_number, bool split, |
Jiri Pirko | bec5267 | 2019-04-03 14:24:16 +0200 | [diff] [blame] | 599 | u32 split_subport_number, |
| 600 | const unsigned char *switch_id, |
| 601 | unsigned char switch_id_len); |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 602 | int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, |
| 603 | u32 size, u16 ingress_pools_count, |
| 604 | u16 egress_pools_count, u16 ingress_tc_count, |
| 605 | u16 egress_tc_count); |
| 606 | void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 607 | int devlink_dpipe_table_register(struct devlink *devlink, |
| 608 | const char *table_name, |
| 609 | struct devlink_dpipe_table_ops *table_ops, |
Arkadi Sharshevsky | ffd3cdc | 2017-08-24 08:40:02 +0200 | [diff] [blame] | 610 | void *priv, bool counter_control_extern); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 611 | void devlink_dpipe_table_unregister(struct devlink *devlink, |
| 612 | const char *table_name); |
| 613 | int devlink_dpipe_headers_register(struct devlink *devlink, |
| 614 | struct devlink_dpipe_headers *dpipe_headers); |
| 615 | void devlink_dpipe_headers_unregister(struct devlink *devlink); |
| 616 | bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, |
| 617 | const char *table_name); |
| 618 | int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); |
| 619 | int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, |
| 620 | struct devlink_dpipe_entry *entry); |
| 621 | 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] | 622 | void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); |
Arkadi Sharshevsky | 1555d20 | 2017-03-28 17:24:10 +0200 | [diff] [blame] | 623 | int devlink_dpipe_action_put(struct sk_buff *skb, |
| 624 | struct devlink_dpipe_action *action); |
| 625 | int devlink_dpipe_match_put(struct sk_buff *skb, |
| 626 | struct devlink_dpipe_match *match); |
Arkadi Sharshevsky | 1177009 | 2017-08-24 08:39:59 +0200 | [diff] [blame] | 627 | extern struct devlink_dpipe_header devlink_dpipe_header_ethernet; |
Arkadi Sharshevsky | 3fb886e | 2017-08-24 08:40:00 +0200 | [diff] [blame] | 628 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv4; |
Arkadi Sharshevsky | 1797f5b | 2017-08-31 17:59:12 +0200 | [diff] [blame] | 629 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv6; |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 630 | |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 631 | int devlink_resource_register(struct devlink *devlink, |
| 632 | const char *resource_name, |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 633 | u64 resource_size, |
| 634 | u64 resource_id, |
| 635 | u64 parent_resource_id, |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 636 | const struct devlink_resource_size_params *size_params); |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 637 | void devlink_resources_unregister(struct devlink *devlink, |
| 638 | struct devlink_resource *resource); |
| 639 | int devlink_resource_size_get(struct devlink *devlink, |
| 640 | u64 resource_id, |
| 641 | u64 *p_resource_size); |
Arkadi Sharshevsky | 56dc7cd | 2018-01-15 08:59:05 +0100 | [diff] [blame] | 642 | int devlink_dpipe_table_resource_set(struct devlink *devlink, |
| 643 | const char *table_name, u64 resource_id, |
| 644 | u64 resource_units); |
Jiri Pirko | fc56be4 | 2018-04-05 22:13:21 +0200 | [diff] [blame] | 645 | void devlink_resource_occ_get_register(struct devlink *devlink, |
| 646 | u64 resource_id, |
| 647 | devlink_resource_occ_get_t *occ_get, |
| 648 | void *occ_get_priv); |
| 649 | void devlink_resource_occ_get_unregister(struct devlink *devlink, |
| 650 | u64 resource_id); |
Moshe Shemesh | eabaef1 | 2018-07-04 14:30:28 +0300 | [diff] [blame] | 651 | int devlink_params_register(struct devlink *devlink, |
| 652 | const struct devlink_param *params, |
| 653 | size_t params_count); |
| 654 | void devlink_params_unregister(struct devlink *devlink, |
| 655 | const struct devlink_param *params, |
| 656 | size_t params_count); |
Jiri Pirko | 7c62cfb | 2019-02-07 11:22:45 +0000 | [diff] [blame] | 657 | void devlink_params_publish(struct devlink *devlink); |
| 658 | void devlink_params_unpublish(struct devlink *devlink); |
Vasundhara Volam | 39e6160 | 2019-01-28 18:00:20 +0530 | [diff] [blame] | 659 | int devlink_port_params_register(struct devlink_port *devlink_port, |
| 660 | const struct devlink_param *params, |
| 661 | size_t params_count); |
| 662 | void devlink_port_params_unregister(struct devlink_port *devlink_port, |
| 663 | const struct devlink_param *params, |
| 664 | size_t params_count); |
Moshe Shemesh | ec01aeb | 2018-07-04 14:30:31 +0300 | [diff] [blame] | 665 | int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, |
| 666 | union devlink_param_value *init_val); |
| 667 | int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, |
| 668 | union devlink_param_value init_val); |
Vasundhara Volam | ffd19b9 | 2019-01-28 18:00:23 +0530 | [diff] [blame] | 669 | int |
| 670 | devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port, |
| 671 | u32 param_id, |
| 672 | union devlink_param_value *init_val); |
Vasundhara Volam | 5473a7b | 2019-01-28 18:00:24 +0530 | [diff] [blame] | 673 | int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port, |
| 674 | u32 param_id, |
| 675 | union devlink_param_value init_val); |
Moshe Shemesh | ea601e1 | 2018-07-04 14:30:32 +0300 | [diff] [blame] | 676 | void devlink_param_value_changed(struct devlink *devlink, u32 param_id); |
Vasundhara Volam | c1e5786d | 2019-01-28 18:00:25 +0530 | [diff] [blame] | 677 | void devlink_port_param_value_changed(struct devlink_port *devlink_port, |
| 678 | u32 param_id); |
Moshe Shemesh | bde74ad1 | 2018-10-10 16:09:27 +0300 | [diff] [blame] | 679 | void devlink_param_value_str_fill(union devlink_param_value *dst_val, |
| 680 | const char *src); |
Alex Vesker | b16ebe9 | 2018-07-12 15:13:08 +0300 | [diff] [blame] | 681 | struct devlink_region *devlink_region_create(struct devlink *devlink, |
| 682 | const char *region_name, |
| 683 | u32 region_max_snapshots, |
| 684 | u64 region_size); |
| 685 | void devlink_region_destroy(struct devlink_region *region); |
Alex Vesker | ccadfa4 | 2018-07-12 15:13:09 +0300 | [diff] [blame] | 686 | u32 devlink_region_shapshot_id_get(struct devlink *devlink); |
Alex Vesker | d7e5272 | 2018-07-12 15:13:10 +0300 | [diff] [blame] | 687 | int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len, |
| 688 | u8 *data, u32 snapshot_id, |
| 689 | devlink_snapshot_data_dest_t *data_destructor); |
Jakub Kicinski | f9cf228 | 2019-01-31 10:50:40 -0800 | [diff] [blame] | 690 | int devlink_info_serial_number_put(struct devlink_info_req *req, |
| 691 | const char *sn); |
| 692 | int devlink_info_driver_name_put(struct devlink_info_req *req, |
| 693 | const char *name); |
Jakub Kicinski | fc6fae7 | 2019-01-31 10:50:41 -0800 | [diff] [blame] | 694 | int devlink_info_version_fixed_put(struct devlink_info_req *req, |
| 695 | const char *version_name, |
| 696 | const char *version_value); |
| 697 | int devlink_info_version_stored_put(struct devlink_info_req *req, |
| 698 | const char *version_name, |
| 699 | const char *version_value); |
| 700 | int devlink_info_version_running_put(struct devlink_info_req *req, |
| 701 | const char *version_name, |
| 702 | const char *version_value); |
Arkadi Sharshevsky | d9f9b9a | 2018-01-15 08:59:03 +0100 | [diff] [blame] | 703 | |
Eran Ben Elisha | 1db64e8 | 2019-02-07 11:36:32 +0200 | [diff] [blame] | 704 | int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg); |
| 705 | int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg); |
| 706 | |
| 707 | int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name); |
| 708 | int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg); |
| 709 | |
| 710 | int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg, |
| 711 | const char *name); |
| 712 | int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg); |
| 713 | |
| 714 | int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value); |
| 715 | int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value); |
| 716 | int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value); |
| 717 | int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value); |
| 718 | int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value); |
| 719 | int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, |
| 720 | u16 value_len); |
| 721 | |
| 722 | int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 723 | bool value); |
| 724 | int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 725 | u8 value); |
| 726 | int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 727 | u32 value); |
| 728 | int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 729 | u64 value); |
| 730 | int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 731 | const char *value); |
| 732 | int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 733 | const void *value, u16 value_len); |
| 734 | |
Eran Ben Elisha | a0bdcc5 | 2019-02-07 11:36:33 +0200 | [diff] [blame] | 735 | struct devlink_health_reporter * |
| 736 | devlink_health_reporter_create(struct devlink *devlink, |
| 737 | const struct devlink_health_reporter_ops *ops, |
| 738 | u64 graceful_period, bool auto_recover, |
| 739 | void *priv); |
| 740 | void |
| 741 | devlink_health_reporter_destroy(struct devlink_health_reporter *reporter); |
| 742 | |
| 743 | void * |
| 744 | devlink_health_reporter_priv(struct devlink_health_reporter *reporter); |
Eran Ben Elisha | c8e1da0 | 2019-02-07 11:36:34 +0200 | [diff] [blame] | 745 | int devlink_health_report(struct devlink_health_reporter *reporter, |
| 746 | const char *msg, void *priv_ctx); |
Eran Ben Elisha | 3167b27 | 2019-03-03 10:57:30 +0200 | [diff] [blame] | 747 | void |
| 748 | devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, |
| 749 | enum devlink_health_reporter_state state); |
Eran Ben Elisha | a0bdcc5 | 2019-02-07 11:36:33 +0200 | [diff] [blame] | 750 | |
Jiri Pirko | 191ed20 | 2019-06-04 15:40:40 +0200 | [diff] [blame] | 751 | void devlink_flash_update_begin_notify(struct devlink *devlink); |
| 752 | void devlink_flash_update_end_notify(struct devlink *devlink); |
| 753 | void devlink_flash_update_status_notify(struct devlink *devlink, |
| 754 | const char *status_msg, |
| 755 | const char *component, |
| 756 | unsigned long done, |
| 757 | unsigned long total); |
| 758 | |
Jiri Pirko | f6b19b3 | 2019-03-24 11:14:38 +0100 | [diff] [blame] | 759 | #if IS_ENABLED(CONFIG_NET_DEVLINK) |
| 760 | |
Jakub Kicinski | f4b6bcc | 2019-02-25 19:34:02 -0800 | [diff] [blame] | 761 | void devlink_compat_running_version(struct net_device *dev, |
| 762 | char *buf, size_t len); |
| 763 | int devlink_compat_flash_update(struct net_device *dev, const char *file_name); |
Jiri Pirko | af3836d | 2019-03-28 13:56:37 +0100 | [diff] [blame] | 764 | int devlink_compat_phys_port_name_get(struct net_device *dev, |
| 765 | char *name, size_t len); |
Jiri Pirko | 7e1146e | 2019-04-03 14:24:17 +0200 | [diff] [blame] | 766 | int devlink_compat_switch_id_get(struct net_device *dev, |
| 767 | struct netdev_phys_item_id *ppid); |
Jakub Kicinski | f4b6bcc | 2019-02-25 19:34:02 -0800 | [diff] [blame] | 768 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 769 | #else |
| 770 | |
Eran Ben Elisha | 3167b27 | 2019-03-03 10:57:30 +0200 | [diff] [blame] | 771 | static inline void |
Jakub Kicinski | ddb6e99 | 2019-01-31 10:50:47 -0800 | [diff] [blame] | 772 | devlink_compat_running_version(struct net_device *dev, char *buf, size_t len) |
| 773 | { |
| 774 | } |
Jakub Kicinski | 4eceba1 | 2019-02-14 13:40:45 -0800 | [diff] [blame] | 775 | |
| 776 | static inline int |
| 777 | devlink_compat_flash_update(struct net_device *dev, const char *file_name) |
| 778 | { |
| 779 | return -EOPNOTSUPP; |
| 780 | } |
Jiri Pirko | f6b19b3 | 2019-03-24 11:14:38 +0100 | [diff] [blame] | 781 | |
Jiri Pirko | af3836d | 2019-03-28 13:56:37 +0100 | [diff] [blame] | 782 | static inline int |
| 783 | devlink_compat_phys_port_name_get(struct net_device *dev, |
| 784 | char *name, size_t len) |
| 785 | { |
| 786 | return -EOPNOTSUPP; |
| 787 | } |
| 788 | |
Jiri Pirko | 7e1146e | 2019-04-03 14:24:17 +0200 | [diff] [blame] | 789 | static inline int |
| 790 | devlink_compat_switch_id_get(struct net_device *dev, |
| 791 | struct netdev_phys_item_id *ppid) |
| 792 | { |
| 793 | return -EOPNOTSUPP; |
| 794 | } |
| 795 | |
Jakub Kicinski | ddb6e99 | 2019-01-31 10:50:47 -0800 | [diff] [blame] | 796 | #endif |
| 797 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 798 | #endif /* _NET_DEVLINK_H_ */ |