linux/include/net/devlink.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * include/net/devlink.h - Network physical device Netlink interface
 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2016 Jiri Pirko <[email protected]>
 */
#ifndef _NET_DEVLINK_H_
#define _NET_DEVLINK_H_

#include <linux/device.h>
#include <linux/slab.h>
#include <linux/gfp.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/refcount.h>
#include <net/net_namespace.h>
#include <net/flow_offload.h>
#include <uapi/linux/devlink.h>
#include <linux/xarray.h>
#include <linux/firmware.h>

struct devlink;
struct devlink_linecard;

struct devlink_port_phys_attrs {};

/**
 * struct devlink_port_pci_pf_attrs - devlink port's PCI PF attributes
 * @controller: Associated controller number
 * @pf: Associated PCI PF number for this port.
 * @external: when set, indicates if a port is for an external controller
 */
struct devlink_port_pci_pf_attrs {};

/**
 * struct devlink_port_pci_vf_attrs - devlink port's PCI VF attributes
 * @controller: Associated controller number
 * @pf: Associated PCI PF number for this port.
 * @vf: Associated PCI VF for of the PCI PF for this port.
 * @external: when set, indicates if a port is for an external controller
 */
struct devlink_port_pci_vf_attrs {};

/**
 * struct devlink_port_pci_sf_attrs - devlink port's PCI SF attributes
 * @controller: Associated controller number
 * @sf: Associated PCI SF for of the PCI PF for this port.
 * @pf: Associated PCI PF number for this port.
 * @external: when set, indicates if a port is for an external controller
 */
struct devlink_port_pci_sf_attrs {};

/**
 * struct devlink_port_attrs - devlink port object
 * @flavour: flavour of the port
 * @split: indicates if this is split port
 * @splittable: indicates if the port can be split.
 * @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink.
 * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
 * @phys: physical port attributes
 * @pci_pf: PCI PF port attributes
 * @pci_vf: PCI VF port attributes
 * @pci_sf: PCI SF port attributes
 */
struct devlink_port_attrs {};

struct devlink_rate {};

struct devlink_port {};

struct devlink_port_new_attrs {};

/**
 * struct devlink_linecard_ops - Linecard operations
 * @provision: callback to provision the linecard slot with certain
 *	       type of linecard. As a result of this operation,
 *	       driver is expected to eventually (could be after
 *	       the function call returns) call one of:
 *	       devlink_linecard_provision_set()
 *	       devlink_linecard_provision_fail()
 * @unprovision: callback to unprovision the linecard slot. As a result
 *		 of this operation, driver is expected to eventually
 *		 (could be after the function call returns) call
 *	         devlink_linecard_provision_clear()
 *	         devlink_linecard_provision_fail()
 * @same_provision: callback to ask the driver if linecard is already
 *                  provisioned in the same way user asks this linecard to be
 *                  provisioned.
 * @types_count: callback to get number of supported types
 * @types_get: callback to get next type in list
 */
struct devlink_linecard_ops {};

struct devlink_sb_pool_info {};

/**
 * struct devlink_dpipe_field - dpipe field object
 * @name: field name
 * @id: index inside the headers field array
 * @bitwidth: bitwidth
 * @mapping_type: mapping type
 */
struct devlink_dpipe_field {};

/**
 * struct devlink_dpipe_header - dpipe header object
 * @name: header name
 * @id: index, global/local determined by global bit
 * @fields: fields
 * @fields_count: number of fields
 * @global: indicates if header is shared like most protocol header
 *	    or driver specific
 */
struct devlink_dpipe_header {};

/**
 * struct devlink_dpipe_match - represents match operation
 * @type: type of match
 * @header_index: header index (packets can have several headers of same
 *		  type like in case of tunnels)
 * @header: header
 * @field_id: field index
 */
struct devlink_dpipe_match {};

/**
 * struct devlink_dpipe_action - represents action operation
 * @type: type of action
 * @header_index: header index (packets can have several headers of same
 *		  type like in case of tunnels)
 * @header: header
 * @field_id: field index
 */
struct devlink_dpipe_action {};

/**
 * struct devlink_dpipe_value - represents value of match/action
 * @action: action
 * @match: match
 * @mapping_value: in case the field has some mapping this value
 *                 specified the mapping value
 * @mapping_valid: specify if mapping value is valid
 * @value_size: value size
 * @value: value
 * @mask: bit mask
 */
struct devlink_dpipe_value {};

/**
 * struct devlink_dpipe_entry - table entry object
 * @index: index of the entry in the table
 * @match_values: match values
 * @match_values_count: count of matches tuples
 * @action_values: actions values
 * @action_values_count: count of actions values
 * @counter: value of counter
 * @counter_valid: Specify if value is valid from hardware
 */
struct devlink_dpipe_entry {};

