1 /* QLogic qedr NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #include <net/addrconf.h>
36 #include <net/route.h>
37 #include <net/ip6_route.h>
40 #include "qedr_iw_cm.h"
43 qedr_fill_sockaddr4(const struct qed_iwarp_cm_info
*cm_info
,
44 struct iw_cm_event
*event
)
46 struct sockaddr_in
*laddr
= (struct sockaddr_in
*)&event
->local_addr
;
47 struct sockaddr_in
*raddr
= (struct sockaddr_in
*)&event
->remote_addr
;
49 laddr
->sin_family
= AF_INET
;
50 raddr
->sin_family
= AF_INET
;
52 laddr
->sin_port
= htons(cm_info
->local_port
);
53 raddr
->sin_port
= htons(cm_info
->remote_port
);
55 laddr
->sin_addr
.s_addr
= htonl(cm_info
->local_ip
[0]);
56 raddr
->sin_addr
.s_addr
= htonl(cm_info
->remote_ip
[0]);
60 qedr_fill_sockaddr6(const struct qed_iwarp_cm_info
*cm_info
,
61 struct iw_cm_event
*event
)
63 struct sockaddr_in6
*laddr6
= (struct sockaddr_in6
*)&event
->local_addr
;
64 struct sockaddr_in6
*raddr6
=
65 (struct sockaddr_in6
*)&event
->remote_addr
;
68 laddr6
->sin6_family
= AF_INET6
;
69 raddr6
->sin6_family
= AF_INET6
;
71 laddr6
->sin6_port
= htons(cm_info
->local_port
);
72 raddr6
->sin6_port
= htons(cm_info
->remote_port
);
74 for (i
= 0; i
< 4; i
++) {
75 laddr6
->sin6_addr
.in6_u
.u6_addr32
[i
] =
76 htonl(cm_info
->local_ip
[i
]);
77 raddr6
->sin6_addr
.in6_u
.u6_addr32
[i
] =
78 htonl(cm_info
->remote_ip
[i
]);
83 qedr_iw_mpa_request(void *context
, struct qed_iwarp_cm_event_params
*params
)
85 struct qedr_iw_listener
*listener
= (struct qedr_iw_listener
*)context
;
86 struct qedr_dev
*dev
= listener
->dev
;
87 struct iw_cm_event event
;
88 struct qedr_iw_ep
*ep
;
90 ep
= kzalloc(sizeof(*ep
), GFP_ATOMIC
);
95 ep
->qed_context
= params
->ep_context
;
97 memset(&event
, 0, sizeof(event
));
98 event
.event
= IW_CM_EVENT_CONNECT_REQUEST
;
99 event
.status
= params
->status
;
101 if (!IS_ENABLED(CONFIG_IPV6
) ||
102 params
->cm_info
->ip_version
== QED_TCP_IPV4
)
103 qedr_fill_sockaddr4(params
->cm_info
, &event
);
105 qedr_fill_sockaddr6(params
->cm_info
, &event
);
107 event
.provider_data
= (void *)ep
;
108 event
.private_data
= (void *)params
->cm_info
->private_data
;
109 event
.private_data_len
= (u8
)params
->cm_info
->private_data_len
;
110 event
.ord
= params
->cm_info
->ord
;
111 event
.ird
= params
->cm_info
->ird
;
113 listener
->cm_id
->event_handler(listener
->cm_id
, &event
);
117 qedr_iw_issue_event(void *context
,
118 struct qed_iwarp_cm_event_params
*params
,
119 enum iw_cm_event_type event_type
)
121 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
122 struct iw_cm_event event
;
124 memset(&event
, 0, sizeof(event
));
125 event
.status
= params
->status
;
126 event
.event
= event_type
;
128 if (params
->cm_info
) {
129 event
.ird
= params
->cm_info
->ird
;
130 event
.ord
= params
->cm_info
->ord
;
131 event
.private_data_len
= params
->cm_info
->private_data_len
;
132 event
.private_data
= (void *)params
->cm_info
->private_data
;
136 ep
->cm_id
->event_handler(ep
->cm_id
, &event
);
140 qedr_iw_close_event(void *context
, struct qed_iwarp_cm_event_params
*params
)
142 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
145 qedr_iw_issue_event(context
, params
, IW_CM_EVENT_CLOSE
);
147 ep
->cm_id
->rem_ref(ep
->cm_id
);
153 qedr_iw_qp_event(void *context
,
154 struct qed_iwarp_cm_event_params
*params
,
155 enum ib_event_type ib_event
, char *str
)
157 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
158 struct qedr_dev
*dev
= ep
->dev
;
159 struct ib_qp
*ibqp
= &ep
->qp
->ibqp
;
160 struct ib_event event
;
162 DP_NOTICE(dev
, "QP error received: %s\n", str
);
164 if (ibqp
->event_handler
) {
165 event
.event
= ib_event
;
166 event
.device
= ibqp
->device
;
167 event
.element
.qp
= ibqp
;
168 ibqp
->event_handler(&event
, ibqp
->qp_context
);
172 struct qedr_discon_work
{
173 struct work_struct work
;
174 struct qedr_iw_ep
*ep
;
175 enum qed_iwarp_event_type event
;
179 static void qedr_iw_disconnect_worker(struct work_struct
*work
)
181 struct qedr_discon_work
*dwork
=
182 container_of(work
, struct qedr_discon_work
, work
);
183 struct qed_rdma_modify_qp_in_params qp_params
= { 0 };
184 struct qedr_iw_ep
*ep
= dwork
->ep
;
185 struct qedr_dev
*dev
= ep
->dev
;
186 struct qedr_qp
*qp
= ep
->qp
;
187 struct iw_cm_event event
;
191 qedr_iw_qp_rem_ref(&qp
->ibqp
);
195 memset(&event
, 0, sizeof(event
));
196 event
.status
= dwork
->status
;
197 event
.event
= IW_CM_EVENT_DISCONNECT
;
199 /* Success means graceful disconnect was requested. modifying
200 * to SQD is translated to graceful disconnect. O/w reset is sent
203 qp_params
.new_state
= QED_ROCE_QP_STATE_ERR
;
205 qp_params
.new_state
= QED_ROCE_QP_STATE_SQD
;
210 ep
->cm_id
->event_handler(ep
->cm_id
, &event
);
212 SET_FIELD(qp_params
.modify_flags
,
213 QED_RDMA_MODIFY_QP_VALID_NEW_STATE
, 1);
215 dev
->ops
->rdma_modify_qp(dev
->rdma_ctx
, qp
->qed_qp
, &qp_params
);
217 qedr_iw_qp_rem_ref(&qp
->ibqp
);
221 qedr_iw_disconnect_event(void *context
,
222 struct qed_iwarp_cm_event_params
*params
)
224 struct qedr_discon_work
*work
;
225 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
226 struct qedr_dev
*dev
= ep
->dev
;
227 struct qedr_qp
*qp
= ep
->qp
;
229 work
= kzalloc(sizeof(*work
), GFP_ATOMIC
);
233 qedr_iw_qp_add_ref(&qp
->ibqp
);
235 work
->event
= params
->event
;
236 work
->status
= params
->status
;
238 INIT_WORK(&work
->work
, qedr_iw_disconnect_worker
);
239 queue_work(dev
->iwarp_wq
, &work
->work
);
243 qedr_iw_passive_complete(void *context
,
244 struct qed_iwarp_cm_event_params
*params
)
246 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
247 struct qedr_dev
*dev
= ep
->dev
;
249 /* We will only reach the following state if MPA_REJECT was called on
250 * passive. In this case there will be no associated QP.
252 if ((params
->status
== -ECONNREFUSED
) && (!ep
->qp
)) {
253 DP_DEBUG(dev
, QEDR_MSG_IWARP
,
254 "PASSIVE connection refused releasing ep...\n");
259 qedr_iw_issue_event(context
, params
, IW_CM_EVENT_ESTABLISHED
);
261 if (params
->status
< 0)
262 qedr_iw_close_event(context
, params
);
266 qedr_iw_mpa_reply(void *context
, struct qed_iwarp_cm_event_params
*params
)
268 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
269 struct qedr_dev
*dev
= ep
->dev
;
270 struct qed_iwarp_send_rtr_in rtr_in
;
272 rtr_in
.ep_context
= params
->ep_context
;
274 return dev
->ops
->iwarp_send_rtr(dev
->rdma_ctx
, &rtr_in
);
278 qedr_iw_event_handler(void *context
, struct qed_iwarp_cm_event_params
*params
)
280 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
281 struct qedr_dev
*dev
= ep
->dev
;
283 switch (params
->event
) {
284 case QED_IWARP_EVENT_MPA_REQUEST
:
285 qedr_iw_mpa_request(context
, params
);
287 case QED_IWARP_EVENT_ACTIVE_MPA_REPLY
:
288 qedr_iw_mpa_reply(context
, params
);
290 case QED_IWARP_EVENT_PASSIVE_COMPLETE
:
291 ep
->during_connect
= 0;
292 qedr_iw_passive_complete(context
, params
);
295 case QED_IWARP_EVENT_ACTIVE_COMPLETE
:
296 ep
->during_connect
= 0;
297 qedr_iw_issue_event(context
,
299 IW_CM_EVENT_CONNECT_REPLY
);
300 if (params
->status
< 0) {
301 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)context
;
303 ep
->cm_id
->rem_ref(ep
->cm_id
);
307 case QED_IWARP_EVENT_DISCONNECT
:
308 qedr_iw_disconnect_event(context
, params
);
310 case QED_IWARP_EVENT_CLOSE
:
311 ep
->during_connect
= 0;
312 qedr_iw_close_event(context
, params
);
314 case QED_IWARP_EVENT_RQ_EMPTY
:
315 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_FATAL
,
316 "QED_IWARP_EVENT_RQ_EMPTY");
318 case QED_IWARP_EVENT_IRQ_FULL
:
319 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_FATAL
,
320 "QED_IWARP_EVENT_IRQ_FULL");
322 case QED_IWARP_EVENT_LLP_TIMEOUT
:
323 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_FATAL
,
324 "QED_IWARP_EVENT_LLP_TIMEOUT");
326 case QED_IWARP_EVENT_REMOTE_PROTECTION_ERROR
:
327 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_ACCESS_ERR
,
328 "QED_IWARP_EVENT_REMOTE_PROTECTION_ERROR");
330 case QED_IWARP_EVENT_CQ_OVERFLOW
:
331 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_FATAL
,
332 "QED_IWARP_EVENT_CQ_OVERFLOW");
334 case QED_IWARP_EVENT_QP_CATASTROPHIC
:
335 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_FATAL
,
336 "QED_IWARP_EVENT_QP_CATASTROPHIC");
338 case QED_IWARP_EVENT_LOCAL_ACCESS_ERROR
:
339 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_ACCESS_ERR
,
340 "QED_IWARP_EVENT_LOCAL_ACCESS_ERROR");
342 case QED_IWARP_EVENT_REMOTE_OPERATION_ERROR
:
343 qedr_iw_qp_event(context
, params
, IB_EVENT_QP_FATAL
,
344 "QED_IWARP_EVENT_REMOTE_OPERATION_ERROR");
346 case QED_IWARP_EVENT_TERMINATE_RECEIVED
:
347 DP_NOTICE(dev
, "Got terminate message\n");
350 DP_NOTICE(dev
, "Unknown event received %d\n", params
->event
);
356 static u16
qedr_iw_get_vlan_ipv4(struct qedr_dev
*dev
, u32
*addr
)
358 struct net_device
*ndev
;
361 ndev
= ip_dev_find(&init_net
, htonl(addr
[0]));
364 vlan_id
= rdma_vlan_dev_vlan_id(ndev
);
367 if (vlan_id
== 0xffff)
372 static u16
qedr_iw_get_vlan_ipv6(u32
*addr
)
374 struct net_device
*ndev
= NULL
;
375 struct in6_addr laddr6
;
379 if (!IS_ENABLED(CONFIG_IPV6
))
382 for (i
= 0; i
< 4; i
++)
383 laddr6
.in6_u
.u6_addr32
[i
] = htonl(addr
[i
]);
386 for_each_netdev_rcu(&init_net
, ndev
) {
387 if (ipv6_chk_addr(&init_net
, &laddr6
, ndev
, 1)) {
388 vlan_id
= rdma_vlan_dev_vlan_id(ndev
);
394 if (vlan_id
== 0xffff)
401 qedr_addr4_resolve(struct qedr_dev
*dev
,
402 struct sockaddr_in
*src_in
,
403 struct sockaddr_in
*dst_in
, u8
*dst_mac
)
405 __be32 src_ip
= src_in
->sin_addr
.s_addr
;
406 __be32 dst_ip
= dst_in
->sin_addr
.s_addr
;
407 struct neighbour
*neigh
= NULL
;
408 struct rtable
*rt
= NULL
;
411 rt
= ip_route_output(&init_net
, dst_ip
, src_ip
, 0, 0);
413 DP_ERR(dev
, "ip_route_output returned error\n");
417 neigh
= dst_neigh_lookup(&rt
->dst
, &dst_ip
);
421 if (neigh
->nud_state
& NUD_VALID
) {
422 ether_addr_copy(dst_mac
, neigh
->ha
);
423 DP_DEBUG(dev
, QEDR_MSG_QP
, "mac_addr=[%pM]\n", dst_mac
);
425 neigh_event_send(neigh
, NULL
);
428 neigh_release(neigh
);
437 qedr_addr6_resolve(struct qedr_dev
*dev
,
438 struct sockaddr_in6
*src_in
,
439 struct sockaddr_in6
*dst_in
, u8
*dst_mac
)
441 struct neighbour
*neigh
= NULL
;
442 struct dst_entry
*dst
;
446 memset(&fl6
, 0, sizeof(fl6
));
447 fl6
.daddr
= dst_in
->sin6_addr
;
448 fl6
.saddr
= src_in
->sin6_addr
;
450 dst
= ip6_route_output(&init_net
, NULL
, &fl6
);
452 if ((!dst
) || dst
->error
) {
456 "ip6_route_output returned dst->error = %d\n",
461 neigh
= dst_neigh_lookup(dst
, &dst_in
);
465 if (neigh
->nud_state
& NUD_VALID
) {
466 ether_addr_copy(dst_mac
, neigh
->ha
);
467 DP_DEBUG(dev
, QEDR_MSG_QP
, "mac_addr=[%pM]\n", dst_mac
);
469 neigh_event_send(neigh
, NULL
);
472 neigh_release(neigh
);
480 int qedr_iw_connect(struct iw_cm_id
*cm_id
, struct iw_cm_conn_param
*conn_param
)
482 struct qedr_dev
*dev
= get_qedr_dev(cm_id
->device
);
483 struct qed_iwarp_connect_out out_params
;
484 struct qed_iwarp_connect_in in_params
;
485 struct qed_iwarp_cm_info
*cm_info
;
486 struct sockaddr_in6
*laddr6
;
487 struct sockaddr_in6
*raddr6
;
488 struct sockaddr_in
*laddr
;
489 struct sockaddr_in
*raddr
;
490 struct qedr_iw_ep
*ep
;
495 qp
= idr_find(&dev
->qpidr
, conn_param
->qpn
);
497 laddr
= (struct sockaddr_in
*)&cm_id
->local_addr
;
498 raddr
= (struct sockaddr_in
*)&cm_id
->remote_addr
;
499 laddr6
= (struct sockaddr_in6
*)&cm_id
->local_addr
;
500 raddr6
= (struct sockaddr_in6
*)&cm_id
->remote_addr
;
502 DP_DEBUG(dev
, QEDR_MSG_IWARP
,
503 "Connect source address: %pISpc, remote address: %pISpc\n",
504 &cm_id
->local_addr
, &cm_id
->remote_addr
);
506 if (!laddr
->sin_port
|| !raddr
->sin_port
)
509 ep
= kzalloc(sizeof(*ep
), GFP_KERNEL
);
516 cm_id
->add_ref(cm_id
);
519 in_params
.event_cb
= qedr_iw_event_handler
;
520 in_params
.cb_context
= ep
;
522 cm_info
= &in_params
.cm_info
;
523 memset(cm_info
->local_ip
, 0, sizeof(cm_info
->local_ip
));
524 memset(cm_info
->remote_ip
, 0, sizeof(cm_info
->remote_ip
));
526 if (!IS_ENABLED(CONFIG_IPV6
) ||
527 cm_id
->remote_addr
.ss_family
== AF_INET
) {
528 cm_info
->ip_version
= QED_TCP_IPV4
;
530 cm_info
->remote_ip
[0] = ntohl(raddr
->sin_addr
.s_addr
);
531 cm_info
->local_ip
[0] = ntohl(laddr
->sin_addr
.s_addr
);
532 cm_info
->remote_port
= ntohs(raddr
->sin_port
);
533 cm_info
->local_port
= ntohs(laddr
->sin_port
);
534 cm_info
->vlan
= qedr_iw_get_vlan_ipv4(dev
, cm_info
->local_ip
);
536 rc
= qedr_addr4_resolve(dev
, laddr
, raddr
,
537 (u8
*)in_params
.remote_mac_addr
);
539 in_params
.mss
= dev
->iwarp_max_mtu
-
540 (sizeof(struct iphdr
) + sizeof(struct tcphdr
));
543 in_params
.cm_info
.ip_version
= QED_TCP_IPV6
;
545 for (i
= 0; i
< 4; i
++) {
546 cm_info
->remote_ip
[i
] =
547 ntohl(raddr6
->sin6_addr
.in6_u
.u6_addr32
[i
]);
548 cm_info
->local_ip
[i
] =
549 ntohl(laddr6
->sin6_addr
.in6_u
.u6_addr32
[i
]);
552 cm_info
->local_port
= ntohs(laddr6
->sin6_port
);
553 cm_info
->remote_port
= ntohs(raddr6
->sin6_port
);
555 in_params
.mss
= dev
->iwarp_max_mtu
-
556 (sizeof(struct ipv6hdr
) + sizeof(struct tcphdr
));
558 cm_info
->vlan
= qedr_iw_get_vlan_ipv6(cm_info
->local_ip
);
560 rc
= qedr_addr6_resolve(dev
, laddr6
, raddr6
,
561 (u8
*)in_params
.remote_mac_addr
);
566 DP_DEBUG(dev
, QEDR_MSG_IWARP
,
567 "ord = %d ird=%d private_data=%p private_data_len=%d rq_psn=%d\n",
568 conn_param
->ord
, conn_param
->ird
, conn_param
->private_data
,
569 conn_param
->private_data_len
, qp
->rq_psn
);
571 cm_info
->ord
= conn_param
->ord
;
572 cm_info
->ird
= conn_param
->ird
;
573 cm_info
->private_data
= conn_param
->private_data
;
574 cm_info
->private_data_len
= conn_param
->private_data_len
;
575 in_params
.qp
= qp
->qed_qp
;
576 memcpy(in_params
.local_mac_addr
, dev
->ndev
->dev_addr
, ETH_ALEN
);
578 ep
->during_connect
= 1;
579 rc
= dev
->ops
->iwarp_connect(dev
->rdma_ctx
, &in_params
, &out_params
);
586 cm_id
->rem_ref(cm_id
);
591 int qedr_iw_create_listen(struct iw_cm_id
*cm_id
, int backlog
)
593 struct qedr_dev
*dev
= get_qedr_dev(cm_id
->device
);
594 struct qedr_iw_listener
*listener
;
595 struct qed_iwarp_listen_in iparams
;
596 struct qed_iwarp_listen_out oparams
;
597 struct sockaddr_in
*laddr
;
598 struct sockaddr_in6
*laddr6
;
602 laddr
= (struct sockaddr_in
*)&cm_id
->local_addr
;
603 laddr6
= (struct sockaddr_in6
*)&cm_id
->local_addr
;
605 DP_DEBUG(dev
, QEDR_MSG_IWARP
,
606 "Create Listener address: %pISpc\n", &cm_id
->local_addr
);
608 listener
= kzalloc(sizeof(*listener
), GFP_KERNEL
);
613 cm_id
->add_ref(cm_id
);
614 listener
->cm_id
= cm_id
;
615 listener
->backlog
= backlog
;
617 iparams
.cb_context
= listener
;
618 iparams
.event_cb
= qedr_iw_event_handler
;
619 iparams
.max_backlog
= backlog
;
621 if (!IS_ENABLED(CONFIG_IPV6
) ||
622 cm_id
->local_addr
.ss_family
== AF_INET
) {
623 iparams
.ip_version
= QED_TCP_IPV4
;
624 memset(iparams
.ip_addr
, 0, sizeof(iparams
.ip_addr
));
626 iparams
.ip_addr
[0] = ntohl(laddr
->sin_addr
.s_addr
);
627 iparams
.port
= ntohs(laddr
->sin_port
);
628 iparams
.vlan
= qedr_iw_get_vlan_ipv4(dev
, iparams
.ip_addr
);
630 iparams
.ip_version
= QED_TCP_IPV6
;
632 for (i
= 0; i
< 4; i
++) {
634 ntohl(laddr6
->sin6_addr
.in6_u
.u6_addr32
[i
]);
637 iparams
.port
= ntohs(laddr6
->sin6_port
);
639 iparams
.vlan
= qedr_iw_get_vlan_ipv6(iparams
.ip_addr
);
641 rc
= dev
->ops
->iwarp_create_listen(dev
->rdma_ctx
, &iparams
, &oparams
);
645 listener
->qed_handle
= oparams
.handle
;
646 cm_id
->provider_data
= listener
;
650 cm_id
->rem_ref(cm_id
);
655 int qedr_iw_destroy_listen(struct iw_cm_id
*cm_id
)
657 struct qedr_iw_listener
*listener
= cm_id
->provider_data
;
658 struct qedr_dev
*dev
= get_qedr_dev(cm_id
->device
);
661 if (listener
->qed_handle
)
662 rc
= dev
->ops
->iwarp_destroy_listen(dev
->rdma_ctx
,
663 listener
->qed_handle
);
665 cm_id
->rem_ref(cm_id
);
669 int qedr_iw_accept(struct iw_cm_id
*cm_id
, struct iw_cm_conn_param
*conn_param
)
671 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)cm_id
->provider_data
;
672 struct qedr_dev
*dev
= ep
->dev
;
674 struct qed_iwarp_accept_in params
;
677 DP_DEBUG(dev
, QEDR_MSG_IWARP
, "Accept on qpid=%d\n", conn_param
->qpn
);
679 qp
= idr_find(&dev
->qpidr
, conn_param
->qpn
);
681 DP_ERR(dev
, "Invalid QP number %d\n", conn_param
->qpn
);
687 cm_id
->add_ref(cm_id
);
690 params
.ep_context
= ep
->qed_context
;
691 params
.cb_context
= ep
;
692 params
.qp
= ep
->qp
->qed_qp
;
693 params
.private_data
= conn_param
->private_data
;
694 params
.private_data_len
= conn_param
->private_data_len
;
695 params
.ird
= conn_param
->ird
;
696 params
.ord
= conn_param
->ord
;
698 ep
->during_connect
= 1;
699 rc
= dev
->ops
->iwarp_accept(dev
->rdma_ctx
, ¶ms
);
705 ep
->during_connect
= 0;
706 cm_id
->rem_ref(cm_id
);
710 int qedr_iw_reject(struct iw_cm_id
*cm_id
, const void *pdata
, u8 pdata_len
)
712 struct qedr_iw_ep
*ep
= (struct qedr_iw_ep
*)cm_id
->provider_data
;
713 struct qedr_dev
*dev
= ep
->dev
;
714 struct qed_iwarp_reject_in params
;
716 params
.ep_context
= ep
->qed_context
;
717 params
.cb_context
= ep
;
718 params
.private_data
= pdata
;
719 params
.private_data_len
= pdata_len
;
722 return dev
->ops
->iwarp_reject(dev
->rdma_ctx
, ¶ms
);
725 void qedr_iw_qp_add_ref(struct ib_qp
*ibqp
)
727 struct qedr_qp
*qp
= get_qedr_qp(ibqp
);
729 atomic_inc(&qp
->refcnt
);
732 void qedr_iw_qp_rem_ref(struct ib_qp
*ibqp
)
734 struct qedr_qp
*qp
= get_qedr_qp(ibqp
);
736 if (atomic_dec_and_test(&qp
->refcnt
)) {
737 spin_lock_irq(&qp
->dev
->idr_lock
);
738 idr_remove(&qp
->dev
->qpidr
, qp
->qp_id
);
739 spin_unlock_irq(&qp
->dev
->idr_lock
);
744 struct ib_qp
*qedr_iw_get_qp(struct ib_device
*ibdev
, int qpn
)
746 struct qedr_dev
*dev
= get_qedr_dev(ibdev
);
748 return idr_find(&dev
->qpidr
, qpn
);