Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50854114 authored by Yishai Hadas's avatar Yishai Hadas Committed by Saeed Mahameed
Browse files

net/mlx5: Use underlay QPN from the root name space



Root flow table is dynamically changed by the underlying flow steering
layer, and IPoIB/ULPs have no idea what will be the root flow table in
the future, hence we need a dynamic infrastructure to move Underlay QPs
with the root flow table.

Fixes: b3ba5149 ("net/mlx5: Refactor create flow table method to accept underlay QP")
Signed-off-by: default avatarErez Shitrit <erezsh@mellanox.com>
Signed-off-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 5360fd47
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1003,7 +1003,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);


int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn);
int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);


int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
+2 −3
Original line number Original line Diff line number Diff line
@@ -800,7 +800,7 @@ void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv)
	mlx5e_destroy_flow_table(&ttc->ft);
	mlx5e_destroy_flow_table(&ttc->ft);
}
}


int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn)
int mlx5e_create_ttc_table(struct mlx5e_priv *priv)
{
{
	struct mlx5e_ttc_table *ttc = &priv->fs.ttc;
	struct mlx5e_ttc_table *ttc = &priv->fs.ttc;
	struct mlx5_flow_table_attr ft_attr = {};
	struct mlx5_flow_table_attr ft_attr = {};
@@ -810,7 +810,6 @@ int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn)
	ft_attr.max_fte = MLX5E_TTC_TABLE_SIZE;
	ft_attr.max_fte = MLX5E_TTC_TABLE_SIZE;
	ft_attr.level = MLX5E_TTC_FT_LEVEL;
	ft_attr.level = MLX5E_TTC_FT_LEVEL;
	ft_attr.prio = MLX5E_NIC_PRIO;
	ft_attr.prio = MLX5E_NIC_PRIO;
	ft_attr.underlay_qpn = underlay_qpn;


	ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
	ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
	if (IS_ERR(ft->t)) {
	if (IS_ERR(ft->t)) {
@@ -1147,7 +1146,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
		priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
		priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
	}
	}


	err = mlx5e_create_ttc_table(priv, 0);
	err = mlx5e_create_ttc_table(priv);
	if (err) {
	if (err) {
		netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
		netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
			   err);
			   err);
+3 −6
Original line number Original line Diff line number Diff line
@@ -40,28 +40,25 @@
#include "eswitch.h"
#include "eswitch.h"


int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
			    struct mlx5_flow_table *ft)
			    struct mlx5_flow_table *ft, u32 underlay_qpn)
{
{
	u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)]   = {0};
	u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)]   = {0};
	u32 out[MLX5_ST_SZ_DW(set_flow_table_root_out)] = {0};
	u32 out[MLX5_ST_SZ_DW(set_flow_table_root_out)] = {0};


	if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
	if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
	    ft->underlay_qpn == 0)
	    underlay_qpn == 0)
		return 0;
		return 0;


	MLX5_SET(set_flow_table_root_in, in, opcode,
	MLX5_SET(set_flow_table_root_in, in, opcode,
		 MLX5_CMD_OP_SET_FLOW_TABLE_ROOT);
		 MLX5_CMD_OP_SET_FLOW_TABLE_ROOT);
	MLX5_SET(set_flow_table_root_in, in, table_type, ft->type);
	MLX5_SET(set_flow_table_root_in, in, table_type, ft->type);
	MLX5_SET(set_flow_table_root_in, in, table_id, ft->id);
	MLX5_SET(set_flow_table_root_in, in, table_id, ft->id);
	MLX5_SET(set_flow_table_root_in, in, underlay_qpn, underlay_qpn);
	if (ft->vport) {
	if (ft->vport) {
		MLX5_SET(set_flow_table_root_in, in, vport_number, ft->vport);
		MLX5_SET(set_flow_table_root_in, in, vport_number, ft->vport);
		MLX5_SET(set_flow_table_root_in, in, other_vport, 1);
		MLX5_SET(set_flow_table_root_in, in, other_vport, 1);
	}
	}


	if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
	    ft->underlay_qpn != 0)
		MLX5_SET(set_flow_table_root_in, in, underlay_qpn, ft->underlay_qpn);

	return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
	return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
}
}


+2 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,8 @@ int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev,
			unsigned int index);
			unsigned int index);


int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
			    struct mlx5_flow_table *ft);
			    struct mlx5_flow_table *ft,
			    u32 underlay_qpn);


int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u16 *id);
int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u16 *id);
int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u16 id);
int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u16 id);
+21 −4
Original line number Original line Diff line number Diff line
@@ -650,7 +650,7 @@ static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio
	if (ft->level >= min_level)
	if (ft->level >= min_level)
		return 0;
		return 0;


	err = mlx5_cmd_update_root_ft(root->dev, ft);
	err = mlx5_cmd_update_root_ft(root->dev, ft, root->underlay_qpn);
	if (err)
	if (err)
		mlx5_core_warn(root->dev, "Update root flow table of id=%u failed\n",
		mlx5_core_warn(root->dev, "Update root flow table of id=%u failed\n",
			       ft->id);
			       ft->id);
@@ -818,8 +818,6 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
		goto unlock_root;
		goto unlock_root;
	}
	}


	ft->underlay_qpn = ft_attr->underlay_qpn;

	tree_init_node(&ft->node, 1, del_flow_table);
	tree_init_node(&ft->node, 1, del_flow_table);
	log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0;
	log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0;
	next_ft = find_next_chained_ft(fs_prio);
	next_ft = find_next_chained_ft(fs_prio);
@@ -1489,7 +1487,8 @@ static int update_root_ft_destroy(struct mlx5_flow_table *ft)


	new_root_ft = find_next_ft(ft);
	new_root_ft = find_next_ft(ft);
	if (new_root_ft) {
	if (new_root_ft) {
		int err = mlx5_cmd_update_root_ft(root->dev, new_root_ft);
		int err = mlx5_cmd_update_root_ft(root->dev, new_root_ft,
						  root->underlay_qpn);


		if (err) {
		if (err) {
			mlx5_core_warn(root->dev, "Update root flow table of id=%u failed\n",
			mlx5_core_warn(root->dev, "Update root flow table of id=%u failed\n",
@@ -2062,3 +2061,21 @@ int mlx5_init_fs(struct mlx5_core_dev *dev)
	mlx5_cleanup_fs(dev);
	mlx5_cleanup_fs(dev);
	return err;
	return err;
}
}

int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn)
{
	struct mlx5_flow_root_namespace *root = dev->priv.steering->root_ns;

	root->underlay_qpn = underlay_qpn;
	return 0;
}
EXPORT_SYMBOL(mlx5_fs_add_rx_underlay_qpn);

int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn)
{
	struct mlx5_flow_root_namespace *root = dev->priv.steering->root_ns;

	root->underlay_qpn = 0;
	return 0;
}
EXPORT_SYMBOL(mlx5_fs_remove_rx_underlay_qpn);
Loading