Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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