Skip to content

Commit b823dd6

Browse files
mark-blochjgunthorpe
authored andcommitted
RDMA/mlx5: Refactor raw flow creation
Move struct mlx5_flow_act to be passed from the method entry point, this will allow to add support for flow action for the raw create flow 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 501f14e commit b823dd6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

drivers/infiniband/hw/mlx5/flow.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static const struct uverbs_attr_spec mlx5_ib_flow_type[] = {
6161
static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
6262
struct ib_uverbs_file *file, struct uverbs_attr_bundle *attrs)
6363
{
64+
struct mlx5_flow_act flow_act = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
6465
struct mlx5_ib_flow_handler *flow_handler;
6566
struct mlx5_ib_flow_matcher *fs_matcher;
6667
void *devx_obj;
@@ -123,7 +124,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
123124
MLX5_IB_ATTR_CREATE_FLOW_MATCH_VALUE);
124125
fs_matcher = uverbs_attr_get_obj(attrs,
125126
MLX5_IB_ATTR_CREATE_FLOW_MATCHER);
126-
flow_handler = mlx5_ib_raw_fs_rule_add(dev, fs_matcher, cmd_in, inlen,
127+
flow_handler = mlx5_ib_raw_fs_rule_add(dev, fs_matcher, &flow_act,
128+
cmd_in, inlen,
127129
dest_id, dest_type);
128130
if (IS_ERR(flow_handler))
129131
return PTR_ERR(flow_handler);

drivers/infiniband/hw/mlx5/main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,10 +3754,10 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
37543754
struct mlx5_ib_flow_prio *ft_prio,
37553755
struct mlx5_flow_destination *dst,
37563756
struct mlx5_ib_flow_matcher *fs_matcher,
3757+
struct mlx5_flow_act *flow_act,
37573758
void *cmd_in, int inlen)
37583759
{
37593760
struct mlx5_ib_flow_handler *handler;
3760-
struct mlx5_flow_act flow_act = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
37613761
struct mlx5_flow_spec *spec;
37623762
struct mlx5_flow_table *ft = ft_prio->flow_table;
37633763
int err = 0;
@@ -3776,9 +3776,8 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
37763776
fs_matcher->mask_len);
37773777
spec->match_criteria_enable = fs_matcher->match_criteria_enable;
37783778

3779-
flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
37803779
handler->rule = mlx5_add_flow_rules(ft, spec,
3781-
&flow_act, dst, 1);
3780+
flow_act, dst, 1);
37823781

37833782
if (IS_ERR(handler->rule)) {
37843783
err = PTR_ERR(handler->rule);
@@ -3840,6 +3839,7 @@ static bool raw_fs_is_multicast(struct mlx5_ib_flow_matcher *fs_matcher,
38403839
struct mlx5_ib_flow_handler *
38413840
mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
38423841
struct mlx5_ib_flow_matcher *fs_matcher,
3842+
struct mlx5_flow_act *flow_act,
38433843
void *cmd_in, int inlen, int dest_id,
38443844
int dest_type)
38453845
{
@@ -3872,13 +3872,15 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
38723872
if (dest_type == MLX5_FLOW_DESTINATION_TYPE_TIR) {
38733873
dst->type = dest_type;
38743874
dst->tir_num = dest_id;
3875+
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
38753876
} else {
38763877
dst->type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM;
38773878
dst->ft_num = dest_id;
3879+
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
38783880
}
38793881

3880-
handler = _create_raw_flow_rule(dev, ft_prio, dst, fs_matcher, cmd_in,
3881-
inlen);
3882+
handler = _create_raw_flow_rule(dev, ft_prio, dst, fs_matcher, flow_act,
3883+
cmd_in, inlen);
38823884

38833885
if (IS_ERR(handler)) {
38843886
err = PTR_ERR(handler);

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <rdma/ib_smi.h>
4040
#include <linux/mlx5/driver.h>
4141
#include <linux/mlx5/cq.h>
42+
#include <linux/mlx5/fs.h>
4243
#include <linux/mlx5/qp.h>
4344
#include <linux/mlx5/srq.h>
4445
#include <linux/mlx5/fs.h>
@@ -1253,7 +1254,8 @@ void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev,
12531254
const struct uverbs_object_tree_def *mlx5_ib_get_devx_tree(void);
12541255
struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(
12551256
struct mlx5_ib_dev *dev, struct mlx5_ib_flow_matcher *fs_matcher,
1256-
void *cmd_in, int inlen, int dest_id, int dest_type);
1257+
struct mlx5_flow_act *flow_act, void *cmd_in, int inlen,
1258+
int dest_id, int dest_type);
12571259
bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type);
12581260
int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root);
12591261
void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction);

0 commit comments

Comments
 (0)