diff options
author | Steve Wise <swise@opengridcomputing.com> | 2008-07-15 02:48:45 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-07-15 02:48:45 -0400 |
commit | e7e55829999deaab3f43e201a087731c02c54cf9 (patch) | |
tree | 665f2ff291045af9469bbb929f99224e9707965b /drivers | |
parent | 00f7ec36c9324928e4cd23f02e6d8550f30c32ca (diff) |
RDMA/cxgb3: MEM_MGT_EXTENSIONS support
- set IB_DEVICE_MEM_MGT_EXTENSIONS capability bit if fw supports it.
- set max_fast_reg_page_list_len device attribute.
- add iwch_alloc_fast_reg_mr function.
- add iwch_alloc_fastreg_pbl
- add iwch_free_fastreg_pbl
- adjust the WQ depth for kernel mode work queues to account for
fastreg possibly taking 2 WR slots.
- add fastreg_mr work request support.
- add local_inv work request support.
- add send_with_inv and send_with_se_inv work request support.
- removed useless duplicate enums/defines for TPT/MW/MR stuff.
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_hal.c | 15 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_hal.h | 1 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_wr.h | 90 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_cq.c | 15 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.c | 104 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.h | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_qp.c | 142 |
7 files changed, 293 insertions, 82 deletions
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c index 3f441fc57c17..340e4181c761 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); |
@@ -558,7 +560,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)); | 560 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); |
559 | memset(wqe, 0, sizeof(*wqe)); | 561 | memset(wqe, 0, sizeof(*wqe)); |
560 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, | 562 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, |
561 | T3_CTL_QP_TID, 7); | 563 | T3_CTL_QP_TID, 7, T3_SOPEOP); |
562 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); | 564 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); |
563 | sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; | 565 | sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; |
564 | wqe->sge_cmd = cpu_to_be64(sge_cmd); | 566 | wqe->sge_cmd = cpu_to_be64(sge_cmd); |
@@ -674,7 +676,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, | 676 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag, |
675 | Q_GENBIT(rdev_p->ctrl_qp.wptr, | 677 | Q_GENBIT(rdev_p->ctrl_qp.wptr, |
676 | T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, | 678 | T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, |
677 | wr_len); | 679 | wr_len, T3_SOPEOP); |
678 | if (flag == T3_COMPLETION_FLAG) | 680 | if (flag == T3_COMPLETION_FLAG) |
679 | ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); | 681 | ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); |
680 | len -= 96; | 682 | len -= 96; |
@@ -816,6 +818,13 @@ int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag) | |||
816 | 0, 0); | 818 | 0, 0); |
817 | } | 819 | } |
818 | 820 | ||
821 | int cxio_allocate_stag(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr) | ||
822 | { | ||
823 | *stag = T3_STAG_UNSET; | ||
824 | return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_NON_SHARED_MR, | ||
825 | 0, 0, 0ULL, 0, 0, pbl_size, pbl_addr); | ||
826 | } | ||
827 | |||
819 | int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) | 828 | int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) |
820 | { | 829 | { |
821 | struct t3_rdma_init_wr *wqe; | 830 | struct t3_rdma_init_wr *wqe; |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h index 6e128f6bab05..25a880664e6b 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.h +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h | |||
@@ -165,6 +165,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, | 165 | int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, |
166 | u32 pbl_addr); | 166 | u32 pbl_addr); |
167 | int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); | 167 | int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); |
168 | 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); | 169 | 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); | 170 | 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); | 171 | 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..de760e9f1cc6 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_wr.h +++ b/drivers/infiniband/hw/cxgb3/cxio_wr.h | |||
@@ -72,7 +72,8 @@ enum t3_wr_opcode { | |||
72 | T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, | 72 | T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, |
73 | T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, | 73 | T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, |
74 | T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, | 74 | T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, |
75 | T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP | 75 | T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP, |
76 | T3_WR_FASTREG = FW_WROPCODE_RI_FASTREGISTER_MR | ||
76 | } __attribute__ ((packed)); | 77 | } __attribute__ ((packed)); |
77 | 78 | ||
78 | enum t3_rdma_opcode { | 79 | enum t3_rdma_opcode { |
@@ -89,7 +90,8 @@ enum t3_rdma_opcode { | |||
89 | T3_FAST_REGISTER, | 90 | T3_FAST_REGISTER, |
90 | T3_LOCAL_INV, | 91 | T3_LOCAL_INV, |
91 | T3_QP_MOD, | 92 | T3_QP_MOD, |
92 | T3_BYPASS | 93 | T3_BYPASS, |
94 | T3_RDMA_READ_REQ_WITH_INV, | ||
93 | } __attribute__ ((packed)); | 95 | } __attribute__ ((packed)); |
94 | 96 | ||
95 | static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) | 97 | static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) |
@@ -103,6 +105,7 @@ static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) | |||
103 | case T3_WR_BIND: return T3_BIND_MW; | 105 | case T3_WR_BIND: return T3_BIND_MW; |
104 | case T3_WR_INIT: return T3_RDMA_INIT; | 106 | case T3_WR_INIT: return T3_RDMA_INIT; |
105 | case T3_WR_QP_MOD: return T3_QP_MOD; | 107 | case T3_WR_QP_MOD: return T3_QP_MOD; |
108 | case T3_WR_FASTREG: return T3_FAST_REGISTER; | ||
106 | default: break; | 109 | default: break; |
107 | } | 110 | } |
108 | return -1; | 111 | return -1; |
@@ -170,11 +173,54 @@ struct t3_send_wr { | |||
170 | struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ | 173 | struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ |
171 | }; | 174 | }; |
172 | 175 | ||
176 | #define T3_MAX_FASTREG_DEPTH 24 | ||
177 | #define T3_MAX_FASTREG_FRAG 10 | ||
178 | |||
179 | struct t3_fastreg_wr { | ||
180 | struct fw_riwrh wrh; /* 0 */ | ||
181 | union t3_wrid wrid; /* 1 */ | ||
182 | __be32 stag; /* 2 */ | ||
183 | __be32 len; | ||
184 | __be32 va_base_hi; /* 3 */ | ||
185 | __be32 va_base_lo_fbo; | ||
186 | __be32 page_type_perms; /* 4 */ | ||
187 | __be32 reserved1; | ||
188 | __be64 pbl_addrs[0]; /* 5+ */ | ||
189 | }; | ||
190 | |||
191 | /* | ||
192 | * If a fastreg wr spans multiple wqes, then the 2nd fragment look like this. | ||
193 | */ | ||
194 | struct t3_pbl_frag { | ||
195 | struct fw_riwrh wrh; /* 0 */ | ||
196 | __be64 pbl_addrs[14]; /* 1..14 */ | ||
197 | }; | ||
198 | |||
199 | #define S_FR_PAGE_COUNT 24 | ||
200 | #define M_FR_PAGE_COUNT 0xff | ||
201 | #define V_FR_PAGE_COUNT(x) ((x) << S_FR_PAGE_COUNT) | ||
202 | #define G_FR_PAGE_COUNT(x) ((((x) >> S_FR_PAGE_COUNT)) & M_FR_PAGE_COUNT) | ||
203 | |||
204 | #define S_FR_PAGE_SIZE 16 | ||
205 | #define M_FR_PAGE_SIZE 0x1f | ||
206 | #define V_FR_PAGE_SIZE(x) ((x) << S_FR_PAGE_SIZE) | ||
207 | #define G_FR_PAGE_SIZE(x) ((((x) >> S_FR_PAGE_SIZE)) & M_FR_PAGE_SIZE) | ||
208 | |||
209 | #define S_FR_TYPE 8 | ||
210 | #define M_FR_TYPE 0x1 | ||
211 | #define V_FR_TYPE(x) ((x) << S_FR_TYPE) | ||
212 | #define G_FR_TYPE(x) ((((x) >> S_FR_TYPE)) & M_FR_TYPE) | ||
213 | |||
214 | #define S_FR_PERMS 0 | ||
215 | #define M_FR_PERMS 0xff | ||
216 | #define V_FR_PERMS(x) ((x) << S_FR_PERMS) | ||
217 | #define G_FR_PERMS(x) ((((x) >> S_FR_PERMS)) & M_FR_PERMS) | ||
218 | |||
173 | struct t3_local_inv_wr { | 219 | struct t3_local_inv_wr { |
174 | struct fw_riwrh wrh; /* 0 */ | 220 | struct fw_riwrh wrh; /* 0 */ |
175 | union t3_wrid wrid; /* 1 */ | 221 | union t3_wrid wrid; /* 1 */ |
176 | __be32 stag; /* 2 */ | 222 | __be32 stag; /* 2 */ |
177 | __be32 reserved3; | 223 | __be32 reserved; |
178 | }; | 224 | }; |
179 | 225 | ||
180 | struct t3_rdma_write_wr { | 226 | struct t3_rdma_write_wr { |
@@ -193,7 +239,8 @@ struct t3_rdma_read_wr { | |||
193 | struct fw_riwrh wrh; /* 0 */ | 239 | struct fw_riwrh wrh; /* 0 */ |
194 | union t3_wrid wrid; /* 1 */ | 240 | union t3_wrid wrid; /* 1 */ |
195 | u8 rdmaop; /* 2 */ | 241 | u8 rdmaop; /* 2 */ |
196 | u8 reserved[3]; | 242 | u8 local_inv; |
243 | u8 reserved[2]; | ||
197 | __be32 rem_stag; | 244 | __be32 rem_stag; |
198 | __be64 rem_to; /* 3 */ | 245 | __be64 rem_to; /* 3 */ |
199 | __be32 local_stag; /* 4 */ | 246 | __be32 local_stag; /* 4 */ |
@@ -201,18 +248,6 @@ struct t3_rdma_read_wr { | |||
201 | __be64 local_to; /* 5 */ | 248 | __be64 local_to; /* 5 */ |
202 | }; | 249 | }; |
203 | 250 | ||
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 { | 251 | struct t3_bind_mw_wr { |
217 | struct fw_riwrh wrh; /* 0 */ | 252 | struct fw_riwrh wrh; /* 0 */ |
218 | union t3_wrid wrid; /* 1 */ | 253 | union t3_wrid wrid; /* 1 */ |
@@ -336,6 +371,11 @@ struct t3_genbit { | |||
336 | __be64 genbit; | 371 | __be64 genbit; |
337 | }; | 372 | }; |
338 | 373 | ||
374 | struct t3_wq_in_err { | ||
375 | u64 flit[13]; | ||
376 | u64 err; | ||
377 | }; | ||
378 | |||
339 | enum rdma_init_wr_flags { | 379 | enum rdma_init_wr_flags { |
340 | MPA_INITIATOR = (1<<0), | 380 | MPA_INITIATOR = (1<<0), |
341 | PRIV_QP = (1<<1), | 381 | PRIV_QP = (1<<1), |
@@ -346,13 +386,16 @@ union t3_wr { | |||
346 | struct t3_rdma_write_wr write; | 386 | struct t3_rdma_write_wr write; |
347 | struct t3_rdma_read_wr read; | 387 | struct t3_rdma_read_wr read; |
348 | struct t3_receive_wr recv; | 388 | struct t3_receive_wr recv; |
389 | struct t3_fastreg_wr fastreg; | ||
390 | struct t3_pbl_frag pbl_frag; | ||
349 | struct t3_local_inv_wr local_inv; | 391 | struct t3_local_inv_wr local_inv; |
350 | struct t3_bind_mw_wr bind; | 392 | struct t3_bind_mw_wr bind; |
351 | struct t3_bypass_wr bypass; | 393 | struct t3_bypass_wr bypass; |
352 | struct t3_rdma_init_wr init; | 394 | struct t3_rdma_init_wr init; |
353 | struct t3_modify_qp_wr qp_mod; | 395 | struct t3_modify_qp_wr qp_mod; |
354 | struct t3_genbit genbit; | 396 | struct t3_genbit genbit; |
355 | u64 flit[16]; | 397 | struct t3_wq_in_err wq_in_err; |
398 | __be64 flit[16]; | ||
356 | }; | 399 | }; |
357 | 400 | ||
358 | #define T3_SQ_CQE_FLIT 13 | 401 | #define T3_SQ_CQE_FLIT 13 |
@@ -366,12 +409,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)); | 409 | return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags)); |
367 | } | 410 | } |
368 | 411 | ||
412 | enum t3_wr_hdr_bits { | ||
413 | T3_EOP = 1, | ||
414 | T3_SOP = 2, | ||
415 | T3_SOPEOP = T3_EOP|T3_SOP, | ||
416 | }; | ||
417 | |||
369 | static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, | 418 | 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, | 419 | enum t3_wr_flags flags, u8 genbit, u32 tid, |
371 | u8 len) | 420 | u8 len, u8 sopeop) |
372 | { | 421 | { |
373 | wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | | 422 | wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | |
374 | V_FW_RIWR_SOPEOP(M_FW_RIWR_SOPEOP) | | 423 | V_FW_RIWR_SOPEOP(sopeop) | |
375 | V_FW_RIWR_FLAGS(flags)); | 424 | V_FW_RIWR_FLAGS(flags)); |
376 | wmb(); | 425 | wmb(); |
377 | wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | | 426 | wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | |
@@ -404,6 +453,7 @@ enum tpt_addr_type { | |||
404 | }; | 453 | }; |
405 | 454 | ||
406 | enum tpt_mem_perm { | 455 | enum tpt_mem_perm { |
456 | TPT_MW_BIND = 0x10, | ||
407 | TPT_LOCAL_READ = 0x8, | 457 | TPT_LOCAL_READ = 0x8, |
408 | TPT_LOCAL_WRITE = 0x4, | 458 | TPT_LOCAL_WRITE = 0x4, |
409 | TPT_REMOTE_READ = 0x2, | 459 | TPT_REMOTE_READ = 0x2, |
@@ -659,7 +709,7 @@ struct t3_cq { | |||
659 | 709 | ||
660 | static inline void cxio_set_wq_in_error(struct t3_wq *wq) | 710 | static inline void cxio_set_wq_in_error(struct t3_wq *wq) |
661 | { | 711 | { |
662 | wq->queue->flit[13] = 1; | 712 | wq->queue->wq_in_err.err = 1; |
663 | } | 713 | } |
664 | 714 | ||
665 | static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) | 715 | static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) |
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..5d504f3ed68b 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -768,6 +768,68 @@ static int iwch_dealloc_mw(struct ib_mw *mw) | |||
768 | return 0; | 768 | return 0; |
769 | } | 769 | } |
770 | 770 | ||
771 | static struct ib_mr *iwch_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth) | ||
772 | { | ||
773 | struct iwch_dev *rhp; | ||
774 | struct iwch_pd *php; | ||
775 | struct iwch_mr *mhp; | ||
776 | u32 mmid; | ||
777 | u32 stag = 0; | ||
778 | int ret; | ||
779 | |||
780 | php = to_iwch_pd(pd); | ||
781 | rhp = php->rhp; | ||
782 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | ||
783 | if (!mhp) | ||
784 | return ERR_PTR(-ENOMEM); | ||
785 | |||
786 | mhp->rhp = rhp; | ||
787 | ret = iwch_alloc_pbl(mhp, pbl_depth); | ||
788 | if (ret) { | ||
789 | kfree(mhp); | ||
790 | return ERR_PTR(ret); | ||
791 | } | ||
792 | mhp->attr.pbl_size = pbl_depth; | ||
793 | ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid, | ||
794 | mhp->attr.pbl_size, mhp->attr.pbl_addr); | ||
795 | if (ret) { | ||
796 | iwch_free_pbl(mhp); | ||
797 | kfree(mhp); | ||
798 | return ERR_PTR(ret); | ||
799 | } | ||
800 | mhp->attr.pdid = php->pdid; | ||
801 | mhp->attr.type = TPT_NON_SHARED_MR; | ||
802 | mhp->attr.stag = stag; | ||
803 | mhp->attr.state = 1; | ||
804 | mmid = (stag) >> 8; | ||
805 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; | ||
806 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | ||
807 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); | ||
808 | return &(mhp->ibmr); | ||
809 | } | ||
810 | |||
811 | static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl( | ||
812 | struct ib_device *device, | ||
813 | int page_list_len) | ||
814 | { | ||
815 | struct ib_fast_reg_page_list *page_list; | ||
816 | |||
817 | page_list = kmalloc(sizeof *page_list + page_list_len * sizeof(u64), | ||
818 | GFP_KERNEL); | ||
819 | if (!page_list) | ||
820 | return ERR_PTR(-ENOMEM); | ||
821 | |||
822 | page_list->page_list = (u64 *)(page_list + 1); | ||
823 | page_list->max_page_list_len = page_list_len; | ||
824 | |||
825 | return page_list; | ||
826 | } | ||
827 | |||
828 | static void iwch_free_fastreg_pbl(struct ib_fast_reg_page_list *page_list) | ||
829 | { | ||
830 | kfree(page_list); | ||
831 | } | ||
832 | |||
771 | static int iwch_destroy_qp(struct ib_qp *ib_qp) | 833 | static int iwch_destroy_qp(struct ib_qp *ib_qp) |
772 | { | 834 | { |
773 | struct iwch_dev *rhp; | 835 | struct iwch_dev *rhp; |
@@ -843,6 +905,15 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | |||
843 | */ | 905 | */ |
844 | sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); | 906 | sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); |
845 | wqsize = roundup_pow_of_two(rqsize + sqsize); | 907 | wqsize = roundup_pow_of_two(rqsize + sqsize); |
908 | |||
909 | /* | ||
910 | * Kernel users need more wq space for fastreg WRs which can take | ||
911 | * 2 WR fragments. | ||
912 | */ | ||
913 | ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL; | ||
914 | if (!ucontext && wqsize < (rqsize + (2 * sqsize))) | ||
915 | wqsize = roundup_pow_of_two(rqsize + | ||
916 | roundup_pow_of_two(attrs->cap.max_send_wr * 2)); | ||
846 | PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__, | 917 | PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__, |
847 | wqsize, sqsize, rqsize); | 918 | wqsize, sqsize, rqsize); |
848 | qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); | 919 | qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); |
@@ -851,7 +922,6 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | |||
851 | qhp->wq.size_log2 = ilog2(wqsize); | 922 | qhp->wq.size_log2 = ilog2(wqsize); |
852 | qhp->wq.rq_size_log2 = ilog2(rqsize); | 923 | qhp->wq.rq_size_log2 = ilog2(rqsize); |
853 | qhp->wq.sq_size_log2 = ilog2(sqsize); | 924 | 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, | 925 | if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq, |
856 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { | 926 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { |
857 | kfree(qhp); | 927 | kfree(qhp); |
@@ -1048,6 +1118,7 @@ static int iwch_query_device(struct ib_device *ibdev, | |||
1048 | props->max_mr = dev->attr.max_mem_regs; | 1118 | props->max_mr = dev->attr.max_mem_regs; |
1049 | props->max_pd = dev->attr.max_pds; | 1119 | props->max_pd = dev->attr.max_pds; |
1050 | props->local_ca_ack_delay = 0; | 1120 | props->local_ca_ack_delay = 0; |
1121 | props->max_fast_reg_page_list_len = T3_MAX_FASTREG_DEPTH; | ||
1051 | 1122 | ||
1052 | return 0; | 1123 | return 0; |
1053 | } | 1124 | } |
@@ -1088,6 +1159,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); | 1159 | return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); |
1089 | } | 1160 | } |
1090 | 1161 | ||
1162 | static int fw_supports_fastreg(struct iwch_dev *iwch_dev) | ||
1163 | { | ||
1164 | struct ethtool_drvinfo info; | ||
1165 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | ||
1166 | char *cp, *next; | ||
1167 | unsigned fw_maj, fw_min; | ||
1168 | |||
1169 | rtnl_lock(); | ||
1170 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | ||
1171 | rtnl_unlock(); | ||
1172 | |||
1173 | next = info.fw_version+1; | ||
1174 | cp = strsep(&next, "."); | ||
1175 | sscanf(cp, "%i", &fw_maj); | ||
1176 | cp = strsep(&next, "."); | ||
1177 | sscanf(cp, "%i", &fw_min); | ||
1178 | |||
1179 | PDBG("%s maj %u min %u\n", __func__, fw_maj, fw_min); | ||
1180 | |||
1181 | return fw_maj > 6 || (fw_maj == 6 && fw_min > 0); | ||
1182 | } | ||
1183 | |||
1091 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) | 1184 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) |
1092 | { | 1185 | { |
1093 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, | 1186 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, |
@@ -1149,8 +1242,10 @@ int iwch_register_device(struct iwch_dev *dev) | |||
1149 | memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); | 1242 | 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); | 1243 | memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); |
1151 | dev->ibdev.owner = THIS_MODULE; | 1244 | dev->ibdev.owner = THIS_MODULE; |
1152 | dev->device_cap_flags = | 1245 | dev->device_cap_flags = IB_DEVICE_ZERO_STAG | |
1153 | (IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW); | 1246 | IB_DEVICE_MEM_WINDOW; |
1247 | if (fw_supports_fastreg(dev)) | ||
1248 | dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; | ||
1154 | 1249 | ||
1155 | dev->ibdev.uverbs_cmd_mask = | 1250 | dev->ibdev.uverbs_cmd_mask = |
1156 | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | | 1251 | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | |
@@ -1202,6 +1297,9 @@ int iwch_register_device(struct iwch_dev *dev) | |||
1202 | dev->ibdev.alloc_mw = iwch_alloc_mw; | 1297 | dev->ibdev.alloc_mw = iwch_alloc_mw; |
1203 | dev->ibdev.bind_mw = iwch_bind_mw; | 1298 | dev->ibdev.bind_mw = iwch_bind_mw; |
1204 | dev->ibdev.dealloc_mw = iwch_dealloc_mw; | 1299 | dev->ibdev.dealloc_mw = iwch_dealloc_mw; |
1300 | dev->ibdev.alloc_fast_reg_mr = iwch_alloc_fast_reg_mr; | ||
1301 | dev->ibdev.alloc_fast_reg_page_list = iwch_alloc_fastreg_pbl; | ||
1302 | dev->ibdev.free_fast_reg_page_list = iwch_free_fastreg_pbl; | ||
1205 | 1303 | ||
1206 | dev->ibdev.attach_mcast = iwch_multicast_attach; | 1304 | dev->ibdev.attach_mcast = iwch_multicast_attach; |
1207 | dev->ibdev.detach_mcast = iwch_multicast_detach; | 1305 | dev->ibdev.detach_mcast = iwch_multicast_detach; |
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..3b44300a3036 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c | |||
@@ -44,54 +44,39 @@ static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, | |||
44 | 44 | ||
45 | switch (wr->opcode) { | 45 | switch (wr->opcode) { |
46 | case IB_WR_SEND: | 46 | case IB_WR_SEND: |
47 | case IB_WR_SEND_WITH_IMM: | ||
48 | if (wr->send_flags & IB_SEND_SOLICITED) | 47 | if (wr->send_flags & IB_SEND_SOLICITED) |
49 | wqe->send.rdmaop = T3_SEND_WITH_SE; | 48 | wqe->send.rdmaop = T3_SEND_WITH_SE; |
50 | else | 49 | else |
51 | wqe->send.rdmaop = T3_SEND; | 50 | wqe->send.rdmaop = T3_SEND; |
52 | wqe->send.rem_stag = 0; | 51 | wqe->send.rem_stag = 0; |
53 | break; | 52 | break; |
54 | #if 0 /* Not currently supported */ | 53 | case IB_WR_SEND_WITH_INV: |
55 | case TYPE_SEND_INVALIDATE: | 54 | if (wr->send_flags & IB_SEND_SOLICITED) |
56 | case TYPE_SEND_INVALIDATE_IMMEDIATE: | 55 | wqe->send.rdmaop = T3_SEND_WITH_SE_INV; |
57 | wqe->send.rdmaop = T3_SEND_WITH_INV; | 56 | else |
58 | wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | 57 | wqe->send.rdmaop = T3_SEND_WITH_INV; |
59 | break; | 58 | 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; | 59 | break; |
64 | #endif | ||
65 | default: | 60 | default: |
66 | break; | 61 | return -EINVAL; |
67 | } | 62 | } |
68 | if (wr->num_sge > T3_MAX_SGE) | 63 | if (wr->num_sge > T3_MAX_SGE) |
69 | return -EINVAL; | 64 | return -EINVAL; |
70 | wqe->send.reserved[0] = 0; | 65 | wqe->send.reserved[0] = 0; |
71 | wqe->send.reserved[1] = 0; | 66 | wqe->send.reserved[1] = 0; |
72 | wqe->send.reserved[2] = 0; | 67 | wqe->send.reserved[2] = 0; |
73 | if (wr->opcode == IB_WR_SEND_WITH_IMM) { | 68 | plen = 0; |
74 | plen = 4; | 69 | for (i = 0; i < wr->num_sge; i++) { |
75 | wqe->send.sgl[0].stag = wr->ex.imm_data; | 70 | if ((plen + wr->sg_list[i].length) < plen) |
76 | wqe->send.sgl[0].len = __constant_cpu_to_be32(0); | 71 | return -EMSGSIZE; |
77 | wqe->send.num_sgle = __constant_cpu_to_be32(0); | 72 | |
78 | *flit_cnt = 5; | 73 | plen += wr->sg_list[i].length; |
79 | } else { | 74 | wqe->send.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); |
80 | plen = 0; | 75 | wqe->send.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); |
81 | for (i = 0; i < wr->num_sge; i++) { | 76 | 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 | } | 77 | } |
78 | wqe->send.num_sgle = cpu_to_be32(wr->num_sge); | ||
79 | *flit_cnt = 4 + ((wr->num_sge) << 1); | ||
95 | wqe->send.plen = cpu_to_be32(plen); | 80 | wqe->send.plen = cpu_to_be32(plen); |
96 | return 0; | 81 | return 0; |
97 | } | 82 | } |
@@ -143,9 +128,12 @@ static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, | |||
143 | if (wr->num_sge > 1) | 128 | if (wr->num_sge > 1) |
144 | return -EINVAL; | 129 | return -EINVAL; |
145 | wqe->read.rdmaop = T3_READ_REQ; | 130 | wqe->read.rdmaop = T3_READ_REQ; |
131 | if (wr->opcode == IB_WR_RDMA_READ_WITH_INV) | ||
132 | wqe->read.local_inv = 1; | ||
133 | else | ||
134 | wqe->read.local_inv = 0; | ||
146 | wqe->read.reserved[0] = 0; | 135 | wqe->read.reserved[0] = 0; |
147 | wqe->read.reserved[1] = 0; | 136 | wqe->read.reserved[1] = 0; |
148 | wqe->read.reserved[2] = 0; | ||
149 | wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | 137 | wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); |
150 | wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr); | 138 | 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); | 139 | wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey); |
@@ -155,6 +143,57 @@ static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, | |||
155 | return 0; | 143 | return 0; |
156 | } | 144 | } |
157 | 145 | ||
146 | static int iwch_build_fastreg(union t3_wr *wqe, struct ib_send_wr *wr, | ||
147 | u8 *flit_cnt, int *wr_cnt, struct t3_wq *wq) | ||
148 | { | ||
149 | int i; | ||
150 | __be64 *p; | ||
151 | |||
152 | if (wr->wr.fast_reg.page_list_len > T3_MAX_FASTREG_DEPTH) | ||
153 | return -EINVAL; | ||
154 | *wr_cnt = 1; | ||
155 | wqe->fastreg.stag = cpu_to_be32(wr->wr.fast_reg.rkey); | ||
156 | wqe->fastreg.len = cpu_to_be32(wr->wr.fast_reg.length); | ||
157 | wqe->fastreg.va_base_hi = cpu_to_be32(wr->wr.fast_reg.iova_start >> 32); | ||
158 | wqe->fastreg.va_base_lo_fbo = | ||
159 | cpu_to_be32(wr->wr.fast_reg.iova_start & 0xffffffff); | ||
160 | wqe->fastreg.page_type_perms = cpu_to_be32( | ||
161 | V_FR_PAGE_COUNT(wr->wr.fast_reg.page_list_len) | | ||
162 | V_FR_PAGE_SIZE(wr->wr.fast_reg.page_shift-12) | | ||
163 | V_FR_TYPE(TPT_VATO) | | ||
164 | V_FR_PERMS(iwch_ib_to_tpt_access(wr->wr.fast_reg.access_flags))); | ||
165 | p = &wqe->fastreg.pbl_addrs[0]; | ||
166 | for (i = 0; i < wr->wr.fast_reg.page_list_len; i++, p++) { | ||
167 | |||
168 | /* If we need a 2nd WR, then set it up */ | ||
169 | if (i == T3_MAX_FASTREG_FRAG) { | ||
170 | *wr_cnt = 2; | ||
171 | wqe = (union t3_wr *)(wq->queue + | ||
172 | Q_PTR2IDX((wq->wptr+1), wq->size_log2)); | ||
173 | build_fw_riwrh((void *)wqe, T3_WR_FASTREG, 0, | ||
174 | Q_GENBIT(wq->wptr + 1, wq->size_log2), | ||
175 | 0, 1 + wr->wr.fast_reg.page_list_len - T3_MAX_FASTREG_FRAG, | ||
176 | T3_EOP); | ||
177 | |||
178 | p = &wqe->pbl_frag.pbl_addrs[0]; | ||
179 | } | ||
180 | *p = cpu_to_be64((u64)wr->wr.fast_reg.page_list->page_list[i]); | ||
181 | } | ||
182 | *flit_cnt = 5 + wr->wr.fast_reg.page_list_len; | ||
183 | if (*flit_cnt > 15) | ||
184 | *flit_cnt = 15; | ||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | static int iwch_build_inv_stag(union t3_wr *wqe, struct ib_send_wr *wr, | ||
189 | u8 *flit_cnt) | ||
190 | { | ||
191 | wqe->local_inv.stag = cpu_to_be32(wr->ex.invalidate_rkey); | ||
192 | wqe->local_inv.reserved = 0; | ||
193 | *flit_cnt = sizeof(struct t3_local_inv_wr) >> 3; | ||
194 | return 0; | ||
195 | } | ||
196 | |||
158 | /* | 197 | /* |
159 | * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. | 198 | * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. |
160 | */ | 199 | */ |
@@ -238,6 +277,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
238 | u32 num_wrs; | 277 | u32 num_wrs; |
239 | unsigned long flag; | 278 | unsigned long flag; |
240 | struct t3_swsq *sqp; | 279 | struct t3_swsq *sqp; |
280 | int wr_cnt = 1; | ||
241 | 281 | ||
242 | qhp = to_iwch_qp(ibqp); | 282 | qhp = to_iwch_qp(ibqp); |
243 | spin_lock_irqsave(&qhp->lock, flag); | 283 | spin_lock_irqsave(&qhp->lock, flag); |
@@ -262,15 +302,15 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
262 | t3_wr_flags = 0; | 302 | t3_wr_flags = 0; |
263 | if (wr->send_flags & IB_SEND_SOLICITED) | 303 | if (wr->send_flags & IB_SEND_SOLICITED) |
264 | t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; | 304 | 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) | 305 | if (wr->send_flags & IB_SEND_SIGNALED) |
268 | t3_wr_flags |= T3_COMPLETION_FLAG; | 306 | t3_wr_flags |= T3_COMPLETION_FLAG; |
269 | sqp = qhp->wq.sq + | 307 | sqp = qhp->wq.sq + |
270 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); | 308 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); |
271 | switch (wr->opcode) { | 309 | switch (wr->opcode) { |
272 | case IB_WR_SEND: | 310 | case IB_WR_SEND: |
273 | case IB_WR_SEND_WITH_IMM: | 311 | case IB_WR_SEND_WITH_INV: |
312 | if (wr->send_flags & IB_SEND_FENCE) | ||
313 | t3_wr_flags |= T3_READ_FENCE_FLAG; | ||
274 | t3_wr_opcode = T3_WR_SEND; | 314 | t3_wr_opcode = T3_WR_SEND; |
275 | err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); | 315 | err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); |
276 | break; | 316 | break; |
@@ -280,6 +320,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
280 | err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); | 320 | err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); |
281 | break; | 321 | break; |
282 | case IB_WR_RDMA_READ: | 322 | case IB_WR_RDMA_READ: |
323 | case IB_WR_RDMA_READ_WITH_INV: | ||
283 | t3_wr_opcode = T3_WR_READ; | 324 | t3_wr_opcode = T3_WR_READ; |
284 | t3_wr_flags = 0; /* T3 reads are always signaled */ | 325 | t3_wr_flags = 0; /* T3 reads are always signaled */ |
285 | err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); | 326 | err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); |
@@ -289,6 +330,17 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
289 | if (!qhp->wq.oldest_read) | 330 | if (!qhp->wq.oldest_read) |
290 | qhp->wq.oldest_read = sqp; | 331 | qhp->wq.oldest_read = sqp; |
291 | break; | 332 | break; |
333 | case IB_WR_FAST_REG_MR: | ||
334 | t3_wr_opcode = T3_WR_FASTREG; | ||
335 | err = iwch_build_fastreg(wqe, wr, &t3_wr_flit_cnt, | ||
336 | &wr_cnt, &qhp->wq); | ||
337 | break; | ||
338 | case IB_WR_LOCAL_INV: | ||
339 | if (wr->send_flags & IB_SEND_FENCE) | ||
340 | t3_wr_flags |= T3_LOCAL_FENCE_FLAG; | ||
341 | t3_wr_opcode = T3_WR_INV_STAG; | ||
342 | err = iwch_build_inv_stag(wqe, wr, &t3_wr_flit_cnt); | ||
343 | break; | ||
292 | default: | 344 | default: |
293 | PDBG("%s post of type=%d TBD!\n", __func__, | 345 | PDBG("%s post of type=%d TBD!\n", __func__, |
294 | wr->opcode); | 346 | wr->opcode); |
@@ -307,14 +359,15 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
307 | 359 | ||
308 | build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, | 360 | build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, |
309 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), | 361 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), |
310 | 0, t3_wr_flit_cnt); | 362 | 0, t3_wr_flit_cnt, |
363 | (wr_cnt == 1) ? T3_SOPEOP : T3_SOP); | ||
311 | PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", | 364 | PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", |
312 | __func__, (unsigned long long) wr->wr_id, idx, | 365 | __func__, (unsigned long long) wr->wr_id, idx, |
313 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), | 366 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), |
314 | sqp->opcode); | 367 | sqp->opcode); |
315 | wr = wr->next; | 368 | wr = wr->next; |
316 | num_wrs--; | 369 | num_wrs--; |
317 | ++(qhp->wq.wptr); | 370 | qhp->wq.wptr += wr_cnt; |
318 | ++(qhp->wq.sq_wptr); | 371 | ++(qhp->wq.sq_wptr); |
319 | } | 372 | } |
320 | spin_unlock_irqrestore(&qhp->lock, flag); | 373 | spin_unlock_irqrestore(&qhp->lock, flag); |
@@ -359,7 +412,7 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
359 | wr->wr_id; | 412 | wr->wr_id; |
360 | build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, | 413 | build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, |
361 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), | 414 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), |
362 | 0, sizeof(struct t3_receive_wr) >> 3); | 415 | 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 " | 416 | 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, | 417 | "wqe %p \n", __func__, (unsigned long long) wr->wr_id, |
365 | idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); | 418 | idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); |
@@ -419,10 +472,10 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
419 | sgl.lkey = mw_bind->mr->lkey; | 472 | sgl.lkey = mw_bind->mr->lkey; |
420 | sgl.length = mw_bind->length; | 473 | sgl.length = mw_bind->length; |
421 | wqe->bind.reserved = 0; | 474 | wqe->bind.reserved = 0; |
422 | wqe->bind.type = T3_VA_BASED_TO; | 475 | wqe->bind.type = TPT_VATO; |
423 | 476 | ||
424 | /* TBD: check perms */ | 477 | /* TBD: check perms */ |
425 | wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags); | 478 | 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); | 479 | wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); |
427 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); | 480 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); |
428 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); | 481 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); |
@@ -430,7 +483,7 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
430 | err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); | 483 | err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); |
431 | if (err) { | 484 | if (err) { |
432 | spin_unlock_irqrestore(&qhp->lock, flag); | 485 | spin_unlock_irqrestore(&qhp->lock, flag); |
433 | return err; | 486 | return err; |
434 | } | 487 | } |
435 | wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; | 488 | 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); | 489 | sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); |
@@ -441,10 +494,9 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
441 | sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); | 494 | sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); |
442 | wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); | 495 | wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); |
443 | wqe->bind.mr_pagesz = page_size; | 496 | 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, | 497 | build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags, |
446 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, | 498 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, |
447 | sizeof(struct t3_bind_mw_wr) >> 3); | 499 | sizeof(struct t3_bind_mw_wr) >> 3, T3_SOPEOP); |
448 | ++(qhp->wq.wptr); | 500 | ++(qhp->wq.wptr); |
449 | ++(qhp->wq.sq_wptr); | 501 | ++(qhp->wq.sq_wptr); |
450 | spin_unlock_irqrestore(&qhp->lock, flag); | 502 | spin_unlock_irqrestore(&qhp->lock, flag); |