/**
 * struct devlink_dpipe_dump_ctx - context provided to driver in order
 *				   to dump
 * @info: info
 * @cmd: devlink command
 * @skb: skb
 * @nest: top attribute
 * @hdr: hdr
 */
struct devlink_dpipe_dump_ctx {};

struct devlink_dpipe_table_ops;

/**
 * struct devlink_dpipe_table - table object
 * @priv: private
 * @name: table name
 * @counters_enabled: indicates if counters are active
 * @counter_control_extern: indicates if counter control is in dpipe or
 *			    external tool
 * @resource_valid: Indicate that the resource id is valid
 * @resource_id: relative resource this table is related to
 * @resource_units: number of resource's unit consumed per table's entry
 * @table_ops: table operations
 * @rcu: rcu
 */
struct devlink_dpipe_table {};

/**
 * struct devlink_dpipe_table_ops - dpipe_table ops
 * @actions_dump: dumps all tables actions
 * @matches_dump: dumps all tables matches
 * @entries_dump: dumps all active entries in the table
 * @counters_set_update:  when changing the counter status hardware sync
 *			  maybe needed to allocate/free counter related
 *			  resources
 * @size_get: get size
 */
struct devlink_dpipe_table_ops {};

/**
 * struct devlink_dpipe_headers - dpipe headers
 * @headers: header array can be shared (global bit) or driver specific
 * @headers_count: count of headers
 */
struct devlink_dpipe_headers {};

/**
 * struct devlink_resource_size_params - resource's size parameters
 * @size_min: minimum size which can be set
 * @size_max: maximum size which can be set
 * @size_granularity: size granularity
 * @unit: resource's basic unit
 */
struct devlink_resource_size_params {};

static inline void
devlink_resource_size_params_init(struct devlink_resource_size_params *size_params,
				  u64 size_min, u64 size_max,
				  u64 size_granularity,
				  enum devlink_resource_unit unit)
{}

devlink_resource_occ_get_t;

#define DEVLINK_RESOURCE_ID_PARENT_TOP

#define DEVLINK_RESOURCE_GENERIC_NAME_PORTS

#define __DEVLINK_PARAM_MAX_STRING_VALUE
enum devlink_param_type {};

devlink_param_value;

struct devlink_param_gset_ctx {};

/**
 * struct devlink_flash_notify - devlink dev flash notify data
 * @status_msg: current status string
 * @component: firmware component being updated
 * @done: amount of work completed of total amount
 * @total: amount of work expected to be done
 * @timeout: expected max timeout in seconds
 *
 * These are values to be given to userland to be displayed in order
 * to show current activity in a firmware update process.
 */
struct devlink_flash_notify {};

/**
 * struct devlink_param - devlink configuration parameter data
 * @id: devlink parameter id number
 * @name: name of the parameter
 * @generic: indicates if the parameter is generic or driver specific
 * @type: parameter type
 * @supported_cmodes: bitmap of supported configuration modes
 * @get: get parameter value, used for runtime and permanent
 *       configuration modes
 * @set: set parameter value, used for runtime and permanent
 *       configuration modes
 * @validate: validate input value is applicable (within value range, etc.)
 *
 * This struct should be used by the driver to fill the data for
 * a parameter it registers.
 */
struct devlink_param {};

struct devlink_param_item {};

enum devlink_param_generic_id {};

#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_NAME
#define DEVLINK_PARAM_GENERIC_INT_ERR_RESET_TYPE

#define DEVLINK_PARAM_GENERIC_MAX_MACS_NAME
#define DEVLINK_PARAM_GENERIC_MAX_MACS_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_SRIOV_TYPE

#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME
#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE

#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME
#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE

#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME
#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE

#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME
#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE

#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_NAME
#define DEVLINK_PARAM_GENERIC_FW_LOAD_POLICY_TYPE

#define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_NAME
#define DEVLINK_PARAM_GENERIC_RESET_DEV_ON_DRV_PROBE_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_ETH_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_ETH_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_RDMA_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_RDMA_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_VNET_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_VNET_TYPE

#define DEVLINK_PARAM_GENERIC_ENABLE_IWARP_NAME
#define DEVLINK_PARAM_GENERIC_ENABLE_IWARP_TYPE

#define DEVLINK_PARAM_GENERIC_IO_EQ_SIZE_NAME
#define DEVLINK_PARAM_GENERIC_IO_EQ_SIZE_TYPE

#define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME
#define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE

#define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate)

#define DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, _get, _set, _validate)

/* Identifier of board design */
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID
/* Revision of board design */
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV
/* Maker of the board */
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE
/* Part number of the board and its components */
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_PART_NUMBER

/* Part number, identifier of asic design */
#define DEVLINK_INFO_VERSION_GENERIC_ASIC_ID
/* Revision of asic design */
#define DEVLINK_INFO_VERSION_GENERIC_ASIC_REV

