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