mlx5_{ib,core}: Add query SQ state helper function
authorEran Ben Elisha <eranbe@mellanox.com>
Tue, 26 Dec 2017 13:17:05 +0000 (15:17 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 28 Mar 2018 00:17:28 +0000 (17:17 -0700)
Move query SQ state function from mlx5_ib to mlx5_core in order to
have it in shared code.

It will be used in a downstream patch from mlx5e.

Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/infiniband/hw/mlx5/qp.c
drivers/net/ethernet/mellanox/mlx5/core/transobj.c
include/linux/mlx5/transobj.h

index 85c612ac547a4ca4a221892483c3cb474743b62b..0d0b0b8dad98bfbade4588e3c2873d639bd32257 100644 (file)
@@ -4739,26 +4739,14 @@ static int query_raw_packet_qp_sq_state(struct mlx5_ib_dev *dev,
                                        struct mlx5_ib_sq *sq,
                                        u8 *sq_state)
 {
-       void *out;
-       void *sqc;
-       int inlen;
        int err;
 
-       inlen = MLX5_ST_SZ_BYTES(query_sq_out);
-       out = kvzalloc(inlen, GFP_KERNEL);
-       if (!out)
-               return -ENOMEM;
-
-       err = mlx5_core_query_sq(dev->mdev, sq->base.mqp.qpn, out);
+       err = mlx5_core_query_sq_state(dev->mdev, sq->base.mqp.qpn, sq_state);
        if (err)
                goto out;
-
-       sqc = MLX5_ADDR_OF(query_sq_out, out, sq_context);
-       *sq_state = MLX5_GET(sqc, sqc, state);
        sq->state = *sq_state;
 
 out:
-       kvfree(out);
        return err;
 }
 
index 9e38343a951f0acf910e3ae0e7be0c8f04160938..c64957b5ef47e9cd81111744379a1f9537af7361 100644 (file)
@@ -157,6 +157,31 @@ int mlx5_core_query_sq(struct mlx5_core_dev *dev, u32 sqn, u32 *out)
 }
 EXPORT_SYMBOL(mlx5_core_query_sq);
 
+int mlx5_core_query_sq_state(struct mlx5_core_dev *dev, u32 sqn, u8 *state)
+{
+       void *out;
+       void *sqc;
+       int inlen;
+       int err;
+
+       inlen = MLX5_ST_SZ_BYTES(query_sq_out);
+       out = kvzalloc(inlen, GFP_KERNEL);
+       if (!out)
+               return -ENOMEM;
+
+       err = mlx5_core_query_sq(dev, sqn, out);
+       if (err)
+               goto out;
+
+       sqc = MLX5_ADDR_OF(query_sq_out, out, sq_context);
+       *state = MLX5_GET(sqc, sqc, state);
+
+out:
+       kvfree(out);
+       return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_core_query_sq_state);
+
 int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen,
                         u32 *tirn)
 {
index 7e8f281f8c0004c22457a18b51ce95856277e4a9..80d7aa8b2831ddb8a8f8b5376ec1777c217b91b8 100644 (file)
@@ -47,6 +47,7 @@ int mlx5_core_create_sq(struct mlx5_core_dev *dev, u32 *in, int inlen,
 int mlx5_core_modify_sq(struct mlx5_core_dev *dev, u32 sqn, u32 *in, int inlen);
 void mlx5_core_destroy_sq(struct mlx5_core_dev *dev, u32 sqn);
 int mlx5_core_query_sq(struct mlx5_core_dev *dev, u32 sqn, u32 *out);
+int mlx5_core_query_sq_state(struct mlx5_core_dev *dev, u32 sqn, u8 *state);
 int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen,
                         u32 *tirn);
 int mlx5_core_modify_tir(struct mlx5_core_dev *dev, u32 tirn, u32 *in,