/* Overall FW version */
#define DEVLINK_INFO_VERSION_GENERIC_FW
/* Control processor FW version */
#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT
/* FW interface specification version */
#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API
/* Data path microcode controlling high-speed packet processing */
#define DEVLINK_INFO_VERSION_GENERIC_FW_APP
/* UNDI software version */
#define DEVLINK_INFO_VERSION_GENERIC_FW_UNDI
/* NCSI support/handler version */
#define DEVLINK_INFO_VERSION_GENERIC_FW_NCSI
/* FW parameter set id */
#define DEVLINK_INFO_VERSION_GENERIC_FW_PSID
/* RoCE FW version */
#define DEVLINK_INFO_VERSION_GENERIC_FW_ROCE
/* Firmware bundle identifier */
#define DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID
/* Bootloader */
#define DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER

/**
 * struct devlink_flash_update_params - Flash Update parameters
 * @fw: pointer to the firmware data to update from
 * @component: the flash component to update
 * @overwrite_mask: which types of flash update are supported (may be %0)
 *
 * With the exception of fw, drivers must opt-in to parameters by
 * setting the appropriate bit in the supported_flash_update_params field in
 * their devlink_ops structure.
 */
struct devlink_flash_update_params {};

#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK

struct devlink_region;
struct devlink_info_req;

/**
 * struct devlink_region_ops - Region operations
 * @name: region name
 * @destructor: callback used to free snapshot memory when deleting
 * @snapshot: callback to request an immediate snapshot. On success,
 *            the data variable must be updated to point to the snapshot data.
 *            The function will be called while the devlink instance lock is
 *            held.
 * @read: callback to directly read a portion of the region. On success,
 *        the data pointer will be updated with the contents of the
 *        requested portion of the region. The function will be called
 *        while the devlink instance lock is held.
 * @priv: Pointer to driver private data for the region operation
 */
struct devlink_region_ops {};

/**
 * struct devlink_port_region_ops - Region operations for a port
 * @name: region name
 * @destructor: callback used to free snapshot memory when deleting
 * @snapshot: callback to request an immediate snapshot. On success,
 *            the data variable must be updated to point to the snapshot data.
 *            The function will be called while the devlink instance lock is
 *            held.
 * @read: callback to directly read a portion of the region. On success,
 *        the data pointer will be updated with the contents of the
 *        requested portion of the region. The function will be called
 *        while the devlink instance lock is held.
 * @priv: Pointer to driver private data for the region operation
 */
struct devlink_port_region_ops {};

struct devlink_fmsg;
struct devlink_health_reporter;

enum devlink_health_reporter_state {};

/**
 * struct devlink_health_reporter_ops - Reporter operations
 * @name: reporter name
 * @recover: callback to recover from reported error
 *           if priv_ctx is NULL, run a full recover
 * @dump: callback to dump an object
 *        if priv_ctx is NULL, run a full dump
 * @diagnose: callback to diagnose the current status
 * @test: callback to trigger a test event
 */

struct devlink_health_reporter_ops {};

/**
 * struct devlink_trap_metadata - Packet trap metadata.
 * @trap_name: Trap name.
 * @trap_group_name: Trap group name.
 * @input_dev: Input netdevice.
 * @dev_tracker: refcount tracker for @input_dev.
 * @fa_cookie: Flow action user cookie.
 * @trap_type: Trap type.
 */
struct devlink_trap_metadata {};

/**
 * struct devlink_trap_policer - Immutable packet trap policer attributes.
 * @id: Policer identifier.
 * @init_rate: Initial rate in packets / sec.
 * @init_burst: Initial burst size in packets.
 * @max_rate: Maximum rate.
 * @min_rate: Minimum rate.
 * @max_burst: Maximum burst size.
 * @min_burst: Minimum burst size.
 *
 * Describes immutable attributes of packet trap policers that drivers register
 * with devlink.
 */
struct devlink_trap_policer {};

/**
 * struct devlink_trap_group - Immutable packet trap group attributes.
 * @name: Trap group name.
 * @id: Trap group identifier.
 * @generic: Whether the trap group is generic or not.
 * @init_policer_id: Initial policer identifier.
 *
 * Describes immutable attributes of packet trap groups that drivers register
 * with devlink.
 */
struct devlink_trap_group {};

#define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT
#define DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE

/**
 * struct devlink_trap - Immutable packet trap attributes.
 * @type: Trap type.
 * @init_action: Initial trap action.
 * @generic: Whether the trap is generic or not.
 * @id: Trap identifier.
 * @name: Trap name.
 * @init_group_id: Initial group identifier.
 * @metadata_cap: Metadata types that can be provided by the trap.
 *
 * Describes immutable attributes of packet traps that drivers register with
 * devlink.
 */
