drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
Extension
.h
Size
9991 bytes
Lines
318
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct lag_func {
	struct mlx5_core_dev *dev;
	struct net_device    *netdev;
	bool has_drop;
	unsigned int idx; /* xarray index assigned by LAG */
	struct mlx5_nb port_change_nb;
	u32 group_id;        /* SD group ID, 0 = not SD */
	bool sd_fdb_active;  /* set on all SD group members */
	/* Lag demux resources - only populated on master devices */
	struct mlx5_flow_table   *lag_demux_ft;
	struct mlx5_flow_group   *lag_demux_fg;
	struct xarray		  lag_demux_rules;
};

/* Used for collection of netdev event info. */
struct lag_tracker {
	enum   netdev_lag_tx_type           tx_type;
	struct netdev_lag_lower_state_info  netdev_state[MLX5_MAX_PORTS];
	unsigned int is_bonded:1;
	unsigned int has_inactive:1;
	enum netdev_lag_hash hash_type;
	u32 bond_speed_mbps;
};

/* LAG data of a ConnectX card.
 * It serves both its phys functions.
 */
struct mlx5_lag {
	enum mlx5_lag_mode        mode;
	unsigned long		  mode_flags;
	unsigned long		  state_flags;
	u8			  ports;
	u8			  buckets;
	int			  mode_changes_in_progress;
	u8			  v2p_map[MLX5_MAX_PORTS * MLX5_LAG_MAX_HASH_BUCKETS];
	struct kref               ref;
	struct xarray             pfs;
	struct lag_tracker        tracker;
	struct workqueue_struct   *wq;
	struct delayed_work       bond_work;
	struct work_struct        speed_update_work;
	struct notifier_block     nb;
	possible_net_t net;
	struct lag_mp             lag_mp;
	struct mlx5_lag_port_sel  port_sel;
	/* Protect lag fields/state changes */
	struct mutex		  lock;
	struct lag_mpesw	  lag_mpesw;
};

static inline struct mlx5_lag *
mlx5_lag_dev(struct mlx5_core_dev *dev)
{
	return dev->priv.lag;
}

static inline struct lag_func *
mlx5_lag_pf(struct mlx5_lag *ldev, unsigned int idx)
{
	return xa_load(&ldev->pfs, idx);
}

/* Get device index (mlx5_get_dev_index) from xarray index */
static inline int mlx5_lag_xa_to_dev_idx(struct mlx5_lag *ldev, int xa_idx)
{
	struct lag_func *pf = mlx5_lag_pf(ldev, xa_idx);

	return pf ? mlx5_get_dev_index(pf->dev) : -ENOENT;
}

/* Find lag_func by device index (reverse lookup from mlx5_get_dev_index) */
static inline struct lag_func *
mlx5_lag_pf_by_dev_idx(struct mlx5_lag *ldev, int dev_idx)
{
	struct lag_func *pf;
	unsigned long idx;

	xa_for_each(&ldev->pfs, idx, pf) {
		if (mlx5_get_dev_index(pf->dev) == dev_idx)
			return pf;
	}
	return NULL;
}

/* Find lag_func by mlx5_core_dev pointer */
static inline struct lag_func *
mlx5_lag_pf_by_dev(struct mlx5_lag *ldev, struct mlx5_core_dev *dev)
{
	struct lag_func *pf;
	unsigned long idx;

Annotation

Implementation Notes