devlink.h 65 KB

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