struct devlink_trap {};

/* All traps must be documented in
 * Documentation/networking/devlink/devlink-trap.rst
 */
enum devlink_trap_generic_id {};

/* All trap groups must be documented in
 * Documentation/networking/devlink/devlink-trap.rst
 */
enum devlink_trap_group_generic_id {};

#define DEVLINK_TRAP_GENERIC_NAME_SMAC_MC
#define DEVLINK_TRAP_GENERIC_NAME_VLAN_TAG_MISMATCH
#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_VLAN_FILTER
#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_STP_FILTER
#define DEVLINK_TRAP_GENERIC_NAME_EMPTY_TX_LIST
#define DEVLINK_TRAP_GENERIC_NAME_PORT_LOOPBACK_FILTER
#define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_ROUTE
#define DEVLINK_TRAP_GENERIC_NAME_TTL_ERROR
#define DEVLINK_TRAP_GENERIC_NAME_TAIL_DROP
#define DEVLINK_TRAP_GENERIC_NAME_NON_IP_PACKET
#define DEVLINK_TRAP_GENERIC_NAME_UC_DIP_MC_DMAC
#define DEVLINK_TRAP_GENERIC_NAME_DIP_LB
#define DEVLINK_TRAP_GENERIC_NAME_SIP_MC
#define DEVLINK_TRAP_GENERIC_NAME_SIP_LB
#define DEVLINK_TRAP_GENERIC_NAME_CORRUPTED_IP_HDR
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_SIP_BC
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_RESERVED_SCOPE
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_MC_DIP_INTERFACE_LOCAL_SCOPE
#define DEVLINK_TRAP_GENERIC_NAME_MTU_ERROR
#define DEVLINK_TRAP_GENERIC_NAME_UNRESOLVED_NEIGH
#define DEVLINK_TRAP_GENERIC_NAME_RPF
#define DEVLINK_TRAP_GENERIC_NAME_REJECT_ROUTE
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_LPM_UNICAST_MISS
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_LPM_UNICAST_MISS
#define DEVLINK_TRAP_GENERIC_NAME_NON_ROUTABLE
#define DEVLINK_TRAP_GENERIC_NAME_DECAP_ERROR
#define DEVLINK_TRAP_GENERIC_NAME_OVERLAY_SMAC_MC
#define DEVLINK_TRAP_GENERIC_NAME_INGRESS_FLOW_ACTION_DROP
#define DEVLINK_TRAP_GENERIC_NAME_EGRESS_FLOW_ACTION_DROP
#define DEVLINK_TRAP_GENERIC_NAME_STP
#define DEVLINK_TRAP_GENERIC_NAME_LACP
#define DEVLINK_TRAP_GENERIC_NAME_LLDP
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_QUERY
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V1_REPORT
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_REPORT
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V3_REPORT
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_LEAVE
#define DEVLINK_TRAP_GENERIC_NAME_MLD_QUERY
#define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_REPORT
#define DEVLINK_TRAP_GENERIC_NAME_MLD_V2_REPORT
#define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_DONE
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_DHCP
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DHCP
#define DEVLINK_TRAP_GENERIC_NAME_ARP_REQUEST
#define DEVLINK_TRAP_GENERIC_NAME_ARP_RESPONSE
#define DEVLINK_TRAP_GENERIC_NAME_ARP_OVERLAY
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_SOLICIT
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_ADVERT
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_BFD
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_BFD
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_OSPF
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_OSPF
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_BGP
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_BGP
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_VRRP
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_VRRP
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_PIM
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_PIM
#define DEVLINK_TRAP_GENERIC_NAME_UC_LB
#define DEVLINK_TRAP_GENERIC_NAME_LOCAL_ROUTE
#define DEVLINK_TRAP_GENERIC_NAME_EXTERNAL_ROUTE
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_UC_DIP_LINK_LOCAL_SCOPE
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_NODES
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_ROUTERS
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_SOLICIT
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ADVERT
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_REDIRECT
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_ROUTER_ALERT
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ALERT
#define DEVLINK_TRAP_GENERIC_NAME_PTP_EVENT
#define DEVLINK_TRAP_GENERIC_NAME_PTP_GENERAL
#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_SAMPLE
#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP
#define DEVLINK_TRAP_GENERIC_NAME_EARLY_DROP
#define DEVLINK_TRAP_GENERIC_NAME_VXLAN_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_LLC_SNAP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_VLAN_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_PPPOE_PPP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_MPLS_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_ARP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_IP_1_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_IP_N_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_GRE_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_UDP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_TCP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_IPSEC_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_SCTP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_DCCP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_GTP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_ESP_PARSING
#define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_NEXTHOP
#define DEVLINK_TRAP_GENERIC_NAME_DMAC_FILTER
#define DEVLINK_TRAP_GENERIC_NAME_EAPOL
#define DEVLINK_TRAP_GENERIC_NAME_LOCKED_PORT

