Commit 6a4d00be authored by Mark Bloch's avatar Mark Bloch Committed by Jason Gunthorpe
Browse files

RDMA/mlx5: Move rep into port struct



In preparation of moving into a model of single IB device multiple ports
move rep to be part of the port structure. We mark a representor device by
setting is_rep, no functional change with this patch.

Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 5d8f6a0e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1904,7 +1904,7 @@ static bool devx_is_supported(struct ib_device *device)
{
	struct mlx5_ib_dev *dev = to_mdev(device);

	return !dev->rep && MLX5_CAP_GEN(dev->mdev, log_max_uctx);
	return !dev->is_rep && MLX5_CAP_GEN(dev->mdev, log_max_uctx);
}

const struct uapi_definition mlx5_ib_devx_defs[] = {
+1 −1
Original line number Diff line number Diff line
@@ -621,7 +621,7 @@ DECLARE_UVERBS_NAMED_OBJECT(MLX5_IB_OBJECT_FLOW_MATCHER,

static bool flow_is_supported(struct ib_device *device)
{
	return !to_mdev(device)->rep;
	return !to_mdev(device)->is_rep;
}

const struct uapi_definition mlx5_ib_flow_defs[] = {
+4 −3
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
		return -ENOMEM;
	}

	ibdev->rep = rep;
	ibdev->is_rep = true;
	ibdev->port[0].rep = rep;
	ibdev->mdev = dev;
	ibdev->num_ports = num_ports;

@@ -151,12 +152,12 @@ int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
	struct mlx5_flow_handle *flow_rule;
	struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;

	if (!dev->rep)
	if (!dev->is_rep)
		return 0;

	flow_rule =
		mlx5_eswitch_add_send_to_vport_rule(esw,
						    dev->rep->vport,
						    dev->port[0].rep->vport,
						    sq->base.mqp.qpn);
	if (IS_ERR(flow_rule))
		return PTR_ERR(flow_rule);
+13 −9
Original line number Diff line number Diff line
@@ -173,12 +173,12 @@ static int mlx5_netdev_event(struct notifier_block *this,
	switch (event) {
	case NETDEV_REGISTER:
		write_lock(&roce->netdev_lock);
		if (ibdev->rep) {
		if (ibdev->is_rep) {
			struct mlx5_eswitch *esw = ibdev->mdev->priv.eswitch;
			struct mlx5_eswitch_rep	*rep = ibdev->port[0].rep;
			struct net_device *rep_ndev;

			rep_ndev = mlx5_ib_get_rep_netdev(esw,
							  ibdev->rep->vport);
			rep_ndev = mlx5_ib_get_rep_netdev(esw, rep->vport);
			if (rep_ndev == ndev)
				roce->netdev = ndev;
		} else if (ndev->dev.parent == &mdev->pdev->dev) {
@@ -3153,10 +3153,10 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
		if (ft_type == MLX5_IB_FT_RX) {
			fn_type = MLX5_FLOW_NAMESPACE_BYPASS;
			prio = &dev->flow_db->prios[priority];
			if (!dev->rep &&
			if (!dev->is_rep &&
			    MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, decap))
				flags |= MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
			if (!dev->rep &&
			if (!dev->is_rep &&
			    MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
					reformat_l3_tunnel_to_l2))
				flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
@@ -3166,7 +3166,7 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
							      log_max_ft_size));
			fn_type = MLX5_FLOW_NAMESPACE_EGRESS;
			prio = &dev->flow_db->egress_prios[priority];
			if (!dev->rep &&
			if (!dev->is_rep &&
			    MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, reformat))
				flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
		}
@@ -3372,7 +3372,7 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
	if (!is_valid_attr(dev->mdev, flow_attr))
		return ERR_PTR(-EINVAL);

	if (dev->rep && is_egress)
	if (dev->is_rep && is_egress)
		return ERR_PTR(-EINVAL);

	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
@@ -3403,13 +3403,17 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
	if (!flow_is_multicast_only(flow_attr))
		set_underlay_qp(dev, spec, underlay_qpn);

	if (dev->rep) {
	if (dev->is_rep) {
		void *misc;

		if (!dev->port[flow_attr->port - 1].rep) {
			err = -EINVAL;
			goto free;
		}
		misc = MLX5_ADDR_OF(fte_match_param, spec->match_value,
				    misc_parameters);
		MLX5_SET(fte_match_set_misc, misc, source_port,
			 dev->rep->vport);
			 dev->port[flow_attr->port - 1].rep->vport);
		misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
				    misc_parameters);
		MLX5_SET_TO_ONES(fte_match_set_misc, misc, source_port);
+2 −1
Original line number Diff line number Diff line
@@ -720,6 +720,7 @@ struct mlx5_ib_port {
	struct mlx5_ib_multiport mp;
	struct mlx5_ib_dbg_cc_params *dbg_cc_params;
	struct mlx5_roce roce;
	struct mlx5_eswitch_rep		*rep;
};

struct mlx5_ib_dbg_param {
@@ -940,7 +941,7 @@ struct mlx5_ib_dev {
	struct mlx5_sq_bfreg	fp_bfreg;
	struct mlx5_ib_delay_drop	delay_drop;
	const struct mlx5_ib_profile	*profile;
	struct mlx5_eswitch_rep		*rep;
	bool			is_rep;
	int				lag_active;

	struct mlx5_ib_lb_state		lb;
Loading