aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDevesh Sharma <Devesh.Sharma@Emulex.Com>2014-02-04 01:27:10 -0500
committerRoland Dreier <roland@purestorage.com>2014-04-03 11:30:06 -0400
commitfad51b7d361b4f1b439aa10fa258a35dac62b297 (patch)
treedf3dc67d74ba56ec36cbe254e178adb8debd0749 /drivers/infiniband
parent334b8db3a6c57bec78bcaacef3b1658bfc6e2efe (diff)
RDMA/ocrdma: Code clean-up
Clean up code. Also modifying GSI QP to error during ocrdma_close is fixed. Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com> Signed-off-by: Selvin Xavier <selvin.xavier@emulex.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma.h6
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_abi.h4
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_ah.c2
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.c20
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_main.c2
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_sli.h16
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_verbs.c21
7 files changed, 24 insertions, 47 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h
index 3042c87a74ba..19011dbb930f 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma.h
@@ -35,6 +35,7 @@
35 35
36#include <rdma/ib_verbs.h> 36#include <rdma/ib_verbs.h>
37#include <rdma/ib_user_verbs.h> 37#include <rdma/ib_user_verbs.h>
38#include <rdma/ib_addr.h>
38 39
39#include <be_roce.h> 40#include <be_roce.h>
40#include "ocrdma_sli.h" 41#include "ocrdma_sli.h"
@@ -234,7 +235,7 @@ struct ocrdma_dev {
234 struct list_head entry; 235 struct list_head entry;
235 struct rcu_head rcu; 236 struct rcu_head rcu;
236 int id; 237 int id;
237 struct ocrdma_mr *stag_arr[OCRDMA_MAX_STAG]; 238 u64 stag_arr[OCRDMA_MAX_STAG];
238 u16 pvid; 239 u16 pvid;
239 u32 asic_id; 240 u32 asic_id;
240 241
@@ -287,7 +288,6 @@ struct ocrdma_cq {
287 288
288struct ocrdma_pd { 289struct ocrdma_pd {
289 struct ib_pd ibpd; 290 struct ib_pd ibpd;
290 struct ocrdma_dev *dev;
291 struct ocrdma_ucontext *uctx; 291 struct ocrdma_ucontext *uctx;
292 u32 id; 292 u32 id;
293 int num_dpp_qp; 293 int num_dpp_qp;
@@ -372,10 +372,8 @@ struct ocrdma_qp {
372 bool dpp_enabled; 372 bool dpp_enabled;
373 u8 *ird_q_va; 373 u8 *ird_q_va;
374 bool signaled; 374 bool signaled;
375 u16 db_cache;
376}; 375};
377 376
378
379struct ocrdma_ucontext { 377struct ocrdma_ucontext {
380 struct ib_ucontext ibucontext; 378 struct ib_ucontext ibucontext;
381 379
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_abi.h b/drivers/infiniband/hw/ocrdma/ocrdma_abi.h
index 5a82ce535181..1554cca5712a 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_abi.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_abi.h
@@ -108,9 +108,7 @@ struct ocrdma_create_qp_uresp {
108 u32 db_sq_offset; 108 u32 db_sq_offset;
109 u32 db_rq_offset; 109 u32 db_rq_offset;
110 u32 db_shift; 110 u32 db_shift;
111 u64 rsvd1; 111 u64 rsvd[11];
112 u64 rsvd2;
113 u64 rsvd3;
114} __packed; 112} __packed;
115 113
116struct ocrdma_create_srq_uresp { 114struct ocrdma_create_srq_uresp {
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 34071143006e..d4cc01f10c01 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -100,7 +100,7 @@ struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr)
100 if (!(attr->ah_flags & IB_AH_GRH)) 100 if (!(attr->ah_flags & IB_AH_GRH))
101 return ERR_PTR(-EINVAL); 101 return ERR_PTR(-EINVAL);
102 102
103 ah = kzalloc(sizeof *ah, GFP_ATOMIC); 103 ah = kzalloc(sizeof(*ah), GFP_ATOMIC);
104 if (!ah) 104 if (!ah)
105 return ERR_PTR(-ENOMEM); 105 return ERR_PTR(-ENOMEM);
106 106
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 5d3485846d87..3bbf2010a821 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -32,7 +32,6 @@
32 32
33#include <rdma/ib_verbs.h> 33#include <rdma/ib_verbs.h>
34#include <rdma/ib_user_verbs.h> 34#include <rdma/ib_user_verbs.h>
35#include <rdma/ib_addr.h>
36 35
37#include "ocrdma.h" 36#include "ocrdma.h"
38#include "ocrdma_hw.h" 37#include "ocrdma_hw.h"
@@ -386,8 +385,8 @@ static void ocrdma_build_q_pages(struct ocrdma_pa *q_pa, int cnt,
386 } 385 }
387} 386}
388 387
389static int ocrdma_mbx_delete_q(struct ocrdma_dev *dev, struct ocrdma_queue_info *q, 388static int ocrdma_mbx_delete_q(struct ocrdma_dev *dev,
390 int queue_type) 389 struct ocrdma_queue_info *q, int queue_type)
391{ 390{
392 u8 opcode = 0; 391 u8 opcode = 0;
393 int status; 392 int status;
@@ -778,7 +777,6 @@ static void ocrdma_process_grp5_aync(struct ocrdma_dev *dev,
778 } 777 }
779} 778}
780 779
781
782static void ocrdma_process_acqe(struct ocrdma_dev *dev, void *ae_cqe) 780static void ocrdma_process_acqe(struct ocrdma_dev *dev, void *ae_cqe)
783{ 781{
784 /* async CQE processing */ 782 /* async CQE processing */
@@ -825,8 +823,6 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id)
825 ocrdma_process_acqe(dev, cqe); 823 ocrdma_process_acqe(dev, cqe);
826 else if (cqe->valid_ae_cmpl_cons & OCRDMA_MCQE_CMPL_MASK) 824 else if (cqe->valid_ae_cmpl_cons & OCRDMA_MCQE_CMPL_MASK)
827 ocrdma_process_mcqe(dev, cqe); 825 ocrdma_process_mcqe(dev, cqe);
828 else
829 pr_err("%s() cqe->compl is not set.\n", __func__);
830 memset(cqe, 0, sizeof(struct ocrdma_mcqe)); 826 memset(cqe, 0, sizeof(struct ocrdma_mcqe));
831 ocrdma_mcq_inc_tail(dev); 827 ocrdma_mcq_inc_tail(dev);
832 } 828 }
@@ -1050,6 +1046,9 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev,
1050 attr->max_qp = 1046 attr->max_qp =
1051 (rsp->qp_srq_cq_ird_ord & OCRDMA_MBX_QUERY_CFG_MAX_QP_MASK) >> 1047 (rsp->qp_srq_cq_ird_ord & OCRDMA_MBX_QUERY_CFG_MAX_QP_MASK) >>
1052 OCRDMA_MBX_QUERY_CFG_MAX_QP_SHIFT; 1048 OCRDMA_MBX_QUERY_CFG_MAX_QP_SHIFT;
1049 attr->max_srq =
1050 (rsp->max_srq_rpir_qps & OCRDMA_MBX_QUERY_CFG_MAX_SRQ_MASK) >>
1051 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_OFFSET;
1053 attr->max_send_sge = ((rsp->max_write_send_sge & 1052 attr->max_send_sge = ((rsp->max_write_send_sge &
1054 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >> 1053 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >>
1055 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT); 1054 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT);
@@ -1065,9 +1064,6 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev,
1065 attr->max_ord_per_qp = (rsp->max_ird_ord_per_qp & 1064 attr->max_ord_per_qp = (rsp->max_ird_ord_per_qp &
1066 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK) >> 1065 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK) >>
1067 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT; 1066 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT;
1068 attr->max_srq =
1069 (rsp->max_srq_rpir_qps & OCRDMA_MBX_QUERY_CFG_MAX_SRQ_MASK) >>
1070 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_OFFSET;
1071 attr->max_ird_per_qp = (rsp->max_ird_ord_per_qp & 1067 attr->max_ird_per_qp = (rsp->max_ird_ord_per_qp &
1072 OCRDMA_MBX_QUERY_CFG_MAX_IRD_PER_QP_MASK) >> 1068 OCRDMA_MBX_QUERY_CFG_MAX_IRD_PER_QP_MASK) >>
1073 OCRDMA_MBX_QUERY_CFG_MAX_IRD_PER_QP_SHIFT; 1069 OCRDMA_MBX_QUERY_CFG_MAX_IRD_PER_QP_SHIFT;
@@ -1411,7 +1407,7 @@ static int ocrdma_build_q_conf(u32 *num_entries, int entry_size,
1411 1407
1412static int ocrdma_mbx_create_ah_tbl(struct ocrdma_dev *dev) 1408static int ocrdma_mbx_create_ah_tbl(struct ocrdma_dev *dev)
1413{ 1409{
1414 int i ; 1410 int i;
1415 int status = 0; 1411 int status = 0;
1416 int max_ah; 1412 int max_ah;
1417 struct ocrdma_create_ah_tbl *cmd; 1413 struct ocrdma_create_ah_tbl *cmd;
@@ -2279,7 +2275,7 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2279 memcpy(&cmd->params.dgid[0], &ah_attr->grh.dgid.raw[0], 2275 memcpy(&cmd->params.dgid[0], &ah_attr->grh.dgid.raw[0],
2280 sizeof(cmd->params.dgid)); 2276 sizeof(cmd->params.dgid));
2281 status = ocrdma_query_gid(&qp->dev->ibdev, 1, 2277 status = ocrdma_query_gid(&qp->dev->ibdev, 1,
2282 ah_attr->grh.sgid_index, &sgid); 2278 ah_attr->grh.sgid_index, &sgid);
2283 if (status) 2279 if (status)
2284 return status; 2280 return status;
2285 2281
@@ -2666,7 +2662,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev)
2666 2662
2667 for (i = 0; i < num_eq; i++) { 2663 for (i = 0; i < num_eq; i++) {
2668 status = ocrdma_create_eq(dev, &dev->eq_tbl[i], 2664 status = ocrdma_create_eq(dev, &dev->eq_tbl[i],
2669 OCRDMA_EQ_LEN); 2665 OCRDMA_EQ_LEN);
2670 if (status) { 2666 if (status) {
2671 status = -EINVAL; 2667 status = -EINVAL;
2672 break; 2668 break;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
index 61248b99f98f..8bd9db689b2f 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
@@ -488,7 +488,7 @@ static int ocrdma_close(struct ocrdma_dev *dev)
488 cur_qp = dev->qp_tbl; 488 cur_qp = dev->qp_tbl;
489 for (i = 0; i < OCRDMA_MAX_QP; i++) { 489 for (i = 0; i < OCRDMA_MAX_QP; i++) {
490 qp = cur_qp[i]; 490 qp = cur_qp[i];
491 if (qp) { 491 if (qp && qp->ibqp.qp_type != IB_QPT_GSI) {
492 /* change the QP state to ERROR */ 492 /* change the QP state to ERROR */
493 _ocrdma_modify_qp(&qp->ibqp, &attrs, attr_mask); 493 _ocrdma_modify_qp(&qp->ibqp, &attrs, attr_mask);
494 494
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h
index 6e048b7283c4..96c9ee602ba4 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h
@@ -152,11 +152,10 @@ enum {
152#define OCRDMA_MIN_Q_PAGE_SIZE (4096) 152#define OCRDMA_MIN_Q_PAGE_SIZE (4096)
153#define OCRDMA_MAX_Q_PAGES (8) 153#define OCRDMA_MAX_Q_PAGES (8)
154 154
155#define OCRDMA_SLI_ASIC_ID_OFFSET 0x9C 155#define OCRDMA_SLI_ASIC_ID_OFFSET 0x9C
156#define OCRDMA_SLI_ASIC_REV_MASK 0x000000FF 156#define OCRDMA_SLI_ASIC_REV_MASK 0x000000FF
157#define OCRDMA_SLI_ASIC_GEN_NUM_MASK 0x0000FF00 157#define OCRDMA_SLI_ASIC_GEN_NUM_MASK 0x0000FF00
158#define OCRDMA_SLI_ASIC_GEN_NUM_SHIFT 0x08 158#define OCRDMA_SLI_ASIC_GEN_NUM_SHIFT 0x08
159
160/* 159/*
161# 0: 4K Bytes 160# 0: 4K Bytes
162# 1: 8K Bytes 161# 1: 8K Bytes
@@ -633,7 +632,7 @@ enum {
633 632
634enum { 633enum {
635 OCRDMA_CREATE_CQ_VER2 = 2, 634 OCRDMA_CREATE_CQ_VER2 = 2,
636 OCRDMA_CREATE_CQ_VER3 = 3, 635 OCRDMA_CREATE_CQ_VER3 = 3,
637 636
638 OCRDMA_CREATE_CQ_PAGE_CNT_MASK = 0xFFFF, 637 OCRDMA_CREATE_CQ_PAGE_CNT_MASK = 0xFFFF,
639 OCRDMA_CREATE_CQ_PAGE_SIZE_SHIFT = 16, 638 OCRDMA_CREATE_CQ_PAGE_SIZE_SHIFT = 16,
@@ -1093,6 +1092,7 @@ enum {
1093 OCRDMA_MODIFY_QP_RSP_MAX_ORD_MASK = 0xFFFF << 1092 OCRDMA_MODIFY_QP_RSP_MAX_ORD_MASK = 0xFFFF <<
1094 OCRDMA_MODIFY_QP_RSP_MAX_ORD_SHIFT 1093 OCRDMA_MODIFY_QP_RSP_MAX_ORD_SHIFT
1095}; 1094};
1095
1096struct ocrdma_modify_qp_rsp { 1096struct ocrdma_modify_qp_rsp {
1097 struct ocrdma_mqe_hdr hdr; 1097 struct ocrdma_mqe_hdr hdr;
1098 struct ocrdma_mbx_rsp rsp; 1098 struct ocrdma_mbx_rsp rsp;
@@ -1105,8 +1105,8 @@ struct ocrdma_query_qp {
1105 struct ocrdma_mqe_hdr hdr; 1105 struct ocrdma_mqe_hdr hdr;
1106 struct ocrdma_mbx_hdr req; 1106 struct ocrdma_mbx_hdr req;
1107 1107
1108#define OCRDMA_QUERY_UP_QP_ID_SHIFT 0 1108#define OCRDMA_QUERY_UP_QP_ID_SHIFT 0
1109#define OCRDMA_QUERY_UP_QP_ID_MASK 0xFFFFFF 1109#define OCRDMA_QUERY_UP_QP_ID_MASK 0xFFFFFF
1110 u32 qp_id; 1110 u32 qp_id;
1111}; 1111};
1112 1112
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 95eeeeb1251b..6d3990f28772 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -53,7 +53,7 @@ int ocrdma_query_gid(struct ib_device *ibdev, u8 port,
53 53
54 dev = get_ocrdma_dev(ibdev); 54 dev = get_ocrdma_dev(ibdev);
55 memset(sgid, 0, sizeof(*sgid)); 55 memset(sgid, 0, sizeof(*sgid));
56 if (index >= OCRDMA_MAX_SGID) 56 if (index > OCRDMA_MAX_SGID)
57 return -EINVAL; 57 return -EINVAL;
58 58
59 memcpy(sgid, &dev->sgid_tbl[index], sizeof(*sgid)); 59 memcpy(sgid, &dev->sgid_tbl[index], sizeof(*sgid));
@@ -144,7 +144,6 @@ static inline void get_link_speed_and_width(struct ocrdma_dev *dev,
144 } 144 }
145} 145}
146 146
147
148int ocrdma_query_port(struct ib_device *ibdev, 147int ocrdma_query_port(struct ib_device *ibdev,
149 u8 port, struct ib_port_attr *props) 148 u8 port, struct ib_port_attr *props)
150{ 149{
@@ -1210,7 +1209,6 @@ static void ocrdma_set_qp_init_params(struct ocrdma_qp *qp,
1210 qp->signaled = (attrs->sq_sig_type == IB_SIGNAL_ALL_WR) ? true : false; 1209 qp->signaled = (attrs->sq_sig_type == IB_SIGNAL_ALL_WR) ? true : false;
1211} 1210}
1212 1211
1213
1214static void ocrdma_store_gsi_qp_cq(struct ocrdma_dev *dev, 1212static void ocrdma_store_gsi_qp_cq(struct ocrdma_dev *dev,
1215 struct ib_qp_init_attr *attrs) 1213 struct ib_qp_init_attr *attrs)
1216{ 1214{
@@ -1296,17 +1294,6 @@ gen_err:
1296 return ERR_PTR(status); 1294 return ERR_PTR(status);
1297} 1295}
1298 1296
1299
1300static void ocrdma_flush_rq_db(struct ocrdma_qp *qp)
1301{
1302 if (qp->db_cache) {
1303 u32 val = qp->rq.dbid | (qp->db_cache <<
1304 OCRDMA_DB_RQ_SHIFT);
1305 iowrite32(val, qp->rq_db);
1306 qp->db_cache = 0;
1307 }
1308}
1309
1310int _ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 1297int _ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1311 int attr_mask) 1298 int attr_mask)
1312{ 1299{
@@ -1325,8 +1312,6 @@ int _ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1325 if (status < 0) 1312 if (status < 0)
1326 return status; 1313 return status;
1327 status = ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask); 1314 status = ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
1328 if (!status && attr_mask & IB_QP_STATE && attr->qp_state == IB_QPS_RTR)
1329 ocrdma_flush_rq_db(qp);
1330 1315
1331 return status; 1316 return status;
1332} 1317}
@@ -2042,7 +2027,7 @@ static int ocrdma_build_fr(struct ocrdma_qp *qp, struct ocrdma_hdr_wqe *hdr,
2042 fast_reg->num_sges = wr->wr.fast_reg.page_list_len; 2027 fast_reg->num_sges = wr->wr.fast_reg.page_list_len;
2043 fast_reg->size_sge = 2028 fast_reg->size_sge =
2044 get_encoded_page_size(1 << wr->wr.fast_reg.page_shift); 2029 get_encoded_page_size(1 << wr->wr.fast_reg.page_shift);
2045 mr = (struct ocrdma_mr *) (unsigned long) qp->dev->stag_arr[(hdr->lkey >> 8) & 2030 mr = (struct ocrdma_mr *)qp->dev->stag_arr[(hdr->lkey >> 8) &
2046 (OCRDMA_MAX_STAG - 1)]; 2031 (OCRDMA_MAX_STAG - 1)];
2047 build_frmr_pbes(wr, mr->hwmr.pbl_table, &mr->hwmr); 2032 build_frmr_pbes(wr, mr->hwmr.pbl_table, &mr->hwmr);
2048 return 0; 2033 return 0;
@@ -2877,7 +2862,7 @@ struct ib_mr *ocrdma_alloc_frmr(struct ib_pd *ibpd, int max_page_list_len)
2877 goto mbx_err; 2862 goto mbx_err;
2878 mr->ibmr.rkey = mr->hwmr.lkey; 2863 mr->ibmr.rkey = mr->hwmr.lkey;
2879 mr->ibmr.lkey = mr->hwmr.lkey; 2864 mr->ibmr.lkey = mr->hwmr.lkey;
2880 dev->stag_arr[(mr->hwmr.lkey >> 8) & (OCRDMA_MAX_STAG - 1)] = mr; 2865 dev->stag_arr[(mr->hwmr.lkey >> 8) & (OCRDMA_MAX_STAG - 1)] = (u64)mr;
2881 return &mr->ibmr; 2866 return &mr->ibmr;
2882mbx_err: 2867mbx_err:
2883 ocrdma_free_mr_pbl_tbl(dev, &mr->hwmr); 2868 ocrdma_free_mr_pbl_tbl(dev, &mr->hwmr);