#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_EXCEPTIONS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_TUNNEL_DROPS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_DROPS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_STP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LACP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LLDP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_MC_SNOOPING
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_DHCP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_NEIGH_DISCOVERY
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BFD
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_OSPF
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BGP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_VRRP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PIM
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_UC_LB
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LOCAL_DELIVERY
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_EXTERNAL_DELIVERY
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_IPV6
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_EVENT
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_GENERAL
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_SAMPLE
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_TRAP
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PARSER_ERROR_DROPS
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_EAPOL

#define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id,	      \
			     _metadata_cap)

#define DEVLINK_TRAP_DRIVER(_type, _init_action, _id, _name, _group_id,	      \
			    _metadata_cap)

#define DEVLINK_TRAP_GROUP_GENERIC(_id, _policer_id)

#define DEVLINK_TRAP_POLICER(_id, _rate, _burst, _max_rate, _min_rate,	      \
			     _max_burst, _min_burst)

enum {};

struct devlink_ops {};

void *devlink_priv(struct devlink *devlink);
struct devlink *priv_to_devlink(void *priv);
struct device *devlink_to_dev(const struct devlink *devlink);

/* Devlink instance explicit locking */
void devl_lock(struct devlink *devlink);
int devl_trylock(struct devlink *devlink);
void devl_unlock(struct devlink *devlink);
void devl_assert_locked(struct devlink *devlink);
bool devl_lock_is_held(struct devlink *devlink);

struct ib_device;

struct net *devlink_net(const struct devlink *devlink);
/* This call is intended for software devices that can create
 * devlink instances in other namespaces than init_net.
 *
 * Drivers that operate on real HW must use devlink_alloc() instead.
 */
struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
				 size_t priv_size, struct net *net,
				 struct device *dev);
static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
					    size_t priv_size,
					    struct device *dev)
{}

int devl_register(struct devlink *devlink);
void devl_unregister(struct devlink *devlink);
void devlink_register(struct devlink *devlink);
void devlink_unregister(struct devlink *devlink);
void devlink_free(struct devlink *devlink);

/**
 * struct devlink_port_ops - Port operations
 * @port_split: Callback used to split the port into multiple ones.
 * @port_unsplit: Callback used to unsplit the port group back into
 *		  a single port.
 * @port_type_set: Callback used to set a type of a port.
 * @port_del: Callback used to delete selected port along with related function.
 *	      Devlink core calls this upon user request to delete
 *	      a port previously created by devlink_ops->port_new().
 * @port_fn_hw_addr_get: Callback used to set port function's hardware address.
 *			 Should be used by device drivers to report
 *			 the hardware address of a function managed
 *			 by the devlink port.
 * @port_fn_hw_addr_set: Callback used to set port function's hardware address.
 *			 Should be used by device drivers to set the hardware
 *			 address of a function managed by the devlink port.
 * @port_fn_roce_get: Callback used to get port function's RoCE capability.
 *		      Should be used by device drivers to report
 *		      the current state of RoCE capability of a function
 *		      managed by the devlink port.
 * @port_fn_roce_set: Callback used to set port function's RoCE capability.
 *		      Should be used by device drivers to enable/disable
 *		      RoCE capability of a function managed
 *		      by the devlink port.
 * @port_fn_migratable_get: Callback used to get port function's migratable
 *			    capability. Should be used by device drivers
 *			    to report the current state of migratable capability
 *			    of a function managed by the devlink port.
 * @port_fn_migratable_set: Callback used to set port function's migratable
 *			    capability. Should be used by device drivers
 *			    to enable/disable migratable capability of
 *			    a function managed by the devlink port.
 * @port_fn_state_get: Callback used to get port function's state.
 *		       Should be used by device drivers to report
 *		       the current admin and operational state of a
 *		       function managed by the devlink port.
 * @port_fn_state_set: Callback used to get port function's state.
 *		       Should be used by device drivers set
 *		       the admin state of a function managed
 *		       by the devlink port.
 * @port_fn_ipsec_crypto_get: Callback used to get port function's ipsec_crypto
 *			      capability. Should be used by device drivers
 *			      to report the current state of ipsec_crypto
 *			      capability of a function managed by the devlink
 *			      port.
 * @port_fn_ipsec_crypto_set: Callback used to set port function's ipsec_crypto
 *			      capability. Should be used by device drivers to
 *			      enable/disable ipsec_crypto capability of a
 *			      function managed by the devlink port.
 * @port_fn_ipsec_packet_get: Callback used to get port function's ipsec_packet
 *			      capability. Should be used by device drivers
 *			      to report the current state of ipsec_packet
 *			      capability of a function managed by the devlink
 *			      port.
 * @port_fn_ipsec_packet_set: Callback used to set port function's ipsec_packet
 *			      capability. Should be used by device drivers to
 *			      enable/disable ipsec_packet capability of a
 *			      function managed by the devlink port.
 * @port_fn_max_io_eqs_get: Callback used to get port function's maximum number
 *			    of event queues. Should be used by device drivers to
 *			    report the maximum event queues of a function
 *			    managed by the devlink port.
 * @port_fn_max_io_eqs_set: Callback used to set port function's maximum number
 *			    of event queues. Should be used by device drivers to
 *			    configure maximum number of event queues
 *			    of a function managed by the devlink port.
 *
 * Note: Driver should return -EOPNOTSUPP if it doesn't support
 * port function (@port_fn_*) handling for a particular port.
 */
