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