Skip to content

Commit 8fcfb4d

Browse files
Hadar Hen Ziondavem330
authored andcommitted
net/mlx4_core: Add firmware commands to support device managed flow steering
Add support for firmware commands to attach/detach a new device managed steering mode. Such network steering rules allow the user to provide an L2/L3/L4 flow specification to the firmware and have the device to steer traffic that matches that specification to the provided QP. Signed-off-by: Hadar Hen Zion <[email protected]> Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c96d97f commit 8fcfb4d

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

drivers/net/ethernet/mellanox/mlx4/cmd.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,25 @@ static struct mlx4_cmd_info cmd_info[] = {
10801080
.verify = NULL,
10811081
.wrapper = NULL
10821082
},
1083+
/* flow steering commands */
1084+
{
1085+
.opcode = MLX4_QP_FLOW_STEERING_ATTACH,
1086+
.has_inbox = true,
1087+
.has_outbox = false,
1088+
.out_is_imm = true,
1089+
.encode_slave_id = false,
1090+
.verify = NULL,
1091+
.wrapper = mlx4_QP_FLOW_STEERING_ATTACH_wrapper
1092+
},
1093+
{
1094+
.opcode = MLX4_QP_FLOW_STEERING_DETACH,
1095+
.has_inbox = false,
1096+
.has_outbox = false,
1097+
.out_is_imm = false,
1098+
.encode_slave_id = false,
1099+
.verify = NULL,
1100+
.wrapper = mlx4_QP_FLOW_STEERING_DETACH_wrapper
1101+
},
10831102
};
10841103

10851104
static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,

drivers/net/ethernet/mellanox/mlx4/mcg.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,35 @@ int mlx4_get_qp_per_mgm(struct mlx4_dev *dev)
6262
return 4 * (mlx4_get_mgm_entry_size(dev) / 16 - 2);
6363
}
6464

65+
static int mlx4_QP_FLOW_STEERING_ATTACH(struct mlx4_dev *dev,
66+
struct mlx4_cmd_mailbox *mailbox,
67+
u32 size,
68+
u64 *reg_id)
69+
{
70+
u64 imm;
71+
int err = 0;
72+
73+
err = mlx4_cmd_imm(dev, mailbox->dma, &imm, size, 0,
74+
MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
75+
MLX4_CMD_NATIVE);
76+
if (err)
77+
return err;
78+
*reg_id = imm;
79+
80+
return err;
81+
}
82+
83+
static int mlx4_QP_FLOW_STEERING_DETACH(struct mlx4_dev *dev, u64 regid)
84+
{
85+
int err = 0;
86+
87+
err = mlx4_cmd(dev, regid, 0, 0,
88+
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
89+
MLX4_CMD_NATIVE);
90+
91+
return err;
92+
}
93+
6594
static int mlx4_READ_ENTRY(struct mlx4_dev *dev, int index,
6695
struct mlx4_cmd_mailbox *mailbox)
6796
{

drivers/net/ethernet/mellanox/mlx4/mlx4.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,16 @@ int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave,
11181118
struct mlx4_cmd_mailbox *inbox,
11191119
struct mlx4_cmd_mailbox *outbox,
11201120
struct mlx4_cmd_info *cmd);
1121+
int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
1122+
struct mlx4_vhcr *vhcr,
1123+
struct mlx4_cmd_mailbox *inbox,
1124+
struct mlx4_cmd_mailbox *outbox,
1125+
struct mlx4_cmd_info *cmd);
1126+
int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
1127+
struct mlx4_vhcr *vhcr,
1128+
struct mlx4_cmd_mailbox *inbox,
1129+
struct mlx4_cmd_mailbox *outbox,
1130+
struct mlx4_cmd_info *cmd);
11211131

11221132
int mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
11231133
int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);

drivers/net/ethernet/mellanox/mlx4/resource_tracker.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,30 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
27382738
return err;
27392739
}
27402740

2741+
int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
2742+
struct mlx4_vhcr *vhcr,
2743+
struct mlx4_cmd_mailbox *inbox,
2744+
struct mlx4_cmd_mailbox *outbox,
2745+
struct mlx4_cmd_info *cmd)
2746+
{
2747+
return mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
2748+
vhcr->in_modifier, 0,
2749+
MLX4_QP_FLOW_STEERING_ATTACH,
2750+
MLX4_CMD_TIME_CLASS_A,
2751+
MLX4_CMD_NATIVE);
2752+
}
2753+
2754+
int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
2755+
struct mlx4_vhcr *vhcr,
2756+
struct mlx4_cmd_mailbox *inbox,
2757+
struct mlx4_cmd_mailbox *outbox,
2758+
struct mlx4_cmd_info *cmd)
2759+
{
2760+
return mlx4_cmd(dev, vhcr->in_param, 0, 0,
2761+
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
2762+
MLX4_CMD_NATIVE);
2763+
}
2764+
27412765
enum {
27422766
BUSY_MAX_RETRIES = 10
27432767
};

include/linux/mlx4/cmd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ enum {
154154
/* set port opcode modifiers */
155155
MLX4_SET_PORT_PRIO2TC = 0x8,
156156
MLX4_SET_PORT_SCHEDULER = 0x9,
157+
158+
/* register/delete flow steering network rules */
159+
MLX4_QP_FLOW_STEERING_ATTACH = 0x65,
160+
MLX4_QP_FLOW_STEERING_DETACH = 0x66,
157161
};
158162

159163
enum {

0 commit comments

Comments
 (0)