struct devlink_port_ops {};

void devlink_port_init(struct devlink *devlink,
		       struct devlink_port *devlink_port);
void devlink_port_fini(struct devlink_port *devlink_port);

int devl_port_register_with_ops(struct devlink *devlink,
				struct devlink_port *devlink_port,
				unsigned int port_index,
				const struct devlink_port_ops *ops);

static inline int devl_port_register(struct devlink *devlink,
				     struct devlink_port *devlink_port,
				     unsigned int port_index)
{}

int devlink_port_register_with_ops(struct devlink *devlink,
				   struct devlink_port *devlink_port,
				   unsigned int port_index,
				   const struct devlink_port_ops *ops);

static inline int devlink_port_register(struct devlink *devlink,
					struct devlink_port *devlink_port,
					unsigned int port_index)
{}

void devl_port_unregister(struct devlink_port *devlink_port);
void devlink_port_unregister(struct devlink_port *devlink_port);
void devlink_port_type_eth_set(struct devlink_port *devlink_port);
void devlink_port_type_ib_set(struct devlink_port *devlink_port,
			      struct ib_device *ibdev);
void devlink_port_type_clear(struct devlink_port *devlink_port);
void devlink_port_attrs_set(struct devlink_port *devlink_port,
			    struct devlink_port_attrs *devlink_port_attrs);
void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 controller,
				   u16 pf, bool external);
void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller,
				   u16 pf, u16 vf, bool external);
void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port,
				   u32 controller, u16 pf, u32 sf,
				   bool external);
int devl_port_fn_devlink_set(struct devlink_port *devlink_port,
			     struct devlink *fn_devlink);
struct devlink_rate *
devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name,
		      struct devlink_rate *parent);
int
devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv,
		      struct devlink_rate *parent);
void devl_rate_leaf_destroy(struct devlink_port *devlink_port);
void devl_rate_nodes_destroy(struct devlink *devlink);
void devlink_port_linecard_set(struct devlink_port *devlink_port,
			       struct devlink_linecard *linecard);
struct devlink_linecard *
devl_linecard_create(struct devlink *devlink, unsigned int linecard_index,
		     const struct devlink_linecard_ops *ops, void *priv);
void devl_linecard_destroy(struct devlink_linecard *linecard);
void devlink_linecard_provision_set(struct devlink_linecard *linecard,
				    const char *type);
void devlink_linecard_provision_clear(struct devlink_linecard *linecard);
void devlink_linecard_provision_fail(struct devlink_linecard *linecard);
void devlink_linecard_activate(struct devlink_linecard *linecard);
void devlink_linecard_deactivate(struct devlink_linecard *linecard);
int devlink_linecard_nested_dl_set(struct devlink_linecard *linecard,
				   struct devlink *nested_devlink);
int devl_sb_register(struct devlink *devlink, unsigned int sb_index,
		     u32 size, u16 ingress_pools_count,
		     u16 egress_pools_count, u16 ingress_tc_count,
		     u16 egress_tc_count);
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
			u32 size, u16 ingress_pools_count,
			u16 egress_pools_count, u16 ingress_tc_count,
			u16 egress_tc_count);
void devl_sb_unregister(struct devlink *devlink, unsigned int sb_index);
void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
int devl_dpipe_table_register(struct devlink *devlink,
			      const char *table_name,
			      const struct devlink_dpipe_table_ops *table_ops,
			      void *priv, bool counter_control_extern);
void devl_dpipe_table_unregister(struct devlink *devlink,
				 const char *table_name);
void devl_dpipe_headers_register(struct devlink *devlink,
				 struct devlink_dpipe_headers *dpipe_headers);
void devl_dpipe_headers_unregister(struct devlink *devlink);
bool devlink_dpipe_table_counter_enabled(struct devlink *devlink,
					 const char *table_name);
int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
				   struct devlink_dpipe_entry *entry);
int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
int devlink_dpipe_action_put(struct sk_buff *skb,
			     struct devlink_dpipe_action *action);
