Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[linux/fpc-iii.git] / drivers / target / iscsi / cxgbit / cxgbit_cm.c
blobdab09b6107231668a7b9aeeea0047bfc96c11aad
1 /*
2 * Copyright (c) 2016 Chelsio Communications, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #include <linux/module.h>
10 #include <linux/list.h>
11 #include <linux/workqueue.h>
12 #include <linux/skbuff.h>
13 #include <linux/timer.h>
14 #include <linux/notifier.h>
15 #include <linux/inetdevice.h>
16 #include <linux/ip.h>
17 #include <linux/tcp.h>
18 #include <linux/if_vlan.h>
20 #include <net/neighbour.h>
21 #include <net/netevent.h>
22 #include <net/route.h>
23 #include <net/tcp.h>
24 #include <net/ip6_route.h>
25 #include <net/addrconf.h>
27 #include <libcxgb_cm.h>
28 #include "cxgbit.h"
29 #include "clip_tbl.h"
31 static void cxgbit_init_wr_wait(struct cxgbit_wr_wait *wr_waitp)
33 wr_waitp->ret = 0;
34 reinit_completion(&wr_waitp->completion);
37 static void
38 cxgbit_wake_up(struct cxgbit_wr_wait *wr_waitp, const char *func, u8 ret)
40 if (ret == CPL_ERR_NONE)
41 wr_waitp->ret = 0;
42 else
43 wr_waitp->ret = -EIO;
45 if (wr_waitp->ret)
46 pr_err("%s: err:%u", func, ret);
48 complete(&wr_waitp->completion);
51 static int
52 cxgbit_wait_for_reply(struct cxgbit_device *cdev,
53 struct cxgbit_wr_wait *wr_waitp, u32 tid, u32 timeout,
54 const char *func)
56 int ret;
58 if (!test_bit(CDEV_STATE_UP, &cdev->flags)) {
59 wr_waitp->ret = -EIO;
60 goto out;
63 ret = wait_for_completion_timeout(&wr_waitp->completion, timeout * HZ);
64 if (!ret) {
65 pr_info("%s - Device %s not responding tid %u\n",
66 func, pci_name(cdev->lldi.pdev), tid);
67 wr_waitp->ret = -ETIMEDOUT;
69 out:
70 if (wr_waitp->ret)
71 pr_info("%s: FW reply %d tid %u\n",
72 pci_name(cdev->lldi.pdev), wr_waitp->ret, tid);
73 return wr_waitp->ret;
76 static int cxgbit_np_hashfn(const struct cxgbit_np *cnp)
78 return ((unsigned long)cnp >> 10) & (NP_INFO_HASH_SIZE - 1);
81 static struct np_info *
82 cxgbit_np_hash_add(struct cxgbit_device *cdev, struct cxgbit_np *cnp,
83 unsigned int stid)
85 struct np_info *p = kzalloc(sizeof(*p), GFP_KERNEL);
87 if (p) {
88 int bucket = cxgbit_np_hashfn(cnp);
90 p->cnp = cnp;
91 p->stid = stid;
92 spin_lock(&cdev->np_lock);
93 p->next = cdev->np_hash_tab[bucket];
94 cdev->np_hash_tab[bucket] = p;
95 spin_unlock(&cdev->np_lock);
98 return p;
101 static int
102 cxgbit_np_hash_find(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
104 int stid = -1, bucket = cxgbit_np_hashfn(cnp);
105 struct np_info *p;
107 spin_lock(&cdev->np_lock);
108 for (p = cdev->np_hash_tab[bucket]; p; p = p->next) {
109 if (p->cnp == cnp) {
110 stid = p->stid;
111 break;
114 spin_unlock(&cdev->np_lock);
116 return stid;
119 static int cxgbit_np_hash_del(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
121 int stid = -1, bucket = cxgbit_np_hashfn(cnp);
122 struct np_info *p, **prev = &cdev->np_hash_tab[bucket];
124 spin_lock(&cdev->np_lock);
125 for (p = *prev; p; prev = &p->next, p = p->next) {
126 if (p->cnp == cnp) {
127 stid = p->stid;
128 *prev = p->next;
129 kfree(p);
130 break;
133 spin_unlock(&cdev->np_lock);
135 return stid;
138 void _cxgbit_free_cnp(struct kref *kref)
140 struct cxgbit_np *cnp;
142 cnp = container_of(kref, struct cxgbit_np, kref);
143 kfree(cnp);
146 static int
147 cxgbit_create_server6(struct cxgbit_device *cdev, unsigned int stid,
148 struct cxgbit_np *cnp)
150 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)
151 &cnp->com.local_addr;
152 int addr_type;
153 int ret;
155 pr_debug("%s: dev = %s; stid = %u; sin6_port = %u\n",
156 __func__, cdev->lldi.ports[0]->name, stid, sin6->sin6_port);
158 addr_type = ipv6_addr_type((const struct in6_addr *)
159 &sin6->sin6_addr);
160 if (addr_type != IPV6_ADDR_ANY) {
161 ret = cxgb4_clip_get(cdev->lldi.ports[0],
162 (const u32 *)&sin6->sin6_addr.s6_addr, 1);
163 if (ret) {
164 pr_err("Unable to find clip table entry. laddr %pI6. Error:%d.\n",
165 sin6->sin6_addr.s6_addr, ret);
166 return -ENOMEM;
170 cxgbit_get_cnp(cnp);
171 cxgbit_init_wr_wait(&cnp->com.wr_wait);
173 ret = cxgb4_create_server6(cdev->lldi.ports[0],
174 stid, &sin6->sin6_addr,
175 sin6->sin6_port,
176 cdev->lldi.rxq_ids[0]);
177 if (!ret)
178 ret = cxgbit_wait_for_reply(cdev, &cnp->com.wr_wait,
179 0, 10, __func__);
180 else if (ret > 0)
181 ret = net_xmit_errno(ret);
182 else
183 cxgbit_put_cnp(cnp);
185 if (ret) {
186 if (ret != -ETIMEDOUT)
187 cxgb4_clip_release(cdev->lldi.ports[0],
188 (const u32 *)&sin6->sin6_addr.s6_addr, 1);
190 pr_err("create server6 err %d stid %d laddr %pI6 lport %d\n",
191 ret, stid, sin6->sin6_addr.s6_addr,
192 ntohs(sin6->sin6_port));
195 return ret;
198 static int
199 cxgbit_create_server4(struct cxgbit_device *cdev, unsigned int stid,
200 struct cxgbit_np *cnp)
202 struct sockaddr_in *sin = (struct sockaddr_in *)
203 &cnp->com.local_addr;
204 int ret;
206 pr_debug("%s: dev = %s; stid = %u; sin_port = %u\n",
207 __func__, cdev->lldi.ports[0]->name, stid, sin->sin_port);
209 cxgbit_get_cnp(cnp);
210 cxgbit_init_wr_wait(&cnp->com.wr_wait);
212 ret = cxgb4_create_server(cdev->lldi.ports[0],
213 stid, sin->sin_addr.s_addr,
214 sin->sin_port, 0,
215 cdev->lldi.rxq_ids[0]);
216 if (!ret)
217 ret = cxgbit_wait_for_reply(cdev,
218 &cnp->com.wr_wait,
219 0, 10, __func__);
220 else if (ret > 0)
221 ret = net_xmit_errno(ret);
222 else
223 cxgbit_put_cnp(cnp);
225 if (ret)
226 pr_err("create server failed err %d stid %d laddr %pI4 lport %d\n",
227 ret, stid, &sin->sin_addr, ntohs(sin->sin_port));
228 return ret;
231 struct cxgbit_device *cxgbit_find_device(struct net_device *ndev, u8 *port_id)
233 struct cxgbit_device *cdev;
234 u8 i;
236 list_for_each_entry(cdev, &cdev_list_head, list) {
237 struct cxgb4_lld_info *lldi = &cdev->lldi;
239 for (i = 0; i < lldi->nports; i++) {
240 if (lldi->ports[i] == ndev) {
241 if (port_id)
242 *port_id = i;
243 return cdev;
248 return NULL;
251 static struct net_device *cxgbit_get_real_dev(struct net_device *ndev)
253 if (ndev->priv_flags & IFF_BONDING) {
254 pr_err("Bond devices are not supported. Interface:%s\n",
255 ndev->name);
256 return NULL;
259 if (is_vlan_dev(ndev))
260 return vlan_dev_real_dev(ndev);
262 return ndev;
265 static struct net_device *cxgbit_ipv4_netdev(__be32 saddr)
267 struct net_device *ndev;
269 ndev = __ip_dev_find(&init_net, saddr, false);
270 if (!ndev)
271 return NULL;
273 return cxgbit_get_real_dev(ndev);
276 static struct net_device *cxgbit_ipv6_netdev(struct in6_addr *addr6)
278 struct net_device *ndev = NULL;
279 bool found = false;
281 if (IS_ENABLED(CONFIG_IPV6)) {
282 for_each_netdev_rcu(&init_net, ndev)
283 if (ipv6_chk_addr(&init_net, addr6, ndev, 1)) {
284 found = true;
285 break;
288 if (!found)
289 return NULL;
290 return cxgbit_get_real_dev(ndev);
293 static struct cxgbit_device *cxgbit_find_np_cdev(struct cxgbit_np *cnp)
295 struct sockaddr_storage *sockaddr = &cnp->com.local_addr;
296 int ss_family = sockaddr->ss_family;
297 struct net_device *ndev = NULL;
298 struct cxgbit_device *cdev = NULL;
300 rcu_read_lock();
301 if (ss_family == AF_INET) {
302 struct sockaddr_in *sin;
304 sin = (struct sockaddr_in *)sockaddr;
305 ndev = cxgbit_ipv4_netdev(sin->sin_addr.s_addr);
306 } else if (ss_family == AF_INET6) {
307 struct sockaddr_in6 *sin6;
309 sin6 = (struct sockaddr_in6 *)sockaddr;
310 ndev = cxgbit_ipv6_netdev(&sin6->sin6_addr);
312 if (!ndev)
313 goto out;
315 cdev = cxgbit_find_device(ndev, NULL);
316 out:
317 rcu_read_unlock();
318 return cdev;
321 static bool cxgbit_inaddr_any(struct cxgbit_np *cnp)
323 struct sockaddr_storage *sockaddr = &cnp->com.local_addr;
324 int ss_family = sockaddr->ss_family;
325 int addr_type;
327 if (ss_family == AF_INET) {
328 struct sockaddr_in *sin;
330 sin = (struct sockaddr_in *)sockaddr;
331 if (sin->sin_addr.s_addr == htonl(INADDR_ANY))
332 return true;
333 } else if (ss_family == AF_INET6) {
334 struct sockaddr_in6 *sin6;
336 sin6 = (struct sockaddr_in6 *)sockaddr;
337 addr_type = ipv6_addr_type((const struct in6_addr *)
338 &sin6->sin6_addr);
339 if (addr_type == IPV6_ADDR_ANY)
340 return true;
342 return false;
345 static int
346 __cxgbit_setup_cdev_np(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
348 int stid, ret;
349 int ss_family = cnp->com.local_addr.ss_family;
351 if (!test_bit(CDEV_STATE_UP, &cdev->flags))
352 return -EINVAL;
354 stid = cxgb4_alloc_stid(cdev->lldi.tids, ss_family, cnp);
355 if (stid < 0)
356 return -EINVAL;
358 if (!cxgbit_np_hash_add(cdev, cnp, stid)) {
359 cxgb4_free_stid(cdev->lldi.tids, stid, ss_family);
360 return -EINVAL;
363 if (ss_family == AF_INET)
364 ret = cxgbit_create_server4(cdev, stid, cnp);
365 else
366 ret = cxgbit_create_server6(cdev, stid, cnp);
368 if (ret) {
369 if (ret != -ETIMEDOUT)
370 cxgb4_free_stid(cdev->lldi.tids, stid,
371 ss_family);
372 cxgbit_np_hash_del(cdev, cnp);
373 return ret;
375 return ret;
378 static int cxgbit_setup_cdev_np(struct cxgbit_np *cnp)
380 struct cxgbit_device *cdev;
381 int ret = -1;
383 mutex_lock(&cdev_list_lock);
384 cdev = cxgbit_find_np_cdev(cnp);
385 if (!cdev)
386 goto out;
388 if (cxgbit_np_hash_find(cdev, cnp) >= 0)
389 goto out;
391 if (__cxgbit_setup_cdev_np(cdev, cnp))
392 goto out;
394 cnp->com.cdev = cdev;
395 ret = 0;
396 out:
397 mutex_unlock(&cdev_list_lock);
398 return ret;
401 static int cxgbit_setup_all_np(struct cxgbit_np *cnp)
403 struct cxgbit_device *cdev;
404 int ret;
405 u32 count = 0;
407 mutex_lock(&cdev_list_lock);
408 list_for_each_entry(cdev, &cdev_list_head, list) {
409 if (cxgbit_np_hash_find(cdev, cnp) >= 0) {
410 mutex_unlock(&cdev_list_lock);
411 return -1;
415 list_for_each_entry(cdev, &cdev_list_head, list) {
416 ret = __cxgbit_setup_cdev_np(cdev, cnp);
417 if (ret == -ETIMEDOUT)
418 break;
419 if (ret != 0)
420 continue;
421 count++;
423 mutex_unlock(&cdev_list_lock);
425 return count ? 0 : -1;
428 int cxgbit_setup_np(struct iscsi_np *np, struct sockaddr_storage *ksockaddr)
430 struct cxgbit_np *cnp;
431 int ret;
433 if ((ksockaddr->ss_family != AF_INET) &&
434 (ksockaddr->ss_family != AF_INET6))
435 return -EINVAL;
437 cnp = kzalloc(sizeof(*cnp), GFP_KERNEL);
438 if (!cnp)
439 return -ENOMEM;
441 init_waitqueue_head(&cnp->accept_wait);
442 init_completion(&cnp->com.wr_wait.completion);
443 init_completion(&cnp->accept_comp);
444 INIT_LIST_HEAD(&cnp->np_accept_list);
445 spin_lock_init(&cnp->np_accept_lock);
446 kref_init(&cnp->kref);
447 memcpy(&np->np_sockaddr, ksockaddr,
448 sizeof(struct sockaddr_storage));
449 memcpy(&cnp->com.local_addr, &np->np_sockaddr,
450 sizeof(cnp->com.local_addr));
452 cnp->np = np;
453 cnp->com.cdev = NULL;
455 if (cxgbit_inaddr_any(cnp))
456 ret = cxgbit_setup_all_np(cnp);
457 else
458 ret = cxgbit_setup_cdev_np(cnp);
460 if (ret) {
461 cxgbit_put_cnp(cnp);
462 return -EINVAL;
465 np->np_context = cnp;
466 cnp->com.state = CSK_STATE_LISTEN;
467 return 0;
470 static void
471 cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn,
472 struct cxgbit_sock *csk)
474 conn->login_family = np->np_sockaddr.ss_family;
475 conn->login_sockaddr = csk->com.remote_addr;
476 conn->local_sockaddr = csk->com.local_addr;
479 int cxgbit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)
481 struct cxgbit_np *cnp = np->np_context;
482 struct cxgbit_sock *csk;
483 int ret = 0;
485 accept_wait:
486 ret = wait_for_completion_interruptible(&cnp->accept_comp);
487 if (ret)
488 return -ENODEV;
490 spin_lock_bh(&np->np_thread_lock);
491 if (np->np_thread_state >= ISCSI_NP_THREAD_RESET) {
492 spin_unlock_bh(&np->np_thread_lock);
494 * No point in stalling here when np_thread
495 * is in state RESET/SHUTDOWN/EXIT - bail
497 return -ENODEV;
499 spin_unlock_bh(&np->np_thread_lock);
501 spin_lock_bh(&cnp->np_accept_lock);
502 if (list_empty(&cnp->np_accept_list)) {
503 spin_unlock_bh(&cnp->np_accept_lock);
504 goto accept_wait;
507 csk = list_first_entry(&cnp->np_accept_list,
508 struct cxgbit_sock,
509 accept_node);
511 list_del_init(&csk->accept_node);
512 spin_unlock_bh(&cnp->np_accept_lock);
513 conn->context = csk;
514 csk->conn = conn;
516 cxgbit_set_conn_info(np, conn, csk);
517 return 0;
520 static int
521 __cxgbit_free_cdev_np(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
523 int stid, ret;
524 bool ipv6 = false;
526 stid = cxgbit_np_hash_del(cdev, cnp);
527 if (stid < 0)
528 return -EINVAL;
529 if (!test_bit(CDEV_STATE_UP, &cdev->flags))
530 return -EINVAL;
532 if (cnp->np->np_sockaddr.ss_family == AF_INET6)
533 ipv6 = true;
535 cxgbit_get_cnp(cnp);
536 cxgbit_init_wr_wait(&cnp->com.wr_wait);
537 ret = cxgb4_remove_server(cdev->lldi.ports[0], stid,
538 cdev->lldi.rxq_ids[0], ipv6);
540 if (ret > 0)
541 ret = net_xmit_errno(ret);
543 if (ret) {
544 cxgbit_put_cnp(cnp);
545 return ret;
548 ret = cxgbit_wait_for_reply(cdev, &cnp->com.wr_wait,
549 0, 10, __func__);
550 if (ret == -ETIMEDOUT)
551 return ret;
553 if (ipv6 && cnp->com.cdev) {
554 struct sockaddr_in6 *sin6;
556 sin6 = (struct sockaddr_in6 *)&cnp->com.local_addr;
557 cxgb4_clip_release(cdev->lldi.ports[0],
558 (const u32 *)&sin6->sin6_addr.s6_addr,
562 cxgb4_free_stid(cdev->lldi.tids, stid,
563 cnp->com.local_addr.ss_family);
564 return 0;
567 static void cxgbit_free_all_np(struct cxgbit_np *cnp)
569 struct cxgbit_device *cdev;
570 int ret;
572 mutex_lock(&cdev_list_lock);
573 list_for_each_entry(cdev, &cdev_list_head, list) {
574 ret = __cxgbit_free_cdev_np(cdev, cnp);
575 if (ret == -ETIMEDOUT)
576 break;
578 mutex_unlock(&cdev_list_lock);
581 static void cxgbit_free_cdev_np(struct cxgbit_np *cnp)
583 struct cxgbit_device *cdev;
584 bool found = false;
586 mutex_lock(&cdev_list_lock);
587 list_for_each_entry(cdev, &cdev_list_head, list) {
588 if (cdev == cnp->com.cdev) {
589 found = true;
590 break;
593 if (!found)
594 goto out;
596 __cxgbit_free_cdev_np(cdev, cnp);
597 out:
598 mutex_unlock(&cdev_list_lock);
601 static void __cxgbit_free_conn(struct cxgbit_sock *csk);
603 void cxgbit_free_np(struct iscsi_np *np)
605 struct cxgbit_np *cnp = np->np_context;
606 struct cxgbit_sock *csk, *tmp;
608 cnp->com.state = CSK_STATE_DEAD;
609 if (cnp->com.cdev)
610 cxgbit_free_cdev_np(cnp);
611 else
612 cxgbit_free_all_np(cnp);
614 spin_lock_bh(&cnp->np_accept_lock);
615 list_for_each_entry_safe(csk, tmp, &cnp->np_accept_list, accept_node) {
616 list_del_init(&csk->accept_node);
617 __cxgbit_free_conn(csk);
619 spin_unlock_bh(&cnp->np_accept_lock);
621 np->np_context = NULL;
622 cxgbit_put_cnp(cnp);
625 static void cxgbit_send_halfclose(struct cxgbit_sock *csk)
627 struct sk_buff *skb;
628 u32 len = roundup(sizeof(struct cpl_close_con_req), 16);
630 skb = alloc_skb(len, GFP_ATOMIC);
631 if (!skb)
632 return;
634 cxgb_mk_close_con_req(skb, len, csk->tid, csk->txq_idx,
635 NULL, NULL);
637 cxgbit_skcb_flags(skb) |= SKCBF_TX_FLAG_COMPL;
638 __skb_queue_tail(&csk->txq, skb);
639 cxgbit_push_tx_frames(csk);
642 static void cxgbit_arp_failure_discard(void *handle, struct sk_buff *skb)
644 struct cxgbit_sock *csk = handle;
646 pr_debug("%s cxgbit_device %p\n", __func__, handle);
647 kfree_skb(skb);
648 cxgbit_put_csk(csk);
651 static void cxgbit_abort_arp_failure(void *handle, struct sk_buff *skb)
653 struct cxgbit_device *cdev = handle;
654 struct cpl_abort_req *req = cplhdr(skb);
656 pr_debug("%s cdev %p\n", __func__, cdev);
657 req->cmd = CPL_ABORT_NO_RST;
658 cxgbit_ofld_send(cdev, skb);
661 static int cxgbit_send_abort_req(struct cxgbit_sock *csk)
663 struct sk_buff *skb;
664 u32 len = roundup(sizeof(struct cpl_abort_req), 16);
666 pr_debug("%s: csk %p tid %u; state %d\n",
667 __func__, csk, csk->tid, csk->com.state);
669 __skb_queue_purge(&csk->txq);
671 if (!test_and_set_bit(CSK_TX_DATA_SENT, &csk->com.flags))
672 cxgbit_send_tx_flowc_wr(csk);
674 skb = __skb_dequeue(&csk->skbq);
675 cxgb_mk_abort_req(skb, len, csk->tid, csk->txq_idx,
676 csk->com.cdev, cxgbit_abort_arp_failure);
678 return cxgbit_l2t_send(csk->com.cdev, skb, csk->l2t);
681 static void
682 __cxgbit_abort_conn(struct cxgbit_sock *csk, struct sk_buff *skb)
684 __kfree_skb(skb);
686 if (csk->com.state != CSK_STATE_ESTABLISHED)
687 goto no_abort;
689 set_bit(CSK_ABORT_RPL_WAIT, &csk->com.flags);
690 csk->com.state = CSK_STATE_ABORTING;
692 cxgbit_send_abort_req(csk);
694 return;
696 no_abort:
697 cxgbit_wake_up(&csk->com.wr_wait, __func__, CPL_ERR_NONE);
698 cxgbit_put_csk(csk);
701 void cxgbit_abort_conn(struct cxgbit_sock *csk)
703 struct sk_buff *skb = alloc_skb(0, GFP_KERNEL | __GFP_NOFAIL);
705 cxgbit_get_csk(csk);
706 cxgbit_init_wr_wait(&csk->com.wr_wait);
708 spin_lock_bh(&csk->lock);
709 if (csk->lock_owner) {
710 cxgbit_skcb_rx_backlog_fn(skb) = __cxgbit_abort_conn;
711 __skb_queue_tail(&csk->backlogq, skb);
712 } else {
713 __cxgbit_abort_conn(csk, skb);
715 spin_unlock_bh(&csk->lock);
717 cxgbit_wait_for_reply(csk->com.cdev, &csk->com.wr_wait,
718 csk->tid, 600, __func__);
721 static void __cxgbit_free_conn(struct cxgbit_sock *csk)
723 struct iscsi_conn *conn = csk->conn;
724 bool release = false;
726 pr_debug("%s: state %d\n",
727 __func__, csk->com.state);
729 spin_lock_bh(&csk->lock);
730 switch (csk->com.state) {
731 case CSK_STATE_ESTABLISHED:
732 if (conn && (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT)) {
733 csk->com.state = CSK_STATE_CLOSING;
734 cxgbit_send_halfclose(csk);
735 } else {
736 csk->com.state = CSK_STATE_ABORTING;
737 cxgbit_send_abort_req(csk);
739 break;
740 case CSK_STATE_CLOSING:
741 csk->com.state = CSK_STATE_MORIBUND;
742 cxgbit_send_halfclose(csk);
743 break;
744 case CSK_STATE_DEAD:
745 release = true;
746 break;
747 default:
748 pr_err("%s: csk %p; state %d\n",
749 __func__, csk, csk->com.state);
751 spin_unlock_bh(&csk->lock);
753 if (release)
754 cxgbit_put_csk(csk);
757 void cxgbit_free_conn(struct iscsi_conn *conn)
759 __cxgbit_free_conn(conn->context);
762 static void cxgbit_set_emss(struct cxgbit_sock *csk, u16 opt)
764 csk->emss = csk->com.cdev->lldi.mtus[TCPOPT_MSS_G(opt)] -
765 ((csk->com.remote_addr.ss_family == AF_INET) ?
766 sizeof(struct iphdr) : sizeof(struct ipv6hdr)) -
767 sizeof(struct tcphdr);
768 csk->mss = csk->emss;
769 if (TCPOPT_TSTAMP_G(opt))
770 csk->emss -= round_up(TCPOLEN_TIMESTAMP, 4);
771 if (csk->emss < 128)
772 csk->emss = 128;
773 if (csk->emss & 7)
774 pr_info("Warning: misaligned mtu idx %u mss %u emss=%u\n",
775 TCPOPT_MSS_G(opt), csk->mss, csk->emss);
776 pr_debug("%s mss_idx %u mss %u emss=%u\n", __func__, TCPOPT_MSS_G(opt),
777 csk->mss, csk->emss);
780 static void cxgbit_free_skb(struct cxgbit_sock *csk)
782 struct sk_buff *skb;
784 __skb_queue_purge(&csk->txq);
785 __skb_queue_purge(&csk->rxq);
786 __skb_queue_purge(&csk->backlogq);
787 __skb_queue_purge(&csk->ppodq);
788 __skb_queue_purge(&csk->skbq);
790 while ((skb = cxgbit_sock_dequeue_wr(csk)))
791 kfree_skb(skb);
793 __kfree_skb(csk->lro_hskb);
796 void _cxgbit_free_csk(struct kref *kref)
798 struct cxgbit_sock *csk;
799 struct cxgbit_device *cdev;
801 csk = container_of(kref, struct cxgbit_sock, kref);
803 pr_debug("%s csk %p state %d\n", __func__, csk, csk->com.state);
805 if (csk->com.local_addr.ss_family == AF_INET6) {
806 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)
807 &csk->com.local_addr;
808 cxgb4_clip_release(csk->com.cdev->lldi.ports[0],
809 (const u32 *)
810 &sin6->sin6_addr.s6_addr, 1);
813 cxgb4_remove_tid(csk->com.cdev->lldi.tids, 0, csk->tid,
814 csk->com.local_addr.ss_family);
815 dst_release(csk->dst);
816 cxgb4_l2t_release(csk->l2t);
818 cdev = csk->com.cdev;
819 spin_lock_bh(&cdev->cskq.lock);
820 list_del(&csk->list);
821 spin_unlock_bh(&cdev->cskq.lock);
823 cxgbit_free_skb(csk);
824 cxgbit_put_cnp(csk->cnp);
825 cxgbit_put_cdev(cdev);
827 kfree(csk);
830 static void cxgbit_set_tcp_window(struct cxgbit_sock *csk, struct port_info *pi)
832 unsigned int linkspeed;
833 u8 scale;
835 linkspeed = pi->link_cfg.speed;
836 scale = linkspeed / SPEED_10000;
838 #define CXGBIT_10G_RCV_WIN (256 * 1024)
839 csk->rcv_win = CXGBIT_10G_RCV_WIN;
840 if (scale)
841 csk->rcv_win *= scale;
843 #define CXGBIT_10G_SND_WIN (256 * 1024)
844 csk->snd_win = CXGBIT_10G_SND_WIN;
845 if (scale)
846 csk->snd_win *= scale;
848 pr_debug("%s snd_win %d rcv_win %d\n",
849 __func__, csk->snd_win, csk->rcv_win);
852 #ifdef CONFIG_CHELSIO_T4_DCB
853 static u8 cxgbit_get_iscsi_dcb_state(struct net_device *ndev)
855 return ndev->dcbnl_ops->getstate(ndev);
858 static int cxgbit_select_priority(int pri_mask)
860 if (!pri_mask)
861 return 0;
863 return (ffs(pri_mask) - 1);
866 static u8 cxgbit_get_iscsi_dcb_priority(struct net_device *ndev, u16 local_port)
868 int ret;
869 u8 caps;
871 struct dcb_app iscsi_dcb_app = {
872 .protocol = local_port
875 ret = (int)ndev->dcbnl_ops->getcap(ndev, DCB_CAP_ATTR_DCBX, &caps);
877 if (ret)
878 return 0;
880 if (caps & DCB_CAP_DCBX_VER_IEEE) {
881 iscsi_dcb_app.selector = IEEE_8021QAZ_APP_SEL_ANY;
883 ret = dcb_ieee_getapp_mask(ndev, &iscsi_dcb_app);
885 } else if (caps & DCB_CAP_DCBX_VER_CEE) {
886 iscsi_dcb_app.selector = DCB_APP_IDTYPE_PORTNUM;
888 ret = dcb_getapp(ndev, &iscsi_dcb_app);
891 pr_info("iSCSI priority is set to %u\n", cxgbit_select_priority(ret));
893 return cxgbit_select_priority(ret);
895 #endif
897 static int
898 cxgbit_offload_init(struct cxgbit_sock *csk, int iptype, __u8 *peer_ip,
899 u16 local_port, struct dst_entry *dst,
900 struct cxgbit_device *cdev)
902 struct neighbour *n;
903 int ret, step;
904 struct net_device *ndev;
905 u16 rxq_idx, port_id;
906 #ifdef CONFIG_CHELSIO_T4_DCB
907 u8 priority = 0;
908 #endif
910 n = dst_neigh_lookup(dst, peer_ip);
911 if (!n)
912 return -ENODEV;
914 rcu_read_lock();
915 if (!(n->nud_state & NUD_VALID))
916 neigh_event_send(n, NULL);
918 ret = -ENOMEM;
919 if (n->dev->flags & IFF_LOOPBACK) {
920 if (iptype == 4)
921 ndev = cxgbit_ipv4_netdev(*(__be32 *)peer_ip);
922 else if (IS_ENABLED(CONFIG_IPV6))
923 ndev = cxgbit_ipv6_netdev((struct in6_addr *)peer_ip);
924 else
925 ndev = NULL;
927 if (!ndev) {
928 ret = -ENODEV;
929 goto out;
932 csk->l2t = cxgb4_l2t_get(cdev->lldi.l2t,
933 n, ndev, 0);
934 if (!csk->l2t)
935 goto out;
936 csk->mtu = ndev->mtu;
937 csk->tx_chan = cxgb4_port_chan(ndev);
938 csk->smac_idx =
939 ((struct port_info *)netdev_priv(ndev))->smt_idx;
940 step = cdev->lldi.ntxq /
941 cdev->lldi.nchan;
942 csk->txq_idx = cxgb4_port_idx(ndev) * step;
943 step = cdev->lldi.nrxq /
944 cdev->lldi.nchan;
945 csk->ctrlq_idx = cxgb4_port_idx(ndev);
946 csk->rss_qid = cdev->lldi.rxq_ids[
947 cxgb4_port_idx(ndev) * step];
948 csk->port_id = cxgb4_port_idx(ndev);
949 cxgbit_set_tcp_window(csk,
950 (struct port_info *)netdev_priv(ndev));
951 } else {
952 ndev = cxgbit_get_real_dev(n->dev);
953 if (!ndev) {
954 ret = -ENODEV;
955 goto out;
958 #ifdef CONFIG_CHELSIO_T4_DCB
959 if (cxgbit_get_iscsi_dcb_state(ndev))
960 priority = cxgbit_get_iscsi_dcb_priority(ndev,
961 local_port);
963 csk->dcb_priority = priority;
965 csk->l2t = cxgb4_l2t_get(cdev->lldi.l2t, n, ndev, priority);
966 #else
967 csk->l2t = cxgb4_l2t_get(cdev->lldi.l2t, n, ndev, 0);
968 #endif
969 if (!csk->l2t)
970 goto out;
971 port_id = cxgb4_port_idx(ndev);
972 csk->mtu = dst_mtu(dst);
973 csk->tx_chan = cxgb4_port_chan(ndev);
974 csk->smac_idx =
975 ((struct port_info *)netdev_priv(ndev))->smt_idx;
976 step = cdev->lldi.ntxq /
977 cdev->lldi.nports;
978 csk->txq_idx = (port_id * step) +
979 (cdev->selectq[port_id][0]++ % step);
980 csk->ctrlq_idx = cxgb4_port_idx(ndev);
981 step = cdev->lldi.nrxq /
982 cdev->lldi.nports;
983 rxq_idx = (port_id * step) +
984 (cdev->selectq[port_id][1]++ % step);
985 csk->rss_qid = cdev->lldi.rxq_ids[rxq_idx];
986 csk->port_id = port_id;
987 cxgbit_set_tcp_window(csk,
988 (struct port_info *)netdev_priv(ndev));
990 ret = 0;
991 out:
992 rcu_read_unlock();
993 neigh_release(n);
994 return ret;
997 int cxgbit_ofld_send(struct cxgbit_device *cdev, struct sk_buff *skb)
999 int ret = 0;
1001 if (!test_bit(CDEV_STATE_UP, &cdev->flags)) {
1002 kfree_skb(skb);
1003 pr_err("%s - device not up - dropping\n", __func__);
1004 return -EIO;
1007 ret = cxgb4_ofld_send(cdev->lldi.ports[0], skb);
1008 if (ret < 0)
1009 kfree_skb(skb);
1010 return ret < 0 ? ret : 0;
1013 static void cxgbit_release_tid(struct cxgbit_device *cdev, u32 tid)
1015 u32 len = roundup(sizeof(struct cpl_tid_release), 16);
1016 struct sk_buff *skb;
1018 skb = alloc_skb(len, GFP_ATOMIC);
1019 if (!skb)
1020 return;
1022 cxgb_mk_tid_release(skb, len, tid, 0);
1023 cxgbit_ofld_send(cdev, skb);
1027 cxgbit_l2t_send(struct cxgbit_device *cdev, struct sk_buff *skb,
1028 struct l2t_entry *l2e)
1030 int ret = 0;
1032 if (!test_bit(CDEV_STATE_UP, &cdev->flags)) {
1033 kfree_skb(skb);
1034 pr_err("%s - device not up - dropping\n", __func__);
1035 return -EIO;
1038 ret = cxgb4_l2t_send(cdev->lldi.ports[0], skb, l2e);
1039 if (ret < 0)
1040 kfree_skb(skb);
1041 return ret < 0 ? ret : 0;
1044 static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb)
1046 if (csk->com.state != CSK_STATE_ESTABLISHED) {
1047 __kfree_skb(skb);
1048 return;
1051 cxgbit_ofld_send(csk->com.cdev, skb);
1055 * CPL connection rx data ack: host ->
1056 * Send RX credits through an RX_DATA_ACK CPL message.
1057 * Returns the number of credits sent.
1059 int cxgbit_rx_data_ack(struct cxgbit_sock *csk)
1061 struct sk_buff *skb;
1062 u32 len = roundup(sizeof(struct cpl_rx_data_ack), 16);
1063 u32 credit_dack;
1065 skb = alloc_skb(len, GFP_KERNEL);
1066 if (!skb)
1067 return -1;
1069 credit_dack = RX_DACK_CHANGE_F | RX_DACK_MODE_V(1) |
1070 RX_CREDITS_V(csk->rx_credits);
1072 cxgb_mk_rx_data_ack(skb, len, csk->tid, csk->ctrlq_idx,
1073 credit_dack);
1075 csk->rx_credits = 0;
1077 spin_lock_bh(&csk->lock);
1078 if (csk->lock_owner) {
1079 cxgbit_skcb_rx_backlog_fn(skb) = cxgbit_send_rx_credits;
1080 __skb_queue_tail(&csk->backlogq, skb);
1081 spin_unlock_bh(&csk->lock);
1082 return 0;
1085 cxgbit_send_rx_credits(csk, skb);
1086 spin_unlock_bh(&csk->lock);
1088 return 0;
1091 #define FLOWC_WR_NPARAMS_MIN 9
1092 #define FLOWC_WR_NPARAMS_MAX 11
1093 static int cxgbit_alloc_csk_skb(struct cxgbit_sock *csk)
1095 struct sk_buff *skb;
1096 u32 len, flowclen;
1097 u8 i;
1099 flowclen = offsetof(struct fw_flowc_wr,
1100 mnemval[FLOWC_WR_NPARAMS_MAX]);
1102 len = max_t(u32, sizeof(struct cpl_abort_req),
1103 sizeof(struct cpl_abort_rpl));
1105 len = max(len, flowclen);
1106 len = roundup(len, 16);
1108 for (i = 0; i < 3; i++) {
1109 skb = alloc_skb(len, GFP_ATOMIC);
1110 if (!skb)
1111 goto out;
1112 __skb_queue_tail(&csk->skbq, skb);
1115 skb = alloc_skb(LRO_SKB_MIN_HEADROOM, GFP_ATOMIC);
1116 if (!skb)
1117 goto out;
1119 memset(skb->data, 0, LRO_SKB_MIN_HEADROOM);
1120 csk->lro_hskb = skb;
1122 return 0;
1123 out:
1124 __skb_queue_purge(&csk->skbq);
1125 return -ENOMEM;
1128 static void
1129 cxgbit_pass_accept_rpl(struct cxgbit_sock *csk, struct cpl_pass_accept_req *req)
1131 struct sk_buff *skb;
1132 const struct tcphdr *tcph;
1133 struct cpl_t5_pass_accept_rpl *rpl5;
1134 struct cxgb4_lld_info *lldi = &csk->com.cdev->lldi;
1135 unsigned int len = roundup(sizeof(*rpl5), 16);
1136 unsigned int mtu_idx;
1137 u64 opt0;
1138 u32 opt2, hlen;
1139 u32 wscale;
1140 u32 win;
1142 pr_debug("%s csk %p tid %u\n", __func__, csk, csk->tid);
1144 skb = alloc_skb(len, GFP_ATOMIC);
1145 if (!skb) {
1146 cxgbit_put_csk(csk);
1147 return;
1150 rpl5 = __skb_put_zero(skb, len);
1152 INIT_TP_WR(rpl5, csk->tid);
1153 OPCODE_TID(rpl5) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL,
1154 csk->tid));
1155 cxgb_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx,
1156 req->tcpopt.tstamp,
1157 (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
1158 wscale = cxgb_compute_wscale(csk->rcv_win);
1160 * Specify the largest window that will fit in opt0. The
1161 * remainder will be specified in the rx_data_ack.
1163 win = csk->rcv_win >> 10;
1164 if (win > RCV_BUFSIZ_M)
1165 win = RCV_BUFSIZ_M;
1166 opt0 = TCAM_BYPASS_F |
1167 WND_SCALE_V(wscale) |
1168 MSS_IDX_V(mtu_idx) |
1169 L2T_IDX_V(csk->l2t->idx) |
1170 TX_CHAN_V(csk->tx_chan) |
1171 SMAC_SEL_V(csk->smac_idx) |
1172 DSCP_V(csk->tos >> 2) |
1173 ULP_MODE_V(ULP_MODE_ISCSI) |
1174 RCV_BUFSIZ_V(win);
1176 opt2 = RX_CHANNEL_V(0) |
1177 RSS_QUEUE_VALID_F | RSS_QUEUE_V(csk->rss_qid);
1179 if (!is_t5(lldi->adapter_type))
1180 opt2 |= RX_FC_DISABLE_F;
1182 if (req->tcpopt.tstamp)
1183 opt2 |= TSTAMPS_EN_F;
1184 if (req->tcpopt.sack)
1185 opt2 |= SACK_EN_F;
1186 if (wscale)
1187 opt2 |= WND_SCALE_EN_F;
1189 hlen = ntohl(req->hdr_len);
1191 if (is_t5(lldi->adapter_type))
1192 tcph = (struct tcphdr *)((u8 *)(req + 1) +
1193 ETH_HDR_LEN_G(hlen) + IP_HDR_LEN_G(hlen));
1194 else
1195 tcph = (struct tcphdr *)((u8 *)(req + 1) +
1196 T6_ETH_HDR_LEN_G(hlen) + T6_IP_HDR_LEN_G(hlen));
1198 if (tcph->ece && tcph->cwr)
1199 opt2 |= CCTRL_ECN_V(1);
1201 opt2 |= RX_COALESCE_V(3);
1202 opt2 |= CONG_CNTRL_V(CONG_ALG_NEWRENO);
1204 opt2 |= T5_ISS_F;
1205 rpl5->iss = cpu_to_be32((prandom_u32() & ~7UL) - 1);
1207 opt2 |= T5_OPT_2_VALID_F;
1209 rpl5->opt0 = cpu_to_be64(opt0);
1210 rpl5->opt2 = cpu_to_be32(opt2);
1211 set_wr_txq(skb, CPL_PRIORITY_SETUP, csk->ctrlq_idx);
1212 t4_set_arp_err_handler(skb, csk, cxgbit_arp_failure_discard);
1213 cxgbit_l2t_send(csk->com.cdev, skb, csk->l2t);
1216 static void
1217 cxgbit_pass_accept_req(struct cxgbit_device *cdev, struct sk_buff *skb)
1219 struct cxgbit_sock *csk = NULL;
1220 struct cxgbit_np *cnp;
1221 struct cpl_pass_accept_req *req = cplhdr(skb);
1222 unsigned int stid = PASS_OPEN_TID_G(ntohl(req->tos_stid));
1223 struct tid_info *t = cdev->lldi.tids;
1224 unsigned int tid = GET_TID(req);
1225 u16 peer_mss = ntohs(req->tcpopt.mss);
1226 unsigned short hdrs;
1228 struct dst_entry *dst;
1229 __u8 local_ip[16], peer_ip[16];
1230 __be16 local_port, peer_port;
1231 int ret;
1232 int iptype;
1234 pr_debug("%s: cdev = %p; stid = %u; tid = %u\n",
1235 __func__, cdev, stid, tid);
1237 cnp = lookup_stid(t, stid);
1238 if (!cnp) {
1239 pr_err("%s connect request on invalid stid %d\n",
1240 __func__, stid);
1241 goto rel_skb;
1244 if (cnp->com.state != CSK_STATE_LISTEN) {
1245 pr_err("%s - listening parent not in CSK_STATE_LISTEN\n",
1246 __func__);
1247 goto reject;
1250 csk = lookup_tid(t, tid);
1251 if (csk) {
1252 pr_err("%s csk not null tid %u\n",
1253 __func__, tid);
1254 goto rel_skb;
1257 cxgb_get_4tuple(req, cdev->lldi.adapter_type, &iptype, local_ip,
1258 peer_ip, &local_port, &peer_port);
1260 /* Find output route */
1261 if (iptype == 4) {
1262 pr_debug("%s parent sock %p tid %u laddr %pI4 raddr %pI4 "
1263 "lport %d rport %d peer_mss %d\n"
1264 , __func__, cnp, tid,
1265 local_ip, peer_ip, ntohs(local_port),
1266 ntohs(peer_port), peer_mss);
1267 dst = cxgb_find_route(&cdev->lldi, cxgbit_get_real_dev,
1268 *(__be32 *)local_ip,
1269 *(__be32 *)peer_ip,
1270 local_port, peer_port,
1271 PASS_OPEN_TOS_G(ntohl(req->tos_stid)));
1272 } else {
1273 pr_debug("%s parent sock %p tid %u laddr %pI6 raddr %pI6 "
1274 "lport %d rport %d peer_mss %d\n"
1275 , __func__, cnp, tid,
1276 local_ip, peer_ip, ntohs(local_port),
1277 ntohs(peer_port), peer_mss);
1278 dst = cxgb_find_route6(&cdev->lldi, cxgbit_get_real_dev,
1279 local_ip, peer_ip,
1280 local_port, peer_port,
1281 PASS_OPEN_TOS_G(ntohl(req->tos_stid)),
1282 ((struct sockaddr_in6 *)
1283 &cnp->com.local_addr)->sin6_scope_id);
1285 if (!dst) {
1286 pr_err("%s - failed to find dst entry!\n",
1287 __func__);
1288 goto reject;
1291 csk = kzalloc(sizeof(*csk), GFP_ATOMIC);
1292 if (!csk) {
1293 dst_release(dst);
1294 goto rel_skb;
1297 ret = cxgbit_offload_init(csk, iptype, peer_ip, ntohs(local_port),
1298 dst, cdev);
1299 if (ret) {
1300 pr_err("%s - failed to allocate l2t entry!\n",
1301 __func__);
1302 dst_release(dst);
1303 kfree(csk);
1304 goto reject;
1307 kref_init(&csk->kref);
1308 init_completion(&csk->com.wr_wait.completion);
1310 INIT_LIST_HEAD(&csk->accept_node);
1312 hdrs = (iptype == 4 ? sizeof(struct iphdr) : sizeof(struct ipv6hdr)) +
1313 sizeof(struct tcphdr) + (req->tcpopt.tstamp ? 12 : 0);
1314 if (peer_mss && csk->mtu > (peer_mss + hdrs))
1315 csk->mtu = peer_mss + hdrs;
1317 csk->com.state = CSK_STATE_CONNECTING;
1318 csk->com.cdev = cdev;
1319 csk->cnp = cnp;
1320 csk->tos = PASS_OPEN_TOS_G(ntohl(req->tos_stid));
1321 csk->dst = dst;
1322 csk->tid = tid;
1323 csk->wr_cred = cdev->lldi.wr_cred -
1324 DIV_ROUND_UP(sizeof(struct cpl_abort_req), 16);
1325 csk->wr_max_cred = csk->wr_cred;
1326 csk->wr_una_cred = 0;
1328 if (iptype == 4) {
1329 struct sockaddr_in *sin = (struct sockaddr_in *)
1330 &csk->com.local_addr;
1331 sin->sin_family = AF_INET;
1332 sin->sin_port = local_port;
1333 sin->sin_addr.s_addr = *(__be32 *)local_ip;
1335 sin = (struct sockaddr_in *)&csk->com.remote_addr;
1336 sin->sin_family = AF_INET;
1337 sin->sin_port = peer_port;
1338 sin->sin_addr.s_addr = *(__be32 *)peer_ip;
1339 } else {
1340 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)
1341 &csk->com.local_addr;
1343 sin6->sin6_family = PF_INET6;
1344 sin6->sin6_port = local_port;
1345 memcpy(sin6->sin6_addr.s6_addr, local_ip, 16);
1346 cxgb4_clip_get(cdev->lldi.ports[0],
1347 (const u32 *)&sin6->sin6_addr.s6_addr,
1350 sin6 = (struct sockaddr_in6 *)&csk->com.remote_addr;
1351 sin6->sin6_family = PF_INET6;
1352 sin6->sin6_port = peer_port;
1353 memcpy(sin6->sin6_addr.s6_addr, peer_ip, 16);
1356 skb_queue_head_init(&csk->rxq);
1357 skb_queue_head_init(&csk->txq);
1358 skb_queue_head_init(&csk->ppodq);
1359 skb_queue_head_init(&csk->backlogq);
1360 skb_queue_head_init(&csk->skbq);
1361 cxgbit_sock_reset_wr_list(csk);
1362 spin_lock_init(&csk->lock);
1363 init_waitqueue_head(&csk->waitq);
1364 init_waitqueue_head(&csk->ack_waitq);
1365 csk->lock_owner = false;
1367 if (cxgbit_alloc_csk_skb(csk)) {
1368 dst_release(dst);
1369 kfree(csk);
1370 goto rel_skb;
1373 cxgbit_get_cnp(cnp);
1374 cxgbit_get_cdev(cdev);
1376 spin_lock(&cdev->cskq.lock);
1377 list_add_tail(&csk->list, &cdev->cskq.list);
1378 spin_unlock(&cdev->cskq.lock);
1379 cxgb4_insert_tid(t, csk, tid, csk->com.local_addr.ss_family);
1380 cxgbit_pass_accept_rpl(csk, req);
1381 goto rel_skb;
1383 reject:
1384 cxgbit_release_tid(cdev, tid);
1385 rel_skb:
1386 __kfree_skb(skb);
1389 static u32
1390 cxgbit_tx_flowc_wr_credits(struct cxgbit_sock *csk, u32 *nparamsp,
1391 u32 *flowclenp)
1393 u32 nparams, flowclen16, flowclen;
1395 nparams = FLOWC_WR_NPARAMS_MIN;
1397 if (csk->snd_wscale)
1398 nparams++;
1400 #ifdef CONFIG_CHELSIO_T4_DCB
1401 nparams++;
1402 #endif
1403 flowclen = offsetof(struct fw_flowc_wr, mnemval[nparams]);
1404 flowclen16 = DIV_ROUND_UP(flowclen, 16);
1405 flowclen = flowclen16 * 16;
1407 * Return the number of 16-byte credits used by the flowc request.
1408 * Pass back the nparams and actual flowc length if requested.
1410 if (nparamsp)
1411 *nparamsp = nparams;
1412 if (flowclenp)
1413 *flowclenp = flowclen;
1414 return flowclen16;
1417 u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *csk)
1419 struct cxgbit_device *cdev = csk->com.cdev;
1420 struct fw_flowc_wr *flowc;
1421 u32 nparams, flowclen16, flowclen;
1422 struct sk_buff *skb;
1423 u8 index;
1425 #ifdef CONFIG_CHELSIO_T4_DCB
1426 u16 vlan = ((struct l2t_entry *)csk->l2t)->vlan;
1427 #endif
1429 flowclen16 = cxgbit_tx_flowc_wr_credits(csk, &nparams, &flowclen);
1431 skb = __skb_dequeue(&csk->skbq);
1432 flowc = __skb_put_zero(skb, flowclen);
1434 flowc->op_to_nparams = cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR) |
1435 FW_FLOWC_WR_NPARAMS_V(nparams));
1436 flowc->flowid_len16 = cpu_to_be32(FW_WR_LEN16_V(flowclen16) |
1437 FW_WR_FLOWID_V(csk->tid));
1438 flowc->mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
1439 flowc->mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN_V
1440 (csk->com.cdev->lldi.pf));
1441 flowc->mnemval[1].mnemonic = FW_FLOWC_MNEM_CH;
1442 flowc->mnemval[1].val = cpu_to_be32(csk->tx_chan);
1443 flowc->mnemval[2].mnemonic = FW_FLOWC_MNEM_PORT;
1444 flowc->mnemval[2].val = cpu_to_be32(csk->tx_chan);
1445 flowc->mnemval[3].mnemonic = FW_FLOWC_MNEM_IQID;
1446 flowc->mnemval[3].val = cpu_to_be32(csk->rss_qid);
1447 flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDNXT;
1448 flowc->mnemval[4].val = cpu_to_be32(csk->snd_nxt);
1449 flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_RCVNXT;
1450 flowc->mnemval[5].val = cpu_to_be32(csk->rcv_nxt);
1451 flowc->mnemval[6].mnemonic = FW_FLOWC_MNEM_SNDBUF;
1452 flowc->mnemval[6].val = cpu_to_be32(csk->snd_win);
1453 flowc->mnemval[7].mnemonic = FW_FLOWC_MNEM_MSS;
1454 flowc->mnemval[7].val = cpu_to_be32(csk->emss);
1456 flowc->mnemval[8].mnemonic = FW_FLOWC_MNEM_TXDATAPLEN_MAX;
1457 if (test_bit(CDEV_ISO_ENABLE, &cdev->flags))
1458 flowc->mnemval[8].val = cpu_to_be32(CXGBIT_MAX_ISO_PAYLOAD);
1459 else
1460 flowc->mnemval[8].val = cpu_to_be32(16384);
1462 index = 9;
1464 if (csk->snd_wscale) {
1465 flowc->mnemval[index].mnemonic = FW_FLOWC_MNEM_RCV_SCALE;
1466 flowc->mnemval[index].val = cpu_to_be32(csk->snd_wscale);
1467 index++;
1470 #ifdef CONFIG_CHELSIO_T4_DCB
1471 flowc->mnemval[index].mnemonic = FW_FLOWC_MNEM_DCBPRIO;
1472 if (vlan == VLAN_NONE) {
1473 pr_warn("csk %u without VLAN Tag on DCB Link\n", csk->tid);
1474 flowc->mnemval[index].val = cpu_to_be32(0);
1475 } else
1476 flowc->mnemval[index].val = cpu_to_be32(
1477 (vlan & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT);
1478 #endif
1480 pr_debug("%s: csk %p; tx_chan = %u; rss_qid = %u; snd_seq = %u;"
1481 " rcv_seq = %u; snd_win = %u; emss = %u\n",
1482 __func__, csk, csk->tx_chan, csk->rss_qid, csk->snd_nxt,
1483 csk->rcv_nxt, csk->snd_win, csk->emss);
1484 set_wr_txq(skb, CPL_PRIORITY_DATA, csk->txq_idx);
1485 cxgbit_ofld_send(csk->com.cdev, skb);
1486 return flowclen16;
1489 int cxgbit_setup_conn_digest(struct cxgbit_sock *csk)
1491 struct sk_buff *skb;
1492 struct cpl_set_tcb_field *req;
1493 u8 hcrc = csk->submode & CXGBIT_SUBMODE_HCRC;
1494 u8 dcrc = csk->submode & CXGBIT_SUBMODE_DCRC;
1495 unsigned int len = roundup(sizeof(*req), 16);
1496 int ret;
1498 skb = alloc_skb(len, GFP_KERNEL);
1499 if (!skb)
1500 return -ENOMEM;
1502 /* set up ulp submode */
1503 req = __skb_put_zero(skb, len);
1505 INIT_TP_WR(req, csk->tid);
1506 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, csk->tid));
1507 req->reply_ctrl = htons(NO_REPLY_V(0) | QUEUENO_V(csk->rss_qid));
1508 req->word_cookie = htons(0);
1509 req->mask = cpu_to_be64(0x3 << 4);
1510 req->val = cpu_to_be64(((hcrc ? ULP_CRC_HEADER : 0) |
1511 (dcrc ? ULP_CRC_DATA : 0)) << 4);
1512 set_wr_txq(skb, CPL_PRIORITY_CONTROL, csk->ctrlq_idx);
1514 cxgbit_get_csk(csk);
1515 cxgbit_init_wr_wait(&csk->com.wr_wait);
1517 cxgbit_ofld_send(csk->com.cdev, skb);
1519 ret = cxgbit_wait_for_reply(csk->com.cdev,
1520 &csk->com.wr_wait,
1521 csk->tid, 5, __func__);
1522 if (ret)
1523 return -1;
1525 return 0;
1528 int cxgbit_setup_conn_pgidx(struct cxgbit_sock *csk, u32 pg_idx)
1530 struct sk_buff *skb;
1531 struct cpl_set_tcb_field *req;
1532 unsigned int len = roundup(sizeof(*req), 16);
1533 int ret;
1535 skb = alloc_skb(len, GFP_KERNEL);
1536 if (!skb)
1537 return -ENOMEM;
1539 req = __skb_put_zero(skb, len);
1541 INIT_TP_WR(req, csk->tid);
1542 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, csk->tid));
1543 req->reply_ctrl = htons(NO_REPLY_V(0) | QUEUENO_V(csk->rss_qid));
1544 req->word_cookie = htons(0);
1545 req->mask = cpu_to_be64(0x3 << 8);
1546 req->val = cpu_to_be64(pg_idx << 8);
1547 set_wr_txq(skb, CPL_PRIORITY_CONTROL, csk->ctrlq_idx);
1549 cxgbit_get_csk(csk);
1550 cxgbit_init_wr_wait(&csk->com.wr_wait);
1552 cxgbit_ofld_send(csk->com.cdev, skb);
1554 ret = cxgbit_wait_for_reply(csk->com.cdev,
1555 &csk->com.wr_wait,
1556 csk->tid, 5, __func__);
1557 if (ret)
1558 return -1;
1560 return 0;
1563 static void
1564 cxgbit_pass_open_rpl(struct cxgbit_device *cdev, struct sk_buff *skb)
1566 struct cpl_pass_open_rpl *rpl = cplhdr(skb);
1567 struct tid_info *t = cdev->lldi.tids;
1568 unsigned int stid = GET_TID(rpl);
1569 struct cxgbit_np *cnp = lookup_stid(t, stid);
1571 pr_debug("%s: cnp = %p; stid = %u; status = %d\n",
1572 __func__, cnp, stid, rpl->status);
1574 if (!cnp) {
1575 pr_info("%s stid %d lookup failure\n", __func__, stid);
1576 goto rel_skb;
1579 cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status);
1580 cxgbit_put_cnp(cnp);
1581 rel_skb:
1582 __kfree_skb(skb);
1585 static void
1586 cxgbit_close_listsrv_rpl(struct cxgbit_device *cdev, struct sk_buff *skb)
1588 struct cpl_close_listsvr_rpl *rpl = cplhdr(skb);
1589 struct tid_info *t = cdev->lldi.tids;
1590 unsigned int stid = GET_TID(rpl);
1591 struct cxgbit_np *cnp = lookup_stid(t, stid);
1593 pr_debug("%s: cnp = %p; stid = %u; status = %d\n",
1594 __func__, cnp, stid, rpl->status);
1596 if (!cnp) {
1597 pr_info("%s stid %d lookup failure\n", __func__, stid);
1598 goto rel_skb;
1601 cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status);
1602 cxgbit_put_cnp(cnp);
1603 rel_skb:
1604 __kfree_skb(skb);
1607 static void
1608 cxgbit_pass_establish(struct cxgbit_device *cdev, struct sk_buff *skb)
1610 struct cpl_pass_establish *req = cplhdr(skb);
1611 struct tid_info *t = cdev->lldi.tids;
1612 unsigned int tid = GET_TID(req);
1613 struct cxgbit_sock *csk;
1614 struct cxgbit_np *cnp;
1615 u16 tcp_opt = be16_to_cpu(req->tcp_opt);
1616 u32 snd_isn = be32_to_cpu(req->snd_isn);
1617 u32 rcv_isn = be32_to_cpu(req->rcv_isn);
1619 csk = lookup_tid(t, tid);
1620 if (unlikely(!csk)) {
1621 pr_err("can't find connection for tid %u.\n", tid);
1622 goto rel_skb;
1624 cnp = csk->cnp;
1626 pr_debug("%s: csk %p; tid %u; cnp %p\n",
1627 __func__, csk, tid, cnp);
1629 csk->write_seq = snd_isn;
1630 csk->snd_una = snd_isn;
1631 csk->snd_nxt = snd_isn;
1633 csk->rcv_nxt = rcv_isn;
1635 if (csk->rcv_win > (RCV_BUFSIZ_M << 10))
1636 csk->rx_credits = (csk->rcv_win - (RCV_BUFSIZ_M << 10));
1638 csk->snd_wscale = TCPOPT_SND_WSCALE_G(tcp_opt);
1639 cxgbit_set_emss(csk, tcp_opt);
1640 dst_confirm(csk->dst);
1641 csk->com.state = CSK_STATE_ESTABLISHED;
1642 spin_lock_bh(&cnp->np_accept_lock);
1643 list_add_tail(&csk->accept_node, &cnp->np_accept_list);
1644 spin_unlock_bh(&cnp->np_accept_lock);
1645 complete(&cnp->accept_comp);
1646 rel_skb:
1647 __kfree_skb(skb);
1650 static void cxgbit_queue_rx_skb(struct cxgbit_sock *csk, struct sk_buff *skb)
1652 cxgbit_skcb_flags(skb) = 0;
1653 spin_lock_bh(&csk->rxq.lock);
1654 __skb_queue_tail(&csk->rxq, skb);
1655 spin_unlock_bh(&csk->rxq.lock);
1656 wake_up(&csk->waitq);
1659 static void cxgbit_peer_close(struct cxgbit_sock *csk, struct sk_buff *skb)
1661 pr_debug("%s: csk %p; tid %u; state %d\n",
1662 __func__, csk, csk->tid, csk->com.state);
1664 switch (csk->com.state) {
1665 case CSK_STATE_ESTABLISHED:
1666 csk->com.state = CSK_STATE_CLOSING;
1667 cxgbit_queue_rx_skb(csk, skb);
1668 return;
1669 case CSK_STATE_CLOSING:
1670 /* simultaneous close */
1671 csk->com.state = CSK_STATE_MORIBUND;
1672 break;
1673 case CSK_STATE_MORIBUND:
1674 csk->com.state = CSK_STATE_DEAD;
1675 cxgbit_put_csk(csk);
1676 break;
1677 case CSK_STATE_ABORTING:
1678 break;
1679 default:
1680 pr_info("%s: cpl_peer_close in bad state %d\n",
1681 __func__, csk->com.state);
1684 __kfree_skb(skb);
1687 static void cxgbit_close_con_rpl(struct cxgbit_sock *csk, struct sk_buff *skb)
1689 pr_debug("%s: csk %p; tid %u; state %d\n",
1690 __func__, csk, csk->tid, csk->com.state);
1692 switch (csk->com.state) {
1693 case CSK_STATE_CLOSING:
1694 csk->com.state = CSK_STATE_MORIBUND;
1695 break;
1696 case CSK_STATE_MORIBUND:
1697 csk->com.state = CSK_STATE_DEAD;
1698 cxgbit_put_csk(csk);
1699 break;
1700 case CSK_STATE_ABORTING:
1701 case CSK_STATE_DEAD:
1702 break;
1703 default:
1704 pr_info("%s: cpl_close_con_rpl in bad state %d\n",
1705 __func__, csk->com.state);
1708 __kfree_skb(skb);
1711 static void cxgbit_abort_req_rss(struct cxgbit_sock *csk, struct sk_buff *skb)
1713 struct cpl_abort_req_rss *hdr = cplhdr(skb);
1714 unsigned int tid = GET_TID(hdr);
1715 struct sk_buff *rpl_skb;
1716 bool release = false;
1717 bool wakeup_thread = false;
1718 u32 len = roundup(sizeof(struct cpl_abort_rpl), 16);
1720 pr_debug("%s: csk %p; tid %u; state %d\n",
1721 __func__, csk, tid, csk->com.state);
1723 if (cxgb_is_neg_adv(hdr->status)) {
1724 pr_err("%s: got neg advise %d on tid %u\n",
1725 __func__, hdr->status, tid);
1726 goto rel_skb;
1729 switch (csk->com.state) {
1730 case CSK_STATE_CONNECTING:
1731 case CSK_STATE_MORIBUND:
1732 csk->com.state = CSK_STATE_DEAD;
1733 release = true;
1734 break;
1735 case CSK_STATE_ESTABLISHED:
1736 csk->com.state = CSK_STATE_DEAD;
1737 wakeup_thread = true;
1738 break;
1739 case CSK_STATE_CLOSING:
1740 csk->com.state = CSK_STATE_DEAD;
1741 if (!csk->conn)
1742 release = true;
1743 break;
1744 case CSK_STATE_ABORTING:
1745 break;
1746 default:
1747 pr_info("%s: cpl_abort_req_rss in bad state %d\n",
1748 __func__, csk->com.state);
1749 csk->com.state = CSK_STATE_DEAD;
1752 __skb_queue_purge(&csk->txq);
1754 if (!test_and_set_bit(CSK_TX_DATA_SENT, &csk->com.flags))
1755 cxgbit_send_tx_flowc_wr(csk);
1757 rpl_skb = __skb_dequeue(&csk->skbq);
1759 cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
1760 cxgbit_ofld_send(csk->com.cdev, rpl_skb);
1762 if (wakeup_thread) {
1763 cxgbit_queue_rx_skb(csk, skb);
1764 return;
1767 if (release)
1768 cxgbit_put_csk(csk);
1769 rel_skb:
1770 __kfree_skb(skb);
1773 static void cxgbit_abort_rpl_rss(struct cxgbit_sock *csk, struct sk_buff *skb)
1775 struct cpl_abort_rpl_rss *rpl = cplhdr(skb);
1777 pr_debug("%s: csk %p; tid %u; state %d\n",
1778 __func__, csk, csk->tid, csk->com.state);
1780 switch (csk->com.state) {
1781 case CSK_STATE_ABORTING:
1782 csk->com.state = CSK_STATE_DEAD;
1783 if (test_bit(CSK_ABORT_RPL_WAIT, &csk->com.flags))
1784 cxgbit_wake_up(&csk->com.wr_wait, __func__,
1785 rpl->status);
1786 cxgbit_put_csk(csk);
1787 break;
1788 default:
1789 pr_info("%s: cpl_abort_rpl_rss in state %d\n",
1790 __func__, csk->com.state);
1793 __kfree_skb(skb);
1796 static bool cxgbit_credit_err(const struct cxgbit_sock *csk)
1798 const struct sk_buff *skb = csk->wr_pending_head;
1799 u32 credit = 0;
1801 if (unlikely(csk->wr_cred > csk->wr_max_cred)) {
1802 pr_err("csk 0x%p, tid %u, credit %u > %u\n",
1803 csk, csk->tid, csk->wr_cred, csk->wr_max_cred);
1804 return true;
1807 while (skb) {
1808 credit += (__force u32)skb->csum;
1809 skb = cxgbit_skcb_tx_wr_next(skb);
1812 if (unlikely((csk->wr_cred + credit) != csk->wr_max_cred)) {
1813 pr_err("csk 0x%p, tid %u, credit %u + %u != %u.\n",
1814 csk, csk->tid, csk->wr_cred,
1815 credit, csk->wr_max_cred);
1817 return true;
1820 return false;
1823 static void cxgbit_fw4_ack(struct cxgbit_sock *csk, struct sk_buff *skb)
1825 struct cpl_fw4_ack *rpl = (struct cpl_fw4_ack *)cplhdr(skb);
1826 u32 credits = rpl->credits;
1827 u32 snd_una = ntohl(rpl->snd_una);
1829 csk->wr_cred += credits;
1830 if (csk->wr_una_cred > (csk->wr_max_cred - csk->wr_cred))
1831 csk->wr_una_cred = csk->wr_max_cred - csk->wr_cred;
1833 while (credits) {
1834 struct sk_buff *p = cxgbit_sock_peek_wr(csk);
1835 const u32 csum = (__force u32)p->csum;
1837 if (unlikely(!p)) {
1838 pr_err("csk 0x%p,%u, cr %u,%u+%u, empty.\n",
1839 csk, csk->tid, credits,
1840 csk->wr_cred, csk->wr_una_cred);
1841 break;
1844 if (unlikely(credits < csum)) {
1845 pr_warn("csk 0x%p,%u, cr %u,%u+%u, < %u.\n",
1846 csk, csk->tid,
1847 credits, csk->wr_cred, csk->wr_una_cred,
1848 csum);
1849 p->csum = (__force __wsum)(csum - credits);
1850 break;
1853 cxgbit_sock_dequeue_wr(csk);
1854 credits -= csum;
1855 kfree_skb(p);
1858 if (unlikely(cxgbit_credit_err(csk))) {
1859 cxgbit_queue_rx_skb(csk, skb);
1860 return;
1863 if (rpl->seq_vld & CPL_FW4_ACK_FLAGS_SEQVAL) {
1864 if (unlikely(before(snd_una, csk->snd_una))) {
1865 pr_warn("csk 0x%p,%u, snd_una %u/%u.",
1866 csk, csk->tid, snd_una,
1867 csk->snd_una);
1868 goto rel_skb;
1871 if (csk->snd_una != snd_una) {
1872 csk->snd_una = snd_una;
1873 dst_confirm(csk->dst);
1874 wake_up(&csk->ack_waitq);
1878 if (skb_queue_len(&csk->txq))
1879 cxgbit_push_tx_frames(csk);
1881 rel_skb:
1882 __kfree_skb(skb);
1885 static void cxgbit_set_tcb_rpl(struct cxgbit_device *cdev, struct sk_buff *skb)
1887 struct cxgbit_sock *csk;
1888 struct cpl_set_tcb_rpl *rpl = (struct cpl_set_tcb_rpl *)skb->data;
1889 unsigned int tid = GET_TID(rpl);
1890 struct cxgb4_lld_info *lldi = &cdev->lldi;
1891 struct tid_info *t = lldi->tids;
1893 csk = lookup_tid(t, tid);
1894 if (unlikely(!csk)) {
1895 pr_err("can't find connection for tid %u.\n", tid);
1896 goto rel_skb;
1897 } else {
1898 cxgbit_wake_up(&csk->com.wr_wait, __func__, rpl->status);
1901 cxgbit_put_csk(csk);
1902 rel_skb:
1903 __kfree_skb(skb);
1906 static void cxgbit_rx_data(struct cxgbit_device *cdev, struct sk_buff *skb)
1908 struct cxgbit_sock *csk;
1909 struct cpl_rx_data *cpl = cplhdr(skb);
1910 unsigned int tid = GET_TID(cpl);
1911 struct cxgb4_lld_info *lldi = &cdev->lldi;
1912 struct tid_info *t = lldi->tids;
1914 csk = lookup_tid(t, tid);
1915 if (unlikely(!csk)) {
1916 pr_err("can't find conn. for tid %u.\n", tid);
1917 goto rel_skb;
1920 cxgbit_queue_rx_skb(csk, skb);
1921 return;
1922 rel_skb:
1923 __kfree_skb(skb);
1926 static void
1927 __cxgbit_process_rx_cpl(struct cxgbit_sock *csk, struct sk_buff *skb)
1929 spin_lock(&csk->lock);
1930 if (csk->lock_owner) {
1931 __skb_queue_tail(&csk->backlogq, skb);
1932 spin_unlock(&csk->lock);
1933 return;
1936 cxgbit_skcb_rx_backlog_fn(skb)(csk, skb);
1937 spin_unlock(&csk->lock);
1940 static void cxgbit_process_rx_cpl(struct cxgbit_sock *csk, struct sk_buff *skb)
1942 cxgbit_get_csk(csk);
1943 __cxgbit_process_rx_cpl(csk, skb);
1944 cxgbit_put_csk(csk);
1947 static void cxgbit_rx_cpl(struct cxgbit_device *cdev, struct sk_buff *skb)
1949 struct cxgbit_sock *csk;
1950 struct cpl_tx_data *cpl = cplhdr(skb);
1951 struct cxgb4_lld_info *lldi = &cdev->lldi;
1952 struct tid_info *t = lldi->tids;
1953 unsigned int tid = GET_TID(cpl);
1954 u8 opcode = cxgbit_skcb_rx_opcode(skb);
1955 bool ref = true;
1957 switch (opcode) {
1958 case CPL_FW4_ACK:
1959 cxgbit_skcb_rx_backlog_fn(skb) = cxgbit_fw4_ack;
1960 ref = false;
1961 break;
1962 case CPL_PEER_CLOSE:
1963 cxgbit_skcb_rx_backlog_fn(skb) = cxgbit_peer_close;
1964 break;
1965 case CPL_CLOSE_CON_RPL:
1966 cxgbit_skcb_rx_backlog_fn(skb) = cxgbit_close_con_rpl;
1967 break;
1968 case CPL_ABORT_REQ_RSS:
1969 cxgbit_skcb_rx_backlog_fn(skb) = cxgbit_abort_req_rss;
1970 break;
1971 case CPL_ABORT_RPL_RSS:
1972 cxgbit_skcb_rx_backlog_fn(skb) = cxgbit_abort_rpl_rss;
1973 break;
1974 default:
1975 goto rel_skb;
1978 csk = lookup_tid(t, tid);
1979 if (unlikely(!csk)) {
1980 pr_err("can't find conn. for tid %u.\n", tid);
1981 goto rel_skb;
1984 if (ref)
1985 cxgbit_process_rx_cpl(csk, skb);
1986 else
1987 __cxgbit_process_rx_cpl(csk, skb);
1989 return;
1990 rel_skb:
1991 __kfree_skb(skb);
1994 cxgbit_cplhandler_func cxgbit_cplhandlers[NUM_CPL_CMDS] = {
1995 [CPL_PASS_OPEN_RPL] = cxgbit_pass_open_rpl,
1996 [CPL_CLOSE_LISTSRV_RPL] = cxgbit_close_listsrv_rpl,
1997 [CPL_PASS_ACCEPT_REQ] = cxgbit_pass_accept_req,
1998 [CPL_PASS_ESTABLISH] = cxgbit_pass_establish,
1999 [CPL_SET_TCB_RPL] = cxgbit_set_tcb_rpl,
2000 [CPL_RX_DATA] = cxgbit_rx_data,
2001 [CPL_FW4_ACK] = cxgbit_rx_cpl,
2002 [CPL_PEER_CLOSE] = cxgbit_rx_cpl,
2003 [CPL_CLOSE_CON_RPL] = cxgbit_rx_cpl,
2004 [CPL_ABORT_REQ_RSS] = cxgbit_rx_cpl,
2005 [CPL_ABORT_RPL_RSS] = cxgbit_rx_cpl,