Commit 430e2d5e authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed
Browse files

net/mlx5: E-Switch, Move send to vport meta rule creation



Move the creation of the rules from offloads fdb table init to
per rep vport init.
This way the driver will creating the send to vport meta rule
on any representor, e.g. SF representors.

Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Reviewed-by: default avatarMaor Dickman <maord@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 4a561817
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2738,7 +2738,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
	netif_tx_start_all_queues(priv->netdev);

	if (mlx5e_is_vport_rep(priv))
		mlx5e_add_sqs_fwd_rules(priv);
		mlx5e_rep_activate_channels(priv);

	mlx5e_wait_channels_min_rx_wqes(&priv->channels);

@@ -2752,7 +2752,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
		mlx5e_rx_res_channels_deactivate(priv->rx_res);

	if (mlx5e_is_vport_rep(priv))
		mlx5e_remove_sqs_fwd_rules(priv);
		mlx5e_rep_deactivate_channels(priv);

	/* The results of ndo_select_queue are unreliable, while netdev config
	 * is being changed (real_num_tx_queues, num_tc). Stop all queues to
+51 −2
Original line number Diff line number Diff line
@@ -398,7 +398,8 @@ static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw,
	return err;
}

int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
static int
mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
{
	int sqs_per_channel = mlx5e_get_dcb_num_tc(&priv->channels.params);
	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
@@ -452,7 +453,8 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
	return err;
}

void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv)
static void
mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv)
{
	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
	struct mlx5e_rep_priv *rpriv = priv->ppriv;
@@ -461,6 +463,53 @@ void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv)
	mlx5e_sqs2vport_stop(esw, rep);
}

static int
mlx5e_rep_add_meta_tunnel_rule(struct mlx5e_priv *priv)
{
	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
	struct mlx5e_rep_priv *rpriv = priv->ppriv;
	struct mlx5_eswitch_rep *rep = rpriv->rep;
	struct mlx5_flow_handle *flow_rule;
	struct mlx5_flow_group *g;
	int err;

	g = esw->fdb_table.offloads.send_to_vport_meta_grp;
	if (!g)
		return 0;

	flow_rule = mlx5_eswitch_add_send_to_vport_meta_rule(esw, rep->vport);
	if (IS_ERR(flow_rule)) {
		err = PTR_ERR(flow_rule);
		goto out;
	}

	rpriv->send_to_vport_meta_rule = flow_rule;

out:
	return err;
}

static void
mlx5e_rep_del_meta_tunnel_rule(struct mlx5e_priv *priv)
{
	struct mlx5e_rep_priv *rpriv = priv->ppriv;

	if (rpriv->send_to_vport_meta_rule)
		mlx5_eswitch_del_send_to_vport_meta_rule(rpriv->send_to_vport_meta_rule);
}

void mlx5e_rep_activate_channels(struct mlx5e_priv *priv)
{
	mlx5e_add_sqs_fwd_rules(priv);
	mlx5e_rep_add_meta_tunnel_rule(priv);
}

void mlx5e_rep_deactivate_channels(struct mlx5e_priv *priv)
{
	mlx5e_rep_del_meta_tunnel_rule(priv);
	mlx5e_remove_sqs_fwd_rules(priv);
}

static int mlx5e_rep_open(struct net_device *dev)
{
	struct mlx5e_priv *priv = netdev_priv(dev);
+5 −4
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ struct mlx5e_rep_priv {
	struct list_head       vport_sqs_list;
	struct mlx5_rep_uplink_priv uplink_priv; /* valid for uplink rep */
	struct rtnl_link_stats64 prev_vf_vport_stats;
	struct mlx5_flow_handle *send_to_vport_meta_rule;
	struct rhashtable tc_ht;
};

@@ -241,8 +242,8 @@ int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev,
				void *sp);

bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv);
int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv);
void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv);
void mlx5e_rep_activate_channels(struct mlx5e_priv *priv);
void mlx5e_rep_deactivate_channels(struct mlx5e_priv *priv);

void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);

@@ -256,8 +257,8 @@ static inline bool mlx5e_eswitch_rep(const struct net_device *netdev)

#else /* CONFIG_MLX5_ESWITCH */
static inline bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) { return false; }
static inline int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv) { return 0; }
static inline void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) {}
static inline void mlx5e_rep_activate_channels(struct mlx5e_priv *priv) {}
static inline void mlx5e_rep_deactivate_channels(struct mlx5e_priv *priv) {}
static inline int mlx5e_rep_init(void) { return 0; };
static inline void mlx5e_rep_cleanup(void) {};
static inline bool mlx5e_rep_has_offload_stats(const struct net_device *dev,
+0 −1
Original line number Diff line number Diff line
@@ -1360,7 +1360,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf)
	if (esw->mode == MLX5_ESWITCH_OFFLOADS) {
		struct devlink *devlink = priv_to_devlink(esw->dev);

		esw_offloads_del_send_to_vport_meta_rules(esw);
		devl_rate_nodes_destroy(devlink);
	}

+4 −1
Original line number Diff line number Diff line
@@ -346,7 +346,10 @@ void esw_offloads_disable(struct mlx5_eswitch *esw);
int esw_offloads_enable(struct mlx5_eswitch *esw);
void esw_offloads_cleanup_reps(struct mlx5_eswitch *esw);
int esw_offloads_init_reps(struct mlx5_eswitch *esw);
void esw_offloads_del_send_to_vport_meta_rules(struct mlx5_eswitch *esw);

struct mlx5_flow_handle *
mlx5_eswitch_add_send_to_vport_meta_rule(struct mlx5_eswitch *esw, u16 vport_num);
void mlx5_eswitch_del_send_to_vport_meta_rule(struct mlx5_flow_handle *rule);

bool mlx5_esw_vport_match_metadata_supported(const struct mlx5_eswitch *esw);
int mlx5_esw_offloads_vport_metadata_set(struct mlx5_eswitch *esw, bool enable);
Loading