int devlink_dpipe_match_put(struct sk_buff *skb,
			    struct devlink_dpipe_match *match);
extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
extern struct devlink_dpipe_header devlink_dpipe_header_ipv6;

int devl_resource_register(struct devlink *devlink,
			   const char *resource_name,
			   u64 resource_size,
			   u64 resource_id,
			   u64 parent_resource_id,
			   const struct devlink_resource_size_params *size_params);
int devlink_resource_register(struct devlink *devlink,
			      const char *resource_name,
			      u64 resource_size,
			      u64 resource_id,
			      u64 parent_resource_id,
			      const struct devlink_resource_size_params *size_params);
void devl_resources_unregister(struct devlink *devlink);
void devlink_resources_unregister(struct devlink *devlink);
int devl_resource_size_get(struct devlink *devlink,
			   u64 resource_id,
			   u64 *p_resource_size);
int devl_dpipe_table_resource_set(struct devlink *devlink,
				  const char *table_name, u64 resource_id,
				  u64 resource_units);
void devl_resource_occ_get_register(struct devlink *devlink,
				    u64 resource_id,
				    devlink_resource_occ_get_t *occ_get,
				    void *occ_get_priv);
void devlink_resource_occ_get_register(struct devlink *devlink,
				       u64 resource_id,
				       devlink_resource_occ_get_t *occ_get,
				       void *occ_get_priv);
void devl_resource_occ_get_unregister(struct devlink *devlink,
				      u64 resource_id);

void devlink_resource_occ_get_unregister(struct devlink *devlink,
					 u64 resource_id);
int devl_params_register(struct devlink *devlink,
			 const struct devlink_param *params,
			 size_t params_count);
int devlink_params_register(struct devlink *devlink,
			    const struct devlink_param *params,
			    size_t params_count);
void devl_params_unregister(struct devlink *devlink,
			    const struct devlink_param *params,
			    size_t params_count);
void devlink_params_unregister(struct devlink *devlink,
			       const struct devlink_param *params,
			       size_t params_count);
int devl_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
				    union devlink_param_value *val);
void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
				     union devlink_param_value init_val);
void devl_param_value_changed(struct devlink *devlink, u32 param_id);
struct devlink_region *devl_region_create(struct devlink *devlink,
					  const struct devlink_region_ops *ops,
					  u32 region_max_snapshots,
					  u64 region_size);
struct devlink_region *
devlink_region_create(struct devlink *devlink,
		      const struct devlink_region_ops *ops,
		      u32 region_max_snapshots, u64 region_size);
struct devlink_region *
devlink_port_region_create(struct devlink_port *port,
			   const struct devlink_port_region_ops *ops,
			   u32 region_max_snapshots, u64 region_size);
void devl_region_destroy(struct devlink_region *region);
void devlink_region_destroy(struct devlink_region *region);
int devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id);
void devlink_region_snapshot_id_put(struct devlink *devlink, u32 id);
int devlink_region_snapshot_create(struct devlink_region *region,
				   u8 *data, u32 snapshot_id);
int devlink_info_serial_number_put(struct devlink_info_req *req,
				   const char *sn);
int devlink_info_board_serial_number_put(struct devlink_info_req *req,
					 const char *bsn);

enum devlink_info_version_type {};

int devlink_info_version_fixed_put(struct devlink_info_req *req,
				   const char *version_name,
				   const char *version_value);
int devlink_info_version_stored_put(struct devlink_info_req *req,
				    const char *version_name,
				    const char *version_value);
int devlink_info_version_stored_put_ext(struct devlink_info_req *req,
					const char *version_name,
					const char *version_value,
					enum devlink_info_version_type version_type);
int devlink_info_version_running_put(struct devlink_info_req *req,
				     const char *version_name,
				     const char *version_value);
int devlink_info_version_running_put_ext(struct devlink_info_req *req,
					 const char *version_name,
					 const char *version_value,
					 enum devlink_info_version_type version_type);

void devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
void devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);

void devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
void devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);

void devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
				      const char *name);
void devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
void devlink_fmsg_binary_pair_nest_start(struct devlink_fmsg *fmsg,
					 const char *name);
void devlink_fmsg_binary_pair_nest_end(struct devlink_fmsg *fmsg);

void devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
void devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
void devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
			     u16 value_len);

void devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
				bool value);
void devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
			      u8 value);
void devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
			       u32 value);
void devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
			       u64 value);
void devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
				  const char *value);
void devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
				  const void *value, u32 value_len);

struct devlink_health_reporter *
devl_port_health_reporter_create(struct devlink_port *port,
				 const struct devlink_health_reporter_ops *ops,
				 u64 graceful_period, void *priv);

