2 * Copyright (c) 2009-2014 Chelsio, Inc. All rights reserved.
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
32 #include <linux/module.h>
33 #include <linux/list.h>
34 #include <linux/workqueue.h>
35 #include <linux/skbuff.h>
36 #include <linux/timer.h>
37 #include <linux/notifier.h>
38 #include <linux/inetdevice.h>
40 #include <linux/tcp.h>
41 #include <linux/if_vlan.h>
43 #include <net/neighbour.h>
44 #include <net/netevent.h>
45 #include <net/route.h>
47 #include <net/ip6_route.h>
48 #include <net/addrconf.h>
50 #include <rdma/ib_addr.h>
52 #include <libcxgb_cm.h>
56 static char *states
[] = {
73 module_param(nocong
, int, 0644);
74 MODULE_PARM_DESC(nocong
, "Turn of congestion control (default=0)");
76 static int enable_ecn
;
77 module_param(enable_ecn
, int, 0644);
78 MODULE_PARM_DESC(enable_ecn
, "Enable ECN (default=0/disabled)");
81 module_param(dack_mode
, int, 0644);
82 MODULE_PARM_DESC(dack_mode
, "Delayed ack mode (default=0)");
84 uint c4iw_max_read_depth
= 32;
85 module_param(c4iw_max_read_depth
, int, 0644);
86 MODULE_PARM_DESC(c4iw_max_read_depth
,
87 "Per-connection max ORD/IRD (default=32)");
89 static int enable_tcp_timestamps
;
90 module_param(enable_tcp_timestamps
, int, 0644);
91 MODULE_PARM_DESC(enable_tcp_timestamps
, "Enable tcp timestamps (default=0)");
93 static int enable_tcp_sack
;
94 module_param(enable_tcp_sack
, int, 0644);
95 MODULE_PARM_DESC(enable_tcp_sack
, "Enable tcp SACK (default=0)");
97 static int enable_tcp_window_scaling
= 1;
98 module_param(enable_tcp_window_scaling
, int, 0644);
99 MODULE_PARM_DESC(enable_tcp_window_scaling
,
100 "Enable tcp window scaling (default=1)");
102 static int peer2peer
= 1;
103 module_param(peer2peer
, int, 0644);
104 MODULE_PARM_DESC(peer2peer
, "Support peer2peer ULPs (default=1)");
106 static int p2p_type
= FW_RI_INIT_P2PTYPE_READ_REQ
;
107 module_param(p2p_type
, int, 0644);
108 MODULE_PARM_DESC(p2p_type
, "RDMAP opcode to use for the RTR message: "
109 "1=RDMA_READ 0=RDMA_WRITE (default 1)");
111 static int ep_timeout_secs
= 60;
112 module_param(ep_timeout_secs
, int, 0644);
113 MODULE_PARM_DESC(ep_timeout_secs
, "CM Endpoint operation timeout "
114 "in seconds (default=60)");
116 static int mpa_rev
= 2;
117 module_param(mpa_rev
, int, 0644);
118 MODULE_PARM_DESC(mpa_rev
, "MPA Revision, 0 supports amso1100, "
119 "1 is RFC5044 spec compliant, 2 is IETF MPA Peer Connect Draft"
120 " compliant (default=2)");
122 static int markers_enabled
;
123 module_param(markers_enabled
, int, 0644);
124 MODULE_PARM_DESC(markers_enabled
, "Enable MPA MARKERS (default(0)=disabled)");
126 static int crc_enabled
= 1;
127 module_param(crc_enabled
, int, 0644);
128 MODULE_PARM_DESC(crc_enabled
, "Enable MPA CRC (default(1)=enabled)");
130 static int rcv_win
= 256 * 1024;
131 module_param(rcv_win
, int, 0644);
132 MODULE_PARM_DESC(rcv_win
, "TCP receive window in bytes (default=256KB)");
134 static int snd_win
= 128 * 1024;
135 module_param(snd_win
, int, 0644);
136 MODULE_PARM_DESC(snd_win
, "TCP send window in bytes (default=128KB)");
138 static struct workqueue_struct
*workq
;
140 static struct sk_buff_head rxq
;
142 static struct sk_buff
*get_skb(struct sk_buff
*skb
, int len
, gfp_t gfp
);
143 static void ep_timeout(struct timer_list
*t
);
144 static void connect_reply_upcall(struct c4iw_ep
*ep
, int status
);
145 static int sched(struct c4iw_dev
*dev
, struct sk_buff
*skb
);
147 static LIST_HEAD(timeout_list
);
148 static DEFINE_SPINLOCK(timeout_lock
);
150 static void deref_cm_id(struct c4iw_ep_common
*epc
)
152 epc
->cm_id
->rem_ref(epc
->cm_id
);
154 set_bit(CM_ID_DEREFED
, &epc
->history
);
157 static void ref_cm_id(struct c4iw_ep_common
*epc
)
159 set_bit(CM_ID_REFED
, &epc
->history
);
160 epc
->cm_id
->add_ref(epc
->cm_id
);
163 static void deref_qp(struct c4iw_ep
*ep
)
165 c4iw_qp_rem_ref(&ep
->com
.qp
->ibqp
);
166 clear_bit(QP_REFERENCED
, &ep
->com
.flags
);
167 set_bit(QP_DEREFED
, &ep
->com
.history
);
170 static void ref_qp(struct c4iw_ep
*ep
)
172 set_bit(QP_REFERENCED
, &ep
->com
.flags
);
173 set_bit(QP_REFED
, &ep
->com
.history
);
174 c4iw_qp_add_ref(&ep
->com
.qp
->ibqp
);
177 static void start_ep_timer(struct c4iw_ep
*ep
)
179 pr_debug("ep %p\n", ep
);
180 if (timer_pending(&ep
->timer
)) {
181 pr_err("%s timer already started! ep %p\n",
185 clear_bit(TIMEOUT
, &ep
->com
.flags
);
186 c4iw_get_ep(&ep
->com
);
187 ep
->timer
.expires
= jiffies
+ ep_timeout_secs
* HZ
;
188 add_timer(&ep
->timer
);
191 static int stop_ep_timer(struct c4iw_ep
*ep
)
193 pr_debug("ep %p stopping\n", ep
);
194 del_timer_sync(&ep
->timer
);
195 if (!test_and_set_bit(TIMEOUT
, &ep
->com
.flags
)) {
196 c4iw_put_ep(&ep
->com
);
202 static int c4iw_l2t_send(struct c4iw_rdev
*rdev
, struct sk_buff
*skb
,
203 struct l2t_entry
*l2e
)
207 if (c4iw_fatal_error(rdev
)) {
209 pr_err("%s - device in error state - dropping\n", __func__
);
212 error
= cxgb4_l2t_send(rdev
->lldi
.ports
[0], skb
, l2e
);
215 else if (error
== NET_XMIT_DROP
)
217 return error
< 0 ? error
: 0;
220 int c4iw_ofld_send(struct c4iw_rdev
*rdev
, struct sk_buff
*skb
)
224 if (c4iw_fatal_error(rdev
)) {
226 pr_err("%s - device in error state - dropping\n", __func__
);
229 error
= cxgb4_ofld_send(rdev
->lldi
.ports
[0], skb
);
232 return error
< 0 ? error
: 0;
235 static void release_tid(struct c4iw_rdev
*rdev
, u32 hwtid
, struct sk_buff
*skb
)
237 u32 len
= roundup(sizeof(struct cpl_tid_release
), 16);
239 skb
= get_skb(skb
, len
, GFP_KERNEL
);
243 cxgb_mk_tid_release(skb
, len
, hwtid
, 0);
244 c4iw_ofld_send(rdev
, skb
);
248 static void set_emss(struct c4iw_ep
*ep
, u16 opt
)
250 ep
->emss
= ep
->com
.dev
->rdev
.lldi
.mtus
[TCPOPT_MSS_G(opt
)] -
251 ((AF_INET
== ep
->com
.remote_addr
.ss_family
) ?
252 sizeof(struct iphdr
) : sizeof(struct ipv6hdr
)) -
253 sizeof(struct tcphdr
);
255 if (TCPOPT_TSTAMP_G(opt
))
256 ep
->emss
-= round_up(TCPOLEN_TIMESTAMP
, 4);
260 pr_debug("Warning: misaligned mtu idx %u mss %u emss=%u\n",
261 TCPOPT_MSS_G(opt
), ep
->mss
, ep
->emss
);
262 pr_debug("mss_idx %u mss %u emss=%u\n", TCPOPT_MSS_G(opt
), ep
->mss
,
266 static enum c4iw_ep_state
state_read(struct c4iw_ep_common
*epc
)
268 enum c4iw_ep_state state
;
270 mutex_lock(&epc
->mutex
);
272 mutex_unlock(&epc
->mutex
);
276 static void __state_set(struct c4iw_ep_common
*epc
, enum c4iw_ep_state
new)
281 static void state_set(struct c4iw_ep_common
*epc
, enum c4iw_ep_state
new)
283 mutex_lock(&epc
->mutex
);
284 pr_debug("%s -> %s\n", states
[epc
->state
], states
[new]);
285 __state_set(epc
, new);
286 mutex_unlock(&epc
->mutex
);
290 static int alloc_ep_skb_list(struct sk_buff_head
*ep_skb_list
, int size
)
296 len
= roundup(sizeof(union cpl_wr_size
), 16);
297 for (i
= 0; i
< size
; i
++) {
298 skb
= alloc_skb(len
, GFP_KERNEL
);
301 skb_queue_tail(ep_skb_list
, skb
);
305 skb_queue_purge(ep_skb_list
);
309 static void *alloc_ep(int size
, gfp_t gfp
)
311 struct c4iw_ep_common
*epc
;
313 epc
= kzalloc(size
, gfp
);
315 epc
->wr_waitp
= c4iw_alloc_wr_wait(gfp
);
316 if (!epc
->wr_waitp
) {
321 kref_init(&epc
->kref
);
322 mutex_init(&epc
->mutex
);
323 c4iw_init_wr_wait(epc
->wr_waitp
);
325 pr_debug("alloc ep %p\n", epc
);
330 static void remove_ep_tid(struct c4iw_ep
*ep
)
334 xa_lock_irqsave(&ep
->com
.dev
->hwtids
, flags
);
335 __xa_erase(&ep
->com
.dev
->hwtids
, ep
->hwtid
);
336 if (xa_empty(&ep
->com
.dev
->hwtids
))
337 wake_up(&ep
->com
.dev
->wait
);
338 xa_unlock_irqrestore(&ep
->com
.dev
->hwtids
, flags
);
341 static int insert_ep_tid(struct c4iw_ep
*ep
)
346 xa_lock_irqsave(&ep
->com
.dev
->hwtids
, flags
);
347 err
= __xa_insert(&ep
->com
.dev
->hwtids
, ep
->hwtid
, ep
, GFP_KERNEL
);
348 xa_unlock_irqrestore(&ep
->com
.dev
->hwtids
, flags
);
354 * Atomically lookup the ep ptr given the tid and grab a reference on the ep.
356 static struct c4iw_ep
*get_ep_from_tid(struct c4iw_dev
*dev
, unsigned int tid
)
361 xa_lock_irqsave(&dev
->hwtids
, flags
);
362 ep
= xa_load(&dev
->hwtids
, tid
);
364 c4iw_get_ep(&ep
->com
);
365 xa_unlock_irqrestore(&dev
->hwtids
, flags
);
370 * Atomically lookup the ep ptr given the stid and grab a reference on the ep.
372 static struct c4iw_listen_ep
*get_ep_from_stid(struct c4iw_dev
*dev
,
375 struct c4iw_listen_ep
*ep
;
378 xa_lock_irqsave(&dev
->stids
, flags
);
379 ep
= xa_load(&dev
->stids
, stid
);
381 c4iw_get_ep(&ep
->com
);
382 xa_unlock_irqrestore(&dev
->stids
, flags
);
386 void _c4iw_free_ep(struct kref
*kref
)
390 ep
= container_of(kref
, struct c4iw_ep
, com
.kref
);
391 pr_debug("ep %p state %s\n", ep
, states
[ep
->com
.state
]);
392 if (test_bit(QP_REFERENCED
, &ep
->com
.flags
))
394 if (test_bit(RELEASE_RESOURCES
, &ep
->com
.flags
)) {
395 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
) {
396 struct sockaddr_in6
*sin6
=
397 (struct sockaddr_in6
*)
401 ep
->com
.dev
->rdev
.lldi
.ports
[0],
402 (const u32
*)&sin6
->sin6_addr
.s6_addr
,
405 cxgb4_remove_tid(ep
->com
.dev
->rdev
.lldi
.tids
, 0, ep
->hwtid
,
406 ep
->com
.local_addr
.ss_family
);
407 dst_release(ep
->dst
);
408 cxgb4_l2t_release(ep
->l2t
);
409 kfree_skb(ep
->mpa_skb
);
411 if (!skb_queue_empty(&ep
->com
.ep_skb_list
))
412 skb_queue_purge(&ep
->com
.ep_skb_list
);
413 c4iw_put_wr_wait(ep
->com
.wr_waitp
);
417 static void release_ep_resources(struct c4iw_ep
*ep
)
419 set_bit(RELEASE_RESOURCES
, &ep
->com
.flags
);
422 * If we have a hwtid, then remove it from the idr table
423 * so lookups will no longer find this endpoint. Otherwise
424 * we have a race where one thread finds the ep ptr just
425 * before the other thread is freeing the ep memory.
429 c4iw_put_ep(&ep
->com
);
432 static int status2errno(int status
)
437 case CPL_ERR_CONN_RESET
:
439 case CPL_ERR_ARP_MISS
:
440 return -EHOSTUNREACH
;
441 case CPL_ERR_CONN_TIMEDOUT
:
443 case CPL_ERR_TCAM_FULL
:
445 case CPL_ERR_CONN_EXIST
:
453 * Try and reuse skbs already allocated...
455 static struct sk_buff
*get_skb(struct sk_buff
*skb
, int len
, gfp_t gfp
)
457 if (skb
&& !skb_is_nonlinear(skb
) && !skb_cloned(skb
)) {
460 skb_reset_transport_header(skb
);
462 skb
= alloc_skb(len
, gfp
);
466 t4_set_arp_err_handler(skb
, NULL
, NULL
);
470 static struct net_device
*get_real_dev(struct net_device
*egress_dev
)
472 return rdma_vlan_dev_real_dev(egress_dev
) ? : egress_dev
;
475 static void arp_failure_discard(void *handle
, struct sk_buff
*skb
)
477 pr_err("ARP failure\n");
481 static void mpa_start_arp_failure(void *handle
, struct sk_buff
*skb
)
483 pr_err("ARP failure during MPA Negotiation - Closing Connection\n");
488 FAKE_CPL_PUT_EP_SAFE
= NUM_CPL_CMDS
+ 0,
489 FAKE_CPL_PASS_PUT_EP_SAFE
= NUM_CPL_CMDS
+ 1,
492 static int _put_ep_safe(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
496 ep
= *((struct c4iw_ep
**)(skb
->cb
+ 2 * sizeof(void *)));
497 release_ep_resources(ep
);
501 static int _put_pass_ep_safe(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
505 ep
= *((struct c4iw_ep
**)(skb
->cb
+ 2 * sizeof(void *)));
506 c4iw_put_ep(&ep
->parent_ep
->com
);
507 release_ep_resources(ep
);
512 * Fake up a special CPL opcode and call sched() so process_work() will call
513 * _put_ep_safe() in a safe context to free the ep resources. This is needed
514 * because ARP error handlers are called in an ATOMIC context, and
515 * _c4iw_free_ep() needs to block.
517 static void queue_arp_failure_cpl(struct c4iw_ep
*ep
, struct sk_buff
*skb
,
520 struct cpl_act_establish
*rpl
= cplhdr(skb
);
522 /* Set our special ARP_FAILURE opcode */
523 rpl
->ot
.opcode
= cpl
;
526 * Save ep in the skb->cb area, after where sched() will save the dev
529 *((struct c4iw_ep
**)(skb
->cb
+ 2 * sizeof(void *))) = ep
;
530 sched(ep
->com
.dev
, skb
);
533 /* Handle an ARP failure for an accept */
534 static void pass_accept_rpl_arp_failure(void *handle
, struct sk_buff
*skb
)
536 struct c4iw_ep
*ep
= handle
;
538 pr_err("ARP failure during accept - tid %u - dropping connection\n",
541 __state_set(&ep
->com
, DEAD
);
542 queue_arp_failure_cpl(ep
, skb
, FAKE_CPL_PASS_PUT_EP_SAFE
);
546 * Handle an ARP failure for an active open.
548 static void act_open_req_arp_failure(void *handle
, struct sk_buff
*skb
)
550 struct c4iw_ep
*ep
= handle
;
552 pr_err("ARP failure during connect\n");
553 connect_reply_upcall(ep
, -EHOSTUNREACH
);
554 __state_set(&ep
->com
, DEAD
);
555 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
) {
556 struct sockaddr_in6
*sin6
=
557 (struct sockaddr_in6
*)&ep
->com
.local_addr
;
558 cxgb4_clip_release(ep
->com
.dev
->rdev
.lldi
.ports
[0],
559 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
561 xa_erase_irq(&ep
->com
.dev
->atids
, ep
->atid
);
562 cxgb4_free_atid(ep
->com
.dev
->rdev
.lldi
.tids
, ep
->atid
);
563 queue_arp_failure_cpl(ep
, skb
, FAKE_CPL_PUT_EP_SAFE
);
567 * Handle an ARP failure for a CPL_ABORT_REQ. Change it into a no RST variant
570 static void abort_arp_failure(void *handle
, struct sk_buff
*skb
)
573 struct c4iw_ep
*ep
= handle
;
574 struct c4iw_rdev
*rdev
= &ep
->com
.dev
->rdev
;
575 struct cpl_abort_req
*req
= cplhdr(skb
);
577 pr_debug("rdev %p\n", rdev
);
578 req
->cmd
= CPL_ABORT_NO_RST
;
580 ret
= c4iw_ofld_send(rdev
, skb
);
582 __state_set(&ep
->com
, DEAD
);
583 queue_arp_failure_cpl(ep
, skb
, FAKE_CPL_PUT_EP_SAFE
);
588 static int send_flowc(struct c4iw_ep
*ep
)
590 struct fw_flowc_wr
*flowc
;
591 struct sk_buff
*skb
= skb_dequeue(&ep
->com
.ep_skb_list
);
592 u16 vlan
= ep
->l2t
->vlan
;
594 int flowclen
, flowclen16
;
599 if (vlan
== CPL_L2T_VLAN_NONE
)
604 flowclen
= offsetof(struct fw_flowc_wr
, mnemval
[nparams
]);
605 flowclen16
= DIV_ROUND_UP(flowclen
, 16);
606 flowclen
= flowclen16
* 16;
608 flowc
= __skb_put(skb
, flowclen
);
609 memset(flowc
, 0, flowclen
);
611 flowc
->op_to_nparams
= cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR
) |
612 FW_FLOWC_WR_NPARAMS_V(nparams
));
613 flowc
->flowid_len16
= cpu_to_be32(FW_WR_LEN16_V(flowclen16
) |
614 FW_WR_FLOWID_V(ep
->hwtid
));
616 flowc
->mnemval
[0].mnemonic
= FW_FLOWC_MNEM_PFNVFN
;
617 flowc
->mnemval
[0].val
= cpu_to_be32(FW_PFVF_CMD_PFN_V
618 (ep
->com
.dev
->rdev
.lldi
.pf
));
619 flowc
->mnemval
[1].mnemonic
= FW_FLOWC_MNEM_CH
;
620 flowc
->mnemval
[1].val
= cpu_to_be32(ep
->tx_chan
);
621 flowc
->mnemval
[2].mnemonic
= FW_FLOWC_MNEM_PORT
;
622 flowc
->mnemval
[2].val
= cpu_to_be32(ep
->tx_chan
);
623 flowc
->mnemval
[3].mnemonic
= FW_FLOWC_MNEM_IQID
;
624 flowc
->mnemval
[3].val
= cpu_to_be32(ep
->rss_qid
);
625 flowc
->mnemval
[4].mnemonic
= FW_FLOWC_MNEM_SNDNXT
;
626 flowc
->mnemval
[4].val
= cpu_to_be32(ep
->snd_seq
);
627 flowc
->mnemval
[5].mnemonic
= FW_FLOWC_MNEM_RCVNXT
;
628 flowc
->mnemval
[5].val
= cpu_to_be32(ep
->rcv_seq
);
629 flowc
->mnemval
[6].mnemonic
= FW_FLOWC_MNEM_SNDBUF
;
630 flowc
->mnemval
[6].val
= cpu_to_be32(ep
->snd_win
);
631 flowc
->mnemval
[7].mnemonic
= FW_FLOWC_MNEM_MSS
;
632 flowc
->mnemval
[7].val
= cpu_to_be32(ep
->emss
);
633 flowc
->mnemval
[8].mnemonic
= FW_FLOWC_MNEM_RCV_SCALE
;
634 flowc
->mnemval
[8].val
= cpu_to_be32(ep
->snd_wscale
);
637 pri
= (vlan
& VLAN_PRIO_MASK
) >> VLAN_PRIO_SHIFT
;
638 flowc
->mnemval
[9].mnemonic
= FW_FLOWC_MNEM_SCHEDCLASS
;
639 flowc
->mnemval
[9].val
= cpu_to_be32(pri
);
642 set_wr_txq(skb
, CPL_PRIORITY_DATA
, ep
->txq_idx
);
643 return c4iw_ofld_send(&ep
->com
.dev
->rdev
, skb
);
646 static int send_halfclose(struct c4iw_ep
*ep
)
648 struct sk_buff
*skb
= skb_dequeue(&ep
->com
.ep_skb_list
);
649 u32 wrlen
= roundup(sizeof(struct cpl_close_con_req
), 16);
651 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
655 cxgb_mk_close_con_req(skb
, wrlen
, ep
->hwtid
, ep
->txq_idx
,
656 NULL
, arp_failure_discard
);
658 return c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
661 static void read_tcb(struct c4iw_ep
*ep
)
664 struct cpl_get_tcb
*req
;
665 int wrlen
= roundup(sizeof(*req
), 16);
667 skb
= get_skb(NULL
, sizeof(*req
), GFP_KERNEL
);
671 set_wr_txq(skb
, CPL_PRIORITY_CONTROL
, ep
->ctrlq_idx
);
672 req
= (struct cpl_get_tcb
*) skb_put(skb
, wrlen
);
673 memset(req
, 0, wrlen
);
674 INIT_TP_WR(req
, ep
->hwtid
);
675 OPCODE_TID(req
) = cpu_to_be32(MK_OPCODE_TID(CPL_GET_TCB
, ep
->hwtid
));
676 req
->reply_ctrl
= htons(REPLY_CHAN_V(0) | QUEUENO_V(ep
->rss_qid
));
679 * keep a ref on the ep so the tcb is not unlocked before this
680 * cpl completes. The ref is released in read_tcb_rpl().
682 c4iw_get_ep(&ep
->com
);
683 if (WARN_ON(c4iw_ofld_send(&ep
->com
.dev
->rdev
, skb
)))
684 c4iw_put_ep(&ep
->com
);
687 static int send_abort_req(struct c4iw_ep
*ep
)
689 u32 wrlen
= roundup(sizeof(struct cpl_abort_req
), 16);
690 struct sk_buff
*req_skb
= skb_dequeue(&ep
->com
.ep_skb_list
);
692 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
693 if (WARN_ON(!req_skb
))
696 cxgb_mk_abort_req(req_skb
, wrlen
, ep
->hwtid
, ep
->txq_idx
,
697 ep
, abort_arp_failure
);
699 return c4iw_l2t_send(&ep
->com
.dev
->rdev
, req_skb
, ep
->l2t
);
702 static int send_abort(struct c4iw_ep
*ep
)
704 if (!ep
->com
.qp
|| !ep
->com
.qp
->srq
) {
708 set_bit(ABORT_REQ_IN_PROGRESS
, &ep
->com
.flags
);
713 static int send_connect(struct c4iw_ep
*ep
)
715 struct cpl_act_open_req
*req
= NULL
;
716 struct cpl_t5_act_open_req
*t5req
= NULL
;
717 struct cpl_t6_act_open_req
*t6req
= NULL
;
718 struct cpl_act_open_req6
*req6
= NULL
;
719 struct cpl_t5_act_open_req6
*t5req6
= NULL
;
720 struct cpl_t6_act_open_req6
*t6req6
= NULL
;
724 unsigned int mtu_idx
;
726 int win
, sizev4
, sizev6
, wrlen
;
727 struct sockaddr_in
*la
= (struct sockaddr_in
*)
729 struct sockaddr_in
*ra
= (struct sockaddr_in
*)
730 &ep
->com
.remote_addr
;
731 struct sockaddr_in6
*la6
= (struct sockaddr_in6
*)
733 struct sockaddr_in6
*ra6
= (struct sockaddr_in6
*)
734 &ep
->com
.remote_addr
;
736 enum chip_type adapter_type
= ep
->com
.dev
->rdev
.lldi
.adapter_type
;
737 u32 isn
= (get_random_u32() & ~7UL) - 1;
738 struct net_device
*netdev
;
741 netdev
= ep
->com
.dev
->rdev
.lldi
.ports
[0];
743 switch (CHELSIO_CHIP_VERSION(adapter_type
)) {
745 sizev4
= sizeof(struct cpl_act_open_req
);
746 sizev6
= sizeof(struct cpl_act_open_req6
);
749 sizev4
= sizeof(struct cpl_t5_act_open_req
);
750 sizev6
= sizeof(struct cpl_t5_act_open_req6
);
753 sizev4
= sizeof(struct cpl_t6_act_open_req
);
754 sizev6
= sizeof(struct cpl_t6_act_open_req6
);
757 pr_err("T%d Chip is not supported\n",
758 CHELSIO_CHIP_VERSION(adapter_type
));
762 wrlen
= (ep
->com
.remote_addr
.ss_family
== AF_INET
) ?
763 roundup(sizev4
, 16) :
766 pr_debug("ep %p atid %u\n", ep
, ep
->atid
);
768 skb
= get_skb(NULL
, wrlen
, GFP_KERNEL
);
770 pr_err("%s - failed to alloc skb\n", __func__
);
773 set_wr_txq(skb
, CPL_PRIORITY_SETUP
, ep
->ctrlq_idx
);
775 cxgb_best_mtu(ep
->com
.dev
->rdev
.lldi
.mtus
, ep
->mtu
, &mtu_idx
,
776 enable_tcp_timestamps
,
777 (ep
->com
.remote_addr
.ss_family
== AF_INET
) ? 0 : 1);
778 wscale
= cxgb_compute_wscale(rcv_win
);
781 * Specify the largest window that will fit in opt0. The
782 * remainder will be specified in the rx_data_ack.
784 win
= ep
->rcv_win
>> 10;
785 if (win
> RCV_BUFSIZ_M
)
788 opt0
= (nocong
? NO_CONG_F
: 0) |
791 WND_SCALE_V(wscale
) |
793 L2T_IDX_V(ep
->l2t
->idx
) |
794 TX_CHAN_V(ep
->tx_chan
) |
795 SMAC_SEL_V(ep
->smac_idx
) |
796 DSCP_V(ep
->tos
>> 2) |
797 ULP_MODE_V(ULP_MODE_TCPDDP
) |
799 opt2
= RX_CHANNEL_V(0) |
800 CCTRL_ECN_V(enable_ecn
) |
801 RSS_QUEUE_VALID_F
| RSS_QUEUE_V(ep
->rss_qid
);
802 if (enable_tcp_timestamps
)
803 opt2
|= TSTAMPS_EN_F
;
806 if (wscale
&& enable_tcp_window_scaling
)
807 opt2
|= WND_SCALE_EN_F
;
808 if (CHELSIO_CHIP_VERSION(adapter_type
) > CHELSIO_T4
) {
812 opt2
|= T5_OPT_2_VALID_F
;
813 opt2
|= CONG_CNTRL_V(CONG_ALG_TAHOE
);
817 params
= cxgb4_select_ntuple(netdev
, ep
->l2t
);
819 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
)
820 cxgb4_clip_get(ep
->com
.dev
->rdev
.lldi
.ports
[0],
821 (const u32
*)&la6
->sin6_addr
.s6_addr
, 1);
823 t4_set_arp_err_handler(skb
, ep
, act_open_req_arp_failure
);
825 if (ep
->com
.remote_addr
.ss_family
== AF_INET
) {
826 switch (CHELSIO_CHIP_VERSION(adapter_type
)) {
828 req
= skb_put(skb
, wrlen
);
832 t5req
= skb_put(skb
, wrlen
);
833 INIT_TP_WR(t5req
, 0);
834 req
= (struct cpl_act_open_req
*)t5req
;
837 t6req
= skb_put(skb
, wrlen
);
838 INIT_TP_WR(t6req
, 0);
839 req
= (struct cpl_act_open_req
*)t6req
;
840 t5req
= (struct cpl_t5_act_open_req
*)t6req
;
843 pr_err("T%d Chip is not supported\n",
844 CHELSIO_CHIP_VERSION(adapter_type
));
849 OPCODE_TID(req
) = cpu_to_be32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ
,
850 ((ep
->rss_qid
<<14) | ep
->atid
)));
851 req
->local_port
= la
->sin_port
;
852 req
->peer_port
= ra
->sin_port
;
853 req
->local_ip
= la
->sin_addr
.s_addr
;
854 req
->peer_ip
= ra
->sin_addr
.s_addr
;
855 req
->opt0
= cpu_to_be64(opt0
);
857 if (is_t4(ep
->com
.dev
->rdev
.lldi
.adapter_type
)) {
858 req
->params
= cpu_to_be32(params
);
859 req
->opt2
= cpu_to_be32(opt2
);
861 if (is_t5(ep
->com
.dev
->rdev
.lldi
.adapter_type
)) {
863 cpu_to_be64(FILTER_TUPLE_V(params
));
864 t5req
->rsvd
= cpu_to_be32(isn
);
865 pr_debug("snd_isn %u\n", t5req
->rsvd
);
866 t5req
->opt2
= cpu_to_be32(opt2
);
869 cpu_to_be64(FILTER_TUPLE_V(params
));
870 t6req
->rsvd
= cpu_to_be32(isn
);
871 pr_debug("snd_isn %u\n", t6req
->rsvd
);
872 t6req
->opt2
= cpu_to_be32(opt2
);
876 switch (CHELSIO_CHIP_VERSION(adapter_type
)) {
878 req6
= skb_put(skb
, wrlen
);
882 t5req6
= skb_put(skb
, wrlen
);
883 INIT_TP_WR(t5req6
, 0);
884 req6
= (struct cpl_act_open_req6
*)t5req6
;
887 t6req6
= skb_put(skb
, wrlen
);
888 INIT_TP_WR(t6req6
, 0);
889 req6
= (struct cpl_act_open_req6
*)t6req6
;
890 t5req6
= (struct cpl_t5_act_open_req6
*)t6req6
;
893 pr_err("T%d Chip is not supported\n",
894 CHELSIO_CHIP_VERSION(adapter_type
));
899 OPCODE_TID(req6
) = cpu_to_be32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ6
,
900 ((ep
->rss_qid
<<14)|ep
->atid
)));
901 req6
->local_port
= la6
->sin6_port
;
902 req6
->peer_port
= ra6
->sin6_port
;
903 req6
->local_ip_hi
= *((__be64
*)(la6
->sin6_addr
.s6_addr
));
904 req6
->local_ip_lo
= *((__be64
*)(la6
->sin6_addr
.s6_addr
+ 8));
905 req6
->peer_ip_hi
= *((__be64
*)(ra6
->sin6_addr
.s6_addr
));
906 req6
->peer_ip_lo
= *((__be64
*)(ra6
->sin6_addr
.s6_addr
+ 8));
907 req6
->opt0
= cpu_to_be64(opt0
);
909 if (is_t4(ep
->com
.dev
->rdev
.lldi
.adapter_type
)) {
910 req6
->params
= cpu_to_be32(cxgb4_select_ntuple(netdev
,
912 req6
->opt2
= cpu_to_be32(opt2
);
914 if (is_t5(ep
->com
.dev
->rdev
.lldi
.adapter_type
)) {
916 cpu_to_be64(FILTER_TUPLE_V(params
));
917 t5req6
->rsvd
= cpu_to_be32(isn
);
918 pr_debug("snd_isn %u\n", t5req6
->rsvd
);
919 t5req6
->opt2
= cpu_to_be32(opt2
);
922 cpu_to_be64(FILTER_TUPLE_V(params
));
923 t6req6
->rsvd
= cpu_to_be32(isn
);
924 pr_debug("snd_isn %u\n", t6req6
->rsvd
);
925 t6req6
->opt2
= cpu_to_be32(opt2
);
931 set_bit(ACT_OPEN_REQ
, &ep
->com
.history
);
932 ret
= c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
934 if (ret
&& ep
->com
.remote_addr
.ss_family
== AF_INET6
)
935 cxgb4_clip_release(ep
->com
.dev
->rdev
.lldi
.ports
[0],
936 (const u32
*)&la6
->sin6_addr
.s6_addr
, 1);
940 static int send_mpa_req(struct c4iw_ep
*ep
, struct sk_buff
*skb
,
943 int mpalen
, wrlen
, ret
;
944 struct fw_ofld_tx_data_wr
*req
;
945 struct mpa_message
*mpa
;
946 struct mpa_v2_conn_params mpa_v2_params
;
948 pr_debug("ep %p tid %u pd_len %d\n",
949 ep
, ep
->hwtid
, ep
->plen
);
951 mpalen
= sizeof(*mpa
) + ep
->plen
;
952 if (mpa_rev_to_use
== 2)
953 mpalen
+= sizeof(struct mpa_v2_conn_params
);
954 wrlen
= roundup(mpalen
+ sizeof(*req
), 16);
955 skb
= get_skb(skb
, wrlen
, GFP_KERNEL
);
957 connect_reply_upcall(ep
, -ENOMEM
);
960 set_wr_txq(skb
, CPL_PRIORITY_DATA
, ep
->txq_idx
);
962 req
= skb_put_zero(skb
, wrlen
);
963 req
->op_to_immdlen
= cpu_to_be32(
964 FW_WR_OP_V(FW_OFLD_TX_DATA_WR
) |
966 FW_WR_IMMDLEN_V(mpalen
));
967 req
->flowid_len16
= cpu_to_be32(
968 FW_WR_FLOWID_V(ep
->hwtid
) |
969 FW_WR_LEN16_V(wrlen
>> 4));
970 req
->plen
= cpu_to_be32(mpalen
);
971 req
->tunnel_to_proxy
= cpu_to_be32(
972 FW_OFLD_TX_DATA_WR_FLUSH_F
|
973 FW_OFLD_TX_DATA_WR_SHOVE_F
);
975 mpa
= (struct mpa_message
*)(req
+ 1);
976 memcpy(mpa
->key
, MPA_KEY_REQ
, sizeof(mpa
->key
));
980 mpa
->flags
|= MPA_CRC
;
981 if (markers_enabled
) {
982 mpa
->flags
|= MPA_MARKERS
;
983 ep
->mpa_attr
.recv_marker_enabled
= 1;
985 ep
->mpa_attr
.recv_marker_enabled
= 0;
987 if (mpa_rev_to_use
== 2)
988 mpa
->flags
|= MPA_ENHANCED_RDMA_CONN
;
990 mpa
->private_data_size
= htons(ep
->plen
);
991 mpa
->revision
= mpa_rev_to_use
;
992 if (mpa_rev_to_use
== 1) {
993 ep
->tried_with_mpa_v1
= 1;
994 ep
->retry_with_mpa_v1
= 0;
997 if (mpa_rev_to_use
== 2) {
998 mpa
->private_data_size
=
999 htons(ntohs(mpa
->private_data_size
) +
1000 sizeof(struct mpa_v2_conn_params
));
1001 pr_debug("initiator ird %u ord %u\n", ep
->ird
,
1003 mpa_v2_params
.ird
= htons((u16
)ep
->ird
);
1004 mpa_v2_params
.ord
= htons((u16
)ep
->ord
);
1007 mpa_v2_params
.ird
|= htons(MPA_V2_PEER2PEER_MODEL
);
1008 if (p2p_type
== FW_RI_INIT_P2PTYPE_RDMA_WRITE
)
1009 mpa_v2_params
.ord
|=
1010 htons(MPA_V2_RDMA_WRITE_RTR
);
1011 else if (p2p_type
== FW_RI_INIT_P2PTYPE_READ_REQ
)
1012 mpa_v2_params
.ord
|=
1013 htons(MPA_V2_RDMA_READ_RTR
);
1015 memcpy(mpa
->private_data
, &mpa_v2_params
,
1016 sizeof(struct mpa_v2_conn_params
));
1019 memcpy(mpa
->private_data
+
1020 sizeof(struct mpa_v2_conn_params
),
1021 ep
->mpa_pkt
+ sizeof(*mpa
), ep
->plen
);
1024 memcpy(mpa
->private_data
,
1025 ep
->mpa_pkt
+ sizeof(*mpa
), ep
->plen
);
1028 * Reference the mpa skb. This ensures the data area
1029 * will remain in memory until the hw acks the tx.
1030 * Function fw4_ack() will deref it.
1033 t4_set_arp_err_handler(skb
, NULL
, arp_failure_discard
);
1035 ret
= c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
1039 __state_set(&ep
->com
, MPA_REQ_SENT
);
1040 ep
->mpa_attr
.initiator
= 1;
1041 ep
->snd_seq
+= mpalen
;
1045 static int send_mpa_reject(struct c4iw_ep
*ep
, const void *pdata
, u8 plen
)
1048 struct fw_ofld_tx_data_wr
*req
;
1049 struct mpa_message
*mpa
;
1050 struct sk_buff
*skb
;
1051 struct mpa_v2_conn_params mpa_v2_params
;
1053 pr_debug("ep %p tid %u pd_len %d\n",
1054 ep
, ep
->hwtid
, ep
->plen
);
1056 mpalen
= sizeof(*mpa
) + plen
;
1057 if (ep
->mpa_attr
.version
== 2 && ep
->mpa_attr
.enhanced_rdma_conn
)
1058 mpalen
+= sizeof(struct mpa_v2_conn_params
);
1059 wrlen
= roundup(mpalen
+ sizeof(*req
), 16);
1061 skb
= get_skb(NULL
, wrlen
, GFP_KERNEL
);
1063 pr_err("%s - cannot alloc skb!\n", __func__
);
1066 set_wr_txq(skb
, CPL_PRIORITY_DATA
, ep
->txq_idx
);
1068 req
= skb_put_zero(skb
, wrlen
);
1069 req
->op_to_immdlen
= cpu_to_be32(
1070 FW_WR_OP_V(FW_OFLD_TX_DATA_WR
) |
1072 FW_WR_IMMDLEN_V(mpalen
));
1073 req
->flowid_len16
= cpu_to_be32(
1074 FW_WR_FLOWID_V(ep
->hwtid
) |
1075 FW_WR_LEN16_V(wrlen
>> 4));
1076 req
->plen
= cpu_to_be32(mpalen
);
1077 req
->tunnel_to_proxy
= cpu_to_be32(
1078 FW_OFLD_TX_DATA_WR_FLUSH_F
|
1079 FW_OFLD_TX_DATA_WR_SHOVE_F
);
1081 mpa
= (struct mpa_message
*)(req
+ 1);
1082 memset(mpa
, 0, sizeof(*mpa
));
1083 memcpy(mpa
->key
, MPA_KEY_REP
, sizeof(mpa
->key
));
1084 mpa
->flags
= MPA_REJECT
;
1085 mpa
->revision
= ep
->mpa_attr
.version
;
1086 mpa
->private_data_size
= htons(plen
);
1088 if (ep
->mpa_attr
.version
== 2 && ep
->mpa_attr
.enhanced_rdma_conn
) {
1089 mpa
->flags
|= MPA_ENHANCED_RDMA_CONN
;
1090 mpa
->private_data_size
=
1091 htons(ntohs(mpa
->private_data_size
) +
1092 sizeof(struct mpa_v2_conn_params
));
1093 mpa_v2_params
.ird
= htons(((u16
)ep
->ird
) |
1094 (peer2peer
? MPA_V2_PEER2PEER_MODEL
:
1096 mpa_v2_params
.ord
= htons(((u16
)ep
->ord
) | (peer2peer
?
1098 FW_RI_INIT_P2PTYPE_RDMA_WRITE
?
1099 MPA_V2_RDMA_WRITE_RTR
: p2p_type
==
1100 FW_RI_INIT_P2PTYPE_READ_REQ
?
1101 MPA_V2_RDMA_READ_RTR
: 0) : 0));
1102 memcpy(mpa
->private_data
, &mpa_v2_params
,
1103 sizeof(struct mpa_v2_conn_params
));
1106 memcpy(mpa
->private_data
+
1107 sizeof(struct mpa_v2_conn_params
), pdata
, plen
);
1110 memcpy(mpa
->private_data
, pdata
, plen
);
1113 * Reference the mpa skb again. This ensures the data area
1114 * will remain in memory until the hw acks the tx.
1115 * Function fw4_ack() will deref it.
1118 set_wr_txq(skb
, CPL_PRIORITY_DATA
, ep
->txq_idx
);
1119 t4_set_arp_err_handler(skb
, NULL
, mpa_start_arp_failure
);
1121 ep
->snd_seq
+= mpalen
;
1122 return c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
1125 static int send_mpa_reply(struct c4iw_ep
*ep
, const void *pdata
, u8 plen
)
1128 struct fw_ofld_tx_data_wr
*req
;
1129 struct mpa_message
*mpa
;
1130 struct sk_buff
*skb
;
1131 struct mpa_v2_conn_params mpa_v2_params
;
1133 pr_debug("ep %p tid %u pd_len %d\n",
1134 ep
, ep
->hwtid
, ep
->plen
);
1136 mpalen
= sizeof(*mpa
) + plen
;
1137 if (ep
->mpa_attr
.version
== 2 && ep
->mpa_attr
.enhanced_rdma_conn
)
1138 mpalen
+= sizeof(struct mpa_v2_conn_params
);
1139 wrlen
= roundup(mpalen
+ sizeof(*req
), 16);
1141 skb
= get_skb(NULL
, wrlen
, GFP_KERNEL
);
1143 pr_err("%s - cannot alloc skb!\n", __func__
);
1146 set_wr_txq(skb
, CPL_PRIORITY_DATA
, ep
->txq_idx
);
1148 req
= skb_put_zero(skb
, wrlen
);
1149 req
->op_to_immdlen
= cpu_to_be32(
1150 FW_WR_OP_V(FW_OFLD_TX_DATA_WR
) |
1152 FW_WR_IMMDLEN_V(mpalen
));
1153 req
->flowid_len16
= cpu_to_be32(
1154 FW_WR_FLOWID_V(ep
->hwtid
) |
1155 FW_WR_LEN16_V(wrlen
>> 4));
1156 req
->plen
= cpu_to_be32(mpalen
);
1157 req
->tunnel_to_proxy
= cpu_to_be32(
1158 FW_OFLD_TX_DATA_WR_FLUSH_F
|
1159 FW_OFLD_TX_DATA_WR_SHOVE_F
);
1161 mpa
= (struct mpa_message
*)(req
+ 1);
1162 memset(mpa
, 0, sizeof(*mpa
));
1163 memcpy(mpa
->key
, MPA_KEY_REP
, sizeof(mpa
->key
));
1165 if (ep
->mpa_attr
.crc_enabled
)
1166 mpa
->flags
|= MPA_CRC
;
1167 if (ep
->mpa_attr
.recv_marker_enabled
)
1168 mpa
->flags
|= MPA_MARKERS
;
1169 mpa
->revision
= ep
->mpa_attr
.version
;
1170 mpa
->private_data_size
= htons(plen
);
1172 if (ep
->mpa_attr
.version
== 2 && ep
->mpa_attr
.enhanced_rdma_conn
) {
1173 mpa
->flags
|= MPA_ENHANCED_RDMA_CONN
;
1174 mpa
->private_data_size
=
1175 htons(ntohs(mpa
->private_data_size
) +
1176 sizeof(struct mpa_v2_conn_params
));
1177 mpa_v2_params
.ird
= htons((u16
)ep
->ird
);
1178 mpa_v2_params
.ord
= htons((u16
)ep
->ord
);
1179 if (peer2peer
&& (ep
->mpa_attr
.p2p_type
!=
1180 FW_RI_INIT_P2PTYPE_DISABLED
)) {
1181 mpa_v2_params
.ird
|= htons(MPA_V2_PEER2PEER_MODEL
);
1183 if (p2p_type
== FW_RI_INIT_P2PTYPE_RDMA_WRITE
)
1184 mpa_v2_params
.ord
|=
1185 htons(MPA_V2_RDMA_WRITE_RTR
);
1186 else if (p2p_type
== FW_RI_INIT_P2PTYPE_READ_REQ
)
1187 mpa_v2_params
.ord
|=
1188 htons(MPA_V2_RDMA_READ_RTR
);
1191 memcpy(mpa
->private_data
, &mpa_v2_params
,
1192 sizeof(struct mpa_v2_conn_params
));
1195 memcpy(mpa
->private_data
+
1196 sizeof(struct mpa_v2_conn_params
), pdata
, plen
);
1199 memcpy(mpa
->private_data
, pdata
, plen
);
1202 * Reference the mpa skb. This ensures the data area
1203 * will remain in memory until the hw acks the tx.
1204 * Function fw4_ack() will deref it.
1207 t4_set_arp_err_handler(skb
, NULL
, mpa_start_arp_failure
);
1209 __state_set(&ep
->com
, MPA_REP_SENT
);
1210 ep
->snd_seq
+= mpalen
;
1211 return c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
1214 static int act_establish(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
1217 struct cpl_act_establish
*req
= cplhdr(skb
);
1218 unsigned short tcp_opt
= ntohs(req
->tcp_opt
);
1219 unsigned int tid
= GET_TID(req
);
1220 unsigned int atid
= TID_TID_G(ntohl(req
->tos_atid
));
1221 struct tid_info
*t
= dev
->rdev
.lldi
.tids
;
1224 ep
= lookup_atid(t
, atid
);
1228 pr_debug("ep %p tid %u snd_isn %u rcv_isn %u\n", ep
, tid
,
1229 be32_to_cpu(req
->snd_isn
), be32_to_cpu(req
->rcv_isn
));
1231 mutex_lock(&ep
->com
.mutex
);
1232 dst_confirm(ep
->dst
);
1234 /* setup the hwtid for this connection */
1236 cxgb4_insert_tid(t
, ep
, tid
, ep
->com
.local_addr
.ss_family
);
1239 ep
->snd_seq
= be32_to_cpu(req
->snd_isn
);
1240 ep
->rcv_seq
= be32_to_cpu(req
->rcv_isn
);
1241 ep
->snd_wscale
= TCPOPT_SND_WSCALE_G(tcp_opt
);
1243 set_emss(ep
, tcp_opt
);
1245 /* dealloc the atid */
1246 xa_erase_irq(&ep
->com
.dev
->atids
, atid
);
1247 cxgb4_free_atid(t
, atid
);
1248 set_bit(ACT_ESTAB
, &ep
->com
.history
);
1250 /* start MPA negotiation */
1251 ret
= send_flowc(ep
);
1254 if (ep
->retry_with_mpa_v1
)
1255 ret
= send_mpa_req(ep
, skb
, 1);
1257 ret
= send_mpa_req(ep
, skb
, mpa_rev
);
1260 mutex_unlock(&ep
->com
.mutex
);
1263 mutex_unlock(&ep
->com
.mutex
);
1264 connect_reply_upcall(ep
, -ENOMEM
);
1265 c4iw_ep_disconnect(ep
, 0, GFP_KERNEL
);
1269 static void close_complete_upcall(struct c4iw_ep
*ep
, int status
)
1271 struct iw_cm_event event
;
1273 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1274 memset(&event
, 0, sizeof(event
));
1275 event
.event
= IW_CM_EVENT_CLOSE
;
1276 event
.status
= status
;
1277 if (ep
->com
.cm_id
) {
1278 pr_debug("close complete delivered ep %p cm_id %p tid %u\n",
1279 ep
, ep
->com
.cm_id
, ep
->hwtid
);
1280 ep
->com
.cm_id
->event_handler(ep
->com
.cm_id
, &event
);
1281 deref_cm_id(&ep
->com
);
1282 set_bit(CLOSE_UPCALL
, &ep
->com
.history
);
1286 static void peer_close_upcall(struct c4iw_ep
*ep
)
1288 struct iw_cm_event event
;
1290 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1291 memset(&event
, 0, sizeof(event
));
1292 event
.event
= IW_CM_EVENT_DISCONNECT
;
1293 if (ep
->com
.cm_id
) {
1294 pr_debug("peer close delivered ep %p cm_id %p tid %u\n",
1295 ep
, ep
->com
.cm_id
, ep
->hwtid
);
1296 ep
->com
.cm_id
->event_handler(ep
->com
.cm_id
, &event
);
1297 set_bit(DISCONN_UPCALL
, &ep
->com
.history
);
1301 static void peer_abort_upcall(struct c4iw_ep
*ep
)
1303 struct iw_cm_event event
;
1305 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1306 memset(&event
, 0, sizeof(event
));
1307 event
.event
= IW_CM_EVENT_CLOSE
;
1308 event
.status
= -ECONNRESET
;
1309 if (ep
->com
.cm_id
) {
1310 pr_debug("abort delivered ep %p cm_id %p tid %u\n", ep
,
1311 ep
->com
.cm_id
, ep
->hwtid
);
1312 ep
->com
.cm_id
->event_handler(ep
->com
.cm_id
, &event
);
1313 deref_cm_id(&ep
->com
);
1314 set_bit(ABORT_UPCALL
, &ep
->com
.history
);
1318 static void connect_reply_upcall(struct c4iw_ep
*ep
, int status
)
1320 struct iw_cm_event event
;
1322 pr_debug("ep %p tid %u status %d\n",
1323 ep
, ep
->hwtid
, status
);
1324 memset(&event
, 0, sizeof(event
));
1325 event
.event
= IW_CM_EVENT_CONNECT_REPLY
;
1326 event
.status
= status
;
1327 memcpy(&event
.local_addr
, &ep
->com
.local_addr
,
1328 sizeof(ep
->com
.local_addr
));
1329 memcpy(&event
.remote_addr
, &ep
->com
.remote_addr
,
1330 sizeof(ep
->com
.remote_addr
));
1332 if ((status
== 0) || (status
== -ECONNREFUSED
)) {
1333 if (!ep
->tried_with_mpa_v1
) {
1334 /* this means MPA_v2 is used */
1335 event
.ord
= ep
->ird
;
1336 event
.ird
= ep
->ord
;
1337 event
.private_data_len
= ep
->plen
-
1338 sizeof(struct mpa_v2_conn_params
);
1339 event
.private_data
= ep
->mpa_pkt
+
1340 sizeof(struct mpa_message
) +
1341 sizeof(struct mpa_v2_conn_params
);
1343 /* this means MPA_v1 is used */
1344 event
.ord
= cur_max_read_depth(ep
->com
.dev
);
1345 event
.ird
= cur_max_read_depth(ep
->com
.dev
);
1346 event
.private_data_len
= ep
->plen
;
1347 event
.private_data
= ep
->mpa_pkt
+
1348 sizeof(struct mpa_message
);
1352 pr_debug("ep %p tid %u status %d\n", ep
,
1354 set_bit(CONN_RPL_UPCALL
, &ep
->com
.history
);
1355 ep
->com
.cm_id
->event_handler(ep
->com
.cm_id
, &event
);
1358 deref_cm_id(&ep
->com
);
1361 static int connect_request_upcall(struct c4iw_ep
*ep
)
1363 struct iw_cm_event event
;
1366 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1367 memset(&event
, 0, sizeof(event
));
1368 event
.event
= IW_CM_EVENT_CONNECT_REQUEST
;
1369 memcpy(&event
.local_addr
, &ep
->com
.local_addr
,
1370 sizeof(ep
->com
.local_addr
));
1371 memcpy(&event
.remote_addr
, &ep
->com
.remote_addr
,
1372 sizeof(ep
->com
.remote_addr
));
1373 event
.provider_data
= ep
;
1374 if (!ep
->tried_with_mpa_v1
) {
1375 /* this means MPA_v2 is used */
1376 event
.ord
= ep
->ord
;
1377 event
.ird
= ep
->ird
;
1378 event
.private_data_len
= ep
->plen
-
1379 sizeof(struct mpa_v2_conn_params
);
1380 event
.private_data
= ep
->mpa_pkt
+ sizeof(struct mpa_message
) +
1381 sizeof(struct mpa_v2_conn_params
);
1383 /* this means MPA_v1 is used. Send max supported */
1384 event
.ord
= cur_max_read_depth(ep
->com
.dev
);
1385 event
.ird
= cur_max_read_depth(ep
->com
.dev
);
1386 event
.private_data_len
= ep
->plen
;
1387 event
.private_data
= ep
->mpa_pkt
+ sizeof(struct mpa_message
);
1389 c4iw_get_ep(&ep
->com
);
1390 ret
= ep
->parent_ep
->com
.cm_id
->event_handler(ep
->parent_ep
->com
.cm_id
,
1393 c4iw_put_ep(&ep
->com
);
1394 set_bit(CONNREQ_UPCALL
, &ep
->com
.history
);
1395 c4iw_put_ep(&ep
->parent_ep
->com
);
1399 static void established_upcall(struct c4iw_ep
*ep
)
1401 struct iw_cm_event event
;
1403 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1404 memset(&event
, 0, sizeof(event
));
1405 event
.event
= IW_CM_EVENT_ESTABLISHED
;
1406 event
.ird
= ep
->ord
;
1407 event
.ord
= ep
->ird
;
1408 if (ep
->com
.cm_id
) {
1409 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1410 ep
->com
.cm_id
->event_handler(ep
->com
.cm_id
, &event
);
1411 set_bit(ESTAB_UPCALL
, &ep
->com
.history
);
1415 static int update_rx_credits(struct c4iw_ep
*ep
, u32 credits
)
1417 struct sk_buff
*skb
;
1418 u32 wrlen
= roundup(sizeof(struct cpl_rx_data_ack
), 16);
1421 pr_debug("ep %p tid %u credits %u\n",
1422 ep
, ep
->hwtid
, credits
);
1423 skb
= get_skb(NULL
, wrlen
, GFP_KERNEL
);
1425 pr_err("update_rx_credits - cannot alloc skb!\n");
1430 * If we couldn't specify the entire rcv window at connection setup
1431 * due to the limit in the number of bits in the RCV_BUFSIZ field,
1432 * then add the overage in to the credits returned.
1434 if (ep
->rcv_win
> RCV_BUFSIZ_M
* 1024)
1435 credits
+= ep
->rcv_win
- RCV_BUFSIZ_M
* 1024;
1437 credit_dack
= credits
| RX_FORCE_ACK_F
| RX_DACK_CHANGE_F
|
1438 RX_DACK_MODE_V(dack_mode
);
1440 cxgb_mk_rx_data_ack(skb
, wrlen
, ep
->hwtid
, ep
->ctrlq_idx
,
1443 c4iw_ofld_send(&ep
->com
.dev
->rdev
, skb
);
1447 #define RELAXED_IRD_NEGOTIATION 1
1450 * process_mpa_reply - process streaming mode MPA reply
1454 * 0 upon success indicating a connect request was delivered to the ULP
1455 * or the mpa request is incomplete but valid so far.
1457 * 1 if a failure requires the caller to close the connection.
1459 * 2 if a failure requires the caller to abort the connection.
1461 static int process_mpa_reply(struct c4iw_ep
*ep
, struct sk_buff
*skb
)
1463 struct mpa_message
*mpa
;
1464 struct mpa_v2_conn_params
*mpa_v2_params
;
1466 u16 resp_ird
, resp_ord
;
1467 u8 rtr_mismatch
= 0, insuff_ird
= 0;
1468 struct c4iw_qp_attributes attrs
;
1469 enum c4iw_qp_attr_mask mask
;
1473 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1476 * If we get more than the supported amount of private data
1477 * then we must fail this connection.
1479 if (ep
->mpa_pkt_len
+ skb
->len
> sizeof(ep
->mpa_pkt
)) {
1481 goto err_stop_timer
;
1485 * copy the new data into our accumulation buffer.
1487 skb_copy_from_linear_data(skb
, &(ep
->mpa_pkt
[ep
->mpa_pkt_len
]),
1489 ep
->mpa_pkt_len
+= skb
->len
;
1492 * if we don't even have the mpa message, then bail.
1494 if (ep
->mpa_pkt_len
< sizeof(*mpa
))
1496 mpa
= (struct mpa_message
*) ep
->mpa_pkt
;
1498 /* Validate MPA header. */
1499 if (mpa
->revision
> mpa_rev
) {
1500 pr_err("%s MPA version mismatch. Local = %d, Received = %d\n",
1501 __func__
, mpa_rev
, mpa
->revision
);
1503 goto err_stop_timer
;
1505 if (memcmp(mpa
->key
, MPA_KEY_REP
, sizeof(mpa
->key
))) {
1507 goto err_stop_timer
;
1510 plen
= ntohs(mpa
->private_data_size
);
1513 * Fail if there's too much private data.
1515 if (plen
> MPA_MAX_PRIVATE_DATA
) {
1517 goto err_stop_timer
;
1521 * If plen does not account for pkt size
1523 if (ep
->mpa_pkt_len
> (sizeof(*mpa
) + plen
)) {
1525 goto err_stop_timer
;
1528 ep
->plen
= (u8
) plen
;
1531 * If we don't have all the pdata yet, then bail.
1532 * We'll continue process when more data arrives.
1534 if (ep
->mpa_pkt_len
< (sizeof(*mpa
) + plen
))
1537 if (mpa
->flags
& MPA_REJECT
) {
1538 err
= -ECONNREFUSED
;
1539 goto err_stop_timer
;
1543 * Stop mpa timer. If it expired, then
1544 * we ignore the MPA reply. process_timeout()
1545 * will abort the connection.
1547 if (stop_ep_timer(ep
))
1551 * If we get here we have accumulated the entire mpa
1552 * start reply message including private data. And
1553 * the MPA header is valid.
1555 __state_set(&ep
->com
, FPDU_MODE
);
1556 ep
->mpa_attr
.crc_enabled
= (mpa
->flags
& MPA_CRC
) | crc_enabled
? 1 : 0;
1557 ep
->mpa_attr
.xmit_marker_enabled
= mpa
->flags
& MPA_MARKERS
? 1 : 0;
1558 ep
->mpa_attr
.version
= mpa
->revision
;
1559 ep
->mpa_attr
.p2p_type
= FW_RI_INIT_P2PTYPE_DISABLED
;
1561 if (mpa
->revision
== 2) {
1562 ep
->mpa_attr
.enhanced_rdma_conn
=
1563 mpa
->flags
& MPA_ENHANCED_RDMA_CONN
? 1 : 0;
1564 if (ep
->mpa_attr
.enhanced_rdma_conn
) {
1565 mpa_v2_params
= (struct mpa_v2_conn_params
*)
1566 (ep
->mpa_pkt
+ sizeof(*mpa
));
1567 resp_ird
= ntohs(mpa_v2_params
->ird
) &
1568 MPA_V2_IRD_ORD_MASK
;
1569 resp_ord
= ntohs(mpa_v2_params
->ord
) &
1570 MPA_V2_IRD_ORD_MASK
;
1571 pr_debug("responder ird %u ord %u ep ird %u ord %u\n",
1572 resp_ird
, resp_ord
, ep
->ird
, ep
->ord
);
1575 * This is a double-check. Ideally, below checks are
1576 * not required since ird/ord stuff has been taken
1577 * care of in c4iw_accept_cr
1579 if (ep
->ird
< resp_ord
) {
1580 if (RELAXED_IRD_NEGOTIATION
&& resp_ord
<=
1581 ep
->com
.dev
->rdev
.lldi
.max_ordird_qp
)
1585 } else if (ep
->ird
> resp_ord
) {
1588 if (ep
->ord
> resp_ird
) {
1589 if (RELAXED_IRD_NEGOTIATION
)
1600 if (ntohs(mpa_v2_params
->ird
) &
1601 MPA_V2_PEER2PEER_MODEL
) {
1602 if (ntohs(mpa_v2_params
->ord
) &
1603 MPA_V2_RDMA_WRITE_RTR
)
1604 ep
->mpa_attr
.p2p_type
=
1605 FW_RI_INIT_P2PTYPE_RDMA_WRITE
;
1606 else if (ntohs(mpa_v2_params
->ord
) &
1607 MPA_V2_RDMA_READ_RTR
)
1608 ep
->mpa_attr
.p2p_type
=
1609 FW_RI_INIT_P2PTYPE_READ_REQ
;
1612 } else if (mpa
->revision
== 1)
1614 ep
->mpa_attr
.p2p_type
= p2p_type
;
1616 pr_debug("crc_enabled=%d, recv_marker_enabled=%d, xmit_marker_enabled=%d, version=%d p2p_type=%d local-p2p_type = %d\n",
1617 ep
->mpa_attr
.crc_enabled
,
1618 ep
->mpa_attr
.recv_marker_enabled
,
1619 ep
->mpa_attr
.xmit_marker_enabled
, ep
->mpa_attr
.version
,
1620 ep
->mpa_attr
.p2p_type
, p2p_type
);
1623 * If responder's RTR does not match with that of initiator, assign
1624 * FW_RI_INIT_P2PTYPE_DISABLED in mpa attributes so that RTR is not
1625 * generated when moving QP to RTS state.
1626 * A TERM message will be sent after QP has moved to RTS state
1628 if ((ep
->mpa_attr
.version
== 2) && peer2peer
&&
1629 (ep
->mpa_attr
.p2p_type
!= p2p_type
)) {
1630 ep
->mpa_attr
.p2p_type
= FW_RI_INIT_P2PTYPE_DISABLED
;
1634 attrs
.mpa_attr
= ep
->mpa_attr
;
1635 attrs
.max_ird
= ep
->ird
;
1636 attrs
.max_ord
= ep
->ord
;
1637 attrs
.llp_stream_handle
= ep
;
1638 attrs
.next_state
= C4IW_QP_STATE_RTS
;
1640 mask
= C4IW_QP_ATTR_NEXT_STATE
|
1641 C4IW_QP_ATTR_LLP_STREAM_HANDLE
| C4IW_QP_ATTR_MPA_ATTR
|
1642 C4IW_QP_ATTR_MAX_IRD
| C4IW_QP_ATTR_MAX_ORD
;
1644 /* bind QP and TID with INIT_WR */
1645 err
= c4iw_modify_qp(ep
->com
.qp
->rhp
,
1646 ep
->com
.qp
, mask
, &attrs
, 1);
1651 * If responder's RTR requirement did not match with what initiator
1652 * supports, generate TERM message
1655 pr_err("%s: RTR mismatch, sending TERM\n", __func__
);
1656 attrs
.layer_etype
= LAYER_MPA
| DDP_LLP
;
1657 attrs
.ecode
= MPA_NOMATCH_RTR
;
1658 attrs
.next_state
= C4IW_QP_STATE_TERMINATE
;
1659 attrs
.send_term
= 1;
1660 err
= c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
1661 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
1668 * Generate TERM if initiator IRD is not sufficient for responder
1669 * provided ORD. Currently, we do the same behaviour even when
1670 * responder provided IRD is also not sufficient as regards to
1674 pr_err("%s: Insufficient IRD, sending TERM\n", __func__
);
1675 attrs
.layer_etype
= LAYER_MPA
| DDP_LLP
;
1676 attrs
.ecode
= MPA_INSUFF_IRD
;
1677 attrs
.next_state
= C4IW_QP_STATE_TERMINATE
;
1678 attrs
.send_term
= 1;
1679 err
= c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
1680 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
1691 connect_reply_upcall(ep
, err
);
1696 * process_mpa_request - process streaming mode MPA request
1700 * 0 upon success indicating a connect request was delivered to the ULP
1701 * or the mpa request is incomplete but valid so far.
1703 * 1 if a failure requires the caller to close the connection.
1705 * 2 if a failure requires the caller to abort the connection.
1707 static int process_mpa_request(struct c4iw_ep
*ep
, struct sk_buff
*skb
)
1709 struct mpa_message
*mpa
;
1710 struct mpa_v2_conn_params
*mpa_v2_params
;
1713 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1716 * If we get more than the supported amount of private data
1717 * then we must fail this connection.
1719 if (ep
->mpa_pkt_len
+ skb
->len
> sizeof(ep
->mpa_pkt
))
1720 goto err_stop_timer
;
1722 pr_debug("enter (%s line %u)\n", __FILE__
, __LINE__
);
1725 * Copy the new data into our accumulation buffer.
1727 skb_copy_from_linear_data(skb
, &(ep
->mpa_pkt
[ep
->mpa_pkt_len
]),
1729 ep
->mpa_pkt_len
+= skb
->len
;
1732 * If we don't even have the mpa message, then bail.
1733 * We'll continue process when more data arrives.
1735 if (ep
->mpa_pkt_len
< sizeof(*mpa
))
1738 pr_debug("enter (%s line %u)\n", __FILE__
, __LINE__
);
1739 mpa
= (struct mpa_message
*) ep
->mpa_pkt
;
1742 * Validate MPA Header.
1744 if (mpa
->revision
> mpa_rev
) {
1745 pr_err("%s MPA version mismatch. Local = %d, Received = %d\n",
1746 __func__
, mpa_rev
, mpa
->revision
);
1747 goto err_stop_timer
;
1750 if (memcmp(mpa
->key
, MPA_KEY_REQ
, sizeof(mpa
->key
)))
1751 goto err_stop_timer
;
1753 plen
= ntohs(mpa
->private_data_size
);
1756 * Fail if there's too much private data.
1758 if (plen
> MPA_MAX_PRIVATE_DATA
)
1759 goto err_stop_timer
;
1762 * If plen does not account for pkt size
1764 if (ep
->mpa_pkt_len
> (sizeof(*mpa
) + plen
))
1765 goto err_stop_timer
;
1766 ep
->plen
= (u8
) plen
;
1769 * If we don't have all the pdata yet, then bail.
1771 if (ep
->mpa_pkt_len
< (sizeof(*mpa
) + plen
))
1775 * If we get here we have accumulated the entire mpa
1776 * start reply message including private data.
1778 ep
->mpa_attr
.initiator
= 0;
1779 ep
->mpa_attr
.crc_enabled
= (mpa
->flags
& MPA_CRC
) | crc_enabled
? 1 : 0;
1780 ep
->mpa_attr
.recv_marker_enabled
= markers_enabled
;
1781 ep
->mpa_attr
.xmit_marker_enabled
= mpa
->flags
& MPA_MARKERS
? 1 : 0;
1782 ep
->mpa_attr
.version
= mpa
->revision
;
1783 if (mpa
->revision
== 1)
1784 ep
->tried_with_mpa_v1
= 1;
1785 ep
->mpa_attr
.p2p_type
= FW_RI_INIT_P2PTYPE_DISABLED
;
1787 if (mpa
->revision
== 2) {
1788 ep
->mpa_attr
.enhanced_rdma_conn
=
1789 mpa
->flags
& MPA_ENHANCED_RDMA_CONN
? 1 : 0;
1790 if (ep
->mpa_attr
.enhanced_rdma_conn
) {
1791 mpa_v2_params
= (struct mpa_v2_conn_params
*)
1792 (ep
->mpa_pkt
+ sizeof(*mpa
));
1793 ep
->ird
= ntohs(mpa_v2_params
->ird
) &
1794 MPA_V2_IRD_ORD_MASK
;
1795 ep
->ird
= min_t(u32
, ep
->ird
,
1796 cur_max_read_depth(ep
->com
.dev
));
1797 ep
->ord
= ntohs(mpa_v2_params
->ord
) &
1798 MPA_V2_IRD_ORD_MASK
;
1799 ep
->ord
= min_t(u32
, ep
->ord
,
1800 cur_max_read_depth(ep
->com
.dev
));
1801 pr_debug("initiator ird %u ord %u\n",
1803 if (ntohs(mpa_v2_params
->ird
) & MPA_V2_PEER2PEER_MODEL
)
1805 if (ntohs(mpa_v2_params
->ord
) &
1806 MPA_V2_RDMA_WRITE_RTR
)
1807 ep
->mpa_attr
.p2p_type
=
1808 FW_RI_INIT_P2PTYPE_RDMA_WRITE
;
1809 else if (ntohs(mpa_v2_params
->ord
) &
1810 MPA_V2_RDMA_READ_RTR
)
1811 ep
->mpa_attr
.p2p_type
=
1812 FW_RI_INIT_P2PTYPE_READ_REQ
;
1815 } else if (mpa
->revision
== 1)
1817 ep
->mpa_attr
.p2p_type
= p2p_type
;
1819 pr_debug("crc_enabled=%d, recv_marker_enabled=%d, xmit_marker_enabled=%d, version=%d p2p_type=%d\n",
1820 ep
->mpa_attr
.crc_enabled
, ep
->mpa_attr
.recv_marker_enabled
,
1821 ep
->mpa_attr
.xmit_marker_enabled
, ep
->mpa_attr
.version
,
1822 ep
->mpa_attr
.p2p_type
);
1824 __state_set(&ep
->com
, MPA_REQ_RCVD
);
1827 mutex_lock_nested(&ep
->parent_ep
->com
.mutex
, SINGLE_DEPTH_NESTING
);
1828 if (ep
->parent_ep
->com
.state
!= DEAD
) {
1829 if (connect_request_upcall(ep
))
1830 goto err_unlock_parent
;
1832 goto err_unlock_parent
;
1834 mutex_unlock(&ep
->parent_ep
->com
.mutex
);
1838 mutex_unlock(&ep
->parent_ep
->com
.mutex
);
1841 (void)stop_ep_timer(ep
);
1846 static int rx_data(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
1849 struct cpl_rx_data
*hdr
= cplhdr(skb
);
1850 unsigned int dlen
= ntohs(hdr
->len
);
1851 unsigned int tid
= GET_TID(hdr
);
1852 __u8 status
= hdr
->status
;
1855 ep
= get_ep_from_tid(dev
, tid
);
1858 pr_debug("ep %p tid %u dlen %u\n", ep
, ep
->hwtid
, dlen
);
1859 skb_pull(skb
, sizeof(*hdr
));
1860 skb_trim(skb
, dlen
);
1861 mutex_lock(&ep
->com
.mutex
);
1863 switch (ep
->com
.state
) {
1865 update_rx_credits(ep
, dlen
);
1866 ep
->rcv_seq
+= dlen
;
1867 disconnect
= process_mpa_reply(ep
, skb
);
1870 update_rx_credits(ep
, dlen
);
1871 ep
->rcv_seq
+= dlen
;
1872 disconnect
= process_mpa_request(ep
, skb
);
1875 struct c4iw_qp_attributes attrs
;
1877 update_rx_credits(ep
, dlen
);
1879 pr_err("%s Unexpected streaming data." \
1880 " qpid %u ep %p state %d tid %u status %d\n",
1881 __func__
, ep
->com
.qp
->wq
.sq
.qid
, ep
,
1882 ep
->com
.state
, ep
->hwtid
, status
);
1883 attrs
.next_state
= C4IW_QP_STATE_TERMINATE
;
1884 c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
1885 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
1892 mutex_unlock(&ep
->com
.mutex
);
1894 c4iw_ep_disconnect(ep
, disconnect
== 2, GFP_KERNEL
);
1895 c4iw_put_ep(&ep
->com
);
1899 static void complete_cached_srq_buffers(struct c4iw_ep
*ep
, u32 srqidx
)
1901 enum chip_type adapter_type
;
1903 adapter_type
= ep
->com
.dev
->rdev
.lldi
.adapter_type
;
1906 * If this TCB had a srq buffer cached, then we must complete
1907 * it. For user mode, that means saving the srqidx in the
1908 * user/kernel status page for this qp. For kernel mode, just
1909 * synthesize the CQE now.
1911 if (CHELSIO_CHIP_VERSION(adapter_type
) > CHELSIO_T5
&& srqidx
) {
1912 if (ep
->com
.qp
->ibqp
.uobject
)
1913 t4_set_wq_in_error(&ep
->com
.qp
->wq
, srqidx
);
1915 c4iw_flush_srqidx(ep
->com
.qp
, srqidx
);
1919 static int abort_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
1923 struct cpl_abort_rpl_rss6
*rpl
= cplhdr(skb
);
1925 unsigned int tid
= GET_TID(rpl
);
1927 ep
= get_ep_from_tid(dev
, tid
);
1929 pr_warn("Abort rpl to freed endpoint\n");
1933 if (ep
->com
.qp
&& ep
->com
.qp
->srq
) {
1934 srqidx
= ABORT_RSS_SRQIDX_G(be32_to_cpu(rpl
->srqidx_status
));
1935 complete_cached_srq_buffers(ep
, srqidx
? srqidx
: ep
->srqe_idx
);
1938 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
1939 mutex_lock(&ep
->com
.mutex
);
1940 switch (ep
->com
.state
) {
1942 c4iw_wake_up_noref(ep
->com
.wr_waitp
, -ECONNRESET
);
1943 __state_set(&ep
->com
, DEAD
);
1947 pr_err("%s ep %p state %d\n", __func__
, ep
, ep
->com
.state
);
1950 mutex_unlock(&ep
->com
.mutex
);
1953 close_complete_upcall(ep
, -ECONNRESET
);
1954 release_ep_resources(ep
);
1956 c4iw_put_ep(&ep
->com
);
1960 static int send_fw_act_open_req(struct c4iw_ep
*ep
, unsigned int atid
)
1962 struct sk_buff
*skb
;
1963 struct fw_ofld_connection_wr
*req
;
1964 unsigned int mtu_idx
;
1966 struct sockaddr_in
*sin
;
1969 skb
= get_skb(NULL
, sizeof(*req
), GFP_KERNEL
);
1973 req
= __skb_put_zero(skb
, sizeof(*req
));
1974 req
->op_compl
= htonl(WR_OP_V(FW_OFLD_CONNECTION_WR
));
1975 req
->len16_pkd
= htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req
), 16)));
1976 req
->le
.filter
= cpu_to_be32(cxgb4_select_ntuple(
1977 ep
->com
.dev
->rdev
.lldi
.ports
[0],
1979 sin
= (struct sockaddr_in
*)&ep
->com
.local_addr
;
1980 req
->le
.lport
= sin
->sin_port
;
1981 req
->le
.u
.ipv4
.lip
= sin
->sin_addr
.s_addr
;
1982 sin
= (struct sockaddr_in
*)&ep
->com
.remote_addr
;
1983 req
->le
.pport
= sin
->sin_port
;
1984 req
->le
.u
.ipv4
.pip
= sin
->sin_addr
.s_addr
;
1985 req
->tcb
.t_state_to_astid
=
1986 htonl(FW_OFLD_CONNECTION_WR_T_STATE_V(TCP_SYN_SENT
) |
1987 FW_OFLD_CONNECTION_WR_ASTID_V(atid
));
1988 req
->tcb
.cplrxdataack_cplpassacceptrpl
=
1989 htons(FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F
);
1990 req
->tcb
.tx_max
= (__force __be32
) jiffies
;
1991 req
->tcb
.rcv_adv
= htons(1);
1992 cxgb_best_mtu(ep
->com
.dev
->rdev
.lldi
.mtus
, ep
->mtu
, &mtu_idx
,
1993 enable_tcp_timestamps
,
1994 (ep
->com
.remote_addr
.ss_family
== AF_INET
) ? 0 : 1);
1995 wscale
= cxgb_compute_wscale(rcv_win
);
1998 * Specify the largest window that will fit in opt0. The
1999 * remainder will be specified in the rx_data_ack.
2001 win
= ep
->rcv_win
>> 10;
2002 if (win
> RCV_BUFSIZ_M
)
2005 req
->tcb
.opt0
= (__force __be64
) (TCAM_BYPASS_F
|
2006 (nocong
? NO_CONG_F
: 0) |
2009 WND_SCALE_V(wscale
) |
2010 MSS_IDX_V(mtu_idx
) |
2011 L2T_IDX_V(ep
->l2t
->idx
) |
2012 TX_CHAN_V(ep
->tx_chan
) |
2013 SMAC_SEL_V(ep
->smac_idx
) |
2014 DSCP_V(ep
->tos
>> 2) |
2015 ULP_MODE_V(ULP_MODE_TCPDDP
) |
2017 req
->tcb
.opt2
= (__force __be32
) (PACE_V(1) |
2018 TX_QUEUE_V(ep
->com
.dev
->rdev
.lldi
.tx_modq
[ep
->tx_chan
]) |
2020 CCTRL_ECN_V(enable_ecn
) |
2021 RSS_QUEUE_VALID_F
| RSS_QUEUE_V(ep
->rss_qid
));
2022 if (enable_tcp_timestamps
)
2023 req
->tcb
.opt2
|= (__force __be32
)TSTAMPS_EN_F
;
2024 if (enable_tcp_sack
)
2025 req
->tcb
.opt2
|= (__force __be32
)SACK_EN_F
;
2026 if (wscale
&& enable_tcp_window_scaling
)
2027 req
->tcb
.opt2
|= (__force __be32
)WND_SCALE_EN_F
;
2028 req
->tcb
.opt0
= cpu_to_be64((__force u64
)req
->tcb
.opt0
);
2029 req
->tcb
.opt2
= cpu_to_be32((__force u32
)req
->tcb
.opt2
);
2030 set_wr_txq(skb
, CPL_PRIORITY_CONTROL
, ep
->ctrlq_idx
);
2031 set_bit(ACT_OFLD_CONN
, &ep
->com
.history
);
2032 return c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
2036 * Some of the error codes above implicitly indicate that there is no TID
2037 * allocated with the result of an ACT_OPEN. We use this predicate to make
2040 static inline int act_open_has_tid(int status
)
2042 return (status
!= CPL_ERR_TCAM_PARITY
&&
2043 status
!= CPL_ERR_TCAM_MISS
&&
2044 status
!= CPL_ERR_TCAM_FULL
&&
2045 status
!= CPL_ERR_CONN_EXIST_SYNRECV
&&
2046 status
!= CPL_ERR_CONN_EXIST
);
2049 static char *neg_adv_str(unsigned int status
)
2052 case CPL_ERR_RTX_NEG_ADVICE
:
2053 return "Retransmit timeout";
2054 case CPL_ERR_PERSIST_NEG_ADVICE
:
2055 return "Persist timeout";
2056 case CPL_ERR_KEEPALV_NEG_ADVICE
:
2057 return "Keepalive timeout";
2063 static void set_tcp_window(struct c4iw_ep
*ep
, struct port_info
*pi
)
2065 ep
->snd_win
= snd_win
;
2066 ep
->rcv_win
= rcv_win
;
2067 pr_debug("snd_win %d rcv_win %d\n",
2068 ep
->snd_win
, ep
->rcv_win
);
2071 #define ACT_OPEN_RETRY_COUNT 2
2073 static int import_ep(struct c4iw_ep
*ep
, int iptype
, __u8
*peer_ip
,
2074 struct dst_entry
*dst
, struct c4iw_dev
*cdev
,
2075 bool clear_mpa_v1
, enum chip_type adapter_type
, u8 tos
)
2077 struct neighbour
*n
;
2079 struct net_device
*pdev
;
2081 n
= dst_neigh_lookup(dst
, peer_ip
);
2087 if (n
->dev
->flags
& IFF_LOOPBACK
) {
2089 pdev
= __ip_dev_find(&init_net
, *(__be32
*)peer_ip
, false);
2090 else if (IS_ENABLED(CONFIG_IPV6
))
2091 for_each_netdev(&init_net
, pdev
) {
2092 if (ipv6_chk_addr(&init_net
,
2093 (struct in6_addr
*)peer_ip
,
2104 if (is_vlan_dev(pdev
))
2105 pdev
= vlan_dev_real_dev(pdev
);
2106 ep
->l2t
= cxgb4_l2t_get(cdev
->rdev
.lldi
.l2t
,
2107 n
, pdev
, rt_tos2priority(tos
));
2110 ep
->mtu
= pdev
->mtu
;
2111 ep
->tx_chan
= cxgb4_port_chan(pdev
);
2112 ep
->smac_idx
= ((struct port_info
*)netdev_priv(pdev
))->smt_idx
;
2113 step
= cdev
->rdev
.lldi
.ntxq
/
2114 cdev
->rdev
.lldi
.nchan
;
2115 ep
->txq_idx
= cxgb4_port_idx(pdev
) * step
;
2116 step
= cdev
->rdev
.lldi
.nrxq
/
2117 cdev
->rdev
.lldi
.nchan
;
2118 ep
->ctrlq_idx
= cxgb4_port_idx(pdev
);
2119 ep
->rss_qid
= cdev
->rdev
.lldi
.rxq_ids
[
2120 cxgb4_port_idx(pdev
) * step
];
2121 set_tcp_window(ep
, (struct port_info
*)netdev_priv(pdev
));
2123 pdev
= get_real_dev(n
->dev
);
2124 ep
->l2t
= cxgb4_l2t_get(cdev
->rdev
.lldi
.l2t
,
2125 n
, pdev
, rt_tos2priority(tos
));
2128 ep
->mtu
= dst_mtu(dst
);
2129 ep
->tx_chan
= cxgb4_port_chan(pdev
);
2130 ep
->smac_idx
= ((struct port_info
*)netdev_priv(pdev
))->smt_idx
;
2131 step
= cdev
->rdev
.lldi
.ntxq
/
2132 cdev
->rdev
.lldi
.nchan
;
2133 ep
->txq_idx
= cxgb4_port_idx(pdev
) * step
;
2134 ep
->ctrlq_idx
= cxgb4_port_idx(pdev
);
2135 step
= cdev
->rdev
.lldi
.nrxq
/
2136 cdev
->rdev
.lldi
.nchan
;
2137 ep
->rss_qid
= cdev
->rdev
.lldi
.rxq_ids
[
2138 cxgb4_port_idx(pdev
) * step
];
2139 set_tcp_window(ep
, (struct port_info
*)netdev_priv(pdev
));
2142 ep
->retry_with_mpa_v1
= 0;
2143 ep
->tried_with_mpa_v1
= 0;
2155 static int c4iw_reconnect(struct c4iw_ep
*ep
)
2159 struct sockaddr_in
*laddr
= (struct sockaddr_in
*)
2160 &ep
->com
.cm_id
->m_local_addr
;
2161 struct sockaddr_in
*raddr
= (struct sockaddr_in
*)
2162 &ep
->com
.cm_id
->m_remote_addr
;
2163 struct sockaddr_in6
*laddr6
= (struct sockaddr_in6
*)
2164 &ep
->com
.cm_id
->m_local_addr
;
2165 struct sockaddr_in6
*raddr6
= (struct sockaddr_in6
*)
2166 &ep
->com
.cm_id
->m_remote_addr
;
2170 pr_debug("qp %p cm_id %p\n", ep
->com
.qp
, ep
->com
.cm_id
);
2171 c4iw_init_wr_wait(ep
->com
.wr_waitp
);
2173 /* When MPA revision is different on nodes, the node with MPA_rev=2
2174 * tries to reconnect with MPA_rev 1 for the same EP through
2175 * c4iw_reconnect(), where the same EP is assigned with new tid for
2176 * further connection establishment. As we are using the same EP pointer
2177 * for reconnect, few skbs are used during the previous c4iw_connect(),
2178 * which leaves the EP with inadequate skbs for further
2179 * c4iw_reconnect(), Further causing a crash due to an empty
2180 * skb_list() during peer_abort(). Allocate skbs which is already used.
2182 size
= (CN_MAX_CON_BUF
- skb_queue_len(&ep
->com
.ep_skb_list
));
2183 if (alloc_ep_skb_list(&ep
->com
.ep_skb_list
, size
)) {
2189 * Allocate an active TID to initiate a TCP connection.
2191 ep
->atid
= cxgb4_alloc_atid(ep
->com
.dev
->rdev
.lldi
.tids
, ep
);
2192 if (ep
->atid
== -1) {
2193 pr_err("%s - cannot alloc atid\n", __func__
);
2197 err
= xa_insert_irq(&ep
->com
.dev
->atids
, ep
->atid
, ep
, GFP_KERNEL
);
2202 if (ep
->com
.cm_id
->m_local_addr
.ss_family
== AF_INET
) {
2203 ep
->dst
= cxgb_find_route(&ep
->com
.dev
->rdev
.lldi
, get_real_dev
,
2204 laddr
->sin_addr
.s_addr
,
2205 raddr
->sin_addr
.s_addr
,
2207 raddr
->sin_port
, ep
->com
.cm_id
->tos
);
2209 ra
= (__u8
*)&raddr
->sin_addr
;
2211 ep
->dst
= cxgb_find_route6(&ep
->com
.dev
->rdev
.lldi
,
2213 laddr6
->sin6_addr
.s6_addr
,
2214 raddr6
->sin6_addr
.s6_addr
,
2218 raddr6
->sin6_scope_id
);
2220 ra
= (__u8
*)&raddr6
->sin6_addr
;
2223 pr_err("%s - cannot find route\n", __func__
);
2224 err
= -EHOSTUNREACH
;
2227 err
= import_ep(ep
, iptype
, ra
, ep
->dst
, ep
->com
.dev
, false,
2228 ep
->com
.dev
->rdev
.lldi
.adapter_type
,
2229 ep
->com
.cm_id
->tos
);
2231 pr_err("%s - cannot alloc l2e\n", __func__
);
2235 pr_debug("txq_idx %u tx_chan %u smac_idx %u rss_qid %u l2t_idx %u\n",
2236 ep
->txq_idx
, ep
->tx_chan
, ep
->smac_idx
, ep
->rss_qid
,
2239 state_set(&ep
->com
, CONNECTING
);
2240 ep
->tos
= ep
->com
.cm_id
->tos
;
2242 /* send connect request to rnic */
2243 err
= send_connect(ep
);
2247 cxgb4_l2t_release(ep
->l2t
);
2249 dst_release(ep
->dst
);
2251 xa_erase_irq(&ep
->com
.dev
->atids
, ep
->atid
);
2253 cxgb4_free_atid(ep
->com
.dev
->rdev
.lldi
.tids
, ep
->atid
);
2256 * remember to send notification to upper layer.
2257 * We are in here so the upper layer is not aware that this is
2258 * re-connect attempt and so, upper layer is still waiting for
2259 * response of 1st connect request.
2261 connect_reply_upcall(ep
, -ECONNRESET
);
2263 c4iw_put_ep(&ep
->com
);
2268 static int act_open_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2271 struct cpl_act_open_rpl
*rpl
= cplhdr(skb
);
2272 unsigned int atid
= TID_TID_G(AOPEN_ATID_G(
2273 ntohl(rpl
->atid_status
)));
2274 struct tid_info
*t
= dev
->rdev
.lldi
.tids
;
2275 int status
= AOPEN_STATUS_G(ntohl(rpl
->atid_status
));
2276 struct sockaddr_in
*la
;
2277 struct sockaddr_in
*ra
;
2278 struct sockaddr_in6
*la6
;
2279 struct sockaddr_in6
*ra6
;
2282 ep
= lookup_atid(t
, atid
);
2286 la
= (struct sockaddr_in
*)&ep
->com
.local_addr
;
2287 ra
= (struct sockaddr_in
*)&ep
->com
.remote_addr
;
2288 la6
= (struct sockaddr_in6
*)&ep
->com
.local_addr
;
2289 ra6
= (struct sockaddr_in6
*)&ep
->com
.remote_addr
;
2291 pr_debug("ep %p atid %u status %u errno %d\n", ep
, atid
,
2292 status
, status2errno(status
));
2294 if (cxgb_is_neg_adv(status
)) {
2295 pr_debug("Connection problems for atid %u status %u (%s)\n",
2296 atid
, status
, neg_adv_str(status
));
2297 ep
->stats
.connect_neg_adv
++;
2298 mutex_lock(&dev
->rdev
.stats
.lock
);
2299 dev
->rdev
.stats
.neg_adv
++;
2300 mutex_unlock(&dev
->rdev
.stats
.lock
);
2304 set_bit(ACT_OPEN_RPL
, &ep
->com
.history
);
2307 * Log interesting failures.
2310 case CPL_ERR_CONN_RESET
:
2311 case CPL_ERR_CONN_TIMEDOUT
:
2313 case CPL_ERR_TCAM_FULL
:
2314 mutex_lock(&dev
->rdev
.stats
.lock
);
2315 dev
->rdev
.stats
.tcam_full
++;
2316 mutex_unlock(&dev
->rdev
.stats
.lock
);
2317 if (ep
->com
.local_addr
.ss_family
== AF_INET
&&
2318 dev
->rdev
.lldi
.enable_fw_ofld_conn
) {
2319 ret
= send_fw_act_open_req(ep
, TID_TID_G(AOPEN_ATID_G(
2320 ntohl(rpl
->atid_status
))));
2326 case CPL_ERR_CONN_EXIST
:
2327 if (ep
->retry_count
++ < ACT_OPEN_RETRY_COUNT
) {
2328 set_bit(ACT_RETRY_INUSE
, &ep
->com
.history
);
2329 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
) {
2330 struct sockaddr_in6
*sin6
=
2331 (struct sockaddr_in6
*)
2332 &ep
->com
.local_addr
;
2334 ep
->com
.dev
->rdev
.lldi
.ports
[0],
2336 &sin6
->sin6_addr
.s6_addr
, 1);
2338 xa_erase_irq(&ep
->com
.dev
->atids
, atid
);
2339 cxgb4_free_atid(t
, atid
);
2340 dst_release(ep
->dst
);
2341 cxgb4_l2t_release(ep
->l2t
);
2347 if (ep
->com
.local_addr
.ss_family
== AF_INET
) {
2348 pr_info("Active open failure - atid %u status %u errno %d %pI4:%u->%pI4:%u\n",
2349 atid
, status
, status2errno(status
),
2350 &la
->sin_addr
.s_addr
, ntohs(la
->sin_port
),
2351 &ra
->sin_addr
.s_addr
, ntohs(ra
->sin_port
));
2353 pr_info("Active open failure - atid %u status %u errno %d %pI6:%u->%pI6:%u\n",
2354 atid
, status
, status2errno(status
),
2355 la6
->sin6_addr
.s6_addr
, ntohs(la6
->sin6_port
),
2356 ra6
->sin6_addr
.s6_addr
, ntohs(ra6
->sin6_port
));
2362 connect_reply_upcall(ep
, status2errno(status
));
2363 state_set(&ep
->com
, DEAD
);
2365 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
) {
2366 struct sockaddr_in6
*sin6
=
2367 (struct sockaddr_in6
*)&ep
->com
.local_addr
;
2368 cxgb4_clip_release(ep
->com
.dev
->rdev
.lldi
.ports
[0],
2369 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
2371 if (status
&& act_open_has_tid(status
))
2372 cxgb4_remove_tid(ep
->com
.dev
->rdev
.lldi
.tids
, 0, GET_TID(rpl
),
2373 ep
->com
.local_addr
.ss_family
);
2375 xa_erase_irq(&ep
->com
.dev
->atids
, atid
);
2376 cxgb4_free_atid(t
, atid
);
2377 dst_release(ep
->dst
);
2378 cxgb4_l2t_release(ep
->l2t
);
2379 c4iw_put_ep(&ep
->com
);
2384 static int pass_open_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2386 struct cpl_pass_open_rpl
*rpl
= cplhdr(skb
);
2387 unsigned int stid
= GET_TID(rpl
);
2388 struct c4iw_listen_ep
*ep
= get_ep_from_stid(dev
, stid
);
2391 pr_warn("%s stid %d lookup failure!\n", __func__
, stid
);
2394 pr_debug("ep %p status %d error %d\n", ep
,
2395 rpl
->status
, status2errno(rpl
->status
));
2396 c4iw_wake_up_noref(ep
->com
.wr_waitp
, status2errno(rpl
->status
));
2397 c4iw_put_ep(&ep
->com
);
2402 static int close_listsrv_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2404 struct cpl_close_listsvr_rpl
*rpl
= cplhdr(skb
);
2405 unsigned int stid
= GET_TID(rpl
);
2406 struct c4iw_listen_ep
*ep
= get_ep_from_stid(dev
, stid
);
2409 pr_warn("%s stid %d lookup failure!\n", __func__
, stid
);
2412 pr_debug("ep %p\n", ep
);
2413 c4iw_wake_up_noref(ep
->com
.wr_waitp
, status2errno(rpl
->status
));
2414 c4iw_put_ep(&ep
->com
);
2419 static int accept_cr(struct c4iw_ep
*ep
, struct sk_buff
*skb
,
2420 struct cpl_pass_accept_req
*req
)
2422 struct cpl_pass_accept_rpl
*rpl
;
2423 unsigned int mtu_idx
;
2427 struct cpl_t5_pass_accept_rpl
*rpl5
= NULL
;
2429 enum chip_type adapter_type
= ep
->com
.dev
->rdev
.lldi
.adapter_type
;
2431 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
2432 cxgb_best_mtu(ep
->com
.dev
->rdev
.lldi
.mtus
, ep
->mtu
, &mtu_idx
,
2433 enable_tcp_timestamps
&& req
->tcpopt
.tstamp
,
2434 (ep
->com
.remote_addr
.ss_family
== AF_INET
) ? 0 : 1);
2435 wscale
= cxgb_compute_wscale(rcv_win
);
2438 * Specify the largest window that will fit in opt0. The
2439 * remainder will be specified in the rx_data_ack.
2441 win
= ep
->rcv_win
>> 10;
2442 if (win
> RCV_BUFSIZ_M
)
2444 opt0
= (nocong
? NO_CONG_F
: 0) |
2447 WND_SCALE_V(wscale
) |
2448 MSS_IDX_V(mtu_idx
) |
2449 L2T_IDX_V(ep
->l2t
->idx
) |
2450 TX_CHAN_V(ep
->tx_chan
) |
2451 SMAC_SEL_V(ep
->smac_idx
) |
2452 DSCP_V(ep
->tos
>> 2) |
2453 ULP_MODE_V(ULP_MODE_TCPDDP
) |
2455 opt2
= RX_CHANNEL_V(0) |
2456 RSS_QUEUE_VALID_F
| RSS_QUEUE_V(ep
->rss_qid
);
2458 if (enable_tcp_timestamps
&& req
->tcpopt
.tstamp
)
2459 opt2
|= TSTAMPS_EN_F
;
2460 if (enable_tcp_sack
&& req
->tcpopt
.sack
)
2462 if (wscale
&& enable_tcp_window_scaling
)
2463 opt2
|= WND_SCALE_EN_F
;
2465 const struct tcphdr
*tcph
;
2466 u32 hlen
= ntohl(req
->hdr_len
);
2468 if (CHELSIO_CHIP_VERSION(adapter_type
) <= CHELSIO_T5
)
2469 tcph
= (const void *)(req
+ 1) + ETH_HDR_LEN_G(hlen
) +
2472 tcph
= (const void *)(req
+ 1) +
2473 T6_ETH_HDR_LEN_G(hlen
) + T6_IP_HDR_LEN_G(hlen
);
2474 if (tcph
->ece
&& tcph
->cwr
)
2475 opt2
|= CCTRL_ECN_V(1);
2478 if (!is_t4(adapter_type
)) {
2479 u32 isn
= (get_random_u32() & ~7UL) - 1;
2481 skb
= get_skb(skb
, roundup(sizeof(*rpl5
), 16), GFP_KERNEL
);
2482 rpl5
= __skb_put_zero(skb
, roundup(sizeof(*rpl5
), 16));
2484 INIT_TP_WR_CPL(rpl5
, CPL_PASS_ACCEPT_RPL
, ep
->hwtid
);
2485 opt2
|= T5_OPT_2_VALID_F
;
2486 opt2
|= CONG_CNTRL_V(CONG_ALG_TAHOE
);
2490 rpl5
->iss
= cpu_to_be32(isn
);
2491 pr_debug("iss %u\n", be32_to_cpu(rpl5
->iss
));
2493 skb
= get_skb(skb
, sizeof(*rpl
), GFP_KERNEL
);
2494 rpl
= __skb_put_zero(skb
, sizeof(*rpl
));
2495 INIT_TP_WR_CPL(rpl
, CPL_PASS_ACCEPT_RPL
, ep
->hwtid
);
2498 rpl
->opt0
= cpu_to_be64(opt0
);
2499 rpl
->opt2
= cpu_to_be32(opt2
);
2500 set_wr_txq(skb
, CPL_PRIORITY_SETUP
, ep
->ctrlq_idx
);
2501 t4_set_arp_err_handler(skb
, ep
, pass_accept_rpl_arp_failure
);
2503 return c4iw_l2t_send(&ep
->com
.dev
->rdev
, skb
, ep
->l2t
);
2506 static void reject_cr(struct c4iw_dev
*dev
, u32 hwtid
, struct sk_buff
*skb
)
2508 pr_debug("c4iw_dev %p tid %u\n", dev
, hwtid
);
2509 skb_trim(skb
, sizeof(struct cpl_tid_release
));
2510 release_tid(&dev
->rdev
, hwtid
, skb
);
2514 static int pass_accept_req(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2516 struct c4iw_ep
*child_ep
= NULL
, *parent_ep
;
2517 struct cpl_pass_accept_req
*req
= cplhdr(skb
);
2518 unsigned int stid
= PASS_OPEN_TID_G(ntohl(req
->tos_stid
));
2519 struct tid_info
*t
= dev
->rdev
.lldi
.tids
;
2520 unsigned int hwtid
= GET_TID(req
);
2521 struct dst_entry
*dst
;
2522 __u8 local_ip
[16], peer_ip
[16];
2523 __be16 local_port
, peer_port
;
2524 struct sockaddr_in6
*sin6
;
2526 u16 peer_mss
= ntohs(req
->tcpopt
.mss
);
2528 unsigned short hdrs
;
2531 parent_ep
= (struct c4iw_ep
*)get_ep_from_stid(dev
, stid
);
2533 pr_err("%s connect request on invalid stid %d\n",
2538 if (state_read(&parent_ep
->com
) != LISTEN
) {
2539 pr_err("%s - listening ep not in LISTEN\n", __func__
);
2543 if (parent_ep
->com
.cm_id
->tos_set
)
2544 tos
= parent_ep
->com
.cm_id
->tos
;
2546 tos
= PASS_OPEN_TOS_G(ntohl(req
->tos_stid
));
2548 cxgb_get_4tuple(req
, parent_ep
->com
.dev
->rdev
.lldi
.adapter_type
,
2549 &iptype
, local_ip
, peer_ip
, &local_port
, &peer_port
);
2551 /* Find output route */
2553 pr_debug("parent ep %p hwtid %u laddr %pI4 raddr %pI4 lport %d rport %d peer_mss %d\n"
2555 local_ip
, peer_ip
, ntohs(local_port
),
2556 ntohs(peer_port
), peer_mss
);
2557 dst
= cxgb_find_route(&dev
->rdev
.lldi
, get_real_dev
,
2558 *(__be32
*)local_ip
, *(__be32
*)peer_ip
,
2559 local_port
, peer_port
, tos
);
2561 pr_debug("parent ep %p hwtid %u laddr %pI6 raddr %pI6 lport %d rport %d peer_mss %d\n"
2563 local_ip
, peer_ip
, ntohs(local_port
),
2564 ntohs(peer_port
), peer_mss
);
2565 dst
= cxgb_find_route6(&dev
->rdev
.lldi
, get_real_dev
,
2566 local_ip
, peer_ip
, local_port
, peer_port
,
2568 ((struct sockaddr_in6
*)
2569 &parent_ep
->com
.local_addr
)->sin6_scope_id
);
2572 pr_err("%s - failed to find dst entry!\n", __func__
);
2576 child_ep
= alloc_ep(sizeof(*child_ep
), GFP_KERNEL
);
2578 pr_err("%s - failed to allocate ep entry!\n", __func__
);
2583 err
= import_ep(child_ep
, iptype
, peer_ip
, dst
, dev
, false,
2584 parent_ep
->com
.dev
->rdev
.lldi
.adapter_type
, tos
);
2586 pr_err("%s - failed to allocate l2t entry!\n", __func__
);
2592 hdrs
= ((iptype
== 4) ? sizeof(struct iphdr
) : sizeof(struct ipv6hdr
)) +
2593 sizeof(struct tcphdr
) +
2594 ((enable_tcp_timestamps
&& req
->tcpopt
.tstamp
) ? 12 : 0);
2595 if (peer_mss
&& child_ep
->mtu
> (peer_mss
+ hdrs
))
2596 child_ep
->mtu
= peer_mss
+ hdrs
;
2598 skb_queue_head_init(&child_ep
->com
.ep_skb_list
);
2599 if (alloc_ep_skb_list(&child_ep
->com
.ep_skb_list
, CN_MAX_CON_BUF
))
2602 state_set(&child_ep
->com
, CONNECTING
);
2603 child_ep
->com
.dev
= dev
;
2604 child_ep
->com
.cm_id
= NULL
;
2607 struct sockaddr_in
*sin
= (struct sockaddr_in
*)
2608 &child_ep
->com
.local_addr
;
2610 sin
->sin_family
= AF_INET
;
2611 sin
->sin_port
= local_port
;
2612 sin
->sin_addr
.s_addr
= *(__be32
*)local_ip
;
2614 sin
= (struct sockaddr_in
*)&child_ep
->com
.local_addr
;
2615 sin
->sin_family
= AF_INET
;
2616 sin
->sin_port
= ((struct sockaddr_in
*)
2617 &parent_ep
->com
.local_addr
)->sin_port
;
2618 sin
->sin_addr
.s_addr
= *(__be32
*)local_ip
;
2620 sin
= (struct sockaddr_in
*)&child_ep
->com
.remote_addr
;
2621 sin
->sin_family
= AF_INET
;
2622 sin
->sin_port
= peer_port
;
2623 sin
->sin_addr
.s_addr
= *(__be32
*)peer_ip
;
2625 sin6
= (struct sockaddr_in6
*)&child_ep
->com
.local_addr
;
2626 sin6
->sin6_family
= PF_INET6
;
2627 sin6
->sin6_port
= local_port
;
2628 memcpy(sin6
->sin6_addr
.s6_addr
, local_ip
, 16);
2630 sin6
= (struct sockaddr_in6
*)&child_ep
->com
.local_addr
;
2631 sin6
->sin6_family
= PF_INET6
;
2632 sin6
->sin6_port
= ((struct sockaddr_in6
*)
2633 &parent_ep
->com
.local_addr
)->sin6_port
;
2634 memcpy(sin6
->sin6_addr
.s6_addr
, local_ip
, 16);
2636 sin6
= (struct sockaddr_in6
*)&child_ep
->com
.remote_addr
;
2637 sin6
->sin6_family
= PF_INET6
;
2638 sin6
->sin6_port
= peer_port
;
2639 memcpy(sin6
->sin6_addr
.s6_addr
, peer_ip
, 16);
2642 c4iw_get_ep(&parent_ep
->com
);
2643 child_ep
->parent_ep
= parent_ep
;
2644 child_ep
->tos
= tos
;
2645 child_ep
->dst
= dst
;
2646 child_ep
->hwtid
= hwtid
;
2648 pr_debug("tx_chan %u smac_idx %u rss_qid %u\n",
2649 child_ep
->tx_chan
, child_ep
->smac_idx
, child_ep
->rss_qid
);
2651 timer_setup(&child_ep
->timer
, ep_timeout
, 0);
2652 cxgb4_insert_tid(t
, child_ep
, hwtid
,
2653 child_ep
->com
.local_addr
.ss_family
);
2654 insert_ep_tid(child_ep
);
2655 if (accept_cr(child_ep
, skb
, req
)) {
2656 c4iw_put_ep(&parent_ep
->com
);
2657 release_ep_resources(child_ep
);
2659 set_bit(PASS_ACCEPT_REQ
, &child_ep
->com
.history
);
2662 sin6
= (struct sockaddr_in6
*)&child_ep
->com
.local_addr
;
2663 cxgb4_clip_get(child_ep
->com
.dev
->rdev
.lldi
.ports
[0],
2664 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
2668 c4iw_put_ep(&child_ep
->com
);
2670 reject_cr(dev
, hwtid
, skb
);
2673 c4iw_put_ep(&parent_ep
->com
);
2677 static int pass_establish(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2680 struct cpl_pass_establish
*req
= cplhdr(skb
);
2681 unsigned int tid
= GET_TID(req
);
2683 u16 tcp_opt
= ntohs(req
->tcp_opt
);
2685 ep
= get_ep_from_tid(dev
, tid
);
2689 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
2690 ep
->snd_seq
= be32_to_cpu(req
->snd_isn
);
2691 ep
->rcv_seq
= be32_to_cpu(req
->rcv_isn
);
2692 ep
->snd_wscale
= TCPOPT_SND_WSCALE_G(tcp_opt
);
2694 pr_debug("ep %p hwtid %u tcp_opt 0x%02x\n", ep
, tid
, tcp_opt
);
2696 set_emss(ep
, tcp_opt
);
2698 dst_confirm(ep
->dst
);
2699 mutex_lock(&ep
->com
.mutex
);
2700 ep
->com
.state
= MPA_REQ_WAIT
;
2702 set_bit(PASS_ESTAB
, &ep
->com
.history
);
2703 ret
= send_flowc(ep
);
2704 mutex_unlock(&ep
->com
.mutex
);
2706 c4iw_ep_disconnect(ep
, 1, GFP_KERNEL
);
2707 c4iw_put_ep(&ep
->com
);
2712 static int peer_close(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2714 struct cpl_peer_close
*hdr
= cplhdr(skb
);
2716 struct c4iw_qp_attributes attrs
;
2719 unsigned int tid
= GET_TID(hdr
);
2722 ep
= get_ep_from_tid(dev
, tid
);
2726 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
2727 dst_confirm(ep
->dst
);
2729 set_bit(PEER_CLOSE
, &ep
->com
.history
);
2730 mutex_lock(&ep
->com
.mutex
);
2731 switch (ep
->com
.state
) {
2733 __state_set(&ep
->com
, CLOSING
);
2736 __state_set(&ep
->com
, CLOSING
);
2737 connect_reply_upcall(ep
, -ECONNRESET
);
2742 * We're gonna mark this puppy DEAD, but keep
2743 * the reference on it until the ULP accepts or
2744 * rejects the CR. Also wake up anyone waiting
2745 * in rdma connection migration (see c4iw_accept_cr()).
2747 __state_set(&ep
->com
, CLOSING
);
2748 pr_debug("waking up ep %p tid %u\n", ep
, ep
->hwtid
);
2749 c4iw_wake_up_noref(ep
->com
.wr_waitp
, -ECONNRESET
);
2752 __state_set(&ep
->com
, CLOSING
);
2753 pr_debug("waking up ep %p tid %u\n", ep
, ep
->hwtid
);
2754 c4iw_wake_up_noref(ep
->com
.wr_waitp
, -ECONNRESET
);
2758 __state_set(&ep
->com
, CLOSING
);
2759 attrs
.next_state
= C4IW_QP_STATE_CLOSING
;
2760 ret
= c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
2761 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
2762 if (ret
!= -ECONNRESET
) {
2763 peer_close_upcall(ep
);
2771 __state_set(&ep
->com
, MORIBUND
);
2775 (void)stop_ep_timer(ep
);
2776 if (ep
->com
.cm_id
&& ep
->com
.qp
) {
2777 attrs
.next_state
= C4IW_QP_STATE_IDLE
;
2778 c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
2779 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
2781 close_complete_upcall(ep
, 0);
2782 __state_set(&ep
->com
, DEAD
);
2790 WARN_ONCE(1, "Bad endpoint state %u\n", ep
->com
.state
);
2792 mutex_unlock(&ep
->com
.mutex
);
2794 c4iw_ep_disconnect(ep
, 0, GFP_KERNEL
);
2796 release_ep_resources(ep
);
2797 c4iw_put_ep(&ep
->com
);
2801 static void finish_peer_abort(struct c4iw_dev
*dev
, struct c4iw_ep
*ep
)
2803 complete_cached_srq_buffers(ep
, ep
->srqe_idx
);
2804 if (ep
->com
.cm_id
&& ep
->com
.qp
) {
2805 struct c4iw_qp_attributes attrs
;
2807 attrs
.next_state
= C4IW_QP_STATE_ERROR
;
2808 c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
2809 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
2811 peer_abort_upcall(ep
);
2812 release_ep_resources(ep
);
2813 c4iw_put_ep(&ep
->com
);
2816 static int peer_abort(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2818 struct cpl_abort_req_rss6
*req
= cplhdr(skb
);
2820 struct sk_buff
*rpl_skb
;
2821 struct c4iw_qp_attributes attrs
;
2824 unsigned int tid
= GET_TID(req
);
2828 u32 len
= roundup(sizeof(struct cpl_abort_rpl
), 16);
2830 ep
= get_ep_from_tid(dev
, tid
);
2834 status
= ABORT_RSS_STATUS_G(be32_to_cpu(req
->srqidx_status
));
2836 if (cxgb_is_neg_adv(status
)) {
2837 pr_debug("Negative advice on abort- tid %u status %d (%s)\n",
2838 ep
->hwtid
, status
, neg_adv_str(status
));
2839 ep
->stats
.abort_neg_adv
++;
2840 mutex_lock(&dev
->rdev
.stats
.lock
);
2841 dev
->rdev
.stats
.neg_adv
++;
2842 mutex_unlock(&dev
->rdev
.stats
.lock
);
2846 pr_debug("ep %p tid %u state %u\n", ep
, ep
->hwtid
,
2848 set_bit(PEER_ABORT
, &ep
->com
.history
);
2851 * Wake up any threads in rdma_init() or rdma_fini().
2852 * However, this is not needed if com state is just
2855 if (ep
->com
.state
!= MPA_REQ_SENT
)
2856 c4iw_wake_up_noref(ep
->com
.wr_waitp
, -ECONNRESET
);
2858 mutex_lock(&ep
->com
.mutex
);
2859 switch (ep
->com
.state
) {
2861 c4iw_put_ep(&ep
->parent_ep
->com
);
2864 (void)stop_ep_timer(ep
);
2867 (void)stop_ep_timer(ep
);
2868 if (status
!= CPL_ERR_CONN_RESET
|| mpa_rev
== 1 ||
2869 (mpa_rev
== 2 && ep
->tried_with_mpa_v1
))
2870 connect_reply_upcall(ep
, -ECONNRESET
);
2873 * we just don't send notification upwards because we
2874 * want to retry with mpa_v1 without upper layers even
2877 * do some housekeeping so as to re-initiate the
2880 pr_info("%s: mpa_rev=%d. Retrying with mpav1\n",
2882 ep
->retry_with_mpa_v1
= 1;
2894 if (ep
->com
.qp
&& ep
->com
.qp
->srq
) {
2895 srqidx
= ABORT_RSS_SRQIDX_G(
2896 be32_to_cpu(req
->srqidx_status
));
2898 complete_cached_srq_buffers(ep
, srqidx
);
2900 /* Hold ep ref until finish_peer_abort() */
2901 c4iw_get_ep(&ep
->com
);
2902 __state_set(&ep
->com
, ABORTING
);
2903 set_bit(PEER_ABORT_IN_PROGRESS
, &ep
->com
.flags
);
2910 if (ep
->com
.cm_id
&& ep
->com
.qp
) {
2911 attrs
.next_state
= C4IW_QP_STATE_ERROR
;
2912 ret
= c4iw_modify_qp(ep
->com
.qp
->rhp
,
2913 ep
->com
.qp
, C4IW_QP_ATTR_NEXT_STATE
,
2916 pr_err("%s - qp <- error failed!\n", __func__
);
2918 peer_abort_upcall(ep
);
2923 pr_warn("%s PEER_ABORT IN DEAD STATE!!!!\n", __func__
);
2924 mutex_unlock(&ep
->com
.mutex
);
2927 WARN_ONCE(1, "Bad endpoint state %u\n", ep
->com
.state
);
2930 dst_confirm(ep
->dst
);
2931 if (ep
->com
.state
!= ABORTING
) {
2932 __state_set(&ep
->com
, DEAD
);
2933 /* we don't release if we want to retry with mpa_v1 */
2934 if (!ep
->retry_with_mpa_v1
)
2937 mutex_unlock(&ep
->com
.mutex
);
2939 rpl_skb
= skb_dequeue(&ep
->com
.ep_skb_list
);
2940 if (WARN_ON(!rpl_skb
)) {
2945 cxgb_mk_abort_rpl(rpl_skb
, len
, ep
->hwtid
, ep
->txq_idx
);
2947 c4iw_ofld_send(&ep
->com
.dev
->rdev
, rpl_skb
);
2950 release_ep_resources(ep
);
2951 else if (ep
->retry_with_mpa_v1
) {
2952 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
) {
2953 struct sockaddr_in6
*sin6
=
2954 (struct sockaddr_in6
*)
2955 &ep
->com
.local_addr
;
2957 ep
->com
.dev
->rdev
.lldi
.ports
[0],
2958 (const u32
*)&sin6
->sin6_addr
.s6_addr
,
2961 xa_erase_irq(&ep
->com
.dev
->hwtids
, ep
->hwtid
);
2962 cxgb4_remove_tid(ep
->com
.dev
->rdev
.lldi
.tids
, 0, ep
->hwtid
,
2963 ep
->com
.local_addr
.ss_family
);
2964 dst_release(ep
->dst
);
2965 cxgb4_l2t_release(ep
->l2t
);
2970 c4iw_put_ep(&ep
->com
);
2971 /* Dereferencing ep, referenced in peer_abort_intr() */
2972 c4iw_put_ep(&ep
->com
);
2976 static int close_con_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
2979 struct c4iw_qp_attributes attrs
;
2980 struct cpl_close_con_rpl
*rpl
= cplhdr(skb
);
2982 unsigned int tid
= GET_TID(rpl
);
2984 ep
= get_ep_from_tid(dev
, tid
);
2988 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
2990 /* The cm_id may be null if we failed to connect */
2991 mutex_lock(&ep
->com
.mutex
);
2992 set_bit(CLOSE_CON_RPL
, &ep
->com
.history
);
2993 switch (ep
->com
.state
) {
2995 __state_set(&ep
->com
, MORIBUND
);
2998 (void)stop_ep_timer(ep
);
2999 if ((ep
->com
.cm_id
) && (ep
->com
.qp
)) {
3000 attrs
.next_state
= C4IW_QP_STATE_IDLE
;
3001 c4iw_modify_qp(ep
->com
.qp
->rhp
,
3003 C4IW_QP_ATTR_NEXT_STATE
,
3006 close_complete_upcall(ep
, 0);
3007 __state_set(&ep
->com
, DEAD
);
3014 WARN_ONCE(1, "Bad endpoint state %u\n", ep
->com
.state
);
3017 mutex_unlock(&ep
->com
.mutex
);
3019 release_ep_resources(ep
);
3020 c4iw_put_ep(&ep
->com
);
3024 static int terminate(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
3026 struct cpl_rdma_terminate
*rpl
= cplhdr(skb
);
3027 unsigned int tid
= GET_TID(rpl
);
3029 struct c4iw_qp_attributes attrs
;
3031 ep
= get_ep_from_tid(dev
, tid
);
3035 pr_warn("TERM received tid %u qpid %u\n", tid
,
3036 ep
->com
.qp
->wq
.sq
.qid
);
3037 attrs
.next_state
= C4IW_QP_STATE_TERMINATE
;
3038 c4iw_modify_qp(ep
->com
.qp
->rhp
, ep
->com
.qp
,
3039 C4IW_QP_ATTR_NEXT_STATE
, &attrs
, 1);
3042 /* As per draft-hilland-iwarp-verbs-v1.0, sec 6.2.3,
3043 * when entering the TERM state the RNIC MUST initiate a CLOSE.
3045 c4iw_ep_disconnect(ep
, 1, GFP_KERNEL
);
3046 c4iw_put_ep(&ep
->com
);
3048 pr_warn("TERM received tid %u no ep/qp\n", tid
);
3054 * Upcall from the adapter indicating data has been transmitted.
3055 * For us its just the single MPA request or reply. We can now free
3056 * the skb holding the mpa message.
3058 static int fw4_ack(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
3061 struct cpl_fw4_ack
*hdr
= cplhdr(skb
);
3062 u8 credits
= hdr
->credits
;
3063 unsigned int tid
= GET_TID(hdr
);
3066 ep
= get_ep_from_tid(dev
, tid
);
3069 pr_debug("ep %p tid %u credits %u\n",
3070 ep
, ep
->hwtid
, credits
);
3072 pr_debug("0 credit ack ep %p tid %u state %u\n",
3073 ep
, ep
->hwtid
, state_read(&ep
->com
));
3077 dst_confirm(ep
->dst
);
3079 pr_debug("last streaming msg ack ep %p tid %u state %u initiator %u freeing skb\n",
3080 ep
, ep
->hwtid
, state_read(&ep
->com
),
3081 ep
->mpa_attr
.initiator
? 1 : 0);
3082 mutex_lock(&ep
->com
.mutex
);
3083 kfree_skb(ep
->mpa_skb
);
3085 if (test_bit(STOP_MPA_TIMER
, &ep
->com
.flags
))
3087 mutex_unlock(&ep
->com
.mutex
);
3090 c4iw_put_ep(&ep
->com
);
3094 int c4iw_reject_cr(struct iw_cm_id
*cm_id
, const void *pdata
, u8 pdata_len
)
3097 struct c4iw_ep
*ep
= to_ep(cm_id
);
3099 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
3101 mutex_lock(&ep
->com
.mutex
);
3102 if (ep
->com
.state
!= MPA_REQ_RCVD
) {
3103 mutex_unlock(&ep
->com
.mutex
);
3104 c4iw_put_ep(&ep
->com
);
3107 set_bit(ULP_REJECT
, &ep
->com
.history
);
3111 abort
= send_mpa_reject(ep
, pdata
, pdata_len
);
3112 mutex_unlock(&ep
->com
.mutex
);
3115 c4iw_ep_disconnect(ep
, abort
!= 0, GFP_KERNEL
);
3116 c4iw_put_ep(&ep
->com
);
3120 int c4iw_accept_cr(struct iw_cm_id
*cm_id
, struct iw_cm_conn_param
*conn_param
)
3123 struct c4iw_qp_attributes attrs
;
3124 enum c4iw_qp_attr_mask mask
;
3125 struct c4iw_ep
*ep
= to_ep(cm_id
);
3126 struct c4iw_dev
*h
= to_c4iw_dev(cm_id
->device
);
3127 struct c4iw_qp
*qp
= get_qhp(h
, conn_param
->qpn
);
3130 pr_debug("ep %p tid %u\n", ep
, ep
->hwtid
);
3132 mutex_lock(&ep
->com
.mutex
);
3133 if (ep
->com
.state
!= MPA_REQ_RCVD
) {
3143 set_bit(ULP_ACCEPT
, &ep
->com
.history
);
3144 if ((conn_param
->ord
> cur_max_read_depth(ep
->com
.dev
)) ||
3145 (conn_param
->ird
> cur_max_read_depth(ep
->com
.dev
))) {
3150 if (ep
->mpa_attr
.version
== 2 && ep
->mpa_attr
.enhanced_rdma_conn
) {
3151 if (conn_param
->ord
> ep
->ird
) {
3152 if (RELAXED_IRD_NEGOTIATION
) {
3153 conn_param
->ord
= ep
->ird
;
3155 ep
->ird
= conn_param
->ird
;
3156 ep
->ord
= conn_param
->ord
;
3157 send_mpa_reject(ep
, conn_param
->private_data
,
3158 conn_param
->private_data_len
);
3163 if (conn_param
->ird
< ep
->ord
) {
3164 if (RELAXED_IRD_NEGOTIATION
&&
3165 ep
->ord
<= h
->rdev
.lldi
.max_ordird_qp
) {
3166 conn_param
->ird
= ep
->ord
;
3173 ep
->ird
= conn_param
->ird
;
3174 ep
->ord
= conn_param
->ord
;
3176 if (ep
->mpa_attr
.version
== 1) {
3177 if (peer2peer
&& ep
->ird
== 0)
3181 (ep
->mpa_attr
.p2p_type
!= FW_RI_INIT_P2PTYPE_DISABLED
) &&
3182 (p2p_type
== FW_RI_INIT_P2PTYPE_READ_REQ
) && ep
->ird
== 0)
3186 pr_debug("ird %d ord %d\n", ep
->ird
, ep
->ord
);
3188 ep
->com
.cm_id
= cm_id
;
3189 ref_cm_id(&ep
->com
);
3193 /* bind QP to EP and move to RTS */
3194 attrs
.mpa_attr
= ep
->mpa_attr
;
3195 attrs
.max_ird
= ep
->ird
;
3196 attrs
.max_ord
= ep
->ord
;
3197 attrs
.llp_stream_handle
= ep
;
3198 attrs
.next_state
= C4IW_QP_STATE_RTS
;
3200 /* bind QP and TID with INIT_WR */
3201 mask
= C4IW_QP_ATTR_NEXT_STATE
|
3202 C4IW_QP_ATTR_LLP_STREAM_HANDLE
|
3203 C4IW_QP_ATTR_MPA_ATTR
|
3204 C4IW_QP_ATTR_MAX_IRD
|
3205 C4IW_QP_ATTR_MAX_ORD
;
3207 err
= c4iw_modify_qp(ep
->com
.qp
->rhp
,
3208 ep
->com
.qp
, mask
, &attrs
, 1);
3210 goto err_deref_cm_id
;
3212 set_bit(STOP_MPA_TIMER
, &ep
->com
.flags
);
3213 err
= send_mpa_reply(ep
, conn_param
->private_data
,
3214 conn_param
->private_data_len
);
3216 goto err_deref_cm_id
;
3218 __state_set(&ep
->com
, FPDU_MODE
);
3219 established_upcall(ep
);
3220 mutex_unlock(&ep
->com
.mutex
);
3221 c4iw_put_ep(&ep
->com
);
3224 deref_cm_id(&ep
->com
);
3228 mutex_unlock(&ep
->com
.mutex
);
3230 c4iw_ep_disconnect(ep
, 1, GFP_KERNEL
);
3231 c4iw_put_ep(&ep
->com
);
3235 static int pick_local_ipaddrs(struct c4iw_dev
*dev
, struct iw_cm_id
*cm_id
)
3237 struct in_device
*ind
;
3239 struct sockaddr_in
*laddr
= (struct sockaddr_in
*)&cm_id
->m_local_addr
;
3240 struct sockaddr_in
*raddr
= (struct sockaddr_in
*)&cm_id
->m_remote_addr
;
3241 const struct in_ifaddr
*ifa
;
3243 ind
= in_dev_get(dev
->rdev
.lldi
.ports
[0]);
3245 return -EADDRNOTAVAIL
;
3247 in_dev_for_each_ifa_rcu(ifa
, ind
) {
3248 if (ifa
->ifa_flags
& IFA_F_SECONDARY
)
3250 laddr
->sin_addr
.s_addr
= ifa
->ifa_address
;
3251 raddr
->sin_addr
.s_addr
= ifa
->ifa_address
;
3258 return found
? 0 : -EADDRNOTAVAIL
;
3261 static int get_lladdr(struct net_device
*dev
, struct in6_addr
*addr
,
3262 unsigned char banned_flags
)
3264 struct inet6_dev
*idev
;
3265 int err
= -EADDRNOTAVAIL
;
3268 idev
= __in6_dev_get(dev
);
3270 struct inet6_ifaddr
*ifp
;
3272 read_lock_bh(&idev
->lock
);
3273 list_for_each_entry(ifp
, &idev
->addr_list
, if_list
) {
3274 if (ifp
->scope
== IFA_LINK
&&
3275 !(ifp
->flags
& banned_flags
)) {
3276 memcpy(addr
, &ifp
->addr
, 16);
3281 read_unlock_bh(&idev
->lock
);
3287 static int pick_local_ip6addrs(struct c4iw_dev
*dev
, struct iw_cm_id
*cm_id
)
3289 struct in6_addr addr
;
3290 struct sockaddr_in6
*la6
= (struct sockaddr_in6
*)&cm_id
->m_local_addr
;
3291 struct sockaddr_in6
*ra6
= (struct sockaddr_in6
*)&cm_id
->m_remote_addr
;
3293 if (!get_lladdr(dev
->rdev
.lldi
.ports
[0], &addr
, IFA_F_TENTATIVE
)) {
3294 memcpy(la6
->sin6_addr
.s6_addr
, &addr
, 16);
3295 memcpy(ra6
->sin6_addr
.s6_addr
, &addr
, 16);
3298 return -EADDRNOTAVAIL
;
3301 int c4iw_connect(struct iw_cm_id
*cm_id
, struct iw_cm_conn_param
*conn_param
)
3303 struct c4iw_dev
*dev
= to_c4iw_dev(cm_id
->device
);
3306 struct sockaddr_in
*laddr
;
3307 struct sockaddr_in
*raddr
;
3308 struct sockaddr_in6
*laddr6
;
3309 struct sockaddr_in6
*raddr6
;
3313 if ((conn_param
->ord
> cur_max_read_depth(dev
)) ||
3314 (conn_param
->ird
> cur_max_read_depth(dev
))) {
3318 ep
= alloc_ep(sizeof(*ep
), GFP_KERNEL
);
3320 pr_err("%s - cannot alloc ep\n", __func__
);
3325 skb_queue_head_init(&ep
->com
.ep_skb_list
);
3326 if (alloc_ep_skb_list(&ep
->com
.ep_skb_list
, CN_MAX_CON_BUF
)) {
3331 timer_setup(&ep
->timer
, ep_timeout
, 0);
3332 ep
->plen
= conn_param
->private_data_len
;
3334 memcpy(ep
->mpa_pkt
+ sizeof(struct mpa_message
),
3335 conn_param
->private_data
, ep
->plen
);
3336 ep
->ird
= conn_param
->ird
;
3337 ep
->ord
= conn_param
->ord
;
3339 if (peer2peer
&& ep
->ord
== 0)
3342 ep
->com
.cm_id
= cm_id
;
3343 ref_cm_id(&ep
->com
);
3344 cm_id
->provider_data
= ep
;
3346 ep
->com
.qp
= get_qhp(dev
, conn_param
->qpn
);
3348 pr_warn("%s qpn 0x%x not found!\n", __func__
, conn_param
->qpn
);
3353 pr_debug("qpn 0x%x qp %p cm_id %p\n", conn_param
->qpn
,
3357 * Allocate an active TID to initiate a TCP connection.
3359 ep
->atid
= cxgb4_alloc_atid(dev
->rdev
.lldi
.tids
, ep
);
3360 if (ep
->atid
== -1) {
3361 pr_err("%s - cannot alloc atid\n", __func__
);
3365 err
= xa_insert_irq(&dev
->atids
, ep
->atid
, ep
, GFP_KERNEL
);
3369 memcpy(&ep
->com
.local_addr
, &cm_id
->m_local_addr
,
3370 sizeof(ep
->com
.local_addr
));
3371 memcpy(&ep
->com
.remote_addr
, &cm_id
->m_remote_addr
,
3372 sizeof(ep
->com
.remote_addr
));
3374 laddr
= (struct sockaddr_in
*)&ep
->com
.local_addr
;
3375 raddr
= (struct sockaddr_in
*)&ep
->com
.remote_addr
;
3376 laddr6
= (struct sockaddr_in6
*)&ep
->com
.local_addr
;
3377 raddr6
= (struct sockaddr_in6
*) &ep
->com
.remote_addr
;
3379 if (cm_id
->m_remote_addr
.ss_family
== AF_INET
) {
3381 ra
= (__u8
*)&raddr
->sin_addr
;
3384 * Handle loopback requests to INADDR_ANY.
3386 if (raddr
->sin_addr
.s_addr
== htonl(INADDR_ANY
)) {
3387 err
= pick_local_ipaddrs(dev
, cm_id
);
3393 pr_debug("saddr %pI4 sport 0x%x raddr %pI4 rport 0x%x\n",
3394 &laddr
->sin_addr
, ntohs(laddr
->sin_port
),
3395 ra
, ntohs(raddr
->sin_port
));
3396 ep
->dst
= cxgb_find_route(&dev
->rdev
.lldi
, get_real_dev
,
3397 laddr
->sin_addr
.s_addr
,
3398 raddr
->sin_addr
.s_addr
,
3400 raddr
->sin_port
, cm_id
->tos
);
3403 ra
= (__u8
*)&raddr6
->sin6_addr
;
3406 * Handle loopback requests to INADDR_ANY.
3408 if (ipv6_addr_type(&raddr6
->sin6_addr
) == IPV6_ADDR_ANY
) {
3409 err
= pick_local_ip6addrs(dev
, cm_id
);
3415 pr_debug("saddr %pI6 sport 0x%x raddr %pI6 rport 0x%x\n",
3416 laddr6
->sin6_addr
.s6_addr
,
3417 ntohs(laddr6
->sin6_port
),
3418 raddr6
->sin6_addr
.s6_addr
, ntohs(raddr6
->sin6_port
));
3419 ep
->dst
= cxgb_find_route6(&dev
->rdev
.lldi
, get_real_dev
,
3420 laddr6
->sin6_addr
.s6_addr
,
3421 raddr6
->sin6_addr
.s6_addr
,
3423 raddr6
->sin6_port
, cm_id
->tos
,
3424 raddr6
->sin6_scope_id
);
3427 pr_err("%s - cannot find route\n", __func__
);
3428 err
= -EHOSTUNREACH
;
3432 err
= import_ep(ep
, iptype
, ra
, ep
->dst
, ep
->com
.dev
, true,
3433 ep
->com
.dev
->rdev
.lldi
.adapter_type
, cm_id
->tos
);
3435 pr_err("%s - cannot alloc l2e\n", __func__
);
3439 pr_debug("txq_idx %u tx_chan %u smac_idx %u rss_qid %u l2t_idx %u\n",
3440 ep
->txq_idx
, ep
->tx_chan
, ep
->smac_idx
, ep
->rss_qid
,
3443 state_set(&ep
->com
, CONNECTING
);
3444 ep
->tos
= cm_id
->tos
;
3446 /* send connect request to rnic */
3447 err
= send_connect(ep
);
3451 cxgb4_l2t_release(ep
->l2t
);
3453 dst_release(ep
->dst
);
3455 xa_erase_irq(&ep
->com
.dev
->atids
, ep
->atid
);
3457 cxgb4_free_atid(ep
->com
.dev
->rdev
.lldi
.tids
, ep
->atid
);
3459 skb_queue_purge(&ep
->com
.ep_skb_list
);
3460 deref_cm_id(&ep
->com
);
3462 c4iw_put_ep(&ep
->com
);
3467 static int create_server6(struct c4iw_dev
*dev
, struct c4iw_listen_ep
*ep
)
3470 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)
3471 &ep
->com
.local_addr
;
3473 if (ipv6_addr_type(&sin6
->sin6_addr
) != IPV6_ADDR_ANY
) {
3474 err
= cxgb4_clip_get(ep
->com
.dev
->rdev
.lldi
.ports
[0],
3475 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
3479 c4iw_init_wr_wait(ep
->com
.wr_waitp
);
3480 err
= cxgb4_create_server6(ep
->com
.dev
->rdev
.lldi
.ports
[0],
3481 ep
->stid
, &sin6
->sin6_addr
,
3483 ep
->com
.dev
->rdev
.lldi
.rxq_ids
[0]);
3485 err
= c4iw_wait_for_reply(&ep
->com
.dev
->rdev
,
3489 err
= net_xmit_errno(err
);
3491 cxgb4_clip_release(ep
->com
.dev
->rdev
.lldi
.ports
[0],
3492 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
3493 pr_err("cxgb4_create_server6/filter failed err %d stid %d laddr %pI6 lport %d\n",
3495 sin6
->sin6_addr
.s6_addr
, ntohs(sin6
->sin6_port
));
3500 static int create_server4(struct c4iw_dev
*dev
, struct c4iw_listen_ep
*ep
)
3503 struct sockaddr_in
*sin
= (struct sockaddr_in
*)
3504 &ep
->com
.local_addr
;
3506 if (dev
->rdev
.lldi
.enable_fw_ofld_conn
) {
3508 err
= cxgb4_create_server_filter(
3509 ep
->com
.dev
->rdev
.lldi
.ports
[0], ep
->stid
,
3510 sin
->sin_addr
.s_addr
, sin
->sin_port
, 0,
3511 ep
->com
.dev
->rdev
.lldi
.rxq_ids
[0], 0, 0);
3512 if (err
== -EBUSY
) {
3513 if (c4iw_fatal_error(&ep
->com
.dev
->rdev
)) {
3517 set_current_state(TASK_UNINTERRUPTIBLE
);
3518 schedule_timeout(usecs_to_jiffies(100));
3520 } while (err
== -EBUSY
);
3522 c4iw_init_wr_wait(ep
->com
.wr_waitp
);
3523 err
= cxgb4_create_server(ep
->com
.dev
->rdev
.lldi
.ports
[0],
3524 ep
->stid
, sin
->sin_addr
.s_addr
, sin
->sin_port
,
3525 0, ep
->com
.dev
->rdev
.lldi
.rxq_ids
[0]);
3527 err
= c4iw_wait_for_reply(&ep
->com
.dev
->rdev
,
3531 err
= net_xmit_errno(err
);
3534 pr_err("cxgb4_create_server/filter failed err %d stid %d laddr %pI4 lport %d\n"
3536 &sin
->sin_addr
, ntohs(sin
->sin_port
));
3540 int c4iw_create_listen(struct iw_cm_id
*cm_id
, int backlog
)
3543 struct c4iw_dev
*dev
= to_c4iw_dev(cm_id
->device
);
3544 struct c4iw_listen_ep
*ep
;
3548 ep
= alloc_ep(sizeof(*ep
), GFP_KERNEL
);
3550 pr_err("%s - cannot alloc ep\n", __func__
);
3554 skb_queue_head_init(&ep
->com
.ep_skb_list
);
3555 pr_debug("ep %p\n", ep
);
3556 ep
->com
.cm_id
= cm_id
;
3557 ref_cm_id(&ep
->com
);
3559 ep
->backlog
= backlog
;
3560 memcpy(&ep
->com
.local_addr
, &cm_id
->m_local_addr
,
3561 sizeof(ep
->com
.local_addr
));
3564 * Allocate a server TID.
3566 if (dev
->rdev
.lldi
.enable_fw_ofld_conn
&&
3567 ep
->com
.local_addr
.ss_family
== AF_INET
)
3568 ep
->stid
= cxgb4_alloc_sftid(dev
->rdev
.lldi
.tids
,
3569 cm_id
->m_local_addr
.ss_family
, ep
);
3571 ep
->stid
= cxgb4_alloc_stid(dev
->rdev
.lldi
.tids
,
3572 cm_id
->m_local_addr
.ss_family
, ep
);
3574 if (ep
->stid
== -1) {
3575 pr_err("%s - cannot alloc stid\n", __func__
);
3579 err
= xa_insert_irq(&dev
->stids
, ep
->stid
, ep
, GFP_KERNEL
);
3583 state_set(&ep
->com
, LISTEN
);
3584 if (ep
->com
.local_addr
.ss_family
== AF_INET
)
3585 err
= create_server4(dev
, ep
);
3587 err
= create_server6(dev
, ep
);
3589 cm_id
->provider_data
= ep
;
3592 xa_erase_irq(&ep
->com
.dev
->stids
, ep
->stid
);
3594 cxgb4_free_stid(ep
->com
.dev
->rdev
.lldi
.tids
, ep
->stid
,
3595 ep
->com
.local_addr
.ss_family
);
3597 deref_cm_id(&ep
->com
);
3598 c4iw_put_ep(&ep
->com
);
3604 int c4iw_destroy_listen(struct iw_cm_id
*cm_id
)
3607 struct c4iw_listen_ep
*ep
= to_listen_ep(cm_id
);
3609 pr_debug("ep %p\n", ep
);
3612 state_set(&ep
->com
, DEAD
);
3613 if (ep
->com
.dev
->rdev
.lldi
.enable_fw_ofld_conn
&&
3614 ep
->com
.local_addr
.ss_family
== AF_INET
) {
3615 err
= cxgb4_remove_server_filter(
3616 ep
->com
.dev
->rdev
.lldi
.ports
[0], ep
->stid
,
3617 ep
->com
.dev
->rdev
.lldi
.rxq_ids
[0], false);
3619 struct sockaddr_in6
*sin6
;
3620 c4iw_init_wr_wait(ep
->com
.wr_waitp
);
3621 err
= cxgb4_remove_server(
3622 ep
->com
.dev
->rdev
.lldi
.ports
[0], ep
->stid
,
3623 ep
->com
.dev
->rdev
.lldi
.rxq_ids
[0],
3624 ep
->com
.local_addr
.ss_family
== AF_INET6
);
3627 err
= c4iw_wait_for_reply(&ep
->com
.dev
->rdev
, ep
->com
.wr_waitp
,
3629 sin6
= (struct sockaddr_in6
*)&ep
->com
.local_addr
;
3630 cxgb4_clip_release(ep
->com
.dev
->rdev
.lldi
.ports
[0],
3631 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
3633 xa_erase_irq(&ep
->com
.dev
->stids
, ep
->stid
);
3634 cxgb4_free_stid(ep
->com
.dev
->rdev
.lldi
.tids
, ep
->stid
,
3635 ep
->com
.local_addr
.ss_family
);
3637 deref_cm_id(&ep
->com
);
3638 c4iw_put_ep(&ep
->com
);
3642 int c4iw_ep_disconnect(struct c4iw_ep
*ep
, int abrupt
, gfp_t gfp
)
3647 struct c4iw_rdev
*rdev
;
3649 mutex_lock(&ep
->com
.mutex
);
3651 pr_debug("ep %p state %s, abrupt %d\n", ep
,
3652 states
[ep
->com
.state
], abrupt
);
3655 * Ref the ep here in case we have fatal errors causing the
3656 * ep to be released and freed.
3658 c4iw_get_ep(&ep
->com
);
3660 rdev
= &ep
->com
.dev
->rdev
;
3661 if (c4iw_fatal_error(rdev
)) {
3663 close_complete_upcall(ep
, -EIO
);
3664 ep
->com
.state
= DEAD
;
3666 switch (ep
->com
.state
) {
3675 ep
->com
.state
= ABORTING
;
3677 ep
->com
.state
= CLOSING
;
3680 * if we close before we see the fw4_ack() then we fix
3681 * up the timer state since we're reusing it.
3684 test_bit(STOP_MPA_TIMER
, &ep
->com
.flags
)) {
3685 clear_bit(STOP_MPA_TIMER
, &ep
->com
.flags
);
3690 set_bit(CLOSE_SENT
, &ep
->com
.flags
);
3693 if (!test_and_set_bit(CLOSE_SENT
, &ep
->com
.flags
)) {
3696 (void)stop_ep_timer(ep
);
3697 ep
->com
.state
= ABORTING
;
3699 ep
->com
.state
= MORIBUND
;
3705 pr_debug("ignoring disconnect ep %p state %u\n",
3709 WARN_ONCE(1, "Bad endpoint state %u\n", ep
->com
.state
);
3715 set_bit(EP_DISC_ABORT
, &ep
->com
.history
);
3716 ret
= send_abort(ep
);
3718 set_bit(EP_DISC_CLOSE
, &ep
->com
.history
);
3719 ret
= send_halfclose(ep
);
3722 set_bit(EP_DISC_FAIL
, &ep
->com
.history
);
3725 close_complete_upcall(ep
, -EIO
);
3728 struct c4iw_qp_attributes attrs
;
3730 attrs
.next_state
= C4IW_QP_STATE_ERROR
;
3731 ret
= c4iw_modify_qp(ep
->com
.qp
->rhp
,
3733 C4IW_QP_ATTR_NEXT_STATE
,
3736 pr_err("%s - qp <- error failed!\n",
3742 mutex_unlock(&ep
->com
.mutex
);
3743 c4iw_put_ep(&ep
->com
);
3745 release_ep_resources(ep
);
3749 static void active_ofld_conn_reply(struct c4iw_dev
*dev
, struct sk_buff
*skb
,
3750 struct cpl_fw6_msg_ofld_connection_wr_rpl
*req
)
3753 int atid
= be32_to_cpu(req
->tid
);
3755 ep
= (struct c4iw_ep
*)lookup_atid(dev
->rdev
.lldi
.tids
,
3756 (__force u32
) req
->tid
);
3760 switch (req
->retval
) {
3762 set_bit(ACT_RETRY_NOMEM
, &ep
->com
.history
);
3763 if (ep
->retry_count
++ < ACT_OPEN_RETRY_COUNT
) {
3764 send_fw_act_open_req(ep
, atid
);
3769 set_bit(ACT_RETRY_INUSE
, &ep
->com
.history
);
3770 if (ep
->retry_count
++ < ACT_OPEN_RETRY_COUNT
) {
3771 send_fw_act_open_req(ep
, atid
);
3776 pr_info("%s unexpected ofld conn wr retval %d\n",
3777 __func__
, req
->retval
);
3780 pr_err("active ofld_connect_wr failure %d atid %d\n",
3782 mutex_lock(&dev
->rdev
.stats
.lock
);
3783 dev
->rdev
.stats
.act_ofld_conn_fails
++;
3784 mutex_unlock(&dev
->rdev
.stats
.lock
);
3785 connect_reply_upcall(ep
, status2errno(req
->retval
));
3786 state_set(&ep
->com
, DEAD
);
3787 if (ep
->com
.remote_addr
.ss_family
== AF_INET6
) {
3788 struct sockaddr_in6
*sin6
=
3789 (struct sockaddr_in6
*)&ep
->com
.local_addr
;
3790 cxgb4_clip_release(ep
->com
.dev
->rdev
.lldi
.ports
[0],
3791 (const u32
*)&sin6
->sin6_addr
.s6_addr
, 1);
3793 xa_erase_irq(&dev
->atids
, atid
);
3794 cxgb4_free_atid(dev
->rdev
.lldi
.tids
, atid
);
3795 dst_release(ep
->dst
);
3796 cxgb4_l2t_release(ep
->l2t
);
3797 c4iw_put_ep(&ep
->com
);
3800 static void passive_ofld_conn_reply(struct c4iw_dev
*dev
, struct sk_buff
*skb
,
3801 struct cpl_fw6_msg_ofld_connection_wr_rpl
*req
)
3803 struct sk_buff
*rpl_skb
;
3804 struct cpl_pass_accept_req
*cpl
;
3807 rpl_skb
= (struct sk_buff
*)(unsigned long)req
->cookie
;
3809 pr_err("%s passive open failure %d\n", __func__
, req
->retval
);
3810 mutex_lock(&dev
->rdev
.stats
.lock
);
3811 dev
->rdev
.stats
.pas_ofld_conn_fails
++;
3812 mutex_unlock(&dev
->rdev
.stats
.lock
);
3815 cpl
= (struct cpl_pass_accept_req
*)cplhdr(rpl_skb
);
3816 OPCODE_TID(cpl
) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_REQ
,
3817 (__force u32
) htonl(
3818 (__force u32
) req
->tid
)));
3819 ret
= pass_accept_req(dev
, rpl_skb
);
3826 static inline u64
t4_tcb_get_field64(__be64
*tcb
, u16 word
)
3828 u64 tlo
= be64_to_cpu(tcb
[((31 - word
) / 2)]);
3829 u64 thi
= be64_to_cpu(tcb
[((31 - word
) / 2) - 1]);
3833 t
= (thi
<< shift
) | (tlo
>> shift
);
3838 static inline u32
t4_tcb_get_field32(__be64
*tcb
, u16 word
, u32 mask
, u32 shift
)
3841 u64 t
= be64_to_cpu(tcb
[(31 - word
) / 2]);
3845 v
= (t
>> shift
) & mask
;
3849 static int read_tcb_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
3851 struct cpl_get_tcb_rpl
*rpl
= cplhdr(skb
);
3852 __be64
*tcb
= (__be64
*)(rpl
+ 1);
3853 unsigned int tid
= GET_TID(rpl
);
3858 ep
= get_ep_from_tid(dev
, tid
);
3861 /* Examine the TF_RX_PDU_OUT (bit 49 of the t_flags) in order to
3862 * determine if there's a rx PDU feedback event pending.
3864 * If that bit is set, it means we'll need to re-read the TCB's
3865 * rq_start value. The final value is the one present in a TCB
3866 * with the TF_RX_PDU_OUT bit cleared.
3869 t_flags_64
= t4_tcb_get_field64(tcb
, TCB_T_FLAGS_W
);
3870 rx_pdu_out
= (t_flags_64
& TF_RX_PDU_OUT_V(1)) >> TF_RX_PDU_OUT_S
;
3872 c4iw_put_ep(&ep
->com
); /* from get_ep_from_tid() */
3873 c4iw_put_ep(&ep
->com
); /* from read_tcb() */
3875 /* If TF_RX_PDU_OUT bit is set, re-read the TCB */
3877 if (++ep
->rx_pdu_out_cnt
>= 2) {
3878 WARN_ONCE(1, "tcb re-read() reached the guard limit, finishing the cleanup\n");
3885 ep
->srqe_idx
= t4_tcb_get_field32(tcb
, TCB_RQ_START_W
, TCB_RQ_START_M
,
3888 pr_debug("ep %p tid %u %016x\n", ep
, ep
->hwtid
, ep
->srqe_idx
);
3890 if (test_bit(PEER_ABORT_IN_PROGRESS
, &ep
->com
.flags
))
3891 finish_peer_abort(dev
, ep
);
3892 else if (test_bit(ABORT_REQ_IN_PROGRESS
, &ep
->com
.flags
))
3895 WARN_ONCE(1, "unexpected state!");
3900 static int deferred_fw6_msg(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
3902 struct cpl_fw6_msg
*rpl
= cplhdr(skb
);
3903 struct cpl_fw6_msg_ofld_connection_wr_rpl
*req
;
3905 switch (rpl
->type
) {
3907 c4iw_ev_dispatch(dev
, (struct t4_cqe
*)&rpl
->data
[0]);
3909 case FW6_TYPE_OFLD_CONNECTION_WR_RPL
:
3910 req
= (struct cpl_fw6_msg_ofld_connection_wr_rpl
*)rpl
->data
;
3911 switch (req
->t_state
) {
3913 active_ofld_conn_reply(dev
, skb
, req
);
3916 passive_ofld_conn_reply(dev
, skb
, req
);
3919 pr_err("%s unexpected ofld conn wr state %d\n",
3920 __func__
, req
->t_state
);
3928 static void build_cpl_pass_accept_req(struct sk_buff
*skb
, int stid
, u8 tos
)
3931 __be16 hdr_len
, vlantag
, len
;
3933 int tcp_hdr_len
, ip_hdr_len
;
3935 struct cpl_rx_pkt
*cpl
= cplhdr(skb
);
3936 struct cpl_pass_accept_req
*req
;
3937 struct tcp_options_received tmp_opt
;
3938 struct c4iw_dev
*dev
;
3939 enum chip_type type
;
3941 dev
= *((struct c4iw_dev
**) (skb
->cb
+ sizeof(void *)));
3942 /* Store values from cpl_rx_pkt in temporary location. */
3943 vlantag
= cpl
->vlan
;
3945 l2info
= cpl
->l2info
;
3946 hdr_len
= cpl
->hdr_len
;
3949 __skb_pull(skb
, sizeof(*req
) + sizeof(struct rss_header
));
3952 * We need to parse the TCP options from SYN packet.
3953 * to generate cpl_pass_accept_req.
3955 memset(&tmp_opt
, 0, sizeof(tmp_opt
));
3956 tcp_clear_options(&tmp_opt
);
3957 tcp_parse_options(&init_net
, skb
, &tmp_opt
, 0, NULL
);
3959 req
= __skb_push(skb
, sizeof(*req
));
3960 memset(req
, 0, sizeof(*req
));
3961 req
->l2info
= cpu_to_be16(SYN_INTF_V(intf
) |
3962 SYN_MAC_IDX_V(RX_MACIDX_G(
3963 be32_to_cpu(l2info
))) |
3965 type
= dev
->rdev
.lldi
.adapter_type
;
3966 tcp_hdr_len
= RX_TCPHDR_LEN_G(be16_to_cpu(hdr_len
));
3967 ip_hdr_len
= RX_IPHDR_LEN_G(be16_to_cpu(hdr_len
));
3969 cpu_to_be32(SYN_RX_CHAN_V(RX_CHAN_G(be32_to_cpu(l2info
))));
3970 if (CHELSIO_CHIP_VERSION(type
) <= CHELSIO_T5
) {
3971 eth_hdr_len
= is_t4(type
) ?
3972 RX_ETHHDR_LEN_G(be32_to_cpu(l2info
)) :
3973 RX_T5_ETHHDR_LEN_G(be32_to_cpu(l2info
));
3974 req
->hdr_len
|= cpu_to_be32(TCP_HDR_LEN_V(tcp_hdr_len
) |
3975 IP_HDR_LEN_V(ip_hdr_len
) |
3976 ETH_HDR_LEN_V(eth_hdr_len
));
3977 } else { /* T6 and later */
3978 eth_hdr_len
= RX_T6_ETHHDR_LEN_G(be32_to_cpu(l2info
));
3979 req
->hdr_len
|= cpu_to_be32(T6_TCP_HDR_LEN_V(tcp_hdr_len
) |
3980 T6_IP_HDR_LEN_V(ip_hdr_len
) |
3981 T6_ETH_HDR_LEN_V(eth_hdr_len
));
3983 req
->vlan
= vlantag
;
3985 req
->tos_stid
= cpu_to_be32(PASS_OPEN_TID_V(stid
) |
3986 PASS_OPEN_TOS_V(tos
));
3987 req
->tcpopt
.mss
= htons(tmp_opt
.mss_clamp
);
3988 if (tmp_opt
.wscale_ok
)
3989 req
->tcpopt
.wsf
= tmp_opt
.snd_wscale
;
3990 req
->tcpopt
.tstamp
= tmp_opt
.saw_tstamp
;
3991 if (tmp_opt
.sack_ok
)
3992 req
->tcpopt
.sack
= 1;
3993 OPCODE_TID(req
) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_REQ
, 0));
3997 static void send_fw_pass_open_req(struct c4iw_dev
*dev
, struct sk_buff
*skb
,
3998 __be32 laddr
, __be16 lport
,
3999 __be32 raddr
, __be16 rport
,
4000 u32 rcv_isn
, u32 filter
, u16 window
,
4001 u32 rss_qid
, u8 port_id
)
4003 struct sk_buff
*req_skb
;
4004 struct fw_ofld_connection_wr
*req
;
4005 struct cpl_pass_accept_req
*cpl
= cplhdr(skb
);
4008 req_skb
= alloc_skb(sizeof(struct fw_ofld_connection_wr
), GFP_KERNEL
);
4011 req
= __skb_put_zero(req_skb
, sizeof(*req
));
4012 req
->op_compl
= htonl(WR_OP_V(FW_OFLD_CONNECTION_WR
) | FW_WR_COMPL_F
);
4013 req
->len16_pkd
= htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req
), 16)));
4014 req
->le
.version_cpl
= htonl(FW_OFLD_CONNECTION_WR_CPL_F
);
4015 req
->le
.filter
= (__force __be32
) filter
;
4016 req
->le
.lport
= lport
;
4017 req
->le
.pport
= rport
;
4018 req
->le
.u
.ipv4
.lip
= laddr
;
4019 req
->le
.u
.ipv4
.pip
= raddr
;
4020 req
->tcb
.rcv_nxt
= htonl(rcv_isn
+ 1);
4021 req
->tcb
.rcv_adv
= htons(window
);
4022 req
->tcb
.t_state_to_astid
=
4023 htonl(FW_OFLD_CONNECTION_WR_T_STATE_V(TCP_SYN_RECV
) |
4024 FW_OFLD_CONNECTION_WR_RCV_SCALE_V(cpl
->tcpopt
.wsf
) |
4025 FW_OFLD_CONNECTION_WR_ASTID_V(
4026 PASS_OPEN_TID_G(ntohl(cpl
->tos_stid
))));
4029 * We store the qid in opt2 which will be used by the firmware
4030 * to send us the wr response.
4032 req
->tcb
.opt2
= htonl(RSS_QUEUE_V(rss_qid
));
4035 * We initialize the MSS index in TCB to 0xF.
4036 * So that when driver sends cpl_pass_accept_rpl
4037 * TCB picks up the correct value. If this was 0
4038 * TP will ignore any value > 0 for MSS index.
4040 req
->tcb
.opt0
= cpu_to_be64(MSS_IDX_V(0xF));
4041 req
->cookie
= (uintptr_t)skb
;
4043 set_wr_txq(req_skb
, CPL_PRIORITY_CONTROL
, port_id
);
4044 ret
= cxgb4_ofld_send(dev
->rdev
.lldi
.ports
[0], req_skb
);
4046 pr_err("%s - cxgb4_ofld_send error %d - dropping\n", __func__
,
4054 * Handler for CPL_RX_PKT message. Need to handle cpl_rx_pkt
4055 * messages when a filter is being used instead of server to
4056 * redirect a syn packet. When packets hit filter they are redirected
4057 * to the offload queue and driver tries to establish the connection
4058 * using firmware work request.
4060 static int rx_pkt(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
4063 unsigned int filter
;
4064 struct ethhdr
*eh
= NULL
;
4065 struct vlan_ethhdr
*vlan_eh
= NULL
;
4067 struct tcphdr
*tcph
;
4068 struct rss_header
*rss
= (void *)skb
->data
;
4069 struct cpl_rx_pkt
*cpl
= (void *)skb
->data
;
4070 struct cpl_pass_accept_req
*req
= (void *)(rss
+ 1);
4071 struct l2t_entry
*e
;
4072 struct dst_entry
*dst
;
4073 struct c4iw_ep
*lep
= NULL
;
4075 struct port_info
*pi
;
4076 struct net_device
*pdev
;
4077 u16 rss_qid
, eth_hdr_len
;
4079 struct neighbour
*neigh
;
4081 /* Drop all non-SYN packets */
4082 if (!(cpl
->l2info
& cpu_to_be32(RXF_SYN_F
)))
4086 * Drop all packets which did not hit the filter.
4087 * Unlikely to happen.
4089 if (!(rss
->filter_hit
&& rss
->filter_tid
))
4093 * Calculate the server tid from filter hit index from cpl_rx_pkt.
4095 stid
= (__force
int) cpu_to_be32((__force u32
) rss
->hash_val
);
4097 lep
= (struct c4iw_ep
*)get_ep_from_stid(dev
, stid
);
4099 pr_warn("%s connect request on invalid stid %d\n",
4104 switch (CHELSIO_CHIP_VERSION(dev
->rdev
.lldi
.adapter_type
)) {
4106 eth_hdr_len
= RX_ETHHDR_LEN_G(be32_to_cpu(cpl
->l2info
));
4109 eth_hdr_len
= RX_T5_ETHHDR_LEN_G(be32_to_cpu(cpl
->l2info
));
4112 eth_hdr_len
= RX_T6_ETHHDR_LEN_G(be32_to_cpu(cpl
->l2info
));
4115 pr_err("T%d Chip is not supported\n",
4116 CHELSIO_CHIP_VERSION(dev
->rdev
.lldi
.adapter_type
));
4120 if (eth_hdr_len
== ETH_HLEN
) {
4121 eh
= (struct ethhdr
*)(req
+ 1);
4122 iph
= (struct iphdr
*)(eh
+ 1);
4124 vlan_eh
= (struct vlan_ethhdr
*)(req
+ 1);
4125 iph
= (struct iphdr
*)(vlan_eh
+ 1);
4126 __vlan_hwaccel_put_tag(skb
, htons(ETH_P_8021Q
), ntohs(cpl
->vlan
));
4129 if (iph
->version
!= 0x4)
4132 tcph
= (struct tcphdr
*)(iph
+ 1);
4133 skb_set_network_header(skb
, (void *)iph
- (void *)rss
);
4134 skb_set_transport_header(skb
, (void *)tcph
- (void *)rss
);
4137 pr_debug("lip 0x%x lport %u pip 0x%x pport %u tos %d\n",
4138 ntohl(iph
->daddr
), ntohs(tcph
->dest
), ntohl(iph
->saddr
),
4139 ntohs(tcph
->source
), iph
->tos
);
4141 dst
= cxgb_find_route(&dev
->rdev
.lldi
, get_real_dev
,
4142 iph
->daddr
, iph
->saddr
, tcph
->dest
,
4143 tcph
->source
, iph
->tos
);
4145 pr_err("%s - failed to find dst entry!\n", __func__
);
4148 neigh
= dst_neigh_lookup_skb(dst
, skb
);
4151 pr_err("%s - failed to allocate neigh!\n", __func__
);
4155 if (neigh
->dev
->flags
& IFF_LOOPBACK
) {
4156 pdev
= ip_dev_find(&init_net
, iph
->daddr
);
4158 pr_err("%s - failed to find device!\n", __func__
);
4161 e
= cxgb4_l2t_get(dev
->rdev
.lldi
.l2t
, neigh
,
4163 pi
= (struct port_info
*)netdev_priv(pdev
);
4166 pdev
= get_real_dev(neigh
->dev
);
4167 e
= cxgb4_l2t_get(dev
->rdev
.lldi
.l2t
, neigh
,
4169 pi
= (struct port_info
*)netdev_priv(pdev
);
4171 neigh_release(neigh
);
4173 pr_err("%s - failed to allocate l2t entry!\n",
4178 step
= dev
->rdev
.lldi
.nrxq
/ dev
->rdev
.lldi
.nchan
;
4179 rss_qid
= dev
->rdev
.lldi
.rxq_ids
[pi
->port_id
* step
];
4180 window
= (__force u16
) htons((__force u16
)tcph
->window
);
4182 /* Calcuate filter portion for LE region. */
4183 filter
= (__force
unsigned int) cpu_to_be32(cxgb4_select_ntuple(
4184 dev
->rdev
.lldi
.ports
[0],
4188 * Synthesize the cpl_pass_accept_req. We have everything except the
4189 * TID. Once firmware sends a reply with TID we update the TID field
4190 * in cpl and pass it through the regular cpl_pass_accept_req path.
4192 build_cpl_pass_accept_req(skb
, stid
, iph
->tos
);
4193 send_fw_pass_open_req(dev
, skb
, iph
->daddr
, tcph
->dest
, iph
->saddr
,
4194 tcph
->source
, ntohl(tcph
->seq
), filter
, window
,
4195 rss_qid
, pi
->port_id
);
4196 cxgb4_l2t_release(e
);
4201 c4iw_put_ep(&lep
->com
);
4206 * These are the real handlers that are called from a
4209 static c4iw_handler_func work_handlers
[NUM_CPL_CMDS
+ NUM_FAKE_CPLS
] = {
4210 [CPL_ACT_ESTABLISH
] = act_establish
,
4211 [CPL_ACT_OPEN_RPL
] = act_open_rpl
,
4212 [CPL_RX_DATA
] = rx_data
,
4213 [CPL_ABORT_RPL_RSS
] = abort_rpl
,
4214 [CPL_ABORT_RPL
] = abort_rpl
,
4215 [CPL_PASS_OPEN_RPL
] = pass_open_rpl
,
4216 [CPL_CLOSE_LISTSRV_RPL
] = close_listsrv_rpl
,
4217 [CPL_PASS_ACCEPT_REQ
] = pass_accept_req
,
4218 [CPL_PASS_ESTABLISH
] = pass_establish
,
4219 [CPL_PEER_CLOSE
] = peer_close
,
4220 [CPL_ABORT_REQ_RSS
] = peer_abort
,
4221 [CPL_CLOSE_CON_RPL
] = close_con_rpl
,
4222 [CPL_RDMA_TERMINATE
] = terminate
,
4223 [CPL_FW4_ACK
] = fw4_ack
,
4224 [CPL_GET_TCB_RPL
] = read_tcb_rpl
,
4225 [CPL_FW6_MSG
] = deferred_fw6_msg
,
4226 [CPL_RX_PKT
] = rx_pkt
,
4227 [FAKE_CPL_PUT_EP_SAFE
] = _put_ep_safe
,
4228 [FAKE_CPL_PASS_PUT_EP_SAFE
] = _put_pass_ep_safe
4231 static void process_timeout(struct c4iw_ep
*ep
)
4233 struct c4iw_qp_attributes attrs
;
4236 mutex_lock(&ep
->com
.mutex
);
4237 pr_debug("ep %p tid %u state %d\n", ep
, ep
->hwtid
, ep
->com
.state
);
4238 set_bit(TIMEDOUT
, &ep
->com
.history
);
4239 switch (ep
->com
.state
) {
4241 connect_reply_upcall(ep
, -ETIMEDOUT
);
4250 if (ep
->com
.cm_id
&& ep
->com
.qp
) {
4251 attrs
.next_state
= C4IW_QP_STATE_ERROR
;
4252 c4iw_modify_qp(ep
->com
.qp
->rhp
,
4253 ep
->com
.qp
, C4IW_QP_ATTR_NEXT_STATE
,
4256 close_complete_upcall(ep
, -ETIMEDOUT
);
4262 * These states are expected if the ep timed out at the same
4263 * time as another thread was calling stop_ep_timer().
4264 * So we silently do nothing for these states.
4269 WARN(1, "%s unexpected state ep %p tid %u state %u\n",
4270 __func__
, ep
, ep
->hwtid
, ep
->com
.state
);
4273 mutex_unlock(&ep
->com
.mutex
);
4275 c4iw_ep_disconnect(ep
, 1, GFP_KERNEL
);
4276 c4iw_put_ep(&ep
->com
);
4279 static void process_timedout_eps(void)
4283 spin_lock_irq(&timeout_lock
);
4284 while (!list_empty(&timeout_list
)) {
4285 struct list_head
*tmp
;
4287 tmp
= timeout_list
.next
;
4291 spin_unlock_irq(&timeout_lock
);
4292 ep
= list_entry(tmp
, struct c4iw_ep
, entry
);
4293 process_timeout(ep
);
4294 spin_lock_irq(&timeout_lock
);
4296 spin_unlock_irq(&timeout_lock
);
4299 static void process_work(struct work_struct
*work
)
4301 struct sk_buff
*skb
= NULL
;
4302 struct c4iw_dev
*dev
;
4303 struct cpl_act_establish
*rpl
;
4304 unsigned int opcode
;
4307 process_timedout_eps();
4308 while ((skb
= skb_dequeue(&rxq
))) {
4310 dev
= *((struct c4iw_dev
**) (skb
->cb
+ sizeof(void *)));
4311 opcode
= rpl
->ot
.opcode
;
4313 if (opcode
>= ARRAY_SIZE(work_handlers
) ||
4314 !work_handlers
[opcode
]) {
4315 pr_err("No handler for opcode 0x%x.\n", opcode
);
4318 ret
= work_handlers
[opcode
](dev
, skb
);
4322 process_timedout_eps();
4326 static DECLARE_WORK(skb_work
, process_work
);
4328 static void ep_timeout(struct timer_list
*t
)
4330 struct c4iw_ep
*ep
= from_timer(ep
, t
, timer
);
4333 spin_lock(&timeout_lock
);
4334 if (!test_and_set_bit(TIMEOUT
, &ep
->com
.flags
)) {
4336 * Only insert if it is not already on the list.
4338 if (!ep
->entry
.next
) {
4339 list_add_tail(&ep
->entry
, &timeout_list
);
4343 spin_unlock(&timeout_lock
);
4345 queue_work(workq
, &skb_work
);
4349 * All the CM events are handled on a work queue to have a safe context.
4351 static int sched(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
4355 * Save dev in the skb->cb area.
4357 *((struct c4iw_dev
**) (skb
->cb
+ sizeof(void *))) = dev
;
4360 * Queue the skb and schedule the worker thread.
4362 skb_queue_tail(&rxq
, skb
);
4363 queue_work(workq
, &skb_work
);
4367 static int set_tcb_rpl(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
4369 struct cpl_set_tcb_rpl
*rpl
= cplhdr(skb
);
4371 if (rpl
->status
!= CPL_ERR_NONE
) {
4372 pr_err("Unexpected SET_TCB_RPL status %u for tid %u\n",
4373 rpl
->status
, GET_TID(rpl
));
4379 static int fw6_msg(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
4381 struct cpl_fw6_msg
*rpl
= cplhdr(skb
);
4382 struct c4iw_wr_wait
*wr_waitp
;
4385 pr_debug("type %u\n", rpl
->type
);
4387 switch (rpl
->type
) {
4388 case FW6_TYPE_WR_RPL
:
4389 ret
= (int)((be64_to_cpu(rpl
->data
[0]) >> 8) & 0xff);
4390 wr_waitp
= (struct c4iw_wr_wait
*)(__force
unsigned long) rpl
->data
[1];
4391 pr_debug("wr_waitp %p ret %u\n", wr_waitp
, ret
);
4393 c4iw_wake_up_deref(wr_waitp
, ret
? -ret
: 0);
4397 case FW6_TYPE_OFLD_CONNECTION_WR_RPL
:
4401 pr_err("%s unexpected fw6 msg type %u\n",
4402 __func__
, rpl
->type
);
4409 static int peer_abort_intr(struct c4iw_dev
*dev
, struct sk_buff
*skb
)
4411 struct cpl_abort_req_rss
*req
= cplhdr(skb
);
4413 unsigned int tid
= GET_TID(req
);
4415 ep
= get_ep_from_tid(dev
, tid
);
4416 /* This EP will be dereferenced in peer_abort() */
4418 pr_warn("Abort on non-existent endpoint, tid %d\n", tid
);
4422 if (cxgb_is_neg_adv(req
->status
)) {
4423 pr_debug("Negative advice on abort- tid %u status %d (%s)\n",
4424 ep
->hwtid
, req
->status
,
4425 neg_adv_str(req
->status
));
4428 pr_debug("ep %p tid %u state %u\n", ep
, ep
->hwtid
, ep
->com
.state
);
4430 c4iw_wake_up_noref(ep
->com
.wr_waitp
, -ECONNRESET
);
4437 * Most upcalls from the T4 Core go to sched() to
4438 * schedule the processing on a work queue.
4440 c4iw_handler_func c4iw_handlers
[NUM_CPL_CMDS
] = {
4441 [CPL_ACT_ESTABLISH
] = sched
,
4442 [CPL_ACT_OPEN_RPL
] = sched
,
4443 [CPL_RX_DATA
] = sched
,
4444 [CPL_ABORT_RPL_RSS
] = sched
,
4445 [CPL_ABORT_RPL
] = sched
,
4446 [CPL_PASS_OPEN_RPL
] = sched
,
4447 [CPL_CLOSE_LISTSRV_RPL
] = sched
,
4448 [CPL_PASS_ACCEPT_REQ
] = sched
,
4449 [CPL_PASS_ESTABLISH
] = sched
,
4450 [CPL_PEER_CLOSE
] = sched
,
4451 [CPL_CLOSE_CON_RPL
] = sched
,
4452 [CPL_ABORT_REQ_RSS
] = peer_abort_intr
,
4453 [CPL_RDMA_TERMINATE
] = sched
,
4454 [CPL_FW4_ACK
] = sched
,
4455 [CPL_SET_TCB_RPL
] = set_tcb_rpl
,
4456 [CPL_GET_TCB_RPL
] = sched
,
4457 [CPL_FW6_MSG
] = fw6_msg
,
4458 [CPL_RX_PKT
] = sched
4461 int __init
c4iw_cm_init(void)
4463 skb_queue_head_init(&rxq
);
4465 workq
= alloc_ordered_workqueue("iw_cxgb4", WQ_MEM_RECLAIM
);
4472 void c4iw_cm_term(void)
4474 WARN_ON(!list_empty(&timeout_list
));
4475 destroy_workqueue(workq
);