18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * include/net/devlink.h - Network physical device Netlink interface 48c2ecf20Sopenharmony_ci * Copyright (c) 2016 Mellanox Technologies. All rights reserved. 58c2ecf20Sopenharmony_ci * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef _NET_DEVLINK_H_ 88c2ecf20Sopenharmony_ci#define _NET_DEVLINK_H_ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/device.h> 118c2ecf20Sopenharmony_ci#include <linux/slab.h> 128c2ecf20Sopenharmony_ci#include <linux/gfp.h> 138c2ecf20Sopenharmony_ci#include <linux/list.h> 148c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 158c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 168c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 178c2ecf20Sopenharmony_ci#include <linux/refcount.h> 188c2ecf20Sopenharmony_ci#include <net/net_namespace.h> 198c2ecf20Sopenharmony_ci#include <net/flow_offload.h> 208c2ecf20Sopenharmony_ci#include <uapi/linux/devlink.h> 218c2ecf20Sopenharmony_ci#include <linux/xarray.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define DEVLINK_RELOAD_STATS_ARRAY_SIZE \ 248c2ecf20Sopenharmony_ci (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct devlink_dev_stats { 278c2ecf20Sopenharmony_ci u32 reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE]; 288c2ecf20Sopenharmony_ci u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE]; 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistruct devlink_ops; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct devlink { 348c2ecf20Sopenharmony_ci struct list_head list; 358c2ecf20Sopenharmony_ci struct list_head port_list; 368c2ecf20Sopenharmony_ci struct list_head sb_list; 378c2ecf20Sopenharmony_ci struct list_head dpipe_table_list; 388c2ecf20Sopenharmony_ci struct list_head resource_list; 398c2ecf20Sopenharmony_ci struct list_head param_list; 408c2ecf20Sopenharmony_ci struct list_head region_list; 418c2ecf20Sopenharmony_ci struct list_head reporter_list; 428c2ecf20Sopenharmony_ci struct mutex reporters_lock; /* protects reporter_list */ 438c2ecf20Sopenharmony_ci struct devlink_dpipe_headers *dpipe_headers; 448c2ecf20Sopenharmony_ci struct list_head trap_list; 458c2ecf20Sopenharmony_ci struct list_head trap_group_list; 468c2ecf20Sopenharmony_ci struct list_head trap_policer_list; 478c2ecf20Sopenharmony_ci const struct devlink_ops *ops; 488c2ecf20Sopenharmony_ci struct xarray snapshot_ids; 498c2ecf20Sopenharmony_ci struct devlink_dev_stats stats; 508c2ecf20Sopenharmony_ci struct device *dev; 518c2ecf20Sopenharmony_ci possible_net_t _net; 528c2ecf20Sopenharmony_ci struct mutex lock; /* Serializes access to devlink instance specific objects such as 538c2ecf20Sopenharmony_ci * port, sb, dpipe, resource, params, region, traps and more. 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci u8 reload_failed:1, 568c2ecf20Sopenharmony_ci reload_enabled:1, 578c2ecf20Sopenharmony_ci registered:1; 588c2ecf20Sopenharmony_ci char priv[0] __aligned(NETDEV_ALIGN); 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistruct devlink_port_phys_attrs { 628c2ecf20Sopenharmony_ci u32 port_number; /* Same value as "split group". 638c2ecf20Sopenharmony_ci * A physical port which is visible to the user 648c2ecf20Sopenharmony_ci * for a given port flavour. 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_ci u32 split_subport_number; /* If the port is split, this is the number of subport. */ 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/** 708c2ecf20Sopenharmony_ci * struct devlink_port_pci_pf_attrs - devlink port's PCI PF attributes 718c2ecf20Sopenharmony_ci * @controller: Associated controller number 728c2ecf20Sopenharmony_ci * @pf: Associated PCI PF number for this port. 738c2ecf20Sopenharmony_ci * @external: when set, indicates if a port is for an external controller 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_cistruct devlink_port_pci_pf_attrs { 768c2ecf20Sopenharmony_ci u32 controller; 778c2ecf20Sopenharmony_ci u16 pf; 788c2ecf20Sopenharmony_ci u8 external:1; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/** 828c2ecf20Sopenharmony_ci * struct devlink_port_pci_vf_attrs - devlink port's PCI VF attributes 838c2ecf20Sopenharmony_ci * @controller: Associated controller number 848c2ecf20Sopenharmony_ci * @pf: Associated PCI PF number for this port. 858c2ecf20Sopenharmony_ci * @vf: Associated PCI VF for of the PCI PF for this port. 868c2ecf20Sopenharmony_ci * @external: when set, indicates if a port is for an external controller 878c2ecf20Sopenharmony_ci */ 888c2ecf20Sopenharmony_cistruct devlink_port_pci_vf_attrs { 898c2ecf20Sopenharmony_ci u32 controller; 908c2ecf20Sopenharmony_ci u16 pf; 918c2ecf20Sopenharmony_ci u16 vf; 928c2ecf20Sopenharmony_ci u8 external:1; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/** 968c2ecf20Sopenharmony_ci * struct devlink_port_attrs - devlink port object 978c2ecf20Sopenharmony_ci * @flavour: flavour of the port 988c2ecf20Sopenharmony_ci * @split: indicates if this is split port 998c2ecf20Sopenharmony_ci * @splittable: indicates if the port can be split. 1008c2ecf20Sopenharmony_ci * @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink. 1018c2ecf20Sopenharmony_ci * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL 1028c2ecf20Sopenharmony_ci * @phys: physical port attributes 1038c2ecf20Sopenharmony_ci * @pci_pf: PCI PF port attributes 1048c2ecf20Sopenharmony_ci * @pci_vf: PCI VF port attributes 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_cistruct devlink_port_attrs { 1078c2ecf20Sopenharmony_ci u8 split:1, 1088c2ecf20Sopenharmony_ci splittable:1; 1098c2ecf20Sopenharmony_ci u32 lanes; 1108c2ecf20Sopenharmony_ci enum devlink_port_flavour flavour; 1118c2ecf20Sopenharmony_ci struct netdev_phys_item_id switch_id; 1128c2ecf20Sopenharmony_ci union { 1138c2ecf20Sopenharmony_ci struct devlink_port_phys_attrs phys; 1148c2ecf20Sopenharmony_ci struct devlink_port_pci_pf_attrs pci_pf; 1158c2ecf20Sopenharmony_ci struct devlink_port_pci_vf_attrs pci_vf; 1168c2ecf20Sopenharmony_ci }; 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistruct devlink_port { 1208c2ecf20Sopenharmony_ci struct list_head list; 1218c2ecf20Sopenharmony_ci struct list_head param_list; 1228c2ecf20Sopenharmony_ci struct list_head region_list; 1238c2ecf20Sopenharmony_ci struct devlink *devlink; 1248c2ecf20Sopenharmony_ci unsigned int index; 1258c2ecf20Sopenharmony_ci bool registered; 1268c2ecf20Sopenharmony_ci spinlock_t type_lock; /* Protects type and type_dev 1278c2ecf20Sopenharmony_ci * pointer consistency. 1288c2ecf20Sopenharmony_ci */ 1298c2ecf20Sopenharmony_ci enum devlink_port_type type; 1308c2ecf20Sopenharmony_ci enum devlink_port_type desired_type; 1318c2ecf20Sopenharmony_ci void *type_dev; 1328c2ecf20Sopenharmony_ci struct devlink_port_attrs attrs; 1338c2ecf20Sopenharmony_ci u8 attrs_set:1, 1348c2ecf20Sopenharmony_ci switch_port:1; 1358c2ecf20Sopenharmony_ci struct delayed_work type_warn_dw; 1368c2ecf20Sopenharmony_ci struct list_head reporter_list; 1378c2ecf20Sopenharmony_ci struct mutex reporters_lock; /* Protects reporter_list */ 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cistruct devlink_sb_pool_info { 1418c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type; 1428c2ecf20Sopenharmony_ci u32 size; 1438c2ecf20Sopenharmony_ci enum devlink_sb_threshold_type threshold_type; 1448c2ecf20Sopenharmony_ci u32 cell_size; 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci/** 1488c2ecf20Sopenharmony_ci * struct devlink_dpipe_field - dpipe field object 1498c2ecf20Sopenharmony_ci * @name: field name 1508c2ecf20Sopenharmony_ci * @id: index inside the headers field array 1518c2ecf20Sopenharmony_ci * @bitwidth: bitwidth 1528c2ecf20Sopenharmony_ci * @mapping_type: mapping type 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_cistruct devlink_dpipe_field { 1558c2ecf20Sopenharmony_ci const char *name; 1568c2ecf20Sopenharmony_ci unsigned int id; 1578c2ecf20Sopenharmony_ci unsigned int bitwidth; 1588c2ecf20Sopenharmony_ci enum devlink_dpipe_field_mapping_type mapping_type; 1598c2ecf20Sopenharmony_ci}; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/** 1628c2ecf20Sopenharmony_ci * struct devlink_dpipe_header - dpipe header object 1638c2ecf20Sopenharmony_ci * @name: header name 1648c2ecf20Sopenharmony_ci * @id: index, global/local detrmined by global bit 1658c2ecf20Sopenharmony_ci * @fields: fields 1668c2ecf20Sopenharmony_ci * @fields_count: number of fields 1678c2ecf20Sopenharmony_ci * @global: indicates if header is shared like most protocol header 1688c2ecf20Sopenharmony_ci * or driver specific 1698c2ecf20Sopenharmony_ci */ 1708c2ecf20Sopenharmony_cistruct devlink_dpipe_header { 1718c2ecf20Sopenharmony_ci const char *name; 1728c2ecf20Sopenharmony_ci unsigned int id; 1738c2ecf20Sopenharmony_ci struct devlink_dpipe_field *fields; 1748c2ecf20Sopenharmony_ci unsigned int fields_count; 1758c2ecf20Sopenharmony_ci bool global; 1768c2ecf20Sopenharmony_ci}; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci/** 1798c2ecf20Sopenharmony_ci * struct devlink_dpipe_match - represents match operation 1808c2ecf20Sopenharmony_ci * @type: type of match 1818c2ecf20Sopenharmony_ci * @header_index: header index (packets can have several headers of same 1828c2ecf20Sopenharmony_ci * type like in case of tunnels) 1838c2ecf20Sopenharmony_ci * @header: header 1848c2ecf20Sopenharmony_ci * @fieled_id: field index 1858c2ecf20Sopenharmony_ci */ 1868c2ecf20Sopenharmony_cistruct devlink_dpipe_match { 1878c2ecf20Sopenharmony_ci enum devlink_dpipe_match_type type; 1888c2ecf20Sopenharmony_ci unsigned int header_index; 1898c2ecf20Sopenharmony_ci struct devlink_dpipe_header *header; 1908c2ecf20Sopenharmony_ci unsigned int field_id; 1918c2ecf20Sopenharmony_ci}; 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci/** 1948c2ecf20Sopenharmony_ci * struct devlink_dpipe_action - represents action operation 1958c2ecf20Sopenharmony_ci * @type: type of action 1968c2ecf20Sopenharmony_ci * @header_index: header index (packets can have several headers of same 1978c2ecf20Sopenharmony_ci * type like in case of tunnels) 1988c2ecf20Sopenharmony_ci * @header: header 1998c2ecf20Sopenharmony_ci * @fieled_id: field index 2008c2ecf20Sopenharmony_ci */ 2018c2ecf20Sopenharmony_cistruct devlink_dpipe_action { 2028c2ecf20Sopenharmony_ci enum devlink_dpipe_action_type type; 2038c2ecf20Sopenharmony_ci unsigned int header_index; 2048c2ecf20Sopenharmony_ci struct devlink_dpipe_header *header; 2058c2ecf20Sopenharmony_ci unsigned int field_id; 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/** 2098c2ecf20Sopenharmony_ci * struct devlink_dpipe_value - represents value of match/action 2108c2ecf20Sopenharmony_ci * @action: action 2118c2ecf20Sopenharmony_ci * @match: match 2128c2ecf20Sopenharmony_ci * @mapping_value: in case the field has some mapping this value 2138c2ecf20Sopenharmony_ci * specified the mapping value 2148c2ecf20Sopenharmony_ci * @mapping_valid: specify if mapping value is valid 2158c2ecf20Sopenharmony_ci * @value_size: value size 2168c2ecf20Sopenharmony_ci * @value: value 2178c2ecf20Sopenharmony_ci * @mask: bit mask 2188c2ecf20Sopenharmony_ci */ 2198c2ecf20Sopenharmony_cistruct devlink_dpipe_value { 2208c2ecf20Sopenharmony_ci union { 2218c2ecf20Sopenharmony_ci struct devlink_dpipe_action *action; 2228c2ecf20Sopenharmony_ci struct devlink_dpipe_match *match; 2238c2ecf20Sopenharmony_ci }; 2248c2ecf20Sopenharmony_ci unsigned int mapping_value; 2258c2ecf20Sopenharmony_ci bool mapping_valid; 2268c2ecf20Sopenharmony_ci unsigned int value_size; 2278c2ecf20Sopenharmony_ci void *value; 2288c2ecf20Sopenharmony_ci void *mask; 2298c2ecf20Sopenharmony_ci}; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci/** 2328c2ecf20Sopenharmony_ci * struct devlink_dpipe_entry - table entry object 2338c2ecf20Sopenharmony_ci * @index: index of the entry in the table 2348c2ecf20Sopenharmony_ci * @match_values: match values 2358c2ecf20Sopenharmony_ci * @matche_values_count: count of matches tuples 2368c2ecf20Sopenharmony_ci * @action_values: actions values 2378c2ecf20Sopenharmony_ci * @action_values_count: count of actions values 2388c2ecf20Sopenharmony_ci * @counter: value of counter 2398c2ecf20Sopenharmony_ci * @counter_valid: Specify if value is valid from hardware 2408c2ecf20Sopenharmony_ci */ 2418c2ecf20Sopenharmony_cistruct devlink_dpipe_entry { 2428c2ecf20Sopenharmony_ci u64 index; 2438c2ecf20Sopenharmony_ci struct devlink_dpipe_value *match_values; 2448c2ecf20Sopenharmony_ci unsigned int match_values_count; 2458c2ecf20Sopenharmony_ci struct devlink_dpipe_value *action_values; 2468c2ecf20Sopenharmony_ci unsigned int action_values_count; 2478c2ecf20Sopenharmony_ci u64 counter; 2488c2ecf20Sopenharmony_ci bool counter_valid; 2498c2ecf20Sopenharmony_ci}; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci/** 2528c2ecf20Sopenharmony_ci * struct devlink_dpipe_dump_ctx - context provided to driver in order 2538c2ecf20Sopenharmony_ci * to dump 2548c2ecf20Sopenharmony_ci * @info: info 2558c2ecf20Sopenharmony_ci * @cmd: devlink command 2568c2ecf20Sopenharmony_ci * @skb: skb 2578c2ecf20Sopenharmony_ci * @nest: top attribute 2588c2ecf20Sopenharmony_ci * @hdr: hdr 2598c2ecf20Sopenharmony_ci */ 2608c2ecf20Sopenharmony_cistruct devlink_dpipe_dump_ctx { 2618c2ecf20Sopenharmony_ci struct genl_info *info; 2628c2ecf20Sopenharmony_ci enum devlink_command cmd; 2638c2ecf20Sopenharmony_ci struct sk_buff *skb; 2648c2ecf20Sopenharmony_ci struct nlattr *nest; 2658c2ecf20Sopenharmony_ci void *hdr; 2668c2ecf20Sopenharmony_ci}; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cistruct devlink_dpipe_table_ops; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/** 2718c2ecf20Sopenharmony_ci * struct devlink_dpipe_table - table object 2728c2ecf20Sopenharmony_ci * @priv: private 2738c2ecf20Sopenharmony_ci * @name: table name 2748c2ecf20Sopenharmony_ci * @counters_enabled: indicates if counters are active 2758c2ecf20Sopenharmony_ci * @counter_control_extern: indicates if counter control is in dpipe or 2768c2ecf20Sopenharmony_ci * external tool 2778c2ecf20Sopenharmony_ci * @resource_valid: Indicate that the resource id is valid 2788c2ecf20Sopenharmony_ci * @resource_id: relative resource this table is related to 2798c2ecf20Sopenharmony_ci * @resource_units: number of resource's unit consumed per table's entry 2808c2ecf20Sopenharmony_ci * @table_ops: table operations 2818c2ecf20Sopenharmony_ci * @rcu: rcu 2828c2ecf20Sopenharmony_ci */ 2838c2ecf20Sopenharmony_cistruct devlink_dpipe_table { 2848c2ecf20Sopenharmony_ci void *priv; 2858c2ecf20Sopenharmony_ci struct list_head list; 2868c2ecf20Sopenharmony_ci const char *name; 2878c2ecf20Sopenharmony_ci bool counters_enabled; 2888c2ecf20Sopenharmony_ci bool counter_control_extern; 2898c2ecf20Sopenharmony_ci bool resource_valid; 2908c2ecf20Sopenharmony_ci u64 resource_id; 2918c2ecf20Sopenharmony_ci u64 resource_units; 2928c2ecf20Sopenharmony_ci struct devlink_dpipe_table_ops *table_ops; 2938c2ecf20Sopenharmony_ci struct rcu_head rcu; 2948c2ecf20Sopenharmony_ci}; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci/** 2978c2ecf20Sopenharmony_ci * struct devlink_dpipe_table_ops - dpipe_table ops 2988c2ecf20Sopenharmony_ci * @actions_dump - dumps all tables actions 2998c2ecf20Sopenharmony_ci * @matches_dump - dumps all tables matches 3008c2ecf20Sopenharmony_ci * @entries_dump - dumps all active entries in the table 3018c2ecf20Sopenharmony_ci * @counters_set_update - when changing the counter status hardware sync 3028c2ecf20Sopenharmony_ci * maybe needed to allocate/free counter related 3038c2ecf20Sopenharmony_ci * resources 3048c2ecf20Sopenharmony_ci * @size_get - get size 3058c2ecf20Sopenharmony_ci */ 3068c2ecf20Sopenharmony_cistruct devlink_dpipe_table_ops { 3078c2ecf20Sopenharmony_ci int (*actions_dump)(void *priv, struct sk_buff *skb); 3088c2ecf20Sopenharmony_ci int (*matches_dump)(void *priv, struct sk_buff *skb); 3098c2ecf20Sopenharmony_ci int (*entries_dump)(void *priv, bool counters_enabled, 3108c2ecf20Sopenharmony_ci struct devlink_dpipe_dump_ctx *dump_ctx); 3118c2ecf20Sopenharmony_ci int (*counters_set_update)(void *priv, bool enable); 3128c2ecf20Sopenharmony_ci u64 (*size_get)(void *priv); 3138c2ecf20Sopenharmony_ci}; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci/** 3168c2ecf20Sopenharmony_ci * struct devlink_dpipe_headers - dpipe headers 3178c2ecf20Sopenharmony_ci * @headers - header array can be shared (global bit) or driver specific 3188c2ecf20Sopenharmony_ci * @headers_count - count of headers 3198c2ecf20Sopenharmony_ci */ 3208c2ecf20Sopenharmony_cistruct devlink_dpipe_headers { 3218c2ecf20Sopenharmony_ci struct devlink_dpipe_header **headers; 3228c2ecf20Sopenharmony_ci unsigned int headers_count; 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci/** 3268c2ecf20Sopenharmony_ci * struct devlink_resource_size_params - resource's size parameters 3278c2ecf20Sopenharmony_ci * @size_min: minimum size which can be set 3288c2ecf20Sopenharmony_ci * @size_max: maximum size which can be set 3298c2ecf20Sopenharmony_ci * @size_granularity: size granularity 3308c2ecf20Sopenharmony_ci * @size_unit: resource's basic unit 3318c2ecf20Sopenharmony_ci */ 3328c2ecf20Sopenharmony_cistruct devlink_resource_size_params { 3338c2ecf20Sopenharmony_ci u64 size_min; 3348c2ecf20Sopenharmony_ci u64 size_max; 3358c2ecf20Sopenharmony_ci u64 size_granularity; 3368c2ecf20Sopenharmony_ci enum devlink_resource_unit unit; 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic inline void 3408c2ecf20Sopenharmony_cidevlink_resource_size_params_init(struct devlink_resource_size_params *size_params, 3418c2ecf20Sopenharmony_ci u64 size_min, u64 size_max, 3428c2ecf20Sopenharmony_ci u64 size_granularity, 3438c2ecf20Sopenharmony_ci enum devlink_resource_unit unit) 3448c2ecf20Sopenharmony_ci{ 3458c2ecf20Sopenharmony_ci size_params->size_min = size_min; 3468c2ecf20Sopenharmony_ci size_params->size_max = size_max; 3478c2ecf20Sopenharmony_ci size_params->size_granularity = size_granularity; 3488c2ecf20Sopenharmony_ci size_params->unit = unit; 3498c2ecf20Sopenharmony_ci} 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_citypedef u64 devlink_resource_occ_get_t(void *priv); 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci/** 3548c2ecf20Sopenharmony_ci * struct devlink_resource - devlink resource 3558c2ecf20Sopenharmony_ci * @name: name of the resource 3568c2ecf20Sopenharmony_ci * @id: id, per devlink instance 3578c2ecf20Sopenharmony_ci * @size: size of the resource 3588c2ecf20Sopenharmony_ci * @size_new: updated size of the resource, reload is needed 3598c2ecf20Sopenharmony_ci * @size_valid: valid in case the total size of the resource is valid 3608c2ecf20Sopenharmony_ci * including its children 3618c2ecf20Sopenharmony_ci * @parent: parent resource 3628c2ecf20Sopenharmony_ci * @size_params: size parameters 3638c2ecf20Sopenharmony_ci * @list: parent list 3648c2ecf20Sopenharmony_ci * @resource_list: list of child resources 3658c2ecf20Sopenharmony_ci */ 3668c2ecf20Sopenharmony_cistruct devlink_resource { 3678c2ecf20Sopenharmony_ci const char *name; 3688c2ecf20Sopenharmony_ci u64 id; 3698c2ecf20Sopenharmony_ci u64 size; 3708c2ecf20Sopenharmony_ci u64 size_new; 3718c2ecf20Sopenharmony_ci bool size_valid; 3728c2ecf20Sopenharmony_ci struct devlink_resource *parent; 3738c2ecf20Sopenharmony_ci struct devlink_resource_size_params size_params; 3748c2ecf20Sopenharmony_ci struct list_head list; 3758c2ecf20Sopenharmony_ci struct list_head resource_list; 3768c2ecf20Sopenharmony_ci devlink_resource_occ_get_t *occ_get; 3778c2ecf20Sopenharmony_ci void *occ_get_priv; 3788c2ecf20Sopenharmony_ci}; 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci#define DEVLINK_RESOURCE_ID_PARENT_TOP 0 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci#define __DEVLINK_PARAM_MAX_STRING_VALUE 32 3838c2ecf20Sopenharmony_cienum devlink_param_type { 3848c2ecf20Sopenharmony_ci DEVLINK_PARAM_TYPE_U8, 3858c2ecf20Sopenharmony_ci DEVLINK_PARAM_TYPE_U16, 3868c2ecf20Sopenharmony_ci DEVLINK_PARAM_TYPE_U32, 3878c2ecf20Sopenharmony_ci DEVLINK_PARAM_TYPE_STRING, 3888c2ecf20Sopenharmony_ci DEVLINK_PARAM_TYPE_BOOL, 3898c2ecf20Sopenharmony_ci}; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ciunion devlink_param_value { 3928c2ecf20Sopenharmony_ci u8 vu8; 3938c2ecf20Sopenharmony_ci u16 vu16; 3948c2ecf20Sopenharmony_ci u32 vu32; 3958c2ecf20Sopenharmony_ci char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE]; 3968c2ecf20Sopenharmony_ci bool vbool; 3978c2ecf20Sopenharmony_ci}; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_cistruct devlink_param_gset_ctx { 4008c2ecf20Sopenharmony_ci union devlink_param_value val; 4018c2ecf20Sopenharmony_ci enum devlink_param_cmode cmode; 4028c2ecf20Sopenharmony_ci}; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci/** 4058c2ecf20Sopenharmony_ci * struct devlink_flash_notify - devlink dev flash notify data 4068c2ecf20Sopenharmony_ci * @status_msg: current status string 4078c2ecf20Sopenharmony_ci * @component: firmware component being updated 4088c2ecf20Sopenharmony_ci * @done: amount of work completed of total amount 4098c2ecf20Sopenharmony_ci * @total: amount of work expected to be done 4108c2ecf20Sopenharmony_ci * @timeout: expected max timeout in seconds 4118c2ecf20Sopenharmony_ci * 4128c2ecf20Sopenharmony_ci * These are values to be given to userland to be displayed in order 4138c2ecf20Sopenharmony_ci * to show current activity in a firmware update process. 4148c2ecf20Sopenharmony_ci */ 4158c2ecf20Sopenharmony_cistruct devlink_flash_notify { 4168c2ecf20Sopenharmony_ci const char *status_msg; 4178c2ecf20Sopenharmony_ci const char *component; 4188c2ecf20Sopenharmony_ci unsigned long done; 4198c2ecf20Sopenharmony_ci unsigned long total; 4208c2ecf20Sopenharmony_ci unsigned long timeout; 4218c2ecf20Sopenharmony_ci}; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci/** 4248c2ecf20Sopenharmony_ci * struct devlink_param - devlink configuration parameter data 4258c2ecf20Sopenharmony_ci * @name: name of the parameter 4268c2ecf20Sopenharmony_ci * @generic: indicates if the parameter is generic or driver specific 4278c2ecf20Sopenharmony_ci * @type: parameter type 4288c2ecf20Sopenharmony_ci * @supported_cmodes: bitmap of supported configuration modes 4298c2ecf20Sopenharmony_ci * @get: get parameter value, used for runtime and permanent 4308c2ecf20Sopenharmony_ci * configuration modes 4318c2ecf20Sopenharmony_ci * @set: set parameter value, used for runtime and permanent 4328c2ecf20Sopenharmony_ci * configuration modes 4338c2ecf20Sopenharmony_ci * @validate: validate input value is applicable (within value range, etc.) 4348c2ecf20Sopenharmony_ci * 4358c2ecf20Sopenharmony_ci * This struct should be used by the driver to fill the data for 4368c2ecf20Sopenharmony_ci * a parameter it registers. 4378c2ecf20Sopenharmony_ci */ 4388c2ecf20Sopenharmony_cistruct devlink_param { 4398c2ecf20Sopenharmony_ci u32 id; 4408c2ecf20Sopenharmony_ci const char *name; 4418c2ecf20Sopenharmony_ci bool generic; 4428c2ecf20Sopenharmony_ci enum devlink_param_type type; 4438c2ecf20Sopenharmony_ci unsigned long supported_cmodes; 4448c2ecf20Sopenharmony_ci int (*get)(struct devlink *devlink, u32 id, 4458c2ecf20Sopenharmony_ci struct devlink_param_gset_ctx *ctx); 4468c2ecf20Sopenharmony_ci int (*set)(struct devlink *devlink, u32 id, 4478c2ecf20Sopenharmony_ci struct devlink_param_gset_ctx *ctx); 4488c2ecf20Sopenharmony_ci int (*validate)(struct devlink *devlink, u32 id, 4498c2ecf20Sopenharmony_ci union devlink_param_value val, 4508c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 4518c2ecf20Sopenharmony_ci}; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_cistruct devlink_param_item { 4548c2ecf20Sopenharmony_ci struct list_head list; 4558c2ecf20Sopenharmony_ci const struct devlink_param *param; 4568c2ecf20Sopenharmony_ci union devlink_param_value driverinit_value; 4578c2ecf20Sopenharmony_ci bool driverinit_value_valid; 4588c2ecf20Sopenharmony_ci bool published; 4598c2ecf20Sopenharmony_ci}; 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_cienum devlink_param_generic_id { 4628c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, 4638c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_MAX_MACS, 4648c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, 4658c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, 4668c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, 4678c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, 4688c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, 4698c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, 4708c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE, 4718c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, 4728c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET, 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci /* add new param generic ids above here*/ 4758c2ecf20Sopenharmony_ci __DEVLINK_PARAM_GENERIC_ID_MAX, 4768c2ecf20Sopenharmony_ci DEVLINK_PARAM_GENERIC_ID_MAX = __DEVLINK_PARAM_GENERIC_ID_MAX - 1, 4778c2ecf20Sopenharmony_ci}; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME "internal_error_reset" 4808c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME "max_macs" 4838c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE DEVLINK_PARAM_TYPE_U32 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME "enable_sriov" 4868c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE DEVLINK_PARAM_TYPE_BOOL 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable" 4898c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari" 4928c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max" 4958c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min" 4988c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME "fw_load_policy" 5018c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE DEVLINK_PARAM_TYPE_U8 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_NAME \ 5048c2ecf20Sopenharmony_ci "reset_dev_on_drv_probe" 5058c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_TYPE DEVLINK_PARAM_TYPE_U8 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME "enable_roce" 5088c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE DEVLINK_PARAM_TYPE_BOOL 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_NAME "enable_remote_dev_reset" 5118c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ 5148c2ecf20Sopenharmony_ci{ \ 5158c2ecf20Sopenharmony_ci .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ 5168c2ecf20Sopenharmony_ci .name = DEVLINK_PARAM_GENERIC_##_id##_NAME, \ 5178c2ecf20Sopenharmony_ci .type = DEVLINK_PARAM_GENERIC_##_id##_TYPE, \ 5188c2ecf20Sopenharmony_ci .generic = true, \ 5198c2ecf20Sopenharmony_ci .supported_cmodes = _cmodes, \ 5208c2ecf20Sopenharmony_ci .get = _get, \ 5218c2ecf20Sopenharmony_ci .set = _set, \ 5228c2ecf20Sopenharmony_ci .validate = _validate, \ 5238c2ecf20Sopenharmony_ci} 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci#define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate) \ 5268c2ecf20Sopenharmony_ci{ \ 5278c2ecf20Sopenharmony_ci .id = _id, \ 5288c2ecf20Sopenharmony_ci .name = _name, \ 5298c2ecf20Sopenharmony_ci .type = _type, \ 5308c2ecf20Sopenharmony_ci .supported_cmodes = _cmodes, \ 5318c2ecf20Sopenharmony_ci .get = _get, \ 5328c2ecf20Sopenharmony_ci .set = _set, \ 5338c2ecf20Sopenharmony_ci .validate = _validate, \ 5348c2ecf20Sopenharmony_ci} 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci/* Part number, identifier of board design */ 5378c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id" 5388c2ecf20Sopenharmony_ci/* Revision of board design */ 5398c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev" 5408c2ecf20Sopenharmony_ci/* Maker of the board */ 5418c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture" 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci/* Part number, identifier of asic design */ 5448c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_ASIC_ID "asic.id" 5458c2ecf20Sopenharmony_ci/* Revision of asic design */ 5468c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_ASIC_REV "asic.rev" 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci/* Overall FW version */ 5498c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW "fw" 5508c2ecf20Sopenharmony_ci/* Control processor FW version */ 5518c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt" 5528c2ecf20Sopenharmony_ci/* FW interface specification version */ 5538c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API "fw.mgmt.api" 5548c2ecf20Sopenharmony_ci/* Data path microcode controlling high-speed packet processing */ 5558c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_APP "fw.app" 5568c2ecf20Sopenharmony_ci/* UNDI software version */ 5578c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI "fw.undi" 5588c2ecf20Sopenharmony_ci/* NCSI support/handler version */ 5598c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI "fw.ncsi" 5608c2ecf20Sopenharmony_ci/* FW parameter set id */ 5618c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_PSID "fw.psid" 5628c2ecf20Sopenharmony_ci/* RoCE FW version */ 5638c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_ROCE "fw.roce" 5648c2ecf20Sopenharmony_ci/* Firmware bundle identifier */ 5658c2ecf20Sopenharmony_ci#define DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID "fw.bundle_id" 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci/** 5688c2ecf20Sopenharmony_ci * struct devlink_flash_update_params - Flash Update parameters 5698c2ecf20Sopenharmony_ci * @file_name: the name of the flash firmware file to update from 5708c2ecf20Sopenharmony_ci * @component: the flash component to update 5718c2ecf20Sopenharmony_ci * 5728c2ecf20Sopenharmony_ci * With the exception of file_name, drivers must opt-in to parameters by 5738c2ecf20Sopenharmony_ci * setting the appropriate bit in the supported_flash_update_params field in 5748c2ecf20Sopenharmony_ci * their devlink_ops structure. 5758c2ecf20Sopenharmony_ci */ 5768c2ecf20Sopenharmony_cistruct devlink_flash_update_params { 5778c2ecf20Sopenharmony_ci const char *file_name; 5788c2ecf20Sopenharmony_ci const char *component; 5798c2ecf20Sopenharmony_ci u32 overwrite_mask; 5808c2ecf20Sopenharmony_ci}; 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci#define DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT BIT(0) 5838c2ecf20Sopenharmony_ci#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1) 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_cistruct devlink_region; 5868c2ecf20Sopenharmony_cistruct devlink_info_req; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci/** 5898c2ecf20Sopenharmony_ci * struct devlink_region_ops - Region operations 5908c2ecf20Sopenharmony_ci * @name: region name 5918c2ecf20Sopenharmony_ci * @destructor: callback used to free snapshot memory when deleting 5928c2ecf20Sopenharmony_ci * @snapshot: callback to request an immediate snapshot. On success, 5938c2ecf20Sopenharmony_ci * the data variable must be updated to point to the snapshot data. 5948c2ecf20Sopenharmony_ci * The function will be called while the devlink instance lock is 5958c2ecf20Sopenharmony_ci * held. 5968c2ecf20Sopenharmony_ci * @priv: Pointer to driver private data for the region operation 5978c2ecf20Sopenharmony_ci */ 5988c2ecf20Sopenharmony_cistruct devlink_region_ops { 5998c2ecf20Sopenharmony_ci const char *name; 6008c2ecf20Sopenharmony_ci void (*destructor)(const void *data); 6018c2ecf20Sopenharmony_ci int (*snapshot)(struct devlink *devlink, 6028c2ecf20Sopenharmony_ci const struct devlink_region_ops *ops, 6038c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack, 6048c2ecf20Sopenharmony_ci u8 **data); 6058c2ecf20Sopenharmony_ci void *priv; 6068c2ecf20Sopenharmony_ci}; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci/** 6098c2ecf20Sopenharmony_ci * struct devlink_port_region_ops - Region operations for a port 6108c2ecf20Sopenharmony_ci * @name: region name 6118c2ecf20Sopenharmony_ci * @destructor: callback used to free snapshot memory when deleting 6128c2ecf20Sopenharmony_ci * @snapshot: callback to request an immediate snapshot. On success, 6138c2ecf20Sopenharmony_ci * the data variable must be updated to point to the snapshot data. 6148c2ecf20Sopenharmony_ci * The function will be called while the devlink instance lock is 6158c2ecf20Sopenharmony_ci * held. 6168c2ecf20Sopenharmony_ci * @priv: Pointer to driver private data for the region operation 6178c2ecf20Sopenharmony_ci */ 6188c2ecf20Sopenharmony_cistruct devlink_port_region_ops { 6198c2ecf20Sopenharmony_ci const char *name; 6208c2ecf20Sopenharmony_ci void (*destructor)(const void *data); 6218c2ecf20Sopenharmony_ci int (*snapshot)(struct devlink_port *port, 6228c2ecf20Sopenharmony_ci const struct devlink_port_region_ops *ops, 6238c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack, 6248c2ecf20Sopenharmony_ci u8 **data); 6258c2ecf20Sopenharmony_ci void *priv; 6268c2ecf20Sopenharmony_ci}; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_cistruct devlink_fmsg; 6298c2ecf20Sopenharmony_cistruct devlink_health_reporter; 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_cienum devlink_health_reporter_state { 6328c2ecf20Sopenharmony_ci DEVLINK_HEALTH_REPORTER_STATE_HEALTHY, 6338c2ecf20Sopenharmony_ci DEVLINK_HEALTH_REPORTER_STATE_ERROR, 6348c2ecf20Sopenharmony_ci}; 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ci/** 6378c2ecf20Sopenharmony_ci * struct devlink_health_reporter_ops - Reporter operations 6388c2ecf20Sopenharmony_ci * @name: reporter name 6398c2ecf20Sopenharmony_ci * @recover: callback to recover from reported error 6408c2ecf20Sopenharmony_ci * if priv_ctx is NULL, run a full recover 6418c2ecf20Sopenharmony_ci * @dump: callback to dump an object 6428c2ecf20Sopenharmony_ci * if priv_ctx is NULL, run a full dump 6438c2ecf20Sopenharmony_ci * @diagnose: callback to diagnose the current status 6448c2ecf20Sopenharmony_ci * @test: callback to trigger a test event 6458c2ecf20Sopenharmony_ci */ 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_cistruct devlink_health_reporter_ops { 6488c2ecf20Sopenharmony_ci char *name; 6498c2ecf20Sopenharmony_ci int (*recover)(struct devlink_health_reporter *reporter, 6508c2ecf20Sopenharmony_ci void *priv_ctx, struct netlink_ext_ack *extack); 6518c2ecf20Sopenharmony_ci int (*dump)(struct devlink_health_reporter *reporter, 6528c2ecf20Sopenharmony_ci struct devlink_fmsg *fmsg, void *priv_ctx, 6538c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 6548c2ecf20Sopenharmony_ci int (*diagnose)(struct devlink_health_reporter *reporter, 6558c2ecf20Sopenharmony_ci struct devlink_fmsg *fmsg, 6568c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 6578c2ecf20Sopenharmony_ci int (*test)(struct devlink_health_reporter *reporter, 6588c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 6598c2ecf20Sopenharmony_ci}; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci/** 6628c2ecf20Sopenharmony_ci * struct devlink_trap_metadata - Packet trap metadata. 6638c2ecf20Sopenharmony_ci * @trap_name: Trap name. 6648c2ecf20Sopenharmony_ci * @trap_group_name: Trap group name. 6658c2ecf20Sopenharmony_ci * @input_dev: Input netdevice. 6668c2ecf20Sopenharmony_ci * @fa_cookie: Flow action user cookie. 6678c2ecf20Sopenharmony_ci * @trap_type: Trap type. 6688c2ecf20Sopenharmony_ci */ 6698c2ecf20Sopenharmony_cistruct devlink_trap_metadata { 6708c2ecf20Sopenharmony_ci const char *trap_name; 6718c2ecf20Sopenharmony_ci const char *trap_group_name; 6728c2ecf20Sopenharmony_ci struct net_device *input_dev; 6738c2ecf20Sopenharmony_ci const struct flow_action_cookie *fa_cookie; 6748c2ecf20Sopenharmony_ci enum devlink_trap_type trap_type; 6758c2ecf20Sopenharmony_ci}; 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci/** 6788c2ecf20Sopenharmony_ci * struct devlink_trap_policer - Immutable packet trap policer attributes. 6798c2ecf20Sopenharmony_ci * @id: Policer identifier. 6808c2ecf20Sopenharmony_ci * @init_rate: Initial rate in packets / sec. 6818c2ecf20Sopenharmony_ci * @init_burst: Initial burst size in packets. 6828c2ecf20Sopenharmony_ci * @max_rate: Maximum rate. 6838c2ecf20Sopenharmony_ci * @min_rate: Minimum rate. 6848c2ecf20Sopenharmony_ci * @max_burst: Maximum burst size. 6858c2ecf20Sopenharmony_ci * @min_burst: Minimum burst size. 6868c2ecf20Sopenharmony_ci * 6878c2ecf20Sopenharmony_ci * Describes immutable attributes of packet trap policers that drivers register 6888c2ecf20Sopenharmony_ci * with devlink. 6898c2ecf20Sopenharmony_ci */ 6908c2ecf20Sopenharmony_cistruct devlink_trap_policer { 6918c2ecf20Sopenharmony_ci u32 id; 6928c2ecf20Sopenharmony_ci u64 init_rate; 6938c2ecf20Sopenharmony_ci u64 init_burst; 6948c2ecf20Sopenharmony_ci u64 max_rate; 6958c2ecf20Sopenharmony_ci u64 min_rate; 6968c2ecf20Sopenharmony_ci u64 max_burst; 6978c2ecf20Sopenharmony_ci u64 min_burst; 6988c2ecf20Sopenharmony_ci}; 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci/** 7018c2ecf20Sopenharmony_ci * struct devlink_trap_group - Immutable packet trap group attributes. 7028c2ecf20Sopenharmony_ci * @name: Trap group name. 7038c2ecf20Sopenharmony_ci * @id: Trap group identifier. 7048c2ecf20Sopenharmony_ci * @generic: Whether the trap group is generic or not. 7058c2ecf20Sopenharmony_ci * @init_policer_id: Initial policer identifier. 7068c2ecf20Sopenharmony_ci * 7078c2ecf20Sopenharmony_ci * Describes immutable attributes of packet trap groups that drivers register 7088c2ecf20Sopenharmony_ci * with devlink. 7098c2ecf20Sopenharmony_ci */ 7108c2ecf20Sopenharmony_cistruct devlink_trap_group { 7118c2ecf20Sopenharmony_ci const char *name; 7128c2ecf20Sopenharmony_ci u16 id; 7138c2ecf20Sopenharmony_ci bool generic; 7148c2ecf20Sopenharmony_ci u32 init_policer_id; 7158c2ecf20Sopenharmony_ci}; 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT BIT(0) 7188c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE BIT(1) 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci/** 7218c2ecf20Sopenharmony_ci * struct devlink_trap - Immutable packet trap attributes. 7228c2ecf20Sopenharmony_ci * @type: Trap type. 7238c2ecf20Sopenharmony_ci * @init_action: Initial trap action. 7248c2ecf20Sopenharmony_ci * @generic: Whether the trap is generic or not. 7258c2ecf20Sopenharmony_ci * @id: Trap identifier. 7268c2ecf20Sopenharmony_ci * @name: Trap name. 7278c2ecf20Sopenharmony_ci * @init_group_id: Initial group identifier. 7288c2ecf20Sopenharmony_ci * @metadata_cap: Metadata types that can be provided by the trap. 7298c2ecf20Sopenharmony_ci * 7308c2ecf20Sopenharmony_ci * Describes immutable attributes of packet traps that drivers register with 7318c2ecf20Sopenharmony_ci * devlink. 7328c2ecf20Sopenharmony_ci */ 7338c2ecf20Sopenharmony_cistruct devlink_trap { 7348c2ecf20Sopenharmony_ci enum devlink_trap_type type; 7358c2ecf20Sopenharmony_ci enum devlink_trap_action init_action; 7368c2ecf20Sopenharmony_ci bool generic; 7378c2ecf20Sopenharmony_ci u16 id; 7388c2ecf20Sopenharmony_ci const char *name; 7398c2ecf20Sopenharmony_ci u16 init_group_id; 7408c2ecf20Sopenharmony_ci u32 metadata_cap; 7418c2ecf20Sopenharmony_ci}; 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci/* All traps must be documented in 7448c2ecf20Sopenharmony_ci * Documentation/networking/devlink/devlink-trap.rst 7458c2ecf20Sopenharmony_ci */ 7468c2ecf20Sopenharmony_cienum devlink_trap_generic_id { 7478c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_SMAC_MC, 7488c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_VLAN_TAG_MISMATCH, 7498c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER, 7508c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_INGRESS_STP_FILTER, 7518c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_EMPTY_TX_LIST, 7528c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_PORT_LOOPBACK_FILTER, 7538c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_BLACKHOLE_ROUTE, 7548c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_TTL_ERROR, 7558c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_TAIL_DROP, 7568c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_NON_IP_PACKET, 7578c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_UC_DIP_MC_DMAC, 7588c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_DIP_LB, 7598c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_SIP_MC, 7608c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_SIP_LB, 7618c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_CORRUPTED_IP_HDR, 7628c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_SIP_BC, 7638c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_RESERVED_SCOPE, 7648c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE, 7658c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MTU_ERROR, 7668c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_UNRESOLVED_NEIGH, 7678c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_RPF, 7688c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_REJECT_ROUTE, 7698c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_LPM_UNICAST_MISS, 7708c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_LPM_UNICAST_MISS, 7718c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_NON_ROUTABLE, 7728c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_DECAP_ERROR, 7738c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_OVERLAY_SMAC_MC, 7748c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_INGRESS_FLOW_ACTION_DROP, 7758c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_EGRESS_FLOW_ACTION_DROP, 7768c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_STP, 7778c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_LACP, 7788c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_LLDP, 7798c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IGMP_QUERY, 7808c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IGMP_V1_REPORT, 7818c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IGMP_V2_REPORT, 7828c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IGMP_V3_REPORT, 7838c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IGMP_V2_LEAVE, 7848c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MLD_QUERY, 7858c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MLD_V1_REPORT, 7868c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MLD_V2_REPORT, 7878c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MLD_V1_DONE, 7888c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_DHCP, 7898c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_DHCP, 7908c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_ARP_REQUEST, 7918c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_ARP_RESPONSE, 7928c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_ARP_OVERLAY, 7938c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_SOLICIT, 7948c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_ADVERT, 7958c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_BFD, 7968c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_BFD, 7978c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_OSPF, 7988c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_OSPF, 7998c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_BGP, 8008c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_BGP, 8018c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_VRRP, 8028c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_VRRP, 8038c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_PIM, 8048c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_PIM, 8058c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_UC_LB, 8068c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_LOCAL_ROUTE, 8078c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_EXTERNAL_ROUTE, 8088c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_UC_DIP_LINK_LOCAL_SCOPE, 8098c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_NODES, 8108c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_ROUTERS, 8118c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_SOLICIT, 8128c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ADVERT, 8138c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_REDIRECT, 8148c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV4_ROUTER_ALERT, 8158c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ALERT, 8168c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_PTP_EVENT, 8178c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_PTP_GENERAL, 8188c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE, 8198c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP, 8208c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_EARLY_DROP, 8218c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_VXLAN_PARSING, 8228c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_LLC_SNAP_PARSING, 8238c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_VLAN_PARSING, 8248c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_PPPOE_PPP_PARSING, 8258c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MPLS_PARSING, 8268c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_ARP_PARSING, 8278c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IP_1_PARSING, 8288c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IP_N_PARSING, 8298c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_GRE_PARSING, 8308c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_UDP_PARSING, 8318c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_TCP_PARSING, 8328c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_IPSEC_PARSING, 8338c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_SCTP_PARSING, 8348c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_DCCP_PARSING, 8358c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_GTP_PARSING, 8368c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_ESP_PARSING, 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci /* Add new generic trap IDs above */ 8398c2ecf20Sopenharmony_ci __DEVLINK_TRAP_GENERIC_ID_MAX, 8408c2ecf20Sopenharmony_ci DEVLINK_TRAP_GENERIC_ID_MAX = __DEVLINK_TRAP_GENERIC_ID_MAX - 1, 8418c2ecf20Sopenharmony_ci}; 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_ci/* All trap groups must be documented in 8448c2ecf20Sopenharmony_ci * Documentation/networking/devlink/devlink-trap.rst 8458c2ecf20Sopenharmony_ci */ 8468c2ecf20Sopenharmony_cienum devlink_trap_group_generic_id { 8478c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS, 8488c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS, 8498c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_L3_EXCEPTIONS, 8508c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS, 8518c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_TUNNEL_DROPS, 8528c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_DROPS, 8538c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_STP, 8548c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_LACP, 8558c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_LLDP, 8568c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_MC_SNOOPING, 8578c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_DHCP, 8588c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_NEIGH_DISCOVERY, 8598c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_BFD, 8608c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_OSPF, 8618c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_BGP, 8628c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_VRRP, 8638c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_PIM, 8648c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_UC_LB, 8658c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_LOCAL_DELIVERY, 8668c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_EXTERNAL_DELIVERY, 8678c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_IPV6, 8688c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_EVENT, 8698c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_GENERAL, 8708c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_SAMPLE, 8718c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_TRAP, 8728c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_PARSER_ERROR_DROPS, 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci /* Add new generic trap group IDs above */ 8758c2ecf20Sopenharmony_ci __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX, 8768c2ecf20Sopenharmony_ci DEVLINK_TRAP_GROUP_GENERIC_ID_MAX = 8778c2ecf20Sopenharmony_ci __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX - 1, 8788c2ecf20Sopenharmony_ci}; 8798c2ecf20Sopenharmony_ci 8808c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_SMAC_MC \ 8818c2ecf20Sopenharmony_ci "source_mac_is_multicast" 8828c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_VLAN_TAG_MISMATCH \ 8838c2ecf20Sopenharmony_ci "vlan_tag_mismatch" 8848c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_VLAN_FILTER \ 8858c2ecf20Sopenharmony_ci "ingress_vlan_filter" 8868c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_STP_FILTER \ 8878c2ecf20Sopenharmony_ci "ingress_spanning_tree_filter" 8888c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_EMPTY_TX_LIST \ 8898c2ecf20Sopenharmony_ci "port_list_is_empty" 8908c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_PORT_LOOPBACK_FILTER \ 8918c2ecf20Sopenharmony_ci "port_loopback_filter" 8928c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_ROUTE \ 8938c2ecf20Sopenharmony_ci "blackhole_route" 8948c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_TTL_ERROR \ 8958c2ecf20Sopenharmony_ci "ttl_value_is_too_small" 8968c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_TAIL_DROP \ 8978c2ecf20Sopenharmony_ci "tail_drop" 8988c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_NON_IP_PACKET \ 8998c2ecf20Sopenharmony_ci "non_ip" 9008c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_UC_DIP_MC_DMAC \ 9018c2ecf20Sopenharmony_ci "uc_dip_over_mc_dmac" 9028c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_DIP_LB \ 9038c2ecf20Sopenharmony_ci "dip_is_loopback_address" 9048c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_SIP_MC \ 9058c2ecf20Sopenharmony_ci "sip_is_mc" 9068c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_SIP_LB \ 9078c2ecf20Sopenharmony_ci "sip_is_loopback_address" 9088c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_CORRUPTED_IP_HDR \ 9098c2ecf20Sopenharmony_ci "ip_header_corrupted" 9108c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_SIP_BC \ 9118c2ecf20Sopenharmony_ci "ipv4_sip_is_limited_bc" 9128c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_RESERVED_SCOPE \ 9138c2ecf20Sopenharmony_ci "ipv6_mc_dip_reserved_scope" 9148c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE \ 9158c2ecf20Sopenharmony_ci "ipv6_mc_dip_interface_local_scope" 9168c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_MTU_ERROR \ 9178c2ecf20Sopenharmony_ci "mtu_value_is_too_small" 9188c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_UNRESOLVED_NEIGH \ 9198c2ecf20Sopenharmony_ci "unresolved_neigh" 9208c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_RPF \ 9218c2ecf20Sopenharmony_ci "mc_reverse_path_forwarding" 9228c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_REJECT_ROUTE \ 9238c2ecf20Sopenharmony_ci "reject_route" 9248c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_LPM_UNICAST_MISS \ 9258c2ecf20Sopenharmony_ci "ipv4_lpm_miss" 9268c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_LPM_UNICAST_MISS \ 9278c2ecf20Sopenharmony_ci "ipv6_lpm_miss" 9288c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_NON_ROUTABLE \ 9298c2ecf20Sopenharmony_ci "non_routable_packet" 9308c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_DECAP_ERROR \ 9318c2ecf20Sopenharmony_ci "decap_error" 9328c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_OVERLAY_SMAC_MC \ 9338c2ecf20Sopenharmony_ci "overlay_smac_is_mc" 9348c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_FLOW_ACTION_DROP \ 9358c2ecf20Sopenharmony_ci "ingress_flow_action_drop" 9368c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_EGRESS_FLOW_ACTION_DROP \ 9378c2ecf20Sopenharmony_ci "egress_flow_action_drop" 9388c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_STP \ 9398c2ecf20Sopenharmony_ci "stp" 9408c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_LACP \ 9418c2ecf20Sopenharmony_ci "lacp" 9428c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_LLDP \ 9438c2ecf20Sopenharmony_ci "lldp" 9448c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IGMP_QUERY \ 9458c2ecf20Sopenharmony_ci "igmp_query" 9468c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V1_REPORT \ 9478c2ecf20Sopenharmony_ci "igmp_v1_report" 9488c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_REPORT \ 9498c2ecf20Sopenharmony_ci "igmp_v2_report" 9508c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V3_REPORT \ 9518c2ecf20Sopenharmony_ci "igmp_v3_report" 9528c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_LEAVE \ 9538c2ecf20Sopenharmony_ci "igmp_v2_leave" 9548c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_MLD_QUERY \ 9558c2ecf20Sopenharmony_ci "mld_query" 9568c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_REPORT \ 9578c2ecf20Sopenharmony_ci "mld_v1_report" 9588c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_MLD_V2_REPORT \ 9598c2ecf20Sopenharmony_ci "mld_v2_report" 9608c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_DONE \ 9618c2ecf20Sopenharmony_ci "mld_v1_done" 9628c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_DHCP \ 9638c2ecf20Sopenharmony_ci "ipv4_dhcp" 9648c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DHCP \ 9658c2ecf20Sopenharmony_ci "ipv6_dhcp" 9668c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_ARP_REQUEST \ 9678c2ecf20Sopenharmony_ci "arp_request" 9688c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_ARP_RESPONSE \ 9698c2ecf20Sopenharmony_ci "arp_response" 9708c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_ARP_OVERLAY \ 9718c2ecf20Sopenharmony_ci "arp_overlay" 9728c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_SOLICIT \ 9738c2ecf20Sopenharmony_ci "ipv6_neigh_solicit" 9748c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_ADVERT \ 9758c2ecf20Sopenharmony_ci "ipv6_neigh_advert" 9768c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_BFD \ 9778c2ecf20Sopenharmony_ci "ipv4_bfd" 9788c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_BFD \ 9798c2ecf20Sopenharmony_ci "ipv6_bfd" 9808c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_OSPF \ 9818c2ecf20Sopenharmony_ci "ipv4_ospf" 9828c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_OSPF \ 9838c2ecf20Sopenharmony_ci "ipv6_ospf" 9848c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_BGP \ 9858c2ecf20Sopenharmony_ci "ipv4_bgp" 9868c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_BGP \ 9878c2ecf20Sopenharmony_ci "ipv6_bgp" 9888c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_VRRP \ 9898c2ecf20Sopenharmony_ci "ipv4_vrrp" 9908c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_VRRP \ 9918c2ecf20Sopenharmony_ci "ipv6_vrrp" 9928c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_PIM \ 9938c2ecf20Sopenharmony_ci "ipv4_pim" 9948c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_PIM \ 9958c2ecf20Sopenharmony_ci "ipv6_pim" 9968c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_UC_LB \ 9978c2ecf20Sopenharmony_ci "uc_loopback" 9988c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_LOCAL_ROUTE \ 9998c2ecf20Sopenharmony_ci "local_route" 10008c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_EXTERNAL_ROUTE \ 10018c2ecf20Sopenharmony_ci "external_route" 10028c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_UC_DIP_LINK_LOCAL_SCOPE \ 10038c2ecf20Sopenharmony_ci "ipv6_uc_dip_link_local_scope" 10048c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_NODES \ 10058c2ecf20Sopenharmony_ci "ipv6_dip_all_nodes" 10068c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_ROUTERS \ 10078c2ecf20Sopenharmony_ci "ipv6_dip_all_routers" 10088c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_SOLICIT \ 10098c2ecf20Sopenharmony_ci "ipv6_router_solicit" 10108c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ADVERT \ 10118c2ecf20Sopenharmony_ci "ipv6_router_advert" 10128c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_REDIRECT \ 10138c2ecf20Sopenharmony_ci "ipv6_redirect" 10148c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV4_ROUTER_ALERT \ 10158c2ecf20Sopenharmony_ci "ipv4_router_alert" 10168c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ALERT \ 10178c2ecf20Sopenharmony_ci "ipv6_router_alert" 10188c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_PTP_EVENT \ 10198c2ecf20Sopenharmony_ci "ptp_event" 10208c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_PTP_GENERAL \ 10218c2ecf20Sopenharmony_ci "ptp_general" 10228c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_SAMPLE \ 10238c2ecf20Sopenharmony_ci "flow_action_sample" 10248c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP \ 10258c2ecf20Sopenharmony_ci "flow_action_trap" 10268c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_EARLY_DROP \ 10278c2ecf20Sopenharmony_ci "early_drop" 10288c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_VXLAN_PARSING \ 10298c2ecf20Sopenharmony_ci "vxlan_parsing" 10308c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_LLC_SNAP_PARSING \ 10318c2ecf20Sopenharmony_ci "llc_snap_parsing" 10328c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_VLAN_PARSING \ 10338c2ecf20Sopenharmony_ci "vlan_parsing" 10348c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_PPPOE_PPP_PARSING \ 10358c2ecf20Sopenharmony_ci "pppoe_ppp_parsing" 10368c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_MPLS_PARSING \ 10378c2ecf20Sopenharmony_ci "mpls_parsing" 10388c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_ARP_PARSING \ 10398c2ecf20Sopenharmony_ci "arp_parsing" 10408c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IP_1_PARSING \ 10418c2ecf20Sopenharmony_ci "ip_1_parsing" 10428c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IP_N_PARSING \ 10438c2ecf20Sopenharmony_ci "ip_n_parsing" 10448c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_GRE_PARSING \ 10458c2ecf20Sopenharmony_ci "gre_parsing" 10468c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_UDP_PARSING \ 10478c2ecf20Sopenharmony_ci "udp_parsing" 10488c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_TCP_PARSING \ 10498c2ecf20Sopenharmony_ci "tcp_parsing" 10508c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_IPSEC_PARSING \ 10518c2ecf20Sopenharmony_ci "ipsec_parsing" 10528c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_SCTP_PARSING \ 10538c2ecf20Sopenharmony_ci "sctp_parsing" 10548c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_DCCP_PARSING \ 10558c2ecf20Sopenharmony_ci "dccp_parsing" 10568c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_GTP_PARSING \ 10578c2ecf20Sopenharmony_ci "gtp_parsing" 10588c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC_NAME_ESP_PARSING \ 10598c2ecf20Sopenharmony_ci "esp_parsing" 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \ 10638c2ecf20Sopenharmony_ci "l2_drops" 10648c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS \ 10658c2ecf20Sopenharmony_ci "l3_drops" 10668c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_EXCEPTIONS \ 10678c2ecf20Sopenharmony_ci "l3_exceptions" 10688c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS \ 10698c2ecf20Sopenharmony_ci "buffer_drops" 10708c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_TUNNEL_DROPS \ 10718c2ecf20Sopenharmony_ci "tunnel_drops" 10728c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_DROPS \ 10738c2ecf20Sopenharmony_ci "acl_drops" 10748c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_STP \ 10758c2ecf20Sopenharmony_ci "stp" 10768c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LACP \ 10778c2ecf20Sopenharmony_ci "lacp" 10788c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LLDP \ 10798c2ecf20Sopenharmony_ci "lldp" 10808c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_MC_SNOOPING \ 10818c2ecf20Sopenharmony_ci "mc_snooping" 10828c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_DHCP \ 10838c2ecf20Sopenharmony_ci "dhcp" 10848c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_NEIGH_DISCOVERY \ 10858c2ecf20Sopenharmony_ci "neigh_discovery" 10868c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BFD \ 10878c2ecf20Sopenharmony_ci "bfd" 10888c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_OSPF \ 10898c2ecf20Sopenharmony_ci "ospf" 10908c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BGP \ 10918c2ecf20Sopenharmony_ci "bgp" 10928c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_VRRP \ 10938c2ecf20Sopenharmony_ci "vrrp" 10948c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PIM \ 10958c2ecf20Sopenharmony_ci "pim" 10968c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_UC_LB \ 10978c2ecf20Sopenharmony_ci "uc_loopback" 10988c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LOCAL_DELIVERY \ 10998c2ecf20Sopenharmony_ci "local_delivery" 11008c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_EXTERNAL_DELIVERY \ 11018c2ecf20Sopenharmony_ci "external_delivery" 11028c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_IPV6 \ 11038c2ecf20Sopenharmony_ci "ipv6" 11048c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_EVENT \ 11058c2ecf20Sopenharmony_ci "ptp_event" 11068c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_GENERAL \ 11078c2ecf20Sopenharmony_ci "ptp_general" 11088c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_SAMPLE \ 11098c2ecf20Sopenharmony_ci "acl_sample" 11108c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_TRAP \ 11118c2ecf20Sopenharmony_ci "acl_trap" 11128c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PARSER_ERROR_DROPS \ 11138c2ecf20Sopenharmony_ci "parser_error_drops" 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id, \ 11168c2ecf20Sopenharmony_ci _metadata_cap) \ 11178c2ecf20Sopenharmony_ci { \ 11188c2ecf20Sopenharmony_ci .type = DEVLINK_TRAP_TYPE_##_type, \ 11198c2ecf20Sopenharmony_ci .init_action = DEVLINK_TRAP_ACTION_##_init_action, \ 11208c2ecf20Sopenharmony_ci .generic = true, \ 11218c2ecf20Sopenharmony_ci .id = DEVLINK_TRAP_GENERIC_ID_##_id, \ 11228c2ecf20Sopenharmony_ci .name = DEVLINK_TRAP_GENERIC_NAME_##_id, \ 11238c2ecf20Sopenharmony_ci .init_group_id = _group_id, \ 11248c2ecf20Sopenharmony_ci .metadata_cap = _metadata_cap, \ 11258c2ecf20Sopenharmony_ci } 11268c2ecf20Sopenharmony_ci 11278c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_DRIVER(_type, _init_action, _id, _name, _group_id, \ 11288c2ecf20Sopenharmony_ci _metadata_cap) \ 11298c2ecf20Sopenharmony_ci { \ 11308c2ecf20Sopenharmony_ci .type = DEVLINK_TRAP_TYPE_##_type, \ 11318c2ecf20Sopenharmony_ci .init_action = DEVLINK_TRAP_ACTION_##_init_action, \ 11328c2ecf20Sopenharmony_ci .generic = false, \ 11338c2ecf20Sopenharmony_ci .id = _id, \ 11348c2ecf20Sopenharmony_ci .name = _name, \ 11358c2ecf20Sopenharmony_ci .init_group_id = _group_id, \ 11368c2ecf20Sopenharmony_ci .metadata_cap = _metadata_cap, \ 11378c2ecf20Sopenharmony_ci } 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_GROUP_GENERIC(_id, _policer_id) \ 11408c2ecf20Sopenharmony_ci { \ 11418c2ecf20Sopenharmony_ci .name = DEVLINK_TRAP_GROUP_GENERIC_NAME_##_id, \ 11428c2ecf20Sopenharmony_ci .id = DEVLINK_TRAP_GROUP_GENERIC_ID_##_id, \ 11438c2ecf20Sopenharmony_ci .generic = true, \ 11448c2ecf20Sopenharmony_ci .init_policer_id = _policer_id, \ 11458c2ecf20Sopenharmony_ci } 11468c2ecf20Sopenharmony_ci 11478c2ecf20Sopenharmony_ci#define DEVLINK_TRAP_POLICER(_id, _rate, _burst, _max_rate, _min_rate, \ 11488c2ecf20Sopenharmony_ci _max_burst, _min_burst) \ 11498c2ecf20Sopenharmony_ci { \ 11508c2ecf20Sopenharmony_ci .id = _id, \ 11518c2ecf20Sopenharmony_ci .init_rate = _rate, \ 11528c2ecf20Sopenharmony_ci .init_burst = _burst, \ 11538c2ecf20Sopenharmony_ci .max_rate = _max_rate, \ 11548c2ecf20Sopenharmony_ci .min_rate = _min_rate, \ 11558c2ecf20Sopenharmony_ci .max_burst = _max_burst, \ 11568c2ecf20Sopenharmony_ci .min_burst = _min_burst, \ 11578c2ecf20Sopenharmony_ci } 11588c2ecf20Sopenharmony_ci 11598c2ecf20Sopenharmony_cistruct devlink_ops { 11608c2ecf20Sopenharmony_ci /** 11618c2ecf20Sopenharmony_ci * @supported_flash_update_params: 11628c2ecf20Sopenharmony_ci * mask of parameters supported by the driver's .flash_update 11638c2ecf20Sopenharmony_ci * implemementation. 11648c2ecf20Sopenharmony_ci */ 11658c2ecf20Sopenharmony_ci u32 supported_flash_update_params; 11668c2ecf20Sopenharmony_ci unsigned long reload_actions; 11678c2ecf20Sopenharmony_ci unsigned long reload_limits; 11688c2ecf20Sopenharmony_ci int (*reload_down)(struct devlink *devlink, bool netns_change, 11698c2ecf20Sopenharmony_ci enum devlink_reload_action action, 11708c2ecf20Sopenharmony_ci enum devlink_reload_limit limit, 11718c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 11728c2ecf20Sopenharmony_ci int (*reload_up)(struct devlink *devlink, enum devlink_reload_action action, 11738c2ecf20Sopenharmony_ci enum devlink_reload_limit limit, u32 *actions_performed, 11748c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 11758c2ecf20Sopenharmony_ci int (*port_type_set)(struct devlink_port *devlink_port, 11768c2ecf20Sopenharmony_ci enum devlink_port_type port_type); 11778c2ecf20Sopenharmony_ci int (*port_split)(struct devlink *devlink, unsigned int port_index, 11788c2ecf20Sopenharmony_ci unsigned int count, struct netlink_ext_ack *extack); 11798c2ecf20Sopenharmony_ci int (*port_unsplit)(struct devlink *devlink, unsigned int port_index, 11808c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 11818c2ecf20Sopenharmony_ci int (*sb_pool_get)(struct devlink *devlink, unsigned int sb_index, 11828c2ecf20Sopenharmony_ci u16 pool_index, 11838c2ecf20Sopenharmony_ci struct devlink_sb_pool_info *pool_info); 11848c2ecf20Sopenharmony_ci int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index, 11858c2ecf20Sopenharmony_ci u16 pool_index, u32 size, 11868c2ecf20Sopenharmony_ci enum devlink_sb_threshold_type threshold_type, 11878c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 11888c2ecf20Sopenharmony_ci int (*sb_port_pool_get)(struct devlink_port *devlink_port, 11898c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 11908c2ecf20Sopenharmony_ci u32 *p_threshold); 11918c2ecf20Sopenharmony_ci int (*sb_port_pool_set)(struct devlink_port *devlink_port, 11928c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 11938c2ecf20Sopenharmony_ci u32 threshold, struct netlink_ext_ack *extack); 11948c2ecf20Sopenharmony_ci int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port, 11958c2ecf20Sopenharmony_ci unsigned int sb_index, 11968c2ecf20Sopenharmony_ci u16 tc_index, 11978c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type, 11988c2ecf20Sopenharmony_ci u16 *p_pool_index, u32 *p_threshold); 11998c2ecf20Sopenharmony_ci int (*sb_tc_pool_bind_set)(struct devlink_port *devlink_port, 12008c2ecf20Sopenharmony_ci unsigned int sb_index, 12018c2ecf20Sopenharmony_ci u16 tc_index, 12028c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type, 12038c2ecf20Sopenharmony_ci u16 pool_index, u32 threshold, 12048c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12058c2ecf20Sopenharmony_ci int (*sb_occ_snapshot)(struct devlink *devlink, 12068c2ecf20Sopenharmony_ci unsigned int sb_index); 12078c2ecf20Sopenharmony_ci int (*sb_occ_max_clear)(struct devlink *devlink, 12088c2ecf20Sopenharmony_ci unsigned int sb_index); 12098c2ecf20Sopenharmony_ci int (*sb_occ_port_pool_get)(struct devlink_port *devlink_port, 12108c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 12118c2ecf20Sopenharmony_ci u32 *p_cur, u32 *p_max); 12128c2ecf20Sopenharmony_ci int (*sb_occ_tc_port_bind_get)(struct devlink_port *devlink_port, 12138c2ecf20Sopenharmony_ci unsigned int sb_index, 12148c2ecf20Sopenharmony_ci u16 tc_index, 12158c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type, 12168c2ecf20Sopenharmony_ci u32 *p_cur, u32 *p_max); 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_ci int (*eswitch_mode_get)(struct devlink *devlink, u16 *p_mode); 12198c2ecf20Sopenharmony_ci int (*eswitch_mode_set)(struct devlink *devlink, u16 mode, 12208c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12218c2ecf20Sopenharmony_ci int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode); 12228c2ecf20Sopenharmony_ci int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode, 12238c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12248c2ecf20Sopenharmony_ci int (*eswitch_encap_mode_get)(struct devlink *devlink, 12258c2ecf20Sopenharmony_ci enum devlink_eswitch_encap_mode *p_encap_mode); 12268c2ecf20Sopenharmony_ci int (*eswitch_encap_mode_set)(struct devlink *devlink, 12278c2ecf20Sopenharmony_ci enum devlink_eswitch_encap_mode encap_mode, 12288c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12298c2ecf20Sopenharmony_ci int (*info_get)(struct devlink *devlink, struct devlink_info_req *req, 12308c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12318c2ecf20Sopenharmony_ci /** 12328c2ecf20Sopenharmony_ci * @flash_update: Device flash update function 12338c2ecf20Sopenharmony_ci * 12348c2ecf20Sopenharmony_ci * Used to perform a flash update for the device. The set of 12358c2ecf20Sopenharmony_ci * parameters supported by the driver should be set in 12368c2ecf20Sopenharmony_ci * supported_flash_update_params. 12378c2ecf20Sopenharmony_ci */ 12388c2ecf20Sopenharmony_ci int (*flash_update)(struct devlink *devlink, 12398c2ecf20Sopenharmony_ci struct devlink_flash_update_params *params, 12408c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12418c2ecf20Sopenharmony_ci /** 12428c2ecf20Sopenharmony_ci * @trap_init: Trap initialization function. 12438c2ecf20Sopenharmony_ci * 12448c2ecf20Sopenharmony_ci * Should be used by device drivers to initialize the trap in the 12458c2ecf20Sopenharmony_ci * underlying device. Drivers should also store the provided trap 12468c2ecf20Sopenharmony_ci * context, so that they could efficiently pass it to 12478c2ecf20Sopenharmony_ci * devlink_trap_report() when the trap is triggered. 12488c2ecf20Sopenharmony_ci */ 12498c2ecf20Sopenharmony_ci int (*trap_init)(struct devlink *devlink, 12508c2ecf20Sopenharmony_ci const struct devlink_trap *trap, void *trap_ctx); 12518c2ecf20Sopenharmony_ci /** 12528c2ecf20Sopenharmony_ci * @trap_fini: Trap de-initialization function. 12538c2ecf20Sopenharmony_ci * 12548c2ecf20Sopenharmony_ci * Should be used by device drivers to de-initialize the trap in the 12558c2ecf20Sopenharmony_ci * underlying device. 12568c2ecf20Sopenharmony_ci */ 12578c2ecf20Sopenharmony_ci void (*trap_fini)(struct devlink *devlink, 12588c2ecf20Sopenharmony_ci const struct devlink_trap *trap, void *trap_ctx); 12598c2ecf20Sopenharmony_ci /** 12608c2ecf20Sopenharmony_ci * @trap_action_set: Trap action set function. 12618c2ecf20Sopenharmony_ci */ 12628c2ecf20Sopenharmony_ci int (*trap_action_set)(struct devlink *devlink, 12638c2ecf20Sopenharmony_ci const struct devlink_trap *trap, 12648c2ecf20Sopenharmony_ci enum devlink_trap_action action, 12658c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12668c2ecf20Sopenharmony_ci /** 12678c2ecf20Sopenharmony_ci * @trap_group_init: Trap group initialization function. 12688c2ecf20Sopenharmony_ci * 12698c2ecf20Sopenharmony_ci * Should be used by device drivers to initialize the trap group in the 12708c2ecf20Sopenharmony_ci * underlying device. 12718c2ecf20Sopenharmony_ci */ 12728c2ecf20Sopenharmony_ci int (*trap_group_init)(struct devlink *devlink, 12738c2ecf20Sopenharmony_ci const struct devlink_trap_group *group); 12748c2ecf20Sopenharmony_ci /** 12758c2ecf20Sopenharmony_ci * @trap_group_set: Trap group parameters set function. 12768c2ecf20Sopenharmony_ci * 12778c2ecf20Sopenharmony_ci * Note: @policer can be NULL when a policer is being unbound from 12788c2ecf20Sopenharmony_ci * @group. 12798c2ecf20Sopenharmony_ci */ 12808c2ecf20Sopenharmony_ci int (*trap_group_set)(struct devlink *devlink, 12818c2ecf20Sopenharmony_ci const struct devlink_trap_group *group, 12828c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer, 12838c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12848c2ecf20Sopenharmony_ci /** 12858c2ecf20Sopenharmony_ci * @trap_group_action_set: Trap group action set function. 12868c2ecf20Sopenharmony_ci * 12878c2ecf20Sopenharmony_ci * If this callback is populated, it will take precedence over looping 12888c2ecf20Sopenharmony_ci * over all traps in a group and calling .trap_action_set(). 12898c2ecf20Sopenharmony_ci */ 12908c2ecf20Sopenharmony_ci int (*trap_group_action_set)(struct devlink *devlink, 12918c2ecf20Sopenharmony_ci const struct devlink_trap_group *group, 12928c2ecf20Sopenharmony_ci enum devlink_trap_action action, 12938c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12948c2ecf20Sopenharmony_ci /** 12958c2ecf20Sopenharmony_ci * @trap_policer_init: Trap policer initialization function. 12968c2ecf20Sopenharmony_ci * 12978c2ecf20Sopenharmony_ci * Should be used by device drivers to initialize the trap policer in 12988c2ecf20Sopenharmony_ci * the underlying device. 12998c2ecf20Sopenharmony_ci */ 13008c2ecf20Sopenharmony_ci int (*trap_policer_init)(struct devlink *devlink, 13018c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer); 13028c2ecf20Sopenharmony_ci /** 13038c2ecf20Sopenharmony_ci * @trap_policer_fini: Trap policer de-initialization function. 13048c2ecf20Sopenharmony_ci * 13058c2ecf20Sopenharmony_ci * Should be used by device drivers to de-initialize the trap policer 13068c2ecf20Sopenharmony_ci * in the underlying device. 13078c2ecf20Sopenharmony_ci */ 13088c2ecf20Sopenharmony_ci void (*trap_policer_fini)(struct devlink *devlink, 13098c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer); 13108c2ecf20Sopenharmony_ci /** 13118c2ecf20Sopenharmony_ci * @trap_policer_set: Trap policer parameters set function. 13128c2ecf20Sopenharmony_ci */ 13138c2ecf20Sopenharmony_ci int (*trap_policer_set)(struct devlink *devlink, 13148c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer, 13158c2ecf20Sopenharmony_ci u64 rate, u64 burst, 13168c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 13178c2ecf20Sopenharmony_ci /** 13188c2ecf20Sopenharmony_ci * @trap_policer_counter_get: Trap policer counter get function. 13198c2ecf20Sopenharmony_ci * 13208c2ecf20Sopenharmony_ci * Should be used by device drivers to report number of packets dropped 13218c2ecf20Sopenharmony_ci * by the policer. 13228c2ecf20Sopenharmony_ci */ 13238c2ecf20Sopenharmony_ci int (*trap_policer_counter_get)(struct devlink *devlink, 13248c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer, 13258c2ecf20Sopenharmony_ci u64 *p_drops); 13268c2ecf20Sopenharmony_ci /** 13278c2ecf20Sopenharmony_ci * @port_function_hw_addr_get: Port function's hardware address get function. 13288c2ecf20Sopenharmony_ci * 13298c2ecf20Sopenharmony_ci * Should be used by device drivers to report the hardware address of a function managed 13308c2ecf20Sopenharmony_ci * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port 13318c2ecf20Sopenharmony_ci * function handling for a particular port. 13328c2ecf20Sopenharmony_ci * 13338c2ecf20Sopenharmony_ci * Note: @extack can be NULL when port notifier queries the port function. 13348c2ecf20Sopenharmony_ci */ 13358c2ecf20Sopenharmony_ci int (*port_function_hw_addr_get)(struct devlink *devlink, struct devlink_port *port, 13368c2ecf20Sopenharmony_ci u8 *hw_addr, int *hw_addr_len, 13378c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 13388c2ecf20Sopenharmony_ci /** 13398c2ecf20Sopenharmony_ci * @port_function_hw_addr_set: Port function's hardware address set function. 13408c2ecf20Sopenharmony_ci * 13418c2ecf20Sopenharmony_ci * Should be used by device drivers to set the hardware address of a function managed 13428c2ecf20Sopenharmony_ci * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port 13438c2ecf20Sopenharmony_ci * function handling for a particular port. 13448c2ecf20Sopenharmony_ci */ 13458c2ecf20Sopenharmony_ci int (*port_function_hw_addr_set)(struct devlink *devlink, struct devlink_port *port, 13468c2ecf20Sopenharmony_ci const u8 *hw_addr, int hw_addr_len, 13478c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 13488c2ecf20Sopenharmony_ci}; 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_cistatic inline void *devlink_priv(struct devlink *devlink) 13518c2ecf20Sopenharmony_ci{ 13528c2ecf20Sopenharmony_ci BUG_ON(!devlink); 13538c2ecf20Sopenharmony_ci return &devlink->priv; 13548c2ecf20Sopenharmony_ci} 13558c2ecf20Sopenharmony_ci 13568c2ecf20Sopenharmony_cistatic inline struct devlink *priv_to_devlink(void *priv) 13578c2ecf20Sopenharmony_ci{ 13588c2ecf20Sopenharmony_ci BUG_ON(!priv); 13598c2ecf20Sopenharmony_ci return container_of(priv, struct devlink, priv); 13608c2ecf20Sopenharmony_ci} 13618c2ecf20Sopenharmony_ci 13628c2ecf20Sopenharmony_cistatic inline struct devlink_port * 13638c2ecf20Sopenharmony_cinetdev_to_devlink_port(struct net_device *dev) 13648c2ecf20Sopenharmony_ci{ 13658c2ecf20Sopenharmony_ci if (dev->netdev_ops->ndo_get_devlink_port) 13668c2ecf20Sopenharmony_ci return dev->netdev_ops->ndo_get_devlink_port(dev); 13678c2ecf20Sopenharmony_ci return NULL; 13688c2ecf20Sopenharmony_ci} 13698c2ecf20Sopenharmony_ci 13708c2ecf20Sopenharmony_cistatic inline struct devlink *netdev_to_devlink(struct net_device *dev) 13718c2ecf20Sopenharmony_ci{ 13728c2ecf20Sopenharmony_ci struct devlink_port *devlink_port = netdev_to_devlink_port(dev); 13738c2ecf20Sopenharmony_ci 13748c2ecf20Sopenharmony_ci if (devlink_port) 13758c2ecf20Sopenharmony_ci return devlink_port->devlink; 13768c2ecf20Sopenharmony_ci return NULL; 13778c2ecf20Sopenharmony_ci} 13788c2ecf20Sopenharmony_ci 13798c2ecf20Sopenharmony_cistruct ib_device; 13808c2ecf20Sopenharmony_ci 13818c2ecf20Sopenharmony_cistruct net *devlink_net(const struct devlink *devlink); 13828c2ecf20Sopenharmony_civoid devlink_net_set(struct devlink *devlink, struct net *net); 13838c2ecf20Sopenharmony_cistruct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size); 13848c2ecf20Sopenharmony_ciint devlink_register(struct devlink *devlink, struct device *dev); 13858c2ecf20Sopenharmony_civoid devlink_unregister(struct devlink *devlink); 13868c2ecf20Sopenharmony_civoid devlink_reload_enable(struct devlink *devlink); 13878c2ecf20Sopenharmony_civoid devlink_reload_disable(struct devlink *devlink); 13888c2ecf20Sopenharmony_civoid devlink_free(struct devlink *devlink); 13898c2ecf20Sopenharmony_ciint devlink_port_register(struct devlink *devlink, 13908c2ecf20Sopenharmony_ci struct devlink_port *devlink_port, 13918c2ecf20Sopenharmony_ci unsigned int port_index); 13928c2ecf20Sopenharmony_civoid devlink_port_unregister(struct devlink_port *devlink_port); 13938c2ecf20Sopenharmony_civoid devlink_port_type_eth_set(struct devlink_port *devlink_port, 13948c2ecf20Sopenharmony_ci struct net_device *netdev); 13958c2ecf20Sopenharmony_civoid devlink_port_type_ib_set(struct devlink_port *devlink_port, 13968c2ecf20Sopenharmony_ci struct ib_device *ibdev); 13978c2ecf20Sopenharmony_civoid devlink_port_type_clear(struct devlink_port *devlink_port); 13988c2ecf20Sopenharmony_civoid devlink_port_attrs_set(struct devlink_port *devlink_port, 13998c2ecf20Sopenharmony_ci struct devlink_port_attrs *devlink_port_attrs); 14008c2ecf20Sopenharmony_civoid devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 controller, 14018c2ecf20Sopenharmony_ci u16 pf, bool external); 14028c2ecf20Sopenharmony_civoid devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller, 14038c2ecf20Sopenharmony_ci u16 pf, u16 vf, bool external); 14048c2ecf20Sopenharmony_ciint devlink_sb_register(struct devlink *devlink, unsigned int sb_index, 14058c2ecf20Sopenharmony_ci u32 size, u16 ingress_pools_count, 14068c2ecf20Sopenharmony_ci u16 egress_pools_count, u16 ingress_tc_count, 14078c2ecf20Sopenharmony_ci u16 egress_tc_count); 14088c2ecf20Sopenharmony_civoid devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index); 14098c2ecf20Sopenharmony_ciint devlink_dpipe_table_register(struct devlink *devlink, 14108c2ecf20Sopenharmony_ci const char *table_name, 14118c2ecf20Sopenharmony_ci struct devlink_dpipe_table_ops *table_ops, 14128c2ecf20Sopenharmony_ci void *priv, bool counter_control_extern); 14138c2ecf20Sopenharmony_civoid devlink_dpipe_table_unregister(struct devlink *devlink, 14148c2ecf20Sopenharmony_ci const char *table_name); 14158c2ecf20Sopenharmony_ciint devlink_dpipe_headers_register(struct devlink *devlink, 14168c2ecf20Sopenharmony_ci struct devlink_dpipe_headers *dpipe_headers); 14178c2ecf20Sopenharmony_civoid devlink_dpipe_headers_unregister(struct devlink *devlink); 14188c2ecf20Sopenharmony_cibool devlink_dpipe_table_counter_enabled(struct devlink *devlink, 14198c2ecf20Sopenharmony_ci const char *table_name); 14208c2ecf20Sopenharmony_ciint devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx); 14218c2ecf20Sopenharmony_ciint devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx, 14228c2ecf20Sopenharmony_ci struct devlink_dpipe_entry *entry); 14238c2ecf20Sopenharmony_ciint devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx); 14248c2ecf20Sopenharmony_civoid devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry); 14258c2ecf20Sopenharmony_ciint devlink_dpipe_action_put(struct sk_buff *skb, 14268c2ecf20Sopenharmony_ci struct devlink_dpipe_action *action); 14278c2ecf20Sopenharmony_ciint devlink_dpipe_match_put(struct sk_buff *skb, 14288c2ecf20Sopenharmony_ci struct devlink_dpipe_match *match); 14298c2ecf20Sopenharmony_ciextern struct devlink_dpipe_header devlink_dpipe_header_ethernet; 14308c2ecf20Sopenharmony_ciextern struct devlink_dpipe_header devlink_dpipe_header_ipv4; 14318c2ecf20Sopenharmony_ciextern struct devlink_dpipe_header devlink_dpipe_header_ipv6; 14328c2ecf20Sopenharmony_ci 14338c2ecf20Sopenharmony_ciint devlink_resource_register(struct devlink *devlink, 14348c2ecf20Sopenharmony_ci const char *resource_name, 14358c2ecf20Sopenharmony_ci u64 resource_size, 14368c2ecf20Sopenharmony_ci u64 resource_id, 14378c2ecf20Sopenharmony_ci u64 parent_resource_id, 14388c2ecf20Sopenharmony_ci const struct devlink_resource_size_params *size_params); 14398c2ecf20Sopenharmony_civoid devlink_resources_unregister(struct devlink *devlink, 14408c2ecf20Sopenharmony_ci struct devlink_resource *resource); 14418c2ecf20Sopenharmony_ciint devlink_resource_size_get(struct devlink *devlink, 14428c2ecf20Sopenharmony_ci u64 resource_id, 14438c2ecf20Sopenharmony_ci u64 *p_resource_size); 14448c2ecf20Sopenharmony_ciint devlink_dpipe_table_resource_set(struct devlink *devlink, 14458c2ecf20Sopenharmony_ci const char *table_name, u64 resource_id, 14468c2ecf20Sopenharmony_ci u64 resource_units); 14478c2ecf20Sopenharmony_civoid devlink_resource_occ_get_register(struct devlink *devlink, 14488c2ecf20Sopenharmony_ci u64 resource_id, 14498c2ecf20Sopenharmony_ci devlink_resource_occ_get_t *occ_get, 14508c2ecf20Sopenharmony_ci void *occ_get_priv); 14518c2ecf20Sopenharmony_civoid devlink_resource_occ_get_unregister(struct devlink *devlink, 14528c2ecf20Sopenharmony_ci u64 resource_id); 14538c2ecf20Sopenharmony_ciint devlink_params_register(struct devlink *devlink, 14548c2ecf20Sopenharmony_ci const struct devlink_param *params, 14558c2ecf20Sopenharmony_ci size_t params_count); 14568c2ecf20Sopenharmony_civoid devlink_params_unregister(struct devlink *devlink, 14578c2ecf20Sopenharmony_ci const struct devlink_param *params, 14588c2ecf20Sopenharmony_ci size_t params_count); 14598c2ecf20Sopenharmony_civoid devlink_params_publish(struct devlink *devlink); 14608c2ecf20Sopenharmony_civoid devlink_params_unpublish(struct devlink *devlink); 14618c2ecf20Sopenharmony_ciint devlink_port_params_register(struct devlink_port *devlink_port, 14628c2ecf20Sopenharmony_ci const struct devlink_param *params, 14638c2ecf20Sopenharmony_ci size_t params_count); 14648c2ecf20Sopenharmony_civoid devlink_port_params_unregister(struct devlink_port *devlink_port, 14658c2ecf20Sopenharmony_ci const struct devlink_param *params, 14668c2ecf20Sopenharmony_ci size_t params_count); 14678c2ecf20Sopenharmony_ciint devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id, 14688c2ecf20Sopenharmony_ci union devlink_param_value *init_val); 14698c2ecf20Sopenharmony_ciint devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id, 14708c2ecf20Sopenharmony_ci union devlink_param_value init_val); 14718c2ecf20Sopenharmony_ciint 14728c2ecf20Sopenharmony_cidevlink_port_param_driverinit_value_get(struct devlink_port *devlink_port, 14738c2ecf20Sopenharmony_ci u32 param_id, 14748c2ecf20Sopenharmony_ci union devlink_param_value *init_val); 14758c2ecf20Sopenharmony_ciint devlink_port_param_driverinit_value_set(struct devlink_port *devlink_port, 14768c2ecf20Sopenharmony_ci u32 param_id, 14778c2ecf20Sopenharmony_ci union devlink_param_value init_val); 14788c2ecf20Sopenharmony_civoid devlink_param_value_changed(struct devlink *devlink, u32 param_id); 14798c2ecf20Sopenharmony_civoid devlink_port_param_value_changed(struct devlink_port *devlink_port, 14808c2ecf20Sopenharmony_ci u32 param_id); 14818c2ecf20Sopenharmony_civoid devlink_param_value_str_fill(union devlink_param_value *dst_val, 14828c2ecf20Sopenharmony_ci const char *src); 14838c2ecf20Sopenharmony_cistruct devlink_region * 14848c2ecf20Sopenharmony_cidevlink_region_create(struct devlink *devlink, 14858c2ecf20Sopenharmony_ci const struct devlink_region_ops *ops, 14868c2ecf20Sopenharmony_ci u32 region_max_snapshots, u64 region_size); 14878c2ecf20Sopenharmony_cistruct devlink_region * 14888c2ecf20Sopenharmony_cidevlink_port_region_create(struct devlink_port *port, 14898c2ecf20Sopenharmony_ci const struct devlink_port_region_ops *ops, 14908c2ecf20Sopenharmony_ci u32 region_max_snapshots, u64 region_size); 14918c2ecf20Sopenharmony_civoid devlink_region_destroy(struct devlink_region *region); 14928c2ecf20Sopenharmony_civoid devlink_port_region_destroy(struct devlink_region *region); 14938c2ecf20Sopenharmony_ci 14948c2ecf20Sopenharmony_ciint devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id); 14958c2ecf20Sopenharmony_civoid devlink_region_snapshot_id_put(struct devlink *devlink, u32 id); 14968c2ecf20Sopenharmony_ciint devlink_region_snapshot_create(struct devlink_region *region, 14978c2ecf20Sopenharmony_ci u8 *data, u32 snapshot_id); 14988c2ecf20Sopenharmony_ciint devlink_info_serial_number_put(struct devlink_info_req *req, 14998c2ecf20Sopenharmony_ci const char *sn); 15008c2ecf20Sopenharmony_ciint devlink_info_driver_name_put(struct devlink_info_req *req, 15018c2ecf20Sopenharmony_ci const char *name); 15028c2ecf20Sopenharmony_ciint devlink_info_board_serial_number_put(struct devlink_info_req *req, 15038c2ecf20Sopenharmony_ci const char *bsn); 15048c2ecf20Sopenharmony_ciint devlink_info_version_fixed_put(struct devlink_info_req *req, 15058c2ecf20Sopenharmony_ci const char *version_name, 15068c2ecf20Sopenharmony_ci const char *version_value); 15078c2ecf20Sopenharmony_ciint devlink_info_version_stored_put(struct devlink_info_req *req, 15088c2ecf20Sopenharmony_ci const char *version_name, 15098c2ecf20Sopenharmony_ci const char *version_value); 15108c2ecf20Sopenharmony_ciint devlink_info_version_running_put(struct devlink_info_req *req, 15118c2ecf20Sopenharmony_ci const char *version_name, 15128c2ecf20Sopenharmony_ci const char *version_value); 15138c2ecf20Sopenharmony_ci 15148c2ecf20Sopenharmony_ciint devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg); 15158c2ecf20Sopenharmony_ciint devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg); 15168c2ecf20Sopenharmony_ci 15178c2ecf20Sopenharmony_ciint devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name); 15188c2ecf20Sopenharmony_ciint devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg); 15198c2ecf20Sopenharmony_ci 15208c2ecf20Sopenharmony_ciint devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg, 15218c2ecf20Sopenharmony_ci const char *name); 15228c2ecf20Sopenharmony_ciint devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg); 15238c2ecf20Sopenharmony_ciint devlink_fmsg_binary_pair_nest_start(struct devlink_fmsg *fmsg, 15248c2ecf20Sopenharmony_ci const char *name); 15258c2ecf20Sopenharmony_ciint devlink_fmsg_binary_pair_nest_end(struct devlink_fmsg *fmsg); 15268c2ecf20Sopenharmony_ci 15278c2ecf20Sopenharmony_ciint devlink_fmsg_bool_put(struct devlink_fmsg *fmsg, bool value); 15288c2ecf20Sopenharmony_ciint devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value); 15298c2ecf20Sopenharmony_ciint devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value); 15308c2ecf20Sopenharmony_ciint devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value); 15318c2ecf20Sopenharmony_ciint devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value); 15328c2ecf20Sopenharmony_ciint devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, 15338c2ecf20Sopenharmony_ci u16 value_len); 15348c2ecf20Sopenharmony_ci 15358c2ecf20Sopenharmony_ciint devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, 15368c2ecf20Sopenharmony_ci bool value); 15378c2ecf20Sopenharmony_ciint devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name, 15388c2ecf20Sopenharmony_ci u8 value); 15398c2ecf20Sopenharmony_ciint devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name, 15408c2ecf20Sopenharmony_ci u32 value); 15418c2ecf20Sopenharmony_ciint devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name, 15428c2ecf20Sopenharmony_ci u64 value); 15438c2ecf20Sopenharmony_ciint devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name, 15448c2ecf20Sopenharmony_ci const char *value); 15458c2ecf20Sopenharmony_ciint devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, 15468c2ecf20Sopenharmony_ci const void *value, u32 value_len); 15478c2ecf20Sopenharmony_ci 15488c2ecf20Sopenharmony_cistruct devlink_health_reporter * 15498c2ecf20Sopenharmony_cidevlink_health_reporter_create(struct devlink *devlink, 15508c2ecf20Sopenharmony_ci const struct devlink_health_reporter_ops *ops, 15518c2ecf20Sopenharmony_ci u64 graceful_period, void *priv); 15528c2ecf20Sopenharmony_ci 15538c2ecf20Sopenharmony_cistruct devlink_health_reporter * 15548c2ecf20Sopenharmony_cidevlink_port_health_reporter_create(struct devlink_port *port, 15558c2ecf20Sopenharmony_ci const struct devlink_health_reporter_ops *ops, 15568c2ecf20Sopenharmony_ci u64 graceful_period, void *priv); 15578c2ecf20Sopenharmony_ci 15588c2ecf20Sopenharmony_civoid 15598c2ecf20Sopenharmony_cidevlink_health_reporter_destroy(struct devlink_health_reporter *reporter); 15608c2ecf20Sopenharmony_ci 15618c2ecf20Sopenharmony_civoid 15628c2ecf20Sopenharmony_cidevlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter); 15638c2ecf20Sopenharmony_ci 15648c2ecf20Sopenharmony_civoid * 15658c2ecf20Sopenharmony_cidevlink_health_reporter_priv(struct devlink_health_reporter *reporter); 15668c2ecf20Sopenharmony_ciint devlink_health_report(struct devlink_health_reporter *reporter, 15678c2ecf20Sopenharmony_ci const char *msg, void *priv_ctx); 15688c2ecf20Sopenharmony_civoid 15698c2ecf20Sopenharmony_cidevlink_health_reporter_state_update(struct devlink_health_reporter *reporter, 15708c2ecf20Sopenharmony_ci enum devlink_health_reporter_state state); 15718c2ecf20Sopenharmony_civoid 15728c2ecf20Sopenharmony_cidevlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter); 15738c2ecf20Sopenharmony_ci 15748c2ecf20Sopenharmony_cibool devlink_is_reload_failed(const struct devlink *devlink); 15758c2ecf20Sopenharmony_civoid devlink_remote_reload_actions_performed(struct devlink *devlink, 15768c2ecf20Sopenharmony_ci enum devlink_reload_limit limit, 15778c2ecf20Sopenharmony_ci u32 actions_performed); 15788c2ecf20Sopenharmony_ci 15798c2ecf20Sopenharmony_civoid devlink_flash_update_begin_notify(struct devlink *devlink); 15808c2ecf20Sopenharmony_civoid devlink_flash_update_end_notify(struct devlink *devlink); 15818c2ecf20Sopenharmony_civoid devlink_flash_update_status_notify(struct devlink *devlink, 15828c2ecf20Sopenharmony_ci const char *status_msg, 15838c2ecf20Sopenharmony_ci const char *component, 15848c2ecf20Sopenharmony_ci unsigned long done, 15858c2ecf20Sopenharmony_ci unsigned long total); 15868c2ecf20Sopenharmony_civoid devlink_flash_update_timeout_notify(struct devlink *devlink, 15878c2ecf20Sopenharmony_ci const char *status_msg, 15888c2ecf20Sopenharmony_ci const char *component, 15898c2ecf20Sopenharmony_ci unsigned long timeout); 15908c2ecf20Sopenharmony_ci 15918c2ecf20Sopenharmony_ciint devlink_traps_register(struct devlink *devlink, 15928c2ecf20Sopenharmony_ci const struct devlink_trap *traps, 15938c2ecf20Sopenharmony_ci size_t traps_count, void *priv); 15948c2ecf20Sopenharmony_civoid devlink_traps_unregister(struct devlink *devlink, 15958c2ecf20Sopenharmony_ci const struct devlink_trap *traps, 15968c2ecf20Sopenharmony_ci size_t traps_count); 15978c2ecf20Sopenharmony_civoid devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, 15988c2ecf20Sopenharmony_ci void *trap_ctx, struct devlink_port *in_devlink_port, 15998c2ecf20Sopenharmony_ci const struct flow_action_cookie *fa_cookie); 16008c2ecf20Sopenharmony_civoid *devlink_trap_ctx_priv(void *trap_ctx); 16018c2ecf20Sopenharmony_ciint devlink_trap_groups_register(struct devlink *devlink, 16028c2ecf20Sopenharmony_ci const struct devlink_trap_group *groups, 16038c2ecf20Sopenharmony_ci size_t groups_count); 16048c2ecf20Sopenharmony_civoid devlink_trap_groups_unregister(struct devlink *devlink, 16058c2ecf20Sopenharmony_ci const struct devlink_trap_group *groups, 16068c2ecf20Sopenharmony_ci size_t groups_count); 16078c2ecf20Sopenharmony_ciint 16088c2ecf20Sopenharmony_cidevlink_trap_policers_register(struct devlink *devlink, 16098c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policers, 16108c2ecf20Sopenharmony_ci size_t policers_count); 16118c2ecf20Sopenharmony_civoid 16128c2ecf20Sopenharmony_cidevlink_trap_policers_unregister(struct devlink *devlink, 16138c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policers, 16148c2ecf20Sopenharmony_ci size_t policers_count); 16158c2ecf20Sopenharmony_ci 16168c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_NET_DEVLINK) 16178c2ecf20Sopenharmony_ci 16188c2ecf20Sopenharmony_civoid devlink_compat_running_version(struct net_device *dev, 16198c2ecf20Sopenharmony_ci char *buf, size_t len); 16208c2ecf20Sopenharmony_ciint devlink_compat_flash_update(struct net_device *dev, const char *file_name); 16218c2ecf20Sopenharmony_ciint devlink_compat_phys_port_name_get(struct net_device *dev, 16228c2ecf20Sopenharmony_ci char *name, size_t len); 16238c2ecf20Sopenharmony_ciint devlink_compat_switch_id_get(struct net_device *dev, 16248c2ecf20Sopenharmony_ci struct netdev_phys_item_id *ppid); 16258c2ecf20Sopenharmony_ci 16268c2ecf20Sopenharmony_ci#else 16278c2ecf20Sopenharmony_ci 16288c2ecf20Sopenharmony_cistatic inline void 16298c2ecf20Sopenharmony_cidevlink_compat_running_version(struct net_device *dev, char *buf, size_t len) 16308c2ecf20Sopenharmony_ci{ 16318c2ecf20Sopenharmony_ci} 16328c2ecf20Sopenharmony_ci 16338c2ecf20Sopenharmony_cistatic inline int 16348c2ecf20Sopenharmony_cidevlink_compat_flash_update(struct net_device *dev, const char *file_name) 16358c2ecf20Sopenharmony_ci{ 16368c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 16378c2ecf20Sopenharmony_ci} 16388c2ecf20Sopenharmony_ci 16398c2ecf20Sopenharmony_cistatic inline int 16408c2ecf20Sopenharmony_cidevlink_compat_phys_port_name_get(struct net_device *dev, 16418c2ecf20Sopenharmony_ci char *name, size_t len) 16428c2ecf20Sopenharmony_ci{ 16438c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 16448c2ecf20Sopenharmony_ci} 16458c2ecf20Sopenharmony_ci 16468c2ecf20Sopenharmony_cistatic inline int 16478c2ecf20Sopenharmony_cidevlink_compat_switch_id_get(struct net_device *dev, 16488c2ecf20Sopenharmony_ci struct netdev_phys_item_id *ppid) 16498c2ecf20Sopenharmony_ci{ 16508c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 16518c2ecf20Sopenharmony_ci} 16528c2ecf20Sopenharmony_ci 16538c2ecf20Sopenharmony_ci#endif 16548c2ecf20Sopenharmony_ci 16558c2ecf20Sopenharmony_ci#endif /* _NET_DEVLINK_H_ */ 1656