net/mlx4_core: Add firmware commands to support device managed flow steering
authorHadar Hen Zion <hadarh@mellanox.co.il>
Thu, 5 Jul 2012 04:03:45 +0000 (04:03 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Jul 2012 23:23:05 +0000 (16:23 -0700)
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 <hadarh@mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/mcg.c
drivers/net/ethernet/mellanox/mlx4/mlx4.h
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
include/linux/mlx4/cmd.h

index 842c8ce9494e0134ea02f7e962298737c11b19d2..7e94987d030c4da44885c5aa3dd56daf1d022907 100644 (file)
@@ -1080,6 +1080,25 @@ static struct mlx4_cmd_info cmd_info[] = {
                .verify = NULL,
                .wrapper = NULL
        },
+       /* flow steering commands */
+       {
+               .opcode = MLX4_QP_FLOW_STEERING_ATTACH,
+               .has_inbox = true,
+               .has_outbox = false,
+               .out_is_imm = true,
+               .encode_slave_id = false,
+               .verify = NULL,
+               .wrapper = mlx4_QP_FLOW_STEERING_ATTACH_wrapper
+       },
+       {
+               .opcode = MLX4_QP_FLOW_STEERING_DETACH,
+               .has_inbox = false,
+               .has_outbox = false,
+               .out_is_imm = false,
+               .encode_slave_id = false,
+               .verify = NULL,
+               .wrapper = mlx4_QP_FLOW_STEERING_DETACH_wrapper
+       },
 };
 
 static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
index 319c9d45d59a76f2884f267e37cce9e8774687ab..3c59a33a98a56ccde74657c36478ac743f6ac0d0 100644 (file)
@@ -62,6 +62,35 @@ int mlx4_get_qp_per_mgm(struct mlx4_dev *dev)
        return 4 * (mlx4_get_mgm_entry_size(dev) / 16 - 2);
 }
 
+static int mlx4_QP_FLOW_STEERING_ATTACH(struct mlx4_dev *dev,
+                                       struct mlx4_cmd_mailbox *mailbox,
+                                       u32 size,
+                                       u64 *reg_id)
+{
+       u64 imm;
+       int err = 0;
+
+       err = mlx4_cmd_imm(dev, mailbox->dma, &imm, size, 0,
+                          MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
+                          MLX4_CMD_NATIVE);
+       if (err)
+               return err;
+       *reg_id = imm;
+
+       return err;
+}
+
+static int mlx4_QP_FLOW_STEERING_DETACH(struct mlx4_dev *dev, u64 regid)
+{
+       int err = 0;
+
+       err = mlx4_cmd(dev, regid, 0, 0,
+                      MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
+                      MLX4_CMD_NATIVE);
+
+       return err;
+}
+
 static int mlx4_READ_ENTRY(struct mlx4_dev *dev, int index,
                           struct mlx4_cmd_mailbox *mailbox)
 {
index a425a984758fbf1d9a4a0646e93cc450ff1a7cc4..c07e882e8369ce6c9e0ed0486c33da3545107165 100644 (file)
@@ -1118,6 +1118,16 @@ int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave,
                               struct mlx4_cmd_mailbox *inbox,
                               struct mlx4_cmd_mailbox *outbox,
                               struct mlx4_cmd_info *cmd);
+int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
+                                        struct mlx4_vhcr *vhcr,
+                                        struct mlx4_cmd_mailbox *inbox,
+                                        struct mlx4_cmd_mailbox *outbox,
+                                        struct mlx4_cmd_info *cmd);
+int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
+                                        struct mlx4_vhcr *vhcr,
+                                        struct mlx4_cmd_mailbox *inbox,
+                                        struct mlx4_cmd_mailbox *outbox,
+                                        struct mlx4_cmd_info *cmd);
 
 int mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
 int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
index 6bdac2955f8b8d729fd2a84d2236bdf767014252..a8ca960f46200201b9b770eb0d2894541f8d474c 100644 (file)
@@ -2738,6 +2738,30 @@ ex_put:
        return err;
 }
 
+int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
+                                        struct mlx4_vhcr *vhcr,
+                                        struct mlx4_cmd_mailbox *inbox,
+                                        struct mlx4_cmd_mailbox *outbox,
+                                        struct mlx4_cmd_info *cmd)
+{
+       return mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
+                           vhcr->in_modifier, 0,
+                           MLX4_QP_FLOW_STEERING_ATTACH,
+                           MLX4_CMD_TIME_CLASS_A,
+                           MLX4_CMD_NATIVE);
+}
+
+int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
+                                        struct mlx4_vhcr *vhcr,
+                                        struct mlx4_cmd_mailbox *inbox,
+                                        struct mlx4_cmd_mailbox *outbox,
+                                        struct mlx4_cmd_info *cmd)
+{
+       return mlx4_cmd(dev, vhcr->in_param, 0, 0,
+                       MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
+                       MLX4_CMD_NATIVE);
+}
+
 enum {
        BUSY_MAX_RETRIES = 10
 };
index 1f3860a8a1099ea1288cbd618cf160290874068e..260695186256eacd0e5c57ad6da5b2db23dfe7e3 100644 (file)
@@ -154,6 +154,10 @@ enum {
        /* set port opcode modifiers */
        MLX4_SET_PORT_PRIO2TC = 0x8,
        MLX4_SET_PORT_SCHEDULER  = 0x9,
+
+       /* register/delete flow steering network rules */
+       MLX4_QP_FLOW_STEERING_ATTACH = 0x65,
+       MLX4_QP_FLOW_STEERING_DETACH = 0x66,
 };
 
 enum {