diff options
Diffstat (limited to 'drivers/infiniband/hw/cxgb3/iwch_ev.c')
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_ev.c | 231 |
1 files changed, 231 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/cxgb3/iwch_ev.c b/drivers/infiniband/hw/cxgb3/iwch_ev.c new file mode 100644 index 000000000000..a6efa8fe15d8 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_ev.c | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/mman.h> | ||
35 | #include <net/sock.h> | ||
36 | #include "iwch_provider.h" | ||
37 | #include "iwch.h" | ||
38 | #include "iwch_cm.h" | ||
39 | #include "cxio_hal.h" | ||
40 | #include "cxio_wr.h" | ||
41 | |||
42 | static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp, | ||
43 | struct respQ_msg_t *rsp_msg, | ||
44 | enum ib_event_type ib_event, | ||
45 | int send_term) | ||
46 | { | ||
47 | struct ib_event event; | ||
48 | struct iwch_qp_attributes attrs; | ||
49 | struct iwch_qp *qhp; | ||
50 | |||
51 | printk(KERN_ERR "%s - AE qpid 0x%x opcode %d status 0x%x " | ||
52 | "type %d wrid.hi 0x%x wrid.lo 0x%x \n", __FUNCTION__, | ||
53 | CQE_QPID(rsp_msg->cqe), CQE_OPCODE(rsp_msg->cqe), | ||
54 | CQE_STATUS(rsp_msg->cqe), CQE_TYPE(rsp_msg->cqe), | ||
55 | CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe)); | ||
56 | |||
57 | spin_lock(&rnicp->lock); | ||
58 | qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe)); | ||
59 | |||
60 | if (!qhp) { | ||
61 | printk(KERN_ERR "%s unaffiliated error 0x%x qpid 0x%x\n", | ||
62 | __FUNCTION__, CQE_STATUS(rsp_msg->cqe), | ||
63 | CQE_QPID(rsp_msg->cqe)); | ||
64 | spin_unlock(&rnicp->lock); | ||
65 | return; | ||
66 | } | ||
67 | |||
68 | if ((qhp->attr.state == IWCH_QP_STATE_ERROR) || | ||
69 | (qhp->attr.state == IWCH_QP_STATE_TERMINATE)) { | ||
70 | PDBG("%s AE received after RTS - " | ||
71 | "qp state %d qpid 0x%x status 0x%x\n", __FUNCTION__, | ||
72 | qhp->attr.state, qhp->wq.qpid, CQE_STATUS(rsp_msg->cqe)); | ||
73 | spin_unlock(&rnicp->lock); | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | atomic_inc(&qhp->refcnt); | ||
78 | spin_unlock(&rnicp->lock); | ||
79 | |||
80 | event.event = ib_event; | ||
81 | event.device = chp->ibcq.device; | ||
82 | if (ib_event == IB_EVENT_CQ_ERR) | ||
83 | event.element.cq = &chp->ibcq; | ||
84 | else | ||
85 | event.element.qp = &qhp->ibqp; | ||
86 | |||
87 | if (qhp->ibqp.event_handler) | ||
88 | (*qhp->ibqp.event_handler)(&event, qhp->ibqp.qp_context); | ||
89 | |||
90 | if (qhp->attr.state == IWCH_QP_STATE_RTS) { | ||
91 | attrs.next_state = IWCH_QP_STATE_TERMINATE; | ||
92 | iwch_modify_qp(qhp->rhp, qhp, IWCH_QP_ATTR_NEXT_STATE, | ||
93 | &attrs, 1); | ||
94 | if (send_term) | ||
95 | iwch_post_terminate(qhp, rsp_msg); | ||
96 | } | ||
97 | |||
98 | if (atomic_dec_and_test(&qhp->refcnt)) | ||
99 | wake_up(&qhp->wait); | ||
100 | } | ||
101 | |||
102 | void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb) | ||
103 | { | ||
104 | struct iwch_dev *rnicp; | ||
105 | struct respQ_msg_t *rsp_msg = (struct respQ_msg_t *) skb->data; | ||
106 | struct iwch_cq *chp; | ||
107 | struct iwch_qp *qhp; | ||
108 | u32 cqid = RSPQ_CQID(rsp_msg); | ||
109 | |||
110 | rnicp = (struct iwch_dev *) rdev_p->ulp; | ||
111 | spin_lock(&rnicp->lock); | ||
112 | chp = get_chp(rnicp, cqid); | ||
113 | qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe)); | ||
114 | if (!chp || !qhp) { | ||
115 | printk(KERN_ERR MOD "BAD AE cqid 0x%x qpid 0x%x opcode %d " | ||
116 | "status 0x%x type %d wrid.hi 0x%x wrid.lo 0x%x \n", | ||
117 | cqid, CQE_QPID(rsp_msg->cqe), | ||
118 | CQE_OPCODE(rsp_msg->cqe), CQE_STATUS(rsp_msg->cqe), | ||
119 | CQE_TYPE(rsp_msg->cqe), CQE_WRID_HI(rsp_msg->cqe), | ||
120 | CQE_WRID_LOW(rsp_msg->cqe)); | ||
121 | spin_unlock(&rnicp->lock); | ||
122 | goto out; | ||
123 | } | ||
124 | iwch_qp_add_ref(&qhp->ibqp); | ||
125 | atomic_inc(&chp->refcnt); | ||
126 | spin_unlock(&rnicp->lock); | ||
127 | |||
128 | /* | ||
129 | * 1) completion of our sending a TERMINATE. | ||
130 | * 2) incoming TERMINATE message. | ||
131 | */ | ||
132 | if ((CQE_OPCODE(rsp_msg->cqe) == T3_TERMINATE) && | ||
133 | (CQE_STATUS(rsp_msg->cqe) == 0)) { | ||
134 | if (SQ_TYPE(rsp_msg->cqe)) { | ||
135 | PDBG("%s QPID 0x%x ep %p disconnecting\n", | ||
136 | __FUNCTION__, qhp->wq.qpid, qhp->ep); | ||
137 | iwch_ep_disconnect(qhp->ep, 0, GFP_ATOMIC); | ||
138 | } else { | ||
139 | PDBG("%s post REQ_ERR AE QPID 0x%x\n", __FUNCTION__, | ||
140 | qhp->wq.qpid); | ||
141 | post_qp_event(rnicp, chp, rsp_msg, | ||
142 | IB_EVENT_QP_REQ_ERR, 0); | ||
143 | iwch_ep_disconnect(qhp->ep, 0, GFP_ATOMIC); | ||
144 | } | ||
145 | goto done; | ||
146 | } | ||
147 | |||
148 | /* Bad incoming Read request */ | ||
149 | if (SQ_TYPE(rsp_msg->cqe) && | ||
150 | (CQE_OPCODE(rsp_msg->cqe) == T3_READ_RESP)) { | ||
151 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_REQ_ERR, 1); | ||
152 | goto done; | ||
153 | } | ||
154 | |||
155 | /* Bad incoming write */ | ||
156 | if (RQ_TYPE(rsp_msg->cqe) && | ||
157 | (CQE_OPCODE(rsp_msg->cqe) == T3_RDMA_WRITE)) { | ||
158 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_REQ_ERR, 1); | ||
159 | goto done; | ||
160 | } | ||
161 | |||
162 | switch (CQE_STATUS(rsp_msg->cqe)) { | ||
163 | |||
164 | /* Completion Events */ | ||
165 | case TPT_ERR_SUCCESS: | ||
166 | |||
167 | /* | ||
168 | * Confirm the destination entry if this is a RECV completion. | ||
169 | */ | ||
170 | if (qhp->ep && SQ_TYPE(rsp_msg->cqe)) | ||
171 | dst_confirm(qhp->ep->dst); | ||
172 | (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); | ||
173 | break; | ||
174 | |||
175 | case TPT_ERR_STAG: | ||
176 | case TPT_ERR_PDID: | ||
177 | case TPT_ERR_QPID: | ||
178 | case TPT_ERR_ACCESS: | ||
179 | case TPT_ERR_WRAP: | ||
180 | case TPT_ERR_BOUND: | ||
181 | case TPT_ERR_INVALIDATE_SHARED_MR: | ||
182 | case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND: | ||
183 | printk(KERN_ERR "%s - CQE Err qpid 0x%x opcode %d status 0x%x " | ||
184 | "type %d wrid.hi 0x%x wrid.lo 0x%x \n", __FUNCTION__, | ||
185 | CQE_QPID(rsp_msg->cqe), CQE_OPCODE(rsp_msg->cqe), | ||
186 | CQE_STATUS(rsp_msg->cqe), CQE_TYPE(rsp_msg->cqe), | ||
187 | CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe)); | ||
188 | (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); | ||
189 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_ACCESS_ERR, 1); | ||
190 | break; | ||
191 | |||
192 | /* Device Fatal Errors */ | ||
193 | case TPT_ERR_ECC: | ||
194 | case TPT_ERR_ECC_PSTAG: | ||
195 | case TPT_ERR_INTERNAL_ERR: | ||
196 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_DEVICE_FATAL, 1); | ||
197 | break; | ||
198 | |||
199 | /* QP Fatal Errors */ | ||
200 | case TPT_ERR_OUT_OF_RQE: | ||
201 | case TPT_ERR_PBL_ADDR_BOUND: | ||
202 | case TPT_ERR_CRC: | ||
203 | case TPT_ERR_MARKER: | ||
204 | case TPT_ERR_PDU_LEN_ERR: | ||
205 | case TPT_ERR_DDP_VERSION: | ||
206 | case TPT_ERR_RDMA_VERSION: | ||
207 | case TPT_ERR_OPCODE: | ||
208 | case TPT_ERR_DDP_QUEUE_NUM: | ||
209 | case TPT_ERR_MSN: | ||
210 | case TPT_ERR_TBIT: | ||
211 | case TPT_ERR_MO: | ||
212 | case TPT_ERR_MSN_GAP: | ||
213 | case TPT_ERR_MSN_RANGE: | ||
214 | case TPT_ERR_RQE_ADDR_BOUND: | ||
215 | case TPT_ERR_IRD_OVERFLOW: | ||
216 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_FATAL, 1); | ||
217 | break; | ||
218 | |||
219 | default: | ||
220 | printk(KERN_ERR MOD "Unknown T3 status 0x%x QPID 0x%x\n", | ||
221 | CQE_STATUS(rsp_msg->cqe), qhp->wq.qpid); | ||
222 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_FATAL, 1); | ||
223 | break; | ||
224 | } | ||
225 | done: | ||
226 | if (atomic_dec_and_test(&chp->refcnt)) | ||
227 | wake_up(&chp->wait); | ||
228 | iwch_qp_rem_ref(&qhp->ibqp); | ||
229 | out: | ||
230 | dev_kfree_skb_irq(skb); | ||
231 | } | ||