Skip to content

Commit b47fd4f

Browse files
mark-blochjgunthorpe
authored andcommitted
RDMA/mlx5: Add NIC TX namespace when getting a flow table
Add the ability to get a NIC TX flow table when using _get_flow_table(). This will allow to create a matcher and a flow rule on the NIC TX path. Signed-off-by: Mark Bloch <markb@mellanox.com> Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent fa76d24 commit b47fd4f

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

drivers/infiniband/hw/mlx5/flow.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)(
189189
if (!obj)
190190
return -ENOMEM;
191191

192+
obj->ns_type = MLX5_FLOW_NAMESPACE_BYPASS;
192193
obj->mask_len = uverbs_attr_get_len(
193194
attrs, MLX5_IB_ATTR_FLOW_MATCHER_MATCH_MASK);
194195
err = uverbs_copy_from(&obj->matcher_mask,

drivers/infiniband/hw/mlx5/main.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,34 +3719,54 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
37193719
return ERR_PTR(err);
37203720
}
37213721

3722-
static struct mlx5_ib_flow_prio *_get_flow_table(struct mlx5_ib_dev *dev,
3723-
int priority, bool mcast)
3722+
static struct mlx5_ib_flow_prio *
3723+
_get_flow_table(struct mlx5_ib_dev *dev,
3724+
struct mlx5_ib_flow_matcher *fs_matcher,
3725+
bool mcast)
37243726
{
3725-
int max_table_size;
37263727
struct mlx5_flow_namespace *ns = NULL;
37273728
struct mlx5_ib_flow_prio *prio;
3729+
int max_table_size;
3730+
u32 flags = 0;
3731+
int priority;
3732+
3733+
if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_BYPASS) {
3734+
max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
3735+
log_max_ft_size));
3736+
if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, decap))
3737+
flags |= MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
3738+
if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
3739+
reformat_l3_tunnel_to_l2))
3740+
flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
3741+
} else { /* Can only be MLX5_FLOW_NAMESPACE_EGRESS */
3742+
max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev,
3743+
log_max_ft_size));
3744+
if (MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, reformat))
3745+
flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
3746+
}
37283747

3729-
max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
3730-
log_max_ft_size));
37313748
if (max_table_size < MLX5_FS_MAX_ENTRIES)
37323749
return ERR_PTR(-ENOMEM);
37333750

37343751
if (mcast)
37353752
priority = MLX5_IB_FLOW_MCAST_PRIO;
37363753
else
3737-
priority = ib_prio_to_core_prio(priority, false);
3754+
priority = ib_prio_to_core_prio(fs_matcher->priority, false);
37383755

3739-
ns = mlx5_get_flow_namespace(dev->mdev, MLX5_FLOW_NAMESPACE_BYPASS);
3756+
ns = mlx5_get_flow_namespace(dev->mdev, fs_matcher->ns_type);
37403757
if (!ns)
37413758
return ERR_PTR(-ENOTSUPP);
37423759

3743-
prio = &dev->flow_db->prios[priority];
3760+
if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_BYPASS)
3761+
prio = &dev->flow_db->prios[priority];
3762+
else
3763+
prio = &dev->flow_db->egress_prios[priority];
37443764

37453765
if (prio->flow_table)
37463766
return prio;
37473767

37483768
return _get_prio(ns, prio, priority, MLX5_FS_MAX_ENTRIES,
3749-
MLX5_FS_MAX_TYPES, 0);
3769+
MLX5_FS_MAX_TYPES, flags);
37503770
}
37513771

37523772
static struct mlx5_ib_flow_handler *
@@ -3845,7 +3865,6 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
38453865
{
38463866
struct mlx5_flow_destination *dst;
38473867
struct mlx5_ib_flow_prio *ft_prio;
3848-
int priority = fs_matcher->priority;
38493868
struct mlx5_ib_flow_handler *handler;
38503869
bool mcast;
38513870
int err;
@@ -3863,7 +3882,7 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
38633882
mcast = raw_fs_is_multicast(fs_matcher, cmd_in);
38643883
mutex_lock(&dev->flow_db->lock);
38653884

3866-
ft_prio = _get_flow_table(dev, priority, mcast);
3885+
ft_prio = _get_flow_table(dev, fs_matcher, mcast);
38673886
if (IS_ERR(ft_prio)) {
38683887
err = PTR_ERR(ft_prio);
38693888
goto unlock;

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct mlx5_ib_flow_matcher {
190190
struct mlx5_ib_match_params matcher_mask;
191191
int mask_len;
192192
enum mlx5_ib_flow_type flow_type;
193+
enum mlx5_flow_namespace_type ns_type;
193194
u16 priority;
194195
struct mlx5_core_dev *mdev;
195196
atomic_t usecnt;

0 commit comments

Comments
 (0)