David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [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> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [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> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 15 | #include <linux/spinlock.h> |
| 16 | #include <linux/workqueue.h> |
| 17 | #include <linux/refcount.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 18 | #include <net/net_namespace.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 19 | #include <net/flow_offload.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | #include <uapi/linux/devlink.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 21 | #include <linux/xarray.h> |
| 22 | |
| 23 | #define DEVLINK_RELOAD_STATS_ARRAY_SIZE \ |
| 24 | (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX) |
| 25 | |
| 26 | struct devlink_dev_stats { |
| 27 | u32 reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE]; |
| 28 | u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE]; |
| 29 | }; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 30 | |
| 31 | struct devlink_ops; |
| 32 | |
| 33 | struct devlink { |
| 34 | struct list_head list; |
| 35 | struct list_head port_list; |
| 36 | struct list_head sb_list; |
| 37 | struct list_head dpipe_table_list; |
| 38 | struct list_head resource_list; |
| 39 | struct list_head param_list; |
| 40 | struct list_head region_list; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 41 | struct list_head reporter_list; |
| 42 | struct mutex reporters_lock; /* protects reporter_list */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 43 | struct devlink_dpipe_headers *dpipe_headers; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 44 | struct list_head trap_list; |
| 45 | struct list_head trap_group_list; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 46 | struct list_head trap_policer_list; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 47 | const struct devlink_ops *ops; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 48 | struct xarray snapshot_ids; |
| 49 | struct devlink_dev_stats stats; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 50 | struct device *dev; |
| 51 | possible_net_t _net; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 52 | struct mutex lock; /* Serializes access to devlink instance specific objects such as |
| 53 | * port, sb, dpipe, resource, params, region, traps and more. |
| 54 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 55 | u8 reload_failed:1, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 56 | reload_enabled:1, |
| 57 | registered:1; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 58 | char priv[0] __aligned(NETDEV_ALIGN); |
| 59 | }; |
| 60 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 61 | struct devlink_port_phys_attrs { |
| 62 | u32 port_number; /* Same value as "split group". |
| 63 | * A physical port which is visible to the user |
| 64 | * for a given port flavour. |
| 65 | */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 66 | u32 split_subport_number; /* If the port is split, this is the number of subport. */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 69 | /** |
| 70 | * struct devlink_port_pci_pf_attrs - devlink port's PCI PF attributes |
| 71 | * @controller: Associated controller number |
| 72 | * @pf: Associated PCI PF number for this port. |
| 73 | * @external: when set, indicates if a port is for an external controller |
| 74 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 75 | struct devlink_port_pci_pf_attrs { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 76 | u32 controller; |
| 77 | u16 pf; |
| 78 | u8 external:1; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 81 | /** |
| 82 | * struct devlink_port_pci_vf_attrs - devlink port's PCI VF attributes |
| 83 | * @controller: Associated controller number |
| 84 | * @pf: Associated PCI PF number for this port. |
| 85 | * @vf: Associated PCI VF for of the PCI PF for this port. |
| 86 | * @external: when set, indicates if a port is for an external controller |
| 87 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 88 | struct devlink_port_pci_vf_attrs { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 89 | u32 controller; |
| 90 | u16 pf; |
| 91 | u16 vf; |
| 92 | u8 external:1; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 95 | /** |
| 96 | * struct devlink_port_attrs - devlink port object |
| 97 | * @flavour: flavour of the port |
| 98 | * @split: indicates if this is split port |
| 99 | * @splittable: indicates if the port can be split. |
| 100 | * @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink. |
| 101 | * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL |
| 102 | * @phys: physical port attributes |
| 103 | * @pci_pf: PCI PF port attributes |
| 104 | * @pci_vf: PCI VF port attributes |
| 105 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 106 | struct devlink_port_attrs { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 107 | u8 split:1, |
| 108 | splittable:1; |
| 109 | u32 lanes; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 110 | enum devlink_port_flavour flavour; |
| 111 | struct netdev_phys_item_id switch_id; |
| 112 | union { |
| 113 | struct devlink_port_phys_attrs phys; |
| 114 | struct devlink_port_pci_pf_attrs pci_pf; |
| 115 | struct devlink_port_pci_vf_attrs pci_vf; |
| 116 | }; |
| 117 | }; |
| 118 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 119 | struct devlink_port { |
| 120 | struct list_head list; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 121 | struct list_head param_list; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 122 | struct list_head region_list; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 123 | struct devlink *devlink; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 124 | unsigned int index; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 125 | bool registered; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 126 | spinlock_t type_lock; /* Protects type and type_dev |
| 127 | * pointer consistency. |
| 128 | */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 129 | enum devlink_port_type type; |
| 130 | enum devlink_port_type desired_type; |
| 131 | void *type_dev; |
| 132 | struct devlink_port_attrs attrs; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 133 | u8 attrs_set:1, |
| 134 | switch_port:1; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 135 | struct delayed_work type_warn_dw; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 136 | struct list_head reporter_list; |
| 137 | struct mutex reporters_lock; /* Protects reporter_list */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | struct devlink_sb_pool_info { |
| 141 | enum devlink_sb_pool_type pool_type; |
| 142 | u32 size; |
| 143 | enum devlink_sb_threshold_type threshold_type; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 144 | u32 cell_size; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | /** |
| 148 | * struct devlink_dpipe_field - dpipe field object |
| 149 | * @name: field name |
| 150 | * @id: index inside the headers field array |
| 151 | * @bitwidth: bitwidth |
| 152 | * @mapping_type: mapping type |
| 153 | */ |
| 154 | struct devlink_dpipe_field { |
| 155 | const char *name; |
| 156 | unsigned int id; |
| 157 | unsigned int bitwidth; |
| 158 | enum devlink_dpipe_field_mapping_type mapping_type; |
| 159 | }; |
| 160 | |
| 161 | /** |
| 162 | * struct devlink_dpipe_header - dpipe header object |
| 163 | * @name: header name |
| 164 | * @id: index, global/local detrmined by global bit |
| 165 | * @fields: fields |
| 166 | * @fields_count: number of fields |
| 167 | * @global: indicates if header is shared like most protocol header |
| 168 | * or driver specific |
| 169 | */ |
| 170 | struct devlink_dpipe_header { |
| 171 | const char *name; |
| 172 | unsigned int id; |
| 173 | struct devlink_dpipe_field *fields; |
| 174 | unsigned int fields_count; |
| 175 | bool global; |
| 176 | }; |
| 177 | |
| 178 | /** |
| 179 | * struct devlink_dpipe_match - represents match operation |
| 180 | * @type: type of match |
| 181 | * @header_index: header index (packets can have several headers of same |
| 182 | * type like in case of tunnels) |
| 183 | * @header: header |
| 184 | * @fieled_id: field index |
| 185 | */ |
| 186 | struct devlink_dpipe_match { |
| 187 | enum devlink_dpipe_match_type type; |
| 188 | unsigned int header_index; |
| 189 | struct devlink_dpipe_header *header; |
| 190 | unsigned int field_id; |
| 191 | }; |
| 192 | |
| 193 | /** |
| 194 | * struct devlink_dpipe_action - represents action operation |
| 195 | * @type: type of action |
| 196 | * @header_index: header index (packets can have several headers of same |
| 197 | * type like in case of tunnels) |
| 198 | * @header: header |
| 199 | * @fieled_id: field index |
| 200 | */ |
| 201 | struct devlink_dpipe_action { |
| 202 | enum devlink_dpipe_action_type type; |
| 203 | unsigned int header_index; |
| 204 | struct devlink_dpipe_header *header; |
| 205 | unsigned int field_id; |
| 206 | }; |
| 207 | |
| 208 | /** |
| 209 | * struct devlink_dpipe_value - represents value of match/action |
| 210 | * @action: action |
| 211 | * @match: match |
| 212 | * @mapping_value: in case the field has some mapping this value |
| 213 | * specified the mapping value |
| 214 | * @mapping_valid: specify if mapping value is valid |
| 215 | * @value_size: value size |
| 216 | * @value: value |
| 217 | * @mask: bit mask |
| 218 | */ |
| 219 | struct devlink_dpipe_value { |
| 220 | union { |
| 221 | struct devlink_dpipe_action *action; |
| 222 | struct devlink_dpipe_match *match; |
| 223 | }; |
| 224 | unsigned int mapping_value; |
| 225 | bool mapping_valid; |
| 226 | unsigned int value_size; |
| 227 | void *value; |
| 228 | void *mask; |
| 229 | }; |
| 230 | |
| 231 | /** |
| 232 | * struct devlink_dpipe_entry - table entry object |
| 233 | * @index: index of the entry in the table |
| 234 | * @match_values: match values |
| 235 | * @matche_values_count: count of matches tuples |
| 236 | * @action_values: actions values |
| 237 | * @action_values_count: count of actions values |
| 238 | * @counter: value of counter |
| 239 | * @counter_valid: Specify if value is valid from hardware |
| 240 | */ |
| 241 | struct devlink_dpipe_entry { |
| 242 | u64 index; |
| 243 | struct devlink_dpipe_value *match_values; |
| 244 | unsigned int match_values_count; |
| 245 | struct devlink_dpipe_value *action_values; |
| 246 | unsigned int action_values_count; |
| 247 | u64 counter; |
| 248 | bool counter_valid; |
| 249 | }; |
| 250 | |
| 251 | /** |
| 252 | * struct devlink_dpipe_dump_ctx - context provided to driver in order |
| 253 | * to dump |
| 254 | * @info: info |
| 255 | * @cmd: devlink command |
| 256 | * @skb: skb |
| 257 | * @nest: top attribute |
| 258 | * @hdr: hdr |
| 259 | */ |
| 260 | struct devlink_dpipe_dump_ctx { |
| 261 | struct genl_info *info; |
| 262 | enum devlink_command cmd; |
| 263 | struct sk_buff *skb; |
| 264 | struct nlattr *nest; |
| 265 | void *hdr; |
| 266 | }; |
| 267 | |
| 268 | struct devlink_dpipe_table_ops; |
| 269 | |
| 270 | /** |
| 271 | * struct devlink_dpipe_table - table object |
| 272 | * @priv: private |
| 273 | * @name: table name |
| 274 | * @counters_enabled: indicates if counters are active |
| 275 | * @counter_control_extern: indicates if counter control is in dpipe or |
| 276 | * external tool |
| 277 | * @resource_valid: Indicate that the resource id is valid |
| 278 | * @resource_id: relative resource this table is related to |
| 279 | * @resource_units: number of resource's unit consumed per table's entry |
| 280 | * @table_ops: table operations |
| 281 | * @rcu: rcu |
| 282 | */ |
| 283 | struct devlink_dpipe_table { |
| 284 | void *priv; |
| 285 | struct list_head list; |
| 286 | const char *name; |
| 287 | bool counters_enabled; |
| 288 | bool counter_control_extern; |
| 289 | bool resource_valid; |
| 290 | u64 resource_id; |
| 291 | u64 resource_units; |
| 292 | struct devlink_dpipe_table_ops *table_ops; |
| 293 | struct rcu_head rcu; |
| 294 | }; |
| 295 | |
| 296 | /** |
| 297 | * struct devlink_dpipe_table_ops - dpipe_table ops |
| 298 | * @actions_dump - dumps all tables actions |
| 299 | * @matches_dump - dumps all tables matches |
| 300 | * @entries_dump - dumps all active entries in the table |
| 301 | * @counters_set_update - when changing the counter status hardware sync |
| 302 | * maybe needed to allocate/free counter related |
| 303 | * resources |
| 304 | * @size_get - get size |
| 305 | */ |
| 306 | struct devlink_dpipe_table_ops { |
| 307 | int (*actions_dump)(void *priv, struct sk_buff *skb); |
| 308 | int (*matches_dump)(void *priv, struct sk_buff *skb); |
| 309 | int (*entries_dump)(void *priv, bool counters_enabled, |
| 310 | struct devlink_dpipe_dump_ctx *dump_ctx); |
| 311 | int (*counters_set_update)(void *priv, bool enable); |
| 312 | u64 (*size_get)(void *priv); |
| 313 | }; |
| 314 | |
| 315 | /** |
| 316 | * struct devlink_dpipe_headers - dpipe headers |
| 317 | * @headers - header array can be shared (global bit) or driver specific |
| 318 | * @headers_count - count of headers |
| 319 | */ |
| 320 | struct devlink_dpipe_headers { |
| 321 | struct devlink_dpipe_header **headers; |
| 322 | unsigned int headers_count; |
| 323 | }; |
| 324 | |
| 325 | /** |
| 326 | * struct devlink_resource_size_params - resource's size parameters |
| 327 | * @size_min: minimum size which can be set |
| 328 | * @size_max: maximum size which can be set |
| 329 | * @size_granularity: size granularity |
| 330 | * @size_unit: resource's basic unit |
| 331 | */ |
| 332 | struct devlink_resource_size_params { |
| 333 | u64 size_min; |
| 334 | u64 size_max; |
| 335 | u64 size_granularity; |
| 336 | enum devlink_resource_unit unit; |
| 337 | }; |
| 338 | |
| 339 | static inline void |
| 340 | devlink_resource_size_params_init(struct devlink_resource_size_params *size_params, |
| 341 | u64 size_min, u64 size_max, |
| 342 | u64 size_granularity, |
| 343 | enum devlink_resource_unit unit) |
| 344 | { |
| 345 | size_params->size_min = size_min; |
| 346 | size_params->size_max = size_max; |
| 347 | size_params->size_granularity = size_granularity; |
| 348 | size_params->unit = unit; |
| 349 | } |
| 350 | |
| 351 | typedef u64 devlink_resource_occ_get_t(void *priv); |
| 352 | |
| 353 | /** |
| 354 | * struct devlink_resource - devlink resource |
| 355 | * @name: name of the resource |
| 356 | * @id: id, per devlink instance |
| 357 | * @size: size of the resource |
| 358 | * @size_new: updated size of the resource, reload is needed |
| 359 | * @size_valid: valid in case the total size of the resource is valid |
| 360 | * including its children |
| 361 | * @parent: parent resource |
| 362 | * @size_params: size parameters |
| 363 | * @list: parent list |
| 364 | * @resource_list: list of child resources |
| 365 | */ |
| 366 | struct devlink_resource { |
| 367 | const char *name; |
| 368 | u64 id; |
| 369 | u64 size; |
| 370 | u64 size_new; |
| 371 | bool size_valid; |
| 372 | struct devlink_resource *parent; |
| 373 | struct devlink_resource_size_params size_params; |
| 374 | struct list_head list; |
| 375 | struct list_head resource_list; |
| 376 | devlink_resource_occ_get_t *occ_get; |
| 377 | void *occ_get_priv; |
| 378 | }; |
| 379 | |
| 380 | #define DEVLINK_RESOURCE_ID_PARENT_TOP 0 |
| 381 | |
| 382 | #define __DEVLINK_PARAM_MAX_STRING_VALUE 32 |
| 383 | enum devlink_param_type { |
| 384 | DEVLINK_PARAM_TYPE_U8, |
| 385 | DEVLINK_PARAM_TYPE_U16, |
| 386 | DEVLINK_PARAM_TYPE_U32, |
| 387 | DEVLINK_PARAM_TYPE_STRING, |
| 388 | DEVLINK_PARAM_TYPE_BOOL, |
| 389 | }; |
| 390 | |
| 391 | union devlink_param_value { |
| 392 | u8 vu8; |
| 393 | u16 vu16; |
| 394 | u32 vu32; |
| 395 | char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE]; |
| 396 | bool vbool; |
| 397 | }; |
| 398 | |
| 399 | struct devlink_param_gset_ctx { |
| 400 | union devlink_param_value val; |
| 401 | enum devlink_param_cmode cmode; |
| 402 | }; |
| 403 | |
| 404 | /** |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 405 | * struct devlink_flash_notify - devlink dev flash notify data |
| 406 | * @status_msg: current status string |
| 407 | * @component: firmware component being updated |
| 408 | * @done: amount of work completed of total amount |
| 409 | * @total: amount of work expected to be done |
| 410 | * @timeout: expected max timeout in seconds |
| 411 | * |
| 412 | * These are values to be given to userland to be displayed in order |
| 413 | * to show current activity in a firmware update process. |
| 414 | */ |
| 415 | struct devlink_flash_notify { |
| 416 | const char *status_msg; |
| 417 | const char *component; |
| 418 | unsigned long done; |
| 419 | unsigned long total; |
| 420 | unsigned long timeout; |
| 421 | }; |
| 422 | |
| 423 | /** |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 424 | * struct devlink_param - devlink configuration parameter data |
| 425 | * @name: name of the parameter |
| 426 | * @generic: indicates if the parameter is generic or driver specific |
| 427 | * @type: parameter type |
| 428 | * @supported_cmodes: bitmap of supported configuration modes |
| 429 | * @get: get parameter value, used for runtime and permanent |
| 430 | * configuration modes |
| 431 | * @set: set parameter value, used for runtime and permanent |
| 432 | * configuration modes |
| 433 | * @validate: validate input value is applicable (within value range, etc.) |
| 434 | * |
| 435 | * This struct should be used by the driver to fill the data for |
| 436 | * a parameter it registers. |
| 437 | */ |
| 438 | struct devlink_param { |
| 439 | u32 id; |
| 440 | const char *name; |
| 441 | bool generic; |
| 442 | enum devlink_param_type type; |
| 443 | unsigned long supported_cmodes; |
| 444 | int (*get)(struct devlink *devlink, u32 id, |
| 445 | struct devlink_param_gset_ctx *ctx); |
| 446 | int (*set)(struct devlink *devlink, u32 id, |
| 447 | struct devlink_param_gset_ctx *ctx); |
| 448 | int (*validate)(struct devlink *devlink, u32 id, |
| 449 | union devlink_param_value val, |
| 450 | struct netlink_ext_ack *extack); |
| 451 | }; |
| 452 | |
| 453 | struct devlink_param_item { |
| 454 | struct list_head list; |
| 455 | const struct devlink_param *param; |
| 456 | union devlink_param_value driverinit_value; |
| 457 | bool driverinit_value_valid; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 458 | bool published; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 459 | }; |
| 460 | |
| 461 | enum devlink_param_generic_id { |
| 462 | DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, |
| 463 | DEVLINK_PARAM_GENERIC_ID_MAX_MACS, |
| 464 | DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, |
| 465 | DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 466 | DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, |
| 467 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, |
| 468 | DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, |
| 469 | DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, |
| 470 | DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 471 | DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, |
| 472 | DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 473 | |
| 474 | /* add new param generic ids above here*/ |
| 475 | __DEVLINK_PARAM_GENERIC_ID_MAX, |
| 476 | DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, |
| 477 | }; |
| 478 | |
| 479 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" |
| 480 | #define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 481 | |
| 482 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" |
| 483 | #define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 |
| 484 | |
| 485 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" |
| 486 | #define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 487 | |
| 488 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" |
| 489 | #define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 490 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 491 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" |
| 492 | #define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 493 | |
| 494 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" |
| 495 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 |
| 496 | |
| 497 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" |
| 498 | #define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 |
| 499 | |
| 500 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy" |
| 501 | #define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8 |
| 502 | |
| 503 | #define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_NAME \ |
| 504 | "reset_dev_on_drv_probe" |
| 505 | #define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_TYPE DEVLINK_PARAM_TYPE_U8 |
| 506 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 507 | #define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME "enable_roce" |
| 508 | #define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 509 | |
| 510 | #define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_NAME "enable_remote_dev_reset" |
| 511 | #define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL |
| 512 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 513 | #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ |
| 514 | { \ |
| 515 | .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ |
| 516 | .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ |
| 517 | .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ |
| 518 | .generic = true, \ |
| 519 | .supported_cmodes = _cmodes, \ |
| 520 | .get = _get, \ |
| 521 | .set = _set, \ |
| 522 | .validate = _validate, \ |
| 523 | } |
| 524 | |
| 525 | #define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ |
| 526 | { \ |
| 527 | .id = _id, \ |
| 528 | .name = _name, \ |
| 529 | .type = _type, \ |
| 530 | .supported_cmodes = _cmodes, \ |
| 531 | .get = _get, \ |
| 532 | .set = _set, \ |
| 533 | .validate = _validate, \ |
| 534 | } |
| 535 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 536 | /* Part number, identifier of board design */ |
| 537 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id" |
| 538 | /* Revision of board design */ |
| 539 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev" |
| 540 | /* Maker of the board */ |
| 541 | #define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture" |
| 542 | |
| 543 | /* Part number, identifier of asic design */ |
| 544 | #define DEVLINK_INFO_VERSION_GENERIC_ASIC_ID "asic.id" |
| 545 | /* Revision of asic design */ |
| 546 | #define DEVLINK_INFO_VERSION_GENERIC_ASIC_REV "asic.rev" |
| 547 | |
| 548 | /* Overall FW version */ |
| 549 | #define DEVLINK_INFO_VERSION_GENERIC_FW "fw" |
| 550 | /* Control processor FW version */ |
| 551 | #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt" |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 552 | /* FW interface specification version */ |
| 553 | #define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API "fw.mgmt.api" |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 554 | /* Data path microcode controlling high-speed packet processing */ |
| 555 | #define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app" |
| 556 | /* UNDI software version */ |
| 557 | #define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi" |
| 558 | /* NCSI support/handler version */ |
| 559 | #define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi" |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 560 | /* FW parameter set id */ |
| 561 | #define DEVLINK_INFO_VERSION_GENERIC_FW_PSID "fw.psid" |
| 562 | /* RoCE FW version */ |
| 563 | #define DEVLINK_INFO_VERSION_GENERIC_FW_ROCE "fw.roce" |
| 564 | /* Firmware bundle identifier */ |
| 565 | #define DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID "fw.bundle_id" |
| 566 | |
| 567 | /** |
| 568 | * struct devlink_flash_update_params - Flash Update parameters |
| 569 | * @file_name: the name of the flash firmware file to update from |
| 570 | * @component: the flash component to update |
| 571 | * |
| 572 | * With the exception of file_name, drivers must opt-in to parameters by |
| 573 | * setting the appropriate bit in the supported_flash_update_params field in |
| 574 | * their devlink_ops structure. |
| 575 | */ |
| 576 | struct devlink_flash_update_params { |
| 577 | const char *file_name; |
| 578 | const char *component; |
| 579 | u32 overwrite_mask; |
| 580 | }; |
| 581 | |
| 582 | #define DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT BIT(0) |
| 583 | #define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 584 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 585 | struct devlink_region; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 586 | struct devlink_info_req; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 587 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 588 | /** |
| 589 | * struct devlink_region_ops - Region operations |
| 590 | * @name: region name |
| 591 | * @destructor: callback used to free snapshot memory when deleting |
| 592 | * @snapshot: callback to request an immediate snapshot. On success, |
| 593 | * the data variable must be updated to point to the snapshot data. |
| 594 | * The function will be called while the devlink instance lock is |
| 595 | * held. |
| 596 | * @priv: Pointer to driver private data for the region operation |
| 597 | */ |
| 598 | struct devlink_region_ops { |
| 599 | const char *name; |
| 600 | void (*destructor)(const void *data); |
| 601 | int (*snapshot)(struct devlink *devlink, |
| 602 | const struct devlink_region_ops *ops, |
| 603 | struct netlink_ext_ack *extack, |
| 604 | u8 **data); |
| 605 | void *priv; |
| 606 | }; |
| 607 | |
| 608 | /** |
| 609 | * struct devlink_port_region_ops - Region operations for a port |
| 610 | * @name: region name |
| 611 | * @destructor: callback used to free snapshot memory when deleting |
| 612 | * @snapshot: callback to request an immediate snapshot. On success, |
| 613 | * the data variable must be updated to point to the snapshot data. |
| 614 | * The function will be called while the devlink instance lock is |
| 615 | * held. |
| 616 | * @priv: Pointer to driver private data for the region operation |
| 617 | */ |
| 618 | struct devlink_port_region_ops { |
| 619 | const char *name; |
| 620 | void (*destructor)(const void *data); |
| 621 | int (*snapshot)(struct devlink_port *port, |
| 622 | const struct devlink_port_region_ops *ops, |
| 623 | struct netlink_ext_ack *extack, |
| 624 | u8 **data); |
| 625 | void *priv; |
| 626 | }; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 627 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 628 | struct devlink_fmsg; |
| 629 | struct devlink_health_reporter; |
| 630 | |
| 631 | enum devlink_health_reporter_state { |
| 632 | DEVLINK_HEALTH_REPORTER_STATE_HEALTHY, |
| 633 | DEVLINK_HEALTH_REPORTER_STATE_ERROR, |
| 634 | }; |
| 635 | |
| 636 | /** |
| 637 | * struct devlink_health_reporter_ops - Reporter operations |
| 638 | * @name: reporter name |
| 639 | * @recover: callback to recover from reported error |
| 640 | * if priv_ctx is NULL, run a full recover |
| 641 | * @dump: callback to dump an object |
| 642 | * if priv_ctx is NULL, run a full dump |
| 643 | * @diagnose: callback to diagnose the current status |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 644 | * @test: callback to trigger a test event |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 645 | */ |
| 646 | |
| 647 | struct devlink_health_reporter_ops { |
| 648 | char *name; |
| 649 | int (*recover)(struct devlink_health_reporter *reporter, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 650 | void *priv_ctx, struct netlink_ext_ack *extack); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 651 | int (*dump)(struct devlink_health_reporter *reporter, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 652 | struct devlink_fmsg *fmsg, void *priv_ctx, |
| 653 | struct netlink_ext_ack *extack); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 654 | int (*diagnose)(struct devlink_health_reporter *reporter, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 655 | struct devlink_fmsg *fmsg, |
| 656 | struct netlink_ext_ack *extack); |
| 657 | int (*test)(struct devlink_health_reporter *reporter, |
| 658 | struct netlink_ext_ack *extack); |
| 659 | }; |
| 660 | |
| 661 | /** |
| 662 | * struct devlink_trap_metadata - Packet trap metadata. |
| 663 | * @trap_name: Trap name. |
| 664 | * @trap_group_name: Trap group name. |
| 665 | * @input_dev: Input netdevice. |
| 666 | * @fa_cookie: Flow action user cookie. |
| 667 | * @trap_type: Trap type. |
| 668 | */ |
| 669 | struct devlink_trap_metadata { |
| 670 | const char *trap_name; |
| 671 | const char *trap_group_name; |
| 672 | struct net_device *input_dev; |
| 673 | const struct flow_action_cookie *fa_cookie; |
| 674 | enum devlink_trap_type trap_type; |
| 675 | }; |
| 676 | |
| 677 | /** |
| 678 | * struct devlink_trap_policer - Immutable packet trap policer attributes. |
| 679 | * @id: Policer identifier. |
| 680 | * @init_rate: Initial rate in packets / sec. |
| 681 | * @init_burst: Initial burst size in packets. |
| 682 | * @max_rate: Maximum rate. |
| 683 | * @min_rate: Minimum rate. |
| 684 | * @max_burst: Maximum burst size. |
| 685 | * @min_burst: Minimum burst size. |
| 686 | * |
| 687 | * Describes immutable attributes of packet trap policers that drivers register |
| 688 | * with devlink. |
| 689 | */ |
| 690 | struct devlink_trap_policer { |
| 691 | u32 id; |
| 692 | u64 init_rate; |
| 693 | u64 init_burst; |
| 694 | u64 max_rate; |
| 695 | u64 min_rate; |
| 696 | u64 max_burst; |
| 697 | u64 min_burst; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 698 | }; |
| 699 | |
| 700 | /** |
| 701 | * struct devlink_trap_group - Immutable packet trap group attributes. |
| 702 | * @name: Trap group name. |
| 703 | * @id: Trap group identifier. |
| 704 | * @generic: Whether the trap group is generic or not. |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 705 | * @init_policer_id: Initial policer identifier. |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 706 | * |
| 707 | * Describes immutable attributes of packet trap groups that drivers register |
| 708 | * with devlink. |
| 709 | */ |
| 710 | struct devlink_trap_group { |
| 711 | const char *name; |
| 712 | u16 id; |
| 713 | bool generic; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 714 | u32 init_policer_id; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 715 | }; |
| 716 | |
| 717 | #define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT BIT(0) |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 718 | #define DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE BIT(1) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 719 | |
| 720 | /** |
| 721 | * struct devlink_trap - Immutable packet trap attributes. |
| 722 | * @type: Trap type. |
| 723 | * @init_action: Initial trap action. |
| 724 | * @generic: Whether the trap is generic or not. |
| 725 | * @id: Trap identifier. |
| 726 | * @name: Trap name. |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 727 | * @init_group_id: Initial group identifier. |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 728 | * @metadata_cap: Metadata types that can be provided by the trap. |
| 729 | * |
| 730 | * Describes immutable attributes of packet traps that drivers register with |
| 731 | * devlink. |
| 732 | */ |
| 733 | struct devlink_trap { |
| 734 | enum devlink_trap_type type; |
| 735 | enum devlink_trap_action init_action; |
| 736 | bool generic; |
| 737 | u16 id; |
| 738 | const char *name; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 739 | u16 init_group_id; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 740 | u32 metadata_cap; |
| 741 | }; |
| 742 | |
| 743 | /* All traps must be documented in |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 744 | * Documentation/networking/devlink/devlink-trap.rst |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 745 | */ |
| 746 | enum devlink_trap_generic_id { |
| 747 | DEVLINK_TRAP_GENERIC_ID_SMAC_MC, |
| 748 | DEVLINK_TRAP_GENERIC_ID_VLAN_TAG_MISMATCH, |
| 749 | DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER, |
| 750 | DEVLINK_TRAP_GENERIC_ID_INGRESS_STP_FILTER, |
| 751 | DEVLINK_TRAP_GENERIC_ID_EMPTY_TX_LIST, |
| 752 | DEVLINK_TRAP_GENERIC_ID_PORT_LOOPBACK_FILTER, |
| 753 | DEVLINK_TRAP_GENERIC_ID_BLACKHOLE_ROUTE, |
| 754 | DEVLINK_TRAP_GENERIC_ID_TTL_ERROR, |
| 755 | DEVLINK_TRAP_GENERIC_ID_TAIL_DROP, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 756 | DEVLINK_TRAP_GENERIC_ID_NON_IP_PACKET, |
| 757 | DEVLINK_TRAP_GENERIC_ID_UC_DIP_MC_DMAC, |
| 758 | DEVLINK_TRAP_GENERIC_ID_DIP_LB, |
| 759 | DEVLINK_TRAP_GENERIC_ID_SIP_MC, |
| 760 | DEVLINK_TRAP_GENERIC_ID_SIP_LB, |
| 761 | DEVLINK_TRAP_GENERIC_ID_CORRUPTED_IP_HDR, |
| 762 | DEVLINK_TRAP_GENERIC_ID_IPV4_SIP_BC, |
| 763 | DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_RESERVED_SCOPE, |
| 764 | DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE, |
| 765 | DEVLINK_TRAP_GENERIC_ID_MTU_ERROR, |
| 766 | DEVLINK_TRAP_GENERIC_ID_UNRESOLVED_NEIGH, |
| 767 | DEVLINK_TRAP_GENERIC_ID_RPF, |
| 768 | DEVLINK_TRAP_GENERIC_ID_REJECT_ROUTE, |
| 769 | DEVLINK_TRAP_GENERIC_ID_IPV4_LPM_UNICAST_MISS, |
| 770 | DEVLINK_TRAP_GENERIC_ID_IPV6_LPM_UNICAST_MISS, |
| 771 | DEVLINK_TRAP_GENERIC_ID_NON_ROUTABLE, |
| 772 | DEVLINK_TRAP_GENERIC_ID_DECAP_ERROR, |
| 773 | DEVLINK_TRAP_GENERIC_ID_OVERLAY_SMAC_MC, |
| 774 | DEVLINK_TRAP_GENERIC_ID_INGRESS_FLOW_ACTION_DROP, |
| 775 | DEVLINK_TRAP_GENERIC_ID_EGRESS_FLOW_ACTION_DROP, |
| 776 | DEVLINK_TRAP_GENERIC_ID_STP, |
| 777 | DEVLINK_TRAP_GENERIC_ID_LACP, |
| 778 | DEVLINK_TRAP_GENERIC_ID_LLDP, |
| 779 | DEVLINK_TRAP_GENERIC_ID_IGMP_QUERY, |
| 780 | DEVLINK_TRAP_GENERIC_ID_IGMP_V1_REPORT, |
| 781 | DEVLINK_TRAP_GENERIC_ID_IGMP_V2_REPORT, |
| 782 | DEVLINK_TRAP_GENERIC_ID_IGMP_V3_REPORT, |
| 783 | DEVLINK_TRAP_GENERIC_ID_IGMP_V2_LEAVE, |
| 784 | DEVLINK_TRAP_GENERIC_ID_MLD_QUERY, |
| 785 | DEVLINK_TRAP_GENERIC_ID_MLD_V1_REPORT, |
| 786 | DEVLINK_TRAP_GENERIC_ID_MLD_V2_REPORT, |
| 787 | DEVLINK_TRAP_GENERIC_ID_MLD_V1_DONE, |
| 788 | DEVLINK_TRAP_GENERIC_ID_IPV4_DHCP, |
| 789 | DEVLINK_TRAP_GENERIC_ID_IPV6_DHCP, |
| 790 | DEVLINK_TRAP_GENERIC_ID_ARP_REQUEST, |
| 791 | DEVLINK_TRAP_GENERIC_ID_ARP_RESPONSE, |
| 792 | DEVLINK_TRAP_GENERIC_ID_ARP_OVERLAY, |
| 793 | DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_SOLICIT, |
| 794 | DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_ADVERT, |
| 795 | DEVLINK_TRAP_GENERIC_ID_IPV4_BFD, |
| 796 | DEVLINK_TRAP_GENERIC_ID_IPV6_BFD, |
| 797 | DEVLINK_TRAP_GENERIC_ID_IPV4_OSPF, |
| 798 | DEVLINK_TRAP_GENERIC_ID_IPV6_OSPF, |
| 799 | DEVLINK_TRAP_GENERIC_ID_IPV4_BGP, |
| 800 | DEVLINK_TRAP_GENERIC_ID_IPV6_BGP, |
| 801 | DEVLINK_TRAP_GENERIC_ID_IPV4_VRRP, |
| 802 | DEVLINK_TRAP_GENERIC_ID_IPV6_VRRP, |
| 803 | DEVLINK_TRAP_GENERIC_ID_IPV4_PIM, |
| 804 | DEVLINK_TRAP_GENERIC_ID_IPV6_PIM, |
| 805 | DEVLINK_TRAP_GENERIC_ID_UC_LB, |
| 806 | DEVLINK_TRAP_GENERIC_ID_LOCAL_ROUTE, |
| 807 | DEVLINK_TRAP_GENERIC_ID_EXTERNAL_ROUTE, |
| 808 | DEVLINK_TRAP_GENERIC_ID_IPV6_UC_DIP_LINK_LOCAL_SCOPE, |
| 809 | DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_NODES, |
| 810 | DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_ROUTERS, |
| 811 | DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_SOLICIT, |
| 812 | DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ADVERT, |
| 813 | DEVLINK_TRAP_GENERIC_ID_IPV6_REDIRECT, |
| 814 | DEVLINK_TRAP_GENERIC_ID_IPV4_ROUTER_ALERT, |
| 815 | DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ALERT, |
| 816 | DEVLINK_TRAP_GENERIC_ID_PTP_EVENT, |
| 817 | DEVLINK_TRAP_GENERIC_ID_PTP_GENERAL, |
| 818 | DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE, |
| 819 | DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP, |
| 820 | DEVLINK_TRAP_GENERIC_ID_EARLY_DROP, |
| 821 | DEVLINK_TRAP_GENERIC_ID_VXLAN_PARSING, |
| 822 | DEVLINK_TRAP_GENERIC_ID_LLC_SNAP_PARSING, |
| 823 | DEVLINK_TRAP_GENERIC_ID_VLAN_PARSING, |
| 824 | DEVLINK_TRAP_GENERIC_ID_PPPOE_PPP_PARSING, |
| 825 | DEVLINK_TRAP_GENERIC_ID_MPLS_PARSING, |
| 826 | DEVLINK_TRAP_GENERIC_ID_ARP_PARSING, |
| 827 | DEVLINK_TRAP_GENERIC_ID_IP_1_PARSING, |
| 828 | DEVLINK_TRAP_GENERIC_ID_IP_N_PARSING, |
| 829 | DEVLINK_TRAP_GENERIC_ID_GRE_PARSING, |
| 830 | DEVLINK_TRAP_GENERIC_ID_UDP_PARSING, |
| 831 | DEVLINK_TRAP_GENERIC_ID_TCP_PARSING, |
| 832 | DEVLINK_TRAP_GENERIC_ID_IPSEC_PARSING, |
| 833 | DEVLINK_TRAP_GENERIC_ID_SCTP_PARSING, |
| 834 | DEVLINK_TRAP_GENERIC_ID_DCCP_PARSING, |
| 835 | DEVLINK_TRAP_GENERIC_ID_GTP_PARSING, |
| 836 | DEVLINK_TRAP_GENERIC_ID_ESP_PARSING, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 837 | |
| 838 | /* Add new generic trap IDs above */ |
| 839 | __DEVLINK_TRAP_GENERIC_ID_MAX, |
| 840 | DEVLINK_TRAP_GENERIC_ID_MAX = __DEVLINK_TRAP_GENERIC_ID_MAX - 1, |
| 841 | }; |
| 842 | |
| 843 | /* All trap groups must be documented in |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 844 | * Documentation/networking/devlink/devlink-trap.rst |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 845 | */ |
| 846 | enum devlink_trap_group_generic_id { |
| 847 | DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS, |
| 848 | DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 849 | DEVLINK_TRAP_GROUP_GENERIC_ID_L3_EXCEPTIONS, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 850 | DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 851 | DEVLINK_TRAP_GROUP_GENERIC_ID_TUNNEL_DROPS, |
| 852 | DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_DROPS, |
| 853 | DEVLINK_TRAP_GROUP_GENERIC_ID_STP, |
| 854 | DEVLINK_TRAP_GROUP_GENERIC_ID_LACP, |
| 855 | DEVLINK_TRAP_GROUP_GENERIC_ID_LLDP, |
| 856 | DEVLINK_TRAP_GROUP_GENERIC_ID_MC_SNOOPING, |
| 857 | DEVLINK_TRAP_GROUP_GENERIC_ID_DHCP, |
| 858 | DEVLINK_TRAP_GROUP_GENERIC_ID_NEIGH_DISCOVERY, |
| 859 | DEVLINK_TRAP_GROUP_GENERIC_ID_BFD, |
| 860 | DEVLINK_TRAP_GROUP_GENERIC_ID_OSPF, |
| 861 | DEVLINK_TRAP_GROUP_GENERIC_ID_BGP, |
| 862 | DEVLINK_TRAP_GROUP_GENERIC_ID_VRRP, |
| 863 | DEVLINK_TRAP_GROUP_GENERIC_ID_PIM, |
| 864 | DEVLINK_TRAP_GROUP_GENERIC_ID_UC_LB, |
| 865 | DEVLINK_TRAP_GROUP_GENERIC_ID_LOCAL_DELIVERY, |
| 866 | DEVLINK_TRAP_GROUP_GENERIC_ID_EXTERNAL_DELIVERY, |
| 867 | DEVLINK_TRAP_GROUP_GENERIC_ID_IPV6, |
| 868 | DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_EVENT, |
| 869 | DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_GENERAL, |
| 870 | DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_SAMPLE, |
| 871 | DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_TRAP, |
| 872 | DEVLINK_TRAP_GROUP_GENERIC_ID_PARSER_ERROR_DROPS, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 873 | |
| 874 | /* Add new generic trap group IDs above */ |
| 875 | __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX, |
| 876 | DEVLINK_TRAP_GROUP_GENERIC_ID_MAX = |
| 877 | __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX - 1, |
| 878 | }; |
| 879 | |
| 880 | #define DEVLINK_TRAP_GENERIC_NAME_SMAC_MC \ |
| 881 | "source_mac_is_multicast" |
| 882 | #define DEVLINK_TRAP_GENERIC_NAME_VLAN_TAG_MISMATCH \ |
| 883 | "vlan_tag_mismatch" |
| 884 | #define DEVLINK_TRAP_GENERIC_NAME_INGRESS_VLAN_FILTER \ |
| 885 | "ingress_vlan_filter" |
| 886 | #define DEVLINK_TRAP_GENERIC_NAME_INGRESS_STP_FILTER \ |
| 887 | "ingress_spanning_tree_filter" |
| 888 | #define DEVLINK_TRAP_GENERIC_NAME_EMPTY_TX_LIST \ |
| 889 | "port_list_is_empty" |
| 890 | #define DEVLINK_TRAP_GENERIC_NAME_PORT_LOOPBACK_FILTER \ |
| 891 | "port_loopback_filter" |
| 892 | #define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_ROUTE \ |
| 893 | "blackhole_route" |
| 894 | #define DEVLINK_TRAP_GENERIC_NAME_TTL_ERROR \ |
| 895 | "ttl_value_is_too_small" |
| 896 | #define DEVLINK_TRAP_GENERIC_NAME_TAIL_DROP \ |
| 897 | "tail_drop" |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 898 | #define DEVLINK_TRAP_GENERIC_NAME_NON_IP_PACKET \ |
| 899 | "non_ip" |
| 900 | #define DEVLINK_TRAP_GENERIC_NAME_UC_DIP_MC_DMAC \ |
| 901 | "uc_dip_over_mc_dmac" |
| 902 | #define DEVLINK_TRAP_GENERIC_NAME_DIP_LB \ |
| 903 | "dip_is_loopback_address" |
| 904 | #define DEVLINK_TRAP_GENERIC_NAME_SIP_MC \ |
| 905 | "sip_is_mc" |
| 906 | #define DEVLINK_TRAP_GENERIC_NAME_SIP_LB \ |
| 907 | "sip_is_loopback_address" |
| 908 | #define DEVLINK_TRAP_GENERIC_NAME_CORRUPTED_IP_HDR \ |
| 909 | "ip_header_corrupted" |
| 910 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_SIP_BC \ |
| 911 | "ipv4_sip_is_limited_bc" |
| 912 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_RESERVED_SCOPE \ |
| 913 | "ipv6_mc_dip_reserved_scope" |
| 914 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE \ |
| 915 | "ipv6_mc_dip_interface_local_scope" |
| 916 | #define DEVLINK_TRAP_GENERIC_NAME_MTU_ERROR \ |
| 917 | "mtu_value_is_too_small" |
| 918 | #define DEVLINK_TRAP_GENERIC_NAME_UNRESOLVED_NEIGH \ |
| 919 | "unresolved_neigh" |
| 920 | #define DEVLINK_TRAP_GENERIC_NAME_RPF \ |
| 921 | "mc_reverse_path_forwarding" |
| 922 | #define DEVLINK_TRAP_GENERIC_NAME_REJECT_ROUTE \ |
| 923 | "reject_route" |
| 924 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_LPM_UNICAST_MISS \ |
| 925 | "ipv4_lpm_miss" |
| 926 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_LPM_UNICAST_MISS \ |
| 927 | "ipv6_lpm_miss" |
| 928 | #define DEVLINK_TRAP_GENERIC_NAME_NON_ROUTABLE \ |
| 929 | "non_routable_packet" |
| 930 | #define DEVLINK_TRAP_GENERIC_NAME_DECAP_ERROR \ |
| 931 | "decap_error" |
| 932 | #define DEVLINK_TRAP_GENERIC_NAME_OVERLAY_SMAC_MC \ |
| 933 | "overlay_smac_is_mc" |
| 934 | #define DEVLINK_TRAP_GENERIC_NAME_INGRESS_FLOW_ACTION_DROP \ |
| 935 | "ingress_flow_action_drop" |
| 936 | #define DEVLINK_TRAP_GENERIC_NAME_EGRESS_FLOW_ACTION_DROP \ |
| 937 | "egress_flow_action_drop" |
| 938 | #define DEVLINK_TRAP_GENERIC_NAME_STP \ |
| 939 | "stp" |
| 940 | #define DEVLINK_TRAP_GENERIC_NAME_LACP \ |
| 941 | "lacp" |
| 942 | #define DEVLINK_TRAP_GENERIC_NAME_LLDP \ |
| 943 | "lldp" |
| 944 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_QUERY \ |
| 945 | "igmp_query" |
| 946 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V1_REPORT \ |
| 947 | "igmp_v1_report" |
| 948 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_REPORT \ |
| 949 | "igmp_v2_report" |
| 950 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V3_REPORT \ |
| 951 | "igmp_v3_report" |
| 952 | #define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_LEAVE \ |
| 953 | "igmp_v2_leave" |
| 954 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_QUERY \ |
| 955 | "mld_query" |
| 956 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_REPORT \ |
| 957 | "mld_v1_report" |
| 958 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_V2_REPORT \ |
| 959 | "mld_v2_report" |
| 960 | #define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_DONE \ |
| 961 | "mld_v1_done" |
| 962 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_DHCP \ |
| 963 | "ipv4_dhcp" |
| 964 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_DHCP \ |
| 965 | "ipv6_dhcp" |
| 966 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_REQUEST \ |
| 967 | "arp_request" |
| 968 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_RESPONSE \ |
| 969 | "arp_response" |
| 970 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_OVERLAY \ |
| 971 | "arp_overlay" |
| 972 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_SOLICIT \ |
| 973 | "ipv6_neigh_solicit" |
| 974 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_ADVERT \ |
| 975 | "ipv6_neigh_advert" |
| 976 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_BFD \ |
| 977 | "ipv4_bfd" |
| 978 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_BFD \ |
| 979 | "ipv6_bfd" |
| 980 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_OSPF \ |
| 981 | "ipv4_ospf" |
| 982 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_OSPF \ |
| 983 | "ipv6_ospf" |
| 984 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_BGP \ |
| 985 | "ipv4_bgp" |
| 986 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_BGP \ |
| 987 | "ipv6_bgp" |
| 988 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_VRRP \ |
| 989 | "ipv4_vrrp" |
| 990 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_VRRP \ |
| 991 | "ipv6_vrrp" |
| 992 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_PIM \ |
| 993 | "ipv4_pim" |
| 994 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_PIM \ |
| 995 | "ipv6_pim" |
| 996 | #define DEVLINK_TRAP_GENERIC_NAME_UC_LB \ |
| 997 | "uc_loopback" |
| 998 | #define DEVLINK_TRAP_GENERIC_NAME_LOCAL_ROUTE \ |
| 999 | "local_route" |
| 1000 | #define DEVLINK_TRAP_GENERIC_NAME_EXTERNAL_ROUTE \ |
| 1001 | "external_route" |
| 1002 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_UC_DIP_LINK_LOCAL_SCOPE \ |
| 1003 | "ipv6_uc_dip_link_local_scope" |
| 1004 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_NODES \ |
| 1005 | "ipv6_dip_all_nodes" |
| 1006 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_ROUTERS \ |
| 1007 | "ipv6_dip_all_routers" |
| 1008 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_SOLICIT \ |
| 1009 | "ipv6_router_solicit" |
| 1010 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ADVERT \ |
| 1011 | "ipv6_router_advert" |
| 1012 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_REDIRECT \ |
| 1013 | "ipv6_redirect" |
| 1014 | #define DEVLINK_TRAP_GENERIC_NAME_IPV4_ROUTER_ALERT \ |
| 1015 | "ipv4_router_alert" |
| 1016 | #define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ALERT \ |
| 1017 | "ipv6_router_alert" |
| 1018 | #define DEVLINK_TRAP_GENERIC_NAME_PTP_EVENT \ |
| 1019 | "ptp_event" |
| 1020 | #define DEVLINK_TRAP_GENERIC_NAME_PTP_GENERAL \ |
| 1021 | "ptp_general" |
| 1022 | #define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_SAMPLE \ |
| 1023 | "flow_action_sample" |
| 1024 | #define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP \ |
| 1025 | "flow_action_trap" |
| 1026 | #define DEVLINK_TRAP_GENERIC_NAME_EARLY_DROP \ |
| 1027 | "early_drop" |
| 1028 | #define DEVLINK_TRAP_GENERIC_NAME_VXLAN_PARSING \ |
| 1029 | "vxlan_parsing" |
| 1030 | #define DEVLINK_TRAP_GENERIC_NAME_LLC_SNAP_PARSING \ |
| 1031 | "llc_snap_parsing" |
| 1032 | #define DEVLINK_TRAP_GENERIC_NAME_VLAN_PARSING \ |
| 1033 | "vlan_parsing" |
| 1034 | #define DEVLINK_TRAP_GENERIC_NAME_PPPOE_PPP_PARSING \ |
| 1035 | "pppoe_ppp_parsing" |
| 1036 | #define DEVLINK_TRAP_GENERIC_NAME_MPLS_PARSING \ |
| 1037 | "mpls_parsing" |
| 1038 | #define DEVLINK_TRAP_GENERIC_NAME_ARP_PARSING \ |
| 1039 | "arp_parsing" |
| 1040 | #define DEVLINK_TRAP_GENERIC_NAME_IP_1_PARSING \ |
| 1041 | "ip_1_parsing" |
| 1042 | #define DEVLINK_TRAP_GENERIC_NAME_IP_N_PARSING \ |
| 1043 | "ip_n_parsing" |
| 1044 | #define DEVLINK_TRAP_GENERIC_NAME_GRE_PARSING \ |
| 1045 | "gre_parsing" |
| 1046 | #define DEVLINK_TRAP_GENERIC_NAME_UDP_PARSING \ |
| 1047 | "udp_parsing" |
| 1048 | #define DEVLINK_TRAP_GENERIC_NAME_TCP_PARSING \ |
| 1049 | "tcp_parsing" |
| 1050 | #define DEVLINK_TRAP_GENERIC_NAME_IPSEC_PARSING \ |
| 1051 | "ipsec_parsing" |
| 1052 | #define DEVLINK_TRAP_GENERIC_NAME_SCTP_PARSING \ |
| 1053 | "sctp_parsing" |
| 1054 | #define DEVLINK_TRAP_GENERIC_NAME_DCCP_PARSING \ |
| 1055 | "dccp_parsing" |
| 1056 | #define DEVLINK_TRAP_GENERIC_NAME_GTP_PARSING \ |
| 1057 | "gtp_parsing" |
| 1058 | #define DEVLINK_TRAP_GENERIC_NAME_ESP_PARSING \ |
| 1059 | "esp_parsing" |
| 1060 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1061 | |
| 1062 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \ |
| 1063 | "l2_drops" |
| 1064 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS \ |
| 1065 | "l3_drops" |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1066 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_EXCEPTIONS \ |
| 1067 | "l3_exceptions" |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1068 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS \ |
| 1069 | "buffer_drops" |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1070 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_TUNNEL_DROPS \ |
| 1071 | "tunnel_drops" |
| 1072 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_DROPS \ |
| 1073 | "acl_drops" |
| 1074 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_STP \ |
| 1075 | "stp" |
| 1076 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_LACP \ |
| 1077 | "lacp" |
| 1078 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_LLDP \ |
| 1079 | "lldp" |
| 1080 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_MC_SNOOPING \ |
| 1081 | "mc_snooping" |
| 1082 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_DHCP \ |
| 1083 | "dhcp" |
| 1084 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_NEIGH_DISCOVERY \ |
| 1085 | "neigh_discovery" |
| 1086 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BFD \ |
| 1087 | "bfd" |
| 1088 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_OSPF \ |
| 1089 | "ospf" |
| 1090 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BGP \ |
| 1091 | "bgp" |
| 1092 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_VRRP \ |
| 1093 | "vrrp" |
| 1094 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PIM \ |
| 1095 | "pim" |
| 1096 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_UC_LB \ |
| 1097 | "uc_loopback" |
| 1098 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_LOCAL_DELIVERY \ |
| 1099 | "local_delivery" |
| 1100 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_EXTERNAL_DELIVERY \ |
| 1101 | "external_delivery" |
| 1102 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_IPV6 \ |
| 1103 | "ipv6" |
| 1104 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_EVENT \ |
| 1105 | "ptp_event" |
| 1106 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_GENERAL \ |
| 1107 | "ptp_general" |
| 1108 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_SAMPLE \ |
| 1109 | "acl_sample" |
| 1110 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_TRAP \ |
| 1111 | "acl_trap" |
| 1112 | #define DEVLINK_TRAP_GROUP_GENERIC_NAME_PARSER_ERROR_DROPS \ |
| 1113 | "parser_error_drops" |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1114 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1115 | #define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id, \ |
| 1116 | _metadata_cap) \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1117 | { \ |
| 1118 | .type = DEVLINK_TRAP_TYPE_##_type, \ |
| 1119 | .init_action = DEVLINK_TRAP_ACTION_##_init_action, \ |
| 1120 | .generic = true, \ |
| 1121 | .id = DEVLINK_TRAP_GENERIC_ID_##_id, \ |
| 1122 | .name = DEVLINK_TRAP_GENERIC_NAME_##_id, \ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1123 | .init_group_id = _group_id, \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1124 | .metadata_cap = _metadata_cap, \ |
| 1125 | } |
| 1126 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1127 | #define DEVLINK_TRAP_DRIVER(_type, _init_action, _id, _name, _group_id, \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1128 | _metadata_cap) \ |
| 1129 | { \ |
| 1130 | .type = DEVLINK_TRAP_TYPE_##_type, \ |
| 1131 | .init_action = DEVLINK_TRAP_ACTION_##_init_action, \ |
| 1132 | .generic = false, \ |
| 1133 | .id = _id, \ |
| 1134 | .name = _name, \ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1135 | .init_group_id = _group_id, \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1136 | .metadata_cap = _metadata_cap, \ |
| 1137 | } |
| 1138 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1139 | #define DEVLINK_TRAP_GROUP_GENERIC(_id, _policer_id) \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1140 | { \ |
| 1141 | .name = DEVLINK_TRAP_GROUP_GENERIC_NAME_##_id, \ |
| 1142 | .id = DEVLINK_TRAP_GROUP_GENERIC_ID_##_id, \ |
| 1143 | .generic = true, \ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1144 | .init_policer_id = _policer_id, \ |
| 1145 | } |
| 1146 | |
| 1147 | #define DEVLINK_TRAP_POLICER(_id, _rate, _burst, _max_rate, _min_rate, \ |
| 1148 | _max_burst, _min_burst) \ |
| 1149 | { \ |
| 1150 | .id = _id, \ |
| 1151 | .init_rate = _rate, \ |
| 1152 | .init_burst = _burst, \ |
| 1153 | .max_rate = _max_rate, \ |
| 1154 | .min_rate = _min_rate, \ |
| 1155 | .max_burst = _max_burst, \ |
| 1156 | .min_burst = _min_burst, \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1159 | struct devlink_ops { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1160 | /** |
| 1161 | * @supported_flash_update_params: |
| 1162 | * mask of parameters supported by the driver's .flash_update |
| 1163 | * implemementation. |
| 1164 | */ |
| 1165 | u32 supported_flash_update_params; |
| 1166 | unsigned long reload_actions; |
| 1167 | unsigned long reload_limits; |
| 1168 | int (*reload_down)(struct devlink *devlink, bool netns_change, |
| 1169 | enum devlink_reload_action action, |
| 1170 | enum devlink_reload_limit limit, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1171 | struct netlink_ext_ack *extack); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1172 | int (*reload_up)(struct devlink *devlink, enum devlink_reload_action action, |
| 1173 | enum devlink_reload_limit limit, u32 *actions_performed, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1174 | struct netlink_ext_ack *extack); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1175 | int (*port_type_set)(struct devlink_port *devlink_port, |
| 1176 | enum devlink_port_type port_type); |
| 1177 | int (*port_split)(struct devlink *devlink, unsigned int port_index, |
| 1178 | unsigned int count, struct netlink_ext_ack *extack); |
| 1179 | int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, |
| 1180 | struct netlink_ext_ack *extack); |
| 1181 | int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, |
| 1182 | u16 pool_index, |
| 1183 | struct devlink_sb_pool_info *pool_info); |
| 1184 | int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, |
| 1185 | u16 pool_index, u32 size, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1186 | enum devlink_sb_threshold_type threshold_type, |
| 1187 | struct netlink_ext_ack *extack); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1188 | int (*sb_port_pool_get)(struct devlink_port *devlink_port, |
| 1189 | unsigned int sb_index, u16 pool_index, |
| 1190 | u32 *p_threshold); |
| 1191 | int (*sb_port_pool_set)(struct devlink_port *devlink_port, |
| 1192 | unsigned int sb_index, u16 pool_index, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1193 | u32 threshold, struct netlink_ext_ack *extack); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1194 | int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, |
| 1195 | unsigned int sb_index, |
| 1196 | u16 tc_index, |
| 1197 | enum devlink_sb_pool_type pool_type, |
| 1198 | u16 *p_pool_index, u32 *p_threshold); |
| 1199 | int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, |
| 1200 | unsigned int sb_index, |
| 1201 | u16 tc_index, |
| 1202 | enum devlink_sb_pool_type pool_type, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1203 | u16 pool_index, u32 threshold, |
| 1204 | struct netlink_ext_ack *extack); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1205 | int (*sb_occ_snapshot)(struct devlink *devlink, |
| 1206 | unsigned int sb_index); |
| 1207 | int (*sb_occ_max_clear)(struct devlink *devlink, |
| 1208 | unsigned int sb_index); |
| 1209 | int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, |
| 1210 | unsigned int sb_index, u16 pool_index, |
| 1211 | u32 *p_cur, u32 *p_max); |
| 1212 | int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, |
| 1213 | unsigned int sb_index, |
| 1214 | u16 tc_index, |
| 1215 | enum devlink_sb_pool_type pool_type, |
| 1216 | u32 *p_cur, u32 *p_max); |
| 1217 | |
| 1218 | int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1219 | int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, |
| 1220 | struct netlink_ext_ack *extack); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1221 | int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1222 | int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, |
| 1223 | struct netlink_ext_ack *extack); |
| 1224 | int (*eswitch_encap_mode_get)(struct devlink *devlink, |
| 1225 | enum devlink_eswitch_encap_mode *p_encap_mode); |
| 1226 | int (*eswitch_encap_mode_set)(struct devlink *devlink, |
| 1227 | enum devlink_eswitch_encap_mode encap_mode, |
| 1228 | struct netlink_ext_ack *extack); |
| 1229 | int (*info_get)(struct devlink *devlink, struct devlink_info_req *req, |
| 1230 | struct netlink_ext_ack *extack); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1231 | /** |
| 1232 | * @flash_update: Device flash update function |
| 1233 | * |
| 1234 | * Used to perform a flash update for the device. The set of |
| 1235 | * parameters supported by the driver should be set in |
| 1236 | * supported_flash_update_params. |
| 1237 | */ |
| 1238 | int (*flash_update)(struct devlink *devlink, |
| 1239 | struct devlink_flash_update_params *params, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1240 | struct netlink_ext_ack *extack); |
| 1241 | /** |
| 1242 | * @trap_init: Trap initialization function. |
| 1243 | * |
| 1244 | * Should be used by device drivers to initialize the trap in the |
| 1245 | * underlying device. Drivers should also store the provided trap |
| 1246 | * context, so that they could efficiently pass it to |
| 1247 | * devlink_trap_report() when the trap is triggered. |
| 1248 | */ |
| 1249 | int (*trap_init)(struct devlink *devlink, |
| 1250 | const struct devlink_trap *trap, void *trap_ctx); |
| 1251 | /** |
| 1252 | * @trap_fini: Trap de-initialization function. |
| 1253 | * |
| 1254 | * Should be used by device drivers to de-initialize the trap in the |
| 1255 | * underlying device. |
| 1256 | */ |
| 1257 | void (*trap_fini)(struct devlink *devlink, |
| 1258 | const struct devlink_trap *trap, void *trap_ctx); |
| 1259 | /** |
| 1260 | * @trap_action_set: Trap action set function. |
| 1261 | */ |
| 1262 | int (*trap_action_set)(struct devlink *devlink, |
| 1263 | const struct devlink_trap *trap, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1264 | enum devlink_trap_action action, |
| 1265 | struct netlink_ext_ack *extack); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1266 | /** |
| 1267 | * @trap_group_init: Trap group initialization function. |
| 1268 | * |
| 1269 | * Should be used by device drivers to initialize the trap group in the |
| 1270 | * underlying device. |
| 1271 | */ |
| 1272 | int (*trap_group_init)(struct devlink *devlink, |
| 1273 | const struct devlink_trap_group *group); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1274 | /** |
| 1275 | * @trap_group_set: Trap group parameters set function. |
| 1276 | * |
| 1277 | * Note: @policer can be NULL when a policer is being unbound from |
| 1278 | * @group. |
| 1279 | */ |
| 1280 | int (*trap_group_set)(struct devlink *devlink, |
| 1281 | const struct devlink_trap_group *group, |
| 1282 | const struct devlink_trap_policer *policer, |
| 1283 | struct netlink_ext_ack *extack); |
| 1284 | /** |
| 1285 | * @trap_group_action_set: Trap group action set function. |
| 1286 | * |
| 1287 | * If this callback is populated, it will take precedence over looping |
| 1288 | * over all traps in a group and calling .trap_action_set(). |
| 1289 | */ |
| 1290 | int (*trap_group_action_set)(struct devlink *devlink, |
| 1291 | const struct devlink_trap_group *group, |
| 1292 | enum devlink_trap_action action, |
| 1293 | struct netlink_ext_ack *extack); |
| 1294 | /** |
| 1295 | * @trap_policer_init: Trap policer initialization function. |
| 1296 | * |
| 1297 | * Should be used by device drivers to initialize the trap policer in |
| 1298 | * the underlying device. |
| 1299 | */ |
| 1300 | int (*trap_policer_init)(struct devlink *devlink, |
| 1301 | const struct devlink_trap_policer *policer); |
| 1302 | /** |
| 1303 | * @trap_policer_fini: Trap policer de-initialization function. |
| 1304 | * |
| 1305 | * Should be used by device drivers to de-initialize the trap policer |
| 1306 | * in the underlying device. |
| 1307 | */ |
| 1308 | void (*trap_policer_fini)(struct devlink *devlink, |
| 1309 | const struct devlink_trap_policer *policer); |
| 1310 | /** |
| 1311 | * @trap_policer_set: Trap policer parameters set function. |
| 1312 | */ |
| 1313 | int (*trap_policer_set)(struct devlink *devlink, |
| 1314 | const struct devlink_trap_policer *policer, |
| 1315 | u64 rate, u64 burst, |
| 1316 | struct netlink_ext_ack *extack); |
| 1317 | /** |
| 1318 | * @trap_policer_counter_get: Trap policer counter get function. |
| 1319 | * |
| 1320 | * Should be used by device drivers to report number of packets dropped |
| 1321 | * by the policer. |
| 1322 | */ |
| 1323 | int (*trap_policer_counter_get)(struct devlink *devlink, |
| 1324 | const struct devlink_trap_policer *policer, |
| 1325 | u64 *p_drops); |
| 1326 | /** |
| 1327 | * @port_function_hw_addr_get: Port function's hardware address get function. |
| 1328 | * |
| 1329 | * Should be used by device drivers to report the hardware address of a function managed |
| 1330 | * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port |
| 1331 | * function handling for a particular port. |
| 1332 | * |
| 1333 | * Note: @extack can be NULL when port notifier queries the port function. |
| 1334 | */ |
| 1335 | int (*port_function_hw_addr_get)(struct devlink *devlink, struct devlink_port *port, |
| 1336 | u8 *hw_addr, int *hw_addr_len, |
| 1337 | struct netlink_ext_ack *extack); |
| 1338 | /** |
| 1339 | * @port_function_hw_addr_set: Port function's hardware address set function. |
| 1340 | * |
| 1341 | * Should be used by device drivers to set the hardware address of a function managed |
| 1342 | * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port |
| 1343 | * function handling for a particular port. |
| 1344 | */ |
| 1345 | int (*port_function_hw_addr_set)(struct devlink *devlink, struct devlink_port *port, |
| 1346 | const u8 *hw_addr, int hw_addr_len, |
| 1347 | struct netlink_ext_ack *extack); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1348 | }; |
| 1349 | |
| 1350 | static inline void *devlink_priv(struct devlink *devlink) |
| 1351 | { |
| 1352 | BUG_ON(!devlink); |
| 1353 | return &devlink->priv; |
| 1354 | } |
| 1355 | |
| 1356 | static inline struct devlink *priv_to_devlink(void *priv) |
| 1357 | { |
| 1358 | BUG_ON(!priv); |
| 1359 | return container_of(priv, struct devlink, priv); |
| 1360 | } |
| 1361 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1362 | static inline struct devlink_port * |
| 1363 | netdev_to_devlink_port(struct net_device *dev) |
| 1364 | { |
| 1365 | if (dev->netdev_ops->ndo_get_devlink_port) |
| 1366 | return dev->netdev_ops->ndo_get_devlink_port(dev); |
| 1367 | return NULL; |
| 1368 | } |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1369 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1370 | static inline struct devlink *netdev_to_devlink(struct net_device *dev) |
| 1371 | { |
| 1372 | struct devlink_port *devlink_port = netdev_to_devlink_port(dev); |
| 1373 | |
| 1374 | if (devlink_port) |
| 1375 | return devlink_port->devlink; |
| 1376 | return NULL; |
| 1377 | } |
| 1378 | |
| 1379 | struct ib_device; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1380 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1381 | struct net *devlink_net(const struct devlink *devlink); |
| 1382 | void devlink_net_set(struct devlink *devlink, struct net *net); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1383 | struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); |
| 1384 | int devlink_register(struct devlink *devlink, struct device *dev); |
| 1385 | void devlink_unregister(struct devlink *devlink); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1386 | void devlink_reload_enable(struct devlink *devlink); |
| 1387 | void devlink_reload_disable(struct devlink *devlink); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1388 | void devlink_free(struct devlink *devlink); |
| 1389 | int devlink_port_register(struct devlink *devlink, |
| 1390 | struct devlink_port *devlink_port, |
| 1391 | unsigned int port_index); |
| 1392 | void devlink_port_unregister(struct devlink_port *devlink_port); |
| 1393 | void devlink_port_type_eth_set(struct devlink_port *devlink_port, |
| 1394 | struct net_device *netdev); |
| 1395 | void devlink_port_type_ib_set(struct devlink_port *devlink_port, |
| 1396 | struct ib_device *ibdev); |
| 1397 | void devlink_port_type_clear(struct devlink_port *devlink_port); |
| 1398 | void devlink_port_attrs_set(struct devlink_port *devlink_port, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1399 | struct devlink_port_attrs *devlink_port_attrs); |
| 1400 | void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 controller, |
| 1401 | u16 pf, bool external); |
| 1402 | void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller, |
| 1403 | u16 pf, u16 vf, bool external); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1404 | int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, |
| 1405 | u32 size, u16 ingress_pools_count, |
| 1406 | u16 egress_pools_count, u16 ingress_tc_count, |
| 1407 | u16 egress_tc_count); |
| 1408 | void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); |
| 1409 | int devlink_dpipe_table_register(struct devlink *devlink, |
| 1410 | const char *table_name, |
| 1411 | struct devlink_dpipe_table_ops *table_ops, |
| 1412 | void *priv, bool counter_control_extern); |
| 1413 | void devlink_dpipe_table_unregister(struct devlink *devlink, |
| 1414 | const char *table_name); |
| 1415 | int devlink_dpipe_headers_register(struct devlink *devlink, |
| 1416 | struct devlink_dpipe_headers *dpipe_headers); |
| 1417 | void devlink_dpipe_headers_unregister(struct devlink *devlink); |
| 1418 | bool devlink_dpipe_table_counter_enabled(struct devlink *devlink, |
| 1419 | const char *table_name); |
| 1420 | int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); |
| 1421 | int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, |
| 1422 | struct devlink_dpipe_entry *entry); |
| 1423 | int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx); |
| 1424 | void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); |
| 1425 | int devlink_dpipe_action_put(struct sk_buff *skb, |
| 1426 | struct devlink_dpipe_action *action); |
| 1427 | int devlink_dpipe_match_put(struct sk_buff *skb, |
| 1428 | struct devlink_dpipe_match *match); |
| 1429 | extern struct devlink_dpipe_header devlink_dpipe_header_ethernet; |
| 1430 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv4; |
| 1431 | extern struct devlink_dpipe_header devlink_dpipe_header_ipv6; |
| 1432 | |
| 1433 | int devlink_resource_register(struct devlink *devlink, |
| 1434 | const char *resource_name, |
| 1435 | u64 resource_size, |
| 1436 | u64 resource_id, |
| 1437 | u64 parent_resource_id, |
| 1438 | const struct devlink_resource_size_params *size_params); |
| 1439 | void devlink_resources_unregister(struct devlink *devlink, |
| 1440 | struct devlink_resource *resource); |
| 1441 | int devlink_resource_size_get(struct devlink *devlink, |
| 1442 | u64 resource_id, |
| 1443 | u64 *p_resource_size); |
| 1444 | int devlink_dpipe_table_resource_set(struct devlink *devlink, |
| 1445 | const char *table_name, u64 resource_id, |
| 1446 | u64 resource_units); |
| 1447 | void devlink_resource_occ_get_register(struct devlink *devlink, |
| 1448 | u64 resource_id, |
| 1449 | devlink_resource_occ_get_t *occ_get, |
| 1450 | void *occ_get_priv); |
| 1451 | void devlink_resource_occ_get_unregister(struct devlink *devlink, |
| 1452 | u64 resource_id); |
| 1453 | int devlink_params_register(struct devlink *devlink, |
| 1454 | const struct devlink_param *params, |
| 1455 | size_t params_count); |
| 1456 | void devlink_params_unregister(struct devlink *devlink, |
| 1457 | const struct devlink_param *params, |
| 1458 | size_t params_count); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1459 | void devlink_params_publish(struct devlink *devlink); |
| 1460 | void devlink_params_unpublish(struct devlink *devlink); |
| 1461 | int devlink_port_params_register(struct devlink_port *devlink_port, |
| 1462 | const struct devlink_param *params, |
| 1463 | size_t params_count); |
| 1464 | void devlink_port_params_unregister(struct devlink_port *devlink_port, |
| 1465 | const struct devlink_param *params, |
| 1466 | size_t params_count); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1467 | int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, |
| 1468 | union devlink_param_value *init_val); |
| 1469 | int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, |
| 1470 | union devlink_param_value init_val); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1471 | int |
| 1472 | devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port, |
| 1473 | u32 param_id, |
| 1474 | union devlink_param_value *init_val); |
| 1475 | int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port, |
| 1476 | u32 param_id, |
| 1477 | union devlink_param_value init_val); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1478 | void devlink_param_value_changed(struct devlink *devlink, u32 param_id); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1479 | void devlink_port_param_value_changed(struct devlink_port *devlink_port, |
| 1480 | u32 param_id); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1481 | void devlink_param_value_str_fill(union devlink_param_value *dst_val, |
| 1482 | const char *src); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1483 | struct devlink_region * |
| 1484 | devlink_region_create(struct devlink *devlink, |
| 1485 | const struct devlink_region_ops *ops, |
| 1486 | u32 region_max_snapshots, u64 region_size); |
| 1487 | struct devlink_region * |
| 1488 | devlink_port_region_create(struct devlink_port *port, |
| 1489 | const struct devlink_port_region_ops *ops, |
| 1490 | u32 region_max_snapshots, u64 region_size); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1491 | void devlink_region_destroy(struct devlink_region *region); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1492 | void devlink_port_region_destroy(struct devlink_region *region); |
| 1493 | |
| 1494 | int devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id); |
| 1495 | void devlink_region_snapshot_id_put(struct devlink *devlink, u32 id); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1496 | int devlink_region_snapshot_create(struct devlink_region *region, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1497 | u8 *data, u32 snapshot_id); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1498 | int devlink_info_serial_number_put(struct devlink_info_req *req, |
| 1499 | const char *sn); |
| 1500 | int devlink_info_driver_name_put(struct devlink_info_req *req, |
| 1501 | const char *name); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1502 | int devlink_info_board_serial_number_put(struct devlink_info_req *req, |
| 1503 | const char *bsn); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1504 | int devlink_info_version_fixed_put(struct devlink_info_req *req, |
| 1505 | const char *version_name, |
| 1506 | const char *version_value); |
| 1507 | int devlink_info_version_stored_put(struct devlink_info_req *req, |
| 1508 | const char *version_name, |
| 1509 | const char *version_value); |
| 1510 | int devlink_info_version_running_put(struct devlink_info_req *req, |
| 1511 | const char *version_name, |
| 1512 | const char *version_value); |
| 1513 | |
| 1514 | int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg); |
| 1515 | int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg); |
| 1516 | |
| 1517 | int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name); |
| 1518 | int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg); |
| 1519 | |
| 1520 | int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg, |
| 1521 | const char *name); |
| 1522 | int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1523 | int devlink_fmsg_binary_pair_nest_start(struct devlink_fmsg *fmsg, |
| 1524 | const char *name); |
| 1525 | int devlink_fmsg_binary_pair_nest_end(struct devlink_fmsg *fmsg); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1526 | |
| 1527 | int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value); |
| 1528 | int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value); |
| 1529 | int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value); |
| 1530 | int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value); |
| 1531 | int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value); |
| 1532 | int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, |
| 1533 | u16 value_len); |
| 1534 | |
| 1535 | int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 1536 | bool value); |
| 1537 | int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 1538 | u8 value); |
| 1539 | int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 1540 | u32 value); |
| 1541 | int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 1542 | u64 value); |
| 1543 | int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name, |
| 1544 | const char *value); |
| 1545 | int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1546 | const void *value, u32 value_len); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1547 | |
| 1548 | struct devlink_health_reporter * |
| 1549 | devlink_health_reporter_create(struct devlink *devlink, |
| 1550 | const struct devlink_health_reporter_ops *ops, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1551 | u64 graceful_period, void *priv); |
| 1552 | |
| 1553 | struct devlink_health_reporter * |
| 1554 | devlink_port_health_reporter_create(struct devlink_port *port, |
| 1555 | const struct devlink_health_reporter_ops *ops, |
| 1556 | u64 graceful_period, void *priv); |
| 1557 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1558 | void |
| 1559 | devlink_health_reporter_destroy(struct devlink_health_reporter *reporter); |
| 1560 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1561 | void |
| 1562 | devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter); |
| 1563 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1564 | void * |
| 1565 | devlink_health_reporter_priv(struct devlink_health_reporter *reporter); |
| 1566 | int devlink_health_report(struct devlink_health_reporter *reporter, |
| 1567 | const char *msg, void *priv_ctx); |
| 1568 | void |
| 1569 | devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, |
| 1570 | enum devlink_health_reporter_state state); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1571 | void |
| 1572 | devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1573 | |
| 1574 | bool devlink_is_reload_failed(const struct devlink *devlink); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1575 | void devlink_remote_reload_actions_performed(struct devlink *devlink, |
| 1576 | enum devlink_reload_limit limit, |
| 1577 | u32 actions_performed); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1578 | |
| 1579 | void devlink_flash_update_begin_notify(struct devlink *devlink); |
| 1580 | void devlink_flash_update_end_notify(struct devlink *devlink); |
| 1581 | void devlink_flash_update_status_notify(struct devlink *devlink, |
| 1582 | const char *status_msg, |
| 1583 | const char *component, |
| 1584 | unsigned long done, |
| 1585 | unsigned long total); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1586 | void devlink_flash_update_timeout_notify(struct devlink *devlink, |
| 1587 | const char *status_msg, |
| 1588 | const char *component, |
| 1589 | unsigned long timeout); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1590 | |
| 1591 | int devlink_traps_register(struct devlink *devlink, |
| 1592 | const struct devlink_trap *traps, |
| 1593 | size_t traps_count, void *priv); |
| 1594 | void devlink_traps_unregister(struct devlink *devlink, |
| 1595 | const struct devlink_trap *traps, |
| 1596 | size_t traps_count); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1597 | void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, |
| 1598 | void *trap_ctx, struct devlink_port *in_devlink_port, |
| 1599 | const struct flow_action_cookie *fa_cookie); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1600 | void *devlink_trap_ctx_priv(void *trap_ctx); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1601 | int devlink_trap_groups_register(struct devlink *devlink, |
| 1602 | const struct devlink_trap_group *groups, |
| 1603 | size_t groups_count); |
| 1604 | void devlink_trap_groups_unregister(struct devlink *devlink, |
| 1605 | const struct devlink_trap_group *groups, |
| 1606 | size_t groups_count); |
| 1607 | int |
| 1608 | devlink_trap_policers_register(struct devlink *devlink, |
| 1609 | const struct devlink_trap_policer *policers, |
| 1610 | size_t policers_count); |
| 1611 | void |
| 1612 | devlink_trap_policers_unregister(struct devlink *devlink, |
| 1613 | const struct devlink_trap_policer *policers, |
| 1614 | size_t policers_count); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1615 | |
| 1616 | #if IS_ENABLED(CONFIG_NET_DEVLINK) |
| 1617 | |
| 1618 | void devlink_compat_running_version(struct net_device *dev, |
| 1619 | char *buf, size_t len); |
| 1620 | int devlink_compat_flash_update(struct net_device *dev, const char *file_name); |
| 1621 | int devlink_compat_phys_port_name_get(struct net_device *dev, |
| 1622 | char *name, size_t len); |
| 1623 | int devlink_compat_switch_id_get(struct net_device *dev, |
| 1624 | struct netdev_phys_item_id *ppid); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1625 | |
| 1626 | #else |
| 1627 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1628 | static inline void |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1629 | devlink_compat_running_version(struct net_device *dev, char *buf, size_t len) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1630 | { |
| 1631 | } |
| 1632 | |
| 1633 | static inline int |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1634 | devlink_compat_flash_update(struct net_device *dev, const char *file_name) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1635 | { |
| 1636 | return -EOPNOTSUPP; |
| 1637 | } |
| 1638 | |
| 1639 | static inline int |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1640 | devlink_compat_phys_port_name_get(struct net_device *dev, |
| 1641 | char *name, size_t len) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1642 | { |
| 1643 | return -EOPNOTSUPP; |
| 1644 | } |
| 1645 | |
| 1646 | static inline int |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1647 | devlink_compat_switch_id_get(struct net_device *dev, |
| 1648 | struct netdev_phys_item_id *ppid) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1649 | { |
| 1650 | return -EOPNOTSUPP; |
| 1651 | } |
| 1652 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1653 | #endif |
| 1654 | |
| 1655 | #endif /* _NET_DEVLINK_H_ */ |