struct devlink_health_reporter *
devlink_port_health_reporter_create(struct devlink_port *port,
				    const struct devlink_health_reporter_ops *ops,
				    u64 graceful_period, void *priv);

struct devlink_health_reporter *
devl_health_reporter_create(struct devlink *devlink,
			    const struct devlink_health_reporter_ops *ops,
			    u64 graceful_period, void *priv);

struct devlink_health_reporter *
devlink_health_reporter_create(struct devlink *devlink,
			       const struct devlink_health_reporter_ops *ops,
			       u64 graceful_period, void *priv);

void
devl_health_reporter_destroy(struct devlink_health_reporter *reporter);

void
devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);

void *
devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
int devlink_health_report(struct devlink_health_reporter *reporter,
			  const char *msg, void *priv_ctx);
void
devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
				     enum devlink_health_reporter_state state);
void
devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter);

int devl_nested_devlink_set(struct devlink *devlink,
			    struct devlink *nested_devlink);
bool devlink_is_reload_failed(const struct devlink *devlink);
void devlink_remote_reload_actions_performed(struct devlink *devlink,
					     enum devlink_reload_limit limit,
					     u32 actions_performed);

void devlink_flash_update_status_notify(struct devlink *devlink,
					const char *status_msg,
					const char *component,
					unsigned long done,
					unsigned long total);
void devlink_flash_update_timeout_notify(struct devlink *devlink,
					 const char *status_msg,
					 const char *component,
					 unsigned long timeout);

int devl_traps_register(struct devlink *devlink,
			const struct devlink_trap *traps,
			size_t traps_count, void *priv);
int devlink_traps_register(struct devlink *devlink,
			   const struct devlink_trap *traps,
			   size_t traps_count, void *priv);
void devl_traps_unregister(struct devlink *devlink,
			   const struct devlink_trap *traps,
			   size_t traps_count);
void devlink_traps_unregister(struct devlink *devlink,
			      const struct devlink_trap *traps,
			      size_t traps_count);
void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb,
			 void *trap_ctx, struct devlink_port *in_devlink_port,
			 const struct flow_action_cookie *fa_cookie);
void *devlink_trap_ctx_priv(void *trap_ctx);
int devl_trap_groups_register(struct devlink *devlink,
			      const struct devlink_trap_group *groups,
			      size_t groups_count);
int devlink_trap_groups_register(struct devlink *devlink,
				 const struct devlink_trap_group *groups,
				 size_t groups_count);
void devl_trap_groups_unregister(struct devlink *devlink,
				 const struct devlink_trap_group *groups,
				 size_t groups_count);
void devlink_trap_groups_unregister(struct devlink *devlink,
				    const struct devlink_trap_group *groups,
				    size_t groups_count);
int
devl_trap_policers_register(struct devlink *devlink,
			    const struct devlink_trap_policer *policers,
			    size_t policers_count);
void
devl_trap_policers_unregister(struct devlink *devlink,
			      const struct devlink_trap_policer *policers,
			      size_t policers_count);

#if IS_ENABLED(CONFIG_NET_DEVLINK)

struct devlink *__must_check devlink_try_get(struct devlink *devlink);
void devlink_put(struct devlink *devlink);

void devlink_compat_running_version(struct devlink *devlink,
				    char *buf, size_t len);
int devlink_compat_flash_update(struct devlink *devlink, const char *file_name);
int devlink_compat_phys_port_name_get(struct net_device *dev,
				      char *name, size_t len);
int devlink_compat_switch_id_get(struct net_device *dev,
				 struct netdev_phys_item_id *ppid);

int devlink_nl_port_handle_fill(struct sk_buff *msg, struct devlink_port *devlink_port);
size_t devlink_nl_port_handle_size(struct devlink_port *devlink_port);

#else

static inline struct devlink *devlink_try_get(struct devlink *devlink)
{
	return NULL;
}

static inline void devlink_put(struct devlink *devlink)
{
}

static inline void
devlink_compat_running_version(struct devlink *devlink, char *buf, size_t len)
{
}

static inline int
devlink_compat_flash_update(struct devlink *devlink, const char *file_name)
{
	return -EOPNOTSUPP;
}

static inline int
devlink_compat_phys_port_name_get(struct net_device *dev,
				  char *name, size_t len)
{
	return -EOPNOTSUPP;
}

static inline int
devlink_compat_switch_id_get(struct net_device *dev,
			     struct netdev_phys_item_id *ppid)
{
	return -EOPNOTSUPP;
}

static inline int
devlink_nl_port_handle_fill(struct sk_buff *msg, struct devlink_port *devlink_port)
{
	return 0;
}

static inline size_t devlink_nl_port_handle_size(struct devlink_port *devlink_port)
{
	return 0;
}

#endif

#endif /* _NET_DEVLINK_H_ */