blob: 63de99e09f046e9bc91f9b77aab0051d8919f943 [file] [log] [blame]
Jiri Pirkobfcd3a42016-02-26 17:32:23 +01001/*
2 * include/net/devlink.h - Network physical device Netlink interface
3 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef _NET_DEVLINK_H_
12#define _NET_DEVLINK_H_
13
14#include <linux/device.h>
15#include <linux/slab.h>
16#include <linux/gfp.h>
17#include <linux/list.h>
18#include <linux/netdevice.h>
19#include <net/net_namespace.h>
20#include <uapi/linux/devlink.h>
21
22struct devlink_ops;
23
24struct devlink {
25 struct list_head list;
26 struct list_head port_list;
Jiri Pirkobf797472016-04-14 18:19:13 +020027 struct list_head sb_list;
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +020028 struct list_head dpipe_table_list;
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +010029 struct list_head resource_list;
Moshe Shemesheabaef12018-07-04 14:30:28 +030030 struct list_head param_list;
Alex Veskerb16ebe92018-07-12 15:13:08 +030031 struct list_head region_list;
Alex Veskerccadfa42018-07-12 15:13:09 +030032 u32 snapshot_id;
Eran Ben Elishaa0bdcc52019-02-07 11:36:33 +020033 struct list_head reporter_list;
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +020034 struct devlink_dpipe_headers *dpipe_headers;
Jiri Pirkobfcd3a42016-02-26 17:32:23 +010035 const struct devlink_ops *ops;
36 struct device *dev;
37 possible_net_t _net;
Arkadi Sharshevsky2406e7e2018-01-15 08:59:02 +010038 struct mutex lock;
Jiri Pirkobfcd3a42016-02-26 17:32:23 +010039 char priv[0] __aligned(NETDEV_ALIGN);
40};
41
Jiri Pirkob9ffcba2018-05-18 09:29:00 +020042struct devlink_port_attrs {
43 bool set;
Jiri Pirko5ec13802018-05-18 09:29:01 +020044 enum devlink_port_flavour flavour;
Jiri Pirkob9ffcba2018-05-18 09:29:00 +020045 u32 port_number; /* same value as "split group" */
46 bool split;
47 u32 split_subport_number;
48};
49
Jiri Pirkobfcd3a42016-02-26 17:32:23 +010050struct devlink_port {
51 struct list_head list;
Vasundhara Volam39e61602019-01-28 18:00:20 +053052 struct list_head param_list;
Jiri Pirkobfcd3a42016-02-26 17:32:23 +010053 struct devlink *devlink;
54 unsigned index;
55 bool registered;
56 enum devlink_port_type type;
57 enum devlink_port_type desired_type;
58 void *type_dev;
Jiri Pirkob9ffcba2018-05-18 09:29:00 +020059 struct devlink_port_attrs attrs;
Jiri Pirkobfcd3a42016-02-26 17:32:23 +010060};
61
Jiri Pirkobf797472016-04-14 18:19:13 +020062struct devlink_sb_pool_info {
63 enum devlink_sb_pool_type pool_type;
64 u32 size;
65 enum devlink_sb_threshold_type threshold_type;
Jakub Kicinskibff57312019-02-01 17:56:28 -080066 u32 cell_size;
Jiri Pirkobf797472016-04-14 18:19:13 +020067};
68
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +020069/**
70 * struct devlink_dpipe_field - dpipe field object
71 * @name: field name
72 * @id: index inside the headers field array
73 * @bitwidth: bitwidth
74 * @mapping_type: mapping type
75 */
76struct devlink_dpipe_field {
77 const char *name;
78 unsigned int id;
79 unsigned int bitwidth;
80 enum devlink_dpipe_field_mapping_type mapping_type;
81};
82
83/**
84 * struct devlink_dpipe_header - dpipe header object
85 * @name: header name
86 * @id: index, global/local detrmined by global bit
87 * @fields: fields
88 * @fields_count: number of fields
89 * @global: indicates if header is shared like most protocol header
90 * or driver specific
91 */
92struct devlink_dpipe_header {
93 const char *name;
94 unsigned int id;
95 struct devlink_dpipe_field *fields;
96 unsigned int fields_count;
97 bool global;
98};
99
100/**
101 * struct devlink_dpipe_match - represents match operation
102 * @type: type of match
103 * @header_index: header index (packets can have several headers of same
104 * type like in case of tunnels)
105 * @header: header
106 * @fieled_id: field index
107 */
108struct devlink_dpipe_match {
109 enum devlink_dpipe_match_type type;
110 unsigned int header_index;
111 struct devlink_dpipe_header *header;
112 unsigned int field_id;
113};
114
115/**
116 * struct devlink_dpipe_action - represents action operation
117 * @type: type of action
118 * @header_index: header index (packets can have several headers of same
119 * type like in case of tunnels)
120 * @header: header
121 * @fieled_id: field index
122 */
123struct devlink_dpipe_action {
124 enum devlink_dpipe_action_type type;
125 unsigned int header_index;
126 struct devlink_dpipe_header *header;
127 unsigned int field_id;
128};
129
130/**
131 * struct devlink_dpipe_value - represents value of match/action
132 * @action: action
133 * @match: match
134 * @mapping_value: in case the field has some mapping this value
135 * specified the mapping value
136 * @mapping_valid: specify if mapping value is valid
137 * @value_size: value size
138 * @value: value
139 * @mask: bit mask
140 */
141struct devlink_dpipe_value {
142 union {
143 struct devlink_dpipe_action *action;
144 struct devlink_dpipe_match *match;
145 };
146 unsigned int mapping_value;
147 bool mapping_valid;
148 unsigned int value_size;
149 void *value;
150 void *mask;
151};
152
153/**
154 * struct devlink_dpipe_entry - table entry object
155 * @index: index of the entry in the table
156 * @match_values: match values
157 * @matche_values_count: count of matches tuples
158 * @action_values: actions values
159 * @action_values_count: count of actions values
160 * @counter: value of counter
161 * @counter_valid: Specify if value is valid from hardware
162 */
163struct devlink_dpipe_entry {
164 u64 index;
165 struct devlink_dpipe_value *match_values;
166 unsigned int match_values_count;
167 struct devlink_dpipe_value *action_values;
168 unsigned int action_values_count;
169 u64 counter;
170 bool counter_valid;
171};
172
173/**
174 * struct devlink_dpipe_dump_ctx - context provided to driver in order
175 * to dump
176 * @info: info
177 * @cmd: devlink command
178 * @skb: skb
179 * @nest: top attribute
180 * @hdr: hdr
181 */
182struct devlink_dpipe_dump_ctx {
183 struct genl_info *info;
184 enum devlink_command cmd;
185 struct sk_buff *skb;
186 struct nlattr *nest;
187 void *hdr;
188};
189
190struct devlink_dpipe_table_ops;
191
192/**
193 * struct devlink_dpipe_table - table object
194 * @priv: private
195 * @name: table name
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200196 * @counters_enabled: indicates if counters are active
197 * @counter_control_extern: indicates if counter control is in dpipe or
198 * external tool
Arkadi Sharshevsky56dc7cd2018-01-15 08:59:05 +0100199 * @resource_valid: Indicate that the resource id is valid
200 * @resource_id: relative resource this table is related to
201 * @resource_units: number of resource's unit consumed per table's entry
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200202 * @table_ops: table operations
203 * @rcu: rcu
204 */
205struct devlink_dpipe_table {
206 void *priv;
207 struct list_head list;
208 const char *name;
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200209 bool counters_enabled;
210 bool counter_control_extern;
Arkadi Sharshevsky56dc7cd2018-01-15 08:59:05 +0100211 bool resource_valid;
212 u64 resource_id;
213 u64 resource_units;
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200214 struct devlink_dpipe_table_ops *table_ops;
215 struct rcu_head rcu;
216};
217
218/**
219 * struct devlink_dpipe_table_ops - dpipe_table ops
220 * @actions_dump - dumps all tables actions
221 * @matches_dump - dumps all tables matches
222 * @entries_dump - dumps all active entries in the table
223 * @counters_set_update - when changing the counter status hardware sync
224 * maybe needed to allocate/free counter related
225 * resources
Arkadi Sharshevskyffd3cdc2017-08-24 08:40:02 +0200226 * @size_get - get size
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200227 */
228struct devlink_dpipe_table_ops {
229 int (*actions_dump)(void *priv, struct sk_buff *skb);
230 int (*matches_dump)(void *priv, struct sk_buff *skb);
231 int (*entries_dump)(void *priv, bool counters_enabled,
232 struct devlink_dpipe_dump_ctx *dump_ctx);
233 int (*counters_set_update)(void *priv, bool enable);
Arkadi Sharshevskyffd3cdc2017-08-24 08:40:02 +0200234 u64 (*size_get)(void *priv);
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200235};
236
237/**
238 * struct devlink_dpipe_headers - dpipe headers
239 * @headers - header array can be shared (global bit) or driver specific
240 * @headers_count - count of headers
241 */
242struct devlink_dpipe_headers {
243 struct devlink_dpipe_header **headers;
244 unsigned int headers_count;
245};
246
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100247/**
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100248 * struct devlink_resource_size_params - resource's size parameters
249 * @size_min: minimum size which can be set
250 * @size_max: maximum size which can be set
251 * @size_granularity: size granularity
252 * @size_unit: resource's basic unit
253 */
254struct devlink_resource_size_params {
255 u64 size_min;
256 u64 size_max;
257 u64 size_granularity;
258 enum devlink_resource_unit unit;
259};
260
Jiri Pirko77d27092018-02-28 13:12:09 +0100261static inline void
262devlink_resource_size_params_init(struct devlink_resource_size_params *size_params,
263 u64 size_min, u64 size_max,
264 u64 size_granularity,
265 enum devlink_resource_unit unit)
266{
267 size_params->size_min = size_min;
268 size_params->size_max = size_max;
269 size_params->size_granularity = size_granularity;
270 size_params->unit = unit;
271}
272
Jiri Pirkofc56be42018-04-05 22:13:21 +0200273typedef u64 devlink_resource_occ_get_t(void *priv);
274
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100275/**
276 * struct devlink_resource - devlink resource
277 * @name: name of the resource
278 * @id: id, per devlink instance
279 * @size: size of the resource
280 * @size_new: updated size of the resource, reload is needed
281 * @size_valid: valid in case the total size of the resource is valid
282 * including its children
283 * @parent: parent resource
284 * @size_params: size parameters
285 * @list: parent list
286 * @resource_list: list of child resources
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100287 */
288struct devlink_resource {
289 const char *name;
290 u64 id;
291 u64 size;
292 u64 size_new;
293 bool size_valid;
294 struct devlink_resource *parent;
Jiri Pirko77d27092018-02-28 13:12:09 +0100295 struct devlink_resource_size_params size_params;
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100296 struct list_head list;
297 struct list_head resource_list;
Jiri Pirkofc56be42018-04-05 22:13:21 +0200298 devlink_resource_occ_get_t *occ_get;
299 void *occ_get_priv;
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100300};
301
302#define DEVLINK_RESOURCE_ID_PARENT_TOP 0
303
Moshe Shemeshbde74ad12018-10-10 16:09:27 +0300304#define __DEVLINK_PARAM_MAX_STRING_VALUE 32
Moshe Shemesheabaef12018-07-04 14:30:28 +0300305enum devlink_param_type {
306 DEVLINK_PARAM_TYPE_U8,
307 DEVLINK_PARAM_TYPE_U16,
308 DEVLINK_PARAM_TYPE_U32,
309 DEVLINK_PARAM_TYPE_STRING,
310 DEVLINK_PARAM_TYPE_BOOL,
311};
312
313union devlink_param_value {
314 u8 vu8;
315 u16 vu16;
316 u32 vu32;
Moshe Shemeshbde74ad12018-10-10 16:09:27 +0300317 char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE];
Moshe Shemesheabaef12018-07-04 14:30:28 +0300318 bool vbool;
319};
320
321struct devlink_param_gset_ctx {
322 union devlink_param_value val;
323 enum devlink_param_cmode cmode;
324};
325
326/**
327 * struct devlink_param - devlink configuration parameter data
328 * @name: name of the parameter
329 * @generic: indicates if the parameter is generic or driver specific
330 * @type: parameter type
331 * @supported_cmodes: bitmap of supported configuration modes
332 * @get: get parameter value, used for runtime and permanent
333 * configuration modes
334 * @set: set parameter value, used for runtime and permanent
335 * configuration modes
Moshe Shemeshe3b7ca12018-07-04 14:30:30 +0300336 * @validate: validate input value is applicable (within value range, etc.)
Moshe Shemesheabaef12018-07-04 14:30:28 +0300337 *
338 * This struct should be used by the driver to fill the data for
339 * a parameter it registers.
340 */
341struct devlink_param {
342 u32 id;
343 const char *name;
344 bool generic;
345 enum devlink_param_type type;
346 unsigned long supported_cmodes;
347 int (*get)(struct devlink *devlink, u32 id,
348 struct devlink_param_gset_ctx *ctx);
349 int (*set)(struct devlink *devlink, u32 id,
350 struct devlink_param_gset_ctx *ctx);
Moshe Shemeshe3b7ca12018-07-04 14:30:30 +0300351 int (*validate)(struct devlink *devlink, u32 id,
352 union devlink_param_value val,
353 struct netlink_ext_ack *extack);
Moshe Shemesheabaef12018-07-04 14:30:28 +0300354};
355
356struct devlink_param_item {
357 struct list_head list;
358 const struct devlink_param *param;
359 union devlink_param_value driverinit_value;
360 bool driverinit_value_valid;
Jiri Pirko7c62cfb2019-02-07 11:22:45 +0000361 bool published;
Moshe Shemesheabaef12018-07-04 14:30:28 +0300362};
363
364enum devlink_param_generic_id {
Moshe Shemesh036467c2018-07-04 14:30:33 +0300365 DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
366 DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
Vasundhara Volamf567bcd2018-07-04 14:30:36 +0300367 DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
Alex Veskerf6a698852018-07-12 15:13:17 +0300368 DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
Vasundhara Volame3b51062018-10-04 11:13:44 +0530369 DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
Vasundhara Volamf61cba42018-10-04 11:13:45 +0530370 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
Vasundhara Volam16511782018-10-04 11:13:46 +0530371 DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
Shalom Toledo846e9802018-12-03 07:58:59 +0000372 DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
Moshe Shemesheabaef12018-07-04 14:30:28 +0300373
374 /* add new param generic ids above here*/
375 __DEVLINK_PARAM_GENERIC_ID_MAX,
376 DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1,
377};
378
Moshe Shemesh036467c2018-07-04 14:30:33 +0300379#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset"
380#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL
381
382#define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs"
383#define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32
384
Vasundhara Volamf567bcd2018-07-04 14:30:36 +0300385#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov"
386#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL
387
Alex Veskerf6a698852018-07-12 15:13:17 +0300388#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
389#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
390
Vasundhara Volame3b51062018-10-04 11:13:44 +0530391#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
392#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
393
Vasundhara Volamf61cba42018-10-04 11:13:45 +0530394#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
395#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
396
Vasundhara Volam16511782018-10-04 11:13:46 +0530397#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
398#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
399
Shalom Toledo846e9802018-12-03 07:58:59 +0000400#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy"
401#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8
402
Moshe Shemesh036467c2018-07-04 14:30:33 +0300403#define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
404{ \
405 .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
406 .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \
407 .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \
408 .generic = true, \
409 .supported_cmodes = _cmodes, \
410 .get = _get, \
411 .set = _set, \
412 .validate = _validate, \
413}
414
415#define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \
416{ \
417 .id = _id, \
418 .name = _name, \
419 .type = _type, \
420 .supported_cmodes = _cmodes, \
421 .get = _get, \
422 .set = _set, \
423 .validate = _validate, \
424}
425
Jakub Kicinski785bd552019-01-31 10:50:42 -0800426/* Part number, identifier of board design */
427#define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
428/* Revision of board design */
429#define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
Jakub Kicinski14fd1902019-02-10 19:35:29 -0800430/* Maker of the board */
431#define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
Jakub Kicinski785bd552019-01-31 10:50:42 -0800432
433/* Control processor FW version */
434#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"
435/* Data path microcode controlling high-speed packet processing */
436#define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app"
437/* UNDI software version */
438#define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi"
439/* NCSI support/handler version */
440#define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi"
441
Alex Veskerb16ebe92018-07-12 15:13:08 +0300442struct devlink_region;
Jakub Kicinskif9cf2282019-01-31 10:50:40 -0800443struct devlink_info_req;
Alex Veskerb16ebe92018-07-12 15:13:08 +0300444
Alex Veskerd7e52722018-07-12 15:13:10 +0300445typedef void devlink_snapshot_data_dest_t(const void *data);
446
Eran Ben Elisha1db64e82019-02-07 11:36:32 +0200447struct devlink_fmsg;
Eran Ben Elishaa0bdcc52019-02-07 11:36:33 +0200448struct devlink_health_reporter;
449
Eran Ben Elisha3167b272019-03-03 10:57:30 +0200450enum devlink_health_reporter_state {
451 DEVLINK_HEALTH_REPORTER_STATE_HEALTHY,
452 DEVLINK_HEALTH_REPORTER_STATE_ERROR,
453};
454
Eran Ben Elishaa0bdcc52019-02-07 11:36:33 +0200455/**
456 * struct devlink_health_reporter_ops - Reporter operations
457 * @name: reporter name
458 * @recover: callback to recover from reported error
459 * if priv_ctx is NULL, run a full recover
460 * @dump: callback to dump an object
461 * if priv_ctx is NULL, run a full dump
462 * @diagnose: callback to diagnose the current status
463 */
464
465struct devlink_health_reporter_ops {
466 char *name;
467 int (*recover)(struct devlink_health_reporter *reporter,
468 void *priv_ctx);
469 int (*dump)(struct devlink_health_reporter *reporter,
470 struct devlink_fmsg *fmsg, void *priv_ctx);
471 int (*diagnose)(struct devlink_health_reporter *reporter,
472 struct devlink_fmsg *fmsg);
473};
Eran Ben Elisha1db64e82019-02-07 11:36:32 +0200474
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100475struct devlink_ops {
David Ahernac0fc8a2018-06-05 08:14:09 -0700476 int (*reload)(struct devlink *devlink, struct netlink_ext_ack *extack);
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100477 int (*port_type_set)(struct devlink_port *devlink_port,
478 enum devlink_port_type port_type);
479 int (*port_split)(struct devlink *devlink, unsigned int port_index,
David Ahernac0fc8a2018-06-05 08:14:09 -0700480 unsigned int count, struct netlink_ext_ack *extack);
481 int (*port_unsplit)(struct devlink *devlink, unsigned int port_index,
482 struct netlink_ext_ack *extack);
Jiri Pirkobf797472016-04-14 18:19:13 +0200483 int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index,
484 u16 pool_index,
485 struct devlink_sb_pool_info *pool_info);
486 int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index,
487 u16 pool_index, u32 size,
488 enum devlink_sb_threshold_type threshold_type);
489 int (*sb_port_pool_get)(struct devlink_port *devlink_port,
490 unsigned int sb_index, u16 pool_index,
491 u32 *p_threshold);
492 int (*sb_port_pool_set)(struct devlink_port *devlink_port,
493 unsigned int sb_index, u16 pool_index,
494 u32 threshold);
495 int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port,
496 unsigned int sb_index,
497 u16 tc_index,
498 enum devlink_sb_pool_type pool_type,
499 u16 *p_pool_index, u32 *p_threshold);
500 int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port,
501 unsigned int sb_index,
502 u16 tc_index,
503 enum devlink_sb_pool_type pool_type,
504 u16 pool_index, u32 threshold);
Jiri Pirkodf38daf2016-04-14 18:19:14 +0200505 int (*sb_occ_snapshot)(struct devlink *devlink,
506 unsigned int sb_index);
507 int (*sb_occ_max_clear)(struct devlink *devlink,
508 unsigned int sb_index);
509 int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port,
510 unsigned int sb_index, u16 pool_index,
511 u32 *p_cur, u32 *p_max);
512 int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port,
513 unsigned int sb_index,
514 u16 tc_index,
515 enum devlink_sb_pool_type pool_type,
516 u32 *p_cur, u32 *p_max);
Or Gerlitz08f4b592016-07-01 14:51:01 +0300517
518 int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode);
Eli Britsteindb7ff192018-08-15 16:02:18 +0300519 int (*eswitch_mode_set)(struct devlink *devlink, u16 mode,
520 struct netlink_ext_ack *extack);
Roi Dayan59bfde02016-11-22 23:09:57 +0200521 int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
Eli Britsteindb7ff192018-08-15 16:02:18 +0300522 int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode,
523 struct netlink_ext_ack *extack);
Roi Dayanf43e9b02016-09-25 13:52:44 +0300524 int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode);
Eli Britsteindb7ff192018-08-15 16:02:18 +0300525 int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode,
526 struct netlink_ext_ack *extack);
Jakub Kicinskif9cf2282019-01-31 10:50:40 -0800527 int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
528 struct netlink_ext_ack *extack);
Jakub Kicinski76726cc2019-02-14 13:40:44 -0800529 int (*flash_update)(struct devlink *devlink, const char *file_name,
530 const char *component,
531 struct netlink_ext_ack *extack);
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100532};
533
534static inline void *devlink_priv(struct devlink *devlink)
535{
536 BUG_ON(!devlink);
537 return &devlink->priv;
538}
539
540static inline struct devlink *priv_to_devlink(void *priv)
541{
542 BUG_ON(!priv);
543 return container_of(priv, struct devlink, priv);
544}
545
Jakub Kicinskib473b0d2019-02-25 19:34:03 -0800546static inline struct devlink *netdev_to_devlink(struct net_device *dev)
547{
548#if IS_ENABLED(CONFIG_NET_DEVLINK)
549 if (dev->netdev_ops->ndo_get_devlink)
550 return dev->netdev_ops->ndo_get_devlink(dev);
551#endif
552 return NULL;
553}
554
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100555struct ib_device;
556
557#if IS_ENABLED(CONFIG_NET_DEVLINK)
558
559struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
560int devlink_register(struct devlink *devlink, struct device *dev);
561void devlink_unregister(struct devlink *devlink);
562void devlink_free(struct devlink *devlink);
563int devlink_port_register(struct devlink *devlink,
564 struct devlink_port *devlink_port,
565 unsigned int port_index);
566void devlink_port_unregister(struct devlink_port *devlink_port);
567void devlink_port_type_eth_set(struct devlink_port *devlink_port,
568 struct net_device *netdev);
569void devlink_port_type_ib_set(struct devlink_port *devlink_port,
570 struct ib_device *ibdev);
571void devlink_port_type_clear(struct devlink_port *devlink_port);
Jiri Pirkob9ffcba2018-05-18 09:29:00 +0200572void devlink_port_attrs_set(struct devlink_port *devlink_port,
Jiri Pirko5ec13802018-05-18 09:29:01 +0200573 enum devlink_port_flavour flavour,
Jiri Pirkob9ffcba2018-05-18 09:29:00 +0200574 u32 port_number, bool split,
575 u32 split_subport_number);
Jiri Pirko08474c12018-05-18 09:29:02 +0200576int devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
577 char *name, size_t len);
Jiri Pirkobf797472016-04-14 18:19:13 +0200578int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
579 u32 size, u16 ingress_pools_count,
580 u16 egress_pools_count, u16 ingress_tc_count,
581 u16 egress_tc_count);
582void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200583int devlink_dpipe_table_register(struct devlink *devlink,
584 const char *table_name,
585 struct devlink_dpipe_table_ops *table_ops,
Arkadi Sharshevskyffd3cdc2017-08-24 08:40:02 +0200586 void *priv, bool counter_control_extern);
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200587void devlink_dpipe_table_unregister(struct devlink *devlink,
588 const char *table_name);
589int devlink_dpipe_headers_register(struct devlink *devlink,
590 struct devlink_dpipe_headers *dpipe_headers);
591void devlink_dpipe_headers_unregister(struct devlink *devlink);
592bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
593 const char *table_name);
594int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
595int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
596 struct devlink_dpipe_entry *entry);
597int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
Arkadi Sharshevsky35807322017-08-24 08:40:03 +0200598void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200599int devlink_dpipe_action_put(struct sk_buff *skb,
600 struct devlink_dpipe_action *action);
601int devlink_dpipe_match_put(struct sk_buff *skb,
602 struct devlink_dpipe_match *match);
Arkadi Sharshevsky11770092017-08-24 08:39:59 +0200603extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
Arkadi Sharshevsky3fb886e2017-08-24 08:40:00 +0200604extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
Arkadi Sharshevsky1797f5b2017-08-31 17:59:12 +0200605extern struct devlink_dpipe_header devlink_dpipe_header_ipv6;
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100606
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100607int devlink_resource_register(struct devlink *devlink,
608 const char *resource_name,
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100609 u64 resource_size,
610 u64 resource_id,
611 u64 parent_resource_id,
Jiri Pirkofc56be42018-04-05 22:13:21 +0200612 const struct devlink_resource_size_params *size_params);
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100613void devlink_resources_unregister(struct devlink *devlink,
614 struct devlink_resource *resource);
615int devlink_resource_size_get(struct devlink *devlink,
616 u64 resource_id,
617 u64 *p_resource_size);
Arkadi Sharshevsky56dc7cd2018-01-15 08:59:05 +0100618int devlink_dpipe_table_resource_set(struct devlink *devlink,
619 const char *table_name, u64 resource_id,
620 u64 resource_units);
Jiri Pirkofc56be42018-04-05 22:13:21 +0200621void devlink_resource_occ_get_register(struct devlink *devlink,
622 u64 resource_id,
623 devlink_resource_occ_get_t *occ_get,
624 void *occ_get_priv);
625void devlink_resource_occ_get_unregister(struct devlink *devlink,
626 u64 resource_id);
Moshe Shemesheabaef12018-07-04 14:30:28 +0300627int devlink_params_register(struct devlink *devlink,
628 const struct devlink_param *params,
629 size_t params_count);
630void devlink_params_unregister(struct devlink *devlink,
631 const struct devlink_param *params,
632 size_t params_count);
Jiri Pirko7c62cfb2019-02-07 11:22:45 +0000633void devlink_params_publish(struct devlink *devlink);
634void devlink_params_unpublish(struct devlink *devlink);
Vasundhara Volam39e61602019-01-28 18:00:20 +0530635int devlink_port_params_register(struct devlink_port *devlink_port,
636 const struct devlink_param *params,
637 size_t params_count);
638void devlink_port_params_unregister(struct devlink_port *devlink_port,
639 const struct devlink_param *params,
640 size_t params_count);
Moshe Shemeshec01aeb2018-07-04 14:30:31 +0300641int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
642 union devlink_param_value *init_val);
643int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
644 union devlink_param_value init_val);
Vasundhara Volamffd19b92019-01-28 18:00:23 +0530645int
646devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
647 u32 param_id,
648 union devlink_param_value *init_val);
Vasundhara Volam5473a7b2019-01-28 18:00:24 +0530649int devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
650 u32 param_id,
651 union devlink_param_value init_val);
Moshe Shemeshea601e12018-07-04 14:30:32 +0300652void devlink_param_value_changed(struct devlink *devlink, u32 param_id);
Vasundhara Volamc1e5786d2019-01-28 18:00:25 +0530653void devlink_port_param_value_changed(struct devlink_port *devlink_port,
654 u32 param_id);
Moshe Shemeshbde74ad12018-10-10 16:09:27 +0300655void devlink_param_value_str_fill(union devlink_param_value *dst_val,
656 const char *src);
Alex Veskerb16ebe92018-07-12 15:13:08 +0300657struct devlink_region *devlink_region_create(struct devlink *devlink,
658 const char *region_name,
659 u32 region_max_snapshots,
660 u64 region_size);
661void devlink_region_destroy(struct devlink_region *region);
Alex Veskerccadfa42018-07-12 15:13:09 +0300662u32 devlink_region_shapshot_id_get(struct devlink *devlink);
Alex Veskerd7e52722018-07-12 15:13:10 +0300663int devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
664 u8 *data, u32 snapshot_id,
665 devlink_snapshot_data_dest_t *data_destructor);
Jakub Kicinskif9cf2282019-01-31 10:50:40 -0800666int devlink_info_serial_number_put(struct devlink_info_req *req,
667 const char *sn);
668int devlink_info_driver_name_put(struct devlink_info_req *req,
669 const char *name);
Jakub Kicinskifc6fae72019-01-31 10:50:41 -0800670int devlink_info_version_fixed_put(struct devlink_info_req *req,
671 const char *version_name,
672 const char *version_value);
673int devlink_info_version_stored_put(struct devlink_info_req *req,
674 const char *version_name,
675 const char *version_value);
676int devlink_info_version_running_put(struct devlink_info_req *req,
677 const char *version_name,
678 const char *version_value);
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100679
Eran Ben Elisha1db64e82019-02-07 11:36:32 +0200680int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
681int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);
682
683int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
684int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);
685
686int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
687 const char *name);
688int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
689
690int devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value);
691int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value);
692int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
693int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value);
694int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
695int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
696 u16 value_len);
697
698int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
699 bool value);
700int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
701 u8 value);
702int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
703 u32 value);
704int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
705 u64 value);
706int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
707 const char *value);
708int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
709 const void *value, u16 value_len);
710
Eran Ben Elishaa0bdcc52019-02-07 11:36:33 +0200711struct devlink_health_reporter *
712devlink_health_reporter_create(struct devlink *devlink,
713 const struct devlink_health_reporter_ops *ops,
714 u64 graceful_period, bool auto_recover,
715 void *priv);
716void
717devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);
718
719void *
720devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
Eran Ben Elishac8e1da02019-02-07 11:36:34 +0200721int devlink_health_report(struct devlink_health_reporter *reporter,
722 const char *msg, void *priv_ctx);
Eran Ben Elisha3167b272019-03-03 10:57:30 +0200723void
724devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
725 enum devlink_health_reporter_state state);
Eran Ben Elishaa0bdcc52019-02-07 11:36:33 +0200726
Jakub Kicinskif4b6bcc2019-02-25 19:34:02 -0800727void devlink_compat_running_version(struct net_device *dev,
728 char *buf, size_t len);
729int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
730
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100731#else
732
733static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
734 size_t priv_size)
735{
736 return kzalloc(sizeof(struct devlink) + priv_size, GFP_KERNEL);
737}
738
739static inline int devlink_register(struct devlink *devlink, struct device *dev)
740{
741 return 0;
742}
743
744static inline void devlink_unregister(struct devlink *devlink)
745{
746}
747
Jiri Pirko7c62cfb2019-02-07 11:22:45 +0000748static inline void devlink_params_publish(struct devlink *devlink)
749{
750}
751
752static inline void devlink_params_unpublish(struct devlink *devlink)
753{
754}
755
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100756static inline void devlink_free(struct devlink *devlink)
757{
758 kfree(devlink);
759}
760
761static inline int devlink_port_register(struct devlink *devlink,
762 struct devlink_port *devlink_port,
763 unsigned int port_index)
764{
765 return 0;
766}
767
768static inline void devlink_port_unregister(struct devlink_port *devlink_port)
769{
770}
771
772static inline void devlink_port_type_eth_set(struct devlink_port *devlink_port,
773 struct net_device *netdev)
774{
775}
776
777static inline void devlink_port_type_ib_set(struct devlink_port *devlink_port,
778 struct ib_device *ibdev)
779{
780}
781
782static inline void devlink_port_type_clear(struct devlink_port *devlink_port)
783{
784}
785
Jiri Pirkob9ffcba2018-05-18 09:29:00 +0200786static inline void devlink_port_attrs_set(struct devlink_port *devlink_port,
Jiri Pirko5ec13802018-05-18 09:29:01 +0200787 enum devlink_port_flavour flavour,
Jiri Pirkob9ffcba2018-05-18 09:29:00 +0200788 u32 port_number, bool split,
789 u32 split_subport_number)
Jiri Pirkobfcd3a42016-02-26 17:32:23 +0100790{
791}
792
Jiri Pirko08474c12018-05-18 09:29:02 +0200793static inline int
794devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
795 char *name, size_t len)
796{
797 return -EOPNOTSUPP;
798}
799
Jiri Pirkobf797472016-04-14 18:19:13 +0200800static inline int devlink_sb_register(struct devlink *devlink,
801 unsigned int sb_index, u32 size,
802 u16 ingress_pools_count,
Jiri Pirkode33efd2016-04-15 09:17:08 +0200803 u16 egress_pools_count,
804 u16 ingress_tc_count,
805 u16 egress_tc_count)
Jiri Pirkobf797472016-04-14 18:19:13 +0200806{
807 return 0;
808}
809
810static inline void devlink_sb_unregister(struct devlink *devlink,
811 unsigned int sb_index)
812{
813}
814
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200815static inline int
816devlink_dpipe_table_register(struct devlink *devlink,
817 const char *table_name,
818 struct devlink_dpipe_table_ops *table_ops,
David S. Miller790c6052017-08-24 18:10:46 -0700819 void *priv, bool counter_control_extern)
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200820{
821 return 0;
822}
823
824static inline void devlink_dpipe_table_unregister(struct devlink *devlink,
825 const char *table_name)
826{
827}
828
829static inline int devlink_dpipe_headers_register(struct devlink *devlink,
830 struct devlink_dpipe_headers *
831 dpipe_headers)
832{
833 return 0;
834}
835
836static inline void devlink_dpipe_headers_unregister(struct devlink *devlink)
837{
838}
839
840static inline bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
841 const char *table_name)
842{
843 return false;
844}
845
846static inline int
847devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx)
848{
849 return 0;
850}
851
852static inline int
853devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
854 struct devlink_dpipe_entry *entry)
855{
856 return 0;
857}
858
859static inline int
860devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx)
861{
862 return 0;
863}
864
Arkadi Sharshevsky35807322017-08-24 08:40:03 +0200865static inline void
866devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry)
867{
868}
869
Arkadi Sharshevsky1555d202017-03-28 17:24:10 +0200870static inline int
871devlink_dpipe_action_put(struct sk_buff *skb,
872 struct devlink_dpipe_action *action)
873{
874 return 0;
875}
876
877static inline int
878devlink_dpipe_match_put(struct sk_buff *skb,
879 struct devlink_dpipe_match *match)
880{
881 return 0;
882}
883
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100884static inline int
885devlink_resource_register(struct devlink *devlink,
886 const char *resource_name,
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100887 u64 resource_size,
888 u64 resource_id,
889 u64 parent_resource_id,
Jiri Pirkofc56be42018-04-05 22:13:21 +0200890 const struct devlink_resource_size_params *size_params)
Arkadi Sharshevskyd9f9b9a2018-01-15 08:59:03 +0100891{
892 return 0;
893}
894
895static inline void
896devlink_resources_unregister(struct devlink *devlink,
897 struct devlink_resource *resource)
898{
899}
900
901static inline int
902devlink_resource_size_get(struct devlink *devlink, u64 resource_id,
903 u64 *p_resource_size)
904{
905 return -EOPNOTSUPP;
906}
907
Arkadi Sharshevsky56dc7cd2018-01-15 08:59:05 +0100908static inline int
909devlink_dpipe_table_resource_set(struct devlink *devlink,
910 const char *table_name, u64 resource_id,
911 u64 resource_units)
912{
913 return -EOPNOTSUPP;
914}
915
Jiri Pirkofc56be42018-04-05 22:13:21 +0200916static inline void
917devlink_resource_occ_get_register(struct devlink *devlink,
918 u64 resource_id,
919 devlink_resource_occ_get_t *occ_get,
920 void *occ_get_priv)
921{
922}
923
924static inline void
925devlink_resource_occ_get_unregister(struct devlink *devlink,
926 u64 resource_id)
927{
928}
929
Moshe Shemesheabaef12018-07-04 14:30:28 +0300930static inline int
931devlink_params_register(struct devlink *devlink,
932 const struct devlink_param *params,
933 size_t params_count)
934{
935 return 0;
936}
937
938static inline void
939devlink_params_unregister(struct devlink *devlink,
940 const struct devlink_param *params,
941 size_t params_count)
942{
943
944}
945
Moshe Shemeshec01aeb2018-07-04 14:30:31 +0300946static inline int
Vasundhara Volam39e61602019-01-28 18:00:20 +0530947devlink_port_params_register(struct devlink_port *devlink_port,
948 const struct devlink_param *params,
949 size_t params_count)
950{
951 return 0;
952}
953
954static inline void
955devlink_port_params_unregister(struct devlink_port *devlink_port,
956 const struct devlink_param *params,
957 size_t params_count)
958{
959}
960
961static inline int
Moshe Shemeshec01aeb2018-07-04 14:30:31 +0300962devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
963 union devlink_param_value *init_val)
964{
965 return -EOPNOTSUPP;
966}
967
968static inline int
969devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
970 union devlink_param_value init_val)
971{
972 return -EOPNOTSUPP;
973}
974
Vasundhara Volamffd19b92019-01-28 18:00:23 +0530975static inline int
976devlink_port_param_driverinit_value_get(struct devlink_port *devlink_port,
977 u32 param_id,
978 union devlink_param_value *init_val)
979{
980 return -EOPNOTSUPP;
981}
982
Vasundhara Volam5473a7b2019-01-28 18:00:24 +0530983static inline int
984devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port,
985 u32 param_id,
986 union devlink_param_value init_val)
987{
988 return -EOPNOTSUPP;
989}
990
Moshe Shemeshea601e12018-07-04 14:30:32 +0300991static inline void
992devlink_param_value_changed(struct devlink *devlink, u32 param_id)
993{
Moshe Shemeshea601e12018-07-04 14:30:32 +0300994}
995
Moshe Shemeshbde74ad12018-10-10 16:09:27 +0300996static inline void
Vasundhara Volamc1e5786d2019-01-28 18:00:25 +0530997devlink_port_param_value_changed(struct devlink_port *devlink_port,
998 u32 param_id)
999{
1000}
1001
1002static inline void
Moshe Shemeshbde74ad12018-10-10 16:09:27 +03001003devlink_param_value_str_fill(union devlink_param_value *dst_val,
1004 const char *src)
1005{
1006}
1007
Alex Veskerb16ebe92018-07-12 15:13:08 +03001008static inline struct devlink_region *
1009devlink_region_create(struct devlink *devlink,
1010 const char *region_name,
1011 u32 region_max_snapshots,
1012 u64 region_size)
1013{
1014 return NULL;
1015}
1016
1017static inline void
1018devlink_region_destroy(struct devlink_region *region)
1019{
1020}
1021
Alex Veskerccadfa42018-07-12 15:13:09 +03001022static inline u32
1023devlink_region_shapshot_id_get(struct devlink *devlink)
1024{
1025 return 0;
1026}
1027
Alex Veskerd7e52722018-07-12 15:13:10 +03001028static inline int
1029devlink_region_snapshot_create(struct devlink_region *region, u64 data_len,
1030 u8 *data, u32 snapshot_id,
1031 devlink_snapshot_data_dest_t *data_destructor)
1032{
1033 return 0;
1034}
1035
Jakub Kicinskif9cf2282019-01-31 10:50:40 -08001036static inline int
1037devlink_info_driver_name_put(struct devlink_info_req *req, const char *name)
1038{
1039 return 0;
1040}
1041
1042static inline int
1043devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn)
1044{
1045 return 0;
1046}
Jakub Kicinskifc6fae72019-01-31 10:50:41 -08001047
1048static inline int
1049devlink_info_version_fixed_put(struct devlink_info_req *req,
1050 const char *version_name,
1051 const char *version_value)
1052{
1053 return 0;
1054}
1055
1056static inline int
1057devlink_info_version_stored_put(struct devlink_info_req *req,
1058 const char *version_name,
1059 const char *version_value)
1060{
1061 return 0;
1062}
1063
1064static inline int
1065devlink_info_version_running_put(struct devlink_info_req *req,
1066 const char *version_name,
1067 const char *version_value)
1068{
1069 return 0;
1070}
Eran Ben Elisha1db64e82019-02-07 11:36:32 +02001071
1072static inline int
1073devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg)
1074{
1075 return 0;
1076}
1077
1078static inline int
1079devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg)
1080{
1081 return 0;
1082}
1083
1084static inline int
1085devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name)
1086{
1087 return 0;
1088}
1089
1090static inline int
1091devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg)
1092{
1093 return 0;
1094}
1095
1096static inline int
1097devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
1098 const char *name)
1099{
1100 return 0;
1101}
1102
1103static inline int
1104devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg)
1105{
1106 return 0;
1107}
1108
1109static inline int
1110devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value)
1111{
1112 return 0;
1113}
1114
1115static inline int
1116devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value)
1117{
1118 return 0;
1119}
1120
1121static inline int
1122devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value)
1123{
1124 return 0;
1125}
1126
1127static inline int
1128devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value)
1129{
1130 return 0;
1131}
1132
1133static inline int
1134devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value)
1135{
1136 return 0;
1137}
1138
1139static inline int
1140devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
1141 u16 value_len)
1142{
1143 return 0;
1144}
1145
1146static inline int
1147devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
1148 bool value)
1149{
1150 return 0;
1151}
1152
1153static inline int
1154devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
1155 u8 value)
1156{
1157 return 0;
1158}
1159
1160static inline int
1161devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
1162 u32 value)
1163{
1164 return 0;
1165}
1166
1167static inline int
1168devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
1169 u64 value)
1170{
1171 return 0;
1172}
1173
1174static inline int
1175devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
1176 const char *value)
1177{
1178 return 0;
1179}
1180
1181static inline int
1182devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
1183 const void *value, u16 value_len)
1184{
1185 return 0;
1186}
Eran Ben Elishaa0bdcc52019-02-07 11:36:33 +02001187
1188static inline struct devlink_health_reporter *
1189devlink_health_reporter_create(struct devlink *devlink,
1190 const struct devlink_health_reporter_ops *ops,
1191 u64 graceful_period, bool auto_recover,
1192 void *priv)
1193{
1194 return NULL;
1195}
1196
1197static inline void
1198devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
1199{
1200}
1201
1202static inline void *
1203devlink_health_reporter_priv(struct devlink_health_reporter *reporter)
1204{
1205 return NULL;
1206}
Eran Ben Elishac8e1da02019-02-07 11:36:34 +02001207
1208static inline int
1209devlink_health_report(struct devlink_health_reporter *reporter,
1210 const char *msg, void *priv_ctx)
1211{
1212 return 0;
1213}
Jiri Pirkobfcd3a42016-02-26 17:32:23 +01001214
Jakub Kicinskiddb6e992019-01-31 10:50:47 -08001215static inline void
Eran Ben Elisha3167b272019-03-03 10:57:30 +02001216devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
1217 enum devlink_health_reporter_state state)
1218{
1219}
1220
1221static inline void
Jakub Kicinskiddb6e992019-01-31 10:50:47 -08001222devlink_compat_running_version(struct net_device *dev, char *buf, size_t len)
1223{
1224}
Jakub Kicinski4eceba12019-02-14 13:40:45 -08001225
1226static inline int
1227devlink_compat_flash_update(struct net_device *dev, const char *file_name)
1228{
1229 return -EOPNOTSUPP;
1230}
Jakub Kicinskiddb6e992019-01-31 10:50:47 -08001231#endif
1232
Jiri Pirkobfcd3a42016-02-26 17:32:23 +01001233#endif /* _NET_DEVLINK_H_ */