IB/mlx5: Add packet based credit mode support
authorDanit Goldberg <danitg@mellanox.com>
Fri, 30 Nov 2018 11:22:05 +0000 (13:22 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 7 Dec 2018 20:22:09 +0000 (13:22 -0700)
The device can support two credit modes, message based (default) and
packet based. In order to enable packet based mode, the QP should be
created with special flag that indicates this.

This patch adds support for the new DV QP creation flag that can be used
for RC QPs in order to change the credit mode.

Signed-off-by: Danit Goldberg <danitg@mellanox.com>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/qp.c
include/uapi/rdma/mlx5-abi.h

index 861b68f2e33085da501fe2ed0ddc6253e3286b2a..3e034bc85bde1d01ba0f686465e9d6fadd2d2371 100644 (file)
@@ -461,6 +461,7 @@ enum mlx5_ib_qp_flags {
        MLX5_IB_QP_UNDERLAY                     = 1 << 10,
        MLX5_IB_QP_PCI_WRITE_END_PADDING        = 1 << 11,
        MLX5_IB_QP_TUNNEL_OFFLOAD               = 1 << 12,
+       MLX5_IB_QP_PACKET_BASED_CREDIT          = 1 << 13,
 };
 
 struct mlx5_umr_wr {
index 6841c0f9237fb3c665cffce42cb501f3200897fe..d5095fcd4cdab75e7cea363ed27b4f1541305286 100644 (file)
@@ -1889,7 +1889,8 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
                                              MLX5_QP_FLAG_BFREG_INDEX |
                                              MLX5_QP_FLAG_TYPE_DCT |
                                              MLX5_QP_FLAG_TYPE_DCI |
-                                             MLX5_QP_FLAG_ALLOW_SCATTER_CQE))
+                                             MLX5_QP_FLAG_ALLOW_SCATTER_CQE |
+                                             MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE))
                        return -EINVAL;
 
                err = get_qp_user_index(to_mucontext(pd->uobject->context),
@@ -1925,6 +1926,15 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
                        qp->flags_en |= MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC;
                }
 
+               if (ucmd.flags & MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE) {
+                       if (init_attr->qp_type != IB_QPT_RC ||
+                               !MLX5_CAP_GEN(dev->mdev, qp_packet_based)) {
+                               mlx5_ib_dbg(dev, "packet based credit mode isn't supported\n");
+                               return -EOPNOTSUPP;
+                       }
+                       qp->flags |= MLX5_IB_QP_PACKET_BASED_CREDIT;
+               }
+
                if (init_attr->create_flags & IB_QP_CREATE_SOURCE_QPN) {
                        if (init_attr->qp_type != IB_QPT_UD ||
                            (MLX5_CAP_GEN(dev->mdev, port_type) !=
@@ -2021,7 +2031,8 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
                MLX5_SET(qpc, qpc, cd_slave_send, 1);
        if (qp->flags & MLX5_IB_QP_MANAGED_RECV)
                MLX5_SET(qpc, qpc, cd_slave_receive, 1);
-
+       if (qp->flags & MLX5_IB_QP_PACKET_BASED_CREDIT)
+               MLX5_SET(qpc, qpc, req_e2e_credit_mode, 1);
        if (qp->scat_cqe && is_connected(init_attr->qp_type)) {
                configure_responder_scat_cqe(init_attr, qpc);
                configure_requester_scat_cqe(dev, init_attr,
index 8fa9f90e2bb19b9d566d65318a10d994c555cad6..4af581170f6220794287f754de45ade22ba5aaa3 100644 (file)
@@ -48,6 +48,7 @@ enum {
        MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_UC = 1 << 6,
        MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC = 1 << 7,
        MLX5_QP_FLAG_ALLOW_SCATTER_CQE  = 1 << 8,
+       MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE   = 1 << 9,
 };
 
 enum {