auto
  +   ˆl–Ü4ý( ©³( 	Å€fàB¦-ÿ¿„uÆÂ/_†I|¥�+ÃÂ ?÷     /* 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 <jiri@mellanox.com>
 */
#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>

#include <linux/rh_kabi.h>

struct devlink;
struct devlink_linecard;

struct devlink_port_phys_attrs {
	u32 port_number; /* Same value as "split group".
			  * A physical port which is visible to the user
			  * for a given port flavour.
			  */
	u32 split_subport_number; /* If the port is split, this is the number of subport. */
};

/**
 * struct devlink_port_pci_pf_attrs - devlink port's PCI PF attributes
 * @controller: Associated controller number
 * @pf: associated PCI function number for the devlink port instance
 * @external: when set, indicates if a port is for an external controller
 */
struct devlink_port_pci_pf_attrs {
	u32 controller;
	u16 pf;
	u8 external:1;
};

/**
 * struct devlink_port_pci_vf_attrs - devlink port's PCI VF attributes
 * @controller: Associated controller number
 * @pf: associated PCI function number for the devlink port instance
 * @vf: associated PCI VF number of a PF for the devlink port instance;
 *	VF number starts from 0 for the first PCI virtual function
 * @external: when set, indicates if a port is for an external controller
 */
struct devlink_port_pci_vf_attrs {
	u32 controller;
	u16 pf;
	u16 vf;
	u8 external:1;
};

/**
 * struct devlink_port_pci_sf_attrs - devlink port's PCI SF attributes
 * @controller: Associated controller number
 * @sf: associated SF number of a PF for the devlink port instance
 * @pf: associated PCI function number for the devlink port instance
 * @external: when set, indicates if a port is for an external controller
 */
struct devlink_port_pci_sf_attrs {
	u32 controller;
	u32 sf;
	u16 pf;
	u8 external:1;
};

/**
 * 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.
 * @no_phys_port_name: skip automatic phys_port_name generation; for
 *		       compatibility only, newly added driver/port instance
 *		       should never set this.
 * @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 {
	u8 split:1,
	   splittable:1,
	   no_phys_port_name:1;
	u32 lanes;
	enum devlink_port_flavour flavour;
	struct netdev_phys_item_id switch_id;
	union {
		struct devlink_port_phys_attrs phys;
		struct devlink_port_pci_pf_attrs pci_pf;
		struct devlink_port_pci_vf_attrs pci_vf;
		struct devlink_port_pci_sf_attrs pci_sf;
	};
};

struct devlink_rate {
	struct list_head list;
	enum devlink_rate_type type;
	struct devlink *devlink;
	void *priv;
	u64 tx_share;
	u64 tx_max;

	struct devlink_rate *parent;
	union {
		struct devlink_port *devlink_port;
		struct {
			char *name;
			refcount_t refcnt;
		};
	};

	u32 tx_priority;
	u32 tx_weight;

	u32 tc_bw[DEVLINK_RATE_TCS_MAX];
};

struct devlink_port {
	struct list_head list;
	struct list_head region_list;
	struct devlink *devlink;
	const struct devlink_port_ops *ops;
	unsigned int index;
	spinlock_t type_lock; /* Protects type and type_eth/ib
			       * structures consistency.
			       */
	enum devlink_port_type type;
	enum devlink_port_type desired_type;
	union {
		struct {
			struct net_device *netdev;
			int ifindex