diff options
Diffstat (limited to 'drivers/infiniband/hw/cxgb3')
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_hal.c | 27 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_hal.h | 5 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_wr.h | 103 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch.c | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch.h | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_cq.c | 15 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.c | 199 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.h | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_qp.c | 261 |
9 files changed, 512 insertions, 116 deletions
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c index 3f441fc57c17..f6d5747153a5 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.c +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c | |||
@@ -145,7 +145,9 @@ static int cxio_hal_clear_qp_ctx(struct cxio_rdev *rdev_p, u32 qpid) | |||
145 | } | 145 | } |
146 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); | 146 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); |
147 | memset(wqe, 0, sizeof(*wqe)); | 147 | memset(wqe, 0, sizeof(*wqe)); |
148 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 3, 0, qpid, 7); | 148 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, |
149 | T3_COMPLETION_FLAG | T3_NOTIFY_FLAG, 0, qpid, 7, | ||
150 | T3_SOPEOP); | ||
149 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); | 151 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); |
150 | sge_cmd = qpid << 8 | 3; | 152 | sge_cmd = qpid << 8 | 3; |
151 | wqe->sge_cmd = cpu_to_be64(sge_cmd); | 153 | wqe->sge_cmd = cpu_to_be64(sge_cmd); |
@@ -276,7 +278,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, | |||
276 | if (!wq->qpid) | 278 | if (!wq->qpid) |
277 | return -ENOMEM; | 279 | return -ENOMEM; |
278 | 280 | ||
279 | wq->rq = kzalloc(depth * sizeof(u64), GFP_KERNEL); | 281 | wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL); |
280 | if (!wq->rq) | 282 | if (!wq->rq) |
281 | goto err1; | 283 | goto err1; |
282 | 284 | ||
@@ -300,6 +302,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, | |||
300 | if (!kernel_domain) | 302 | if (!kernel_domain) |
301 | wq->udb = (u64)rdev_p->rnic_info.udbell_physbase + | 303 | wq->udb = (u64)rdev_p->rnic_info.udbell_physbase + |
302 | (wq->qpid << rdev_p->qpshift); | 304 | (wq->qpid << rdev_p->qpshift); |
305 | wq->rdev = rdev_p; | ||
303 | PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __func__, | 306 | PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __func__, |
304 | wq->qpid, wq->doorbell, (unsigned long long) wq->udb); | 307 | wq->qpid, wq->doorbell, (unsigned long long) wq->udb); |
305 | return 0; | 308 | return 0; |
@@ -558,7 +561,7 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p) | |||
558 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); | 561 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); |
559 | memset(wqe, 0, sizeof(*wqe)); | 562 | memset(wqe, 0, sizeof(*wqe)); |
560 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, | 563 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, |
561 | T3_CTL_QP_TID, 7); | 564 | T3_CTL_QP_TID, 7, T3_SOPEOP); |
562 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); | 565 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); |
563 | sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; | 566 | sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; |
564 | wqe->sge_cmd = cpu_to_be64(sge_cmd); | 567 | wqe->sge_cmd = cpu_to_be64(sge_cmd); |
@@ -674,7 +677,7 @@ static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr, | |||
674 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag, | 677 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag, |
675 | Q_GENBIT(rdev_p->ctrl_qp.wptr, | 678 | Q_GENBIT(rdev_p->ctrl_qp.wptr, |
676 | T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, | 679 | T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, |
677 | wr_len); | 680 | wr_len, T3_SOPEOP); |
678 | if (flag == T3_COMPLETION_FLAG) | 681 | if (flag == T3_COMPLETION_FLAG) |
679 | ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); | 682 | ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); |
680 | len -= 96; | 683 | len -= 96; |
@@ -816,6 +819,13 @@ int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag) | |||
816 | 0, 0); | 819 | 0, 0); |
817 | } | 820 | } |
818 | 821 | ||
822 | int cxio_allocate_stag(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr) | ||
823 | { | ||
824 | *stag = T3_STAG_UNSET; | ||
825 | return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_NON_SHARED_MR, | ||
826 | 0, 0, 0ULL, 0, 0, pbl_size, pbl_addr); | ||
827 | } | ||
828 | |||
819 | int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) | 829 | int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) |
820 | { | 830 | { |
821 | struct t3_rdma_init_wr *wqe; | 831 | struct t3_rdma_init_wr *wqe; |
@@ -1257,13 +1267,16 @@ proc_cqe: | |||
1257 | wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe); | 1267 | wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe); |
1258 | PDBG("%s completing sq idx %ld\n", __func__, | 1268 | PDBG("%s completing sq idx %ld\n", __func__, |
1259 | Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)); | 1269 | Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)); |
1260 | *cookie = (wq->sq + | 1270 | *cookie = wq->sq[Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)].wr_id; |
1261 | Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2))->wr_id; | ||
1262 | wq->sq_rptr++; | 1271 | wq->sq_rptr++; |
1263 | } else { | 1272 | } else { |
1264 | PDBG("%s completing rq idx %ld\n", __func__, | 1273 | PDBG("%s completing rq idx %ld\n", __func__, |
1265 | Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); | 1274 | Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); |
1266 | *cookie = *(wq->rq + Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); | 1275 | *cookie = wq->rq[Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)].wr_id; |
1276 | if (wq->rq[Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)].pbl_addr) | ||
1277 | cxio_hal_pblpool_free(wq->rdev, | ||
1278 | wq->rq[Q_PTR2IDX(wq->rq_rptr, | ||
1279 | wq->rq_size_log2)].pbl_addr, T3_STAG0_PBL_SIZE); | ||
1267 | wq->rq_rptr++; | 1280 | wq->rq_rptr++; |
1268 | } | 1281 | } |
1269 | 1282 | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h index 6e128f6bab05..656fe47bc84f 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.h +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h | |||
@@ -45,15 +45,17 @@ | |||
45 | #define T3_CTRL_QP_SIZE_LOG2 8 | 45 | #define T3_CTRL_QP_SIZE_LOG2 8 |
46 | #define T3_CTRL_CQ_ID 0 | 46 | #define T3_CTRL_CQ_ID 0 |
47 | 47 | ||
48 | /* TBD */ | ||
49 | #define T3_MAX_NUM_RI (1<<15) | 48 | #define T3_MAX_NUM_RI (1<<15) |
50 | #define T3_MAX_NUM_QP (1<<15) | 49 | #define T3_MAX_NUM_QP (1<<15) |
51 | #define T3_MAX_NUM_CQ (1<<15) | 50 | #define T3_MAX_NUM_CQ (1<<15) |
52 | #define T3_MAX_NUM_PD (1<<15) | 51 | #define T3_MAX_NUM_PD (1<<15) |
53 | #define T3_MAX_PBL_SIZE 256 | 52 | #define T3_MAX_PBL_SIZE 256 |
54 | #define T3_MAX_RQ_SIZE 1024 | 53 | #define T3_MAX_RQ_SIZE 1024 |
54 | #define T3_MAX_QP_DEPTH (T3_MAX_RQ_SIZE-1) | ||
55 | #define T3_MAX_CQ_DEPTH 8192 | ||
55 | #define T3_MAX_NUM_STAG (1<<15) | 56 | #define T3_MAX_NUM_STAG (1<<15) |
56 | #define T3_MAX_MR_SIZE 0x100000000ULL | 57 | #define T3_MAX_MR_SIZE 0x100000000ULL |
58 | #define T3_PAGESIZE_MASK 0xffff000 /* 4KB-128MB */ | ||
57 | 59 | ||
58 | #define T3_STAG_UNSET 0xffffffff | 60 | #define T3_STAG_UNSET 0xffffffff |
59 | 61 | ||
@@ -165,6 +167,7 @@ int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid, | |||
165 | int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, | 167 | int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, |
166 | u32 pbl_addr); | 168 | u32 pbl_addr); |
167 | int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); | 169 | int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); |
170 | int cxio_allocate_stag(struct cxio_rdev *rdev, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr); | ||
168 | int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag); | 171 | int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag); |
169 | int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr); | 172 | int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr); |
170 | void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb); | 173 | void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb); |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_wr.h b/drivers/infiniband/hw/cxgb3/cxio_wr.h index f1a25a821a45..04618f7bfbb3 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_wr.h +++ b/drivers/infiniband/hw/cxgb3/cxio_wr.h | |||
@@ -39,6 +39,9 @@ | |||
39 | 39 | ||
40 | #define T3_MAX_SGE 4 | 40 | #define T3_MAX_SGE 4 |
41 | #define T3_MAX_INLINE 64 | 41 | #define T3_MAX_INLINE 64 |
42 | #define T3_STAG0_PBL_SIZE (2 * T3_MAX_SGE << 3) | ||
43 | #define T3_STAG0_MAX_PBE_LEN (128 * 1024 * 1024) | ||
44 | #define T3_STAG0_PAGE_SHIFT 15 | ||
42 | 45 | ||
43 | #define Q_EMPTY(rptr,wptr) ((rptr)==(wptr)) | 46 | #define Q_EMPTY(rptr,wptr) ((rptr)==(wptr)) |
44 | #define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \ | 47 | #define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \ |
@@ -72,7 +75,8 @@ enum t3_wr_opcode { | |||
72 | T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, | 75 | T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, |
73 | T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, | 76 | T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, |
74 | T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, | 77 | T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, |
75 | T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP | 78 | T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP, |
79 | T3_WR_FASTREG = FW_WROPCODE_RI_FASTREGISTER_MR | ||
76 | } __attribute__ ((packed)); | 80 | } __attribute__ ((packed)); |
77 | 81 | ||
78 | enum t3_rdma_opcode { | 82 | enum t3_rdma_opcode { |
@@ -89,7 +93,8 @@ enum t3_rdma_opcode { | |||
89 | T3_FAST_REGISTER, | 93 | T3_FAST_REGISTER, |
90 | T3_LOCAL_INV, | 94 | T3_LOCAL_INV, |
91 | T3_QP_MOD, | 95 | T3_QP_MOD, |
92 | T3_BYPASS | 96 | T3_BYPASS, |
97 | T3_RDMA_READ_REQ_WITH_INV, | ||
93 | } __attribute__ ((packed)); | 98 | } __attribute__ ((packed)); |
94 | 99 | ||
95 | static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) | 100 | static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) |
@@ -103,6 +108,7 @@ static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) | |||
103 | case T3_WR_BIND: return T3_BIND_MW; | 108 | case T3_WR_BIND: return T3_BIND_MW; |
104 | case T3_WR_INIT: return T3_RDMA_INIT; | 109 | case T3_WR_INIT: return T3_RDMA_INIT; |
105 | case T3_WR_QP_MOD: return T3_QP_MOD; | 110 | case T3_WR_QP_MOD: return T3_QP_MOD; |
111 | case T3_WR_FASTREG: return T3_FAST_REGISTER; | ||
106 | default: break; | 112 | default: break; |
107 | } | 113 | } |
108 | return -1; | 114 | return -1; |
@@ -170,11 +176,54 @@ struct t3_send_wr { | |||
170 | struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ | 176 | struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ |
171 | }; | 177 | }; |
172 | 178 | ||
179 | #define T3_MAX_FASTREG_DEPTH 24 | ||
180 | #define T3_MAX_FASTREG_FRAG 10 | ||
181 | |||
182 | struct t3_fastreg_wr { | ||
183 | struct fw_riwrh wrh; /* 0 */ | ||
184 | union t3_wrid wrid; /* 1 */ | ||
185 | __be32 stag; /* 2 */ | ||
186 | __be32 len; | ||
187 | __be32 va_base_hi; /* 3 */ | ||
188 | __be32 va_base_lo_fbo; | ||
189 | __be32 page_type_perms; /* 4 */ | ||
190 | __be32 reserved1; | ||
191 | __be64 pbl_addrs[0]; /* 5+ */ | ||
192 | }; | ||
193 | |||
194 | /* | ||
195 | * If a fastreg wr spans multiple wqes, then the 2nd fragment look like this. | ||
196 | */ | ||
197 | struct t3_pbl_frag { | ||
198 | struct fw_riwrh wrh; /* 0 */ | ||
199 | __be64 pbl_addrs[14]; /* 1..14 */ | ||
200 | }; | ||
201 | |||
202 | #define S_FR_PAGE_COUNT 24 | ||
203 | #define M_FR_PAGE_COUNT 0xff | ||
204 | #define V_FR_PAGE_COUNT(x) ((x) << S_FR_PAGE_COUNT) | ||
205 | #define G_FR_PAGE_COUNT(x) ((((x) >> S_FR_PAGE_COUNT)) & M_FR_PAGE_COUNT) | ||
206 | |||
207 | #define S_FR_PAGE_SIZE 16 | ||
208 | #define M_FR_PAGE_SIZE 0x1f | ||
209 | #define V_FR_PAGE_SIZE(x) ((x) << S_FR_PAGE_SIZE) | ||
210 | #define G_FR_PAGE_SIZE(x) ((((x) >> S_FR_PAGE_SIZE)) & M_FR_PAGE_SIZE) | ||
211 | |||
212 | #define S_FR_TYPE 8 | ||
213 | #define M_FR_TYPE 0x1 | ||
214 | #define V_FR_TYPE(x) ((x) << S_FR_TYPE) | ||
215 | #define G_FR_TYPE(x) ((((x) >> S_FR_TYPE)) & M_FR_TYPE) | ||
216 | |||
217 | #define S_FR_PERMS 0 | ||
218 | #define M_FR_PERMS 0xff | ||
219 | #define V_FR_PERMS(x) ((x) << S_FR_PERMS) | ||
220 | #define G_FR_PERMS(x) ((((x) >> S_FR_PERMS)) & M_FR_PERMS) | ||
221 | |||
173 | struct t3_local_inv_wr { | 222 | struct t3_local_inv_wr { |
174 | struct fw_riwrh wrh; /* 0 */ | 223 | struct fw_riwrh wrh; /* 0 */ |
175 | union t3_wrid wrid; /* 1 */ | 224 | union t3_wrid wrid; /* 1 */ |
176 | __be32 stag; /* 2 */ | 225 | __be32 stag; /* 2 */ |
177 | __be32 reserved3; | 226 | __be32 reserved; |
178 | }; | 227 | }; |
179 | 228 | ||
180 | struct t3_rdma_write_wr { | 229 | struct t3_rdma_write_wr { |
@@ -193,7 +242,8 @@ struct t3_rdma_read_wr { | |||
193 | struct fw_riwrh wrh; /* 0 */ | 242 | struct fw_riwrh wrh; /* 0 */ |
194 | union t3_wrid wrid; /* 1 */ | 243 | union t3_wrid wrid; /* 1 */ |
195 | u8 rdmaop; /* 2 */ | 244 | u8 rdmaop; /* 2 */ |
196 | u8 reserved[3]; | 245 | u8 local_inv; |
246 | u8 reserved[2]; | ||
197 | __be32 rem_stag; | 247 | __be32 rem_stag; |
198 | __be64 rem_to; /* 3 */ | 248 | __be64 rem_to; /* 3 */ |
199 | __be32 local_stag; /* 4 */ | 249 | __be32 local_stag; /* 4 */ |
@@ -201,18 +251,6 @@ struct t3_rdma_read_wr { | |||
201 | __be64 local_to; /* 5 */ | 251 | __be64 local_to; /* 5 */ |
202 | }; | 252 | }; |
203 | 253 | ||
204 | enum t3_addr_type { | ||
205 | T3_VA_BASED_TO = 0x0, | ||
206 | T3_ZERO_BASED_TO = 0x1 | ||
207 | } __attribute__ ((packed)); | ||
208 | |||
209 | enum t3_mem_perms { | ||
210 | T3_MEM_ACCESS_LOCAL_READ = 0x1, | ||
211 | T3_MEM_ACCESS_LOCAL_WRITE = 0x2, | ||
212 | T3_MEM_ACCESS_REM_READ = 0x4, | ||
213 | T3_MEM_ACCESS_REM_WRITE = 0x8 | ||
214 | } __attribute__ ((packed)); | ||
215 | |||
216 | struct t3_bind_mw_wr { | 254 | struct t3_bind_mw_wr { |
217 | struct fw_riwrh wrh; /* 0 */ | 255 | struct fw_riwrh wrh; /* 0 */ |
218 | union t3_wrid wrid; /* 1 */ | 256 | union t3_wrid wrid; /* 1 */ |
@@ -336,6 +374,11 @@ struct t3_genbit { | |||
336 | __be64 genbit; | 374 | __be64 genbit; |
337 | }; | 375 | }; |
338 | 376 | ||
377 | struct t3_wq_in_err { | ||
378 | u64 flit[13]; | ||
379 | u64 err; | ||
380 | }; | ||
381 | |||
339 | enum rdma_init_wr_flags { | 382 | enum rdma_init_wr_flags { |
340 | MPA_INITIATOR = (1<<0), | 383 | MPA_INITIATOR = (1<<0), |
341 | PRIV_QP = (1<<1), | 384 | PRIV_QP = (1<<1), |
@@ -346,13 +389,16 @@ union t3_wr { | |||
346 | struct t3_rdma_write_wr write; | 389 | struct t3_rdma_write_wr write; |
347 | struct t3_rdma_read_wr read; | 390 | struct t3_rdma_read_wr read; |
348 | struct t3_receive_wr recv; | 391 | struct t3_receive_wr recv; |
392 | struct t3_fastreg_wr fastreg; | ||
393 | struct t3_pbl_frag pbl_frag; | ||
349 | struct t3_local_inv_wr local_inv; | 394 | struct t3_local_inv_wr local_inv; |
350 | struct t3_bind_mw_wr bind; | 395 | struct t3_bind_mw_wr bind; |
351 | struct t3_bypass_wr bypass; | 396 | struct t3_bypass_wr bypass; |
352 | struct t3_rdma_init_wr init; | 397 | struct t3_rdma_init_wr init; |
353 | struct t3_modify_qp_wr qp_mod; | 398 | struct t3_modify_qp_wr qp_mod; |
354 | struct t3_genbit genbit; | 399 | struct t3_genbit genbit; |
355 | u64 flit[16]; | 400 | struct t3_wq_in_err wq_in_err; |
401 | __be64 flit[16]; | ||
356 | }; | 402 | }; |
357 | 403 | ||
358 | #define T3_SQ_CQE_FLIT 13 | 404 | #define T3_SQ_CQE_FLIT 13 |
@@ -366,12 +412,18 @@ static inline enum t3_wr_opcode fw_riwrh_opcode(struct fw_riwrh *wqe) | |||
366 | return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags)); | 412 | return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags)); |
367 | } | 413 | } |
368 | 414 | ||
415 | enum t3_wr_hdr_bits { | ||
416 | T3_EOP = 1, | ||
417 | T3_SOP = 2, | ||
418 | T3_SOPEOP = T3_EOP|T3_SOP, | ||
419 | }; | ||
420 | |||
369 | static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, | 421 | static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, |
370 | enum t3_wr_flags flags, u8 genbit, u32 tid, | 422 | enum t3_wr_flags flags, u8 genbit, u32 tid, |
371 | u8 len) | 423 | u8 len, u8 sopeop) |
372 | { | 424 | { |
373 | wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | | 425 | wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | |
374 | V_FW_RIWR_SOPEOP(M_FW_RIWR_SOPEOP) | | 426 | V_FW_RIWR_SOPEOP(sopeop) | |
375 | V_FW_RIWR_FLAGS(flags)); | 427 | V_FW_RIWR_FLAGS(flags)); |
376 | wmb(); | 428 | wmb(); |
377 | wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | | 429 | wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | |
@@ -404,6 +456,7 @@ enum tpt_addr_type { | |||
404 | }; | 456 | }; |
405 | 457 | ||
406 | enum tpt_mem_perm { | 458 | enum tpt_mem_perm { |
459 | TPT_MW_BIND = 0x10, | ||
407 | TPT_LOCAL_READ = 0x8, | 460 | TPT_LOCAL_READ = 0x8, |
408 | TPT_LOCAL_WRITE = 0x4, | 461 | TPT_LOCAL_WRITE = 0x4, |
409 | TPT_REMOTE_READ = 0x2, | 462 | TPT_REMOTE_READ = 0x2, |
@@ -615,6 +668,11 @@ struct t3_swsq { | |||
615 | int signaled; | 668 | int signaled; |
616 | }; | 669 | }; |
617 | 670 | ||
671 | struct t3_swrq { | ||
672 | __u64 wr_id; | ||
673 | __u32 pbl_addr; | ||
674 | }; | ||
675 | |||
618 | /* | 676 | /* |
619 | * A T3 WQ implements both the SQ and RQ. | 677 | * A T3 WQ implements both the SQ and RQ. |
620 | */ | 678 | */ |
@@ -631,14 +689,15 @@ struct t3_wq { | |||
631 | u32 sq_wptr; /* sq_wptr - sq_rptr == count of */ | 689 | u32 sq_wptr; /* sq_wptr - sq_rptr == count of */ |
632 | u32 sq_rptr; /* pending wrs */ | 690 | u32 sq_rptr; /* pending wrs */ |
633 | u32 sq_size_log2; /* sq size */ | 691 | u32 sq_size_log2; /* sq size */ |
634 | u64 *rq; /* SW RQ (holds consumer wr_ids */ | 692 | struct t3_swrq *rq; /* SW RQ (holds consumer wr_ids */ |
635 | u32 rq_wptr; /* rq_wptr - rq_rptr == count of */ | 693 | u32 rq_wptr; /* rq_wptr - rq_rptr == count of */ |
636 | u32 rq_rptr; /* pending wrs */ | 694 | u32 rq_rptr; /* pending wrs */ |
637 | u64 *rq_oldest_wr; /* oldest wr on the SW RQ */ | 695 | struct t3_swrq *rq_oldest_wr; /* oldest wr on the SW RQ */ |
638 | u32 rq_size_log2; /* rq size */ | 696 | u32 rq_size_log2; /* rq size */ |
639 | u32 rq_addr; /* rq adapter address */ | 697 | u32 rq_addr; /* rq adapter address */ |
640 | void __iomem *doorbell; /* kernel db */ | 698 | void __iomem *doorbell; /* kernel db */ |
641 | u64 udb; /* user db if any */ | 699 | u64 udb; /* user db if any */ |
700 | struct cxio_rdev *rdev; | ||
642 | }; | 701 | }; |
643 | 702 | ||
644 | struct t3_cq { | 703 | struct t3_cq { |
@@ -659,7 +718,7 @@ struct t3_cq { | |||
659 | 718 | ||
660 | static inline void cxio_set_wq_in_error(struct t3_wq *wq) | 719 | static inline void cxio_set_wq_in_error(struct t3_wq *wq) |
661 | { | 720 | { |
662 | wq->queue->flit[13] = 1; | 721 | wq->queue->wq_in_err.err = 1; |
663 | } | 722 | } |
664 | 723 | ||
665 | static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) | 724 | static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) |
diff --git a/drivers/infiniband/hw/cxgb3/iwch.c b/drivers/infiniband/hw/cxgb3/iwch.c index 71554eacb13c..4489c89d6710 100644 --- a/drivers/infiniband/hw/cxgb3/iwch.c +++ b/drivers/infiniband/hw/cxgb3/iwch.c | |||
@@ -71,18 +71,16 @@ static void rnic_init(struct iwch_dev *rnicp) | |||
71 | idr_init(&rnicp->mmidr); | 71 | idr_init(&rnicp->mmidr); |
72 | spin_lock_init(&rnicp->lock); | 72 | spin_lock_init(&rnicp->lock); |
73 | 73 | ||
74 | rnicp->attr.vendor_id = 0x168; | ||
75 | rnicp->attr.vendor_part_id = 7; | ||
76 | rnicp->attr.max_qps = T3_MAX_NUM_QP - 32; | 74 | rnicp->attr.max_qps = T3_MAX_NUM_QP - 32; |
77 | rnicp->attr.max_wrs = (1UL << 24) - 1; | 75 | rnicp->attr.max_wrs = T3_MAX_QP_DEPTH; |
78 | rnicp->attr.max_sge_per_wr = T3_MAX_SGE; | 76 | rnicp->attr.max_sge_per_wr = T3_MAX_SGE; |
79 | rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE; | 77 | rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE; |
80 | rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1; | 78 | rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1; |
81 | rnicp->attr.max_cqes_per_cq = (1UL << 24) - 1; | 79 | rnicp->attr.max_cqes_per_cq = T3_MAX_CQ_DEPTH; |
82 | rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev); | 80 | rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev); |
83 | rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE; | 81 | rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE; |
84 | rnicp->attr.max_pds = T3_MAX_NUM_PD - 1; | 82 | rnicp->attr.max_pds = T3_MAX_NUM_PD - 1; |
85 | rnicp->attr.mem_pgsizes_bitmask = 0x7FFF; /* 4KB-128MB */ | 83 | rnicp->attr.mem_pgsizes_bitmask = T3_PAGESIZE_MASK; |
86 | rnicp->attr.max_mr_size = T3_MAX_MR_SIZE; | 84 | rnicp->attr.max_mr_size = T3_MAX_MR_SIZE; |
87 | rnicp->attr.can_resize_wq = 0; | 85 | rnicp->attr.can_resize_wq = 0; |
88 | rnicp->attr.max_rdma_reads_per_qp = 8; | 86 | rnicp->attr.max_rdma_reads_per_qp = 8; |
diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h index d2409a505e8d..3773453b2cf0 100644 --- a/drivers/infiniband/hw/cxgb3/iwch.h +++ b/drivers/infiniband/hw/cxgb3/iwch.h | |||
@@ -48,8 +48,6 @@ struct iwch_qp; | |||
48 | struct iwch_mr; | 48 | struct iwch_mr; |
49 | 49 | ||
50 | struct iwch_rnic_attributes { | 50 | struct iwch_rnic_attributes { |
51 | u32 vendor_id; | ||
52 | u32 vendor_part_id; | ||
53 | u32 max_qps; | 51 | u32 max_qps; |
54 | u32 max_wrs; /* Max for any SQ/RQ */ | 52 | u32 max_wrs; /* Max for any SQ/RQ */ |
55 | u32 max_sge_per_wr; | 53 | u32 max_sge_per_wr; |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cq.c b/drivers/infiniband/hw/cxgb3/iwch_cq.c index 4ee8ccd0a9e5..cf5474ae68ff 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cq.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cq.c | |||
@@ -81,6 +81,7 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp, | |||
81 | wc->wr_id = cookie; | 81 | wc->wr_id = cookie; |
82 | wc->qp = &qhp->ibqp; | 82 | wc->qp = &qhp->ibqp; |
83 | wc->vendor_err = CQE_STATUS(cqe); | 83 | wc->vendor_err = CQE_STATUS(cqe); |
84 | wc->wc_flags = 0; | ||
84 | 85 | ||
85 | PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " | 86 | PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " |
86 | "lo 0x%x cookie 0x%llx\n", __func__, | 87 | "lo 0x%x cookie 0x%llx\n", __func__, |
@@ -94,6 +95,11 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp, | |||
94 | else | 95 | else |
95 | wc->byte_len = 0; | 96 | wc->byte_len = 0; |
96 | wc->opcode = IB_WC_RECV; | 97 | wc->opcode = IB_WC_RECV; |
98 | if (CQE_OPCODE(cqe) == T3_SEND_WITH_INV || | ||
99 | CQE_OPCODE(cqe) == T3_SEND_WITH_SE_INV) { | ||
100 | wc->ex.invalidate_rkey = CQE_WRID_STAG(cqe); | ||
101 | wc->wc_flags |= IB_WC_WITH_INVALIDATE; | ||
102 | } | ||
97 | } else { | 103 | } else { |
98 | switch (CQE_OPCODE(cqe)) { | 104 | switch (CQE_OPCODE(cqe)) { |
99 | case T3_RDMA_WRITE: | 105 | case T3_RDMA_WRITE: |
@@ -105,17 +111,20 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp, | |||
105 | break; | 111 | break; |
106 | case T3_SEND: | 112 | case T3_SEND: |
107 | case T3_SEND_WITH_SE: | 113 | case T3_SEND_WITH_SE: |
114 | case T3_SEND_WITH_INV: | ||
115 | case T3_SEND_WITH_SE_INV: | ||
108 | wc->opcode = IB_WC_SEND; | 116 | wc->opcode = IB_WC_SEND; |
109 | break; | 117 | break; |
110 | case T3_BIND_MW: | 118 | case T3_BIND_MW: |
111 | wc->opcode = IB_WC_BIND_MW; | 119 | wc->opcode = IB_WC_BIND_MW; |
112 | break; | 120 | break; |
113 | 121 | ||
114 | /* these aren't supported yet */ | ||
115 | case T3_SEND_WITH_INV: | ||
116 | case T3_SEND_WITH_SE_INV: | ||
117 | case T3_LOCAL_INV: | 122 | case T3_LOCAL_INV: |
123 | wc->opcode = IB_WC_LOCAL_INV; | ||
124 | break; | ||
118 | case T3_FAST_REGISTER: | 125 | case T3_FAST_REGISTER: |
126 | wc->opcode = IB_WC_FAST_REG_MR; | ||
127 | break; | ||
119 | default: | 128 | default: |
120 | printk(KERN_ERR MOD "Unexpected opcode %d " | 129 | printk(KERN_ERR MOD "Unexpected opcode %d " |
121 | "in the CQE received for QPID=0x%0x\n", | 130 | "in the CQE received for QPID=0x%0x\n", |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 95f82cfb6c54..b89640aa6e10 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include "iwch_provider.h" | 56 | #include "iwch_provider.h" |
57 | #include "iwch_cm.h" | 57 | #include "iwch_cm.h" |
58 | #include "iwch_user.h" | 58 | #include "iwch_user.h" |
59 | #include "common.h" | ||
59 | 60 | ||
60 | static int iwch_modify_port(struct ib_device *ibdev, | 61 | static int iwch_modify_port(struct ib_device *ibdev, |
61 | u8 port, int port_modify_mask, | 62 | u8 port, int port_modify_mask, |
@@ -747,6 +748,7 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd) | |||
747 | mhp->attr.type = TPT_MW; | 748 | mhp->attr.type = TPT_MW; |
748 | mhp->attr.stag = stag; | 749 | mhp->attr.stag = stag; |
749 | mmid = (stag) >> 8; | 750 | mmid = (stag) >> 8; |
751 | mhp->ibmw.rkey = stag; | ||
750 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | 752 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); |
751 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); | 753 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); |
752 | return &(mhp->ibmw); | 754 | return &(mhp->ibmw); |
@@ -768,6 +770,68 @@ static int iwch_dealloc_mw(struct ib_mw *mw) | |||
768 | return 0; | 770 | return 0; |
769 | } | 771 | } |
770 | 772 | ||
773 | static struct ib_mr *iwch_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth) | ||
774 | { | ||
775 | struct iwch_dev *rhp; | ||
776 | struct iwch_pd *php; | ||
777 | struct iwch_mr *mhp; | ||
778 | u32 mmid; | ||
779 | u32 stag = 0; | ||
780 | int ret; | ||
781 | |||
782 | php = to_iwch_pd(pd); | ||
783 | rhp = php->rhp; | ||
784 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | ||
785 | if (!mhp) | ||
786 | return ERR_PTR(-ENOMEM); | ||
787 | |||
788 | mhp->rhp = rhp; | ||
789 | ret = iwch_alloc_pbl(mhp, pbl_depth); | ||
790 | if (ret) { | ||
791 | kfree(mhp); | ||
792 | return ERR_PTR(ret); | ||
793 | } | ||
794 | mhp->attr.pbl_size = pbl_depth; | ||
795 | ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid, | ||
796 | mhp->attr.pbl_size, mhp->attr.pbl_addr); | ||
797 | if (ret) { | ||
798 | iwch_free_pbl(mhp); | ||
799 | kfree(mhp); | ||
800 | return ERR_PTR(ret); | ||
801 | } | ||
802 | mhp->attr.pdid = php->pdid; | ||
803 | mhp->attr.type = TPT_NON_SHARED_MR; | ||
804 | mhp->attr.stag = stag; | ||
805 | mhp->attr.state = 1; | ||
806 | mmid = (stag) >> 8; | ||
807 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; | ||
808 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | ||
809 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); | ||
810 | return &(mhp->ibmr); | ||
811 | } | ||
812 | |||
813 | static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl( | ||
814 | struct ib_device *device, | ||
815 | int page_list_len) | ||
816 | { | ||
817 | struct ib_fast_reg_page_list *page_list; | ||
818 | |||
819 | page_list = kmalloc(sizeof *page_list + page_list_len * sizeof(u64), | ||
820 | GFP_KERNEL); | ||
821 | if (!page_list) | ||
822 | return ERR_PTR(-ENOMEM); | ||
823 | |||
824 | page_list->page_list = (u64 *)(page_list + 1); | ||
825 | page_list->max_page_list_len = page_list_len; | ||
826 | |||
827 | return page_list; | ||
828 | } | ||
829 | |||
830 | static void iwch_free_fastreg_pbl(struct ib_fast_reg_page_list *page_list) | ||
831 | { | ||
832 | kfree(page_list); | ||
833 | } | ||
834 | |||
771 | static int iwch_destroy_qp(struct ib_qp *ib_qp) | 835 | static int iwch_destroy_qp(struct ib_qp *ib_qp) |
772 | { | 836 | { |
773 | struct iwch_dev *rhp; | 837 | struct iwch_dev *rhp; |
@@ -843,6 +907,15 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | |||
843 | */ | 907 | */ |
844 | sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); | 908 | sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); |
845 | wqsize = roundup_pow_of_two(rqsize + sqsize); | 909 | wqsize = roundup_pow_of_two(rqsize + sqsize); |
910 | |||
911 | /* | ||
912 | * Kernel users need more wq space for fastreg WRs which can take | ||
913 | * 2 WR fragments. | ||
914 | */ | ||
915 | ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL; | ||
916 | if (!ucontext && wqsize < (rqsize + (2 * sqsize))) | ||
917 | wqsize = roundup_pow_of_two(rqsize + | ||
918 | roundup_pow_of_two(attrs->cap.max_send_wr * 2)); | ||
846 | PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__, | 919 | PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__, |
847 | wqsize, sqsize, rqsize); | 920 | wqsize, sqsize, rqsize); |
848 | qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); | 921 | qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); |
@@ -851,7 +924,6 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | |||
851 | qhp->wq.size_log2 = ilog2(wqsize); | 924 | qhp->wq.size_log2 = ilog2(wqsize); |
852 | qhp->wq.rq_size_log2 = ilog2(rqsize); | 925 | qhp->wq.rq_size_log2 = ilog2(rqsize); |
853 | qhp->wq.sq_size_log2 = ilog2(sqsize); | 926 | qhp->wq.sq_size_log2 = ilog2(sqsize); |
854 | ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL; | ||
855 | if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq, | 927 | if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq, |
856 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { | 928 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { |
857 | kfree(qhp); | 929 | kfree(qhp); |
@@ -935,10 +1007,10 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | |||
935 | qhp->ibqp.qp_num = qhp->wq.qpid; | 1007 | qhp->ibqp.qp_num = qhp->wq.qpid; |
936 | init_timer(&(qhp->timer)); | 1008 | init_timer(&(qhp->timer)); |
937 | PDBG("%s sq_num_entries %d, rq_num_entries %d " | 1009 | PDBG("%s sq_num_entries %d, rq_num_entries %d " |
938 | "qpid 0x%0x qhp %p dma_addr 0x%llx size %d\n", | 1010 | "qpid 0x%0x qhp %p dma_addr 0x%llx size %d rq_addr 0x%x\n", |
939 | __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries, | 1011 | __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries, |
940 | qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr, | 1012 | qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr, |
941 | 1 << qhp->wq.size_log2); | 1013 | 1 << qhp->wq.size_log2, qhp->wq.rq_addr); |
942 | return &qhp->ibqp; | 1014 | return &qhp->ibqp; |
943 | } | 1015 | } |
944 | 1016 | ||
@@ -1023,6 +1095,29 @@ static int iwch_query_gid(struct ib_device *ibdev, u8 port, | |||
1023 | return 0; | 1095 | return 0; |
1024 | } | 1096 | } |
1025 | 1097 | ||
1098 | static u64 fw_vers_string_to_u64(struct iwch_dev *iwch_dev) | ||
1099 | { | ||
1100 | struct ethtool_drvinfo info; | ||
1101 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | ||
1102 | char *cp, *next; | ||
1103 | unsigned fw_maj, fw_min, fw_mic; | ||
1104 | |||
1105 | rtnl_lock(); | ||
1106 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | ||
1107 | rtnl_unlock(); | ||
1108 | |||
1109 | next = info.fw_version + 1; | ||
1110 | cp = strsep(&next, "."); | ||
1111 | sscanf(cp, "%i", &fw_maj); | ||
1112 | cp = strsep(&next, "."); | ||
1113 | sscanf(cp, "%i", &fw_min); | ||
1114 | cp = strsep(&next, "."); | ||
1115 | sscanf(cp, "%i", &fw_mic); | ||
1116 | |||
1117 | return (((u64)fw_maj & 0xffff) << 32) | ((fw_min & 0xffff) << 16) | | ||
1118 | (fw_mic & 0xffff); | ||
1119 | } | ||
1120 | |||
1026 | static int iwch_query_device(struct ib_device *ibdev, | 1121 | static int iwch_query_device(struct ib_device *ibdev, |
1027 | struct ib_device_attr *props) | 1122 | struct ib_device_attr *props) |
1028 | { | 1123 | { |
@@ -1033,7 +1128,10 @@ static int iwch_query_device(struct ib_device *ibdev, | |||
1033 | dev = to_iwch_dev(ibdev); | 1128 | dev = to_iwch_dev(ibdev); |
1034 | memset(props, 0, sizeof *props); | 1129 | memset(props, 0, sizeof *props); |
1035 | memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); | 1130 | memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); |
1131 | props->hw_ver = dev->rdev.t3cdev_p->type; | ||
1132 | props->fw_ver = fw_vers_string_to_u64(dev); | ||
1036 | props->device_cap_flags = dev->device_cap_flags; | 1133 | props->device_cap_flags = dev->device_cap_flags; |
1134 | props->page_size_cap = dev->attr.mem_pgsizes_bitmask; | ||
1037 | props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor; | 1135 | props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor; |
1038 | props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device; | 1136 | props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device; |
1039 | props->max_mr_size = dev->attr.max_mr_size; | 1137 | props->max_mr_size = dev->attr.max_mr_size; |
@@ -1048,6 +1146,7 @@ static int iwch_query_device(struct ib_device *ibdev, | |||
1048 | props->max_mr = dev->attr.max_mem_regs; | 1146 | props->max_mr = dev->attr.max_mem_regs; |
1049 | props->max_pd = dev->attr.max_pds; | 1147 | props->max_pd = dev->attr.max_pds; |
1050 | props->local_ca_ack_delay = 0; | 1148 | props->local_ca_ack_delay = 0; |
1149 | props->max_fast_reg_page_list_len = T3_MAX_FASTREG_DEPTH; | ||
1051 | 1150 | ||
1052 | return 0; | 1151 | return 0; |
1053 | } | 1152 | } |
@@ -1088,6 +1187,28 @@ static ssize_t show_rev(struct device *dev, struct device_attribute *attr, | |||
1088 | return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); | 1187 | return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); |
1089 | } | 1188 | } |
1090 | 1189 | ||
1190 | static int fw_supports_fastreg(struct iwch_dev *iwch_dev) | ||
1191 | { | ||
1192 | struct ethtool_drvinfo info; | ||
1193 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | ||
1194 | char *cp, *next; | ||
1195 | unsigned fw_maj, fw_min; | ||
1196 | |||
1197 | rtnl_lock(); | ||
1198 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | ||
1199 | rtnl_unlock(); | ||
1200 | |||
1201 | next = info.fw_version+1; | ||
1202 | cp = strsep(&next, "."); | ||
1203 | sscanf(cp, "%i", &fw_maj); | ||
1204 | cp = strsep(&next, "."); | ||
1205 | sscanf(cp, "%i", &fw_min); | ||
1206 | |||
1207 | PDBG("%s maj %u min %u\n", __func__, fw_maj, fw_min); | ||
1208 | |||
1209 | return fw_maj > 6 || (fw_maj == 6 && fw_min > 0); | ||
1210 | } | ||
1211 | |||
1091 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) | 1212 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) |
1092 | { | 1213 | { |
1093 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, | 1214 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, |
@@ -1127,6 +1248,61 @@ static ssize_t show_board(struct device *dev, struct device_attribute *attr, | |||
1127 | iwch_dev->rdev.rnic_info.pdev->device); | 1248 | iwch_dev->rdev.rnic_info.pdev->device); |
1128 | } | 1249 | } |
1129 | 1250 | ||
1251 | static int iwch_get_mib(struct ib_device *ibdev, | ||
1252 | union rdma_protocol_stats *stats) | ||
1253 | { | ||
1254 | struct iwch_dev *dev; | ||
1255 | struct tp_mib_stats m; | ||
1256 | int ret; | ||
1257 | |||
1258 | PDBG("%s ibdev %p\n", __func__, ibdev); | ||
1259 | dev = to_iwch_dev(ibdev); | ||
1260 | ret = dev->rdev.t3cdev_p->ctl(dev->rdev.t3cdev_p, RDMA_GET_MIB, &m); | ||
1261 | if (ret) | ||
1262 | return -ENOSYS; | ||
1263 | |||
1264 | memset(stats, 0, sizeof *stats); | ||
1265 | stats->iw.ipInReceives = ((u64) m.ipInReceive_hi << 32) + | ||
1266 | m.ipInReceive_lo; | ||
1267 | stats->iw.ipInHdrErrors = ((u64) m.ipInHdrErrors_hi << 32) + | ||
1268 | m.ipInHdrErrors_lo; | ||
1269 | stats->iw.ipInAddrErrors = ((u64) m.ipInAddrErrors_hi << 32) + | ||
1270 | m.ipInAddrErrors_lo; | ||
1271 | stats->iw.ipInUnknownProtos = ((u64) m.ipInUnknownProtos_hi << 32) + | ||
1272 | m.ipInUnknownProtos_lo; | ||
1273 | stats->iw.ipInDiscards = ((u64) m.ipInDiscards_hi << 32) + | ||
1274 | m.ipInDiscards_lo; | ||
1275 | stats->iw.ipInDelivers = ((u64) m.ipInDelivers_hi << 32) + | ||
1276 | m.ipInDelivers_lo; | ||
1277 | stats->iw.ipOutRequests = ((u64) m.ipOutRequests_hi << 32) + | ||
1278 | m.ipOutRequests_lo; | ||
1279 | stats->iw.ipOutDiscards = ((u64) m.ipOutDiscards_hi << 32) + | ||
1280 | m.ipOutDiscards_lo; | ||
1281 | stats->iw.ipOutNoRoutes = ((u64) m.ipOutNoRoutes_hi << 32) + | ||
1282 | m.ipOutNoRoutes_lo; | ||
1283 | stats->iw.ipReasmTimeout = (u64) m.ipReasmTimeout; | ||
1284 | stats->iw.ipReasmReqds = (u64) m.ipReasmReqds; | ||
1285 | stats->iw.ipReasmOKs = (u64) m.ipReasmOKs; | ||
1286 | stats->iw.ipReasmFails = (u64) m.ipReasmFails; | ||
1287 | stats->iw.tcpActiveOpens = (u64) m.tcpActiveOpens; | ||
1288 | stats->iw.tcpPassiveOpens = (u64) m.tcpPassiveOpens; | ||
1289 | stats->iw.tcpAttemptFails = (u64) m.tcpAttemptFails; | ||
1290 | stats->iw.tcpEstabResets = (u64) m.tcpEstabResets; | ||
1291 | stats->iw.tcpOutRsts = (u64) m.tcpOutRsts; | ||
1292 | stats->iw.tcpCurrEstab = (u64) m.tcpCurrEstab; | ||
1293 | stats->iw.tcpInSegs = ((u64) m.tcpInSegs_hi << 32) + | ||
1294 | m.tcpInSegs_lo; | ||
1295 | stats->iw.tcpOutSegs = ((u64) m.tcpOutSegs_hi << 32) + | ||
1296 | m.tcpOutSegs_lo; | ||
1297 | stats->iw.tcpRetransSegs = ((u64) m.tcpRetransSeg_hi << 32) + | ||
1298 | m.tcpRetransSeg_lo; | ||
1299 | stats->iw.tcpInErrs = ((u64) m.tcpInErrs_hi << 32) + | ||
1300 | m.tcpInErrs_lo; | ||
1301 | stats->iw.tcpRtoMin = (u64) m.tcpRtoMin; | ||
1302 | stats->iw.tcpRtoMax = (u64) m.tcpRtoMax; | ||
1303 | return 0; | ||
1304 | } | ||
1305 | |||
1130 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 1306 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
1131 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | 1307 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); |
1132 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 1308 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
@@ -1136,7 +1312,7 @@ static struct device_attribute *iwch_class_attributes[] = { | |||
1136 | &dev_attr_hw_rev, | 1312 | &dev_attr_hw_rev, |
1137 | &dev_attr_fw_ver, | 1313 | &dev_attr_fw_ver, |
1138 | &dev_attr_hca_type, | 1314 | &dev_attr_hca_type, |
1139 | &dev_attr_board_id | 1315 | &dev_attr_board_id, |
1140 | }; | 1316 | }; |
1141 | 1317 | ||
1142 | int iwch_register_device(struct iwch_dev *dev) | 1318 | int iwch_register_device(struct iwch_dev *dev) |
@@ -1149,8 +1325,12 @@ int iwch_register_device(struct iwch_dev *dev) | |||
1149 | memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); | 1325 | memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); |
1150 | memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); | 1326 | memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); |
1151 | dev->ibdev.owner = THIS_MODULE; | 1327 | dev->ibdev.owner = THIS_MODULE; |
1152 | dev->device_cap_flags = | 1328 | dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW; |
1153 | (IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW); | 1329 | |
1330 | /* cxgb3 supports STag 0. */ | ||
1331 | dev->ibdev.local_dma_lkey = 0; | ||
1332 | if (fw_supports_fastreg(dev)) | ||
1333 | dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; | ||
1154 | 1334 | ||
1155 | dev->ibdev.uverbs_cmd_mask = | 1335 | dev->ibdev.uverbs_cmd_mask = |
1156 | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | | 1336 | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | |
@@ -1202,15 +1382,16 @@ int iwch_register_device(struct iwch_dev *dev) | |||
1202 | dev->ibdev.alloc_mw = iwch_alloc_mw; | 1382 | dev->ibdev.alloc_mw = iwch_alloc_mw; |
1203 | dev->ibdev.bind_mw = iwch_bind_mw; | 1383 | dev->ibdev.bind_mw = iwch_bind_mw; |
1204 | dev->ibdev.dealloc_mw = iwch_dealloc_mw; | 1384 | dev->ibdev.dealloc_mw = iwch_dealloc_mw; |
1205 | 1385 | dev->ibdev.alloc_fast_reg_mr = iwch_alloc_fast_reg_mr; | |
1386 | dev->ibdev.alloc_fast_reg_page_list = iwch_alloc_fastreg_pbl; | ||
1387 | dev->ibdev.free_fast_reg_page_list = iwch_free_fastreg_pbl; | ||
1206 | dev->ibdev.attach_mcast = iwch_multicast_attach; | 1388 | dev->ibdev.attach_mcast = iwch_multicast_attach; |
1207 | dev->ibdev.detach_mcast = iwch_multicast_detach; | 1389 | dev->ibdev.detach_mcast = iwch_multicast_detach; |
1208 | dev->ibdev.process_mad = iwch_process_mad; | 1390 | dev->ibdev.process_mad = iwch_process_mad; |
1209 | |||
1210 | dev->ibdev.req_notify_cq = iwch_arm_cq; | 1391 | dev->ibdev.req_notify_cq = iwch_arm_cq; |
1211 | dev->ibdev.post_send = iwch_post_send; | 1392 | dev->ibdev.post_send = iwch_post_send; |
1212 | dev->ibdev.post_recv = iwch_post_receive; | 1393 | dev->ibdev.post_recv = iwch_post_receive; |
1213 | 1394 | dev->ibdev.get_protocol_stats = iwch_get_mib; | |
1214 | 1395 | ||
1215 | dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); | 1396 | dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); |
1216 | if (!dev->ibdev.iwcm) | 1397 | if (!dev->ibdev.iwcm) |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h index 836163fc5429..f5ceca05c435 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.h +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h | |||
@@ -296,14 +296,6 @@ static inline u32 iwch_ib_to_tpt_access(int acc) | |||
296 | TPT_LOCAL_READ; | 296 | TPT_LOCAL_READ; |
297 | } | 297 | } |
298 | 298 | ||
299 | static inline u32 iwch_ib_to_mwbind_access(int acc) | ||
300 | { | ||
301 | return (acc & IB_ACCESS_REMOTE_WRITE ? T3_MEM_ACCESS_REM_WRITE : 0) | | ||
302 | (acc & IB_ACCESS_REMOTE_READ ? T3_MEM_ACCESS_REM_READ : 0) | | ||
303 | (acc & IB_ACCESS_LOCAL_WRITE ? T3_MEM_ACCESS_LOCAL_WRITE : 0) | | ||
304 | T3_MEM_ACCESS_LOCAL_READ; | ||
305 | } | ||
306 | |||
307 | enum iwch_mmid_state { | 299 | enum iwch_mmid_state { |
308 | IWCH_STAG_STATE_VALID, | 300 | IWCH_STAG_STATE_VALID, |
309 | IWCH_STAG_STATE_INVALID | 301 | IWCH_STAG_STATE_INVALID |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c index 992613799228..9a3be3a9d5dc 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c | |||
@@ -33,10 +33,11 @@ | |||
33 | #include "iwch.h" | 33 | #include "iwch.h" |
34 | #include "iwch_cm.h" | 34 | #include "iwch_cm.h" |
35 | #include "cxio_hal.h" | 35 | #include "cxio_hal.h" |
36 | #include "cxio_resource.h" | ||
36 | 37 | ||
37 | #define NO_SUPPORT -1 | 38 | #define NO_SUPPORT -1 |
38 | 39 | ||
39 | static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, | 40 | static int build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, |
40 | u8 * flit_cnt) | 41 | u8 * flit_cnt) |
41 | { | 42 | { |
42 | int i; | 43 | int i; |
@@ -44,59 +45,44 @@ static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, | |||
44 | 45 | ||
45 | switch (wr->opcode) { | 46 | switch (wr->opcode) { |
46 | case IB_WR_SEND: | 47 | case IB_WR_SEND: |
47 | case IB_WR_SEND_WITH_IMM: | ||
48 | if (wr->send_flags & IB_SEND_SOLICITED) | 48 | if (wr->send_flags & IB_SEND_SOLICITED) |
49 | wqe->send.rdmaop = T3_SEND_WITH_SE; | 49 | wqe->send.rdmaop = T3_SEND_WITH_SE; |
50 | else | 50 | else |
51 | wqe->send.rdmaop = T3_SEND; | 51 | wqe->send.rdmaop = T3_SEND; |
52 | wqe->send.rem_stag = 0; | 52 | wqe->send.rem_stag = 0; |
53 | break; | 53 | break; |
54 | #if 0 /* Not currently supported */ | 54 | case IB_WR_SEND_WITH_INV: |
55 | case TYPE_SEND_INVALIDATE: | 55 | if (wr->send_flags & IB_SEND_SOLICITED) |
56 | case TYPE_SEND_INVALIDATE_IMMEDIATE: | 56 | wqe->send.rdmaop = T3_SEND_WITH_SE_INV; |
57 | wqe->send.rdmaop = T3_SEND_WITH_INV; | 57 | else |
58 | wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | 58 | wqe->send.rdmaop = T3_SEND_WITH_INV; |
59 | break; | 59 | wqe->send.rem_stag = cpu_to_be32(wr->ex.invalidate_rkey); |
60 | case TYPE_SEND_SE_INVALIDATE: | ||
61 | wqe->send.rdmaop = T3_SEND_WITH_SE_INV; | ||
62 | wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | ||
63 | break; | 60 | break; |
64 | #endif | ||
65 | default: | 61 | default: |
66 | break; | 62 | return -EINVAL; |
67 | } | 63 | } |
68 | if (wr->num_sge > T3_MAX_SGE) | 64 | if (wr->num_sge > T3_MAX_SGE) |
69 | return -EINVAL; | 65 | return -EINVAL; |
70 | wqe->send.reserved[0] = 0; | 66 | wqe->send.reserved[0] = 0; |
71 | wqe->send.reserved[1] = 0; | 67 | wqe->send.reserved[1] = 0; |
72 | wqe->send.reserved[2] = 0; | 68 | wqe->send.reserved[2] = 0; |
73 | if (wr->opcode == IB_WR_SEND_WITH_IMM) { | 69 | plen = 0; |
74 | plen = 4; | 70 | for (i = 0; i < wr->num_sge; i++) { |
75 | wqe->send.sgl[0].stag = wr->ex.imm_data; | 71 | if ((plen + wr->sg_list[i].length) < plen) |
76 | wqe->send.sgl[0].len = __constant_cpu_to_be32(0); | 72 | return -EMSGSIZE; |
77 | wqe->send.num_sgle = __constant_cpu_to_be32(0); | 73 | |
78 | *flit_cnt = 5; | 74 | plen += wr->sg_list[i].length; |
79 | } else { | 75 | wqe->send.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); |
80 | plen = 0; | 76 | wqe->send.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); |
81 | for (i = 0; i < wr->num_sge; i++) { | 77 | wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); |
82 | if ((plen + wr->sg_list[i].length) < plen) { | ||
83 | return -EMSGSIZE; | ||
84 | } | ||
85 | plen += wr->sg_list[i].length; | ||
86 | wqe->send.sgl[i].stag = | ||
87 | cpu_to_be32(wr->sg_list[i].lkey); | ||
88 | wqe->send.sgl[i].len = | ||
89 | cpu_to_be32(wr->sg_list[i].length); | ||
90 | wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); | ||
91 | } | ||
92 | wqe->send.num_sgle = cpu_to_be32(wr->num_sge); | ||
93 | *flit_cnt = 4 + ((wr->num_sge) << 1); | ||
94 | } | 78 | } |
79 | wqe->send.num_sgle = cpu_to_be32(wr->num_sge); | ||
80 | *flit_cnt = 4 + ((wr->num_sge) << 1); | ||
95 | wqe->send.plen = cpu_to_be32(plen); | 81 | wqe->send.plen = cpu_to_be32(plen); |
96 | return 0; | 82 | return 0; |
97 | } | 83 | } |
98 | 84 | ||
99 | static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, | 85 | static int build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, |
100 | u8 *flit_cnt) | 86 | u8 *flit_cnt) |
101 | { | 87 | { |
102 | int i; | 88 | int i; |
@@ -137,15 +123,18 @@ static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, | |||
137 | return 0; | 123 | return 0; |
138 | } | 124 | } |
139 | 125 | ||
140 | static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, | 126 | static int build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, |
141 | u8 *flit_cnt) | 127 | u8 *flit_cnt) |
142 | { | 128 | { |
143 | if (wr->num_sge > 1) | 129 | if (wr->num_sge > 1) |
144 | return -EINVAL; | 130 | return -EINVAL; |
145 | wqe->read.rdmaop = T3_READ_REQ; | 131 | wqe->read.rdmaop = T3_READ_REQ; |
132 | if (wr->opcode == IB_WR_RDMA_READ_WITH_INV) | ||
133 | wqe->read.local_inv = 1; | ||
134 | else | ||
135 | wqe->read.local_inv = 0; | ||
146 | wqe->read.reserved[0] = 0; | 136 | wqe->read.reserved[0] = 0; |
147 | wqe->read.reserved[1] = 0; | 137 | wqe->read.reserved[1] = 0; |
148 | wqe->read.reserved[2] = 0; | ||
149 | wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | 138 | wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); |
150 | wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr); | 139 | wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr); |
151 | wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey); | 140 | wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey); |
@@ -155,6 +144,57 @@ static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, | |||
155 | return 0; | 144 | return 0; |
156 | } | 145 | } |
157 | 146 | ||
147 | static int build_fastreg(union t3_wr *wqe, struct ib_send_wr *wr, | ||
148 | u8 *flit_cnt, int *wr_cnt, struct t3_wq *wq) | ||
149 | { | ||
150 | int i; | ||
151 | __be64 *p; | ||
152 | |||
153 | if (wr->wr.fast_reg.page_list_len > T3_MAX_FASTREG_DEPTH) | ||
154 | return -EINVAL; | ||
155 | *wr_cnt = 1; | ||
156 | wqe->fastreg.stag = cpu_to_be32(wr->wr.fast_reg.rkey); | ||
157 | wqe->fastreg.len = cpu_to_be32(wr->wr.fast_reg.length); | ||
158 | wqe->fastreg.va_base_hi = cpu_to_be32(wr->wr.fast_reg.iova_start >> 32); | ||
159 | wqe->fastreg.va_base_lo_fbo = | ||
160 | cpu_to_be32(wr->wr.fast_reg.iova_start & 0xffffffff); | ||
161 | wqe->fastreg.page_type_perms = cpu_to_be32( | ||
162 | V_FR_PAGE_COUNT(wr->wr.fast_reg.page_list_len) | | ||
163 | V_FR_PAGE_SIZE(wr->wr.fast_reg.page_shift-12) | | ||
164 | V_FR_TYPE(TPT_VATO) | | ||
165 | V_FR_PERMS(iwch_ib_to_tpt_access(wr->wr.fast_reg.access_flags))); | ||
166 | p = &wqe->fastreg.pbl_addrs[0]; | ||
167 | for (i = 0; i < wr->wr.fast_reg.page_list_len; i++, p++) { | ||
168 | |||
169 | /* If we need a 2nd WR, then set it up */ | ||
170 | if (i == T3_MAX_FASTREG_FRAG) { | ||
171 | *wr_cnt = 2; | ||
172 | wqe = (union t3_wr *)(wq->queue + | ||
173 | Q_PTR2IDX((wq->wptr+1), wq->size_log2)); | ||
174 | build_fw_riwrh((void *)wqe, T3_WR_FASTREG, 0, | ||
175 | Q_GENBIT(wq->wptr + 1, wq->size_log2), | ||
176 | 0, 1 + wr->wr.fast_reg.page_list_len - T3_MAX_FASTREG_FRAG, | ||
177 | T3_EOP); | ||
178 | |||
179 | p = &wqe->pbl_frag.pbl_addrs[0]; | ||
180 | } | ||
181 | *p = cpu_to_be64((u64)wr->wr.fast_reg.page_list->page_list[i]); | ||
182 | } | ||
183 | *flit_cnt = 5 + wr->wr.fast_reg.page_list_len; | ||
184 | if (*flit_cnt > 15) | ||
185 | *flit_cnt = 15; | ||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | static int build_inv_stag(union t3_wr *wqe, struct ib_send_wr *wr, | ||
190 | u8 *flit_cnt) | ||
191 | { | ||
192 | wqe->local_inv.stag = cpu_to_be32(wr->ex.invalidate_rkey); | ||
193 | wqe->local_inv.reserved = 0; | ||
194 | *flit_cnt = sizeof(struct t3_local_inv_wr) >> 3; | ||
195 | return 0; | ||
196 | } | ||
197 | |||
158 | /* | 198 | /* |
159 | * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. | 199 | * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. |
160 | */ | 200 | */ |
@@ -205,23 +245,106 @@ static int iwch_sgl2pbl_map(struct iwch_dev *rhp, struct ib_sge *sg_list, | |||
205 | return 0; | 245 | return 0; |
206 | } | 246 | } |
207 | 247 | ||
208 | static int iwch_build_rdma_recv(struct iwch_dev *rhp, union t3_wr *wqe, | 248 | static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe, |
209 | struct ib_recv_wr *wr) | 249 | struct ib_recv_wr *wr) |
210 | { | 250 | { |
211 | int i; | 251 | int i, err = 0; |
212 | if (wr->num_sge > T3_MAX_SGE) | 252 | u32 pbl_addr[T3_MAX_SGE]; |
213 | return -EINVAL; | 253 | u8 page_size[T3_MAX_SGE]; |
254 | |||
255 | err = iwch_sgl2pbl_map(qhp->rhp, wr->sg_list, wr->num_sge, pbl_addr, | ||
256 | page_size); | ||
257 | if (err) | ||
258 | return err; | ||
259 | wqe->recv.pagesz[0] = page_size[0]; | ||
260 | wqe->recv.pagesz[1] = page_size[1]; | ||
261 | wqe->recv.pagesz[2] = page_size[2]; | ||
262 | wqe->recv.pagesz[3] = page_size[3]; | ||
214 | wqe->recv.num_sgle = cpu_to_be32(wr->num_sge); | 263 | wqe->recv.num_sgle = cpu_to_be32(wr->num_sge); |
215 | for (i = 0; i < wr->num_sge; i++) { | 264 | for (i = 0; i < wr->num_sge; i++) { |
216 | wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); | 265 | wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); |
217 | wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); | 266 | wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); |
267 | |||
268 | /* to in the WQE == the offset into the page */ | ||
269 | wqe->recv.sgl[i].to = cpu_to_be64(((u32) wr->sg_list[i].addr) % | ||
270 | (1UL << (12 + page_size[i]))); | ||
271 | |||
272 | /* pbl_addr is the adapters address in the PBL */ | ||
273 | wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_addr[i]); | ||
274 | } | ||
275 | for (; i < T3_MAX_SGE; i++) { | ||
276 | wqe->recv.sgl[i].stag = 0; | ||
277 | wqe->recv.sgl[i].len = 0; | ||
278 | wqe->recv.sgl[i].to = 0; | ||
279 | wqe->recv.pbl_addr[i] = 0; | ||
280 | } | ||
281 | qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, | ||
282 | qhp->wq.rq_size_log2)].wr_id = wr->wr_id; | ||
283 | qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, | ||
284 | qhp->wq.rq_size_log2)].pbl_addr = 0; | ||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe, | ||
289 | struct ib_recv_wr *wr) | ||
290 | { | ||
291 | int i; | ||
292 | u32 pbl_addr; | ||
293 | u32 pbl_offset; | ||
294 | |||
295 | |||
296 | /* | ||
297 | * The T3 HW requires the PBL in the HW recv descriptor to reference | ||
298 | * a PBL entry. So we allocate the max needed PBL memory here and pass | ||
299 | * it to the uP in the recv WR. The uP will build the PBL and setup | ||
300 | * the HW recv descriptor. | ||
301 | */ | ||
302 | pbl_addr = cxio_hal_pblpool_alloc(&qhp->rhp->rdev, T3_STAG0_PBL_SIZE); | ||
303 | if (!pbl_addr) | ||
304 | return -ENOMEM; | ||
305 | |||
306 | /* | ||
307 | * Compute the 8B aligned offset. | ||
308 | */ | ||
309 | pbl_offset = (pbl_addr - qhp->rhp->rdev.rnic_info.pbl_base) >> 3; | ||
310 | |||
311 | wqe->recv.num_sgle = cpu_to_be32(wr->num_sge); | ||
312 | |||
313 | for (i = 0; i < wr->num_sge; i++) { | ||
314 | |||
315 | /* | ||
316 | * Use a 128MB page size. This and an imposed 128MB | ||
317 | * sge length limit allows us to require only a 2-entry HW | ||
318 | * PBL for each SGE. This restriction is acceptable since | ||
319 | * since it is not possible to allocate 128MB of contiguous | ||
320 | * DMA coherent memory! | ||
321 | */ | ||
322 | if (wr->sg_list[i].length > T3_STAG0_MAX_PBE_LEN) | ||
323 | return -EINVAL; | ||
324 | wqe->recv.pagesz[i] = T3_STAG0_PAGE_SHIFT; | ||
325 | |||
326 | /* | ||
327 | * T3 restricts a recv to all zero-stag or all non-zero-stag. | ||
328 | */ | ||
329 | if (wr->sg_list[i].lkey != 0) | ||
330 | return -EINVAL; | ||
331 | wqe->recv.sgl[i].stag = 0; | ||
332 | wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); | ||
218 | wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); | 333 | wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); |
334 | wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_offset); | ||
335 | pbl_offset += 2; | ||
219 | } | 336 | } |
220 | for (; i < T3_MAX_SGE; i++) { | 337 | for (; i < T3_MAX_SGE; i++) { |
338 | wqe->recv.pagesz[i] = 0; | ||
221 | wqe->recv.sgl[i].stag = 0; | 339 | wqe->recv.sgl[i].stag = 0; |
222 | wqe->recv.sgl[i].len = 0; | 340 | wqe->recv.sgl[i].len = 0; |
223 | wqe->recv.sgl[i].to = 0; | 341 | wqe->recv.sgl[i].to = 0; |
342 | wqe->recv.pbl_addr[i] = 0; | ||
224 | } | 343 | } |
344 | qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, | ||
345 | qhp->wq.rq_size_log2)].wr_id = wr->wr_id; | ||
346 | qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, | ||
347 | qhp->wq.rq_size_log2)].pbl_addr = pbl_addr; | ||
225 | return 0; | 348 | return 0; |
226 | } | 349 | } |
227 | 350 | ||
@@ -238,6 +361,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
238 | u32 num_wrs; | 361 | u32 num_wrs; |
239 | unsigned long flag; | 362 | unsigned long flag; |
240 | struct t3_swsq *sqp; | 363 | struct t3_swsq *sqp; |
364 | int wr_cnt = 1; | ||
241 | 365 | ||
242 | qhp = to_iwch_qp(ibqp); | 366 | qhp = to_iwch_qp(ibqp); |
243 | spin_lock_irqsave(&qhp->lock, flag); | 367 | spin_lock_irqsave(&qhp->lock, flag); |
@@ -262,33 +386,45 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
262 | t3_wr_flags = 0; | 386 | t3_wr_flags = 0; |
263 | if (wr->send_flags & IB_SEND_SOLICITED) | 387 | if (wr->send_flags & IB_SEND_SOLICITED) |
264 | t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; | 388 | t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; |
265 | if (wr->send_flags & IB_SEND_FENCE) | ||
266 | t3_wr_flags |= T3_READ_FENCE_FLAG; | ||
267 | if (wr->send_flags & IB_SEND_SIGNALED) | 389 | if (wr->send_flags & IB_SEND_SIGNALED) |
268 | t3_wr_flags |= T3_COMPLETION_FLAG; | 390 | t3_wr_flags |= T3_COMPLETION_FLAG; |
269 | sqp = qhp->wq.sq + | 391 | sqp = qhp->wq.sq + |
270 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); | 392 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); |
271 | switch (wr->opcode) { | 393 | switch (wr->opcode) { |
272 | case IB_WR_SEND: | 394 | case IB_WR_SEND: |
273 | case IB_WR_SEND_WITH_IMM: | 395 | case IB_WR_SEND_WITH_INV: |
396 | if (wr->send_flags & IB_SEND_FENCE) | ||
397 | t3_wr_flags |= T3_READ_FENCE_FLAG; | ||
274 | t3_wr_opcode = T3_WR_SEND; | 398 | t3_wr_opcode = T3_WR_SEND; |
275 | err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); | 399 | err = build_rdma_send(wqe, wr, &t3_wr_flit_cnt); |
276 | break; | 400 | break; |
277 | case IB_WR_RDMA_WRITE: | 401 | case IB_WR_RDMA_WRITE: |
278 | case IB_WR_RDMA_WRITE_WITH_IMM: | 402 | case IB_WR_RDMA_WRITE_WITH_IMM: |
279 | t3_wr_opcode = T3_WR_WRITE; | 403 | t3_wr_opcode = T3_WR_WRITE; |
280 | err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); | 404 | err = build_rdma_write(wqe, wr, &t3_wr_flit_cnt); |
281 | break; | 405 | break; |
282 | case IB_WR_RDMA_READ: | 406 | case IB_WR_RDMA_READ: |
407 | case IB_WR_RDMA_READ_WITH_INV: | ||
283 | t3_wr_opcode = T3_WR_READ; | 408 | t3_wr_opcode = T3_WR_READ; |
284 | t3_wr_flags = 0; /* T3 reads are always signaled */ | 409 | t3_wr_flags = 0; /* T3 reads are always signaled */ |
285 | err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); | 410 | err = build_rdma_read(wqe, wr, &t3_wr_flit_cnt); |
286 | if (err) | 411 | if (err) |
287 | break; | 412 | break; |
288 | sqp->read_len = wqe->read.local_len; | 413 | sqp->read_len = wqe->read.local_len; |
289 | if (!qhp->wq.oldest_read) | 414 | if (!qhp->wq.oldest_read) |
290 | qhp->wq.oldest_read = sqp; | 415 | qhp->wq.oldest_read = sqp; |
291 | break; | 416 | break; |
417 | case IB_WR_FAST_REG_MR: | ||
418 | t3_wr_opcode = T3_WR_FASTREG; | ||
419 | err = build_fastreg(wqe, wr, &t3_wr_flit_cnt, | ||
420 | &wr_cnt, &qhp->wq); | ||
421 | break; | ||
422 | case IB_WR_LOCAL_INV: | ||
423 | if (wr->send_flags & IB_SEND_FENCE) | ||
424 | t3_wr_flags |= T3_LOCAL_FENCE_FLAG; | ||
425 | t3_wr_opcode = T3_WR_INV_STAG; | ||
426 | err = build_inv_stag(wqe, wr, &t3_wr_flit_cnt); | ||
427 | break; | ||
292 | default: | 428 | default: |
293 | PDBG("%s post of type=%d TBD!\n", __func__, | 429 | PDBG("%s post of type=%d TBD!\n", __func__, |
294 | wr->opcode); | 430 | wr->opcode); |
@@ -307,14 +443,15 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
307 | 443 | ||
308 | build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, | 444 | build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, |
309 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), | 445 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), |
310 | 0, t3_wr_flit_cnt); | 446 | 0, t3_wr_flit_cnt, |
447 | (wr_cnt == 1) ? T3_SOPEOP : T3_SOP); | ||
311 | PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", | 448 | PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", |
312 | __func__, (unsigned long long) wr->wr_id, idx, | 449 | __func__, (unsigned long long) wr->wr_id, idx, |
313 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), | 450 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), |
314 | sqp->opcode); | 451 | sqp->opcode); |
315 | wr = wr->next; | 452 | wr = wr->next; |
316 | num_wrs--; | 453 | num_wrs--; |
317 | ++(qhp->wq.wptr); | 454 | qhp->wq.wptr += wr_cnt; |
318 | ++(qhp->wq.sq_wptr); | 455 | ++(qhp->wq.sq_wptr); |
319 | } | 456 | } |
320 | spin_unlock_irqrestore(&qhp->lock, flag); | 457 | spin_unlock_irqrestore(&qhp->lock, flag); |
@@ -345,21 +482,27 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
345 | return -EINVAL; | 482 | return -EINVAL; |
346 | } | 483 | } |
347 | while (wr) { | 484 | while (wr) { |
485 | if (wr->num_sge > T3_MAX_SGE) { | ||
486 | err = -EINVAL; | ||
487 | *bad_wr = wr; | ||
488 | break; | ||
489 | } | ||
348 | idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); | 490 | idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); |
349 | wqe = (union t3_wr *) (qhp->wq.queue + idx); | 491 | wqe = (union t3_wr *) (qhp->wq.queue + idx); |
350 | if (num_wrs) | 492 | if (num_wrs) |
351 | err = iwch_build_rdma_recv(qhp->rhp, wqe, wr); | 493 | if (wr->sg_list[0].lkey) |
494 | err = build_rdma_recv(qhp, wqe, wr); | ||
495 | else | ||
496 | err = build_zero_stag_recv(qhp, wqe, wr); | ||
352 | else | 497 | else |
353 | err = -ENOMEM; | 498 | err = -ENOMEM; |
354 | if (err) { | 499 | if (err) { |
355 | *bad_wr = wr; | 500 | *bad_wr = wr; |
356 | break; | 501 | break; |
357 | } | 502 | } |
358 | qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, qhp->wq.rq_size_log2)] = | ||
359 | wr->wr_id; | ||
360 | build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, | 503 | build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, |
361 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), | 504 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), |
362 | 0, sizeof(struct t3_receive_wr) >> 3); | 505 | 0, sizeof(struct t3_receive_wr) >> 3, T3_SOPEOP); |
363 | PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x " | 506 | PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x " |
364 | "wqe %p \n", __func__, (unsigned long long) wr->wr_id, | 507 | "wqe %p \n", __func__, (unsigned long long) wr->wr_id, |
365 | idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); | 508 | idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); |
@@ -419,10 +562,10 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
419 | sgl.lkey = mw_bind->mr->lkey; | 562 | sgl.lkey = mw_bind->mr->lkey; |
420 | sgl.length = mw_bind->length; | 563 | sgl.length = mw_bind->length; |
421 | wqe->bind.reserved = 0; | 564 | wqe->bind.reserved = 0; |
422 | wqe->bind.type = T3_VA_BASED_TO; | 565 | wqe->bind.type = TPT_VATO; |
423 | 566 | ||
424 | /* TBD: check perms */ | 567 | /* TBD: check perms */ |
425 | wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags); | 568 | wqe->bind.perms = iwch_ib_to_tpt_access(mw_bind->mw_access_flags); |
426 | wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); | 569 | wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); |
427 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); | 570 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); |
428 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); | 571 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); |
@@ -430,7 +573,7 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
430 | err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); | 573 | err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); |
431 | if (err) { | 574 | if (err) { |
432 | spin_unlock_irqrestore(&qhp->lock, flag); | 575 | spin_unlock_irqrestore(&qhp->lock, flag); |
433 | return err; | 576 | return err; |
434 | } | 577 | } |
435 | wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; | 578 | wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; |
436 | sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); | 579 | sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); |
@@ -441,10 +584,9 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
441 | sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); | 584 | sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); |
442 | wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); | 585 | wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); |
443 | wqe->bind.mr_pagesz = page_size; | 586 | wqe->bind.mr_pagesz = page_size; |
444 | wqe->flit[T3_SQ_COOKIE_FLIT] = mw_bind->wr_id; | ||
445 | build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags, | 587 | build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags, |
446 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, | 588 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, |
447 | sizeof(struct t3_bind_mw_wr) >> 3); | 589 | sizeof(struct t3_bind_mw_wr) >> 3, T3_SOPEOP); |
448 | ++(qhp->wq.wptr); | 590 | ++(qhp->wq.wptr); |
449 | ++(qhp->wq.sq_wptr); | 591 | ++(qhp->wq.sq_wptr); |
450 | spin_unlock_irqrestore(&qhp->lock, flag); | 592 | spin_unlock_irqrestore(&qhp->lock, flag); |
@@ -758,7 +900,8 @@ static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp, | |||
758 | init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); | 900 | init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); |
759 | init_attr.rqe_count = iwch_rqes_posted(qhp); | 901 | init_attr.rqe_count = iwch_rqes_posted(qhp); |
760 | init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0; | 902 | init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0; |
761 | init_attr.flags |= capable(CAP_NET_BIND_SERVICE) ? PRIV_QP : 0; | 903 | if (!qhp->ibqp.uobject) |
904 | init_attr.flags |= PRIV_QP; | ||
762 | if (peer2peer) { | 905 | if (peer2peer) { |
763 | init_attr.rtr_type = RTR_READ; | 906 | init_attr.rtr_type = RTR_READ; |
764 | if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator) | 907 | if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator) |