Skip to content

Commit b636401

Browse files
Sagi Grimbergdledford
authored andcommitted
mlx5: Fix incorrect wc pkey_index assignment for GSI messages
Since patch series "Demux IB CM requests in the rdma_cm module" the P_Key index is taken from the work completion rather than the message itself. The HCA provides us with the message P_Key. In order to provide the P_Key index, we need to look it up. Given that this is relevant only for GSI messages (session establishments) which is less performance critical, micro-optimize against the GSI (is_qp1) branch. Fixes: 4c21b5b ("IB/cma: Add net_dev and private data checks to RDMA CM") Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 11d7480 commit b636401

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎drivers/infiniband/hw/mlx5/cq.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/kref.h>
3434
#include <rdma/ib_umem.h>
3535
#include <rdma/ib_user_verbs.h>
36+
#include <rdma/ib_cache.h>
3637
#include "mlx5_ib.h"
3738
#include "user.h"
3839

@@ -227,7 +228,14 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
227228
wc->dlid_path_bits = cqe->ml_path;
228229
g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3;
229230
wc->wc_flags |= g ? IB_WC_GRH : 0;
230-
wc->pkey_index = be32_to_cpu(cqe->imm_inval_pkey) & 0xffff;
231+
if (unlikely(is_qp1(qp->ibqp.qp_type))) {
232+
u16 pkey = be32_to_cpu(cqe->imm_inval_pkey) & 0xffff;
233+
234+
ib_find_cached_pkey(&dev->ib_dev, qp->port, pkey,
235+
&wc->pkey_index);
236+
} else {
237+
wc->pkey_index = 0;
238+
}
231239
}
232240

233241
static void dump_cqe(struct mlx5_ib_dev *dev, struct mlx5_err_cqe *cqe)

‎drivers/infiniband/hw/mlx5/mlx5_ib.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ static inline u8 convert_access(int acc)
680680
MLX5_PERM_LOCAL_READ;
681681
}
682682

683+
static inline int is_qp1(enum ib_qp_type qp_type)
684+
{
685+
return qp_type == IB_QPT_GSI;
686+
}
687+
683688
#define MLX5_MAX_UMR_SHIFT 16
684689
#define MLX5_MAX_UMR_PAGES (1 << MLX5_MAX_UMR_SHIFT)
685690

‎drivers/infiniband/hw/mlx5/qp.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ static int is_qp0(enum ib_qp_type qp_type)
7676
return qp_type == IB_QPT_SMI;
7777
}
7878

79-
static int is_qp1(enum ib_qp_type qp_type)
80-
{
81-
return qp_type == IB_QPT_GSI;
82-
}
83-
8479
static int is_sqp(enum ib_qp_type qp_type)
8580
{
8681
return is_qp0(qp_type) || is_qp1(qp_type);

0 commit comments

Comments
 (0)